/* Responsive layer — adapts the fixed 1920 design to tablet & mobile.
   Everything here is max-width gated, so the desktop design (>=1281px) is
   left exactly as authored; >=1920 stays pixel-faithful. Type uses clamp()
   with the desktop value as the ceiling, so the breakpoint is seamless and
   it scales down cleanly from there. */

/* Drawer plumbing — hidden on desktop, switched on below 1024px. */
.nav-toggle { display: none; }
.nav-overlay { display: none; }

/* ===================== Tablet & below (<= 1280px) ===================== */
@media (max-width: 1280px) {
  :root { --gutter: 40px; }

  .header-inner { padding-inline: 40px; }

  /* Hero — stop absolute-positioning the terminal; stack to one column. */
  .hero { height: auto; padding: 150px 0 84px; }
  .hero-inner { flex-direction: column; align-items: flex-start; padding-left: 0; padding-inline: var(--gutter); gap: 56px; }
  .hero-copy { padding-top: 0; max-width: 780px; }
  .hero-title { font-size: clamp(38px, 6.2vw, 67px); line-height: 1.12; }
  .hero-lede { font-size: clamp(17px, 1.9vw, 24px); line-height: 1.55; }
  .hero-lede br { display: none; }
  .hero-terminal { position: static; inset: auto; width: 100%; max-width: 780px; }
  .hero-terminal .terminal-body { overflow-x: auto; }

  /* Section headings scale (ceiling = desktop size -> seamless at 1280). */
  .about-title, .toolkit-title, .lifecycle-title, .reference-title, .why-title, .inaction-title {
    font-size: clamp(34px, 4.6vw, 57px); line-height: 1.16;
  }
  .community-title { font-size: clamp(32px, 4.1vw, 50px); }
  .pip-title { font-size: clamp(30px, 3.6vw, 44px); }

  /* Grid reflow: About 4->2, Toolkit 3->2 (Why/Community stay 3 until mobile). */
  .pillar-grid { grid-template-columns: repeat(2, 1fr); }
  .toolkit-grid { grid-template-columns: repeat(2, 1fr); }

  /* Reference: stack copy above terminal. */
  .reference-grid { grid-template-columns: 1fr; gap: 40px; align-items: stretch; }
  .reference-copy { transform: none; }

  /* Lifecycle: tab rail wraps; the two panels stack. */
  .step-tabs { flex-wrap: wrap; }
  .stepper-panels { grid-template-columns: 1fr; height: auto; }
  .stage-terminal { min-height: 340px; }
  .stage-terminal .terminal-body { overflow-x: auto; }

  /* Pip console becomes fluid. */
  .pip-console { width: 100%; max-width: 1160px; }
}

/* ===================== Nav -> drawer (<= 1023px) ===================== */
@media (max-width: 1023px) {
  .brand { margin-right: auto; }

  .nav-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 46px; height: 44px; margin-left: 14px; padding: 0 11px;
    border: 1px solid var(--line-btn); border-radius: 9px; background: #0c0c0c;
  }
  .nav-toggle-bar {
    display: block; width: 100%; height: 2px; border-radius: 2px; background: var(--text-hi);
    transition: transform 160ms ease, opacity 160ms ease;
  }
  .site-header.nav-open .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .site-header.nav-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
  .site-header.nav-open .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .site-nav {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(330px, 84vw);
    flex-direction: column; align-items: stretch; gap: 4px;
    margin: 0; padding: 92px 26px 32px;
    background: #050807; border-left: 1px solid var(--line-card);
    transform: translateX(100%); transition: transform 200ms ease;
    z-index: 60; overflow-y: auto;
  }
  .site-header.nav-open .site-nav { transform: translateX(0); }
  .site-nav a { font-size: 20px; padding: 13px 4px; border-bottom: 1px solid #11201b; }

  .nav-overlay {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(2px);
  }
  .nav-overlay[hidden] { display: none; }

  .header-inner { height: 72px; }
  .btn-github { height: 42px; padding: 0 15px; font-size: 14px; }
}

/* ===================== Mobile (<= 767px) ===================== */
@media (max-width: 767px) {
  :root { --gutter: 20px; }
  .header-inner { padding-inline: 20px; }

  .hero { padding: 104px 0 60px; }
  .hero-title { font-size: clamp(30px, 8.6vw, 48px); }
  .hero-actions { flex-wrap: wrap; gap: 14px; }
  .hero-actions .btn { width: 100%; }

  /* All card grids collapse to one column. */
  .pillar-grid, .toolkit-grid, .why-grid, .community-grid, .report-grid {
    grid-template-columns: 1fr; gap: 16px;
  }
  .report-grid { gap: 20px; }
  /* Let tall fixed minimums size to content on small screens. */
  .pillar-grid .card, .tool-card, .why-card { min-height: 0; }

  /* Tighten the large vertical rhythm. */
  .about { padding: 64px 0 56px; }
  .toolkit { padding-block: 64px; }
  .lifecycle { padding: 64px 0 56px; }
  .reference { padding: 56px 0 64px; }
  .why { padding: 64px 0 56px; }
  .pip { padding: 56px 0 64px; }
  .community { padding: 56px 0 64px; }

  /* Stepper: tab rail scrolls horizontally; controls wrap. */
  .step-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .step-tab { flex: 0 0 auto; }
  .stage-card { padding: 24px; }
  .stage-nav { flex-wrap: wrap; gap: 12px; }
  .stage-progress { order: 3; flex-basis: 100%; }

  /* Pip: actions wrap, console body stacks. */
  .pip-actions { flex-wrap: wrap; gap: 12px; margin-top: 40px; }
  .pip-btn { flex: 1 1 auto; justify-content: center; }
  .pip-console-body { flex-direction: column; align-items: stretch; gap: 18px; padding: 28px 22px; }
  .pip-cmd { font-size: 16px; word-break: break-all; text-align: center; }
  .pip-copy { justify-content: center; }

  /* Footer stacks. */
  .footer-inner { flex-direction: column; gap: 16px; height: auto; padding-block: 40px; text-align: center; }
}

/* ===================== Small phones (<= 419px) ===================== */
@media (max-width: 419px) {
  .hero-title { font-size: clamp(25px, 9vw, 36px); }
  .brand-word { font-size: 24px; }
  .brand-mark { width: 32px; height: 32px; font-size: 16px; }
  .btn-github { padding: 0 11px; font-size: 13px; }
  .btn-github svg { width: 16px; height: 16px; }
  .step-tab { font-size: 13px; padding: 16px 12px; }
  .stage-terminal .terminal-body,
  .report-body,
  .reference-term-body { font-size: 13px; }
  .pip-cmd { font-size: 14px; }
}
