/* Second Calamity — Official Guide design system.
   Inspired by 2000s print strategy guides; built as a screen document, not a
   facsimile of a book. No columns, no folios, no page furniture.
   All content, art, and fonts are ours (OFL: Charm / Alegreya / Signika). */

@font-face {
  font-family: "Charm";
  src: url("fonts/Charm-Regular.ttf");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Charm";
  src: url("fonts/Charm-Bold.ttf");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("fonts/Alegreya-VariableFont_wght.ttf");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("fonts/Alegreya-Italic-VariableFont_wght.ttf");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Signika";
  src: url("fonts/Signika-VariableFont_GRAD,wght.ttf");
  font-weight: 300 700;
  font-display: swap;
}

/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  /* Ground. Never used as a single flat fill — see .book background layers. */
  --paper: #f0e8d4;
  --paper-lit: #fbf6e9;
  --paper-deep: #e3d9c0;
  --paper-shade: rgba(122, 98, 60, 0.13);

  --ink: #2b2620;
  --ink-soft: #574a3b;

  /* Chapter hues. One per chapter, printed-ink saturation. Everything a
     chapter colors — title, rules, sweep, drop caps, tab, TOC card — resolves
     from its entry here, so recoloring a chapter is a one-line change. */
  --ch-basics:      #6f5aa6;  /* violet */
  --ch-world:       #a35a2a;  /* sienna */
  --ch-jobs:        #d95f22;  /* orange */
  --ch-equipment:   #b3861a;  /* gold */
  --ch-crafting:    #5c7d3f;  /* moss */
  --ch-adventuring: #2f7d80;  /* teal */
  --ch-danger:      #a8322a;  /* crimson */
  --ch-quests:      #7d4a80;  /* plum */
  --ch-regions:     #3f7a52;  /* forest */
  --ch-appendix:    #2f6a8c;  /* steel */

  /* Active accent. Set per chapter on body; the light and deep ends are
     derived so a chapter only ever declares one colour. */
  --accent: var(--ch-jobs);
  --accent-lit: #f0955c;
  --accent-deep: #a83f10;

  --label-red: #b0301f;
  --label-rule: #7d1e12;

  --table-head: #2f5364;
  --table-head-lit: #3f6a7d;
  --table-head-deep: #1f3b48;
  --table-head-ink: #f6f1e4;

  --row-warm-a: #f7cb9c;
  --row-warm-b: #efba85;
  --row-pale-a: #f6ecd8;
  --row-pale-b: #ebdfc6;
  --row-blue-a: #c4dcea;
  --row-blue-b: #aecfe1;
  --row-blue-pale-a: #e2f0f6;
  --row-blue-pale-b: #d1e6ef;
  --cell-hair: rgba(255, 253, 246, 0.72);
  --cell-hair-h: rgba(120, 96, 60, 0.22);

  --sage: #b3bba0;
  --sage-lit: #cbd1bb;
  --olive: #55673d;
  --olive-lit: #7d8f57;

  --strip-a: #e6b481;
  --strip-b: #f3d3ae;
  --strip-c: #f9e6cf;

  --flavor-panel-a: #cfc6db;
  --flavor-panel-b: #b9aecb;
  --flavor-outline: #ddc94a;

  --chip-gold: #c8a44e;

  /* Depth */
  --lift-xs: 0 1px 1px rgba(58, 44, 28, 0.16);
  --lift-sm: 0 1px 2px rgba(58, 44, 28, 0.2), 0 2px 6px rgba(58, 44, 28, 0.08);
  --lift-md: 0 1px 2px rgba(58, 44, 28, 0.22), 0 6px 16px rgba(58, 44, 28, 0.13);
  --gloss: inset 0 1px 0 rgba(255, 255, 255, 0.42);
  --gloss-dark: inset 0 1px 0 rgba(255, 255, 255, 0.16);

  /* Grain overlay. Kept faint — it should read as stock, not as noise. */
  --grain: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="180" height="180"><filter id="g"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3" stitchTiles="stitch"/><feColorMatrix type="saturate" values="0"/></filter><rect width="180" height="180" filter="url(%23g)" opacity="0.5"/></svg>');

  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --script: "Charm", "Segoe Script", cursive;
  --sans: "Signika", "Segoe UI", Calibri, sans-serif;

  /* Layout. rem, not em — an em measure resolves against each element's own
     font-size, which hands headings a cap several times the prose width. */
  --measure: 36rem;     /* prose line length */
  --measure-table: 38rem;
  --aside-w: 15rem;     /* devnotes & side figures, floated into the measure */
  --page-pad: 2.6rem;
}

* { box-sizing: border-box; }

html {
  background: #b8ab90 var(--grain);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 1.4;
  background: var(--paper);
}

/* ==========================================================================
   Book frame
   ========================================================================== */

.book {
  display: flex;
  min-height: 100vh;
  max-width: 47rem;
  margin: 0 auto;
  position: relative;
  background-color: var(--paper);
  background-image:
    var(--grain),
    radial-gradient(120% 55% at 50% 0%, rgba(255, 252, 243, 0.9), rgba(255, 252, 243, 0) 62%),
    radial-gradient(90% 60% at 100% 100%, var(--paper-shade), rgba(122, 98, 60, 0) 60%),
    radial-gradient(70% 45% at 0% 82%, var(--paper-shade), rgba(122, 98, 60, 0) 60%);
  box-shadow: 0 0 3rem rgba(38, 30, 20, 0.45);
}

/* ---------- Edge tab rail ---------- */

nav.tabs {
  flex: 0 0 3.6rem;
  padding: 4.6rem 0 2rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-image: linear-gradient(90deg, rgba(122, 98, 60, 0.22), rgba(122, 98, 60, 0.05) 55%, rgba(122, 98, 60, 0.12));
}

nav.tabs a {
  writing-mode: vertical-rl;
  display: block;
  min-height: 6.2rem;
  padding: 0.7rem 0.3rem;
  margin: 0 auto 0 0;
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  color: rgba(70, 58, 44, 0.62);
  width: 2.5rem;
  border-radius: 0 5px 5px 0;
  background-image: linear-gradient(
    90deg,
    color-mix(in srgb, var(--tab, #ddd5c2) 78%, #6b5a44) 0%,
    var(--tab, #ddd5c2) 45%,
    color-mix(in srgb, var(--tab, #ddd5c2) 84%, white) 100%
  );
  box-shadow: var(--gloss), var(--lift-xs);
  transition: width 0.12s ease, color 0.12s ease;
}

nav.tabs a:hover { color: var(--ink); width: 2.9rem; }

nav.tabs a:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 2px; }

nav.tabs a.current {
  width: 3.4rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  background-image: linear-gradient(90deg, var(--accent-deep), var(--accent) 45%, var(--accent-lit));
  box-shadow: var(--gloss-dark), var(--lift-md);
}

/* ---------- Chapter accents ---------- */

/* .ch-* on <body> colours the page; .tab-* colours a rail tab or TOC card.
   Both resolve the same hue, so a tab always matches the chapter it opens. */
.ch-basics,      .tab-basics      { --accent: var(--ch-basics); }
.ch-world,       .tab-world       { --accent: var(--ch-world); }
.ch-jobs,        .tab-jobs        { --accent: var(--ch-jobs); }
.ch-equipment,   .tab-equipment   { --accent: var(--ch-equipment); }
.ch-crafting,    .tab-crafting    { --accent: var(--ch-crafting); }
.ch-adventuring, .tab-adventuring { --accent: var(--ch-adventuring); }
.ch-danger,      .tab-danger      { --accent: var(--ch-danger); }
.ch-quests,      .tab-quests      { --accent: var(--ch-quests); }
.ch-regions,     .tab-regions     { --accent: var(--ch-regions); }
.ch-appendix,    .tab-appendix    { --accent: var(--ch-appendix); }

/* Derived ends, resolved wherever an accent is declared. */
body, nav.tabs a, .toc-chapters li {
  --accent-lit: color-mix(in srgb, var(--accent) 58%, #fff5e6);
  --accent-deep: color-mix(in srgb, var(--accent) 76%, #2b1608);
  --tab: color-mix(in srgb, var(--accent) 24%, #f4ecda);
}

/* ---------- Page body ---------- */

main.page {
  flex: 1;
  min-width: 0;
  padding: 0 var(--page-pad) 5rem;
  border-top: 3px solid var(--accent);
  box-shadow:
    inset 0 4px 0 rgba(255, 250, 238, 0.9),
    inset 0 6px 10px rgba(122, 98, 60, 0.12);
}

/* The measure. Everything in the flow is capped unless it opts out with
   .wide. The page is only as wide as the measure — no reserved outer column,
   because an empty one reads as a dead band. Side material floats into the
   prose as it's added, and the text wraps around it. */
main.page > *          { max-width: var(--measure); }
main.page > table.stats,
main.page > .jobdex    { max-width: var(--measure-table); }
main.page > .wide,
main.page > header.chapter-head,
main.page > hr         { max-width: none; }

p { margin: 0 0 0.62rem; text-align: justify; hyphens: auto; }

/* Ruled and banded heads sit beside a float rather than sliding under it —
   without this their border/background runs behind the devnote. */
h2, h2.sub, h3, .label, .jobname,
p.todo, div.todo, aside.callout, blockquote.flavor, details.spoiler { display: flow-root; }
ul, ol { margin: 0 0 0.7rem; padding-left: 1.3rem; }
li { margin: 0.15rem 0; }

/* ==========================================================================
   Chapter head
   ========================================================================== */

header.chapter-head {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  position: relative;
  margin: 0 0 1.8rem;
  text-align: right;
}

/* Banner strip. Real art goes in --banner; it dissolves into the page at the
   bottom edge rather than ending on a rule. */
header.chapter-head::before {
  content: "";
  display: block;
  align-self: stretch;
  height: 6.2rem;
  margin: 0 calc(var(--page-pad) * -1) 0.7rem;
  background-color: var(--paper-deep);
  background-image: var(--banner, linear-gradient(100deg, #35422f, #55673d 26%, #8a7a4e 52%, #2f5364 78%, #22303a));
  background-size: cover;
  background-position: center 40%;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 58%, rgba(0, 0, 0, 0.35) 84%, rgba(0, 0, 0, 0) 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 58%, rgba(0, 0, 0, 0.35) 84%, rgba(0, 0, 0, 0) 100%);
}

/* Curved accent sweep across the banner, in place of a straight rule. */
header.chapter-head::after {
  content: "";
  position: absolute;
  left: calc(var(--page-pad) * -1);
  right: calc(var(--page-pad) * -1);
  top: 0;
  height: 5.6rem;
  border-bottom: 2px solid var(--accent);
  border-radius: 0 0 50% 50% / 0 0 1.1rem 1.1rem;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(58, 44, 28, 0.35));
}

h1 {
  font-family: var(--script);
  font-weight: 400;
  font-size: 4.1rem;
  line-height: 0.95;
  margin: 0;
  padding-bottom: 0.05rem;
  border-bottom: 2px solid var(--ink);
  align-self: stretch;
  color: var(--accent);
  text-shadow: 0 1px 0 rgba(255, 252, 242, 0.8), 0 2px 3px rgba(58, 44, 28, 0.22);
}

header.chapter-head .kicker {
  order: 2;
  font-family: var(--serif);
  font-variant: small-caps;
  letter-spacing: 0.22em;
  font-size: 0.8rem;
  color: var(--accent-deep);
  margin-top: 0.95rem;
}

/* ==========================================================================
   Headings
   ========================================================================== */

h2 {
  font-family: var(--script);
  font-weight: 400;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--accent);
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.05rem;
  margin: 2.1rem 0 0.6rem;
  text-shadow: 0 1px 0 rgba(255, 252, 242, 0.75);
}

h2.sub {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 2px solid var(--label-rule);
  padding-bottom: 0.1rem;
  margin: 1.8rem 0 0.55rem;
}

h3 {
  font-family: var(--script);
  font-weight: 400;
  font-size: 1.8rem;
  color: #f6f1e2;
  padding: 0.1rem 0.9rem 0;
  margin: 1.6rem 0 0.6rem;
  border-radius: 2px 9px 9px 2px;
  /* Earthy band, shifted toward the chapter accent so entity names belong to
     the chapter they sit in. */
  background-image: linear-gradient(
    100deg,
    color-mix(in srgb, var(--accent) 38%, #334023),
    color-mix(in srgb, var(--accent) 34%, var(--olive)) 30%,
    color-mix(in srgb, var(--accent) 30%, var(--olive-lit)) 78%,
    color-mix(in srgb, var(--accent) 26%, #8e9d68)
  );
  box-shadow: var(--gloss-dark), var(--lift-sm);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ---------- Job name bar ---------- */

.jobname {
  display: flex;
  align-items: baseline;
  margin: 2rem 0 0.7rem;
  padding-left: 0.4rem;
  border-bottom: 2px solid var(--ink);
  border-radius: 3px 10px 0 0;
  background-image: linear-gradient(100deg, #98a186, var(--sage) 38%, var(--sage-lit) 100%);
  box-shadow: var(--gloss), var(--lift-sm);
}

.jobname .cap {
  font-family: var(--script);
  font-size: 4rem;
  line-height: 0.55;
  color: var(--accent);
  padding-right: 0.05em;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55), 0 2px 4px rgba(46, 40, 34, 0.3);
}

.jobname .rest {
  flex: 1;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.8rem;
  padding: 0.05rem 0.8rem 0.05rem 0.1rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ---------- Sub-heads: two tiers, and only two ----------
   .striphead is the workhorse — a filled strip carrying the label, tinted by
   the chapter accent. .label is the rule head, for table captions and the odd
   standalone tag. Nothing else sits between a section head and body copy. */

.striphead {
  display: flow-root;
  margin: 1.2rem 0 0.5rem;
  padding: 0.26rem 0.75rem;
  border-radius: 2px 9px 9px 2px;
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3b2e1d;
  background-image: linear-gradient(
    95deg,
    color-mix(in srgb, var(--accent) 32%, #efd6b2) 0%,
    color-mix(in srgb, var(--accent) 17%, #f8e7cd) 55%,
    color-mix(in srgb, var(--accent) 7%, #fdf4e5) 100%
  );
  box-shadow: var(--gloss), var(--lift-xs);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.label, table.stats caption {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--label-red);
  border-bottom: 2px solid var(--label-rule);
  padding-bottom: 0.08rem;
  margin: 1.15rem 0 0.35rem;
  text-shadow: 0 1px 0 rgba(255, 252, 242, 0.7);
}

/* ---------- Drop cap ---------- */

.dropcap::first-letter {
  font-family: var(--script);
  font-size: 3.4em;
  float: left;
  line-height: 0.8;
  padding: 0.05em 0.1em 0 0;
  color: var(--accent);
  text-shadow: 0 1px 0 rgba(255, 252, 242, 0.8), 0 2px 4px rgba(58, 44, 28, 0.28);
}

/* ==========================================================================
   Data tables
   ========================================================================== */

table.stats {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-weight: 350;
  font-size: 0.78rem;
  margin: 0 0 1.1rem;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: var(--lift-sm);
}

table.stats caption {
  caption-side: top;
  text-align: left;
  display: table-caption;
}

table.stats th {
  color: var(--table-head-ink);
  font-weight: 600;
  font-size: 0.71rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.34rem 0.55rem;
  text-align: left;
  background-image: linear-gradient(180deg, var(--table-head-lit), var(--table-head) 55%, var(--table-head-deep));
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--gloss-dark);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
table.stats th:last-child { border-right: 0; }

table.stats td {
  padding: 0.26rem 0.55rem;
  border-right: 1px solid var(--cell-hair);
  border-bottom: 1px solid var(--cell-hair-h);
}
table.stats td:last-child { border-right: 0; }
table.stats tbody tr:last-child td { border-bottom: 0; }

table.stats tbody tr:nth-child(odd) td {
  background-image: linear-gradient(180deg, var(--row-warm-a), var(--row-warm-b));
}
table.stats tbody tr:nth-child(even) td {
  background-image: linear-gradient(180deg, var(--row-pale-a), var(--row-pale-b));
}

table.stats td.num { text-align: center; font-variant-numeric: tabular-nums; }

/* Bestiary / appendix variant */
table.stats.blue tbody tr:nth-child(odd) td {
  background-image: linear-gradient(180deg, var(--row-blue-a), var(--row-blue-b));
}
table.stats.blue tbody tr:nth-child(even) td {
  background-image: linear-gradient(180deg, var(--row-blue-pale-a), var(--row-blue-pale-b));
}

/* Column tints — a wash laid over the row gradient, for tables that group
   columns (job columns, element columns). Apply per-cell. */
table.stats td.tint-a { box-shadow: inset 0 0 0 99px rgba(63, 106, 125, 0.15); }
table.stats td.tint-b { box-shadow: inset 0 0 0 99px rgba(160, 58, 38, 0.13); }
table.stats td.tint-c { box-shadow: inset 0 0 0 99px rgba(85, 103, 61, 0.15); }
table.stats td.tint-d { box-shadow: inset 0 0 0 99px rgba(119, 98, 142, 0.15); }

/* ==========================================================================
   Callouts
   ========================================================================== */

aside.callout {
  --strip: var(--strip-a);
  --strip-hi: var(--strip-b);
  margin: 1.15rem 0;
  padding: 0 0 0.55rem;
  border: 1px solid rgba(122, 98, 60, 0.4);
  border-radius: 5px;
  background-image: linear-gradient(180deg, rgba(255, 253, 245, 0.85), rgba(255, 253, 245, 0) 3.2rem);
  box-shadow: var(--lift-sm);
  break-inside: avoid;
}

aside.callout > h4 {
  position: relative;
  margin: 0 0 0.5rem;
  padding: 0.3rem 0.7rem 0.3rem 2.7rem;
  border-radius: 4px 4px 0 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background-image: linear-gradient(95deg, var(--strip) 0%, var(--strip-hi) 58%, var(--strip-c) 100%);
  box-shadow: var(--gloss), 0 1px 2px rgba(58, 44, 28, 0.18);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* Icon disc overlapping the strip's left end. Set --icon to real art. */
aside.callout > h4::before {
  content: "";
  position: absolute;
  left: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background-image: var(--icon, radial-gradient(120% 120% at 32% 24%, #fff6e2, var(--strip) 48%, var(--accent-deep)));
  background-size: cover;
  box-shadow: 0 1px 2px rgba(58, 44, 28, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

aside.callout > p,
aside.callout > ol,
aside.callout > ul { margin: 0.45rem 0.8rem; }

aside.callout.warn   { --strip: #dd9a7c; --strip-hi: #eebda6; }
aside.callout.aether { --strip: #a3c1c9; --strip-hi: #c6dbe0; }

/* ==========================================================================
   Flavor box
   ========================================================================== */

blockquote.flavor {
  border: 1.5px solid var(--ink-soft);
  border-radius: 12px;
  margin: 1.35rem 0;
  padding: 0.6rem 0.85rem 0.8rem;
  background-image: linear-gradient(180deg, rgba(255, 253, 245, 0.7), rgba(214, 196, 164, 0.25));
  box-shadow: var(--lift-sm);
  break-inside: avoid;
}

blockquote.flavor > h4 {
  margin: 0 0 0.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

blockquote.flavor > .panel {
  border: 2px solid var(--flavor-outline);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
  font-family: var(--sans);
  font-weight: 350;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #29222f;
  background-image: linear-gradient(165deg, var(--flavor-panel-a), var(--flavor-panel-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -6px 14px rgba(60, 46, 78, 0.16);
}

blockquote.flavor footer {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.45rem;
  text-align: right;
  color: var(--ink-soft);
}

/* ==========================================================================
   Quest card
   --------------------------------------------------------------------------
   Shaped title bar, a facts panel, then the walkthrough in plain prose below
   the panel — the facts are scannable, the prose is readable, and neither is
   forced into a table.
   ========================================================================== */

article.quest {
  margin: 1.25rem 0;
  border: 1px solid rgba(122, 98, 60, 0.42);
  border-radius: 6px;
  overflow: hidden;
  background-image: linear-gradient(180deg, rgba(255, 253, 245, 0.9), rgba(232, 220, 196, 0.45));
  box-shadow: var(--lift-sm);
  break-inside: avoid;
}

article.quest > h4 {
  margin: 0;
  padding: 0.3rem 2.4rem 0.32rem 0.85rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #3b2e1d;
  clip-path: polygon(0 0, 100% 0, calc(100% - 1.5rem) 100%, 0 100%);
  background-image: linear-gradient(
    95deg,
    color-mix(in srgb, var(--chip-gold) 62%, #f2dcaa) 0%,
    color-mix(in srgb, var(--chip-gold) 34%, #f8ebc9) 60%,
    color-mix(in srgb, var(--chip-gold) 14%, #fdf6e2) 100%
  );
  box-shadow: var(--gloss);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.quest-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.12rem 1.2rem;
  margin: 0;
  padding: 0.5rem 0.85rem 0.55rem;
  border-bottom: 1px solid rgba(122, 98, 60, 0.28);
  font-family: var(--sans);
  font-size: 0.78rem;
  background-image: linear-gradient(180deg, rgba(246, 236, 214, 0.9), rgba(230, 217, 189, 0.75));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.quest-facts > div { display: flex; gap: 0.4rem; align-items: baseline; }

.quest-facts dt {
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--label-red);
  white-space: nowrap;
}

.quest-facts dd { margin: 0; min-width: 0; }

article.quest > p { margin: 0.5rem 0.85rem; }
article.quest > p:last-child { margin-bottom: 0.7rem; }

@media (max-width: 40rem) {
  .quest-facts { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Figures
   ========================================================================== */

figure.shot { margin: 1.2rem 0; break-inside: avoid; }

figure.shot img,
figure.portrait img {
  width: 100%;
  display: block;
  border: 1px solid rgba(43, 38, 32, 0.55);
  border-radius: 2px;
  box-shadow: var(--lift-md), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

figure.shot figcaption {
  font-family: var(--sans);
  font-weight: 350;
  font-size: 0.75rem;
  color: var(--ink-soft);
  padding-top: 0.28rem;
}

figure.shot.left  { float: left;  width: 46%; margin: 0.3rem 1.2rem 0.7rem 0; }
figure.shot.right { float: right; width: 46%; margin: 0.3rem 0 0.7rem 1.2rem; }

figure.portrait { float: left; width: 38%; margin: 0 1.3rem 0.5rem 0; }

/* Side figures float into the prose; the text wraps around them. */
figure.shot.side {
  float: right;
  clear: right;
  width: var(--aside-w);
  max-width: var(--aside-w);
  margin: 0.35rem 0 0.9rem 1.4rem;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.08rem 0.45rem;
  border-radius: 0.6rem;
  color: #fff;
  margin-right: 0.15rem;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(0, 0, 0, 0.14)),
    linear-gradient(var(--chip-c, #574a3b), var(--chip-c, #574a3b));
  box-shadow: var(--lift-xs), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.badge.aggro   { --chip-c: #9c3623; }
.badge.passive { --chip-c: #59744a; }
.badge.links   { --chip-c: #a97b2a; }
.badge.sight   { --chip-c: #4a6987; }
.badge.sound   { --chip-c: #715d87; }
.badge.aether  { --chip-c: #2a6971; }

/* ==========================================================================
   Helpers
   ========================================================================== */

.clear { clear: both; }

hr {
  border: 0;
  height: 2px;
  margin: 1.6rem 0;
  background-image: linear-gradient(90deg, rgba(122, 98, 60, 0), rgba(122, 98, 60, 0.5) 20%, rgba(122, 98, 60, 0.5) 80%, rgba(122, 98, 60, 0));
}

a { color: #1a5f66; }

/* ==========================================================================
   TOC / cover
   ========================================================================== */

.toc-chapters {
  display: grid;
  /* Clears any floated devnote above it — a grid is a formatting context, so
     it would otherwise narrow beside the float instead of running full width. */
  clear: both;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1rem;
  padding: 0;
  margin: 1.6rem 0;
  list-style: none;
}

.toc-chapters li {
  border-top: 0.35rem solid var(--tab, #ddd5c2);
  border-radius: 0 0 4px 4px;
  padding: 0.85rem 1rem;
  background-image: linear-gradient(180deg, rgba(255, 253, 245, 0.95), rgba(228, 215, 189, 0.5));
  box-shadow: var(--lift-sm);
}

.toc-chapters li a {
  font-family: var(--script);
  font-size: 1.6rem;
  color: var(--accent);
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(255, 252, 242, 0.8);
}

.toc-chapters li p {
  font-family: var(--sans);
  font-weight: 350;
  font-size: 0.79rem;
  color: var(--ink-soft);
  margin: 0.35rem 0 0;
  text-align: left;
}

/* ==========================================================================
   Job quick-selector
   ========================================================================== */

.jobname, h2.sub { scroll-margin-top: 1rem; }

.jobdex {
  margin: 1.2rem 0 1.6rem;
  padding: 0.75rem 1rem 0.85rem;
  border: 1px solid rgba(122, 98, 60, 0.35);
  border-left: 4px solid var(--olive);
  border-radius: 0 5px 5px 0;
  background-image: linear-gradient(180deg, rgba(255, 253, 245, 0.9), rgba(219, 206, 178, 0.55));
  box-shadow: var(--lift-sm);
}

.jobdex-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  margin: 0.3rem 0;
}

.jobdex-group a {
  font-family: var(--sans);
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.05rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 3px;
  white-space: nowrap;
}

.jobdex-group a:hover {
  color: var(--ink);
  border-color: rgba(122, 98, 60, 0.45);
  background-image: linear-gradient(180deg, rgba(255, 255, 250, 0.95), rgba(226, 213, 186, 0.8));
  box-shadow: var(--lift-xs);
}

.jobdex-group a.jobdex-role {
  font-weight: 600;
  font-size: 0.77rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--label-red);
  min-width: 8.5rem;
  padding-left: 0;
}
.jobdex-group a.jobdex-role:hover { background-image: none; border-color: transparent; box-shadow: none; }

/* ==========================================================================
   Removable layer — design-build only
   --------------------------------------------------------------------------
   Everything below is stripped for the retail build. The invariant: any text
   that will not ship lives inside .devnote, .todo, or details.spoiler. Prose
   outside those containers is final guide copy.
   ========================================================================== */

details.spoiler {
  margin: 1.2rem 0;
  border: 1px solid #9c3623;
  border-radius: 4px;
  background-image: linear-gradient(180deg, rgba(252, 240, 232, 0.95), rgba(233, 210, 196, 0.6));
  box-shadow: var(--lift-sm);
}

details.spoiler > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.45rem 0.85rem;
  border-radius: 3px 3px 0 0;
  color: #f8f2e6;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background-image: linear-gradient(180deg, #b8452f, #9c3623 60%, #832c1c);
  box-shadow: var(--gloss-dark);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

details.spoiler > summary::-webkit-details-marker { display: none; }
details.spoiler > summary::before { content: "\25B8\00a0\00a0"; display: inline-block; }
details.spoiler[open] > summary::before { content: "\25BE\00a0\00a0"; }
details.spoiler > summary:hover { background-image: linear-gradient(180deg, #c9553e, #b8452f 60%, #9c3623); }
details.spoiler > .spoiler-body { padding: 0.35rem 1rem 0.9rem; }
details.spoiler .spoiler-body > h3 { margin-top: 1rem; }

.devnote {
  margin: 1rem 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid rgba(47, 83, 100, 0.35);
  border-left: 4px solid var(--table-head);
  border-radius: 0 4px 4px 0;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: #2f3d47;
  background-image: linear-gradient(180deg, rgba(238, 243, 246, 0.95), rgba(212, 224, 231, 0.75));
  box-shadow: var(--lift-sm);
}

.devnote p { text-align: left; margin: 0.35rem 0; }
.devnote p:first-child { margin-top: 0; }
.devnote p:last-child { margin-bottom: 0; }

.devnote-tag {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--table-head);
}

/* Devnotes float beside the prose so they read as apparatus, not as copy. */
@media (min-width: 48rem) {
  main.page > .devnote {
    float: right;
    clear: right;
    width: var(--aside-w);
    max-width: var(--aside-w);
    margin: 0.35rem 0 0.9rem 1.4rem;
  }
}

/* Unwritten content. Marked so the retail build can strip it and the build
   check can fail on anything left behind. */
.todo {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-style: normal;
  color: #6d4a12;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(214, 160, 46, 0.16) 0 6px,
    rgba(214, 160, 46, 0.07) 6px 12px
  );
  box-shadow: inset 0 0 0 1px rgba(176, 128, 30, 0.4);
  border-radius: 3px;
}

p.todo, div.todo { padding: 0.4rem 0.7rem; margin: 0.7rem 0; text-align: left; }
span.todo { padding: 0 0.3rem; }
td.todo { color: #8a6a2a; box-shadow: none; background-image: none; }

/* ---------- Retail preview: <html data-build="retail"> ---------- */

html[data-build="retail"] .devnote,
html[data-build="retail"] .todo { display: none !important; }

html[data-build="retail"] td.todo { display: table-cell !important; color: transparent; }

html[data-build="retail"] details.spoiler {
  border: 0;
  background: none;
  box-shadow: none;
  margin: 0;
}
html[data-build="retail"] details.spoiler > summary { display: none; }
html[data-build="retail"] details.spoiler > .spoiler-body { padding: 0; }

/* ==========================================================================
   Narrow screens
   ========================================================================== */

@media (max-width: 54rem) {
  :root { --page-pad: 1.2rem; }

  .book { flex-direction: column; }

  nav.tabs {
    position: static; height: auto; flex-basis: auto;
    flex-direction: row; flex-wrap: wrap; padding: 0.5rem; gap: 0.3rem;
  }
  nav.tabs a {
    writing-mode: horizontal-tb; min-height: 0; width: auto;
    padding: 0.4rem 0.7rem; border-radius: 4px;
  }
  nav.tabs a:hover, nav.tabs a.current { width: auto; }

  h1 { font-size: 2.8rem; }

  figure.shot.left, figure.shot.right, figure.shot.side, figure.portrait {
    float: none; width: 100%; max-width: none; margin: 1.2rem 0;
  }
}
