/* ==========================================================================
   History101 — drawn with a marker
   The whole story on one scroll, in the spirit of a hand-drawn world:
   paper white, ink outlines, flat blue seas, tan land, red arrows.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Literata:ital,opsz,wght@0,7..72,400;0,7..72,600;1,7..72,400&family=Nunito:ital,wght@0,400;0,600;0,700;0,800;1,400;1,600&display=swap');

:root {
  --paper: #faf7ef;
  --paper-2: #f2ecdc;
  --ink: #22262b;
  --ink-soft: #5a6068;
  --ink-faint: #8a8f96;
  --sea: #8fbde0;
  --sea-deep: #5f97c4;
  --land: #e2cd96;
  --arrow: #d64533;
  --sun: #f2c230;
  --leaf: #6da86d;
  --line: #22262b;
  --rule: rgba(34, 38, 43, 0.18);
  --card-shadow: 3px 4px 0 rgba(34, 38, 43, 0.9);
  --font-display: 'Fredoka', 'Comic Sans MS', system-ui, sans-serif;
  --font-text: 'Nunito', system-ui, -apple-system, sans-serif;
  --font-prose: 'Literata', 'Iowan Old Style', Georgia, serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.925rem;
  --text-base: 1.0625rem;
  --text-md: 1.3rem;
  --text-lg: 1.7rem;
  --text-xl: 2.3rem;
  --text-2xl: clamp(2.6rem, 6vw, 4.6rem);
  --leading-body: 1.68;
  --measure: 40rem;
  --page: 72rem;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --r-sm: 10px;
  --r-md: 16px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

::selection { background: var(--sun); color: var(--ink); }

.wrap { max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }

a { color: #b03525; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--arrow); }

:focus-visible { outline: 3px solid var(--arrow); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--ink); color: #fff; padding: 0.6rem 1rem;
  border-radius: var(--r-sm); font-weight: 700;
  transition: top 160ms var(--ease-out);
}
.skip-link:focus { top: 1rem; color: #fff; }

/* ————— Header ————— */

.site-header {
  background: var(--paper);
  border-bottom: 3px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner { display: flex; align-items: center; gap: 1.5rem; padding-block: 0.8rem; }

.brand {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--ink); text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: 1.35rem;
  padding-block: 0.3rem;
  min-height: 44px;
}

.brand__lamp {
  width: 27px; height: 27px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle at 33% 31%, #a8d0ec 0 20%, transparent 21%),
    radial-gradient(circle at 64% 66%, var(--land) 0 28%, transparent 29%),
    var(--sea-deep);
  border: 3px solid var(--line);
  position: relative;
}
.brand__lamp::after {
  content: ""; position: absolute; right: -6px; top: -6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sun); border: 2px solid var(--line);
}
.brand:hover .brand__lamp { transform: rotate(-8deg); }
.brand__lamp { transition: transform 240ms var(--ease-out); }

.site-nav { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 1.3rem; font-size: var(--text-sm); font-weight: 700; }
.site-nav a { color: var(--ink); text-decoration: none; padding-block: 0.55rem; display: inline-flex; align-items: center; min-height: 44px; }
.site-nav a:hover { color: var(--arrow); text-decoration: underline; text-decoration-thickness: 2px; }

/* ————— Hero: the rock ————— */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem);
}

.hero__kicker {
  font-family: var(--font-display); font-weight: 500;
  font-size: var(--text-md); margin: 0 0 0.6rem; color: var(--ink-soft);
}

.hero h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-2xl); line-height: 1.02; letter-spacing: 0;
  margin: 0 0 1rem; max-width: 16ch;
}
/* The marker band is measured from the glyphs, not the line box: a solid
   swatch positioned by em so it sits behind the x-height and stops just
   under the baseline instead of hanging below the line. */
.hero h1 .hl {
  background-image: linear-gradient(var(--sun), var(--sun));
  background-repeat: no-repeat;
  background-size: 100% 0.56em;
  background-position: 0 0.49em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-inline: 0.04em;
}

.hero__deck { font-size: var(--text-md); color: var(--ink-soft); max-width: 34rem; margin: 0; }

.planet {
  width: clamp(150px, 22vw, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #a8d0ec 0 18%, transparent 19%),
    radial-gradient(circle at 68% 62%, var(--land) 0 26%, transparent 27%),
    radial-gradient(circle at 40% 72%, var(--land) 0 14%, transparent 15%),
    var(--sea);
  border: 4px solid var(--line);
  box-shadow: var(--card-shadow);
  position: relative;
  flex: none;
}
.planet::after {
  content: "you are here";
  position: absolute; left: 50%; bottom: -2.4rem; transform: translateX(-50%) rotate(-3deg);
  font-family: var(--font-display); font-weight: 600; font-size: var(--text-sm);
  background: #fff; border: 3px solid var(--line); border-radius: 999px;
  padding: 0.15rem 0.8rem; white-space: nowrap;
}

.scroll-cue {
  font-family: var(--font-display); font-weight: 500;
  color: var(--ink-soft); margin: 2.2rem 0 0; font-size: var(--text-sm);
}

/* ————— Eras ————— */

.era { scroll-margin-top: 7rem; margin-top: 3.5rem; padding-top: 2.5rem; border-top: 4px solid var(--line); }

.era-index { margin: 2.5rem 0 0; scroll-margin-top: 7rem; }
.era-index h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--text-xl); margin: 0 0 1rem;
}
.era-index ol { list-style: none; margin: 0; padding: 0; display: grid; }
.era-index li { border-top: 3px solid var(--line); }
.era-index li:last-child { border-bottom: 3px solid var(--line); }
.era-index a {
  display: grid; grid-template-columns: 11rem 1fr;
  gap: 0.2rem 1.5rem; padding: 0.9rem 0;
  text-decoration: none; align-items: baseline; color: var(--ink);
}
.era-index a span { font-weight: 800; color: var(--arrow); font-size: var(--text-sm); }
.era-index a strong { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.era-index a { transition: background-color 160ms var(--ease-out); }
.era-index a:hover { background: rgba(242, 194, 48, 0.16); }
.era-index a:hover strong { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }
.era-index a em { grid-column: 2; font-style: normal; color: var(--ink-soft); font-size: var(--text-sm); }

.chapter-head__span {
  font-family: var(--font-display); font-weight: 500;
  color: var(--ink-soft); margin: 0 0 0.4rem; font-size: var(--text-md);
}
.chapter-head h2 {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-xl); line-height: 1.08; margin: 0 0 0.7rem; max-width: 22ch;
}
.chapter-head__deck { color: var(--ink-soft); font-size: var(--text-md); max-width: 38rem; margin: 0; }.cold-open {
  font-family: var(--font-prose);
  font-weight: 400;
  font-size: 1.24rem; line-height: 1.5;
  border-left: 5px solid var(--arrow);
  background: #fff;
  border-top: 3px solid var(--line);
  border-right: 3px solid var(--line);
  border-bottom: 3px solid var(--line);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: 0.9rem 1.2rem;
  margin: 1.4rem 0 0;
  max-width: var(--measure);
}

/* ————— Folio: just paper, no lamp ————— */

.folio {
  background: #fffdf8;
  border: 2px solid rgba(34, 38, 43, 0.55);
  border-radius: var(--r-md);
  padding: clamp(1.6rem, 4vw, 2.9rem) clamp(1.25rem, 4vw, 2.6rem);
  margin-block: 1.75rem;
}
.folio__inner { max-width: var(--measure); margin-inline: auto; }
.folio p,
.folio li,
.folio blockquote {
  font-family: var(--font-prose);
  font-size: 1.07rem;
  line-height: 1.72;
  letter-spacing: 0.002em;
}

.folio h3 {
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--text-lg); margin: 2rem 0 0.6rem; line-height: 1.2;
}
.folio h3:first-child { margin-top: 0; }
.folio p { margin: 0 0 1.05rem; }
.folio p:last-child { margin-bottom: 0; }
.folio .dropcap::first-letter {
  font-family: var(--font-display); font-weight: 700;
  font-size: 3.2em; float: left; line-height: 0.86;
  padding-right: 0.12em; color: var(--arrow);
}.pullquote {
  font-family: var(--font-prose);
  font-style: italic;
  font-weight: 400;
  font-size: 1.28rem;
  line-height: 1.58;
  border-top: 3px solid var(--line);
  border-bottom: 3px solid var(--line);
  padding: 1.05rem 0; margin: 1.6rem 0;
}
.pullquote cite { display: block; font-family: var(--font-text); font-weight: 600; font-style: normal; font-size: var(--text-sm); color: var(--ink-soft); margin-top: 0.5rem; }

.dateline {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem;
  list-style: none; margin: 1.2rem 0; padding: 1rem 0;
  border-top: 3px dashed var(--rule);
  border-bottom: 3px dashed var(--rule);
}
.dateline li { font-size: var(--text-sm); }
.dateline b { color: var(--arrow); font-weight: 800; margin-right: 0.45rem; font-variant-numeric: tabular-nums; }

/* ————— Source box ————— */

.source {
  background: var(--paper-2);
  border: 3px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  margin: 1.75rem 0;
  overflow: hidden;
}
.source__head { padding: 1.1rem 1.4rem 0; }
.source__label { font-family: var(--font-display); font-weight: 500; color: var(--arrow); margin: 0 0 0.2rem; font-size: var(--text-sm); }
.source__head h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 0.2rem; font-size: var(--text-md); }
.source__head > p { color: var(--ink-soft); font-size: var(--text-sm); margin: 0 0 0.5rem; }
.source blockquote {
  margin: 0.8rem 1.4rem; padding: 1rem 1.2rem;
  border-left: 5px solid var(--arrow);
  background: #fffdf8; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-family: var(--font-prose);
  font-style: italic;
  font-size: 1.03rem;
  line-height: 1.65;
}
.source__notes { padding: 0 1.4rem 1.2rem; }
.source__notes[hidden] { display: none; }
.source__notes p { font-size: var(--text-sm); margin: 0.6rem 0 0; }
.source__notes b { color: #b03525; }

.btn {
  font-family: var(--font-display); font-weight: 600; font-size: var(--text-sm);
  background: var(--sun); color: var(--ink);
  border: 3px solid var(--line); border-radius: 999px;
  padding: 0.45rem 1.2rem; cursor: pointer;
  min-height: 44px;
  box-shadow: 2px 3px 0 var(--line);
  transition: transform 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--line); }
.btn:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--line); }
.source__head .btn { margin: 0.4rem 0 1.1rem; }

/* ————— Plates: the drawn illustrations, one per chapter ————— */

.plate {
  margin: 1.9rem 0;
  border: 4px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  background: var(--paper-2);
}

.plate__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 640;
  background: var(--paper-2);
}

.plate figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.7rem;
  padding: 0.7rem clamp(0.9rem, 2.5vw, 1.4rem) 0.75rem;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-soft);
  border-top: 3px solid var(--line);
  background: var(--paper-2);
}

.plate__no {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--arrow);
  flex: none;
}

/* ————— Reading progress ————— */

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 4px;
  background: transparent;
  z-index: 60;
  pointer-events: none;
}

.progress i {
  display: block;
  height: 100%;
  background: var(--arrow);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ————— Hero artwork ————— */

.planet {
  width: clamp(180px, 24vw, 250px);
  aspect-ratio: 1;
  border: 0;
  background: none;
  box-shadow: none;
  border-radius: 50%;
  flex: none;
  overflow: visible;
  position: relative;
}

.planet::after { content: none; }

.hero__art {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
  border: 4px solid var(--line);
  box-shadow: var(--card-shadow);
  background: #1b2430;
}

.planet { position: relative; }

.planet__tag {
  position: absolute;
  left: 50%;
  bottom: -1.15rem;
  transform: translateX(-50%) rotate(-3deg);
  margin: 0;
  padding: 0.05rem 0.7rem 0.12rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(34, 38, 43, 0.85);
}

/* ————— Story maps ————— */

.map {
  margin: 1.75rem 0;
  background: var(--sea);
  border: 4px solid var(--line);
  border-radius: var(--r-md);
  padding: clamp(0.6rem, 2vw, 1.2rem);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.map svg { display: block; width: 100%; height: auto; }

.map__ocean { fill: var(--sea); }

.map__grid line {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1.4;
}
.map__grid .map__equator {
  stroke: rgba(255, 255, 255, 0.42);
  stroke-width: 2;
  stroke-dasharray: 10 8;
}

.map__land path {
  fill: var(--land);
  stroke: var(--line);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.map__land-hatch {
  fill: url(#map-hatch);
  stroke: none;
}

.map__lake {
  fill: var(--sea);
  stroke: var(--line);
  stroke-width: 2;
  stroke-linejoin: round;
}

.map__base-labels text {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.08em;
  fill: rgba(34, 38, 43, 0.34);
}
.map__zone {
  fill: rgba(214, 69, 51, 0.18);
  stroke: var(--arrow);
  stroke-width: 3;
  stroke-dasharray: 10 7;
  stroke-linejoin: round;
}
.map__arrow {
  fill: none; stroke: var(--arrow); stroke-width: 5; stroke-linecap: round;
  transition: stroke-dashoffset 1.4s var(--ease-out);
}
.map.is-drawn .map__arrow { stroke-dashoffset: 0 !important; }
.map__halo { fill: rgba(214, 69, 51, 0.25); }
.map__pip { fill: var(--arrow); stroke: var(--line); stroke-width: 2.5; }
.map__dot { opacity: 0; transition: opacity 500ms var(--ease-out); }
.map.is-drawn .map__dot { opacity: 1; }
.map__label {
  font-family: var(--font-display); font-weight: 500; font-size: 22px;
  fill: var(--ink); paint-order: stroke;
  stroke: rgba(250, 247, 239, 0.9); stroke-width: 6px;
}
.map__label--route { fill: #a02c1e; }
.map__leader { stroke: var(--ink); stroke-width: 1.4; opacity: 0.45; }
.map figcaption { color: #23465f; font-size: var(--text-sm); font-weight: 600; padding: 0.6rem 0.4rem 0.1rem; }

/* ————— Guide / glossary ————— */

.page-head { padding-block: clamp(2rem, 5vw, 3.5rem) 1rem; }
.page-head h1 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-2xl); margin: 0 0 0.8rem; line-height: 1.05; }
.page-head .lede { color: var(--ink-soft); font-size: var(--text-md); max-width: 38rem; margin: 0; }

.gloss-list { display: grid; margin: 2rem 0 3rem; border-top: 3px solid var(--line); }
.gloss-list > div { display: grid; grid-template-columns: minmax(10rem, 15rem) 1fr; gap: 1.5rem; padding: 1rem 0; border-bottom: 3px solid var(--line); }
.gloss-list dt { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.gloss-list dd { margin: 0; color: var(--ink-soft); }
.gloss-list dd small { display: block; color: var(--ink-faint); margin-top: 0.25rem; }

.breadcrumb { font-size: var(--text-sm); color: var(--ink-faint); padding-top: 1.5rem; font-weight: 700; }
.breadcrumb ol { list-style: none; display: flex; gap: 0.6rem; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "·"; margin-right: 0.6rem; }
.breadcrumb a { color: var(--ink-soft); text-decoration: none; }

/* ————— Footer ————— */

.site-footer { border-top: 4px solid var(--line); margin-top: 4rem; padding: 2.5rem 0 3rem; }
.footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.footer-grid h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); margin: 0 0 0.6rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.footer-grid a { color: var(--ink); text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; min-height: 40px; }
.footer-grid a:hover { color: var(--arrow); text-decoration: underline; }
.footer-fine { margin-top: 2rem; padding-top: 1.2rem; border-top: 3px solid var(--line); color: var(--ink-soft); font-size: var(--text-sm); }

.sound-toggle {
  background: #fff; border: 3px solid var(--line); color: var(--ink);
  border-radius: 999px; font-family: var(--font-display); font-weight: 500;
  font-size: var(--text-sm); padding: 0.35rem 1rem; cursor: pointer; margin-top: 1rem;
  min-height: 44px;
  box-shadow: 2px 3px 0 var(--line);
}
.sound-toggle:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--line); }

.shelves {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 4px solid var(--line);
}
.shelves > h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); margin: 0 0 0.4rem; max-width: 20ch; }
.shelves__lede { color: var(--ink-soft); max-width: 40rem; margin: 0 0 2rem; font-size: var(--text-md); }

/* ————— Responsive, motion ————— */

@media (max-width: 620px) {
  /* keep the sticky header to a single compact row so it stops eating the viewport */
  .header-inner { gap: 0.5rem; padding-block: 0.45rem; }
  .brand { font-size: 1.08rem; gap: 0.4rem; }
  .brand__lamp { width: 22px; height: 22px; border-width: 2.5px; }
  .brand__lamp::after { width: 7px; height: 7px; right: -5px; top: -5px; }
  .site-nav { gap: 0.1rem 0.65rem; font-size: 0.8rem; }
  .site-nav a { padding-block: 0.4rem; }
  .breadcrumb a { padding-block: 0.45rem; display: inline-flex; align-items: center; }
}

@media (max-width: 380px) {
  /* below this width the nav has to wrap, so stop pinning the header */
  .site-header { position: static; }
  .era { scroll-margin-top: 1.5rem; }
  .era-index { scroll-margin-top: 1.5rem; }
}

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .planet { width: 148px; order: -1; }
  .hero h1 { max-width: 14ch; }
  .plate figcaption { font-size: 0.85rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .gloss-list > div { grid-template-columns: 1fr; gap: 0.25rem; }
  .era-index a { grid-template-columns: 1fr; }
  .era-index a em { grid-column: 1; }
  .site-nav { gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
  .map__dot { opacity: 1; }
  .map.is-drawn .map__arrow { stroke-dashoffset: 0 !important; }
}

/* Superscript citation references in the narrative. */
.cite a {
  color: var(--arrow);
  font-weight: 800;
  text-decoration: none;
  padding-inline: 0.1em;
}
.cite a:hover { text-decoration: underline; }
.cite a:visited { color: var(--arrow); }

/* Numbered citations shelf. */
.citations { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; counter-reset: none; }
.citations li {
  border: 3px solid var(--line);
  box-shadow: 4px 5px 0 var(--line);
  background: #fffdf8;
  padding: 0.9rem 1.1rem;
}
.citations li:target { outline: 4px solid var(--sun); outline-offset: 3px; }
.citations .cite-no {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 800;
  color: #fffdf8;
  background: var(--arrow);
  min-width: 2rem;
  text-align: center;
  padding: 0.1rem 0.4rem;
  margin-right: 0.5rem;
}
.citations h3 { font-family: var(--font-display); font-size: var(--text-md); margin: 0 0 0.25rem; }
.citations p { font-size: var(--text-sm); color: var(--ink-soft); margin: 0.25rem 0 0; }
.citations .cite-link { font-weight: 700; overflow-wrap: anywhere; }

/* Links inside the footer fine print. */
.footer-fine a { color: inherit; text-underline-offset: 0.15em; }
