/* ─── app.css: design system v2 + app shell (loaded on every page after main.css) ───
   Desktop/tablet (≥ 769px): full header with navigation, rich sections.
   Phone (≤ 768px): app bar on top, tab bar at the bottom, sheets instead of dropdowns. */

:root {
    --teal-50:  #EEF7F8;
    --teal-100: #D5ECEE;
    --teal-200: #A9D7DC;
    --teal-500: #2E7C85;
    --teal-600: #256870;
    --teal-700: #1E5A61;
    --teal-900: #0D3740;
    --orange-50:  #FDF2EC;
    --orange-100: #FADFCF;
    --surface:   #FFFFFF;
    --surface-2: #F4F8F9;
    --surface-3: #E9F1F2;
    --ink:       #10232A;
    --r-sm: 10px;
    --r-md: 14px;
    --r-xl: 24px;
    --e1: 0 1px 2px rgba(13,55,64,.06), 0 1px 3px rgba(13,55,64,.08);
    --e2: 0 2px 4px rgba(13,55,64,.05), 0 8px 24px rgba(13,55,64,.09);
    --e3: 0 4px 8px rgba(13,55,64,.06), 0 18px 48px rgba(13,55,64,.14);
    --grad-hero:
        radial-gradient(1200px 500px at 85% -10%, rgba(217,112,61,.22), transparent 60%),
        radial-gradient(900px 600px at 0% 110%, rgba(46,124,133,.55), transparent 60%),
        linear-gradient(160deg, #0D3740 0%, #12454F 45%, #1E5A61 100%);
    --grad-brand: linear-gradient(135deg, #2E7C85 0%, #1E5A61 100%);
    --grad-warm:  linear-gradient(135deg, #E07B45 0%, #C9622F 100%);
    --tabbar-h: 64px;
    --appbar-h: 56px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

body { background: var(--surface-2); color: var(--ink); -webkit-tap-highlight-color: transparent; }
::selection { background: var(--teal-100); color: var(--teal-900); }

/* ── Motion: content rises in as it scrolls into view ───────────────────────── */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal-stagger > * { opacity: 0; transform: translateY(12px); transition: opacity .45s var(--ease), transform .45s var(--ease); }
.reveal-stagger.in > * { opacity: 1; transform: none; }
.reveal-stagger.in > *:nth-child(2) { transition-delay: .05s; }
.reveal-stagger.in > *:nth-child(3) { transition-delay: .10s; }
.reveal-stagger.in > *:nth-child(4) { transition-delay: .15s; }
.reveal-stagger.in > *:nth-child(5) { transition-delay: .20s; }
.reveal-stagger.in > *:nth-child(6) { transition-delay: .25s; }
@media (prefers-reduced-motion: reduce) {
    .reveal, .reveal-stagger > * { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* ── Buttons: depth and a pressed state ─────────────────────────────────────── */
.btn { border-radius: var(--r-md); transition: background-color .15s, border-color .15s, color .15s, box-shadow .2s, transform .12s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad-warm); box-shadow: 0 6px 16px rgba(217,112,61,.32); }
.btn-primary:hover { background: var(--grad-warm); box-shadow: 0 8px 22px rgba(217,112,61,.42); filter: brightness(1.04); }
.btn-teal { background: var(--grad-brand); box-shadow: 0 6px 16px rgba(30,90,97,.28); }
.btn-teal:hover { background: var(--grad-brand); filter: brightness(1.06); }
.btn-glass { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.28); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn-glass:hover { background: rgba(255,255,255,.2); }

/* ── Shared building blocks other pages use ─────────────────────────────────── */
.q-card { background: var(--surface); border: 1px solid rgba(13,55,64,.07); border-radius: var(--r-lg); box-shadow: var(--e1); transition: box-shadow .2s, transform .2s, border-color .2s; }
.q-card--hover:hover { box-shadow: var(--e2); transform: translateY(-2px); border-color: var(--teal-100); }
.q-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--teal-50); color: var(--teal-700); font-size: 13px; font-weight: 600; white-space: nowrap; }
.q-chip--warm { background: var(--orange-50); color: var(--orange-d); }
.q-section-title { font-size: clamp(20px, 2.6vw, 28px); font-weight: 800; letter-spacing: -.3px; color: var(--ink); line-height: 1.3; }
.q-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--teal-600); text-transform: none; margin-bottom: 6px; }
.q-skel { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.q-skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: q-shimmer 1.3s infinite; }
@keyframes q-shimmer { to { transform: translateX(100%); } }
/* Horizontal scroller (carousels on phones, rows on desktop) */
.q-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: none; }
.q-rail::-webkit-scrollbar { display: none; }
.q-rail > * { scroll-snap-align: start; }

/* ── Header (desktop/tablet): glass bar that turns solid on scroll ──────────── */
.header.scrolled, .header.is-solid {
    background: rgba(255,255,255,.86);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom-color: rgba(13,55,64,.08);
    box-shadow: 0 1px 0 rgba(13,55,64,.04), 0 6px 20px rgba(13,55,64,.05);
}
.hdr-nav a { border-radius: 10px; }
.hdr-nav a.active { box-shadow: inset 0 -2px 0 var(--orange); border-radius: 10px 10px 4px 4px; }
.hdr-join { background: var(--grad-warm); border: 0; box-shadow: 0 4px 12px rgba(217,112,61,.3); border-radius: 10px; }
.hdr-join:hover { background: var(--grad-warm); filter: brightness(1.05); }
.hdr-icon-btn { display: none; }

/* Top progress bar for page navigation */
#qdProgress { position: fixed; inset-inline: 0; top: 0; height: 3px; z-index: 10002; pointer-events: none; }
#qdProgress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), #F4A261); box-shadow: 0 0 8px rgba(217,112,61,.6); transition: width .3s ease, opacity .3s; }
#qdProgress.run span { width: 70%; transition: width 6s cubic-bezier(.1,.6,.2,1); }
#qdProgress.done span { width: 100%; opacity: 0; transition: width .2s, opacity .4s .2s; }

/* Tab bar + sheet are phone-only */
.tabbar, .sheet-backdrop { display: none; }

/* ══════════════════════════════════════════════════════════════════════════
   PHONE LAYOUT (≤ 768px): app bar + bottom tab bar
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root { --header-h: var(--appbar-h); }
    body { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }

    /* App bar */
    .header { height: var(--appbar-h); }
    .header .wrap { padding: 0 12px; }
    .header-inner { gap: 8px; }
    .hdr-logo img { height: 30px; }
    .hdr-logo-text { font-size: 18px; }
    .hdr-right { display: flex !important; gap: 6px; margin-inline-start: auto; }
    .hdr-right > .hdr-lang, .hdr-right > .hdr-profile, .hdr-right > .hdr-signin, .hdr-right > .hdr-join { display: none; }
    .hdr-icon-btn, .hdr-bell-btn { display: inline-flex; width: 38px; height: 38px; border-radius: 12px; align-items: center; justify-content: center; position: relative; }
    .hdr-icon-btn { background: rgba(255,255,255,.12); border: 1.5px solid rgba(255,255,255,.25); color: #fff; }
    .header.scrolled .hdr-icon-btn, .header.is-solid .hdr-icon-btn { background: var(--surface-2); border-color: var(--border); color: var(--ink); }
    .hdr-notif-panel { position: fixed; top: calc(var(--appbar-h) + 8px); inset-inline: 10px; width: auto; }
    .burger { display: none !important; }
    .hdr-chat-btn { display: none !important; }
    .mobile-menu { display: none !important; }

    /* Bottom tab bar */
    .tabbar {
        display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
        position: fixed; inset-inline: 0; bottom: 0; z-index: 998;
        height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
        background: rgba(255,255,255,.94);
        backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
        border-top: 1px solid rgba(13,55,64,.08);
        box-shadow: 0 -6px 24px rgba(13,55,64,.08);
    }
    .tab {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        height: var(--tabbar-h); color: #7A8A90; font-size: 11px; font-weight: 600; text-align: center;
        transition: color .15s;
    }
    .tab svg { width: 23px; height: 23px; transition: transform .2s var(--ease); }
    .tab.active { color: var(--teal-600); }
    .tab.active::before { content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--teal-500); }
    .tab:active svg { transform: scale(.88); }
    .tab-badge { position: absolute; top: 8px; inset-inline-start: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: #EF4444; color: #fff; font-size: 10px; font-weight: 700; line-height: 17px; text-align: center; border: 2px solid #fff; }
    .tab--fab { color: var(--orange-d); }
    .tab-fab-btn {
        width: 54px; height: 54px; margin-top: -26px; border-radius: 18px;
        display: grid; place-items: center; color: #fff;
        background: var(--grad-warm); box-shadow: 0 8px 20px rgba(217,112,61,.45), 0 0 0 5px #fff;
        transform: rotate(0); transition: transform .2s var(--ease);
    }
    .tab--fab:active .tab-fab-btn { transform: scale(.92); }
    .tab--fab svg { width: 26px; height: 26px; }

    /* Bottom sheet ("More" menu and other sheets) */
    .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 10000; background: rgba(13,35,42,.45); opacity: 0; pointer-events: none; transition: opacity .25s; }
    .sheet-backdrop.open { opacity: 1; pointer-events: auto; }
    .sheet {
        position: fixed; inset-inline: 0; bottom: 0; z-index: 10001;
        background: var(--surface); border-radius: 22px 22px 0 0;
        padding: 10px 16px calc(20px + var(--safe-b));
        box-shadow: 0 -10px 40px rgba(13,35,42,.2);
        transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.9,.25,1);
        max-height: 86vh; overflow-y: auto;
    }
    .sheet.open { transform: none; }
    .sheet-handle { width: 40px; height: 5px; border-radius: 99px; background: #D5DDE0; margin: 0 auto 14px; }
    .sheet h3 { font-size: 16px; font-weight: 800; margin: 0 4px 12px; }
    .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .sheet-tile {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
        padding: 14px 6px; border-radius: 16px; background: var(--surface-2); border: 1px solid rgba(13,55,64,.06);
        font-size: 12.5px; font-weight: 700; color: var(--ink); text-align: center; line-height: 1.3;
    }
    .sheet-tile:active { transform: scale(.97); }
    .sheet-tile:focus { outline: none; }
    .sheet-tile:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; }
    .sheet-tile i { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--teal-50); color: var(--teal-600); font-style: normal; }
    .sheet-tile.warm i { background: var(--orange-50); color: var(--orange-d); }
    .sheet-list { margin-top: 14px; border-radius: 16px; background: var(--surface-2); overflow: hidden; }
    .sheet-list a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; font-size: 14.5px; font-weight: 600; color: var(--ink); border-bottom: 1px solid rgba(13,55,64,.06); }
    .sheet-list a:last-child { border-bottom: 0; }
    .sheet-list a.danger { color: #DC2626; }
    .sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; }
    .sheet-user .av { width: 44px; height: 44px; border-radius: 14px; background: var(--grad-brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; overflow: hidden; }
    .sheet-user .av img { width: 100%; height: 100%; object-fit: cover; }
    .sheet-user b { display: block; font-size: 15px; }
    .sheet-user small { color: var(--muted); font-size: 12.5px; }

    /* Floating things sit above the tab bar */
    .wa-fab { bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px) !important; width: 48px !important; height: 48px !important; }
    .wa-fab svg { width: 26px; height: 26px; }
    #cookie-bar { bottom: calc(var(--tabbar-h) + var(--safe-b)); border-radius: 16px 16px 0 0; }

    /* Footer becomes a compact strip on phones */
    .footer-grid { display: none; }
    .footer-bottom { padding: 18px 0; justify-content: center; text-align: center; }

    .section { padding: 40px 0; }
    .wrap { padding: 0 16px; }
}

/* Tablet / small laptop: keep the full header on one line */
@media (min-width: 769px) and (max-width: 1180px) {
    .header .wrap { padding: 0 18px; }
    .header-inner { gap: 12px; }
    .hdr-nav a { padding: 8px 9px; font-size: 13px; }
    .hdr-nav a[href="/about"] { display: none; }
    .hdr-right { gap: 8px; }
    .hdr-join { display: none; }
    .hdr-profile-name { max-width: 70px; }
}
@media (min-width: 769px) and (max-width: 940px) {
    .hdr-logo-text { display: none; }
    .hdr-nav a[href="/categories"] { display: none; }
}
