/* =============================================================
   intentfirst.ai — Context Grammar Section Shared Styles
   Requires: tokens.css, components.css loaded first
   Used by: context-grammar/*.html only
   =============================================================

   Contents:
   1. Page wrapper (.page)
   2. Hero section (.hero, .hero-label, .hero-title, .hero-sub)
   3. Content section wrapper (.content-section, .content-inner)
   4. Section dividers (.section-divider + color modifiers)
   5. Intro prose (.prose)
   6. Arch-card layout (.arch-cards, .arch-card)
   7. Readiness stars (.readiness, .readiness-stars)
   8. Content title alias (.content-title)
   9. Why This Matters (.why-matters)
  10. TOC Preview Cards (.toc-grid, .toc-card)
  11. Start Here (.start-here)
   ============================================================= */

/* ── 1. Page wrapper ── */
.page {
  padding-top: 56px;  /* nav height */
}

/* ── 2. Hero Section ── */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #08070b;
  color: #f0ece4;
  position: relative;
  overflow: hidden;
  padding: clamp(100px, 14vh, 160px) clamp(24px, 4vw, 48px) clamp(60px, 8vh, 100px);
}

/* Dark nav pages with subnav: hero covers nav+subnav area (96px combined).
   Without this, the body's 96px padding-top exposes the white body background
   behind the transparent nav, making light-coloured nav links unreadable. */
body[data-dark-nav].nav-has-subnav {
  padding-top: 0 !important;
}
body[data-dark-nav].nav-has-subnav .hero {
  padding-top: calc(96px + clamp(100px, 14vh, 160px));
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, rgba(74,106,144,0.06), transparent);
  pointer-events: none;
}

/* Default hero typography — pages override where different */
.hero-label {
  font-family: var(--font-mono);
  font-size: clamp(11px, 0.85vw, 13px);
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(240,236,228,0.35);
  margin-bottom: 24px;
  opacity: 0;
  animation: fadeUp 0.8s 0.2s forwards;
}
.hero-title {
  font-weight: var(--hero-title-weight, 500);
  font-size: var(--hero-title-size, clamp(32px, 4.5vw, 58px));
  line-height: 1.08;
  letter-spacing: var(--hero-title-tracking, -2px);
  color: #f0ece4;
  margin-bottom: 24px;
  max-width: 820px;
  opacity: 0;
  animation: fadeUp 0.8s 0.4s forwards;
}
.hero-sub {
  font-size: var(--hero-sub-size, clamp(17px, 1.4vw, 22px));
  font-weight: var(--hero-sub-weight, 400);
  color: var(--hero-sub-color-dark, rgba(240,236,228,0.82));
  max-width: 620px;
  line-height: 1.75;
  margin: 0 auto;
  opacity: 0;
  animation: fadeUp 0.8s 0.6s forwards;
}
.hero-scroll-hint {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  animation: fadeUp 0.8s 1s forwards;
}
.hero-scroll-hint span {
  display: block;
  width: 1px;
  height: 40px;
  background: rgba(240,236,228,0.15);
  margin: 0 auto;
  animation: scrollPulse 2s ease-in-out infinite;
}
@keyframes scrollPulse {
  0%, 100% { transform: scaleY(1); opacity: 0.3; }
  50% { transform: scaleY(1.4); opacity: 0.6; }
}

/* ── 2b. Hero — split layout (text left, illustration right) ── */
body[data-dark-nav].nav-has-subnav .hero.hero--split {
  padding-top: 96px;
  padding-bottom: 24px;
  min-height: 100vh;
}
.hero--split {
  flex-direction: row !important;
  align-items: center !important;
  text-align: left !important;
  gap: clamp(32px, 5vw, 80px);
  padding-left: clamp(24px, 5vw, 80px);
  padding-right: clamp(24px, 5vw, 80px);
}
.hero--split .hero-title,
.hero--split .hero-label,
.hero--split .hero-sub { margin-left: 0; margin-right: 0; }
.hero-split-text { flex: 0 0 auto; max-width: 400px; }
.hero-illu {
  flex: 1 1 auto;
  max-width: 620px;
  height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: fadeUp 0.8s 0.8s forwards;
}
.hero-illu img {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  display: block;
}
.hero-illu .ga { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.hero-illu .ga svg { width: 100%; height: auto; max-width: 520px; max-height: calc(100vh - 160px); display: block; }

/* ── 2c. Hero — mobile rules ──
   Placed AFTER the desktop `.hero--split { flex-direction: row !important }`
   so source order favors them at ≤768px (specificity and !important are
   equal between desktop and mobile rules). */
@media (max-width: 768px) {
  /* Mobile: 56px nav + 44px subnav = 100px top offset */
  body[data-dark-nav].nav-has-subnav .hero {
    padding-top: calc(100px + clamp(40px, 8vh, 80px));
  }
  body[data-dark-nav].nav-has-subnav .hero.hero--split {
    min-height: 100vh;
    padding-top: 116px;
    padding-bottom: 32px;
  }
  /* Stack the split layout vertically on mobile */
  .hero--split {
    flex-direction: column !important;
    align-items: stretch !important;
    text-align: left !important;
    justify-content: flex-start;
    gap: clamp(20px, 4vh, 32px);
    padding-left: 20px;
    padding-right: 20px;
  }
  .hero--split .hero-split-text {
    flex: 0 0 auto;
    max-width: 100%;
    width: 100%;
  }
  .hero--split .hero-illu {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 45vh;
  }
  .hero--split .hero-illu img,
  .hero--split .hero-illu .ga svg {
    max-height: 45vh;
    width: 100%;
    height: auto;
    object-fit: contain;
    transform: none;
  }
  /* Non-split heroes: shrink the illustration */
  .hero:not(.hero--split) .hero-illu { flex: 1 1 auto; }
  .hero:not(.hero--split) .hero-illu img {
    max-height: 60vh;
    transform: scale(1.2);
  }
  /* Tighter hero typography on mobile */
  .hero-title {
    font-size: clamp(28px, 8vw, 40px);
    letter-spacing: -1px;
    max-width: 100%;
  }
  .hero-label { letter-spacing: 2px; }
  .hero-sub {
    font-size: clamp(15px, 4.2vw, 18px);
    line-height: 1.6;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  body[data-dark-nav].nav-has-subnav .hero.hero--split {
    padding-top: 100px;
    padding-bottom: 24px;
  }
  .hero--split {
    padding-left: 16px;
    padding-right: 16px;
    gap: 20px;
  }
  .hero--split .hero-illu,
  .hero--split .hero-illu img,
  .hero--split .hero-illu .ga svg {
    max-height: 38vh;
  }
  .hero-title { font-size: clamp(26px, 8.5vw, 34px); letter-spacing: -0.5px; }
}

/* ── 3. Content section wrapper ── */
.content-section {
  padding: clamp(60px, 8vh, 100px) clamp(24px, 5vw, 80px);
  display: flex;
  justify-content: center;
}
.content-section--light { background: var(--bg); }
.content-section--alt { background: var(--bg-2); }
.content-section--dark {
  background: #08070b;
  color: #f0ece4;
}
.content-inner {
  width: 100%;
  max-width: var(--max-w);
}

/* ── 3b. Section blocks (.sec pattern used on brain/trust/specs/ax-patterns) ── */
.sec {
  padding: clamp(80px, 10vw, 140px) clamp(24px, 4vw, 48px);
}
.sec-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.sec-inner--wide {
  max-width: 1200px;
  margin: 0 auto;
}
.sec-dim  { background: var(--bg-2); }
.sec-dark { background: #08070b; color: #f0ece4; }
.sec-sand { background: #f0e8d8; }
.sec-alt  { background: var(--bg-2); }

/* ── 3c. Section label (mono uppercase, above section title) ── */
.sec-label {
  font-family: var(--font-mono);
  font-size: clamp(10px, 0.8vw, 12px);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* ── 3d. Content body text ── */
.content-body {
  font-size: clamp(17px, 1.2vw, 20px);
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.75;
  max-width: 720px;
}
.content-body p { margin-bottom: 1.2em; }
.content-body p:last-child { margin-bottom: 0; }
.content-body strong { font-weight: 600; color: var(--text); }

/* ── 3e. Scroll reveal animation ── */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s var(--ease, cubic-bezier(0.16,1,0.3,1)),
              transform 0.6s var(--ease, cubic-bezier(0.16,1,0.3,1));
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}
.reveal.d1 { transition-delay: 0.1s; }
.reveal.d2 { transition-delay: 0.2s; }
.reveal.d3 { transition-delay: 0.3s; }
.reveal.d4 { transition-delay: 0.4s; }

/* ── 4. Section dividers ── */
.section-divider {
  padding: 14px clamp(24px, 4vw, 48px);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
}
.section-divider--grammar  { background: var(--color-grammar); }
.section-divider--brain    { background: var(--color-brain); }
.section-divider--intent   { background: var(--color-intent); }

/* ── 5. Intro prose ── */
.prose {
  max-width: 680px;
}
.prose p {
  font-size: clamp(15px, 1.1vw, 18px);
  font-weight: 400;
  line-height: 1.8;
  color: var(--text-2);
  margin-bottom: 1.2em;
}
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; color: var(--text); }
.content-section--dark .prose p { color: rgba(240,236,228,0.55); }
.content-section--dark .prose strong { color: #f0ece4; }

/* ── 6. Architecture cards (.arch-cards used on CG overview) ── */
.arch-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(24px, 3vw, 40px);
  max-width: 900px;
  margin: 0 auto;
}
.arch-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(24px, 2.5vw, 36px);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.arch-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.04);
}
.arch-card-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.arch-card-label--intent  { color: var(--color-intent); }
.arch-card-label--tokens  { color: var(--color-grammar); }
.arch-card-label--brain   { color: var(--color-brain); }
.arch-card-label--rules   { color: var(--color-label); }
.arch-card-label--response { color: var(--color-success); }
.arch-card h3 {
  font-weight: 500;
  font-size: clamp(18px, 1.4vw, 22px);
  letter-spacing: -0.3px;
  margin-bottom: 10px;
  line-height: 1.25;
}
.arch-card p {
  font-size: clamp(15px, 1.05vw, 17px);
  color: var(--text-2);
  font-weight: 400;
  line-height: 1.7;
  margin-bottom: 16px;
}
.arch-card .sec-illust {
  max-width: 100%;
  margin: 20px 0 0;
  padding: 16px;
  border-radius: 12px;
}

/* ── 7. Readiness stars ── */
.readiness {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(13px, 0.9vw, 14px);
  font-weight: 400;
  color: var(--text-3);
  margin-top: 8px;
}
.readiness-stars {
  color: var(--color-grammar);
  letter-spacing: 2px;
}

/* ── 8. Content title alias ── */
.content-title {
  font-size: var(--sec-title-size, clamp(30px, 3.5vw, 48px));
  font-weight: var(--sec-title-weight, 500);
  letter-spacing: var(--sec-title-tracking, -1.5px);
  line-height: 1.1;
  margin-bottom: 16px;
}

/* ── 9. Why This Matters (post-hero intro) ── */
.why-matters {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
  padding: 8px 0;
}
.why-matters-text {
  font-size: clamp(16px, 1.2vw, 20px);
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.8;
}

/* ── 10. TOC Preview Cards ── */
.toc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
}
.toc-card {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: clamp(20px, 2vw, 28px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
.toc-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(42, 184, 90, 0.06);
  border-color: var(--color-accent-border);
}
.toc-card-thumb {
  width: 200px;
  height: 150px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: contain;
  mix-blend-mode: multiply;
  background: var(--bg-3);
  padding: 8px;
  transition: transform 0.4s var(--ease);
}
.toc-card:hover .toc-card-thumb {
  transform: scale(1.04);
}
.toc-card-body {
  flex: 1;
  min-width: 0;
}
.toc-card-title {
  font-size: clamp(18px, 1.4vw, 22px);
  font-weight: 500;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
  color: var(--text);
}
.toc-card-desc {
  font-size: clamp(15px, 1vw, 16px);
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 12px;
}
.toc-card-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
}
.toc-card-tag--everyone  { background: var(--chip-green-bg); color: var(--chip-green-text); }
.toc-card-tag--designers { background: var(--chip-purple-bg); color: var(--chip-purple-text); }
.toc-card-tag--engineers { background: var(--chip-blue-bg); color: var(--chip-blue-text); }

/* ── 11. Start Here (recommended path) ── */
.start-here {
  max-width: 900px;
  margin: 0 auto 48px;
  padding: clamp(24px, 2.5vw, 36px);
  background: var(--bg-2);
  border-radius: 16px;
  border: 1px solid var(--border);
}
.start-here-title {
  font-size: clamp(16px, 1.2vw, 20px);
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--text);
}
.start-here-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.start-here-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.start-here-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-grammar);
  flex-shrink: 0;
}
.start-here-name {
  font-weight: 500;
  color: var(--text);
}
.start-here-desc {
  font-size: clamp(15px, 1vw, 16px);
  font-weight: 400;
  color: var(--text-2);
}

@media (max-width: 640px) {
  .toc-card { flex-direction: column; }
  .toc-card-thumb { width: 100%; height: 180px; mix-blend-mode: multiply; }
}

/* ── 12. Illustration panel — standalone, shared across all CG pages ── */
/* Used in: trust-design (.section-illu), brain (<figure class="illust-panel">), standalone grammar */
.illust-panel,
.section-illu {
  width: 100%;
  max-width: 680px;
  margin: clamp(28px, 3.5vw, 48px) auto;
  padding: clamp(20px, 3vw, 40px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}
.illust-panel img,
.section-illu img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.illust-panel--wide,
.section-illu--wide  { max-width: 840px; }
.illust-panel--compact,
.section-illu--compact { max-width: 480px; }

/* ── 13. Token illustration — base styles ── */
/* Grid placement overrides live in grammar/index.html */
.token-illust {
  overflow: hidden;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0; /* reset figure default margin */
}
.token-illust img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}
/* Standalone token illustration (outside a card grid) */
.token-illust--standalone {
  max-width: 800px;
  margin: clamp(20px, 3vw, 40px) auto;
  padding: clamp(20px, 3vw, 40px);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}
.token-illust--standalone img {
  max-height: 480px;
}

/* ── 14. Chapter Navigation (Explore other chapters) ──
   Injected by assets/js/chapter-nav.js on every CG sub-page.
   ─────────────────────────────────────────────────── */
.chapter-nav-wrap {
  padding: clamp(64px, 8vw, 120px) clamp(24px, 4vw, 48px);
  background: var(--bg-2);
}
.chapter-nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.chapter-nav-label {
  font-family: var(--font-mono);
  font-size: clamp(10px, 0.8vw, 12px);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--color-grammar);
  margin-bottom: 14px;
  font-weight: 500;
}
.chapter-nav-title {
  font-weight: 500;
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.1;
  letter-spacing: -1.5px;
  margin-bottom: 16px;
  color: var(--text);
}
.chapter-nav-desc {
  font-size: clamp(15px, 1.1vw, 17px);
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.75;
  max-width: 640px;
  margin-bottom: clamp(32px, 4vw, 48px);
}
.chapter-nav-wrap .toc-grid {
  max-width: 100%;
}

/* ── 14b. Chapter Pair Nav (Prev / Next) — replaces 7-card grid ──
   Injected by assets/js/chapter-nav.js v2 (2026-04-27)
   ─────────────────────────────────────────────────── */
.chapter-nav__pair {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(48px, 6vw, 80px) clamp(24px, 4vw, 48px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.chapter-nav__pair-cell {
  background: var(--bg);
  padding: clamp(24px, 3vw, 36px) clamp(20px, 2.5vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
  transition: background 200ms var(--ease, ease);
  min-height: 120px;
}
.chapter-nav__pair-cell--next {
  text-align: right;
  align-items: flex-end;
}
.chapter-nav__pair-cell:hover {
  background: var(--bg-2);
}
.chapter-nav__pair-cell--empty {
  background: transparent;
  pointer-events: none;
}
.chapter-nav__pair-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-3);
  transition: color 200ms ease;
}
.chapter-nav__pair-cell:hover .chapter-nav__pair-label {
  color: var(--color-grammar, var(--text));
}
.chapter-nav__pair-floor {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  opacity: 0.7;
}
.chapter-nav__pair-title {
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 500;
  letter-spacing: -0.6px;
  margin-top: 4px;
  color: var(--text);
}
@media (max-width: 640px) {
  .chapter-nav__pair { grid-template-columns: 1fr; }
  .chapter-nav__pair-cell--next { text-align: left; align-items: flex-start; }
  .chapter-nav__pair-cell--empty { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   READING-WIDTH TIER UTILITIES (added 2026-04-30)
   Apply to wrapper divs to constrain content to reading-optimal width.
   The width tokens are defined in tokens.css.
   Usage:
     <div class="cg-prose">     ← long-form text, ~64ch
     <div class="cg-card-w">    ← code, tables, demos, ~960px
     <div class="cg-wide">      ← card grids, illustrations, ~1280px
     <div class="cg-bleed">     ← hero animations, full-width visuals
   ═══════════════════════════════════════════════════════════════ */
.cg-prose   { max-width: var(--read-w-prose);  margin-left: auto; margin-right: auto; }
.cg-card-w  { max-width: var(--read-w-card);   margin-left: auto; margin-right: auto; }
.cg-wide    { max-width: var(--read-w-wide);   margin-left: auto; margin-right: auto; }
.cg-bleed   { max-width: var(--read-w-bleed); }

/* Auto-constrain prose elements within sections — without classes.
   When you put a <p> directly in .section-inner, it gets reading-width. */
.cg-page-prose .section-inner > p,
.cg-page-prose .section-inner > h2,
.cg-page-prose .section-inner > h3,
.cg-page-prose .section-inner > .sec-label,
.cg-page-prose .section-inner > .sec-title,
.cg-page-prose .section-inner > .sec-desc {
  max-width: var(--read-w-prose);
  margin-left: auto;
  margin-right: auto;
}

/* Slightly more breathing room across all CG sections */
@media (min-width: 768px) {
  .cg-page-prose .section {
    padding-top: clamp(72px, 9vw, 128px);
    padding-bottom: clamp(72px, 9vw, 128px);
  }
}
