/* ============================================================
   Mobile / smartphone responsive overrides
   Targets phones (≤ 720px) with a denser pass at ≤ 560px and
   ≤ 420px.  All large desktop layouts are preserved; this file
   only shrinks paddings, restacks grids, and rewires widgets
   that don't survive narrow widths (tabs, risk matrix, roadmap
   rail, wide tables, etc.).
   ============================================================ */

/* -----------------------------------------------------------
   <= 720px — tablet portrait / phablet
   ----------------------------------------------------------- */
@media (max-width: 720px) {

  :root {
    --gutter: 18px;
  }

  body { font-size: 16px; }

  /* Section spacing tightens */
  section { padding: 56px 0 64px; }

  /* Nav: hide subtle subtitle, keep glyph + active link */
  .nav { padding: 12px 14px; }
  .nav.scrolled { padding-top: 10px; padding-bottom: 10px; }
  .nav-mark .nav-mark-glyph { width: 30px; height: 30px; font-size: 12px; }
  .nav-links { gap: 0; padding: 3px; background: rgba(255,255,255,0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); }
  .nav-links a { padding: 7px 10px; font-size: 12.5px; }

  /* Hero */
  .hero { padding-top: 96px; padding-bottom: 48px; }
  .hero-meta { gap: 6px; }
  .hero-meta .chip { font-size: 12px; padding: 5px 10px; }
  .hero .display { font-size: clamp(40px, 13vw, 64px); }
  .hero-grid { gap: 28px; margin-top: 28px; }
  .hero-lede { gap: 22px; }
  .hero-cta { gap: 8px; }
  .hero-cta .btn { padding: 12px 18px; font-size: 14px; }
  .hero-card { padding: 20px; }
  .hero-card-row { padding: 10px 0; gap: 10px; }
  .hero-card-row .hero-card-v { font-size: 13.5px; }

  /* Method carousel */
  .method-carousel { margin-top: 40px; padding-top: 22px; }
  .method-carousel-head { gap: 12px; margin-bottom: 14px; }
  .method-carousel-track { padding: 6px var(--gutter) 18px; }
  .mc-card { flex-basis: 240px; min-height: 150px; padding: 16px; }

  /* Section heads — looser breathing room replaced with tighter */
  .section-head { gap: 14px; margin-bottom: 28px; }
  .section-head .section-meta { gap: 8px; padding-bottom: 12px; flex-wrap: wrap; }
  .section-head .section-meta > .mono.ink-3,
  .section-head .section-meta > .mono.ink-3:last-child { margin-left: 0; text-align: left; flex-basis: 100%; }
  .section-head .section-title { gap: 12px; }

  /* Buttons */
  .btn { padding: 12px 18px; font-size: 14px; }

  /* Cards & wrappers — uniformly trim heavy paddings */
  .card { padding: 20px; border-radius: var(--r-md); }
  .arch3-wrap,
  .roadmap,
  .riskmx,
  .npv-card,
  .sensitivity,
  .annot-block { padding: 18px; border-radius: var(--r-md); }
  .npv-card { padding: 22px; }
  .annot-block { padding: 20px; }

  /* Stats grid: switch to 2col here */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 36px; }
  .stat-card { padding: 16px 16px 18px; }
  .stat-num { font-size: clamp(28px, 8vw, 36px); }
  .stat-num .stat-unit { font-size: 0.4em; }

  /* Goal cards / tasks */
  .goal-card { padding: 18px; min-height: 0; }
  .tasks-toggle { padding: 16px 18px; }
  .tasks-item { grid-template-columns: 44px 1fr; gap: 12px; padding: 14px 18px; }
  .tasks-text { font-size: 14.5px; }

  /* Bank cards — fully stack rows */
  .bank-card { padding: 22px; }
  .bank-row { grid-template-columns: 1fr; gap: 4px; padding: 10px 0; }
  .bank-row dt { color: var(--ink-3); }
  .bank-row dd { font-size: 14px; }

  /* ============================================================
     Architecture diagram — 3 states.  The 3-tab segmented control
     does not fit at 540px+ width.  Switch to an equal-width grid
     and drop the animated slider; the active tab gets the dark fill.
     ============================================================ */
  .arch3-toolbar { gap: 14px; margin-bottom: 16px; }
  .arch3-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 3px;
    padding: 3px;
    width: 100%;
  }
  .arch3-tab {
    width: 100%;
    padding: 8px 6px;
    font-size: 11.5px;
    gap: 2px;
    flex-direction: column;
    line-height: 1.1;
  }
  .arch3-tab .mono:first-child { font-size: 9px; }
  .arch3-tab-name { font-size: 12px; }
  .arch3-tab-state { font-size: 9px; }
  .arch3-tab-slider { display: none; }
  .arch3-tab.active { background: var(--ink); border-radius: 100px; }

  .arch3-legend { gap: 8px 14px; font-size: 11px; }
  .arch3-stage { padding: 12px; }
  .arch3-stage-meta { font-size: 11px; flex-wrap: wrap; }

  .arch3-perimeter-head { padding: 12px; }
  .arch3-perimeter-counter strong { font-size: 18px; }
  .arch3-perimeter-body { padding: 4px 8px; }
  .arch3-row { padding: 10px 4px; }
  .arch3-chip { max-width: 100%; padding: 6px 10px; font-size: 12.5px; }
  .arch3-foot-cell p { font-size: 13px; }

  /* ============================================================
     Roadmap rail — flatten to a vertical stack of phase cards on
     mobile.  Absolute positioning of bars by month-% gives
     unreadable 20-30px-wide strips on a phone.
     ============================================================ */
  .roadmap-track { padding: 0; }
  .roadmap-rail {
    position: relative;
    height: auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
  }
  .roadmap-tick { display: none; }
  .roadmap-bar {
    position: relative !important;
    top: auto !important;
    left: 0 !important;
    width: 100% !important;
    height: auto;
    padding: 0;
  }
  .roadmap-bar-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    gap: 12px;
  }
  .roadmap-bar-name { font-size: 14px; }
  .roadmap-bar-state { font-size: 10px; white-space: nowrap; }

  .roadmap-detail { margin-top: 22px; padding-top: 22px; gap: 22px; }
  .roadmap-summary { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 22px; padding-top: 18px; }
  .roadmap-summary-cell { padding: 12px; }
  .roadmap-summary-cell strong { font-size: 18px; }

  /* ============================================================
     Risk matrix — squeeze the 5×5 grid, drop the rotated axis
     labels (they overflow), shrink dots.
     ============================================================ */
  .riskmx { gap: 18px; }
  .riskmx-board { padding-left: 0; padding-bottom: 12px; }
  .riskmx-axis-y, .riskmx-axis-x { display: none; }
  .riskmx-grid {
    grid-template-columns: 46px repeat(5, 1fr);
    aspect-ratio: auto;
    gap: 3px;
  }
  .riskmx-cell { min-height: 52px; padding: 4px; gap: 2px; }
  .riskmx-ylabel { padding-right: 4px; font-size: 9px; line-height: 1.15; }
  .riskmx-xlabel { font-size: 9px; padding-top: 4px; }
  .riskmx-dot {
    min-width: 26px;
    height: 18px;
    padding: 0 4px;
    font-size: 9.5px;
    border-width: 1px;
  }
  .riskmx-card { padding: 16px; min-height: 0; }
  .riskmx-stats { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; }
  .riskmx-stat { padding: 10px; }
  .riskmx-stat strong { font-size: 18px; }

  /* ============================================================
     NPV / economics tables — make horizontally scrollable
     ============================================================ */
  .npv-card.big { min-height: 0; }
  .npv-big { font-size: clamp(36px, 10vw, 48px); }
  .npv-table-wrap, .art-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .npv-table, .art-table { min-width: 520px; }
  .npv-table th, .npv-table td,
  .art-table th, .art-table td { padding: 8px 10px; font-size: 12px; }
  .npv-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .npv-row-cell { padding: 14px; }
  .npv-row-cell strong { font-size: 18px; }
  .sensitivity { padding: 18px; }
  .sensitivity-head { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Methodology / methods grids */
  .methodology-group { padding: 18px 0; gap: 12px; }
  .methodology-group-body { grid-template-columns: 1fr; gap: 8px; }
  .methodology-item { padding: 12px 30px 12px 14px; }
  .methodology-item-name { font-size: 14px; }
  .methodology-item-use { font-size: 12px; }

  /* Method cards (grid of 4) — switch to 1 col on small phones */
  .methods-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .method-card { padding: 16px; gap: 14px; }

  /* Artifacts tease */
  .art-tease { grid-template-columns: 1fr 1fr; gap: 10px; }
  .art-tease-card { padding: 14px; gap: 12px; }

  /* Author block */
  .author-grid { gap: 22px; }
  .author-supervisors { font-size: 14px; }

  /* ============================================================
     Footer — collapse to single column on phones
     ============================================================ */
  .site-footer { padding: 48px 0 24px; margin-top: 56px; }
  .site-footer .footer-grid { grid-template-columns: 1fr; gap: 26px; margin-bottom: 32px; }
  .site-footer h4 { margin-bottom: 10px; }
  .site-footer ul { gap: 8px; }

  /* ============================================================
     Pages: Artifacts
     ============================================================ */
  .art-page-hero { padding-top: 110px; padding-bottom: 28px; }
  .art-page-hero .h1 { font-size: clamp(34px, 9vw, 52px); }
  .art-page-hero .lead { margin-top: 14px; font-size: 16px; }
  .art-count-badge { display: inline-block; font-size: 12px; padding: 4px 10px; margin-left: 8px; transform: none; vertical-align: middle; }
  .art-toc { gap: 6px; margin-top: 22px; }
  .art-toc a { padding: 7px 11px; font-size: 12.5px; }

  .page-section-head { padding: 28px 0 16px; gap: 14px; }
  .page-section-head .section-meta { padding-bottom: 10px; flex-wrap: wrap; }
  .page-section-head .section-meta > .mono.ink-3,
  .page-section-head .section-meta > .mono.ink-3:last-child { margin-left: 0; text-align: left; flex-basis: 100%; }
  .page-section-head .lead { font-size: 15.5px; }
  .page-section-head .section-title { gap: 10px; }

  .artifacts-grid { gap: 12px; padding-bottom: 18px; }
  .artifact-tile .placeholder, .artifact-tile .placeholder.tall { min-height: 200px; padding: 16px; }
  .artifact-tile .at-foot { padding: 12px 14px; gap: 8px; }
  .artifact-tile .at-title { font-size: 14px; }

  /* Gantt — usable via horizontal scroll, just tighten label col */
  .art-gantt { --gantt-label-w: 200px; padding: 4px 0 8px; }
  .art-gantt-label { padding: 0 8px; font-size: 10.5px; }
  .art-gantt-id { min-width: 32px; font-size: 9.5px; padding: 1px 4px; }
  .art-gantt-legend { padding: 10px 14px; gap: 10px 16px; font-size: 11px; }

  /* ============================================================
     Pages: Documents
     ============================================================ */
  .doc-card { padding: 18px; }
  .doc-preview { height: 160px; padding: 14px; margin-bottom: 14px; }
  .doc-meta .doc-title { font-size: 16px; }
  .doc-meta .doc-sub { font-size: 13px; }
  .doc-meta .doc-action { margin-top: 14px; font-size: 13px; }

  /* Annotation block + side */
  .annot-body { font-size: 15px; line-height: 1.65; }
  .annot-side .annot-stat { padding: 14px; }
  .annot-side .annot-stat strong { font-size: 19px; }
  .annot-method-list li {
    grid-template-columns: 90px 1fr;
    gap: 10px;
    font-size: 12.5px;
  }

  /* Sources bar — stack search above filter */
  .sources-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
  }
  .sources-bar > .mono { font-size: 11px; letter-spacing: 0.06em; }
  .sources-bar input[type="search"] {
    border: 1px solid var(--line);
    background: var(--bg-deep);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 15px;
    min-width: 0;
    width: 100%;
  }
  .sources-filter {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    align-self: stretch;
    justify-content: flex-start;
  }
  .sources-filter::-webkit-scrollbar { display: none; }
  .sources-filter button { white-space: nowrap; font-size: 11.5px; padding: 6px 10px; flex-shrink: 0; }

  .source-row { padding: 14px 14px; gap: 6px; }
  .source-row .src-num { font-size: 11px; }
  .source-row .src-title { font-size: 13.5px; }
  .src-link { font-size: 11.5px; }
}

/* -----------------------------------------------------------
   <= 560px — typical phone portrait
   ----------------------------------------------------------- */
@media (max-width: 560px) {

  /* Show only active nav link on very narrow phones — saves room */
  .nav-mark .nav-mark-glyph { width: 28px; height: 28px; }
  .nav-links a { padding: 7px 9px; font-size: 12px; }
  .nav-links a:not(.active) { padding-left: 9px; padding-right: 9px; }

  /* Hero CTA full-width primary */
  .hero-cta { width: 100%; }
  .hero-cta .btn { flex: 1 1 auto; justify-content: center; }
  .hero-cta .btn:first-child { flex-basis: 100%; }

  /* Hero card — switch rows to label-on-top */
  .hero-card-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 0;
  }
  .hero-card-row .hero-card-v {
    text-align: left;
    font-size: 14px;
  }

  /* Single-column for densest grids */
  .methods-grid { grid-template-columns: 1fr; }
  .art-tease { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .npv-row { grid-template-columns: 1fr; }
  .roadmap-summary { grid-template-columns: 1fr 1fr; }
  .riskmx-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .doc-grid { grid-template-columns: 1fr; }

  /* Risk matrix gets a bit more breathing room */
  .riskmx-grid { grid-template-columns: 40px repeat(5, 1fr); }
  .riskmx-cell { min-height: 46px; }
  .riskmx-dot { min-width: 22px; height: 16px; font-size: 9px; }
  .riskmx-ylabel { font-size: 8.5px; padding-right: 2px; }

  /* Arch3 tabs: hide tertiary “mono” code line, keep only name+state */
  .arch3-tab .mono:first-child { display: none; }
  .arch3-tab-state { font-size: 8.5px; }
  .arch3-tab-name { font-size: 11.5px; }

  /* Annot method list: stack each row */
  .annot-method-list li {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px 0;
  }
  .annot-method-list li .mono { font-size: 9.5px; }

  /* Supervisor rows fully stack */
  .sup-row { grid-template-columns: 1fr; gap: 4px; padding: 12px 0; }

  /* Hero subtitle text becomes more compact */
  .hero .display { font-size: clamp(38px, 14vw, 56px); line-height: 1.0; }
  .h1 { font-size: clamp(30px, 9vw, 44px); }
  .h2 { font-size: clamp(24px, 6.5vw, 32px); }
  .lead { font-size: 15.5px; }

  /* Method carousel cards a bit smaller */
  .mc-card { flex-basis: 220px; min-height: 140px; padding: 14px; }
  .mc-name { font-size: 17px; }

  /* Lightbox already handles small screens — keep nav buttons tighter */
  .art-lightbox-topbar { padding: 12px 14px 10px; }
  .art-lightbox-num { padding: 3px 8px; font-size: 11px; }
}

/* -----------------------------------------------------------
   <= 420px — very small phones (iPhone SE, etc.)
   ----------------------------------------------------------- */
@media (max-width: 420px) {

  :root { --gutter: 14px; }

  /* Nav — collapse to glyph + dark pill of active link only */
  .nav { padding: 10px 12px; }
  .nav-links a .num { display: none; }
  .nav-links a:not(.active) { display: none; }
  .nav-links a.active { padding: 7px 14px; }

  /* Hero title: a bit smaller, retains impact */
  .hero { padding-top: 84px; }
  .hero .display { font-size: clamp(34px, 14vw, 48px); }

  /* Stats / risk stats fully list */
  .stat-grid { gap: 10px; }
  .riskmx-stats { grid-template-columns: 1fr 1fr; }
  .roadmap-summary { grid-template-columns: 1fr; }

  /* Section heads tighter */
  .page-section-head { padding: 22px 0 12px; }
  section { padding: 44px 0 52px; }

  /* Cards even tighter */
  .arch3-wrap, .roadmap, .riskmx, .sensitivity, .annot-block { padding: 14px; }
  .npv-card { padding: 18px; }
  .bank-card { padding: 18px; }

  /* Risk matrix: minimal y-label width */
  .riskmx-grid { grid-template-columns: 36px repeat(5, 1fr); gap: 2px; }
  .riskmx-cell { min-height: 42px; padding: 3px; }
  .riskmx-ylabel { font-size: 8px; padding-right: 2px; }
  .riskmx-xlabel { font-size: 8px; }
  .riskmx-dot { min-width: 20px; height: 15px; font-size: 8.5px; padding: 0 3px; border-width: 1px; }
}

/* -----------------------------------------------------------
   Touch / pointer hints (coarse pointers only)
   ----------------------------------------------------------- */
@media (hover: none) and (pointer: coarse) {
  /* Hide hover-only hint affordances that confuse on touch */
  .mc-head-hint { display: none; }
  .art-tease-zoom, .art-img-zoom { display: none; }

  /* Ensure tappable hit targets ≥ 40px */
  .nav-links a { min-height: 36px; }
  .btn { min-height: 44px; }
  .mc-ctrl { width: 40px; height: 40px; }
}
