/* ============================================================
 * App header (fixed) + user menu dropdown
 * Fixe car évite le rebond iOS au scroll (effect natif Safari)
 * ============================================================ */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    padding: calc(var(--safe-top) + 3px) max(var(--space-4), var(--safe-right)) 3px max(var(--space-4), var(--safe-left));
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--header-h);
}
/* Bouton Connexion (anonyme) : reste positionné à droite via absolute */
.app-header > .btn {
    position: absolute;
    right: max(var(--space-4), var(--safe-right));
    top: 50%;
    transform: translateY(-50%);
}

/* Lien notifications (user logué) : icône cloche en absolute right.
   Pattern standard des social media (Twitter, Instagram, Letterboxd).
   Le badge non-lu se superpose en absolute via .nav-badge. */
.app-header__notifs {
    position: absolute;
    right: max(var(--space-4), var(--safe-right));
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--ink);
    text-decoration: none;
    transition: background 120ms;
}
.app-header__notifs:hover { background: var(--bg-paper); text-decoration: none; }
.app-header__notifs:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--violet);
}
.app-header__notifs .nav-badge {
    position: absolute;
    top: 2px;
    right: 2px;
}

.brand {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.brand:hover { text-decoration: none; }

/* Logo icône (PNG transparent). 40×40 pour matcher l'avatar agrandi. */
.brand-mark {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    object-fit: contain;
    display: block;
}
.brand-name {
    line-height: 1;
}

/* Logo LivreComment (mark inline SVG). Traits en ink, ligne du haut violette,
   via tokens -> s'adapte clair/sombre. Remplace l'ancien PNG logo-mark. */
.logo-mark { display: block; flex-shrink: 0; }
.logo-mark__ln { stroke: var(--ink); }
.logo-mark__accent { stroke: var(--violet); }

.app-avatar {
    width: 38px;
    height: 38px;
    background: var(--violet-soft);
    color: var(--violet);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: 999px;
    flex-shrink: 0;
    text-decoration: none;
    overflow: hidden;
}
.app-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* === User menu dropdown === */

.user-menu { position: relative; }

.user-menu__trigger {
    list-style: none;
    cursor: pointer;
    border-radius: 999px;
    transition: box-shadow 120ms;
}
.user-menu__trigger::-webkit-details-marker,
.user-menu__trigger::marker {
    display: none;
    content: '';
}
.user-menu__trigger:hover {
    box-shadow: 0 0 0 2px var(--violet-soft);
}
.user-menu[open] .user-menu__trigger {
    box-shadow: 0 0 0 2px var(--violet);
}

.user-menu__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    min-width: 220px;
    padding: 4px;
    z-index: 40;
}

.user-menu__identity {
    padding: 10px 12px 8px;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.user-menu__identity strong {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--ink);
}
.user-menu__identity span {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 1px;
}

.user-menu__divider {
    height: 1px;
    background: var(--border);
    margin: 4px -4px;
}

.user-menu__item,
.user-menu__logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    text-align: left;
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    min-height: 40px;
}
.user-menu__item:hover,
.user-menu__logout:hover {
    background: var(--bg-paper);
    text-decoration: none;
}
.user-menu__item--muted {
    color: var(--subtle);
    cursor: not-allowed;
}
.user-menu__item--muted:hover {
    background: transparent;
}
.user-menu__item svg,
.user-menu__logout svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--muted);
}
.user-menu__logout {
    color: var(--ink);
}
.user-menu__logout-form {
    margin: 0;
}

/* Header contextuel — utilisé sur son propre profil (pattern Instagram).
   [logo gauche] [@username centré] [burger droite] */
.app-header--profile {
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}
.app-header__brand {
    position: absolute;
    left: max(var(--space-4), var(--safe-left));
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}
.app-header__brand img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    display: block;
}
.app-header__handle {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.app-header__actions {
    position: absolute;
    right: max(var(--space-4), var(--safe-right));
    top: 50%;
    transform: translateY(-50%);
}

/* Header contextuel des pages detail : [< Nom-de-retour] a gauche, logo
   centre, cloche a droite. Le logo reste au centre (repere de marque), le
   retour prend la place a gauche (plus de bouton retour separe sous le
   header). */
.app-header--detail {
    justify-content: flex-start;
    gap: 0;
}
.app-header__logo-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}
.app-header__logo-center img { width: 50px; height: 50px; object-fit: contain; display: block; }
.app-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: calc(50% - 40px); /* n'atteint pas le logo centre */
    min-height: 44px;
    color: var(--ink);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.app-back svg { flex-shrink: 0; margin-left: -5px; }
.app-back__title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-back:hover { text-decoration: none; }
.app-back:active { opacity: 0.6; }
.app-back:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--violet); border-radius: var(--radius-sm); }

/* Desktop : la nav (bottom-nav) remonte en haut à droite du header et
   chevauchait la cloche de notif (home) et le burger (profil), tous deux en
   absolute top-right. On les fait descendre JUSTE SOUS le header, alignés à
   droite sous la nav : plus de collision. */
@media (min-width: 900px) {
    .app-header__notifs,
    .app-header--profile .app-header__actions {
        position: fixed;
        top: calc(var(--header-h) + var(--space-2));
        right: max(var(--space-4), var(--safe-right));
        transform: none;
        z-index: 25;
    }
}
