/* ==========================================================================
   Stoutenburger Almanac — Central Stylesheet
   Eo Ena visual identity + structured card body elements
   ========================================================================== */

/* OFFLINE FONTS — Lora (variable, bundled locally) */
@font-face {
  font-family: 'Lora';
  src: url('../fonts/Lora-Variable.ttf') format('truetype');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('../fonts/Lora-Italic-Variable.ttf') format('truetype');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

/* OFFLINE FONTS — EB Garamond (headings, bundled locally) */
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/EBGaramond-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'EB Garamond';
  src: url('../fonts/EBGaramond-latin-ext.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}


/* ========= COLOR THEMES (per card type) ========= */

/* Theme 1: Product (Warm Gold) */
.page-product {
  --ink: #3b2e28;
  --heading: #5c4033;
  --muted: #6d5447;
  --accent: #c07a2d;
  --accent-dark: #8a5523;
  --accent-light: #faf0e0;
  --btn-bg: #fffaf4;
  --btn-hover: #fdf2e5;
  --handbook: #fdf9f3;
  --paper: #f9f5ef;
  --paper-top: #f7f0e2;
  --paper-mid: #fdf9f3;
  --paper-blend: color-mix(in srgb, var(--paper-top) 50%, var(--paper-mid) 50%);
  --paper-edge: rgba(0, 0, 0, .06);
  --rule-line: #e0d7c8;
}

/* Theme 2: Instruction (Steel Blue) */
.page-instruction {
  --ink: #366889;
  --heading: #214c6b;
  --muted: #3e5666;
  --accent: #2e5e84;
  --accent-dark: #1c3e57;
  --accent-light: #ebf1f5;
  --btn-bg: #f6f9fc;
  --btn-hover: #eef3f7;
  --handbook: #f7f4e2;
  --paper: #f2efeb;
  --paper-top: #f4eed8;
  --paper-mid: #f7f4e2;
  --paper-blend: color-mix(in srgb, var(--paper-top) 50%, var(--paper-mid) 50%);
  --paper-edge: rgba(0, 0, 0, .06);
  --rule-line: #c9d3da;
}

/* Theme 3: Knowledge (Sage Green) */
.page-knowledge {
  --ink: #487444;
  --heading: #1a4324;
  --muted: #4c5a6a;
  --accent: #4d6b50;
  --accent-dark: #2e5036;
  --accent-light: #e8ede8;
  --btn-bg: #fffdf5;
  --btn-hover: #f2eee6;
  --handbook: #f7f4e2;
  --paper: #f2efeb;
  --paper-top: #f4eed8;
  --paper-mid: #f7f4e2;
  --paper-blend: color-mix(in srgb, var(--paper-top) 50%, var(--paper-mid) 50%);
  --paper-edge: rgba(0, 0, 0, .06);
  --rule-line: #d0cfb8;
}

/* Theme 4: Maker (Workshop Orange) */
.page-maker {
  --ink: #3e342e;
  --heading: #8c451c;
  --muted: #7a6455;
  --accent: #b75e28;
  --accent-dark: #7a3d18;
  --accent-light: #f5e8da;
  --btn-bg: #fffdf5;
  --btn-hover: #f2eee6;
  --handbook: #f7f4e2;
  --paper: #f2efeb;
  --paper-top: #f4eed8;
  --paper-mid: #f7f4e2;
  --paper-blend: color-mix(in srgb, var(--paper-top) 50%, var(--paper-mid) 50%);
  --paper-edge: rgba(0, 0, 0, .06);
  --rule-line: #cc8e70;
}



/* Theme 5: Network (Deep Teal) */
.page-network {
  --ink: #2a4a4a;
  --heading: #1a3a3a;
  --muted: #4a6060;
  --accent: #2a6b6b;
  --accent-dark: #1a4a4a;
  --accent-light: #e0eaea;
  --btn-bg: #f5fafa;
  --btn-hover: #eaf2f2;
  --handbook: #f2f7f5;
  --paper: #eef3f1;
  --paper-top: #e8f0ec;
  --paper-mid: #f2f7f5;
  --paper-blend: color-mix(in srgb, var(--paper-top) 50%, var(--paper-mid) 50%);
  --paper-edge: rgba(0, 0, 0, .06);
  --rule-line: #b8ccc4;
}


/* ========= GENERAL VARIABLES & BASE ========= */
:root {
  /* Eo Ena header/footer layout */
  --brand-line: 6px;
  --brand-pad: 1.4rem;
  --badge-h: 34px;
  --eo-h: 130px;
  --badge-y: 6px;
  --stamp-lift: 10px;

  /* Shared body variables (defaults, work with all themes) */
  --teal: #2a6b6b;
  --bg-card: #faf7f0;
  --bg-paper: #fffdf8;
  --ink-light: #6b5e52;
  --ink-faint: #7b6e5e;
  --line: #d0c9b8;
  --line-light: #ddd5c8;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  font: 18px/1.6 "Lora", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.container {
  max-width: 980px;
  margin: 3.5rem auto;
  padding: 0 1.2rem;
}


/* ========= CARD (paper texture) ========= */
.card {
  position: relative;
  background: var(--handbook);
  border-radius: 18px;
  padding: 1.4rem 1.6rem 1.6rem;
  overflow: hidden;
  border: 1px solid transparent;
  box-shadow:
    inset 0 1px 3px rgba(80, 60, 40, .08),
    inset 0 -1px 3px rgba(80, 60, 40, .05),
    0 14px 36px rgba(80, 60, 40, .18),
    0 5px 15px rgba(80, 60, 40, .10),
    0 1px 3px rgba(0, 0, 0, .05);
  background:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="160" height="160"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.04"/></svg>') repeat,
    radial-gradient(1200px 220px at 50% -20px, rgba(120, 80, 50, .05) 0%, rgba(120, 80, 50, .03) 40%, rgba(0, 0, 0, 0) 80%),
    radial-gradient(600px 160px at -80px -40px, rgba(120, 80, 50, .05), rgba(0, 0, 0, 0) 70%),
    radial-gradient(600px 160px at calc(100% + 80px) -40px, rgba(120, 80, 50, .05), rgba(0, 0, 0, 0) 70%),
    linear-gradient(to right, var(--paper-top) 0%, var(--paper-top) 10%, var(--paper-blend) 22%, var(--paper-mid) 38%, var(--paper-mid) 62%, var(--paper-blend) 78%, var(--paper-top) 90%, var(--paper-top) 100%),
    var(--paper);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-attachment: fixed, scroll, scroll, scroll, scroll, scroll;
  transition: background-color .35s ease, box-shadow .35s ease, border-color .35s ease, background-image .35s ease;
}


/* ========= HEADER (Eo Ena brand band) ========= */
.masthead {
  margin: .2rem 0 1.4rem;
}

.brand-band {
  position: relative;
  border-top: var(--brand-line) double var(--heading);
  border-bottom: var(--brand-line) double var(--heading);
  padding-block: var(--brand-pad);
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.brand {
  font-family: "Lora", serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  word-spacing: .21em;
  color: var(--heading);
  font-size: clamp(1.6rem, 4.8vw, 2.2rem);
  line-height: 1.08;
  margin: 0;
  text-align: center;
  padding: 0 7.5rem;
}
.brand-short {
  display: none;
}

.eo-figure {
  position: absolute;
  left: .9rem;
  top: 50%;
  height: var(--eo-h);
  transform: translateY(-45%);
  z-index: 2;
}

.brand-program {
  text-align: center;
  font-family: 'EB Garamond', serif;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: .25rem;
}

.badge-img {
  position: absolute;
  right: 1.2rem;
  height: var(--badge-h);
  z-index: 3;
  top: calc(-1 * ((var(--badge-h) / 2) + (var(--brand-line) / 2)) + var(--badge-y));
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .10));
  pointer-events: none;
}


/* ========= MASTHEAD META (program + codon) ========= */
.masthead-meta,
.card-intro,
.card-body {
  position: relative;
  z-index: 5;
}

.masthead-meta {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  padding: .6rem 0 0;
  font-size: .82rem;
}

/* ========= CARD INTRO (title + lede, below brand band) ========= */
.card-intro {
  padding: .8rem 0 .4rem;
}

.card-title {
  font-family: 'EB Garamond', 'Lora', serif;
  font-size: clamp(1.4rem, 4.2vw, 2rem);
  font-weight: 700;
  color: var(--heading);
  letter-spacing: .04em;
  margin: 0;
  line-height: 1.25;
}

.card-lede {
  margin: .3rem 0 0;
  font-size: .95rem;
  font-style: italic;
  color: var(--muted);
  line-height: 1.55;
}

.meta-program {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .04em;
}

.meta-codon {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: .75rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: .04em;
}


/* ========= TITLES & META ========= */
h1, h2 {
  font-family: "EB Garamond", "Lora", serif;
  letter-spacing: .04em;
  margin: .4rem 0;
}

h1 {
  color: var(--heading);
  font-size: clamp(1.4rem, 4.2vw, 2rem);
  font-weight: 700;
}

h2 {
  font-size: 1.05rem;
  color: var(--heading);
  font-weight: 600;
  margin: 1.25rem 0 .4rem;
  padding-bottom: .2rem;
  border-bottom: 1px solid var(--line-light);
}

h2 + .story,
h2 + p,
h2 + ul,
h2 + ol {
  margin-top: .25rem;
}

.lede {
  margin: .2rem 0 1rem;
  color: var(--muted);
  font-size: 1.2rem;
}


/* ========= CARD BODY ========= */
.card-body {
  padding: .5rem .2rem;
}

.card-body a {
  color: var(--teal);
}
.card-body a:hover {
  color: var(--accent);
}


/* ========= SECTION TITLES ========= */
.section-title {
  font-family: 'EB Garamond', serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.25rem 0 .4rem;
  padding-bottom: .2rem;
  border-bottom: 1px solid var(--line-light);
}
.section-title:first-child { margin-top: 0; }


/* ========= BODY TEXT & STORY ========= */
.story {
  font-size: .88rem;
  line-height: 1.75;
  color: var(--ink);
}
.story p {
  margin: .4rem 0;
}
.story strong {
  color: var(--accent-dark, var(--ink));
}
.story h2 {
  font-family: 'EB Garamond', serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.25rem 0 .4rem;
  padding-bottom: .2rem;
  border-bottom: 1px solid var(--line-light);
}
.story ul, .story ol {
  padding-left: 1.4rem;
  margin: .4rem 0;
}
.story li {
  margin: .25rem 0;
}


/* ========= STORY SECTIONS (framed knowledge boxes) ========= */
.story-section {
  background: var(--bg-card);
  border: 1px solid var(--line-light);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
}
.story-section h2 {
  margin-top: 0;
  padding-bottom: .15rem;
  border-bottom: none;
}
.story-section ul,
.story-section ol {
  padding-left: 1.4rem;
  margin: .4rem 0;
}
.story-section li {
  margin: .25rem 0;
}

/* The Essence — key takeaway */
.story-section--essence {
  border-left: 3px solid var(--accent);
  border-color: var(--line-light);
  border-left-color: var(--accent);
  background: var(--bg-paper);
}

/* Output / Goal — prominent callout */
.story-section--output {
  border-left: 3px solid var(--accent);
  border-color: var(--line-light);
  border-left-color: var(--accent);
  background: var(--accent-light);
}
.story-section--output h2 {
  color: var(--accent);
}

/* Why It Matters — standard section */
.story-section--context {
  background: var(--bg-paper);
  border: 1px solid var(--line-light);
}

/* Minimum Starting Conditions — prereq-style box */
.story-section--conditions {
  border: 1.5px solid var(--accent);
  background: var(--accent-light);
}
.story-section--conditions h2 {
  color: var(--accent);
}

/* The Process — clean section */
.story-section--process {
  background: var(--bg-paper);
}

/* How To Verify — accent border */
.story-section--verify {
  border-left: 3px solid var(--teal);
  border-color: var(--line-light);
  border-left-color: var(--teal);
}

/* Common Failures & Recovery — standard */
.story-section--recovery {
  background: var(--bg-paper);
}

/* Hazards — warning style */
.story-section--hazards {
  border: 1.5px solid #b54a3a;
  background: #fdf0ee;
}
.story-section--hazards h2 {
  color: #b54a3a;
}

/* Sources / Lineage — quiet */
.story-section--sources {
  background: var(--bg-paper);
  border: 1px solid var(--line);
}


/* ========= TOPIC BADGES ========= */
.topic-list {
  margin-bottom: .8rem;
}
.topic-badge {
  display: inline-block;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  padding: .15rem .55rem;
  margin: .15rem .2rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-light);
  letter-spacing: .03em;
}


/* ========= SHARED BOX LABEL ========= */
.box-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  margin-bottom: .4rem;
}
.box-text {
  margin: 0;
  font-size: .82rem;
  line-height: 1.7;
}
.box-text--upgrade {
  font-style: italic;
  color: var(--ink-light);
  margin-top: .3rem;
  font-size: .78rem;
}


/* ========= MATERIALS BOX (instruction cards) ========= */
.materials-box {
  border: 1.5px solid var(--accent);
  background: var(--accent-light);
  padding: .85rem 1rem;
  margin-bottom: .75rem;
}
.materials-box .box-label {
  color: var(--accent);
}
.materials-box--optional {
  border-style: dashed;
  border-color: var(--line);
  background: var(--bg-card);
}
.materials-box--optional .box-label {
  color: var(--ink-light);
}
.materials-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.materials-item {
  padding: .35rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, .07);
  font-size: .8rem;
  line-height: 1.65;
}
.materials-item:last-child {
  border-bottom: none;
}


/* ========= PREREQUISITES / RECOMMENDED / UNLOCKS ========= */
.prereq-group {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: .75rem;
}
.prereq-box {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--accent);
  background: var(--accent-light);
  padding: .85rem 1rem;
}
.prereq-box .box-label {
  color: var(--accent);
}
.prereq-box--recommended {
  border-color: #c4913a;
  background: #faf0e0;
}
.prereq-box--recommended .box-label {
  color: #c4913a;
}
.prereq-box--unlocks {
  border-color: var(--teal);
  background: #e8f0ef;
}
.prereq-box--unlocks .box-label {
  color: var(--teal);
}
.prereq-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.prereq-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, .07);
  font-size: .8rem;
}
.prereq-item:last-child {
  border-bottom: none;
}
.prereq-title {
  color: var(--ink);
}


/* ========= STEP LIST ========= */
.step-list {
  list-style: none;
  counter-reset: steps;
  padding: 0;
}
.step-item {
  counter-increment: steps;
  display: flex;
  gap: .6rem;
  padding: .4rem 0;
  font-size: .82rem;
  line-height: 1.65;
}
.step-item::before {
  content: counter(steps);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: .1rem;
}

/* Rule step — visually distinct final step */
.step-item--rule {
  border: 1.5px solid #b54a3a;
  background: #fdf0ee;
  padding: .5rem .8rem;
  margin-top: .4rem;
}
.step-item--rule::before {
  background: #b54a3a;
  color: #fff;
}


/* ========= OUTPUT BOX ========= */
.output-box {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  padding: .85rem 1rem;
  margin-bottom: .75rem;
}
.output-box .box-label {
  color: var(--accent);
}


/* ========= CONSEQUENCE CALLOUT ========= */
.consequence-box {
  text-align: center;
  font-weight: 600;
  color: #b54a3a;
  padding: .6rem 1rem;
  margin: .75rem 0;
  border-top: 1px solid var(--line-light);
  border-bottom: 1px solid var(--line-light);
  font-size: .85rem;
  font-style: italic;
}


/* ========= VERIFY / FAILURES / HAZARDS BOXES ========= */
.verify-box,
.failures-box,
.hazards-box {
  padding: .85rem 1rem;
  margin-bottom: .75rem;
  font-size: .82rem;
  line-height: 1.7;
}
.field-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.field-list li {
  padding: .3rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, .05);
}
.field-list li:last-child {
  border-bottom: none;
}

.verify-box {
  background: var(--bg-card);
  border: 1px solid var(--line-light);
  border-left: 3px solid var(--teal);
}
.verify-box .box-label {
  color: var(--teal);
}

.failures-box {
  background: var(--bg-card);
  border: 1px solid var(--line-light);
}
.failures-box .box-label {
  color: var(--ink-light);
}

.hazards-box {
  border: 1.5px solid #b54a3a;
  background: #fdf0ee;
}
.hazards-box .box-label {
  color: #b54a3a;
}


/* ========= SOURCES ========= */
.sources-box {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  font-size: .82rem;
  line-height: 1.7;
}
.sources-box .section-label {
  font-family: 'EB Garamond', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--teal);
  margin-bottom: .4rem;
}
.sources-box ul {
  padding-left: 1.2rem;
  margin: 0;
}
.sources-box li {
  margin: .25rem 0;
}


/* ========= MAKER META (maker cards) ========= */
.maker-meta-box {
  background: var(--bg-card);
  border: 1px solid var(--line-light);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  font-size: .82rem;
}
.meta-line {
  padding: .2rem 0;
}
.meta-line a {
  color: var(--teal);
}
.maker-ref {
  margin: 1rem 0;
  font-size: .85rem;
}


/* ========= CARD SEPARATOR ========= */
.card-sep {
  margin: 0;
  border: none;
  border-top: 1px solid var(--line-light);
}


/* ========= SEE ALSO ========= */
.seealso-box {
  padding: .85rem 0;
}
.seealso-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-bottom: .5rem;
}
.seealso-items {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.seealso-tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  padding: .3rem .65rem;
  font-size: .75rem;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .2s ease;
}
a.seealso-tag:hover {
  border-color: var(--accent);
}
.seealso-title {
  color: var(--ink-light);
  font-size: .7rem;
}


/* ========= TYPE BADGES (inline) ========= */
.type-badge {
  display: inline-block;
  font-size: .55rem;
  font-weight: 700;
  color: #fff;
  padding: .1rem .35rem;
  letter-spacing: .08em;
  flex-shrink: 0;
  line-height: 1;
  vertical-align: middle;
}
.type-badge--k { background: #6b8f71; }
.type-badge--i { background: #4a7c9b; }
.type-badge--p { background: #c4913a; }
.type-badge--m { background: #c47a3a; }


/* ========= CARD ACTIONS (Print / Network) ========= */
.card-actions {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 2rem;
  position: relative;
  z-index: 4;
}

.card-actions a {
  border: 2px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 999px;
  padding: .35rem .7rem;
  font-weight: 700;
  font-size: .85rem;
  text-decoration: none;
  cursor: pointer;
}
.card-actions a:hover {
  background: var(--btn-hover, rgba(0,0,0,.03));
}


/* ========= SET NAVIGATION (Prev / Next) ========= */
.set-nav {
  display: flex;
  gap: .6rem;
  margin: 1.5rem 0 1rem;
}
.set-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: .7rem .9rem;
  border: 2px solid var(--rule-line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s;
}
.set-nav-link:hover {
  border-color: var(--accent);
}
.set-nav-prev { text-align: left; }
.set-nav-next { text-align: right; }
.set-nav-placeholder { visibility: hidden; }
.set-nav-dir {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .2rem;
}
.set-nav-meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  font-weight: 700;
}
.set-nav-next .set-nav-meta {
  justify-content: flex-end;
}
.set-nav-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
}
.set-nav-type.type-K { background: #4d6b50; }
.set-nav-type.type-I { background: #2e5e84; }
.set-nav-type.type-P { background: #c07a2d; }
.set-nav-type.type-M { background: #b75e28; }
.set-nav-type.type-N { background: #006a71; }


/* ========= FOOTER (Eo Ena stamp) ========= */
.footer-stamp {
  margin-top: 2.4rem;
  padding: 2.4rem 0 1.2rem;
  text-align: center;
}

.footer-line {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  height: 3px;
  background: var(--rule-line);
}

.footer-stamp-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - var(--stamp-lift)));
  height: 90px;
  padding: 0 .8rem;
}


/* ========= FOOTER INFO (maker + edition) ========= */
.footer-info {
  margin-top: 1.2rem;
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}

.footer-maker {
  margin-bottom: .15rem;
}
.footer-maker strong {
  color: var(--heading);
}

.footer-edition {
  font-size: .72rem;
  color: var(--muted);
  opacity: .8;
  letter-spacing: .03em;
}


/* ========= DNA CODE (below stamp) ========= */
.dna-wrap {
  max-width: 100%;
  width: 100%;
  margin: 0.2rem auto 0;
  padding: 0.4rem 1.6rem;
  box-sizing: border-box;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.85;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: keep-all;
  display: block;
}

.dna-label {
  font-weight: 700;
  margin-right: 0.5rem;
  letter-spacing: 0.05em;
  color: var(--heading);
  font-size: inherit;
  opacity: 1;
  display: inline;
}

.dna-code {
  letter-spacing: 0.04em;
  font-size: inherit;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
  display: inline;
  color: var(--muted);
}

.codon-sep {
  opacity: .4;
  margin: 0 .15rem;
}


/* ========= PRINT ========= */
@media print {
  @page {
    size: A4;
    margin: 18mm;
  }

  html, body {
    margin: 0;
    padding: 0;
    background: #fff;
    color: #111;
    font-size: 12pt;
    line-height: 1.5;
    orphans: 2;
    widows: 2;
  }

  .container {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }

  .card {
    margin: 0;
    padding: 0;
    background: #fff;
    background-image: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
  }

  /* Hide decorative/interactive/navigation elements */
  .eo-figure,
  .badge-img,
  .card-actions,
  .set-nav,
  .footer-stamp-img,
  .site-nav,
  .site-cta {
    display: none !important;
  }

  /* Simplify header for print */
  .brand-band {
    border-top: 2px solid #111;
    border-bottom: 2px solid #111;
    padding-block: 0.6rem;
  }

  .brand {
    padding: 0;
    font-size: 14pt;
    color: #111;
  }

  .brand-program { color: #555; }
  .masthead-meta { color: #555; }
  .meta-codon { color: #333; }

  /* Content — toner-friendly B&W */
  h1 { font-size: 20pt; color: #111; }
  h2 { font-size: 14pt; color: #111; border-bottom-color: #ccc; }
  .section-title { color: #111; border-bottom-color: #ccc; }
  .card-title { color: #111; }
  .card-lede { color: #444; }
  .lede { color: #444; }
  .story { color: #111; font-size: 10pt; }
  .story strong { color: #111; }
  .card-body a { color: #111; }

  a { color: #111; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #666; }
  a[href^="#"]::after,
  a[href^="javascript"]::after,
  .masthead a[href]::after,
  .footer-stamp a[href]::after,
  .card-index a[href]::after,
  .seealso-tag[href]::after,
  .network-link[href]::after { content: ""; }

  /* Boxes — toner-friendly: white backgrounds, grey borders */
  .materials-box,
  .prereq-box,
  .output-box,
  .verify-box,
  .failures-box,
  .story-section,
  .story-section--essence,
  .story-section--output,
  .story-section--conditions,
  .story-section--context,
  .story-section--process,
  .story-section--verify,
  .story-section--recovery,
  .story-section--sources,
  .sources-box,
  .maker-meta-box {
    background: #fff;
    border-color: #ccc;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .story-section--essence,
  .story-section--output,
  .story-section--verify {
    border-left-color: #555;
  }

  .story-section--conditions {
    border-color: #999;
  }

  .story-section h2,
  .story-section--output h2,
  .story-section--conditions h2 {
    color: #333;
  }

  /* Hazards — keep red border (safety!) */
  .hazards-box,
  .story-section--hazards {
    background: #fff;
    border-color: #b54a3a;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .hazards-box .box-label,
  .story-section--hazards h2 { color: #b54a3a; }

  .step-item--rule {
    background: #fff;
    border-color: #b54a3a;
  }

  /* Box labels & text — greyscale */
  .box-label { color: #333; }
  .materials-box .box-label { color: #333; }
  .prereq-box .box-label { color: #333; }
  .output-box .box-label { color: #333; }
  .verify-box .box-label { color: #333; }
  .failures-box .box-label { color: #555; }
  .sources-box .section-label { color: #333; }

  .prereq-box { border-color: #ccc; background: #fff; }
  .prereq-box--recommended { border-color: #ccc; background: #fff; }
  .prereq-box--recommended .box-label { color: #555; }
  .prereq-box--unlocks { border-color: #ccc; background: #fff; }
  .prereq-box--unlocks .box-label { color: #555; }

  .output-box { border-left-color: #555; background: #fff; }

  /* Step numbers — greyscale */
  .step-item::before {
    background: #eee;
    color: #333;
  }

  /* Topic badges — greyscale */
  .topic-badge {
    background: #fff;
    border-color: #ccc;
    color: #333;
  }

  /* See-also — greyscale */
  .seealso-tag {
    background: #fff;
    border-color: #ccc;
    color: #333;
  }

  /* Type badges — KEEP color (small, crucial for identification) */
  .type-badge,
  .type-badge--k,
  .type-badge--i,
  .type-badge--p,
  .type-badge--m {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Card index type letters — KEEP color */
  .card-index .idx-type {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .consequence-box { color: #333; }

  /* Network items — greyscale */
  .network-item { border-bottom-color: #ccc; }
  .network-item-type { background: #eee; color: #333; }
  .network-item-role { color: #555; }

  /* Footer & DNA: always visible on print */
  .footer-stamp { margin-top: 1.5rem; padding-top: 1rem; }
  .footer-line { background: #111; height: 2px; }
  .footer-info { color: #333; }
  .footer-maker strong { color: #111; }
  .footer-edition { color: #555; }

  .dna-wrap {
    color: #111;
    opacity: 1;
    font-size: 8pt;
    white-space: normal;
    word-break: break-all;
  }
  .dna-label { color: #111; }
  .dna-code { color: #333; opacity: 1; }

  /* Tier badge + set number in print */
  .tier-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .meta-set-number, .dna-set-number { color: #333; }

  /* ---- Page break control ---- */
  h1, h2, h3 { break-after: avoid; }

  .step-item,
  .story-section,
  .network-item,
  .materials-box,
  .prereq-box,
  .output-box,
  .verify-box,
  .failures-box,
  .hazards-box,
  .sources-box,
  .maker-meta-box { break-inside: avoid; }

  /* Safety net for long card bodies */
  .card-body > * { break-inside: avoid; }

  /* Card index: repeat table header per page, avoid row breaks */
  .card-index thead { display: table-header-group; }
  .card-index tbody tr { break-inside: avoid; }

  /* Card index: hide DNA remainder in print (too long) */
  .card-index .idx-dna-rest { display: none; }
}


/* ========= TIER BADGE ========= */
.tier-badge {
  display: inline-block;
  font-family: 'EB Garamond', serif;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .15em .6em;
  border-radius: 3px;
  line-height: 1.4;
}
.tier-basic {
  background: #e8f5e9;
  color: #2e7d32;
}
.tier-skilled {
  background: #e3f2fd;
  color: #1565c0;
}
.tier-master {
  background: #fff3e0;
  color: #e65100;
}

/* ========= SET NUMBER ========= */
.meta-set-number,
.dna-set-number {
  font-family: 'EB Garamond', serif;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--accent, #666);
  margin-left: .5em;
}
.dna-set-number {
  margin-right: .5em;
  margin-left: 0;
}

/* ========= NETWORK BODY ========= */
.network-body h2 {
  font-family: 'EB Garamond', serif;
  font-size: 1.2rem;
  color: var(--heading, #333);
  margin-top: 1.5rem;
}
.network-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.network-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--rule-line, #ddd);
}
.network-item:last-child { border-bottom: none; }
.network-item-type {
  font-family: 'EB Garamond', serif;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .15em .5em;
  border-radius: 2px;
  background: var(--accent-light, #eee);
  color: var(--accent-dark, #555);
}
.network-item-title { font-family: 'Lora', serif; }
.network-link { text-decoration: none; color: var(--ink, #333); display: flex; align-items: center; gap: .6rem; }
.network-link:hover .network-item-title { text-decoration: underline; }
.network-item-role {
  margin-left: auto;
  font-size: .75rem;
  color: var(--muted, #888);
  font-style: italic;
}
.network-item--missing { opacity: .5; }

/* ========= RESPONSIVE ========= */
@media (max-width: 640px) {
  :root {
    --eo-h: 104px;
    --badge-h: 0px;
    --badge-y: 0px;
    --brand-pad: 1rem;
    --brand-line: 4px;
  }

  .badge-img {
    --badge-h: 22px;
    height: 22px;
    right: .3rem;
  }

  .brand-full {
    display: none;
  }
  .brand-short {
    display: inline;
  }

  .masthead .brand {
    text-align: right;
    padding: 0 0 0 7rem;
    margin-right: 0;
  }

  .brand-program {
    text-align: right;
    padding: 0 0 0 7rem;
    font-size: .65rem;
    letter-spacing: .08em;
    margin-right: -.08em;
  }

  .card-body {
    padding: .5rem 0;
  }
}

@media (max-width: 520px) {
  :root {
    --eo-h: 104px;
  }

  .brand {
    font-size: clamp(1rem, 4.8vw, 1.3rem);
    padding: 0 0 0 5.5rem;
  }

  .brand-program {
    padding: 0 0 0 5.5rem;
    font-size: .58rem;
  }

  .eo-figure {
    left: .5rem;
  }
}

/* ==========================================================================
   Card Index — auto-generated table of all cards
   ========================================================================== */

.card-index {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

.card-index thead th {
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--accent, #5a7a6a);
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-index tbody tr {
  border-bottom: 1px solid #e0ddd8;
}
.card-index tbody tr:hover {
  background: rgba(0,0,0,.03);
}

.card-index td {
  padding: 0.5rem 0.6rem;
  vertical-align: top;
}

.card-index .idx-type {
  font-weight: 700;
  width: 1.5em;
  text-align: center;
}

.card-index .idx-type.type-K { color: #5a7a6a; }
.card-index .idx-type.type-I { color: #4a6a8a; }
.card-index .idx-type.type-P { color: #8a7040; }
.card-index .idx-type.type-M { color: #b06030; }
.card-index .idx-type.type-N { color: #2a6a6a; }

.card-index .idx-codon {
  font-family: 'Lora', serif;
  white-space: nowrap;
}

.card-index td a {
  color: inherit;
  text-decoration: none;
  display: block;
}

.card-index .idx-title a {
  border-bottom: 1px solid transparent;
}
.card-index .idx-title a:hover {
  border-bottom-color: var(--accent, #5a7a6a);
}

.card-index .idx-set {
  font-family: monospace;
  font-size: 0.85em;
  white-space: nowrap;
  color: #666;
}

.card-index .idx-dna-rest {
  font-family: monospace;
  font-size: 0.7em;
  color: #999;
  word-break: break-all;
}

@media (max-width: 640px) {
  .card-index .idx-dna-rest {
    display: none;
  }
}

/* CTA below card-index table */
.index-cta {
  text-align: center;
  font-size: .9rem;
  margin: 1.2rem 0 0;
  color: var(--muted);
}
.index-cta a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.index-cta a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Site Pages — Landing & Docs
   ========================================================================== */

/* Quote on landing page */
.site-quote {
  font-family: 'EB Garamond', serif;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  margin: 1rem auto;
  padding: .4rem 0 .4rem 1.2rem;
  max-width: 600px;
}

/* Hero section */
.site-hero {
  text-align: center;
  padding: 1.5rem 0 1rem;
}
.site-hero .card-title {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}
.site-hero .card-lede {
  font-size: 1.05rem;
  max-width: 600px;
  margin: .5rem auto 0;
}
.site-hero .card-lede--statement {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  line-height: 1.5;
  max-width: 500px;
}

/* Site navigation links */
.site-nav {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin: 1.5rem 0 .5rem;
}
.site-nav a {
  border: 2px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 999px;
  padding: .35rem .7rem;
  font-weight: 700;
  font-size: .85rem;
  text-decoration: none;
  cursor: pointer;
}
.site-nav a:hover {
  background: var(--btn-hover, rgba(0,0,0,.03));
}

/* Card type grid on landing page */
.type-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin: 1rem 0;
}
.type-card-item {
  border: 1.5px solid var(--rule-line);
  background: var(--bg-paper, #fffdf8);
  padding: .8rem 1rem;
  text-align: center;
}
.type-card-item strong {
  display: block;
  font-family: 'EB Garamond', serif;
  font-size: 1rem;
  margin-bottom: .25rem;
}
.type-card-item .type-letter {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: .7rem;
  margin-bottom: .3rem;
}
.type-card-item p {
  margin: 0;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Docs sections */
.docs-section {
  margin: 1.5rem 0;
}
.docs-section h2 {
  margin-top: 0;
}
.docs-section p,
.docs-section ul,
.docs-section ol {
  font-size: .88rem;
  line-height: 1.75;
}
.docs-section ul,
.docs-section ol {
  padding-left: 1.4rem;
}
.docs-section li {
  margin: .25rem 0;
}
.docs-section code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82em;
  background: var(--accent-light, #eee);
  padding: .1em .35em;
  border-radius: 3px;
}
.docs-section .dna-example {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  background: var(--accent-light);
  border: 1px solid var(--rule-line);
  padding: .8rem 1rem;
  margin: .6rem 0;
  word-break: break-all;
  line-height: 1.7;
}

/* Try-offline hint on landing */
.try-offline-hint {
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
  margin: .3rem 0 0;
}

/* CTA buttons on landing */
.site-cta {
  display: flex;
  justify-content: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}
.site-cta a {
  display: inline-block;
  border: 2px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 999px;
  padding: .5rem 1.2rem;
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
}
.site-cta a:hover {
  background: var(--btn-hover, rgba(0,0,0,.03));
}
.site-cta a.cta-primary {
  background: var(--accent);
  color: #fff;
}
.site-cta a.cta-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
