/*
 * AnaJak Store: compact phone header and the right-side navigation drawer (below 768 px, Tailwind md).
 * ─────────────────────────────────────────────────────────────────────────────
 * Markup and behaviour: components/navbar.blade.php (header icon buttons, the #mobile-menu drawer and its
 * backdrop after </nav>, Alpine.data('navDrawer')). Loaded in both design modes (White & Blue and custom),
 * after ds-color-modes.css and kh-landscape.css.
 * Colours come only from tokens: light values in :root below, dark values in ds-color-modes.css
 * (html[data-theme="dark"], more specific than :root, so they win whatever the load order).
 * The drawer and backdrop are fixed at z-index 61/60, above the fixed summary bars of the game and premium
 * pages (z-50 / z-40); the support chat button (z-1000) is hidden while the drawer is open.
 * Only transform and opacity animate (200 ms); no transition with prefers-reduced-motion. Hover and press colours
 * change without a transition. (The "Dark mode" switch keeps its approved style from ds-color-modes.css.)
 */
:root {
    /* light values of tokens the drawer reads that ds-tokens.css lacks; same values as ds-color-modes.css :root
       (custom design mode does not load that file). Dark values: ds-color-modes.css. --ds-on-primary is NOT
       declared here: a global value would change the custom-mode dashboard/settings buttons (design §1.6);
       any use below must be var(--ds-on-primary, #FFFFFF). design-review.md M2 allows this fallback form. */
    --ds-bg-elevated: #FFFFFF;
    --ds-link-strong: #1D4ED8;
    --ds-focus: #2563EB;
    --ds-nav-divider: #E2E8F0;
    --ds-nav-hover: #F1F5F9;
    --ds-nav-active: #EFF6FF;
    --ds-nav-press: #DBEAFE;
    --ds-backdrop: rgba(15, 23, 42, .45);
    --ds-drawer-shadow: -16px 0 40px -20px rgba(15, 23, 42, .35);
}

/* ── Header icon buttons (phone search and menu) and the drawer close button: 44 x 44, no border ── */
.ds-nav-iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ds-text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .ds-nav-iconbtn:hover { background: var(--ds-nav-hover); } }
.ds-nav-iconbtn:active { background: var(--ds-nav-press); }
.ds-nav-iconbtn:focus-visible { outline: 2px solid var(--ds-focus); outline-offset: 2px; box-shadow: none; }
.ds-nav-iconbtn .bi { line-height: 1; }
.ds-nav-iconbtn .bi-search { font-size: 18px; }
.ds-nav-iconbtn .bi-list { font-size: 22px; }
.ds-nav-iconbtn .bi-x-lg { font-size: 20px; }

/* ── Backdrop and drawer (outside the fixed <nav>, so its stacking context cannot hold them down) ── */
.ds-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--ds-backdrop);
    -webkit-tap-highlight-color: transparent;
}
.ds-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 61;
    width: min(340px, 88vw);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--ds-bg-elevated);
    color: var(--ds-text);
    box-shadow: var(--ds-drawer-shadow);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) 0;
}

/* drawer header: brand left, close right (the close button lands where the menu button was) */
.ds-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: none;
    min-height: 64px;
    padding: 0 16px;
    border-bottom: 1px solid var(--ds-nav-divider);
}
.ds-drawer-brand {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--ds-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ds-drawer-brand img { display: block; height: 32px; width: auto; max-width: 100%; object-fit: contain; }

/* rows */
.ds-drawer-nav { flex: none; padding: 8px; }
.ds-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 0 14px;
    border-radius: 12px;
    color: var(--ds-text);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.ds-drawer-link + .ds-drawer-link { margin-top: 2px; }
.ds-drawer-link > .bi { flex: none; font-size: 18px; line-height: 1; color: var(--ds-text-muted); }
.ds-drawer-link > span { min-width: 0; padding: 6px 0; overflow-wrap: anywhere; }
@media (hover: hover) { .ds-drawer-link:hover { background: var(--ds-nav-hover); } }
.ds-drawer-link.is-active { background: var(--ds-nav-active); color: var(--ds-link-strong); font-weight: 600; }
.ds-drawer-link.is-active > .bi { color: var(--ds-link-strong); }
.ds-drawer-link:active { background: var(--ds-nav-press); }

/* utilities: Log in or the account, the language pair, the Dark mode switch */
.ds-drawer-utils {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: none;
    padding: 16px;
    border-top: 1px solid var(--ds-nav-divider);
}
.ds-drawer-label {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ds-text-muted);
}
.ds-drawer-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ds-drawer-seg-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    color: var(--ds-text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.ds-drawer-seg-btn img { flex: none; }
.ds-drawer-seg-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .ds-drawer-seg-btn:hover { background: var(--ds-nav-hover); } }
.ds-drawer-seg-btn.is-current { background: var(--ds-nav-active); color: var(--ds-link-strong); border-color: var(--ds-primary); font-weight: 600; }
.ds-drawer-seg-btn:active { background: var(--ds-nav-press); }
.ds-drawer-account {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 6px 12px 6px 8px;
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    color: var(--ds-text);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .ds-drawer-account:hover { background: var(--ds-nav-hover); } }
.ds-drawer-account:active { background: var(--ds-nav-press); }
.ds-drawer-account img { flex: none; width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.ds-drawer-account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ds-drawer-account-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-drawer-account-sub { font-size: 13px; color: var(--ds-text-muted); }
/* the approved "Dark mode" row (ds-color-modes.css); inside the drawer the utilities gap spaces it */
.ds-drawer .ds-theme-switch { margin-top: 0; }

/* one visible focus indicator inside the drawer, drawn inside each control so the scroll box cannot clip it
   (.ds-btn normally draws a box-shadow ring) */
.ds-drawer :focus-visible { outline: 2px solid var(--ds-focus); outline-offset: -2px; box-shadow: none; }

/* ── Motion: drawer slides in from the right, backdrop fades (x-transition classes) ── */
.ds-drawer-anim { transition: transform .2s ease-out; }
.ds-drawer-out { transform: translateX(100%); }
.ds-drawer-in { transform: translateX(0); }
.ds-fade-anim { transition: opacity .2s ease-out; }
.ds-fade-out { opacity: 0; }
.ds-fade-in { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .ds-drawer-anim, .ds-fade-anim { transition: none !important; }
}

/* ── While open: the page keeps its place (scroll lock, scrollbar gap on <html> and the fixed nav) ── */
html.ds-nav-open { overflow: hidden; padding-right: var(--ds-scrollbar-gap, 0px); }
html.ds-nav-open .ds-site-nav { padding-right: var(--ds-scrollbar-gap, 0px); }
html.ds-nav-open .chat-button { visibility: hidden; }

/* ── From 768 px the desktop header takes over; the drawer never shows there ── */
@media (min-width: 768px) {
    .ds-drawer, .ds-drawer-backdrop { display: none !important; }
}
