/* ==========================================================================
   Cyber Falak v3: phone design
   Below 720px the site behaves like an app: a slim top bar, a bottom tab bar,
   a "More" sheet, sticky section tabs on topic pages and compact tiles.
   Loaded last; nothing here applies on tablet or desktop.
   ========================================================================== */
.m-tabs, .m-sheet, .m-hdr-a11y, .m-subnav { display: none; }

@media (max-width: 719px) {
  :root { --m-bar: 56px; --m-tabs: 64px; --m-safe: env(safe-area-inset-bottom, 0px); }
  body { padding-bottom: calc(var(--m-tabs) + var(--m-safe)); }

  /* ---------- Top bar: full width, slim ---------- */
  .site-header .menu-toggle, .site-header .hdr-cta, .a11y-fab, .main-nav.mega-nav { display: none !important; }
  .m-hdr-a11y {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; padding: 0;
    border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .06); color: #fff; cursor: pointer;
  }
  .m-hdr-a11y svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .site-header .header-actions { gap: 8px; }
  .site-header .hdr-alert { width: 40px; height: 40px; border-radius: 12px; }
  html:not(.a11y-contrast):not(.a11y-dark) {
    & .site-header { padding: 0; }
    & .site-header .header-inner,
    &.sp-js .site-header[data-hero]:not(:has(.main-nav.open)) .header-inner {
      height: var(--m-bar); max-width: none; padding-inline: 16px 12px; border-radius: 0; border: 0;
      border-bottom: 1px solid rgba(157, 182, 255, .12); box-shadow: none;
      background: rgba(5, 11, 38, .86); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
    }
    &.sp-js .site-header[data-hero] .header-inner { background: transparent; border-bottom-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
    & .site-header .brand img { width: 32px; height: 32px; }
    & .site-header .brand-name { font-size: .8125rem; letter-spacing: .16em; color: #fff; }
    & .hdr-orbit { display: none; }
    & .site-header.is-hidden { transform: translateY(-100%); }
  }
  .a11y-contrast .m-hdr-a11y { background: #000; border: 2px solid #fff; }

  /* ---------- Bottom tab bar ---------- */
  .m-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--m-tabs) + var(--m-safe)); padding: 6px 6px calc(6px + var(--m-safe));
    background: rgba(5, 11, 38, .9); border-top: 1px solid rgba(157, 182, 255, .14);
    backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  }
  .m-tabs > a, .m-tabs > button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0;
    border: 0; border-radius: 14px; background: none; color: rgba(214, 223, 255, .62); text-decoration: none; cursor: pointer;
    font: 600 .6875rem/1 var(--sp-font, inherit); letter-spacing: .01em; -webkit-tap-highlight-color: transparent;
  }
  .m-tabs span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .m-tabs [aria-current="page"], .m-tabs [data-current], .m-tabs [aria-expanded="true"] { color: #fff; }
  .m-tabs [aria-current="page"] svg, .m-tabs [data-current] svg, .m-tabs [aria-expanded="true"] svg {
    padding: 3px 14px; width: 50px; height: 28px; border-radius: 999px; background: rgba(157, 182, 255, .2); margin-block: -3px;
  }
  .a11y-contrast .m-tabs { background: #000; border-top: 2px solid #fff; }
  .a11y-contrast .m-tabs > * { color: #fff; }
  .a11y-contrast .m-tabs [aria-current="page"] svg { background: #ffeb3b; color: #000; }

  /* Things that float sit above the tab bar */
  .player { bottom: calc(var(--m-tabs) + var(--m-safe) + 10px) !important; }
  .player-open .a11y-fab { bottom: auto; }

  /* ---------- "More" sheet ---------- */
  .m-sheet[open] {
    display: block; position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 88svh; overflow: auto;
    padding: 8px 16px calc(20px + var(--m-safe)); border: 0; border-radius: 28px 28px 0 0;
    background: #f3f4f7; color: #0b1230; box-shadow: 0 -20px 60px rgba(2, 6, 25, .45);
    animation: m-sheet-up .32s cubic-bezier(.2, .8, .2, 1);
  }
  .m-sheet::backdrop { background: rgba(3, 7, 26, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
  @keyframes m-sheet-up { from { transform: translateY(40%); opacity: .4; } }
  @media (prefers-reduced-motion: reduce) { .m-sheet[open] { animation: none; } }
  .a11y-still .m-sheet[open] { animation: none; }
  .m-sheet-head { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 14px 0 12px; }
  .m-grab { position: absolute; left: 50%; top: 2px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: rgba(11, 18, 48, .18); }
  .m-sheet-title { margin: 0; font: 600 1.125rem/1.2 var(--sp-font, inherit); letter-spacing: -.01em; color: #0b1230; }
  .m-sheet-close { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #fff; color: #0b1230; box-shadow: 0 1px 2px rgba(11, 18, 48, .08); cursor: pointer; }
  .m-sheet-close svg, .m-sheet svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .m-sheet-grid { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0 0 14px; }
  .m-sheet-grid a {
    display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 6px 6px 10px; border-radius: 18px; text-decoration: none;
    background: #fff; color: #0b1230; font: 600 .8125rem/1.25 var(--sp-font, inherit); box-shadow: 0 1px 2px rgba(11, 18, 48, .05), 0 10px 24px -18px rgba(11, 18, 48, .3);
  }
  .m-sheet-grid a > span:last-child { padding-inline: 4px; }
  .m-sheet-grid a[aria-current="page"] { outline: 2px solid #2f5bea; outline-offset: -2px; }
  .m-sheet-grid .ex-art { height: 64px; width: 100%; margin: 0; border-radius: 13px; }
  .m-sheet-grid .ex-art i { transform: scale(.42); }
  .m-sheet-cta {
    display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 52px; border-radius: 16px; text-decoration: none;
    background: #0b1230; color: #fff; font: 600 1rem/1 var(--sp-font, inherit);
  }
  .m-sheet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
  .m-sheet-row > * {
    display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; border-radius: 14px; border: 0; cursor: pointer;
    background: #fff; color: #0b1230; text-decoration: none; font: 600 .9375rem/1 var(--sp-font, inherit); box-shadow: 0 1px 2px rgba(11, 18, 48, .06);
  }
  .m-sheet-row-soft > * { background: transparent; box-shadow: inset 0 0 0 1px rgba(11, 18, 48, .1); font-size: .875rem; }
  .m-dot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 4px rgba(229, 72, 77, .18); }

  /* ---------- Sticky section tabs (topic pages) ---------- */
  .page-hero .page-jump { display: none; }
  .m-subnav {
    display: block; position: sticky; top: var(--m-bar); z-index: 40; margin-top: -1px;
    background: rgba(243, 244, 247, .9); border-bottom: 1px solid rgba(11, 18, 48, .07);
    backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
    transition: top .3s ease;
  }
  html.m-hdr-hidden .m-subnav { top: 0; }
  .m-subnav ul { list-style: none; display: flex; gap: 6px; margin: 0; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; }
  .m-subnav ul::-webkit-scrollbar { display: none; }
  .m-subnav a {
    display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; white-space: nowrap; text-decoration: none;
    color: #5a6585; font: 600 .8125rem/1 var(--sp-font, inherit);
  }
  .m-subnav a[aria-current] { background: #0b1230; color: #fff; }
  .a11y-contrast .m-subnav { background: #000; border-bottom: 2px solid #fff; }
  .a11y-contrast .m-subnav a { color: #fff; }
  .a11y-contrast .m-subnav a[aria-current] { background: #ffeb3b; color: #000; }
  /* the sheet after the hero no longer tucks under it: the tabs sit between */
  html:not(.a11y-contrast):not(.a11y-dark) .m-subnav + :is(.section, [id]) { margin-top: 0 !important; border-radius: 0 !important; }
  html:not(.a11y-contrast):not(.a11y-dark) .page-hero:has(+ .m-subnav) { padding-bottom: 1.75rem !important; }
  html:not(.a11y-contrast):not(.a11y-dark) .page-hero:not(:has(+ .m-subnav)) { padding-bottom: calc(1.75rem + 36px) !important; }
  :is(.section, .story, .finale, [id]) { scroll-margin-top: calc(var(--m-bar) + 56px); }

  /* ---------- Home hero: an app welcome screen ---------- */
  html:not(.a11y-contrast):not(.a11y-dark) {
    & .hero:not(.page-hero) { padding-block: calc(var(--m-bar) + 2rem) calc(3rem + 36px); }
    & .hero-coords { font-size: .6875rem; }
    & .hero .cta-row { grid-template-columns: 1fr; }
    & .hero .cta-row .btn { min-height: 50px; font-size: .9375rem; border-radius: 14px; }
    & .hero-simple .hero-listen { width: 100%; justify-content: flex-start; border-radius: 14px; padding: .5rem .75rem .5rem .5rem; background: rgba(255, 255, 255, .06); }
  }

  /* ---------- Topic page heroes: compact title card ---------- */
  html:not(.a11y-contrast):not(.a11y-dark) {
    & .hero.page-hero { padding-top: calc(var(--m-bar) + 1.5rem); }
    & .page-hero .crumbs { display: none; }
    & .page-hero .lead { margin-bottom: 0; }
  }

  /* ---------- Section headers: app-style ---------- */
  .section-head { margin-bottom: 1.25rem; }
  .section-head .eyebrow { font-size: .6875rem; }
  :is(.listen, .listen-dark) { min-height: 32px; padding: 0 .75rem; font-size: .75rem; }
  .section { padding-block: 2.5rem; }
  .container { padding-inline: 16px; }

  /* ---------- Explore: two-up app tiles ---------- */
  .explore-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .explore-grid a { display: flex; flex-direction: column; gap: .3rem; padding: 6px 6px 12px; border-radius: 20px; }
  .explore-grid a > :not(.ex-art) { margin-inline: 8px; }
  .explore-grid .ex-art { width: 100%; height: 92px; margin: 0 0 .4rem; border-radius: 15px; }
  .explore-grid .ex-art i { transform: scale(.6); }
  .explore-grid .ex-title { font-size: .9375rem; line-height: 1.25; }
  .explore-grid .ex-desc, .explore-grid .ex-go { display: none; }
  .explore-grid .ex-kicker { font-size: .625rem; padding: 0; }

  /* ---------- Footer: the tab bar and sheet carry the links ---------- */
  .site-footer { padding-top: 2.5rem; padding-bottom: 1rem; }
  .footer-grid > nav { display: none; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; padding-bottom: 1.5rem; }
  .footer-grid > :last-child { grid-column: auto; }
  .footer-bottom { flex-direction: column; gap: .5rem; }

  /* ---------- Dialogs above the tab bar ---------- */
  dialog[open]:not(.m-sheet) { z-index: 90; }
}
@media (max-width: 719px) {
  .site-footer .brand-footer .brand-text { display: flex; flex-direction: column; }
  .site-footer .footer-h { font-size: .75rem !important; letter-spacing: .14em; margin-bottom: .75rem; }
  .site-footer .footer-grid li a, .site-footer .footer-grid address a { min-height: 40px; display: inline-flex; align-items: center; }
}

/* Home banner on phones: the shield scene sits on top, the words below it */
@media (max-width: 719px) {
  .hero:not(.page-hero) .shield-scene { right: auto; left: 50%; top: calc(var(--m-bar) - 30px); width: min(390px, 100vw); transform: translateX(-50%); }
  html:not(.a11y-contrast):not(.a11y-dark):not(.a11y-noimages) .hero:not(.page-hero) { padding-top: calc(var(--m-bar) + min(330px, 88vw)); }
  .shield-chip { font-size: .75rem; padding: .4rem .8rem; }
}
