/* Jupiter 2011: The Second Recording — reading site */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Bitstream Charter", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs: 1.15rem;
  --measure: 36rem;
}

[data-theme="dark"] {
  --bg: #07080b;
  --bg-raised: #0f1116;
  --ink: #e7e1d4;
  --ink-soft: #bdb7aa;
  --muted: #8d887d;
  --rule: #24262d;
  --brass: #c9a24e;
  --brass-soft: rgba(201, 162, 78, 0.14);
  --alert: #ff6257;
  --ok: #7fe0a2;
  --paper: #e9e3d4;
  --paper-ink: #1e1c18;
  --paper-muted: #5c574d;
  --paper-rule: #c9c1ad;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3efe6;
  --bg-raised: #ebe6da;
  --ink: #1d1b17;
  --ink-soft: #3d3a33;
  --muted: #6c665b;
  --rule: #d6cfbf;
  --brass: #84631d;
  --brass-soft: rgba(132, 99, 29, 0.1);
  --alert: #b3261e;
  --ok: #1f7a43;
  --paper: #fffdf8;
  --paper-ink: #1e1c18;
  --paper-muted: #625d52;
  --paper-rule: #d9d2c2;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs);
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

::selection {
  background: var(--brass);
  color: var(--bg);
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.8rem;
  background: var(--brass);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.9rem;
  z-index: 10;
}

.skip:focus {
  top: 0.75rem;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  position: relative;
  z-index: 2;
}

.home {
  text-decoration: none;
  color: var(--muted);
}

.home:hover {
  color: var(--brass);
}

.tools {
  display: flex;
  gap: 0.35rem;
}

.tools button,
.resume button {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  min-width: 2.4rem;
  height: 2.1rem;
  padding: 0 0.55rem;
  cursor: pointer;
}

.tools button:hover,
.resume button:hover {
  color: var(--ink);
  border-color: var(--brass);
}

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 5;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background: var(--brass);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ---------- chapter ---------- */

.chapter {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.chapter-head {
  text-align: center;
  margin: 3rem 0 4.5rem;
}

.chapter-num {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 1rem;
}

.chapter-head h1 {
  font-weight: 400;
  font-size: clamp(2.1rem, 7vw, 3.2rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 1.1rem;
  text-wrap: balance;
}

.chapter-meta {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.prose p {
  margin: 0;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.prose p + p {
  text-indent: 1.5em;
}

.prose em {
  font-style: italic;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--brass-soft);
  padding: 0.08em 0.35em;
  border-radius: 3px;
  word-break: break-all;
}

.dateline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 1.6rem !important;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-indent: 0 !important;
  color: var(--muted);
}

.dateline .place {
  color: var(--brass);
}

.dateline + p {
  text-indent: 0 !important;
}

.dateline + p::first-line {
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

.prose * + .dateline {
  margin-top: 0.5rem !important;
}

hr.scene {
  border: 0;
  height: 1.5rem;
  margin: 3.2rem auto;
  position: relative;
  overflow: visible;
}

hr.scene::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.62rem;
  height: 0.62rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: repeating-linear-gradient(180deg, var(--brass) 0 2px, transparent 2px 3.5px);
  opacity: 0.85;
}

hr.scene::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7rem;
  height: 1px;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, transparent, var(--rule) 30%, transparent 44%, transparent 56%, var(--rule) 70%, transparent);
}

/* ---------- in-world documents ---------- */

.doc {
  margin: 2.4rem 0;
  text-indent: 0;
}

.prose .doc p {
  text-indent: 0;
}

/* the NASA transcript: a sheet of paper */
.transcript {
  margin-left: -0.75rem;
  margin-right: -0.75rem;
}

.transcript .paper {
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.55;
  padding: 1.6rem 1.4rem 1.4rem;
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  position: relative;
}

.transcript .paper::before {
  content: "RELEASED";
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.25em;
  color: #a8322a;
  border: 2px solid #a8322a;
  padding: 0.15rem 0.45rem 0.1rem 0.6rem;
  transform: rotate(4deg);
  opacity: 0.75;
}

.transcript .doc-title {
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0 0 0.1rem;
  max-width: 80%;
}

.transcript .doc-sub {
  color: var(--paper-muted);
  margin: 0 0 1.2rem;
}

.transcript .doc-title + .doc-meta,
.transcript .doc-sub + .doc-title {
  margin-top: 0;
}

.transcript .doc-meta,
.transcript .doc-note {
  margin: 0 0 1rem !important;
  color: var(--paper-muted);
}

.transcript .doc-note {
  font-style: normal;
  border-left: 2px solid var(--paper-rule);
  padding-left: 0.7rem;
}

.transcript .doc-note em {
  font-style: normal;
}

.legend {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.9rem;
  margin: 0 0 1rem;
  color: var(--paper-muted);
}

.legend dt {
  font-weight: 700;
  color: var(--paper-ink);
}

.legend dd {
  margin: 0;
}

.cvr {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0 1.2rem;
  border-top: 1px solid var(--paper-rule);
}

.cvr thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.cvr td {
  vertical-align: top;
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--paper-rule);
}

.cvr .t {
  width: 3.6rem;
  color: var(--paper-muted);
  white-space: nowrap;
}

.cvr .s {
  width: 2.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.cvr .cue,
.cvr .row-cue .x {
  color: var(--paper-muted);
  font-style: italic;
}

/* social feed */
.feed {
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1rem 0 0.25rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.45;
}

.feed figcaption {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 1.1rem 0.8rem;
  border-bottom: 1px solid var(--rule);
}

.feed ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.post:last-child {
  border-bottom: 0;
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--rule);
}

.handle {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.post p {
  margin: 0.15rem 0 0 !important;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* audio playback */
.audio {
  border-left: 2px solid var(--brass);
  background: linear-gradient(90deg, var(--brass-soft), transparent 70%);
  padding: 0.9rem 1.1rem 0.9rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.75;
}

.audio figcaption {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 0.55rem;
}

.rec {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--alert);
  animation: rec 1.6s steps(2, jump-none) infinite;
}

@keyframes rec {
  50% {
    opacity: 0.15;
  }
}

.audio p {
  margin: 0 !important;
}

.a-cue {
  color: var(--muted);
  font-style: italic;
}

.a-who {
  display: inline-block;
  width: 2.6rem;
  color: var(--brass);
}

.a-line .cue {
  color: var(--muted);
  font-style: italic;
}

/* one line of telemetry */
.telemetry {
  margin: 1.8rem 0;
  padding: 0.85rem 1rem;
  background: #050607;
  border: 1px solid #1b1d22;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-indent: 0;
}

.telemetry code {
  font: inherit;
  background: none;
  padding: 0;
}

.telemetry.alert {
  color: #ff6257;
  text-shadow: 0 0 10px rgba(255, 98, 87, 0.35);
}

.telemetry.ok {
  color: #7fe0a2;
  text-shadow: 0 0 10px rgba(127, 224, 162, 0.3);
}

/* ---------- chapter end ---------- */

.chapter-end {
  margin-top: 4rem;
  text-align: center;
}

.end-mark {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 2.5rem;
}

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  text-align: left;
}

.chapter-nav a,
.chapter-nav .pending {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  line-height: 1.35;
}

.chapter-nav a:hover {
  border-color: var(--brass);
}

.chapter-nav .nav-next {
  grid-column: 2;
  text-align: right;
}

.chapter-nav small {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.chapter-nav .pending {
  color: var(--muted);
  border-style: dashed;
}

.chapter-nav .pending em {
  display: block;
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.72rem;
  margin-top: 0.3rem;
}

/* resume notice */
.resume {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem 0.55rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  z-index: 6;
  max-width: calc(100vw - 2rem);
}

.resume[hidden] {
  display: none;
}

.resume span {
  white-space: nowrap;
}

.resume button {
  height: 1.9rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .resume {
    left: 0.75rem;
    right: 0.75rem;
    transform: none;
    max-width: none;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .resume span {
    flex: 1 0 100%;
  }
}

/* ---------- index ---------- */

.page-index {
  overflow-x: hidden;
}

/* Jupiter as a thin lit crescent in the top-right corner, night side toward the text */
.planet {
  position: absolute;
  top: -20vmax;
  right: -32vmax;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 7% 4.5% at 63% 66%, rgba(170, 78, 48, 0.75), transparent 70%),
    linear-gradient(
      172deg,
      #3b2a1b 0%,
      #74522f 7%,
      #cdb18a 12%,
      #8f633c 17%,
      #e2d0ad 23%,
      #a77c51 29%,
      #dbc7a3 36%,
      #7d5434 43%,
      #c9ac83 50%,
      #e8d9bc 56%,
      #9c714a 62%,
      #d5bd95 69%,
      #714b2f 77%,
      #b9966c 85%,
      #3f2c1c 100%
    );
  box-shadow: inset 15vmax 5vmax 9vmax rgba(7, 8, 11, 0.97), 0 0 6vmax rgba(201, 162, 78, 0.06);
  filter: saturate(0.85);
  opacity: 0.8;
  z-index: 0;
  pointer-events: none;
}

[data-theme="light"] .planet {
  opacity: 0.45;
  box-shadow: inset 15vmax 5vmax 9vmax rgba(243, 239, 230, 0.97);
}

.cover {
  position: relative;
  z-index: 1;
  max-width: 40rem;
  margin: 0 auto;
  padding: 5vh 1.25rem 4rem;
}

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--ok);
  margin: 0 0 1.4rem;
}

.cover h1 {
  margin: 0 0 1.6rem;
  font-weight: 400;
  line-height: 1;
}

.cover .t1 {
  display: block;
  font-size: clamp(3.2rem, 13vw, 6.2rem);
  letter-spacing: -0.02em;
}

.cover .t2 {
  display: block;
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: clamp(0.8rem, 2.6vw, 1rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--brass);
}

.logline {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 32rem;
  margin: 0 0 2rem;
}

.button {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bg);
  background: var(--brass);
  padding: 0.85rem 1.3rem;
  border-radius: 4px;
}

.button:hover {
  filter: brightness(1.1);
}

.toc {
  margin-top: 4rem;
}

.toc h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

.toc h2 small {
  font-size: inherit;
  letter-spacing: 0.1em;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item > a,
.toc-item.pending {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.toc-item > a:hover .toc-title {
  color: var(--brass);
}

.toc-num {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.toc-title {
  font-size: 1.15rem;
}

.toc-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.toc-item.pending .toc-title {
  color: var(--muted);
}

.toc-item.pending .toc-meta {
  opacity: 0.7;
}

.toc-item.is-read .toc-meta::after {
  content: " · read";
  color: var(--ok);
}

.toc-item.is-started .toc-meta::after {
  content: " · " attr(data-progress);
  color: var(--brass);
}

/* ---------- 404 ---------- */

.lost {
  max-width: 30rem;
  margin: 12vh auto;
  padding: 0 1.25rem;
  text-align: center;
}

.lost h1 {
  font-weight: 400;
  font-size: 2.4rem;
  margin: 1.5rem 0 0.5rem;
}

.lost .telemetry {
  display: inline-block;
}

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

.site-foot {
  position: relative;
  z-index: 1;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

/* ---------- small screens ---------- */

@media (max-width: 34rem) {
  .chapter {
    padding-top: 0.5rem;
  }

  .chapter-head {
    margin: 2rem 0 3rem;
  }

  .transcript {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
  }

  .transcript .paper {
    padding: 1.2rem 1rem;
    border-radius: 0;
    font-size: 0.7rem;
  }

  .transcript .paper::before {
    position: static;
    display: inline-block;
    margin-bottom: 0.8rem;
  }

  .transcript .doc-title {
    max-width: none;
  }

  .cvr .t {
    width: 3.1rem;
  }

  .chapter-nav {
    grid-template-columns: 1fr;
  }

  .chapter-nav .nav-next {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rec {
    animation: none;
  }

  html {
    scroll-behavior: auto;
  }
}

@media print {
  .topbar,
  .progress,
  .resume,
  .chapter-nav,
  .planet {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
