/* ==========================================================================
   The Thousand-Year Rain — shared system
   Display: Imbue (tall, thin, vertical — the rain). Text: Newsreader.
   Machine voice: IBM Plex Mono (the depot, the numbers).
   One deliberate world: the night sea. Light grounds appear only where the
   content is paper, sky, or sun.
   ========================================================================== */

/* ---------- fonts ---------- */
@font-face {
  font-family: "Imbue";
  src: url(/assets/fonts/imbue-latin.woff2) format("woff2");
  font-weight: 100 900;
  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: "Imbue";
  src: url(/assets/fonts/imbue-symbols.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+2030, U+2074, U+2190, U+2192, U+2196-2199, U+2248;
}
@font-face {
  font-family: "Newsreader";
  src: url(/assets/fonts/newsreader-latin.woff2) format("woff2");
  font-weight: 200 800;
  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: "Newsreader";
  src: url(/assets/fonts/newsreader-latin-italic.woff2) format("woff2");
  font-weight: 200 800;
  font-style: italic;
  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: "Newsreader";
  src: url(/assets/fonts/newsreader-symbols.woff2) format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+2030, U+2070, U+2074, U+2248;
}
@font-face {
  font-family: "Newsreader";
  src: url(/assets/fonts/newsreader-symbols-italic.woff2) format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
  unicode-range: U+2030, U+2070, U+2074, U+2248;
}
@font-face { font-family: "IBM Plex Mono"; src: url(/assets/fonts/plex-mono-latin-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(/assets/fonts/plex-mono-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(/assets/fonts/plex-mono-latin-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(/assets/fonts/plex-mono-latin-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face {
  font-family: "IBM Plex Mono";
  src: url(/assets/fonts/plex-mono-symbols-400.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+2030, U+2070, U+2074-2079, U+2080-2089, U+2190, U+2192, U+2196-2199, U+2206, U+221A, U+221E, U+2248;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url(/assets/fonts/plex-mono-symbols-500.woff2) format("woff2");
  font-weight: 500 600;
  font-display: swap;
  unicode-range: U+2030, U+2070, U+2074-2079, U+2080-2089, U+2190, U+2192, U+2196-2199, U+2206, U+221A, U+221E, U+2248;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;

  /* the sea, from the bottom up */
  --abyss: #050e14;
  --night: #0a1a23;
  --deep: #0e2632;
  --tide: #1b4150;
  --sea: #2f7480;
  --spray: #8fc3c6;
  --foam: #c9e2e2;

  /* ink on the dark */
  --salt: #e6ecea;
  --mist: #a9bbbe;
  --haze: #7d959c;

  /* the depot's light: the one warm thing in the sky */
  --signal: #f2a93b;
  --signal-dim: #b9802b;

  /* paper, and ink on paper */
  --paper: #e9ebe4;
  --paper-2: #dde1d8;
  --ink: #0b1820;
  --ink-2: #33444b;
  --ink-3: #52636a;
  --stamp: #b3342b;

  --sun: #ffd37e;

  --f-display: "Imbue", "Didot", "Bodoni 72", "Bodoni MT", Georgia, serif;
  --f-text: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --t-mega: clamp(4.2rem, 13.5vw, 14rem);
  --t-xxl: clamp(3.4rem, 9vw, 9rem);
  --t-xl: clamp(2.6rem, 6vw, 5.75rem);
  --t-l: clamp(2rem, 3.8vw, 3.4rem);
  --t-m: clamp(1.3rem, 1.1rem + 0.9vw, 1.8rem);
  --t-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --t-s: 0.9375rem;
  --t-xs: 0.75rem;
  --t-xxs: 0.6875rem;

  --gutter: clamp(1.25rem, 4.5vw, 4rem);
  --max: 90rem;
  --measure: 36rem;
  --head: 4.25rem;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--salt);
  font-family: var(--f-text);
  font-size: var(--t-body);
  font-weight: 400;
  line-height: 1.62;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas, video { display: block; max-width: 100%; }
h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
/* zero specificity, so a page can give a list its own padding */
:where(ul[role="list"], ol[role="list"]) { list-style: none; padding: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
button { font: inherit; color: inherit; }
table { border-collapse: collapse; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
::selection { background: var(--signal); color: var(--night); }
sup, sub { font-size: 0.64em; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.55em; }
sub { bottom: -0.22em; }
abbr[title] { text-decoration: none; }
i, em, cite { font-style: italic; }

.sci { white-space: nowrap; }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 100;
  background: var(--signal); color: var(--night);
  font: 500 var(--t-xs)/1 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.8rem 1rem; text-decoration: none;
}
.skip:focus { top: 0.75rem; }

/* ---------- type ---------- */
.display {
  font-family: var(--f-display);
  font-weight: 250;
  line-height: 0.92;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.label {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.4;
}
.lede {
  font-family: var(--f-text);
  font-style: italic;
  font-weight: 330;
  font-size: var(--t-m);
  line-height: 1.38;
  text-wrap: pretty;
}
/* a title inside italic text goes roman */
.lede i, .lede em, .lede cite { font-style: normal; }
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1.05em; }
.prose p { text-wrap: pretty; hanging-punctuation: first; }
.mono { font-family: var(--f-mono); }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.arr { font-family: var(--f-mono); font-style: normal; }

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- masthead ---------- */
.masthead {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--head);
  padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  transition: background-color 0.35s var(--ease), border-color 0.35s var(--ease), backdrop-filter 0.35s;
  border-bottom: 1px solid transparent;
}
.masthead[data-scrolled] {
  background: rgba(8, 21, 29, 0.84);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom-color: rgba(143, 195, 198, 0.12);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-family: var(--f-display);
  font-weight: 350;
  font-size: 1.3rem;
  letter-spacing: 0.005em;
  line-height: 1;
  color: var(--salt);
  white-space: nowrap;
}
.wordmark .mark { width: 1.75rem; height: 1.75rem; flex: none; color: var(--spray); }

.site-nav ul { list-style: none; padding: 0; margin: 0; display: flex; gap: clamp(1rem, 2.2vw, 2.25rem); }
.site-nav a {
  display: block;
  text-decoration: none;
  color: var(--mist);
  font-family: var(--f-mono);
  font-size: var(--t-xxs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.5rem 0;
  position: relative;
}
.site-nav a:hover { color: var(--salt); }
.site-nav a[aria-current="page"] { color: var(--salt); }
.site-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.1rem;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--signal);
}
.nav-when, .nav-blurb { display: none; }

.nav-toggle {
  display: none;
  align-items: center;
  gap: 0.7rem;
  background: none;
  border: 0;
  padding: 0.6rem 0;
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: var(--t-xxs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--salt);
}
.nav-toggle-lines { display: grid; gap: 5px; width: 22px; }
.nav-toggle-lines i { display: block; height: 1.5px; background: currentColor; transition: transform 0.3s var(--ease); }

@media (max-width: 56rem) {
  .nav-toggle { display: inline-flex; position: relative; z-index: 2; }
  .site-nav {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: var(--abyss);
    padding: calc(var(--head) + env(safe-area-inset-top, 0px) + 1.5rem) var(--gutter) 2rem;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ease), visibility 0s linear 0.3s;
  }
  .masthead[data-open] .site-nav { opacity: 1; visibility: visible; transition: opacity 0.3s var(--ease); }
  .masthead[data-open] .nav-toggle-lines i:first-child { transform: translateY(3.25px) rotate(45deg); }
  .masthead[data-open] .nav-toggle-lines i:last-child { transform: translateY(-3.25px) rotate(-45deg); }
  .masthead[data-open] .wordmark { position: relative; z-index: 3; }
  .nav-toggle { z-index: 3; }
  /* a solid band behind the name and the close button, so the menu scrolls under it cleanly */
  .masthead[data-open]::before {
    content: "";
    position: fixed;
    inset: 0 0 auto 0;
    height: calc(var(--head) + env(safe-area-inset-top, 0px));
    background: var(--abyss);
    border-bottom: 1px solid rgba(143, 195, 198, 0.16);
    z-index: 2;
  }
  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav li { border-top: 1px solid rgba(143, 195, 198, 0.16); }
  .site-nav li:last-child { border-bottom: 1px solid rgba(143, 195, 198, 0.16); }
  .site-nav a {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.3rem;
    padding: 1.1rem 0 1.2rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--salt);
  }
  .site-nav a[aria-current="page"]::before { left: auto; right: 0; top: 50%; bottom: auto; width: 7px; height: 7px; }
  .nav-when { display: block; font-family: var(--f-mono); font-size: var(--t-xxs); letter-spacing: 0.16em; text-transform: uppercase; color: var(--haze); }
  .nav-label { font-family: var(--f-display); font-weight: 300; font-size: clamp(2.6rem, 11vw, 3.6rem); line-height: 0.95; }
  .nav-blurb { display: block; font-family: var(--f-text); font-style: italic; font-size: 1.05rem; color: var(--mist); }
  html.nav-open { overflow: hidden; }
}
@media (max-width: 26rem) {
  .wordmark span { font-size: 1.12rem; }
}

/* ---------- shared blocks ---------- */

/* Cross-reference from the setting to the novella: which member of the line is here, going which way. */
.xref {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-family: var(--f-mono);
  font-size: var(--t-xxs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: inherit;
  border-top: 1px solid currentColor;
  padding-top: 0.6rem;
  opacity: 0.85;
}
.xref b { font-weight: 600; letter-spacing: 0.14em; }
.xref:hover { opacity: 1; }
.xref:hover .arr { transform: translateX(3px); }
.xref .arr { display: inline-block; transition: transform 0.2s var(--ease); }

.caption {
  font-family: var(--f-mono);
  font-size: var(--t-xxs);
  letter-spacing: 0.04em;
  line-height: 1.55;
  color: var(--haze);
  max-width: 44rem;
}

/* A chart's table twin */
.table-view { margin-top: 1rem; font-family: var(--f-mono); font-size: var(--t-xs); }
.table-view summary {
  cursor: pointer;
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--mist);
  list-style: none;
}
.table-view summary::-webkit-details-marker { display: none; }
.table-view summary::before { content: "+"; display: inline-block; width: 1ch; }
.table-view[open] summary::before { content: "−"; }
.table-view .table-scroll { overflow-x: auto; margin-top: 0.8rem; }
.data-table { width: 100%; min-width: 34rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: left; padding: 0.45rem 1rem 0.45rem 0; border-bottom: 1px solid rgba(143, 195, 198, 0.14); white-space: nowrap; }
.data-table th { font-weight: 500; color: var(--haze); letter-spacing: 0.08em; text-transform: uppercase; font-size: var(--t-xxs); }
.data-table td { color: var(--salt); }
.data-table .r { text-align: right; }

/* Hover readout shared by the charts */
.tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 11rem;
  background: rgba(5, 14, 20, 0.94);
  border: 1px solid rgba(143, 195, 198, 0.22);
  padding: 0.7rem 0.85rem;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  line-height: 1.5;
  color: var(--mist);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.tip[data-show] { opacity: 1; transform: none; }
.tip strong { display: block; color: var(--salt); font-weight: 500; font-size: 0.95rem; }
.tip .tip-row { display: flex; justify-content: space-between; gap: 1.2rem; }
.tip .tip-row b { font-weight: 500; color: var(--salt); }

/* The door to the next page */
.onward {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--salt);
  background: var(--abyss);
  border-top: 1px solid rgba(143, 195, 198, 0.14);
  overflow: hidden;
}
.onward-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 1rem 2rem;
  padding-block: clamp(3rem, 8vw, 6.5rem);
}
.onward .label { color: var(--haze); grid-column: 1 / -1; }
.onward-title {
  font-family: var(--f-display);
  font-weight: 250;
  font-size: var(--t-xl);
  line-height: 0.95;
}
.onward-blurb { grid-column: 1; font-style: italic; color: var(--mist); max-width: 32rem; }
.onward-arrow {
  grid-row: 2 / span 2;
  grid-column: 2;
  font-family: var(--f-mono);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 400;
  color: var(--signal);
  transition: transform 0.35s var(--ease);
  line-height: 1;
}
.onward::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 0;
  background: linear-gradient(180deg, rgba(47, 116, 128, 0.18), rgba(47, 116, 128, 0.32));
  transition: height 0.6s var(--ease);
}
.onward:hover::before, .onward:focus-visible::before { height: 100%; }
.onward:hover .onward-arrow { transform: translateX(0.4rem); }
.onward > * { position: relative; }

/* ---------- footer ---------- */
.colophon {
  background: var(--abyss);
  color: var(--mist);
  font-size: var(--t-s);
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
}
.colophon-tide {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(143, 195, 198, 0.35) 20%, rgba(143, 195, 198, 0.35) 80%, transparent);
}
.colophon-inner {
  max-width: var(--max);
  margin-inline: auto;
  padding: 3.5rem var(--gutter) 0;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 2.5rem 3rem;
}
.colophon-title p { margin-top: 1rem; max-width: 30rem; line-height: 1.55; }
.colophon-nav ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem 2rem; }
.colophon-nav a {
  font-family: var(--f-mono);
  font-size: var(--t-xxs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--mist);
}
.colophon-nav a:hover { color: var(--salt); }
.colophon-fine {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(143, 195, 198, 0.12);
  padding-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem 3rem;
  font-size: 0.875rem;
  color: var(--haze);
}
.colophon-fine p { max-width: 40rem; }
.colophon-key { font-family: var(--f-mono); font-size: var(--t-xxs); letter-spacing: 0.06em; }
@media (max-width: 44rem) {
  .colophon-inner { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* the way out of this book to the author's other fiction: set apart from the book's own sections */
.site-nav .nav-other { padding-left: clamp(1rem, 2.2vw, 2.25rem); border-left: 1px solid rgba(143, 195, 198, 0.28); }
.site-nav .nav-other a { color: var(--spray); }
.site-nav .nav-other a:hover { color: var(--salt); }
@media (max-width: 56rem) {
  .site-nav .nav-other { margin-top: 1.5rem; padding-left: 0; border-left: 0; border-top: 3px double rgba(143, 195, 198, 0.3) !important; }
  .site-nav .nav-other .nav-label { font-style: italic; font-family: var(--f-text); font-weight: 300; font-size: clamp(2rem, 8vw, 2.6rem); }
}
