/* =============================================================
   Folio - editorial engineering-journal aesthetic
   Palette and typography follow the mid-century technical manual.
   ============================================================= */

:root {
  /* Warm paper cream, ink black, blueprint blue accent */
  --paper: #f5f0e6;
  --paper-edge: #eae3d2;
  --paper-lift: #f0ead8;
  --ink: #1a1a1a;
  --ink-muted: #4a4a4a;
  --ink-faded: #8a8578;
  --rule: #c9c1a8;
  --rule-bright: #b8af92;

  --blue: #1e3a5f;
  --blue-light: #4a6a95;
  --blue-pale: #d9e2ed;

  --rust: #a04020;
  --rust-pale: #efe5df;

  /* Aliases that the dark theme used. Mapping back to cream-theme equivalents. */
  --amber: var(--rust);
  --amber-glow: rgba(160, 64, 32, 0.12);
  --amber-pale: var(--rust-pale);

  /* Typography */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Layout */
  --reading-column: 64ch;
  --wide-column: 78ch;
  --gutter: 2rem;
  --doc-margin: clamp(1.5rem, 5vw, 4rem);
}

/* =============================================================
   Reset and base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
}

/* Paper texture - subtle grain via layered gradients */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(201, 193, 168, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(201, 193, 168, 0.06), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

main { position: relative; z-index: 1; }

/* Text */
h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 0.5em;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  color: var(--ink);
}
h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin-bottom: 0.6em;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  max-width: 16ch;
}
/* Hero h1 can be wider since the hero centers it and lets it breathe */
.hero h1 {
  font-size: clamp(2.75rem, 7vw, 5.25rem);
  max-width: 18ch;
}
h2 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  letter-spacing: -0.03em;
  margin-bottom: 0.6em;
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 40;
}
h3 {
  font-size: 1.5rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 72, "SOFT" 50;
  font-weight: 500;
}
h4 {
  font-size: 1.1rem;
  font-family: var(--sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  line-height: 1.3;
}

/* H2 gets a small decorative mark that hangs to the left of the
   text, so the text itself aligns with the eyebrow above it. */
.sheet h2 {
  position: relative;
}
.sheet h2::before {
  content: "";
  position: absolute;
  left: -2.6rem;
  top: 0.85em;
  width: 1.75rem;
  height: 3px;
  background: var(--rust);
}
/* On narrow viewports where -2.6rem would push off-screen, hide the mark */
@media (max-width: 800px) {
  .sheet h2::before { display: none; }
}
/* But not inside scenarios, steps, or features (they have their own markers) */
.scenario h2::before,
.step h2::before,
.feature h2::before,
.hero h2::before,
h2.plain::before {
  display: none;
}

p { margin: 0 0 1.2em; }
p.lede {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.45;
  color: var(--ink-muted);
  max-width: 48ch;
  font-variation-settings: "opsz" 18, "SOFT" 80;
  letter-spacing: -0.005em;
  font-weight: 400;
}
p.lede--wide { max-width: 60ch; }

/* Opening paragraph drop cap (used in scenarios) */
.dropcap::first-letter {
  font-family: var(--serif);
  font-size: 4.8rem;
  line-height: 0.9;
  float: left;
  padding: 0.35rem 0.6rem 0 0;
  color: var(--blue);
  font-variation-settings: "opsz" 144, "SOFT" 30;
  font-weight: 400;
}

a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: color 120ms;
}
a:hover { color: var(--rust); }

strong { font-weight: 600; }
em { font-style: italic; }

/* =============================================================
   Layout scaffolding
   ============================================================= */
.sheet {
  max-width: calc(var(--wide-column) + 2 * var(--doc-margin));
  margin: 0 auto;
  padding: 0 var(--doc-margin);
}

.sheet--narrow {
  max-width: calc(var(--reading-column) + 2 * var(--doc-margin));
}

section {
  padding: 9rem 0 7rem;
  border-top: 1px solid var(--rule);
}
section:first-of-type { border-top: none; padding-top: 4.5rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.eyebrow::before {
  content: "";
  width: 2rem;
  height: 1px;
  background: var(--amber);
}

/* =============================================================
   Navigation
   ============================================================= */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 240, 230, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.nav__inner {
  max-width: calc(var(--wide-column) + 2 * var(--doc-margin));
  margin: 0 auto;
  padding: 1rem var(--doc-margin);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
}
.nav__brand {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  border: none;
  font-variation-settings: "opsz" 144, "SOFT" 30;
}
.nav__brand:hover { color: var(--rust); }
.nav__brand em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faded);
  margin-left: 0.5rem;
  vertical-align: middle;
}
.nav__links {
  display: flex;
  gap: 1.75rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav__links a {
  color: var(--ink-muted);
  border: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.nav__links a:hover,
.nav__links a.active {
  color: var(--ink);
  border-bottom-color: var(--rust);
}

@media (max-width: 640px) {
  .nav__inner { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .nav__links { gap: 1.25rem; font-size: 0.85rem; flex-wrap: wrap; }
}

/* =============================================================
   Footer
   ============================================================= */
.foot {
  border-top: 1px solid var(--rule);
  padding: 3rem var(--doc-margin) 2rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-faded);
  max-width: calc(var(--wide-column) + 2 * var(--doc-margin));
  margin: 0 auto;
}
.foot__row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.foot a { color: var(--ink-muted); border-bottom: 1px dotted var(--ink-faded); }

/* =============================================================
   Terminal blocks
   Styled to evoke a real shell without being a skeuomorphic window.
   ============================================================= */
.term {
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.55;
  background: #1a1a1a;
  color: #e8e2d0;
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid #2a2a2a;
  position: relative;
}
.term::before {
  content: "SHELL";
  position: absolute;
  top: 0.5rem;
  right: 0.9rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  color: #5a5a5a;
}
.term .cmd { color: #f0e6c8; }
.term .cmd::before { content: "$ "; color: #8e8678; }
.term .comment { color: #7a7262; font-style: italic; }
.term .out { color: #c9c2ae; }
.term .ok { color: #7fa87a; }
.term .warn { color: #c99a4a; }
.term .err { color: #c06a5a; }
.term .accent { color: #8ba3c4; }

/* =============================================================
   Inline code
   ============================================================= */
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--paper-edge);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--ink);
}

/* =============================================================
   Cards and callouts
   ============================================================= */
.card {
  border: 1px solid var(--rule);
  background: rgba(255, 253, 246, 0.6);
  padding: 2.25rem 2rem 2rem;
  border-radius: 2px;
  position: relative;
  transition: border-color 180ms, transform 180ms, box-shadow 180ms;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: var(--rule-bright);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}
.card > h3:first-child,
.card > h3:nth-of-type(1) {
  margin-top: 0;
}
.card > p { color: var(--ink-muted); }
.card .cta-row {
  margin-top: auto;
  padding-top: 1.5rem;
  margin-bottom: 0;
}
.card__corner {
  position: absolute;
  top: -0.5rem;
  left: 1.5rem;
  background: var(--paper);
  padding: 0 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rust);
}

.callout {
  border-left: 3px solid var(--blue);
  background: var(--blue-pale);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink);
  font-variation-settings: "opsz" 14, "SOFT" 70;
}
.callout strong { color: var(--blue); }

.note {
  border-left: 2px dashed var(--rust);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 1.5rem 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
  max-width: var(--reading-column);
}

/* =============================================================
   Grid layouts
   ============================================================= */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* =============================================================
   Feature box (scenario cards and feature summaries)
   ============================================================= */
.feature {
  padding: 2rem 0 0;
  border-top: 3px solid var(--ink);
}
.feature__label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue);
  display: block;
  margin-bottom: 0.6rem;
  white-space: nowrap;
}
.feature__title {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0 0 1rem;
  font-variation-settings: "opsz" 72, "SOFT" 50;
  color: var(--ink);
}
.feature p { color: var(--ink-muted); }

/* =============================================================
   Scenario block (why.html)
   ============================================================= */
.scenario {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 3rem;
  padding: 4rem 0;
  border-top: 1px solid var(--rule);
}
.scenario__num {
  font-family: var(--serif);
  font-size: 4rem;
  font-weight: 400;
  line-height: 1;
  color: var(--blue);
  font-variation-settings: "opsz" 144, "SOFT" 30;
}
.scenario__body h2 { margin-top: 0; }
.scenario__quote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--ink-muted);
  border-left: 2px solid var(--rust);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  max-width: var(--reading-column);
  font-variation-settings: "opsz" 20, "SOFT" 80;
}

@media (max-width: 740px) {
  .scenario { grid-template-columns: 1fr; gap: 1rem; }
  .scenario__num { font-size: 3rem; }
}

/* =============================================================
   Tutorial step layout
   ============================================================= */
.step {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 2.5rem;
  padding: 3rem 0;
  border-top: 1px solid var(--rule);
}
.step__num {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--rust);
  letter-spacing: 0.2em;
  padding-top: 0.5rem;
}
.step__body h2 { margin-top: 0; }
.step__body h3 { margin-top: 2rem; }

@media (max-width: 740px) {
  .step { grid-template-columns: 1fr; gap: 0.5rem; }
}

/* =============================================================
   Table of contents (features.html, tutorial.html)
   ============================================================= */
.toc {
  font-family: var(--mono);
  font-size: 0.9rem;
  margin: 2rem 0 4rem;
  padding: 1.5rem 1.75rem;
  background: var(--paper-edge);
  border-radius: 2px;
}
.toc__title {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--rust);
  margin-bottom: 0.75rem;
}
.toc ol { padding-left: 1.2rem; margin: 0; }
.toc li { padding: 0.25rem 0; }
.toc a { color: var(--ink); border-bottom: 1px dotted var(--ink-faded); }

/* =============================================================
   Story components (used in quickstart)
   Interstitials, scene markers, character moments
   ============================================================= */
.scene {
  background: var(--paper-edge);
  padding: 2.5rem var(--doc-margin);
  margin: 2rem calc(-1 * var(--doc-margin));
  position: relative;
  border-left: 3px solid var(--rust);
}
.scene__stamp {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--rust);
  margin-bottom: 1rem;
}
.scene h3 {
  font-family: var(--serif);
  font-size: 1.8rem;
  margin: 0 0 0.8rem;
  line-height: 1.1;
  font-variation-settings: "opsz" 144, "SOFT" 60;
}
.scene p {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--ink);
  max-width: var(--reading-column);
  font-variation-settings: "opsz" 14, "SOFT" 80;
  margin-bottom: 0.8em;
}
.scene p:last-child { margin-bottom: 0; }

/* Email-like quote box (the customer inquiry) */
.email {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.55;
  position: relative;
  max-width: 40rem;
  font-variation-settings: "opsz" 14, "SOFT" 80;
}
.email::before {
  content: "INQUIRY";
  position: absolute;
  top: -0.55rem;
  left: 1.25rem;
  background: var(--paper);
  padding: 0 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  color: var(--rust);
}
.email__header {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faded);
  letter-spacing: 0.04em;
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
  border-bottom: 1px dashed var(--rule);
}
.email__header strong { color: var(--ink-muted); font-weight: 500; }

/* Character introduction marker (e.g., "Meet Maya") */
.character {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--blue-pale);
  border-radius: 2px;
}
.character__icon {
  flex: 0 0 4rem;
  height: 4rem;
  background: var(--blue);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  border-radius: 50%;
  font-variation-settings: "opsz" 72, "SOFT" 30;
}
.character__body {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--ink);
  font-variation-settings: "opsz" 14, "SOFT" 80;
}
.character__body strong {
  font-variation-settings: "opsz" 14, "SOFT" 30;
}
.character__body p:last-child { margin-bottom: 0; }

/* Aside: author-to-reader commentary during the guide */
.aside {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-muted);
  max-width: var(--reading-column);
  padding: 0.5rem 0 0.5rem 1.25rem;
  border-left: 2px solid var(--rule);
  margin: 1.5rem 0;
  font-style: italic;
}
.pull {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  max-width: 44rem;
  padding: 2.5rem 0;
  color: var(--ink);
  font-variation-settings: "opsz" 144, "SOFT" 80;
  font-weight: 400;
}
.pull em {
  font-style: italic;
  color: var(--rust);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

/* =============================================================
   Button / call to action
   ============================================================= */
.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.85rem 1.4rem;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 2px;
  transition: background 150ms, transform 150ms;
  white-space: nowrap;
}
.btn:hover {
  background: var(--blue);
  transform: translateY(-1px);
  color: var(--paper);
}
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
.btn--ghost:hover {
  background: var(--ink);
  color: var(--paper);
}

.cta-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 2rem 0;
}

/* =============================================================
   Datasheet side-by-side (the hardware vs software analogy)
   Two-column layout that LOOKS like a real engineering document,
   designed to make the analogy click instantly.
   ============================================================= */
.ds-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--ink);
  background: var(--paper);
  border-radius: 3px;
  overflow: hidden;
  margin: 3rem 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.ds-compare__col {
  padding: 0;
  display: flex;
  flex-direction: column;
}
.ds-compare__col:first-child {
  border-right: 1px solid var(--ink);
}
.ds-compare__label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  padding: 0.7rem 1.5rem;
  text-align: center;
}
.ds-header {
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-edge);
}
.ds-header__partno {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--rust);
  letter-spacing: 0.06em;
  font-weight: 500;
}
.ds-header__title {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink);
  margin: 0.3rem 0 0.5rem;
  line-height: 1.2;
  font-variation-settings: "opsz" 72, "SOFT" 50;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.ds-header__meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-faded);
  letter-spacing: 0.04em;
}
.ds-section {
  padding: 1rem 1.5rem 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.ds-section:last-child { border-bottom: none; }
.ds-section__title {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--rust);
  margin-bottom: 0.7rem;
  font-weight: 500;
}
.ds-section__row {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.5rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0.1rem 0;
  color: var(--ink);
}
.ds-section__row .label {
  color: var(--ink-faded);
}
.ds-section__row .val {
  color: var(--ink);
}
.ds-section__row .val--accent {
  color: var(--rust);
  font-weight: 500;
}

@media (max-width: 800px) {
  .ds-compare { grid-template-columns: 1fr; }
  .ds-compare__col:first-child {
    border-right: none;
    border-bottom: 1px solid var(--ink);
  }
  .ds-section__row {
    grid-template-columns: 8rem 1fr;
    font-size: 0.72rem;
  }
}

/* =============================================================
   Comparison table (landing)
   ============================================================= */
.compare {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95rem;
}
.compare th, .compare td {
  text-align: left;
  padding: 0.8rem 0.8rem;
  border-bottom: 1px solid var(--rule);
}
.compare th {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.compare td:first-child { font-weight: 500; }
.compare .yes { color: var(--blue); font-weight: 600; }
.compare .no { color: var(--ink-faded); }
.compare .highlight { background: var(--rust-pale); }

/* =============================================================
   Accessibility: respect prefers-reduced-motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
