/* ==========================================================================
   Tengri Header — indigo + gold + cream
   Used on every page via fragments/layout.html.
   Mobile-first: defaults target <481px. Tablet/desktop layered above.
   ========================================================================== */

.tengri-header {
    background: var(--tengri-sky);
    color: var(--tengri-cream);
    position: sticky;
    top: 0;
    z-index: 100;
    font-family: var(--font-heading);
    box-shadow: 0 1px 0 rgba(217, 164, 65, 0.18);
}

/* ----- Hero band (mobile defaults: compact, single row) ----- */
.tengri-header__hero {
    position: relative;
    overflow: hidden;
    padding: 0.55rem 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid rgba(217, 164, 65, 0.2);
}

.tengri-header__decor,
.tengri-header__decor--inner {
    display: none; /* gold rings hidden on mobile */
}

.tengri-header__inner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    position: relative;
    z-index: 1;
}

.tengri-header__mark {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    z-index: 1;
}

.tengri-header__mark .toono-mark {
    width: 36px;
    height: 36px;
    display: block;
}

.tengri-header__title {
    flex: 1;
    min-width: 0;
    z-index: 1;
}

.tengri-header__kicker {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 0.18em;
    opacity: 0.7;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
}

.tengri-header__name {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--tengri-cream);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tengri-header__tag {
    display: none; /* hidden on mobile to save space */
    margin: 0.2rem 0 0;
    font-size: 0.7rem;
    opacity: 0.7;
    font-style: italic;
    font-family: var(--font-body);
}

/* ----- Right widget (weather + almanac + currency) — hidden on mobile ----- */
.tengri-header__widget {
    display: none;
    flex-shrink: 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    line-height: 1.65;
    z-index: 1;
}

.tengri-header__weather[hidden] { display: none; }
.tengri-header__weather-glyph { font-size: 0.95rem; }
.tengri-header__weather-sep { opacity: 0.55; }

.tengri-header__almanac {
    opacity: 0.75;
    letter-spacing: 0.05em;
}

/* ----- Nav bar (mobile: hamburger only) ----- */
.tengri-nav {
    background: var(--tengri-sky);
    border-top: 1px solid rgba(217, 164, 65, 0.12);
}

.tengri-nav__container {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
}

/* Hamburger button — visible on mobile, hidden on desktop */
.tengri-nav__hamburger {
    background: transparent;
    border: 1px solid rgba(217, 164, 65, 0.35);
    color: var(--tengri-cream);
    padding: 0 0.4rem;
    min-height: 26px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.tengri-nav__hamburger:hover,
.tengri-nav__hamburger:focus-visible {
    background: rgba(217, 164, 65, 0.12);
    color: var(--tengri-sun-soft);
    border-color: var(--tengri-sun);
    outline: none;
}

.tengri-nav__hamburger-icon {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 14px;
    height: 12px;
}

.tengri-nav__hamburger-icon span {
    display: block;
    height: 1.5px;
    width: 100%;
    background: currentColor;
    border-radius: 2px;
}

/* ----- Nav menu — vertical inside the drawer on mobile ----- */
.tengri-nav__drawer-body {
    padding: 0.5rem 0.6rem 1rem;
}

.tengri-nav__menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0;
    padding: 0;
}

.tengri-nav__menu li {
    display: flex;
}

.tengri-nav__menu a {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    padding: 0.5rem 0.7rem;
    min-height: 36px;
    color: var(--tengri-ink);
    text-decoration: none;
    font-family: var(--font-body);
    border-left: 3px solid transparent;
    border-radius: 4px;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.tengri-nav__menu a:hover,
.tengri-nav__menu a:focus-visible {
    background: var(--tengri-cream);
    color: var(--tengri-sky);
    outline: none;
}

.tengri-nav__menu li.active a {
    color: var(--tengri-sky);
    border-left-color: var(--tengri-sun);
    background: var(--tengri-cream);
    font-weight: 700;
}

.tengri-nav__mn {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.tengri-nav__en {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.55;
    line-height: 1;
}

/* Auth block inside drawer */
.tengri-nav__auth {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--tengri-line);
    font-family: var(--font-body);
}

.auth-links {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}

.user-menu {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    color: var(--tengri-ink);
}

.user-greeting {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--tengri-ink-soft);
    letter-spacing: 0.03em;
}

.user-greeting__name {
    color: var(--tengri-sky);
    font-weight: 700;
    text-decoration: none;
}

.user-greeting__name:hover { color: var(--accent-color); }

.auth-link {
    text-decoration: none;
    color: var(--tengri-sky);
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    min-height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
    background: transparent;
    border: 1px solid var(--tengri-line);
    cursor: pointer;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    font-family: var(--font-body);
}

.auth-link:hover { background: var(--tengri-cream); }

.auth-link--primary,
.auth-link--logout {
    background: var(--tengri-sun);
    color: var(--tengri-sky-deep);
    font-weight: 700;
    border-color: var(--tengri-sun);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.auth-link--primary:hover,
.auth-link--logout:hover {
    background: var(--tengri-sun-soft);
    color: var(--tengri-sky-deep);
    border-color: var(--tengri-sun-soft);
}

/* ==========================================================================
   Tablet (≥481px) — restore hero subtitle + decor
   ========================================================================== */
@media (min-width: 481px) {
    .tengri-header__hero {
        padding: 0.85rem 0 0.75rem;
        gap: clamp(0.75rem, 2.5vw, 1.5rem);
    }
    .tengri-header__inner { gap: clamp(0.75rem, 2.5vw, 1.5rem); }
    .tengri-header__mark .toono-mark { width: 48px; height: 48px; }
    .tengri-header__name {
        font-size: clamp(1rem, 1.9vw, 1.4rem);
        line-height: 1.05;
        white-space: normal;
    }
    .tengri-header__tag {
        display: block;
    }
    .tengri-header__kicker {
        font-size: 0.5625rem;
        letter-spacing: 0.2em;
        margin-bottom: 0.2rem;
    }
}

/* ==========================================================================
   Desktop (≥769px) — restore decor, currency widget, horizontal nav
   ========================================================================== */
@media (min-width: 769px) {
    .tengri-header__decor {
        display: block;
        position: absolute;
        right: -80px;
        top: -80px;
        width: 220px;
        height: 220px;
        border-radius: 50%;
        border: 1px solid var(--tengri-sun);
        opacity: 0.2;
        pointer-events: none;
    }
    .tengri-header__decor--inner {
        display: block;
        right: -50px;
        top: -50px;
        width: 160px;
        height: 160px;
        opacity: 0.3;
    }

    .tengri-header__mark .toono-mark { width: 56px; height: 56px; }

    .tengri-header__widget {
        display: block;
        border-left: 1px solid rgba(217, 164, 65, 0.25);
        padding-left: 1.1rem;
    }
    .tengri-header__weather {
        color: var(--tengri-sun-soft);
        font-size: 0.75rem;
        font-weight: 700;
        margin-bottom: 0.25rem;
        display: inline-flex;
        align-items: baseline;
        gap: 0.35rem;
    }
    .tengri-header__widget .currency-rates {
        margin-top: 0.5rem;
        flex-direction: row;
        gap: 0.625rem;
        justify-content: flex-end;
    }

    /* Hide hamburger; restore inline horizontal nav layout.
       Compound selector bumps specificity above base.css `.drawer-trigger`. */
    .tengri-nav__hamburger.drawer-trigger { display: none; }

    .tengri-nav__container {
        align-items: stretch;
        gap: 0.75rem;
        padding: 0;
    }

    /* Drawer becomes inline on desktop — make it stretch and turn the body into
       a flex row so the menu and the auth block sit on the same line. Without
       this the panel stays display:block and the auth wraps below the menu. */
    .tengri-nav__drawer.drawer--inline-md {
        flex: 1;
        display: flex;
    }
    .tengri-nav__drawer.drawer--inline-md .drawer__panel {
        display: flex;
        flex: 1;
    }

    .tengri-nav__drawer-body {
        padding: 0;
        display: flex;
        align-items: center;
        flex: 1;
    }

    .tengri-nav__menu {
        flex-direction: row;
        gap: 0;
    }

    .tengri-nav__menu a {
        flex: 0 0 auto;
        flex-direction: column;
        gap: 0.15rem;
        padding: 0.95rem 1.1rem;
        min-height: 0;
        color: var(--tengri-cream);
        background: transparent;
        border-left: none;
        border-bottom: 2px solid transparent;
        border-radius: 0;
    }

    .tengri-nav__menu a:hover,
    .tengri-nav__menu a:focus-visible {
        background: transparent;
        color: var(--tengri-sun-soft);
    }

    .tengri-nav__menu li.active a {
        color: var(--tengri-sun);
        border-left-color: transparent;
        border-bottom-color: var(--tengri-sun);
        background: transparent;
    }

    .tengri-nav__mn {
        font-size: 0.8125rem;
        line-height: 1;
    }

    .tengri-nav__en {
        font-size: 0.5625rem;
        opacity: 0.5;
    }

    .tengri-nav__auth {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        margin: 0 0 0 auto;
        padding: 0;
        border-top: none;
    }

    .user-menu {
        flex-direction: row;
        align-items: center;
        gap: 0.85rem;
        color: var(--tengri-cream);
    }

    .user-greeting {
        font-size: 0.6875rem;
        opacity: 0.85;
        color: var(--tengri-cream);
    }

    .user-greeting__name { color: var(--tengri-sun); }
    .user-greeting__name:hover { color: var(--tengri-sun-soft); }

    .auth-link {
        color: var(--tengri-cream);
        background: transparent;
        border-color: transparent;
        padding: 0.45rem 1.1rem;
        min-height: 0;
        font-size: 0.75rem;
    }

    .auth-link:hover {
        background: transparent;
        color: var(--tengri-sun-soft);
    }

    .auth-link--primary,
    .auth-link--logout {
        background: var(--tengri-sun);
        color: var(--tengri-sky-deep);
        border-color: var(--tengri-sun);
    }
}
/* ==========================================================================
   Phones (≤768px): no top header. The tab bar (.tabbar, below) is the
   navigation. Signed-in staff get a «Цэс» tab that opens the menu drawer,
   which lives in .tengri-nav; so the nav stays rendered with zero height and
   only its trigger button is hidden.
   ========================================================================== */
@media (max-width: 768px) {
    .tengri-header { position: relative; box-shadow: none; background: none; }
    .tengri-header__hero { display: none; }
    .tengri-nav { height: 0; border: none; background: none; }
    .tengri-nav .tengri-nav__hamburger { display: none; }

    /* Drawer menu: full-size rows for thumbs */
    .tengri-nav__menu { gap: 0.25rem; }
    .tengri-nav__menu a {
        min-height: 48px;
        justify-content: center;
        padding: 0.55rem 0.85rem;
        border-radius: var(--radius-sm);
    }
    .tengri-nav__mn { font-size: 1rem; }
    .auth-link { min-height: var(--tap-target); font-size: 0.85rem; }

    /* No header above: give the first thing on each page some air */
    .site-main { padding-top: 0.5rem; }
}


/* ==========================================================================
   Tab bar (phones only). The active tab's icon sits in a gold ring, the
   toono of the logo; everything else stays quiet.
   ========================================================================== */
.tabbar { display: none; }

@media (max-width: 768px) {
    :root { --tabbar-h: 60px; }

    body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

    .tabbar {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 90; /* below the header (100), whose menu drawer must cover it */
        padding: 0 0.25rem env(safe-area-inset-bottom);
        background: var(--tengri-sky-deep);
        border-top: 1px solid rgba(217, 164, 65, 0.22);
    }

    .tabbar__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        height: var(--tabbar-h);
        color: rgba(246, 239, 224, 0.6);
        font-family: var(--font-body);
        font-size: 0.6875rem;
        font-weight: 600;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .tabbar__item:visited { color: rgba(246, 239, 224, 0.6); }

    .tabbar__icon {
        display: grid;
        place-items: center;
        width: 34px;
        height: 34px;
        border-radius: 999px;
        border: 1px solid transparent;
        transition: transform 160ms var(--ease-out), background 200ms ease, border-color 200ms ease;
    }
    .tabbar__icon svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.75;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .tabbar__item.is-active,
    .tabbar__item.is-active:visited { color: var(--tengri-sun-soft); }
    .tabbar__item.is-active .tabbar__icon {
        border-color: var(--tengri-sun);
        background: rgba(217, 164, 65, 0.14);
    }
    .tabbar__item:active .tabbar__icon { transform: scale(0.9); }
    .tabbar__item:focus-visible { outline: none; }
    .tabbar__item:focus-visible .tabbar__icon { outline: 2px solid var(--tengri-sun); outline-offset: 2px; }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .tabbar__item:active .tabbar__icon { transform: none; }
}

/* The staff «Цэс» tab is a <button> (drawer trigger): reset the generic
   .drawer-trigger look so it matches the link tabs. */
@media (max-width: 768px) {
    .tabbar button.tabbar__item {
        min-width: 0;
        min-height: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        background: none;
        font: inherit;
        font-size: 0.6875rem;
        font-weight: 600;
        cursor: pointer;
    }
    .tabbar button.tabbar__item:hover,
    .tabbar button.tabbar__item:focus-visible { background: none; border: none; }
    .tabbar button.tabbar__item[aria-expanded="true"] { color: var(--tengri-sun-soft); }
    .tabbar button.tabbar__item[aria-expanded="true"] .tabbar__icon { border-color: var(--tengri-sun); background: rgba(217, 164, 65, 0.14); }
}
