/* ============================================================
   mobile.css — iPhone / small-screen polish for all four pages.
   Loaded LAST on every page so its rules win without !important.
   Targets:
     · 520px and below   = iPhone portrait + small Androids
     · 380px and below   = iPhone mini / SE
   Paired with viewport meta `viewport-fit=cover` so safe-area
   insets resolve correctly on notch / Dynamic Island devices.
   ============================================================ */

/* ─── Universal: prevent horizontal overflow + safe-area pad ───── */
@media (max-width: 520px) {
  html, body { overflow-x: hidden; }

  /* page shell — tighter side gutters, safe-area home-bar pad */
  .page {
    padding: 80px 14px max(40px, env(safe-area-inset-bottom)) !important;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  /* tap targets: WCAG / Apple HIG floor of 44×44 */
  .btn,
  .pk-slate__btn,
  .db-range__btn,
  .pk-play__deeplink,
  .term-iconbtn,
  .term-slate-tab,
  .term-chip,
  .term-clear,
  .nav__link {
    min-height: 44px;
  }
  .btn { padding: 12px 18px; font-size: 12.5px; }

  /* eyebrow rule — shorter rules so the label fits */
  .eyebrow::before, .eyebrow::after { width: 18px; }

  /* footer */
  .site-footer { margin-top: 56px; padding-top: 32px; }
  .site-footer__links { gap: 14px 16px; }
  .site-footer__legal { font-size: 10.5px; padding: 0 4px; }
}

/* ──────────────────────────────────────────────────────────────
   AURUM NAV (used on Terminal + ported to Landing/Picks/Dashboard)
   ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .aurum .nav__inner { padding: 0 12px; height: 56px; }
  .aurum .nav__wordmark { font-size: 1.25rem; letter-spacing: 0.18em; }
  .aurum .nav__logo-img { height: 24px; width: 24px; }
}

/* ──────────────────────────────────────────────────────────────
   LANDING
   ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  /* hero */
  .lp-hero { padding: 16px 0 36px; gap: 28px; }
  .lp-hero__head {
    flex-wrap: wrap; row-gap: 6px; column-gap: 10px;
    font-size: 10px; letter-spacing: 2px; margin-bottom: 16px;
  }
  .lp-hero__title {
    font-size: clamp(44px, 13vw, 64px) !important;
    line-height: 0.95;
  }
  .lp-hero__sub { font-size: 14px; line-height: 1.55; }
  .lp-hero__cta { gap: 10px; width: 100%; }
  .lp-hero__cta .btn { flex: 1 1 calc(50% - 5px); justify-content: center; }
  .lp-hero__meta { font-size: 10px; letter-spacing: 1.5px; }

  /* "now" panel — tighten + restructure the per-game row so
     long pitcher names don't blow out the column */
  .lp-now__head { padding: 12px 14px; }
  .lp-now__title { font-size: 16px; }
  .lp-now__cell { padding: 10px 12px; }
  .lp-now__val  { font-size: 22px; }
  .lp-now__lab  { font-size: 9px; letter-spacing: 1.5px; }

  .lp-now__game {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "match edge"
      "match pick";
    column-gap: 12px; row-gap: 2px;
    padding: 10px 14px;
  }
  .lp-now__rank { display: none; }
  .lp-now__match { grid-area: match; min-width: 0; }
  .lp-now__match .pitch {
    font-size: 10.5px; margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .lp-now__edge { grid-area: edge; }
  .lp-now__pick { grid-area: pick; }

  .lp-now__foot { padding: 10px 14px; flex-wrap: wrap; gap: 6px; font-size: 10px; }

  /* thesis */
  .lp-thesis { padding: 40px 0; gap: 22px; }
  .lp-thesis__title { font-size: 28px; }
  .lp-thesis__copy p { font-size: 14px; line-height: 1.65; }

  /* yesterday tape — already 2col below 860; tighten cell padding */
  .lp-yest { padding: 36px 0; }
  .lp-yest__title { font-size: 22px; }
  .lp-yest__cell { padding: 14px 14px; }
  .lp-yest__val { font-size: 24px; }

  /* engine + cta — collapse engine to 1 col, reduce CTA chrome */
  .lp-engine { grid-template-columns: 1fr !important; gap: 16px !important; }
  .lp-engine__h { font-size: 18px; }
  .lp-cta { padding: 36px 22px !important; }
  .lp-cta__h { font-size: clamp(28px, 8vw, 40px) !important; }
}
@media (max-width: 380px) {
  .lp-hero__cta .btn { flex-basis: 100%; }
}

/* ──────────────────────────────────────────────────────────────
   PICKS
   ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .pk-head { gap: 14px; margin-bottom: 22px; }
  .pk-head__title { font-size: clamp(34px, 11vw, 48px) !important; }
  .pk-head__date { font-size: 11px; letter-spacing: 1.8px; }
  .pk-head__right { width: 100%; gap: 8px; }
  .pk-slate { width: 100%; }
  .pk-slate__btn { flex: 1; padding: 12px 10px; font-size: 10.5px; letter-spacing: 1.6px; }

  /* tape strip */
  .pk-tape__cell { padding: 12px 14px; }
  .pk-tape__val { font-size: 20px !important; }
  .pk-tape__lab { font-size: 9px; }

  /* qualified plays — already 1col below 920; mobile-specific tightening */
  .pk-section-h { margin: 28px 0 14px; }
  .pk-section-h__title { font-size: 20px; }

  .pk-play__rail { padding: 10px 14px !important; gap: 14px; align-items: baseline; }
  .pk-play__edge { font-size: 26px !important; }
  .pk-play__main { padding: 14px 16px; }
  .pk-play__matchup { font-size: 20px; }
  .pk-play__pitch { font-size: 11.5px; margin-bottom: 8px; }
  .pk-play__reasoning { font-size: 13.5px; line-height: 1.55; }
  .pk-play__call { padding: 14px 16px; border-top: 1px solid var(--c-rule); border-right: 0; }
  .pk-play__call-side { font-size: 19px; }
  .pk-play__aside { padding: 14px 16px; border-top: 1px solid var(--c-rule); }
  .pk-play__deeplink { padding: 10px 14px; font-size: 11px; align-self: stretch; text-align: center; }
  .pk-play__books { font-size: 11px; }

  /* skipped — full restructure: time + match on row 1, edge + why on row 2 */
  .pk-skipped__row {
    grid-template-columns: 64px 1fr auto !important;
    grid-template-areas:
      "time match edge"
      "why  why   why" !important;
    row-gap: 6px; column-gap: 10px;
    padding: 12px 14px !important;
  }
  .pk-skipped__time { grid-area: time; }
  .pk-skipped__match { grid-area: match; }
  .pk-skipped__edge { grid-area: edge; }
  .pk-skipped__why  {
    grid-area: why; padding-left: 0 !important;
    padding-top: 6px; border-top: 1px solid var(--c-rule-soft);
    font-size: 12px;
  }

  /* yesterday list — drop one column, let pick wrap under match */
  .pk-yest__item {
    grid-template-columns: 1fr auto auto !important;
    grid-template-areas:
      "match  score result"
      "pick   pick  pick" !important;
    column-gap: 10px; row-gap: 4px;
    padding: 12px 14px !important;
  }
  .pk-yest__match  { grid-area: match; }
  .pk-yest__pick   { grid-area: pick; color: var(--c-text); }
  .pk-yest__score  { grid-area: score; text-align: right; }
  .pk-yest__r      { grid-area: result; }
}

/* ──────────────────────────────────────────────────────────────
   DASHBOARD
   ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .db-head { gap: 14px; margin-bottom: 22px; }
  .db-head__title { font-size: clamp(34px, 11vw, 48px) !important; }
  .db-head__sub { font-size: 11px; letter-spacing: 1.6px; }
  .db-range { width: 100%; }
  .db-range__btn { flex: 1; padding: 12px 8px; font-size: 10.5px; letter-spacing: 1.5px; }

  /* KPI tiles — 2 across already; shrink number so + sign + 8.4 + u all fit */
  .db-kpi { padding: 16px 14px; }
  .db-kpi__lab { font-size: 9.5px; letter-spacing: 1.8px; }
  .db-kpi__val { font-size: 30px !important; margin-top: 6px; }
  .db-kpi__val .sgn  { font-size: 18px; }
  .db-kpi__val .unit { font-size: 13px; }
  .db-kpi__sub { font-size: 10.5px; }
  .db-kpi__spark { display: none; } /* spark sits under values otherwise */

  /* P/L chart — keep all 30 bars but compress vertical + tighten gap */
  .db-pnl__head { padding: 12px 14px; flex-wrap: wrap; gap: 4px; }
  .db-pnl__title { font-size: 16px; }
  .db-pnl__sub { font-size: 10px; }
  .db-pnl__chart { height: 110px; padding: 14px 12px 24px; gap: 2px; }
  .db-pnl__legend { padding: 0 14px 12px; gap: 12px; font-size: 10px; }

  /* CLV card */
  .db-clv { padding: 18px 16px; }
  .db-clv__title { font-size: 16px; }
  .db-clv__lede { font-size: 10px; margin-bottom: 12px; }
  .db-clv__row { gap: 10px; }
  .db-clv__bar { margin: 0 8px; }
  .db-clv__val { font-size: 12px; min-width: 52px; }
  .db-clv__note { font-size: 12px; line-height: 1.55; margin-top: 12px; }

  /* tables — wrap horizontal scroll so columns keep their widths */
  .db-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .db-table table { min-width: 480px; } /* let it scroll inside its frame */
  .db-table th, .db-table td { padding: 10px 12px !important; font-size: 11.5px; }
  .db-table th { font-size: 9.5px; letter-spacing: 1.5px; }

  /* hint that tables scroll — subtle right-edge gradient */
  .db-table {
    background-image: linear-gradient(to left, var(--c-panel) 0, transparent 24px),
                      linear-gradient(to right, var(--c-panel) 0, transparent 24px);
    background-position: right center, left center;
    background-size: 24px 100%, 24px 100%;
    background-repeat: no-repeat;
    background-attachment: local, local;
  }

  /* calibration plot — keep aspect, scale labels */
  .cal { padding: 14px; }
  .cal__chart { height: 200px; }
  .cal__axis-y, .cal__axis-x { font-size: 10px; }
  .cal__legend { font-size: 10px; gap: 10px; flex-wrap: wrap; }

  /* honest read */
  .db-honest { padding: 22px 18px !important; }
  .db-honest__h { font-size: 18px; }
  .db-honest__col h4 { font-size: 13px; }
  .db-honest__col p { font-size: 13px; line-height: 1.6; }

  /* shared section heading */
  .section-h { margin-bottom: 12px; }
  .section-h__title { font-size: 16px; }
  .section-h__sub { font-size: 10px; }
}

/* ──────────────────────────────────────────────────────────────
   TERMINAL — keep desktop matrix on iPad, swap to cards on phone.
   The cards already render; this tunes the surrounding chrome so
   nothing horizontally clips.
   ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* header strip — stack into 3 rows: status / search / actions */
  .term-header { padding: 12px 14px; }
  .term-header__inner {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .term-eyebrow { flex-wrap: wrap; row-gap: 4px; font-size: 10px; }
  .term-search { max-width: none !important; justify-self: stretch !important; }
  .term-search__input { padding: 12px 12px 12px 36px; font-size: 14px; }
  .term-actions { justify-self: stretch; gap: 8px; }
  .term-actions .term-iconbtn { flex: 1; justify-content: center; padding: 10px 8px; }

  /* slate tabs — let them scroll horizontally instead of squashing */
  .term-slate-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 14px;
  }
  .term-slate-tabs::-webkit-scrollbar { display: none; }
  .term-slate-tab { flex: 0 0 auto; padding: 12px 14px; font-size: 11px; }
  .term-slate-tab__lock { display: none; }

  /* filter bar — let each group take its own row */
  .term-filters {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 10px;
  }
  .term-filter-group { flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
  .term-filters__spacer { display: none; }
  .term-filters__count { align-self: flex-start; font-size: 10px; }
  .term-clear { align-self: flex-start; min-height: 36px; }
  .term-slider-wrap { flex: 1; min-width: 160px; }

  /* mobile banner — restate it as helpful, not punitive */
  .term-mobile-banner { font-size: 11.5px; line-height: 1.5; }

  /* mobile cards — already styled in terminal-detail.css; the only
     tuning we need is comfortable padding inside the page */
  .term-stage { padding: 14px 14px 32px !important; }
}

/* extra-small phones: stop the 4-up signal grid from squishing */
@media (max-width: 380px) {
  .mcard__signals { grid-template-columns: 1fr 1fr !important; }
}

/* ──────────────────────────────────────────────────────────────
   TWEAKS PANEL — keep it usable on phone (it's draggable, but it
   shouldn't open wider than the viewport)
   ────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .tweaks-panel,
  [class*="tweaks-panel"] {
    max-width: calc(100vw - 16px) !important;
    width: calc(100vw - 16px) !important;
  }
}
