/*
 * Direct mobile header preferences — 2026-10-27 owner request #485.
 * Deliberately shared FUNCTIONAL controls, not a shared visual brand shell.
 * Loaded after the existing header and brand CSS so 320–1439px always has
 * an immediately accessible theme/locale pair even when the drawer is closed.
 */
.tna-mobile-header-preferences { display: none; }

@media (max-width: 1439px) {
    /*
     * Existing CSS (public-v22/tna-next/academy) hides .tna-site-actions.
     * Do NOT unhide the whole desktop toolbar: notifications/account actions
     * would overflow the mobile masthead. This compact pair is independent.
     * All 7 brand mastheads and the company masthead include the same partial.
     */
    html body .tna-site-header .tna-site-nav:has(> .tna-mobile-header-preferences) {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        /* One direction-aware edge for the identity; one for all 3 tools. */
        justify-content: flex-start !important;
        direction: inherit !important;
        column-gap: clamp(6px, 1vw, 12px) !important;
        flex-wrap: nowrap !important;
        min-width: 0;
    }

    html body .tna-site-header .tna-site-nav > .tna-site-brand {
        /* Keep logo+name a single compact lockup, never a stretched middle island. */
        flex: 0 1 auto !important;
        order: 0 !important;
        margin-inline-start: 0 !important;
        margin-inline-end: auto !important;
        min-width: 0 !important;
        max-width: calc(100% - 160px) !important;
        overflow: hidden;
    }
    html body .tna-site-header .tna-site-nav > .tna-site-brand .tna-site-brand__copy {
        min-width: 0;
        overflow: hidden;
    }
    html body .tna-site-header .tna-site-nav > .tna-site-brand .tna-site-brand__copy strong {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    html body .tna-site-header .tna-site-nav > .tna-mobile-header-preferences {
        display: inline-flex !important;
        order: 2 !important;
        flex: none !important;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-width: 0;
        margin: 0;
        padding: 0;
        /* Keep the visual theme → language order aligned with DOM Tab order
           in either writing direction. */
        direction: inherit;
        position: relative;
        z-index: 1;
    }
    html body .tna-site-header .tna-mobile-header-preferences > * {
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: none;
        width: 44px;
        min-width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 0;
        margin: 0;
        border: 1px solid color-mix(in srgb, currentColor 23%, transparent);
        border-radius: 13px;
        background: color-mix(in srgb, currentColor 5%, transparent);
        color: inherit;
        font: inherit;
        font-size: 12px;
        font-weight: 800;
        letter-spacing: .035em;
        line-height: 1;
        text-decoration: none;
        box-shadow: none;
        cursor: pointer;
        transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
    }
    html body .tna-site-header .tna-mobile-header-preferences > *:is(:hover, :focus-visible) {
        border-color: currentColor;
        background: color-mix(in srgb, currentColor 12%, transparent);
        transform: translateY(-1px);
    }
    html body .tna-site-header .tna-mobile-header-preferences > *:focus-visible {
        outline: 2px solid currentColor;
        outline-offset: 3px;
    }
    html body .tna-site-header .tna-mobile-header-preferences > .tna-mobile-header-preferences__language {
        font-size: 10px;
        letter-spacing: 0;
    }
    html body .tna-site-header .tna-mobile-header-preferences__theme::before,
    html body .tna-site-header .tna-mobile-header-preferences__theme::after {
        display: none !important;
    }
    html body .tna-site-header .tna-mobile-header-preferences__theme svg {
        width: 20px;
        height: 20px;
        pointer-events: none;
    }

    /* A dedicated control row is not a reason to lose the original menu. */
    html body .tna-site-header .tna-site-nav > .tna-site-menu-button {
        /* Immediately beside locale/theme; never separated by flex auto margins. */
        order: 1 !important;
        margin-inline: 0 !important;
        flex: 0 0 48px !important;
        width: 48px !important;
        min-width: 48px !important;
        height: 46px !important;
        min-height: 46px !important;
        padding: 0 !important;
        display: inline-flex !important;
        justify-content: center;
        align-items: center;
        border-radius: 14px;
    }
    html body .tna-site-header .tna-site-nav > .tna-site-menu-button b {
        /* Keep the word available to assistive tech but out of the tight row. */
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    /* All eight headers inherit the same semantic RTL/LTR relationship.
     * Their individual colors, fonts and logos remain independent.
     * Never reinstate per-brand order permutations here. */

    /* Only supplementary desktop story/actions hide; useful links stay in
       the existing accessible drawer and in their own brand content. */
    html body .tna-site-header .tna-site-nav > .tna-site-desktop-nav,
    html body .tna-site-header .tna-site-nav > .tna-site-actions,
    html body .tna-site-header .tna-site-nav > .pro-masthead__statement {
        display: none !important;
    }

    /* Preserve each brand's presentation rather than forcing seven copies. */
    html body [data-tna-header][data-brand="pro"] .tna-mobile-header-preferences > * {
        border-radius: 6px;
    }
    html body [data-tna-header][data-brand="amooz"] .tna-mobile-header-preferences > * {
        border-radius: 16px;
    }
    html body [data-tna-header][data-brand="mag"] .tna-mobile-header-preferences > * {
        border-radius: 3px;
    }
    html body [data-tna-header][data-brand="cup"] .tna-mobile-header-preferences > * {
        border-radius: 50%;
    }

    /*
     * Existing Pro browser regression asserts a 44px hamburger hit box at
     * 320–1439px. Preserve this established precision instead of silently
     * growing the industrial masthead control to 48px.
     */
    html body[data-tna-pro-shell] .tna-site-header .tna-site-nav > .tna-site-menu-button {
        flex: 0 0 44px !important;
        min-width: 44px !important;
        width: 44px !important;
        max-width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
    }

    /* Reversible bar movement: the drawer already slides in AND out using
       .is-open. Maintain the same state and JS/focus/accessibility behavior. */
    html body .tna-site-header .tna-site-menu-button i {
        transition: transform .28s cubic-bezier(.22, 1, .36, 1),
                    opacity .18s ease !important;
        transform-origin: center;
    }
}
/* Preserve the Pro inquiry in its hero and drawer: any extra root child
   between the brand and grouped controls defeats the two-group masthead.
   Hide the duplicate shortcut until the desktop masthead resumes. */
@media (max-width: 1439px) {
    html body[data-tna-pro-shell] .tna-site-header .tna-site-nav > .pro-masthead__mobile-request {
        display: none !important;
    }
}
@media (max-width: 430px) {
    html body .tna-site-header .tna-site-nav:has(> .tna-mobile-header-preferences) {
        column-gap: 6px !important;
    }
    html body .tna-site-header .tna-site-nav > .tna-site-brand .tna-site-brand__copy small,
    html body .tna-site-header .tna-site-nav > .tna-site-brand .tna-site-brand__context {
        display: none !important;
    }
}
@media (max-width: 350px) {
    /* Keep the human-readable brand name rather than collapsing it into
       an unlabeled symbol at 320px. Optional subtitle was removed above. */
    html body .tna-site-header .tna-site-nav > .tna-site-brand {
        max-width: calc(100% - 154px) !important;
        gap: 5px !important;
    }
    html body .tna-site-header .tna-site-nav > .tna-site-brand .tna-site-brand__mark {
        width: 40px !important;
        height: 40px !important;
        flex-basis: 40px !important;
    }
    html body .tna-site-header .tna-site-nav > .tna-site-brand .tna-site-brand__copy {
        display: grid !important;
        min-width: 0 !important;
    }
    html body .tna-site-header .tna-mobile-header-preferences > * {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }
}
@media (prefers-reduced-motion: reduce) {
    html body .tna-site-header .tna-mobile-header-preferences > * {
        transition: none !important;
        animation: none !important;
        transform: none;
    }
    /* Instant X state still needs its transform: only the tween is removed. */
    html body .tna-site-header .tna-site-menu-button i {
        transition: none !important;
        animation: none !important;
    }
}

/* Reduced motion applies to the entire sheet/backdrop, not only the bar icon. */
@media (prefers-reduced-motion: reduce) {
    html[dir] body [data-tna-header] .tna-site-drawer.tcr-drawer,
    html[dir] body [data-tna-header] .tna-menu-backdrop,
    html[dir] body [data-tna-header] .tna-site-drawer.tcr-drawer * { transition:none !important; animation:none !important; }
}
