/* ──────────────────────────────────────────────────────────────────────────
   File:        web.css
   Purpose:     Structural web styles that extend the existing type/colour
                rules in colors_and_type.css. Scope is deliberately small:
                container widths, responsive breakpoints, heading layout
                (margins and max-width only — typography lives in
                colors_and_type.css), figure layout, pull quote / callout
                / stat spotlight web treatments, and the PDF download
                affordance required by Section 9.4.

                Consumers MUST load tokens.css before web.css. colors_and_type.css
                should also be loaded (it supplies typography rules and the
                legacy --midnight/--signal-red aliases). Every value below
                is sourced from var(--token-*) — no hardcoded colour,
                font family, or spacing.
   Version:     0.2.0
   Date:        2026-04-20
   Source:      agents/rules/document-design-reference-print.md
                (Sections 3.3, 4, 5, 6.5, 9).
   ────────────────────────────────────────────────────────────────────────── */

@import "tokens.css";

/* ──────────────────────────────────────────────────────────────────────────
   Container widths and responsive shell (Section 3.3, 9.1)
   Content is constrained to 38rem for body reading columns; up to 80rem
   for full-width sections (hero, figure, table layouts).
   ────────────────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
  max-width: 80rem;
}

.container--prose {
  max-width: 38rem;
}

@media (min-width: 768px) {
  .container {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: var(--space-16);
    padding-right: var(--space-16);
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Heading layout — MARGINS and MEASURE only.
   Typography (family, size, weight) is owned by colors_and_type.css.
   This file only controls how headings sit in the flow.
   ────────────────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  max-width: 38rem;
  text-wrap: balance;
}

h1 {
  margin-top: var(--space-16);
  margin-bottom: var(--space-6);
}

h2 {
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}

h3 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

p {
  margin: 0 0 var(--space-4);
  max-width: 38rem;
}

p + p {
  margin-top: var(--space-2);
}

h1 + h2,
h2 + h3 {
  margin-top: var(--space-4);
}

/* ──────────────────────────────────────────────────────────────────────────
   Section spacing — at least one line height between major blocks.
   ────────────────────────────────────────────────────────────────────────── */
section {
  margin-bottom: var(--space-16);
}

.section--hero {
  padding-top: var(--space-24);
  padding-bottom: var(--space-24);
}

@media (max-width: 768px) {
  .section--hero {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Figures and captions (Section 6.5)
   ────────────────────────────────────────────────────────────────────────── */
figure {
  margin: var(--space-8) 0;
  max-width: 100%;
}

figure img,
figure svg {
  display: block;
  max-width: 100%;
  height: auto;
}

figcaption {
  font-family: var(--font-body-web);
  font-size: var(--text-web-caption);
  line-height: 1.4;
  color: var(--color-slate);
  margin-top: var(--space-2);
  max-width: 38rem;
}

figcaption::before {
  content: "Figure " counter(figure) ": ";
  font-weight: 600;
  color: var(--color-midnight);
}

body { counter-reset: figure; }
figure { counter-increment: figure; }

/* ──────────────────────────────────────────────────────────────────────────
   Cover image (Sprint 25A)
   Full-bleed photographic hero for the cover chapter.
   ────────────────────────────────────────────────────────────────────────── */
.cover-image {
  margin: 0 0 var(--space-6);
  padding: 0;
  width: 100%;
}
.cover-image picture,
.cover-image img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: cover;
}

/* ──────────────────────────────────────────────────────────────────────────
   Hero image — chapter opener treatment (Sprint 25A)
   Used at the top of long-form chapters to set tone before prose begins.
   Constrained to the content column at desktop widths; full-bleed on mobile.
   ────────────────────────────────────────────────────────────────────────── */
.hero-image {
  margin: 0 auto var(--space-8);
  padding: 0;
  width: 100%;
}
.hero-image picture,
.hero-image img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 2px;
}
@media (min-width: 1024px) {
  .hero-image {
    max-width: 960px;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Pull quote — web treatment (Section 5.1)
   ────────────────────────────────────────────────────────────────────────── */
.pull-quote {
  font-family: var(--font-body-print);
  font-style: italic;
  font-size: var(--text-web-h3);
  line-height: 1.4;
  color: var(--color-midnight);
  border-left: 3px solid var(--color-signal-red);
  padding-left: var(--space-6);
  margin: var(--space-12) 0;
  max-width: 38rem;
}

.pull-quote__attribution {
  font-family: var(--font-body-web);
  font-style: normal;
  font-size: var(--text-web-caption);
  color: var(--color-slate);
  margin-top: var(--space-3);
}

.pull-quote__attribution::before {
  content: "— ";
}

/* ──────────────────────────────────────────────────────────────────────────
   Callout box — web treatment (Section 5.2)
   ────────────────────────────────────────────────────────────────────────── */
.callout,
.callout-box {
  background: var(--color-stone);
  border-left: 4px solid var(--color-signal-red);
  padding: var(--space-6);
  margin: var(--space-8) 0;
  max-width: 38rem;
}

.callout__label,
.callout-box__label {
  font-family: var(--font-body-web);
  font-weight: 600;
  font-size: var(--text-web-caption);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-signal-red);
  margin-bottom: var(--space-3);
}

.callout__body,
.callout-box__body {
  font-family: var(--font-body-web);
  font-size: var(--text-web-body);
  line-height: 1.5;
  color: var(--color-graphite);
}

/* ──────────────────────────────────────────────────────────────────────────
   Stat spotlight — web treatment (Section 5.3)
   ────────────────────────────────────────────────────────────────────────── */
.stat-spotlight {
  margin: var(--space-12) 0;
  max-width: 38rem;
}

.stat-spotlight__number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-web-hero);
  line-height: 1;
  color: var(--color-signal-red);
  font-variant-numeric: tabular-nums;
}

.stat-spotlight__descriptor {
  font-family: var(--font-body-web);
  font-size: var(--text-web-body);
  color: var(--color-graphite);
  margin-top: var(--space-3);
}

.stat-spotlight__source {
  font-family: var(--font-body-web);
  font-size: var(--text-web-caption);
  color: var(--color-slate);
  margin-top: var(--space-2);
}

/* ──────────────────────────────────────────────────────────────────────────
   PDF download affordance (Section 9.4)
   Prominent button linking to /downloads/{report-slug}.pdf.
   ────────────────────────────────────────────────────────────────────────── */
.pdf-download,
.download-pdf {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body-web);
  font-size: var(--text-web-body);
  font-weight: 600;
  color: var(--color-paper-white);
  background: var(--color-signal-red);
  border: 1px solid var(--color-signal-red);
  border-radius: var(--space-2);
  text-decoration: none;
  transition: background-color 180ms ease, transform 180ms ease;
}

.pdf-download:hover,
.download-pdf:hover {
  background: var(--color-signal-red-deep);
  border-color: var(--color-signal-red-deep);
  transform: translateY(-1px);
}

.pdf-download:focus-visible,
.download-pdf:focus-visible {
  outline: 2px solid var(--color-signal-red);
  outline-offset: 2px;
}

.pdf-download__meta,
.download-pdf__meta {
  font-family: var(--font-body-web);
  font-size: var(--text-web-caption);
  font-weight: 400;
  color: var(--color-slate);
  margin-left: var(--space-2);
}

/* ──────────────────────────────────────────────────────────────────────────
   Sticky table-of-contents sidebar (Section 4.2, 9.1)
   Shown at >= 1024px; collapses to top nav below that.
   ────────────────────────────────────────────────────────────────────────── */
.toc-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .toc-sidebar {
    display: block;
    position: sticky;
    top: var(--space-8);
    max-width: 18rem;
    padding: var(--space-6);
    font-family: var(--font-body-web);
    font-size: var(--text-web-caption);
    color: var(--color-graphite);
    border-left: 1px solid var(--color-stone);
  }

  .toc-sidebar a {
    color: var(--color-midnight);
    text-decoration: none;
  }

  .toc-sidebar a:hover {
    color: var(--color-signal-red);
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   PDF download affordance (Section 9.4, Sprint 23)
   Prominent CTA on the web; hidden in the print output.
   ────────────────────────────────────────────────────────────────────────── */
.pdf-download-affordance {
  display: flex;
  justify-content: center;
  margin: var(--space-8) 0 var(--space-12);
}

.pdf-download-button {
  display: inline-flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-8);
  background: var(--color-midnight);
  color: var(--color-paper-white);
  font-family: var(--font-body-web);
  text-decoration: none;
  border: 2px solid var(--color-signal-red);
  border-radius: 2px;
  transition: background 120ms ease, transform 120ms ease;
}

.pdf-download-button:hover,
.pdf-download-button:focus {
  background: var(--color-signal-red);
  transform: translateY(-1px);
}

.pdf-download-label {
  font-weight: 600;
  font-size: var(--text-web-body);
  letter-spacing: 0.01em;
}

.pdf-download-meta {
  font-size: var(--text-web-caption);
  color: var(--color-stone);
  opacity: 0.92;
}

.print-hidden {
  /* Web: rendered normally. Print media query below hides it. */
}

@media print {
  .print-hidden,
  .pdf-download-affordance,
  .audience-selector {
    display: none !important;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Audience selector (Sprint 28)
   Three stacked audience-tailored download buttons replacing the single
   PDF download card. Grid layout collapses to a single column at mobile
   and expands to a three-column row at >= 768px. Every value below is
   sourced from tokens; no hardcoded hex.
   ────────────────────────────────────────────────────────────────────────── */
.audience-selector {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin: var(--space-8) 0 var(--space-12);
  max-width: 80rem;
}

@media (min-width: 768px) {
  .audience-selector {
    grid-template-columns: repeat(3, 1fr);
  }
}

.audience-option {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-6);
  background: var(--color-midnight);
  color: var(--color-paper-white);
  font-family: var(--font-body-web);
  text-decoration: none;
  border: 2px solid var(--color-signal-red);
  border-radius: 2px;
  transition: background 120ms ease, transform 120ms ease;
}

.audience-option:hover,
.audience-option:focus {
  background: var(--color-signal-red);
  transform: translateY(-1px);
}

.audience-option:focus-visible {
  outline: 2px solid var(--color-signal-red);
  outline-offset: 2px;
}

.audience-option-label {
  font-weight: 600;
  font-size: var(--text-web-body);
  letter-spacing: 0.01em;
}

.audience-option-desc {
  font-size: var(--text-web-caption);
  color: var(--color-stone);
  opacity: 0.92;
}
