/*
 * The site's design tokens: every color, the corner radius and the type, in one place.
 *
 * Variables only, no rules. Every page of the site reads them: the static pages (the
 * landing page, a plan type's catalog and designs, the terms, a reference) through
 * `site.css`, and every interactive page (a configurator, the plans page) through the
 * stylesheets its entry imports. A color written anywhere but here is a page that has
 * stopped matching the others, and `test/styles.test.ts` fails on it. A shade of one of
 * these (a veil over the 3D view, a tint of the accent) is `color-mix` of the token,
 * not a new literal.
 *
 * Dark, so the render and the drawings are the brightest things on screen.
 */

:root {
  color-scheme: dark;

  --bg: #0e1013;
  --panel: #16191e;
  --panel-2: #1d2127;
  --line: #2a2f37;
  --text: #e8eaed;
  --muted: #9aa2ad;
  --accent: #e0a03c;
  --accent-ink: #14161a;
  --warning: #d9a441;
  --error: #e2685f;

  --white: #ffffff;
  --black: #000000;

  /* Paper: a drawing on a page sits on white, as it does when printed. */
  --paper: var(--white);
  --paper-ink: #4a4f57;

  /* The reference's framing diagrams (`reference/diagrams.tsx`). */
  --diagram-lumber: #5c6472;
  --diagram-lumber-accent: #3a3021;
  --diagram-line: #4b5361;
  --diagram-note: #6d7684;

  /* The films (`film/`): ink and flat washes on drafting paper, the accent as the spot color. */
  --film-paper: #f6f1e6;
  --film-grid: #c9dbe8;
  --film-ink: #24272c;
  --film-sky: #cfe4f3;
  --film-grass: #b8d49b;
  --film-wood: #e6c493;
  --film-wood-dark: #b98c55;
  --film-siding: #7fa9a4;
  --film-roof: #6f7a86;
  --film-glass: #a9d3ee;
  --film-shadow: #d8cfbd;

  --radius: 8px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* The width a reading page's column and its header bar line up on. */
  --page-width: 1120px;
}

/*
 * The static pages: the landing page, each plan type's catalog and ready-made designs,
 * the terms of sale and a plan type's reference. Plain HTML written at build time
 * (`site/`), each page linking this one stylesheet after `tokens.css` — one hashed file
 * a browser fetches once for every page, rather than a copy pasted into each.
 *
 * Two kinds of rule, and the split is what lets the plans page (an interactive page,
 * with `controls.css`) wear the same header bar and footer without inheriting a reading
 * page's type: anything that styles a bare element is under `:where(.site)` — the body
 * class of a static page, at no specificity, so any component class still wins over
 * it — and everything else is a component class (`.bar`, `.foot`, `.cta`, …)
 * that means the same wherever it is put. The interactive pages already own `.button`
 * and `.card`, so the site's button is `.cta` and its cards are `.cards > .card`.
 */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

.site {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:where(.site) a {
  color: var(--accent);
}

:where(.site) a:hover {
  text-decoration-thickness: 2px;
}

:where(.site) img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ---- the header bar and the footer, on every page ------------------------------ */

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px max(16px, calc((100% - var(--page-width)) / 2));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-sans);
  line-height: 1.55;
}

.bar-brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.bar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 14px;
}

.bar nav a {
  color: var(--muted);
  text-decoration: none;
}

.bar nav a:hover,
.bar nav a[aria-current="page"] {
  color: var(--text);
}

.foot {
  max-width: var(--page-width);
  margin: 24px auto 0;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
}

.foot a {
  color: var(--muted);
}

/* ---- a page's column and its type ------------------------------------------------ */

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 16px 48px;
}

.page section {
  margin-top: 56px;
}

:where(.site) h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

:where(.site) h2 {
  margin: 0 0 14px;
  font-size: 24px;
}

:where(.site) h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 19px;
}

.hero {
  margin-top: 40px;
}

.hero p {
  max-width: 62ch;
  color: var(--muted);
}

.hero .lead {
  color: var(--text);
}

.hero-preset,
.hero-landing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 40px;
  align-items: center;
}

.small {
  font-size: 13.5px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 22px 0 12px;
}

/* The one call to action a page leads with. */
.cta {
  display: inline-block;
  padding: 11px 18px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  text-decoration: none;
}

.cta:hover {
  filter: brightness(1.08);
}

.cta::after {
  content: " \2192";
}

.text-link {
  font-weight: 550;
}

.crumbs {
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
}

.crumbs a {
  color: var(--muted);
}

/* ---- drawings, facts and cards ---------------------------------------------------- */

.paper {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--white) 6%, transparent),
    0 18px 40px -24px color-mix(in srgb, var(--black) 80%, transparent);
}

.paper figcaption {
  margin-top: 8px;
  color: var(--paper-ink);
  font-size: 13px;
  text-align: center;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.facts div {
  padding: 14px 16px;
  background: var(--panel);
}

.facts dt {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.facts dd {
  margin: 4px 0 0;
}

.facts ul {
  margin: 0;
  padding-left: 18px;
}

.permit {
  max-width: 80ch;
  margin: 18px 0 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--panel-2);
}

.drawings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.contents {
  columns: 2 300px;
  column-gap: 40px;
  padding-left: 22px;
}

.contents li {
  margin: 0 0 8px;
  break-inside: avoid;
}

.band {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
}

.band p {
  max-width: 62ch;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}

.cards-small {
  margin-top: 20px;
}

.cards > .card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.card-picture {
  display: block;
  aspect-ratio: 4 / 3;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  border-radius: 0;
  box-shadow: none;
}

.card-picture img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px 18px 18px;
}

.cards .card h2,
.cards .card h3 {
  margin: 0 0 6px;
  font-size: 19px;
}

.cards .card h2 a,
.cards .card h3 a {
  color: var(--text);
  text-decoration: none;
}

.cards .card h2 a:hover,
.cards .card h3 a:hover {
  color: var(--accent);
}

.cards > .card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  font-size: 12.5px;
  list-style: none;
}

.chips li {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
}

.cards > .card .card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: auto 0 0;
}

.card-actions .cta {
  padding: 8px 14px;
  font-size: 14.5px;
}

/* ---- the landing page --------------------------------------------------------- */

.hero-landing {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

.section-lead {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
}

.more {
  margin: 20px 0 0;
}

/* A plan type: its picture beside what it is, one per row, so one type is not a lone
   card in a grid of three. */
.type-cards {
  display: grid;
  gap: 24px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.type-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.type-card .card-picture {
  aspect-ratio: auto;
  height: 100%;
  max-height: 340px;
}

.type-card .card-body {
  justify-content: center;
  padding: 24px 28px;
}

.type-card h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.type-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.type-card p {
  max-width: 56ch;
  margin: 0 0 14px;
  color: var(--muted);
}

.type-card .card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 4px 0 0;
}

/* What's in a package: the sentence beside the cover's own list. */
.package {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 32px;
  align-items: start;
}

.package .contents {
  margin: 0;
  columns: 1;
  color: var(--text);
}

.steps ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 18px 18px 18px 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: 16px;
  left: 18px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  line-height: 28px;
  text-align: center;
}

.steps strong {
  display: block;
  color: var(--text);
}

/* ---- reading pages: the terms and a reference ------------------------------------- */

/* One column at a reading measure, inside the page's width. */
.reading > * {
  max-width: 760px;
  margin-right: auto;
  margin-left: auto;
}

.reading section {
  margin-top: 0;
}

.reading-head {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 40px 0 20px;
  border-bottom: 1px solid var(--line);
}

.reading-head h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.01em;
}

.reading-head p {
  max-width: 50ch;
  margin: 8px 0 0;
  color: var(--muted);
}

.reading-head .cta {
  flex: none;
}

.reading-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 16px 0 8px;
}

.reading-nav a {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
}

.reading-nav a:hover {
  color: var(--text);
}

.reading-section {
  padding-top: 36px;
}

.reading-section h2 {
  margin: 0 0 6px;
  font-size: 21px;
}

.reading-section h3 {
  margin: 22px 0 8px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reading-blurb {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.reading-paragraph {
  max-width: 66ch;
  margin: 0 0 12px;
  line-height: 1.6;
}

.reading-foot {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.reading-foot p {
  max-width: 66ch;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

/* The glossary: a term, what else it is called, what it is and why it matters. */
.terms {
  margin: 0;
}

.term {
  padding: 14px 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 72px;
}

.term dt {
  font-size: 16px;
  font-weight: 600;
}

.term .aka {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 400;
}

.term dd {
  margin: 6px 0 0;
  line-height: 1.62;
}

.term dd p {
  max-width: 66ch;
  margin: 0 0 6px;
}

.term-note {
  color: var(--muted);
}

.term-see {
  color: var(--muted);
  font-size: 13.5px;
}

.term-see a {
  text-decoration: none;
}

.term-see a:hover {
  text-decoration: underline;
}

.sources {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sources li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.sources a {
  font-weight: 600;
  text-decoration: none;
}

.sources a:hover {
  text-decoration: underline;
}

.sources .publisher {
  color: var(--muted);
  font-size: 13.5px;
}

.sources p {
  max-width: 66ch;
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.reading [id] {
  scroll-margin-top: 72px;
}

/* ---- the reference's framing diagrams (`reference/diagrams.tsx`) ------------------ */

.reference-figures {
  padding-top: 24px;
}

.diagram {
  margin: 0 0 26px;
}

.diagram-frame {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.diagram figcaption {
  max-width: 66ch;
  margin-top: 9px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.diagram figcaption strong {
  color: var(--text);
  font-weight: 600;
}

.diagram .lumber {
  fill: var(--panel-2);
  stroke: var(--diagram-lumber);
  stroke-width: 1;
}

.diagram .lumber.accent {
  fill: var(--diagram-lumber-accent);
  stroke: var(--accent);
}

.diagram .void {
  fill: none;
  stroke: var(--diagram-line);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.diagram .void-label,
.diagram .sheet-label {
  fill: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.diagram .notch {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.diagram .sheet {
  fill: color-mix(in srgb, var(--muted) 9%, transparent);
  stroke: var(--diagram-line);
  stroke-width: 1;
}

.diagram .joint {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.diagram .centerline {
  stroke: var(--diagram-line);
  stroke-width: 0.75;
  stroke-dasharray: 3 3;
}

.diagram .leader line {
  stroke: var(--diagram-note);
  stroke-width: 0.75;
}

.diagram .leader circle {
  fill: var(--diagram-note);
}

.diagram .leader text {
  fill: var(--text);
  font-size: 10.5px;
}

.diagram .dimension line {
  stroke: var(--diagram-note);
  stroke-width: 0.75;
}

.diagram .dimension text {
  fill: var(--muted);
  font-size: 10px;
}

/* ---- phones ---------------------------------------------------------------------- */

@media (max-width: 760px) {
  .hero-preset,
  .hero-landing,
  .type-card,
  .package {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .type-card {
    gap: 0;
  }

  .type-card .card-picture {
    aspect-ratio: 4 / 3;
  }

  .page section {
    margin-top: 44px;
  }

  .reading section {
    margin-top: 0;
  }

  .band {
    padding: 22px;
  }

  .reading-head {
    flex-direction: column;
    padding-top: 28px;
  }
}
