/* ============================================================
 * user_ui — Header chrome (with the bell and the balance display).
 * ============================================================
 *
 * Styles extracted VERBATIM from the landing-page mockup per
 * the mockup-verbatim canonical-class rule (`.head`, `.brand`,
 * `nav.primary`, `.spacer`). The mockup's
 * `.hamburger` is not used — the mobile-menu trigger is the
 * `.mobile-menus-edge` arrow tab owned by menus/mobile_menus.css.
 *
 * Section-local class additions only — never replaces or
 * shadows canonical classes that other stylesheets also use:
 *   - `.user-pill`         section-local (logged-in placeholder)
 *   - `.user-pill-avatar`  section-local (img inside the pill)
 *   - `.bell`              section-local (bell button)
 *   - `.bell-badge`        section-local (unread count)
 *   - `.user-pill-wrap`    section-local (positions the avatar badge)
 *   - `.user-pill-badge`   section-local (site-inventory unit count)
 *   - `.user-pill-status`  section-local (live region for that count)
 *   - `.hdr-balance*`      section-local (balance display)
 *   - `.lang-switch`, `.lang-switch-toggle`, `.lang-switch-flag`,
 *     `.lang-switch-caret`, `.lang-switch-menu`
 *                          section-local (header language switch;
 *                          its option rows are shared — see
 *                          css/shared/language_options.css)
 *
 * Colours come from tokens.css, so the light/dark theme flip is
 * automatic, except the two badge text colours (`.bell-badge`
 * #fff, `.user-pill-badge` #1B2230): they sit on fixed brand
 * fills that do not flip with the theme.
 *
 * Loaded by ui/user/templates/user_ui/shared/base.html as part
 * of the global cascade.
 * ============================================================ */

/* ---- Sticky header bar ---- */
/* The bar paints the designer-supplied diagonal-stripe strip
   (img/user_ui/shared/header-bg-{dark,light}.webp, 1249×89).
   `cover` — the strip fills the full bar (`contain` renders the
   strip too small at the 64px bar height). The image's baked-in rounded corners scale off the
   visible edges under cover; `var(--bg)` remains the paint
   fallback while the image loads / if it 404s. Theme pattern
   mirrors help.css / about.css:
   dark image is the default, `html[data-theme="light"]` swaps in the
   light variant — see documentation/user/IMAGE_USAGE.md. */
header.site {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg) url("../../../img/user_ui/shared/header-bg-dark.3ed15739eee4.webp") center / cover no-repeat;
    border-bottom: 1px solid var(--line-2);
}
html[data-theme="light"] header.site {
    background-image: url("../../../img/user_ui/shared/header-bg-light.3ace33e5b067.webp");
}

/* ---- Inner flex row (uses .wrap from base.css for max-width + padding) ---- */
.head {
    display: flex;
    align-items: center;
    gap: 28px;
    height: 64px;
}

/* ---- Brand lockup ---- */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}
.brand img.brand-mark {
    height: 38px;
    width: auto;
    display: block;
}

/* ---- Primary nav ---- */
nav.primary {
    display: flex;
    gap: 28px;
    margin-left: 24px;
}
nav.primary a {
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: var(--font-head);
}
nav.primary a:hover {
    color: var(--orange);
}
nav.primary a[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Flex spacer pushing the right cluster to the edge ---- */
.head .spacer {
    flex: 1;
}

/* ---- Bell (notification button) ---- */
.bell {
    position: relative;
}

/* ---- Bell badge (unread count) ---- */
.bell-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--orange);
    color: #fff;
    border: 2px solid var(--bg);
    border-radius: 9px;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 10px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.bell-badge[hidden] {
    display: none;
}

/* ---- Avatar inventory badge (site-inventory unit count) ----
   Same geometry as `.bell-badge`, gold with dark text so the two counts
   read as different things side by side. It sits on `.user-pill-wrap`,
   not inside `.user-pill`, because the pill clips to its circle
   (`overflow: hidden`). Click-through: the badge overlaps the avatar's
   corner, and a click there still has to reach the pill. The dark text
   is a fixed value because the gold does not flip with the theme. */
.user-pill-wrap {
    position: relative;
    display: inline-flex;
    flex: none;
}
.user-pill-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--gold);
    color: #1B2230;
    border: 2px solid var(--bg);
    border-radius: 9px;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 10px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    pointer-events: none;
}
.user-pill-badge[hidden] {
    display: none;
}
/* Live region announcing a count change after paint. Visually hidden but
   kept in the accessibility tree (the site has no shared sr-only class). */
.user-pill-status {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ============================================================
 * Header balance (live total spendable balance).
 * ============================================================
 *
 * A bordered pill carrying a small uppercase label + the
 * spendable total, plus a `+` tile that opens the quick-deposit
 * modal (balance.js). Token-driven so both themes work
 * without per-theme rules. SiteBalance (balance.js) rewrites
 * `[data-balance-amount]` text on `balance.updated`.
 */
.hdr-balance {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 5px 6px 5px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    background: var(--surface);
}
.hdr-balance-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}
.hdr-balance-label {
    font-family: var(--font-head);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--text-mute);
}
.hdr-balance-amount {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
/* `+` tile — neutral surface (matches the mockup's grey button),
   not orange, so it does not compete with the page's primary CTAs. */
.hdr-balance-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    flex: none;
}
.hdr-balance-add svg {
    width: 16px;
    height: 16px;
}
.hdr-balance-add:not(:disabled):hover {
    background: var(--bg-2);
}
.hdr-balance-add:not(:disabled):focus-visible {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
}
/* Unused: no template or script ever sets `disabled` on the `+`
   tile, so this rule and the `:not(:disabled)` qualifiers above
   match nothing. The correct fix is to delete
   `.hdr-balance-add:disabled` and drop the `:not(:disabled)`
   qualifiers — a stylesheet change of its own, not a comment edit. */
.hdr-balance-add:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

/* ---- User pill (logged-in placeholder) ---- */
.user-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
}
.user-pill:hover {
    box-shadow: 0 0 0 2px var(--orange-3);
}
.user-pill:focus-visible {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
}
.user-pill-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

/* ============================================================
 * Language switch (LanguageSwitch, ge/language_switch).
 * ============================================================
 *
 * Header only: `.lang-switch` wraps a borderless pill toggle
 * (flag + short label + caret, the same hover fill as the
 * `.icon-btn` beside it) and an absolutely positioned disclosure
 * panel. The option rows inside the panel are shared with the
 * left mobile drawer and styled in css/shared/language_options.css.
 * The toggle's flag is a 3:2 SVG (img/user_ui/flags/) drawn at
 * 21×14 (18×12 in the phone bar).
 */
.lang-switch {
    position: relative;
    flex: none;
}
.lang-switch-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 8px 0 10px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.06em;
    cursor: pointer;
}
.lang-switch-toggle:hover {
    background: var(--chip);
}
.lang-switch-toggle:focus-visible {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
}
/* The toggle's own flag — sized here because the phone bar shrinks it;
   the option rows' `.lang-flag` lives in css/shared/language_options.css. */
.lang-switch-flag {
    display: block;
    flex: none;
    width: 21px;
    height: 14px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px var(--line);
}
.lang-switch-caret {
    width: 12px;
    height: 12px;
    flex: none;
    color: var(--text-mute);
    transition: transform 120ms ease-out;
}
.lang-switch-toggle[aria-expanded="true"] .lang-switch-caret {
    transform: rotate(180deg);
}
.lang-switch-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    min-width: 180px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.lang-switch-menu[hidden] {
    display: none;
}

/* ============================================================
 * Responsive — values mirror the mockup verbatim.
 * ============================================================ */

/* ---- iPad / tablet (≤ 1100px) ---- */
@media (max-width: 1100px) {
    nav.primary { gap: 18px; }
    nav.primary a { font-size: 13px; }
    /* Below desktop the balance pill is too wide for the header — with the
       nav still showing on tablet it pushed the user-pill off the right
       edge. Pull it out of the bar here; the account menu(s) render a
       `[data-balance-root]` copy (SiteBalance mounts on each, both
       server-seed + live-update) so the figure stays reachable. */
    .hdr-balance { display: none; }
}

/* ---- Mobile / phone (≤ 760px) ---- */
@media (max-width: 760px) {
    nav.primary { display: none; }
    .head { height: 58px; gap: 10px; }
    .brand img.brand-mark { height: 32px; }
    /* Compact language toggle: the logged-in bar at 360px has
       320px inside the padding, and brand (100.5) + theme, bell
       and avatar (3 × 38) + five 10px gaps leave 55.5px for it.
       Flag 18 + label ~16 + gap 4 + padding 2 × 6 ≈ 50. */
    .lang-switch-toggle { gap: 4px; padding: 0 6px; }
    .lang-switch-flag { width: 18px; height: 12px; }
    .lang-switch-caret { display: none; }
}

/* ---- Narrow phone, logged out (≤ 480px) ----
   Logged out, the Steam sign-in button (197px wide at its 32px
   phone height) sits in the bar: brand + switch + theme + sign-in + four
   gaps need ~425px inside the padding, i.e. a ~466px viewport.
   Below that the header switch does not fit, so it is hidden;
   the 480 step leaves a margin for a fallback font. The left
   mobile drawer carries the same choice at every width. */
@media (max-width: 480px) {
    .lang-switch.is-anonymous { display: none; }
}
