/* FastballHQ — mobile layout & touch UX (loaded last; desktop ≥901px unchanged via overrides below)
 *
 * Policy: do not change default/board/inner/page CSS for desktop. New layout tweaks go only inside
 * @media (max-width: 900px) here (and existing @media (max-width: 1100px) for Picks sidebar in this file).
 * Exceptions: page-scoped @media in fastballhq-digest.css etc. must also use max-width ≤900px only.
 */
:root {
  --fq-mq-nav: 900px;
  --fq-header-h: 54px;
  --fq-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Mobile-only: Tipstrr verification strip (below ticker) */
.fq-mobile-tipstrr-strip {
  display: none;
}

/* ── Horizontal scroll for wide tables (touch-friendly) ── */
@media (max-width: 900px) {
  .sched-wrap,
  .stats-wrap,
  .results-track-page .results-wrap,
  .teams-stats-page .teams-wrap,
  .teams-stats-page .trf-table-wrap,
  .team-detail-page .td-table-wrap,
  .team-detail-page .td-splits-wrap,
  .pt-page .sched-wrap {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
  }

  .sched-table {
    min-width: 900px;
  }
  .sched-wrap--home .sched-table {
    min-width: 0;
  }
  .stats-table {
    min-width: 640px;
  }
  .results-track-page .results-table {
    min-width: 780px;
  }
  .team-detail-page .td-table {
    min-width: 560px;
  }
  .team-detail-page .td-splits-table {
    min-width: 420px;
  }
  /* Full table width — scroll horizontally (column hiding removed in fastballhq-teams.css) */
  .teams-stats-page .teams-table {
    min-width: 980px;
  }
  .teams-stats-page .trf-table {
    min-width: 720px;
  }

  /* No horizontal page pan — only table wrappers (sched-wrap, etc.) scroll sideways */
  html {
    overflow-x: hidden;
    max-width: 100%;
  }
  body.fq-site {
    font-size: 16px;
    line-height: 1.55;
    overflow-x: hidden;
    max-width: 100%;
  }

  .fq-inner-main,
  .page,
  .results-track-page,
  .teams-stats-page,
  .team-detail-page,
  .digest-page,
  .static-body {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    padding-bottom: calc(3rem + var(--fq-safe-bottom));
  }

  .page {
    min-width: 0;
  }
  .main-col {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
  }
  .hero-banner {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .hero-banner--home {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  .breadcrumb {
    padding-left: 0;
    padding-right: 0;
    flex-wrap: wrap;
    row-gap: 4px;
    font-size: 0.8rem;
  }

  .site-footer .footer-inner {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  .footer-nav-main {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    row-gap: 0.65rem;
  }
  .footer-nav-main a,
  .footer-legal-links a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0;
  }

  .filter-tabs,
  .results-track-page .filter-tabs,
  .teams-stats-page .div-filters {
    flex-wrap: wrap;
    gap: 8px;
  }
  /* Results filter chips: compact rules in fastballhq-results.css (loads after this file) */
  .teams-stats-page .div-btn {
    min-height: 40px;
    padding: 8px 14px;
  }

  .sched-filters button,
  .pt-filter-btn {
    min-height: 40px;
  }

  .sec-label-link,
  .inner-section-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Slightly larger table cell text on small screens */
  .sched-table td {
    font-size: 0.88rem;
  }
  .stats-table th,
  .stats-table td {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .hero-banner .hero-right {
    align-items: center;
    gap: 0.45rem;
  }

  /* Tipstrr: one compact row (logo + label), smaller than desktop */
  .hero-banner .hero-verified-badge {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    max-width: 100%;
    padding: 0.28rem 0.4rem;
    font-size: 0.52rem;
    letter-spacing: 0.05em;
  }
  .hero-banner .hero-verified-logo {
    height: 16px;
    max-width: 64px;
    opacity: 0.85;
  }
  .hero-banner .hero-verified-line {
    gap: 0.15rem;
    flex-wrap: nowrap;
  }
  .hero-banner .hero-verified-text {
    font-size: inherit;
    font-weight: 700;
    white-space: nowrap;
  }
  .hero-banner .hero-verified-icon {
    width: 11px !important;
    height: 11px !important;
    vertical-align: -0.1em;
  }

  /* Shorter date in header — frees space for logo + menu button */
  .date-tag--full {
    display: none !important;
  }
  .date-tag--short {
    display: inline !important;
  }

  /* Test-mode line: full-width bar above scoreboard ticker (not squeezed in header row) */
  .fq-header-test-note--header {
    display: none !important;
  }
  .fq-header-test-note--pre-ticker {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.4rem max(1rem, env(safe-area-inset-left, 0px)) 0.4rem max(1rem, env(safe-area-inset-right, 0px));
    font-size: 0.58rem;
    line-height: 1.35;
    letter-spacing: 0.02em;
    text-align: center;
    align-self: stretch;
    background: var(--bg2, #131315);
    border-bottom: 1px solid var(--border, #2a2a30);
    flex: none;
  }
  .fq-header-test-note--pre-ticker .fq-header-test-note__text {
    text-align: center;
    border-bottom: none;
    padding-bottom: 0;
    max-width: 42rem;
    margin: 0 auto;
    display: inline-block;
  }

  .site-header {
    overflow: visible;
    max-width: 100%;
  }
  .sec-label {
    min-width: 0;
    max-width: 100%;
  }
  .site-header .logo {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.05rem;
    letter-spacing: 0.04em;
  }
  .header-logo-cluster,
  .footer-logo-cluster {
    gap: 0.35rem;
    min-width: 0;
  }
  .header-mlb-mark {
    height: 33px;
    max-width: 51px;
  }

  /* Hero stat strip — wrapped grid inside viewport (no sideways page scroll) */
  .hero-banner .hero-stats.hero-stats-strip,
  .hero-banner .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: visible;
    overflow-y: visible;
    gap: 0;
    border-radius: 4px;
  }
  .hero-banner .hstat {
    min-width: 0;
    padding: 0.28rem 0.3rem;
    border-right: 1px solid var(--border, #2a2a30);
    border-bottom: 1px solid var(--border, #2a2a30);
  }
  .hero-banner .hstat:nth-child(3n) {
    border-right: none;
  }
  .hero-banner .hstat:nth-child(n + 4) {
    border-bottom: none;
  }
  /* Five tiles: second row = two cells */
  .hero-banner .hstat:nth-child(4) {
    grid-column: 1;
  }
  .hero-banner .hstat:nth-child(5) {
    grid-column: 2;
  }
  .hero-banner .hstat-val {
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.05;
  }
  .hero-banner .hstat-lbl {
    font-size: 0.4rem;
    margin-top: 2px;
    letter-spacing: 0.05em;
    line-height: 1.15;
  }

  .pt-page .hero-banner .hero-stats-strip .hstat-val,
  .nrfi-page-main .hero-banner .hstat-val {
    font-size: 0.72rem;
    font-weight: 800;
  }

  /* Hero titles: board.css clamp() floor is ~2.8rem — too tall on phones */
  .hero-banner .hero-title {
    font-size: clamp(1.55rem, 6.5vw, 2.65rem);
    line-height: 0.96;
  }

  /* Red kicker line (MLB · season · date · ET) — smaller on phones */
  .hero-kicker {
    font-size: 0.52rem;
    letter-spacing: 0.1em;
    margin-bottom: 0.28rem;
    line-height: 1.35;
  }

  /* Table scroll hints (paired with templates/components/table_scroll_hint.html) */
  .fq-table-scroll-hint {
    display: block;
    font-family: var(--mono, "JetBrains Mono", monospace);
    font-size: 0.62rem;
    color: #6a6a7e;
    margin: 0 0 0.45rem;
    letter-spacing: 0.04em;
    line-height: 1.35;
  }

  /* Home: sidebar widgets stack (board.css uses 2-col for 901–1100px) */
  .page .sidebar {
    grid-template-columns: 1fr;
  }

  /* Editor's Picks: one card per row, compact (home + any .picks-row on board routes) */
  .picks-row:not(.picks-row--scroll) {
    min-width: 0;
    max-width: 100%;
    grid-template-columns: 1fr !important;
    gap: 0.6rem;
  }
  .picks-row:not(.picks-row--scroll) .pick {
    min-width: 0;
    max-width: 100%;
  }
  /* Many Editor's Picks: keep horizontal swipe row on small screens */
  .picks-row--scroll {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
    grid-template-columns: unset !important;
    gap: 0.75rem;
    padding-bottom: 8px;
  }
  .picks-row--scroll .pick {
    flex: 0 0 min(280px, 86vw);
    min-width: min(280px, 86vw);
    max-width: min(320px, 90vw);
  }
  .picks-row .pick--wide .pick-inner {
    flex-direction: column;
  }
  .picks-row .pick--wide .pick-body {
    border-right: none;
  }
  .picks-row .pick--wide .pick-foot {
    width: auto;
    border-top: 1px solid var(--border, #2a2a30);
    padding: 0.5rem 0.65rem;
  }
  .picks-row .pick-head {
    padding: 0.42rem 0.6rem;
  }
  .picks-row .pick-body {
    padding: 0.5rem 0.6rem;
  }
  .picks-row .pick-foot {
    padding: 0.5rem 0.6rem;
  }
  .picks-row .pick-teams {
    font-size: 0.82rem;
  }
  .picks-row .pick-teams--full {
    font-size: 0.78rem;
    line-height: 1.2;
  }
  .picks-row .pick-matchup-strip {
    gap: 0.4rem;
    margin-bottom: 0.35rem;
  }
  .picks-row .pick-matchup-strip .fb-logo-wrap {
    --fb-box: 1.6rem;
  }
  .picks-row .pick-meta {
    font-size: 0.56rem;
    margin-bottom: 0.4rem;
  }
  .picks-row .pick-pitchers-grid {
    gap: 0.35rem;
    margin-bottom: 0.45rem;
  }
  .picks-row .pick-pitcher-tile {
    padding: 0.35rem 0.4rem;
  }
  .picks-row .pick-pitcher-photo {
    width: 30px;
    height: 30px;
  }
  .picks-row .pick-pitcher-name {
    font-size: 0.7rem;
  }
  .picks-row .pick-stat-badge {
    font-size: 0.48rem;
    padding: 2px 4px;
  }
  .picks-row .pick-dots {
    margin-bottom: 0.45rem;
    gap: 4px;
  }
  .picks-row .dot-tag {
    font-size: 0.55rem;
    padding: 3px 6px;
    min-height: 1.4rem;
  }
  .picks-row .pick-snippet {
    font-size: 0.78rem;
    line-height: 1.45;
    margin-bottom: 0.35rem;
  }
  .picks-row .pick-ms {
    font-size: 0.82rem;
    padding: 2px 6px;
  }
  .picks-row .pick-fq-bar-hint {
    font-size: 0.5rem;
    max-width: 9rem;
  }
  .picks-row .pick-foot-main {
    gap: 0.35rem;
  }
  .picks-row .pick-signal {
    font-size: 0.72rem;
  }
  .picks-row .pick-odds {
    font-size: 0.62rem;
  }
  .picks-row .pick-cta {
    font-size: 0.68rem;
  }
  .picks-row .pick-chips,
  .picks-row .editor-pick-chips-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .board-pick-card,
  .pt-picks-detail .ptpd-card {
    min-width: 0;
    max-width: 100%;
  }

  /* Picks Today — season record table */
  .pt-results-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
  }
  .pt-results-table {
    min-width: 560px;
  }

  /* NRFI page — slate/season tables (inner.css uses overflow:hidden on wraps) */
  .nrfi-page-main .nrfi-slate-wrap,
  .nrfi-page-main .nrfi-season-wrap {
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
  }
  .nrfi-slate-table {
    min-width: 680px;
  }
  .nrfi-season-table {
    min-width: 520px;
  }

  /* Game detail — batter / game log tables (class on panel; avoids relying on :has() alone) */
  .gd-page .gd-panel.gd-panel--table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
  }
  .gd-player-table,
  .gd-log-table {
    min-width: 420px;
  }

  /* Static pages — link rows wrap */
  .static-page .static-link-row {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    justify-content: flex-start;
  }
  .static-page .static-link-row a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .inner-section-head {
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
  }

  /* Best bets (Tailwind-heavy page) */
  .best-bets-page {
    padding-bottom: 2rem;
  }
  .best-bets-page h1 {
    font-size: clamp(1.45rem, 5vw, 2.25rem);
    line-height: 1.1;
  }

  /* Ticker: keep animation inside bar (no body overflow) */
  .scoreboard-ticker {
    max-width: 100vw;
  }
}

/* Picks Today: hide right sidebar on narrow/tablet widths — avoids overlap with main column */
@media (max-width: 1100px) {
  .pt-page .pt-sidebar {
    display: none !important;
  }
  .pt-page .pt-two-col {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
}

/* ── Hamburger + drawer (max-width 900px only) ── */
.fq-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border, #2a2a30);
  border-radius: 6px;
  background: var(--bg3, #212126);
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.fq-nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text, #eaeaee);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
body.fq-nav-open .fq-nav-toggle .fq-nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
body.fq-nav-open .fq-nav-toggle .fq-nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
body.fq-nav-open .fq-nav-toggle .fq-nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.fq-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--fq-header-h);
  z-index: 240;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* Mobile: backdrop blur breaks drawer legibility in some WebKit/Firefox stacks; keep dim only. */
@media (max-width: 900px) {
  .fq-nav-backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    z-index: 550;
  }
}

@media (max-width: 900px) {
  .header-inner {
    flex-wrap: nowrap;
    gap: 0.75rem;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    min-height: var(--fq-header-h);
    height: auto;
  }

  .header-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }

  .header-right {
    margin-left: 0;
  }

  /* Test-mode line uses .fq-header-test-note--pre-ticker above ticker (not this row). */
  .header-right .date-tag {
    font-size: 0.62rem;
    padding: 4px 8px;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fq-nav-toggle {
    display: flex;
    position: relative;
    z-index: 620;
  }

  /* Drawer sits above dimmer: sibling backdrop was painting over fixed nav (nav inside header). */
  body.fq-nav-open .site-header {
    position: relative;
    z-index: 600;
  }

  .site-header .fq-primary-nav {
    position: fixed;
    top: var(--fq-header-h);
    right: 0;
    width: min(100%, 20rem);
    max-width: 100%;
    height: calc(100dvh - var(--fq-header-h));
    margin: 0;
    padding: 0.5rem 0 calc(1rem + var(--fq-safe-bottom));
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    background: rgba(19, 19, 21, 0.98);
    border-left: 1px solid var(--border, #2a2a30);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
    z-index: 610;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.22s ease, visibility 0.22s;
  }

  body.fq-nav-open .site-header .fq-primary-nav {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  body.fq-nav-open .fq-nav-backdrop {
    display: block;
  }

  .site-header .fq-primary-nav a {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 48px;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border, #2a2a30);
    border-left: 3px solid transparent;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    justify-content: flex-start;
  }
  .site-header .fq-primary-nav a.active {
    border-bottom-color: var(--border, #2a2a30);
    border-left-color: var(--red, #e8473f);
    background: rgba(232, 71, 63, 0.06);
  }

  body.fq-nav-open {
    overflow: hidden;
  }

  .fq-mobile-tipstrr-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.85rem;
    margin: 0;
    padding: 0.4rem 1rem 0.45rem;
    font-size: 0.68rem;
    line-height: 1.4;
    color: #8e8e9e;
    background: rgba(240, 165, 0, 0.07);
    border-bottom: 1px solid rgba(240, 165, 0, 0.18);
  }
  .fq-mobile-tipstrr-strip__text {
    flex: 1 1 12rem;
    min-width: 0;
  }
  .fq-mobile-tipstrr-strip__link {
    flex: 0 0 auto;
    font-family: var(--mono, "JetBrains Mono", monospace);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gold, #f0a500);
    text-decoration: none;
    border-bottom: 1px solid rgba(240, 165, 0, 0.35);
    padding-bottom: 1px;
  }
  .fq-mobile-tipstrr-strip__link:hover {
    color: #e8c46a;
  }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .site-header .fq-primary-nav {
    transition: none;
  }
  .fq-nav-toggle-bar {
    transition: none;
  }
}

/* Desktop: hamburger off, backdrop hidden */
@media (min-width: 901px) {
  .fq-nav-toggle {
    display: none !important;
  }
  .fq-nav-backdrop {
    display: none !important;
  }
}
