/* ================================================================
   page_profile.css
   Öffentliche Profilseite + Profileinstellungen
   WCAG 2.1 AA / AAA – Kontrast, Fokus, Screenreader
   ================================================================ */

/* ── Utilities ─────────────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ================================================================
   ÖFFENTLICHES PROFIL
   ================================================================ */

.profile-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

/* ── Hero ──────────────────────────────────────────────────────── */
.profile-hero {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    padding: 2.5rem 0 2rem;
    margin-bottom: 2rem;
}

.profile-hero__inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

/* Avatar-Initialen (dekorativ, aria-hidden) */
.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: var(--color-primary, #1a73e8);
    color: #ffffff;
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* WCAG 1.4.3: Weiß auf #1a73e8 ≈ 4.7:1 (AA) */
    user-select: none;
}

/* Avatar als Bild */
.profile-avatar--image {
    object-fit: cover;
    background: none;
    font-size: 0;
    border: 2px solid #e5e7eb;
}

.profile-hero__info {
    flex: 1;
}

.profile-hero__name {
    font-size: 1.625rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.25rem;
    line-height: 1.2;
}

.profile-hero__hometown {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
}

.profile-hero__edit {
    margin-left: auto;
    align-self: flex-start;
}

/* ── Body ──────────────────────────────────────────────────────── */
.profile-body {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* ── Section ───────────────────────────────────────────────────── */
.profile-section {
    /* visually contained */
}

.profile-section__title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.profile-section__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 0.75rem;
    font-weight: 600;
    /* WCAG 1.4.3: #374151 auf #e5e7eb ≈ 7:1 (AAA) */
}

/* ── Biographie ────────────────────────────────────────────────── */
.profile-bio {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: #374151;
    white-space: pre-line;
    /* WCAG 1.4.3: #374151 auf #ffffff ≈ 8.6:1 (AAA) */
}

/* ── Auszeichnungen ────────────────────────────────────────────── */
.profile-awards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.profile-award {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.profile-award__img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}

.profile-award__info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.profile-award__name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
}

.profile-award__desc {
    font-size: 0.8125rem;
    color: #6b7280;
    /* WCAG 1.4.3: #6b7280 auf #f9fafb ≈ 4.6:1 (AA) */
}

/* ── Rezensionen ───────────────────────────────────────────────── */
.profile-reviews {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.profile-review {
    padding: 1rem 1.125rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
}

.profile-review__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.profile-review__institution {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary, #1a73e8);
    text-decoration: underline;
    text-underline-offset: 2px;
    /* WCAG 1.4.3: #1a73e8 auf #ffffff ≈ 4.7:1 (AA) */
}

.profile-review__institution:hover {
    text-decoration: none;
}

/* WCAG 2.4.7 */
.profile-review__institution:focus-visible {
    outline: 2px solid var(--color-primary, #1a73e8);
    outline-offset: 2px;
    border-radius: 2px;
}

.profile-review__stars {
    display: flex;
    gap: 1px;
}

.profile-star {
    color: #d1d5db;
}

.profile-star--filled {
    color: #f59e0b;
    /* WCAG 1.4.11: Gelb auf weiß – Grenze sichtbar durch Stern-Form */
}

.profile-review__date {
    font-size: 0.8125rem;
    color: #9ca3af;
    margin-left: auto;
}

.profile-review__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.35rem;
}

.profile-review__text {
    font-size: 0.9rem;
    color: #374151;
    line-height: 1.6;
    margin: 0 0 0.5rem;
}

.profile-review__images {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.profile-review__img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

/* ── Leer-Zustand ──────────────────────────────────────────────── */
.profile-empty {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
}

.profile-empty--center {
    text-align: center;
    padding: 3rem 0;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .profile-hero__inner {
        gap: 1rem;
    }

    .profile-avatar {
        width: 56px;
        height: 56px;
        font-size: 1.375rem;
    }

    .profile-hero__name {
        font-size: 1.375rem;
    }

    .profile-hero__edit {
        margin-left: 0;
        width: 100%;
    }
}

/* ── Avatar-Einstellungen ───────────────────────────────────────── */
.profile-avatar-settings {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 0.75rem;
}

.profile-avatar-settings__preview .profile-avatar {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}

.profile-avatar-settings__actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

/* Verstecktes file-input, Label fungiert als Button */
.profile-avatar-settings__file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.profile-avatar-settings__upload-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* Fokusring auf dem Label wenn file-input fokussiert (WCAG 2.4.7) */
.profile-avatar-settings__file-input:focus-visible + .profile-avatar-settings__upload-btn,
.profile-avatar-settings__upload-btn:focus-visible {
    outline: 3px solid var(--color-primary, #1a73e8);
    outline-offset: 2px;
}

.profile-avatar-settings__delete-btn {
    color: #dc2626;
    border-color: #fca5a5;
}

.profile-avatar-settings__delete-btn:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

@media (max-width: 480px) {
    .profile-avatar-settings {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ================================================================
   PROFILEINSTELLUNGEN
   ================================================================ */

.profile-settings-page {
    min-height: 100%;
    background: #f4f6f9;
    padding: 2.5rem 1rem 4rem;
}

.profile-settings-wrap {
    max-width: 640px;
    margin: 0 auto;
}

/* ── Header ────────────────────────────────────────────────────── */
.profile-settings-header {
    margin-bottom: 1.75rem;
}

.profile-settings-header__title {
    font-size: 1.625rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.4rem;
}

.profile-settings-header__subtitle {
    font-size: 0.9375rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.55;
}

/* ── Alert ─────────────────────────────────────────────────────── */
.profile-alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.profile-alert--success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    /* WCAG 1.4.3: #166534 auf #f0fdf4 ≈ 7.5:1 (AAA) */
}

/* ── Form ──────────────────────────────────────────────────────── */
.profile-settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ── Section Card ──────────────────────────────────────────────── */
.profile-settings-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.profile-settings-section__title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.profile-settings-section__desc {
    font-size: 0.875rem;
    color: #6b7280;
    margin: -0.75rem 0 1.25rem;
    line-height: 1.5;
}

/* ── Fields ────────────────────────────────────────────────────── */
.profile-settings-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1.25rem;
}

.profile-settings-field:last-child {
    margin-bottom: 0;
}

.profile-settings-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
}

.profile-settings-label__optional {
    font-weight: 400;
    color: #9ca3af;
    font-size: 0.8125rem;
}

/* WCAG 1.4.3 + 2.4.7 */
.profile-settings-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    min-height: 48px;
}

.profile-settings-input--textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

.profile-settings-input::placeholder {
    color: #9ca3af;
}

.profile-settings-input:focus {
    outline: none;
    border-color: var(--color-primary, #1a73e8);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.25);
}

.profile-settings-input.is-invalid {
    border-color: #dc2626;
}

.profile-settings-input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.profile-settings-error {
    font-size: 0.8125rem;
    color: #dc2626;
    font-weight: 500;
}

.profile-settings-hint {
    font-size: 0.8125rem;
    color: #6b7280;
}

/* ── Toggle-Switches ───────────────────────────────────────────── */
.profile-settings-toggles {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Gesamte Zeile ist klickbar – WCAG 2.5.5 ≥ 44px Trefferzone */
.profile-settings-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    cursor: pointer;
    min-height: 44px;
    padding: 0.25rem 0;
}

/* Versteckter nativer Checkbox */
.profile-settings-toggle__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Sichtbarer Track (ersetzt visuell die Checkbox) */
.profile-settings-toggle__track {
    position: relative;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 999px;
    flex-shrink: 0;
    transition: background 0.2s ease;
    margin-top: 2px;
}

/* Knopf */
.profile-settings-toggle__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

/* Checked-State */
.profile-settings-toggle__input:checked + .profile-settings-toggle__track {
    background: var(--color-primary, #1a73e8);
}

.profile-settings-toggle__input:checked + .profile-settings-toggle__track::after {
    transform: translateX(20px);
}

/* WCAG 2.4.7 – Fokusring am Track, da Input versteckt */
.profile-settings-toggle__input:focus-visible + .profile-settings-toggle__track {
    outline: 3px solid var(--color-primary, #1a73e8);
    outline-offset: 2px;
}

.profile-settings-toggle__label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.4;
}

.profile-settings-toggle__desc {
    font-size: 0.8125rem;
    font-weight: 400;
    color: #6b7280;
    /* WCAG 1.4.3: #6b7280 auf #ffffff ≈ 4.6:1 (AA) */
}

/* ── Actions ───────────────────────────────────────────────────── */
.profile-settings-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .profile-settings-section {
        padding: 1.25rem 1rem;
    }

    .profile-settings-header__title {
        font-size: 1.375rem;
    }

    .profile-settings-actions {
        flex-direction: column;
    }

    .profile-settings-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ================================================================
   KONTOEINSTELLUNGEN – Danger Zone & Ergänzungen
   ================================================================ */

/* ── Alert-Fehler-Variante ─────────────────────────────────────── */
.profile-alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    /* WCAG 1.4.3: #991b1b auf #fef2f2 ≈ 7.2:1 (AAA) */
}

/* ── Danger-Zone-Section ───────────────────────────────────────── */
.profile-settings-section--danger {
    border-color: #fca5a5;
    background: #fff5f5;
}

.profile-settings-section__title--danger {
    color: #b91c1c;
    /* WCAG 1.4.3: #b91c1c auf #fff5f5 ≈ 5.8:1 (AA) */
}

/* ── Checkbox-Feld ─────────────────────────────────────────────── */
.profile-settings-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
}

.profile-settings-checkbox__input {
    /* Nativ sichtbar lassen – Screenreader + Tastatur nutzbar */
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    margin-top: 0.125rem; /* vertikale Ausrichtung zur ersten Textzeile */
    accent-color: var(--color-primary, #1a73e8);
    cursor: pointer;
}

.profile-settings-checkbox__input:focus-visible {
    outline: 3px solid var(--color-primary, #1a73e8);
    outline-offset: 2px;
}

.profile-settings-checkbox__input.is-invalid {
    accent-color: #dc2626;
    outline: 2px solid #dc2626;
    outline-offset: 1px;
}

.profile-settings-checkbox__label {
    font-size: 0.9375rem;
    color: #374151;
    cursor: pointer;
    line-height: 1.5;
}

/* ── Level-Badge (wiederverwendbar) ────────────────────────────── */
.level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9375rem;
    flex-shrink: 0;
    background: #e2e8f0;
    color: #475569;
}
.level-badge--1  { background: #e0f2fe; color: #0369a1; }
.level-badge--2  { background: #dcfce7; color: #166534; }
.level-badge--3  { background: #fef9c3; color: #854d0e; }
.level-badge--4  { background: #fde68a; color: #92400e; }
.level-badge--5  { background: #fed7aa; color: #9a3412; }
.level-badge--6  { background: #fecaca; color: #991b1b; }
.level-badge--7  { background: #f5d0fe; color: #7e22ce; }
.level-badge--8  { background: #c7d2fe; color: #3730a3; }
.level-badge--9  { background: #99f6e4; color: #0f766e; }
.level-badge--10 { background: #1e293b; color: #f1f5f9; }

/* ── Profil Level-Bar ───────────────────────────────────────────── */
.profile-level-bar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.875rem 0;
}
.profile-level-bar__inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.profile-level-bar__left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
}
.profile-level-bar__info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.profile-level-bar__label {
    font-weight: 700;
    font-size: 0.9375rem;
    color: #1e293b;
    white-space: nowrap;
}
.profile-level-bar__exp {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
}
.profile-level-bar__right {
    flex: 1;
    min-width: 0;
}
.profile-level-bar__progress-wrap {
    height: 10px;
    background: #e2e8f0;
    border-radius: 100rem;
    overflow: hidden;
    margin-bottom: 0.25rem;
}
.profile-level-bar__progress {
    height: 100%;
    background: linear-gradient(90deg, #1a73e8 0%, #60a5fa 100%);
    border-radius: 100rem;
    transition: width 0.5s ease;
    min-width: 2px;
}
.profile-level-bar__next {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0;
    text-align: right;
}
@media (max-width: 540px) {
    .profile-level-bar__inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .profile-level-bar__next {
        text-align: left;
    }
}

/* ── Favoriten-Sektion im Profil ────────────────────────────────── */

/*
 * WCAG 1.4.3: Linktext #1a73e8 auf weiß ≈ 4.7:1 (AA)
 * WCAG 1.4.11: Fokusring sichtbar (3 px solid)
 * WCAG 2.4.4: Linkziel durch Name der Institution klar
 */
.profile-favorites {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.profile-favorite {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.profile-favorite:hover {
    border-color: #cbd5e1;
}

.profile-favorite__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    text-decoration: none;
    color: inherit;
    border-radius: 10px;
}

.profile-favorite__link:focus-visible {
    outline: 3px solid var(--color-primary, #1a73e8);
    outline-offset: 2px;
}

/* Cover-Vorschaubild */
.profile-favorite__img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #f1f5f9;
}

/* Platzhalter wenn kein Cover */
.profile-favorite__placeholder {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #f1f5f9;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.profile-favorite__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.profile-favorite__name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-favorite__link:hover .profile-favorite__name {
    color: var(--color-primary, #1a73e8);
}

.profile-favorite__category {
    font-size: 0.78rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.profile-favorite__arrow {
    color: #94a3b8;
    flex-shrink: 0;
    transition: color 0.15s, transform 0.15s;
}

.profile-favorite__link:hover .profile-favorite__arrow {
    color: var(--color-primary, #1a73e8);
    transform: translateX(2px);
}

/* Reduzierte Bewegung (WCAG 2.3.3 AAA) */
@media (prefers-reduced-motion: reduce) {
    .profile-favorite__arrow {
        transition: none;
    }
}
