/* ============================================================
   MIÉRRE — Residual Archives
   Palette derived from the theme bible:
   porcelain #E8E8EC · brushed metal #6E6E73 · android cyan #66CCFF
   ethereal #A3E0E9 · teal energy #3E92A3 · shadow #1F1F23
   ============================================================ */

:root,
[data-theme="umbra"] {
  --bg: #0d0e12;
  --bg-raise: #14151b;
  --line: #24262e;
  --ink: #e8e8ec;
  --ink-dim: #9a9aa2;
  --muted: #6e6e73;
  --seam: #66ccff;
  --seam-soft: #a3e0e9;
  --halo: rgba(102, 204, 255, 0.07);
  --selection: rgba(102, 204, 255, 0.25);
  --glow: 0 0 14px rgba(102, 204, 255, 0.35);
}

[data-theme="ember"] {
  --bg: #100e0d;
  --bg-raise: #181412;
  --line: #2c2521;
  --ink: #ece7e2;
  --ink-dim: #a49a92;
  --muted: #75695f;
  --seam: #e09a5c;
  --seam-soft: #e9c3a3;
  --halo: rgba(224, 154, 92, 0.07);
  --selection: rgba(224, 154, 92, 0.25);
  --glow: 0 0 14px rgba(224, 154, 92, 0.35);
}

[data-theme="void"] {
  --bg: #000000;
  --bg-raise: #0a0a0c;
  --line: #1c1c20;
  --ink: #d8d8de;
  --ink-dim: #8c8c94;
  --muted: #62626a;
  --seam: #5fb8e8;
  --seam-soft: #93cfe4;
  --halo: rgba(95, 184, 232, 0.06);
  --selection: rgba(95, 184, 232, 0.25);
  --glow: 0 0 12px rgba(95, 184, 232, 0.3);
}

[data-theme="porcelain"] {
  --bg: #f5f5f8;
  --bg-raise: #ececf1;
  --line: #d8d8e0;
  --ink: #26262c;
  --ink-dim: #55555e;
  --muted: #84848d;
  --seam: #1f7fb5;
  --seam-soft: #3e92a3;
  --halo: rgba(31, 127, 181, 0.06);
  --selection: rgba(31, 127, 181, 0.18);
  --glow: none;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.7;
  min-height: 100svh;
  transition: background 0.4s ease, color 0.4s ease;
}

::selection { background: var(--selection); }

a { color: var(--seam); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 1px solid var(--seam);
  outline-offset: 3px;
  border-radius: 2px;
}

.mono {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

.display {
  font-family: "Marcellus", "Literata", Georgia, serif;
  font-weight: 400;
}

/* faint film grain over everything, very subtle */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.55 0 0 0 0.03 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, header, footer { position: relative; z-index: 1; }

/* ============================================================
   INDEX PAGE
   ============================================================ */

.index-wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px 96px;
}

.site-head {
  text-align: center;
  padding: 72px 16px 8px;
}

.site-head .eyebrow {
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 18px;
}

.site-head h1 {
  font-size: clamp(44px, 9vw, 84px);
  letter-spacing: 0.28em;
  text-indent: 0.28em; /* optically recentre tracked type */
  margin: 0;
  font-weight: 400;
  color: var(--ink);
  text-shadow: var(--glow);
}

.site-head .sub {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 14px;
}

.head-rule {
  width: 180px;
  margin: 34px auto 0;
  border: 0;
  border-top: 1px solid var(--line);
  position: relative;
  overflow: visible;
}
.head-rule::after {
  content: "◦";
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -55%);
  color: var(--seam);
  background: var(--bg);
  padding: 0 10px;
  font-size: 11px;
}

/* ---------- path selector ---------- */

.path-select {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 44px 0 6px;
}

.path-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 9px 16px;
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s, box-shadow 0.25s;
}

.path-btn:hover { color: var(--ink); border-color: var(--muted); }

.path-btn[aria-pressed="true"] {
  color: var(--seam);
  border-color: var(--seam);
  box-shadow: var(--glow);
}

.path-note {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  min-height: 1.6em;
  margin: 10px 0 0;
}

/* ---------- the tree ---------- */

.tree-frame {
  position: relative;
  margin: 26px auto 10px;
  max-width: 640px;
}

.tree-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

.tree-pillar-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  fill: var(--ink-dim);
  opacity: 0.9;
}

.tree-halo {
  fill: none;
  stroke: var(--line);
  opacity: 0.8;
}

.tree-tick { stroke: var(--line); }

.tree-edge {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
  transition: stroke 0.45s, opacity 0.45s;
}

.tree-edge.lit {
  stroke: var(--seam);
  opacity: 0.85;
}

.tree-node { cursor: pointer; }

.tree-node circle.core {
  fill: var(--bg);
  stroke: var(--muted);
  stroke-width: 1;
  transition: stroke 0.45s, fill 0.45s;
}

.tree-node circle.ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
  transition: stroke 0.45s, opacity 0.45s;
}

.tree-node text {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  fill: var(--ink-dim);
  text-anchor: middle;
  dominant-baseline: middle;
  transition: fill 0.45s;
  pointer-events: none;
}

.tree-node.lit circle.core { stroke: var(--node-c, var(--seam)); }
.tree-node.lit circle.ring { stroke: var(--node-c, var(--seam)); opacity: 0.45; }
.tree-node.lit text { fill: var(--ink); }

.tree-node.dim { opacity: 0.38; }

.tree-node:hover circle.core,
.tree-node:focus-visible circle.core {
  fill: var(--bg-raise);
}

.tree-node .order-badge {
  font-size: 8.5px;
  fill: var(--muted);
}
.tree-node.lit .order-badge { fill: var(--node-c, var(--seam)); }

.tree-caption {
  text-align: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ink-dim) 80%, var(--bg));
  margin: 4px 0 0;
}

/* character legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin: 26px auto 0;
  padding: 0;
  list-style: none;
  max-width: 620px;
}
.legend li {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 7px;
}
.legend .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: inline-block;
}

/* ---------- reading order list ---------- */

.order-section { margin-top: 70px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title::before,
.section-title::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.story-list {
  list-style: none;
  margin: 34px auto 0;
  padding: 0;
  max-width: 720px;
}

.story-list li { border-bottom: 1px solid var(--line); }
.story-list li:first-child { border-top: 1px solid var(--line); }

.story-link {
  display: grid;
  grid-template-columns: 44px 84px 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 16px 10px;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.2s;
}
.story-link:hover { background: var(--bg-raise); text-decoration: none; }

.story-link .no {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
}
.story-link .code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--story-c, var(--seam));
}
.story-link .title-cell .t {
  font-family: "Marcellus", Georgia, serif;
  font-size: 17px;
  letter-spacing: 0.02em;
}
.story-link .title-cell .syn {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  font-style: italic;
  margin-top: 2px;
}
.story-link .who {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- footer ---------- */

.site-foot {
  margin-top: 90px;
  text-align: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.site-foot .wiki-link { display: inline-block; margin-bottom: 10px; }
.site-foot .warn {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 9.5px;
  letter-spacing: 0.24em;
}

/* ============================================================
   READER PAGE
   ============================================================ */

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.reader-bar a { color: var(--ink-dim); }
.reader-bar a:hover { color: var(--seam); text-decoration: none; }
.reader-bar .code { color: var(--seam); }
.reader-bar .pos { color: var(--muted); }

.progress-seam {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--seam);
  box-shadow: var(--glow);
  z-index: 6;
  transition: width 0.1s linear;
}

.chapter {
  max-width: 68ch;
  margin: 0 auto;
  padding: 56px 22px 40px;
}

.chapter-head { text-align: center; margin-bottom: 56px; }
.chapter-head .rec {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--seam);
}
.chapter-head h1 {
  font-family: "Marcellus", Georgia, serif;
  font-weight: 400;
  font-size: clamp(26px, 5vw, 38px);
  letter-spacing: 0.06em;
  margin: 16px 0 0;
}
.chapter-head .who {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 14px;
}
.chapter-head::after {
  content: "◦ ◦ ◦";
  display: block;
  margin-top: 34px;
  color: var(--muted);
  letter-spacing: 1.2em;
  text-indent: 1.2em;
  font-size: 10px;
}

/* prose */
.prose { font-size: var(--reader-size, 17px); line-height: 1.85; }
.prose p { margin: 0 0 1.35em; }
.prose h1, .prose h2, .prose h3 {
  font-family: "Marcellus", Georgia, serif;
  font-weight: 400;
  letter-spacing: 0.08em;
  margin: 2.4em 0 1em;
  line-height: 1.3;
}
.prose h1 { font-size: 1.55em; text-align: center; }
.prose h2 { font-size: 1.25em; }
.prose h3 { font-size: 1.05em; text-transform: uppercase; letter-spacing: 0.2em; }
.prose em { color: var(--ink); }
.prose blockquote {
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.4em;
  border-left: 1px solid var(--seam);
  color: var(--ink-dim);
  font-size: 0.94em;
}
.prose hr {
  border: 0;
  text-align: center;
  margin: 2.6em 0;
}
.prose hr::after {
  content: "✦";
  color: var(--muted);
  font-size: 12px;
}
.prose code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--bg-raise);
  padding: 0.1em 0.4em;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.prose img { max-width: 100%; height: auto; display: block; margin: 2em auto; }
.prose ul, .prose ol { margin: 0 0 1.35em; padding-left: 1.4em; }

/* chapter nav */
.chapter-nav {
  max-width: 68ch;
  margin: 0 auto;
  padding: 10px 22px 110px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
}
.chapter-nav a {
  border: 1px solid var(--line);
  padding: 13px 18px;
  color: var(--ink-dim);
  max-width: 46%;
  transition: border-color 0.25s, color 0.25s;
}
.chapter-nav a:hover { border-color: var(--seam); color: var(--seam); text-decoration: none; }
.chapter-nav a .lbl { display: block; font-size: 9px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.chapter-nav .next { text-align: right; margin-left: auto; }

/* ---------- theme control (non-intrusive) ---------- */

.theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(6px);
  color: var(--ink-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.25s, color 0.25s, opacity 0.3s;
  opacity: 0.55;
}
.theme-toggle:hover, .theme-toggle:focus-visible, .theme-toggle[aria-expanded="true"] {
  opacity: 1;
  border-color: var(--seam);
  color: var(--seam);
}
.theme-toggle svg { display: block; }

.theme-panel {
  position: fixed;
  right: 18px;
  bottom: 70px;
  z-index: 10;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  padding: 16px;
  width: 216px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: none;
}
.theme-panel.open { display: block; }
.theme-panel .row { margin-bottom: 14px; }
.theme-panel .row:last-child { margin-bottom: 0; }
.theme-panel .row-label { display: block; margin-bottom: 8px; }

.swatches { display: flex; gap: 8px; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.2s;
}
.swatch:hover { transform: scale(1.1); }
.swatch[aria-pressed="true"] { border-color: var(--seam); box-shadow: var(--glow); }
.swatch.s-umbra { background: radial-gradient(circle at 35% 35%, #66ccff 0 18%, #0d0e12 20%); }
.swatch.s-ember { background: radial-gradient(circle at 35% 35%, #e09a5c 0 18%, #100e0d 20%); }
.swatch.s-void { background: radial-gradient(circle at 35% 35%, #5fb8e8 0 18%, #000 20%); }
.swatch.s-porcelain { background: radial-gradient(circle at 35% 35%, #1f7fb5 0 18%, #f5f5f8 20%); }

.size-btns { display: flex; gap: 8px; align-items: center; }
.size-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  width: 34px; height: 30px;
  cursor: pointer;
}
.size-btn:hover { border-color: var(--seam); color: var(--seam); }
.size-val { color: var(--ink-dim); }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .site-head { padding-top: 52px; }
  .story-link {
    grid-template-columns: 34px 1fr;
    grid-template-areas: "no codewho" "no title";
    row-gap: 4px;
  }
  .story-link .no { grid-area: no; }
  .story-link .code { grid-area: codewho; }
  .story-link .title-cell { grid-area: title; }
  .story-link .who { display: none; }
  .chapter { padding-top: 40px; }
  .theme-toggle { right: 14px; bottom: 14px; }
  .theme-panel { right: 14px; bottom: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* subtle load-in for the tree, respecting reduced motion */
@media (prefers-reduced-motion: no-preference) {
  .tree-frame svg { animation: treeIn 1.1s ease both; }
  @keyframes treeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }
}

/* ---------- suspended records capsule ---------- */

.tree-capsule {
  fill: none;
  stroke: var(--line);
  stroke-dasharray: 3 6;
}
.tree-capsule.inner {
  stroke-dasharray: 1 7;
  opacity: 0.6;
}

.tree-node.pod circle.core {
  stroke-dasharray: 3 4;
  fill: color-mix(in srgb, var(--bg-raise) 60%, var(--bg));
}
.tree-node.pod circle.ring {
  stroke-dasharray: 1 5;
}
.tree-node.pod text { font-size: 9.5px; }
.tree-node.pod.lit circle.core {
  stroke-dasharray: none;
}

/* ---------- dossier blocks (personnel abstracts, system records) ---------- */

.prose .dossier {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.72em;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-x: auto;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-left: 2px solid var(--seam);
  padding: 1.1em 1.3em;
  margin: 2em 0;
  color: var(--ink-dim);
}
.prose .dossier em { color: var(--ink); font-style: italic; }
.prose .dossier strong { color: var(--seam); }

/* transparent white-line images (sigils) need a dark plate on the light theme */
[data-theme="porcelain"] .prose img {
  background: #26262c;
  border-radius: 4px;
  padding: 14px;
}
.prose img { max-width: min(100%, 420px); }

@media (max-width: 480px) {
  .prose .dossier { font-size: 0.62em; padding: 0.9em 0.8em; }
}

/* ---------- graphite / spacegray theme ---------- */

[data-theme="graphite"] {
  --bg: #3d3d3d;
  --bg-raise: #474849;
  --line: #565758;
  --ink: #eeeef1;
  --ink-dim: #c2c3c6;
  --muted: #9a9b9e;
  --seam: #8fd6f2;
  --seam-soft: #b9e4f2;
  --halo: rgba(143, 214, 242, 0.08);
  --selection: rgba(143, 214, 242, 0.3);
  --glow: 0 0 10px rgba(143, 214, 242, 0.3);
}
.swatch.s-graphite { background: radial-gradient(circle at 35% 35%, #8fd6f2 0 18%, #3d3d3d 20%); }

/* ---------- clean sci-fi display for the site title ---------- */

.site-head h1 {
  font-family: "Michroma", "Marcellus", sans-serif;
  font-size: clamp(30px, 6.4vw, 58px);
  letter-spacing: 0.34em;
  text-indent: 0.34em;
}

/* ---------- preloaded loading state ---------- */

.loading {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  text-align: center;
  padding: 110px 0;
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  animation: loadingPulse 1.8s ease-in-out infinite;
}
@keyframes loadingPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.85; }
}

/* ---------- capsule wake ---------- */

.tree-capsule { transition: stroke 0.5s, opacity 0.5s; }
.tree-capsule.lit { stroke: #a9a9c7; opacity: 0.9; }
.tree-capsule.inner.lit { opacity: 0.45; }

/* ---------- render-failure distortion ---------- */

.legend-name { display: inline-block; min-width: 2ch; }
.glitching {
  animation: glitchJitter 0.09s steps(2, end) infinite;
}
@keyframes glitchJitter {
  0%   { transform: translateX(-1px); opacity: 0.85; }
  50%  { transform: translateX(1px) skewX(-4deg); opacity: 1; }
  100% { transform: translateX(0); opacity: 0.9; }
}

/* ---------- reader typeface ---------- */

.prose { font-family: var(--reader-font, "Literata", Georgia, "Times New Roman", serif); }

.font-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.font-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 6px 9px;
  cursor: pointer;
  text-transform: none;
}
.font-btn:hover { border-color: var(--seam); color: var(--seam); }
.font-btn[aria-pressed="true"] { border-color: var(--seam); color: var(--seam); box-shadow: var(--glow); }
.font-btn[data-font="book"] { font-family: "Literata", Georgia, serif; }
.font-btn[data-font="georgia"] { font-family: Georgia, serif; }
.font-btn[data-font="arial"] { font-family: Arial, Helvetica, sans-serif; }
.font-btn[data-font="consolas"] { font-family: Consolas, ui-monospace, monospace; }

/* ---------- tucked-away colophon ---------- */

.colophon {
  margin-top: 26px;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: color-mix(in srgb, var(--muted) 70%, var(--bg));
  text-transform: uppercase;
}
.colophon a { color: inherit; }
.colophon a:hover { color: var(--muted); }

/* ---------- epigraph & resume ---------- */

.epigraph {
  font-style: italic;
  color: var(--muted);
  font-size: 14px;
  margin: 22px 0 0;
  min-height: 1.4em;
}

.resume-line {
  text-align: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 26px 0 -14px;
  min-height: 1.2em;
}
.resume-line a {
  display: inline-block;
  color: var(--seam);
  border: 1px solid color-mix(in srgb, var(--seam) 45%, transparent);
  border-radius: 2px;
  padding: 7px 14px;
  background: var(--halo);
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.resume-line a:hover {
  text-decoration: none;
  border-color: var(--seam);
  box-shadow: var(--glow);
  background: color-mix(in srgb, var(--seam) 12%, transparent);
}
.resume-line a::before {
  content: "◦";
  margin-right: 9px;
  animation: resumePulse 2.4s ease-in-out infinite;
}
@keyframes resumePulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* ---------- read state on the tree ---------- */

.tree-node.read circle.core {
  fill: color-mix(in srgb, var(--node-c, var(--seam)) 16%, var(--bg));
}
.tree-node.read.dim circle.core {
  fill: color-mix(in srgb, var(--muted) 14%, var(--bg));
}

/* ---------- reading time in the list ---------- */

.story-link .meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.story-link .mins {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: color-mix(in srgb, var(--muted) 72%, var(--bg));
  white-space: nowrap;
}

/* ---------- query the archive ---------- */

.query-section { margin-top: 70px; max-width: 720px; margin-left: auto; margin-right: auto; }

.query-input {
  display: block;
  width: 100%;
  margin-top: 30px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 13px 16px;
  outline: none;
  transition: border-color 0.25s;
}
.query-input::placeholder { color: var(--muted); text-transform: uppercase; letter-spacing: 0.22em; font-size: 11px; }
.query-input:focus { border-color: var(--seam); }

.query-status {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 12px 2px 0;
  min-height: 1.2em;
}

.query-results { list-style: none; margin: 14px 0 0; padding: 0; }
.query-results li { border-bottom: 1px solid var(--line); }
.query-hit {
  display: block;
  padding: 13px 10px;
  color: var(--ink);
  transition: background 0.2s;
}
.query-hit:hover { background: var(--bg-raise); text-decoration: none; }
.qh-head { display: flex; align-items: baseline; gap: 12px; }
.qh-head .code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--story-c, var(--seam));
}
.qh-title { font-family: "Marcellus", Georgia, serif; font-size: 15px; }
.qh-count {
  margin-left: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9.5px;
  color: var(--muted);
}
.qh-snip {
  display: block;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--ink-dim);
  font-style: italic;
  line-height: 1.6;
}
mark {
  background: var(--selection);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}

/* ---------- jump menu ---------- */

.reader-bar .pos {
  appearance: none;
  background: transparent;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 2px;
}
.reader-bar .pos:hover, .reader-bar .pos[aria-expanded="true"] { color: var(--seam); }

.jump-panel {
  position: fixed;
  top: 46px;
  right: 12px;
  z-index: 7;
  width: min(320px, calc(100vw - 24px));
  max-height: min(60vh, 480px);
  overflow-y: auto;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  display: none;
}
.jump-panel.open { display: block; }
.jump-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
}
.jump-item:last-child { border-bottom: 0; }
.jump-item:hover { background: color-mix(in srgb, var(--seam) 8%, var(--bg-raise)); text-decoration: none; }
.jump-item.here { color: var(--seam); }
.jump-item .j-no { color: var(--muted); font-size: 9.5px; }
.jump-item .j-title {
  font-family: "Literata", Georgia, serif;
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jump-item.here .j-title { color: var(--seam-soft); }

@media (max-width: 640px) {
  .story-link .meta { grid-area: codewho; justify-self: end; flex-direction: row; align-items: baseline; }
  .story-link .meta .who { display: none; }
}

.colophon.rights { margin-top: 8px; letter-spacing: 0.16em; }
.reader-rights { text-align: center; padding-bottom: 60px; margin-top: -70px; }

/* ---------- cryobay scene ---------- */

.star, .mote { fill: var(--ink); opacity: 0; transition: opacity 1.2s ease; transform-box: fill-box; transform-origin: center; }

svg.scene-cryobay .star {
  opacity: var(--o, 0.3);
  animation: starTwinkle var(--d, 3.5s) ease-in-out infinite;
  animation-delay: var(--dl, 0s);
}
@keyframes starTwinkle {
  0%, 100% { opacity: calc(var(--o, 0.3) * 0.35); }
  50% { opacity: var(--o, 0.3); }
}
svg.scene-cryobay .star.ship {
  fill: var(--seam);
  animation: shipTransit 46s linear infinite;
}
@keyframes shipTransit {
  from { transform: translateX(20px); }
  to { transform: translateX(600px); }
}

svg.scene-cryobay .mote {
  fill: #cfeaf5;
  opacity: var(--o, 0.3);
  animation: moteDrift var(--d, 6s) ease-in-out infinite alternate;
  animation-delay: var(--dl, 0s);
}
@keyframes moteDrift {
  from { transform: translateY(-3px); }
  to { transform: translateY(4px); }
}

/* the tree recedes into the dark */
.tree-node, .tree-halo, .tree-tick, .tree-pillar-label { transition: opacity 0.9s ease; }
svg.scene-cryobay .tree-node:not(.pod) { opacity: 0.07; pointer-events: none; }
svg.scene-cryobay .tree-edge:not(.cap-rail) { opacity: 0.05; }
svg.scene-cryobay .tree-halo, svg.scene-cryobay .tree-tick { opacity: 0.1; }
svg.scene-cryobay .tree-pillar-label:not(.cap-label):not(.cap-temp) { opacity: 0.12; }

/* frost on the capsule */
svg.scene-cryobay .tree-capsule {
  stroke: #bfe6f2;
  opacity: 1;
  filter: drop-shadow(0 0 7px rgba(170, 220, 244, 0.35));
}
svg.scene-cryobay .tree-capsule.inner { stroke: #9fd3e6; opacity: 0.55; }
svg.scene-cryobay .cap-rail { stroke: #9fd3e6; opacity: 0.5; }
svg.scene-cryobay .tree-node.pod circle.core {
  stroke: #cfeaf5;
  fill: color-mix(in srgb, #bfe6f2 11%, var(--bg));
}
svg.scene-cryobay .tree-node.pod circle.ring { stroke: #9fd3e6; opacity: 0.6; }
svg.scene-cryobay .tree-node.pod text { fill: #dff2fa; }
svg.scene-cryobay .cap-label { fill: #bfe6f2; opacity: 1; }

.cap-temp { font-size: 8.5px; opacity: 0; letter-spacing: 0.3em; transition: opacity 1.2s ease 0.4s; }
svg.scene-cryobay .cap-temp { opacity: 0.75; fill: #9fd3e6; }

/* porcelain theme: ice needs darker strokes to read on light ground */
[data-theme="porcelain"] svg.scene-cryobay .tree-capsule,
[data-theme="porcelain"] svg.scene-cryobay .cap-label { stroke: #4d9cbf; fill: #3e92a3; }
[data-theme="porcelain"] svg.scene-cryobay .star { fill: #26262c; }

/* ---------- resume clear ---------- */

.resume-line { transition: opacity 0.4s ease; }
.resume-line.gone { opacity: 0; }
.resume-wrap { position: relative; display: inline-block; }
.resume-clear {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: none;
  border: 0;
  cursor: pointer;
  margin-left: 12px;
  color: color-mix(in srgb, var(--muted) 75%, var(--bg));
  font-family: "Literata", Georgia, serif;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: none;
  transition: color 0.25s;
}
.resume-clear em { font-style: italic; }
.resume-clear:hover { color: var(--ink-dim); }

@media (max-width: 640px) {
  .resume-clear {
    position: static;
    display: block;
    transform: none;
    margin: 7px auto 0;
  }
}

/* ---------- terminal readouts (fenced ``` blocks) ---------- */

.prose .terminal {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.78em;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-x: auto;
  margin: 2.2em 0;
  padding: 1.3em 1.5em;
  color: var(--seam-soft);
  background:
    repeating-linear-gradient(0deg,
      transparent 0 2px,
      rgba(255, 255, 255, 0.012) 2px 3px),
    color-mix(in srgb, var(--bg) 60%, #000);
  border: 1px solid var(--line);
  border-top: 1px solid color-mix(in srgb, var(--seam) 40%, var(--line));
  text-shadow: 0 0 8px color-mix(in srgb, var(--seam) 22%, transparent);
}
.prose .terminal .err {
  color: #d98a6f;
  text-shadow: 0 0 8px rgba(217, 138, 111, 0.25);
}
.prose .terminal em { color: inherit; }
.prose .terminal .cursor {
  display: inline-block;
  color: var(--seam);
  animation: cursorBlink 1.1s steps(1) infinite;
}
@keyframes cursorBlink { 50% { opacity: 0; } }

[data-theme="porcelain"] .prose .terminal {
  color: #cfe8f4;
  background: #1b1c22;
  text-shadow: none;
}
