/* ================================================================
   SITE MENU (Components/Layout/MainLayout.razor)

   Built to be read at a glance: big labels, high contrast, icons
   everyone knows (Material Symbols Rounded). The coffee lives in the
   colours and in one detail: the current page is a solid amber tab
   with an espresso drop hanging under it.
   Sizes are in px on purpose: the site's root font is 14px, so rem
   values would shrink the menu.

   Desktop (> 1024px): one full-width bar under the header.
   Phone/tablet (<= 1024px): tab bar at the bottom of the screen;
   "Menu" opens #bar-sheet, a native popover listing every page.
   ================================================================ */

:root {
    --nav-bg:          #15100c;
    --nav-bg-2:        #100c09;
    --nav-line:        rgba(245, 158, 11, 0.28);
    --nav-text:        #f1e8db;
    --nav-text-dim:    #cbbdab;
    --nav-icon:        #fbbf24;
    --nav-hover:       rgba(245, 158, 11, 0.14);
    --nav-amber:       linear-gradient(180deg, #fcc94d 0%, #f59e0b 55%, #e08a06 100%);
    --nav-amber-solid: #f59e0b;
    --nav-drop:        #e08a06;
    --nav-on-amber:    #1d1006;
    --nav-glow:        0 8px 22px -8px rgba(245, 158, 11, 0.75);
    --nav-sheet-bg:    #17110d;
    --nav-card:        #211913;
    --nav-card-line:   #3a2c20;
    --nav-dock-h:      0px;
}

html.theme-light {
    --nav-bg:          #fffaf2;
    --nav-bg-2:        #fbf3e6;
    --nav-line:        #e8d4b4;
    --nav-text:        #24170d;
    --nav-text-dim:    #4e3a2a;
    --nav-icon:        #b45309;
    --nav-hover:       rgba(196, 122, 10, 0.12);
    --nav-amber:       linear-gradient(180deg, #fbbf24 0%, #f59e0b 55%, #e08a06 100%);
    --nav-glow:        0 8px 18px -8px rgba(196, 122, 10, 0.6);
    --nav-sheet-bg:    #fffaf2;
    --nav-card:        #ffffff;
    --nav-card-line:   #ead9bf;
}

/* ── Icons ─────────────────────────────────────────────────────── */
.ms {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    display: inline-block;
    flex: none;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
    /* the glyph name is text until the font arrives; never let it widen the bar */
    width: 1em;
    overflow: hidden;
}

/* ── Desktop bar ───────────────────────────────────────────────── */
.bar-menu {
    position: relative;
    z-index: 5;
    background: linear-gradient(180deg, var(--nav-bg), var(--nav-bg-2));
    border-bottom: 1px solid var(--nav-line);
    box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.9);
}
html.theme-light .bar-menu { box-shadow: 0 10px 24px -20px rgba(90, 55, 20, 0.5); }

.bar-rail {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 20px;
}

.bar-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    border-radius: 12px;
    color: var(--nav-text);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.005em;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.bar-item .ms { font-size: 23px; color: var(--nav-icon); transition: color 0.18s ease; }
.bar-item:hover {
    background: var(--nav-hover);
    color: var(--nav-text);
    text-decoration: none;
}
.bar-item:hover .ms { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.bar-item:focus-visible {
    outline: 2px solid var(--nav-amber-solid);
    outline-offset: 2px;
}

/* current page: a solid amber tab... */
.bar-item.is-active {
    color: var(--nav-on-amber);
    font-weight: 700;
    background: var(--nav-amber);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), var(--nav-glow);
}
.bar-item.is-active .ms {
    color: var(--nav-on-amber);
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}
/* ...with an espresso drop hanging under it */
.bar-item.is-active::after {
    content: "";
    position: absolute;
    left: 50%;
    top: calc(100% - 4px);
    width: 11px;
    height: 11px;
    margin-left: -5.5px;
    border-radius: 0 50% 50% 50%;
    background: var(--nav-drop);
    transform: rotate(45deg);
    animation: nav-drip 0.6s cubic-bezier(.3, 1.4, .5, 1) both;
}
@keyframes nav-drip {
    from { transform: translateY(-8px) rotate(45deg) scale(0.4); opacity: 0; }
    to   { transform: rotate(45deg); opacity: 1; }
}

@media (max-width: 1300px) {
    .bar-rail { gap: 2px; padding: 9px 14px; }
    .bar-item { padding: 10px 13px; font-size: 15px; gap: 7px; }
    .bar-item .ms { font-size: 21px; }
}
@media (max-width: 1140px) {
    .bar-item { padding: 10px 11px; }
}

/* ── Phone / tablet tab bar ────────────────────────────────────── */
.bar-dock { display: none; }

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    padding: 8px 2px 6px;
    border: 0;
    background: none;
    color: var(--nav-text-dim);
    font-family: var(--font-display);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.dock-item:hover { color: var(--nav-text); text-decoration: none; }
.dock-item:focus-visible { outline: 2px solid var(--nav-amber-solid); outline-offset: -3px; border-radius: 14px; }

.dock-pill {
    display: grid;
    place-items: center;
    width: 60px;
    height: 34px;
    border-radius: 17px;
    transition: background 0.2s ease, transform 0.15s ease;
}
.dock-pill .ms { font-size: 27px; color: var(--nav-text); }
.dock-item:active .dock-pill { transform: scale(0.92); }

.dock-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.1;
}

.dock-item.is-active { color: var(--nav-icon); }
.dock-item.is-active .dock-label { font-weight: 800; }
.dock-item.is-active .dock-pill {
    background: var(--nav-amber);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), var(--nav-glow);
}
.dock-item.is-active .dock-pill .ms {
    color: var(--nav-on-amber);
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

/* ── Menu sheet (popover) ──────────────────────────────────────── */
.bar-sheet {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: 600px;
    height: auto;
    max-height: min(90dvh, 820px);
    margin: 0 auto;
    padding: 8px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-top: 2px solid var(--nav-amber-solid);
    border-radius: 24px 24px 0 0;
    color: var(--nav-text);
    background: var(--nav-sheet-bg);
    box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.55);
    transform: translateY(0);
    transition:
        transform 0.32s cubic-bezier(.2, .85, .25, 1),
        display 0.32s allow-discrete,
        overlay 0.32s allow-discrete;
}
.bar-sheet:not(:popover-open) { transform: translateY(104%); }
@starting-style {
    .bar-sheet:popover-open { transform: translateY(104%); }
}
.bar-sheet::backdrop {
    background: rgba(8, 5, 2, 0.62);
    opacity: 1;
    transition: opacity 0.28s ease, display 0.28s allow-discrete, overlay 0.28s allow-discrete;
}
.bar-sheet:not(:popover-open)::backdrop { opacity: 0; }
@starting-style {
    .bar-sheet:popover-open::backdrop { opacity: 0; }
}
html.theme-light .bar-sheet { box-shadow: 0 -20px 50px rgba(70, 40, 15, 0.25); }
html.theme-light .bar-sheet::backdrop { background: rgba(50, 30, 12, 0.4); }

.sheet-grip {
    width: 44px;
    height: 5px;
    margin: 4px auto 10px;
    border-radius: 5px;
    background: var(--nav-card-line);
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px 12px;
}
.sheet-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--nav-text);
}
.sheet-close {
    display: grid;
    place-items: center;
    flex: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--nav-card-line);
    border-radius: 50%;
    background: var(--nav-card);
    color: var(--nav-text);
    cursor: pointer;
}
.sheet-close:hover { border-color: var(--nav-amber-solid); }

.sheet-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}
@media (min-width: 560px) {
    .sheet-list { grid-template-columns: 1fr 1fr; }
}

.sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    padding: 10px 14px 10px 10px;
    border: 1px solid var(--nav-card-line);
    border-radius: 16px;
    background: var(--nav-card);
    color: var(--nav-text);
    text-decoration: none;
    transition: border-color 0.18s ease, transform 0.12s ease;
}
.sheet-item:hover { border-color: var(--nav-amber-solid); color: var(--nav-text); text-decoration: none; }
.sheet-item:active { transform: scale(0.98); }
.sheet-item:focus-visible { outline: 2px solid var(--nav-amber-solid); outline-offset: 2px; }

.sheet-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--nav-hover);
}
.sheet-icon .ms { font-size: 26px; color: var(--nav-icon); }

.sheet-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sheet-name {
    font-family: var(--font-display);
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.2;
}
.sheet-desc {
    font-size: 13.5px;
    line-height: 1.3;
    color: var(--nav-text-dim);
}

.sheet-item.is-active {
    border: 2px solid var(--nav-amber-solid);
    padding: 9px 13px 9px 9px;
}
.sheet-item.is-active .sheet-icon {
    background: var(--nav-amber);
    box-shadow: var(--nav-glow);
}
.sheet-item.is-active .sheet-icon .ms {
    color: var(--nav-on-amber);
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

.bar-sheet:popover-open .sheet-list li {
    animation: nav-sheet-in 0.36s cubic-bezier(.2, .85, .25, 1) both;
    animation-delay: calc(50ms + var(--i, 0) * 25ms);
}
@keyframes nav-sheet-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* ── Phone / tablet layout ─────────────────────────────────────── */
@media (max-width: 1024px) {
    :root { --nav-dock-h: calc(68px + env(safe-area-inset-bottom, 0px)); }

    .bar-menu { display: none; }

    .bar-dock {
        position: fixed;
        z-index: 90;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        padding: 2px max(6px, calc((100vw - 640px) / 2)) env(safe-area-inset-bottom, 0px);
        background: var(--nav-bg);
        border-top: 1px solid var(--nav-line);
        box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.45);
    }
    html.theme-light .bar-dock { box-shadow: 0 -8px 24px rgba(90, 55, 20, 0.12); }

    /* keep the end of every page clear of the tab bar */
    body { padding-bottom: var(--nav-dock-h); }

    /* the dialing tool's floating "recommend" bar sits on top of the tab bar */
    .taste-recommend-bar--armed {
        bottom: var(--nav-dock-h);
        padding-bottom: 0.7rem;
    }
    body:has(.taste-recommend-bar--armed) { padding-bottom: calc(var(--nav-dock-h) + 5.25rem); }
}

/* ── Compact phone header: brand left, actions right ───────────
   A grid, because the account group (AppHeader.razor) comes after the utilities in
   the markup but belongs under the mark here: a localized "Sign in" or a user row
   next to three buttons would not fit a 360px screen on one line.
   The first column may shrink (minmax(0, 1fr)), so a long user row gives way
   before the buttons do. */
@media (max-width: 860px) {
    .app-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand actions"
            "user  actions";
        align-items: center;
        gap: 0 0.6rem;
        padding: 0.55rem 0.85rem;
    }
    .app-header-brand { grid-area: brand; min-width: 0; }
    /* 5px under the mark: clear of the brand link's focus ring (css/brand.css) */
    .app-header-user { grid-area: user; margin-top: 5px; gap: 6px; }
    .header-auth-btn { padding: 3px 10px; font-size: 0.7rem; }
    /* the name leads the row, under the start of the mark */
    .header-username-link { order: -1; max-width: 104px; }
    .app-header .app-header-actions {
        grid-area: actions;
        flex-wrap: nowrap;
        justify-content: flex-end;
        gap: 6px;
    }
    .app-header .app-header-actions .support-btn,
    .app-header .app-header-actions .settings-btn,
    .app-header .app-header-actions .rec-nav-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        font-size: 1.15rem;
    }
    .app-header .app-header-actions .support-btn svg,
    .app-header .app-header-actions .settings-btn svg,
    .app-header .app-header-actions .rec-nav-btn svg { width: 19px; height: 19px; }
}

@media (max-width: 479px) {
    .sheet-list { gap: 6px; }
    .sheet-item { padding: 8px 12px 8px 8px; gap: 12px; }
    .sheet-item.is-active { padding: 7px 11px 7px 7px; }
    .sheet-icon { width: 42px; height: 42px; }
}

@media (max-width: 350px) {
    .dock-pill { width: 50px; }
    .dock-label { font-size: 11px; }
}

@media print {
    .bar-menu,
    .bar-dock,
    .bar-sheet { display: none !important; }
    body { padding-bottom: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
    .bar-item.is-active::after,
    .bar-sheet:popover-open .sheet-list li { animation: none; }
    .bar-sheet,
    .bar-sheet::backdrop { transition: none; }
}

/* ── Header on phones: mark + account row ────────────────────────────────────
   The mark and the account row share the first grid column (see "Compact phone header"
   above), and that column may give way to the buttons. A long localized row (name, bell,
   admin, "Se déconnecter") once pushed the gear button off the screen; now the username
   ellipsizes first, and below 420px Sign out becomes an icon (its label stays as hidden
   text for screen readers).
   The lockup ends exactly at the ring, so the account row keeps 5px clear of it: room for the
   link's focus ring (css/brand.css), and the unread badge rises 1px, not 4px, above the bell. */
@media (max-width: 860px) {
    .app-header-user { min-width: 0; }
    .app-header-user .header-bell-count { top: -1px; }
}
.header-logout-icon { display: none; }
@media (max-width: 419px) {
    .header-logout-btn { padding: 4px 7px; }
    .header-logout-text {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .header-logout-icon { display: block; width: 14px; height: 14px; }
    [dir="rtl"] .header-logout-icon { transform: scaleX(-1); }
}
@media (max-width: 350px) {
    .app-header { column-gap: 0.45rem; padding-left: 0.7rem; padding-right: 0.7rem; }
    .app-header-user { gap: 4px; }
    .app-header .app-header-actions { gap: 4px; }
}
@media (max-width: 330px) {
    .app-header .app-header-actions .support-btn,
    .app-header .app-header-actions .settings-btn,
    .app-header .app-header-actions .rec-nav-btn { width: 34px; height: 34px; min-width: 34px; }
}
