/* Single-page publication: hero, rail, chapters, in-place widgets. */

.layout {
  position: relative;
}

/* Hero */
.hero {
  position: relative;
  padding: clamp(3rem, 9vh, 6.25rem) var(--gutter) clamp(2.5rem, 6vh, 4.5rem);
}

.hero__grid {
  max-width: var(--wide);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(1.75rem, 5vw, 4rem);
  align-items: end;
}

.hero h1 {
  font-size: clamp(2.6rem, 7vw, 4.8rem);
  margin: 0 0 1.25rem;
  font-weight: 500;
}

.hero h1 span {
  display: block;
}

.hero .lede {
  margin: 0 0 1.2rem;
}

.hero__body {
  max-width: 36rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.hero-visual {
  position: relative;
  min-height: 240px;
  height: min(48vw, 400px);
}

.hero-visual svg {
  width: 100%;
  height: 100%;
}

.hero-caption {
  position: absolute;
  left: 0;
  bottom: 0;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Light constellation */
.dot {
  fill: var(--ink);
  opacity: 0.18;
}

.dot.bright {
  fill: var(--accent);
  opacity: 1;
}

.constellation-line {
  stroke: var(--ink);
  stroke-width: 0.7;
  opacity: 0.1;
  fill: none;
}

.node-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.3;
  opacity: 0.85;
}

.cloud-label,
.node-label {
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 1.4px;
  fill: var(--muted);
  text-transform: uppercase;
}

#compress .from-cloud {
  transform-box: fill-box;
  transform-origin: center;
  animation: drift-in 20s var(--ease) infinite alternate;
}

#compress .to-node {
  animation: settle 20s var(--ease) infinite alternate;
}

@keyframes drift-in {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.45;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.4);
    opacity: 0.08;
  }
}

@keyframes settle {
  0% {
    transform: translate(14px, -10px);
    opacity: 0.4;
  }
  100% {
    transform: translate(0, 0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  #compress .from-cloud,
  #compress .to-node {
    animation: none;
  }
  #compress .from-cloud {
    opacity: 0.16;
  }
}

/* Narrative strip */
.narrative {
  padding: 0 var(--gutter);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.narrative ol {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.85rem 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0;
  align-items: center;
}

.narrative li {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.narrative li:not(:last-child)::after {
  content: "\2192";
  color: var(--accent);
  letter-spacing: 0;
  margin: 0 0.5rem 0 0.1rem;
}

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

.narrative a:hover {
  color: var(--ink);
}

/* Chapter rail sits in a reserved left gutter — never over body text. */
.rail {
  display: none;
}

@media (min-width: 1240px) {
  main {
    padding-left: 11rem;
    min-width: 0;
  }

  .site-footer {
    padding-left: calc(11rem + var(--gutter));
    min-width: 0;
  }

  .rail {
    display: block;
    position: fixed;
    left: 0.65rem;
    top: calc(var(--nav-h) + 1.5rem);
    width: 9.5rem;
    margin: 0;
    float: none;
    z-index: 5;
    pointer-events: none;
    max-height: calc(100vh - var(--nav-h) - 2.5rem);
    overflow: auto;
  }

  .rail ol {
    pointer-events: auto;
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--line);
  }

  .rail a {
    display: flex;
    gap: 0.55rem;
    align-items: baseline;
    text-decoration: none;
    color: var(--muted-2);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.38rem 0 0.38rem 0.75rem;
    border-left: 2px solid transparent;
    margin-left: -1px;
  }

  .rail a span {
    font-variant-numeric: tabular-nums;
    color: var(--muted-2);
  }

  .rail a:hover {
    color: var(--ink);
  }

  .rail a.is-active {
    color: var(--ink);
    border-left-color: var(--accent);
  }

  .rail a.is-active span {
    color: var(--accent-ink);
  }
}

/* Assumption diagrams */
.contrast {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2.25rem;
}

.contrast figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1.3rem 1.2rem 1.1rem;
  min-height: 200px;
  border-radius: var(--radius-lg);
}

.contrast figcaption {
  margin-top: 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.diagram-pc,
.diagram-dc {
  width: 100%;
  height: 132px;
}

/* Chapter accordion */
.chapters {
  padding: 0 0 clamp(3rem, 8vh, 5rem);
}

.chapter {
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--nav-h) + 0.75rem);
}

.chapter:last-of-type {
  border-bottom: 1px solid var(--line);
}

.chapter-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem 1.4rem;
  align-items: start;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 1.6rem var(--gutter);
  cursor: pointer;
  color: inherit;
  font: inherit;
  max-width: none;
}

.chapter-toggle:hover {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.chapter-num {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  padding-top: 0.35rem;
  min-width: 2.2rem;
}

.chapter-titles {
  min-width: 0;
  max-width: 46rem;
}

.chapter-titles .kicker {
  margin-bottom: 0.35rem;
}

.chapter-titles h2,
.chapter-titles .chapter-title {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(1.55rem, 3.4vw, 2.35rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.45rem;
}

.thesis {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 38rem;
  line-height: 1.5;
}

.chapter-mark {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  background: var(--surface);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.chapter-mark svg {
  width: 12px;
  height: 12px;
  transition: transform 0.28s var(--ease);
}

.chapter.is-open .chapter-mark svg {
  transform: rotate(45deg);
}

.chapter.is-open .chapter-toggle {
  background: transparent;
}

.chapter-panel {
  padding: 0 var(--gutter) 2.8rem;
}

.chapter-panel[hidden] {
  display: none;
}

.chapter-panel__inner {
  max-width: var(--page-w);
  margin: 0 auto;
  padding-left: 0;
}

@media (min-width: 720px) {
  .chapter-panel__inner {
    padding-left: 3.6rem;
  }
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0 0 1.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Chronology (Gap): all years visible, stacked */
.timeline {
  margin: 1.6rem 0 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.15rem 1.25rem;
}

.timeline-year-block {
  margin: 0 0 1.45rem;
}

.timeline-year-block:last-of-type {
  margin-bottom: 0.35rem;
}

.timeline-year-heading {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3.6vw, 2.25rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 0.65rem;
  color: var(--ink);
  position: sticky;
  top: var(--nav-h);
  background: var(--surface);
  padding: 0.4rem 0 0.45rem;
  z-index: 1;
  border-bottom: 1px solid var(--line);
}

.timeline-events {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tl-event {
  font: inherit;
  text-align: left;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  min-height: 2.75rem;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.7rem;
  width: 100%;
}

.tl-event:hover,
.tl-event[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.tl-event .when {
  display: inline;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted);
  min-width: 8.6rem;
}

.tl-event strong {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.015em;
}

.timeline-detail {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  min-height: 6.5rem;
}

.timeline-detail .when {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.timeline-detail h3 {
  margin: 0.2rem 0 0.4rem;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--ink);
}

.timeline-detail p {
  margin: 0 0 0.7rem;
  color: var(--muted);
}

.timeline-detail a {
  color: var(--accent-ink);
}

.timeline-empty {
  color: var(--muted);
  margin: 0;
}

/* Size explorer */
.size-explorer {
  margin: 1.5rem 0 0.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.15rem 1.3rem;
}

.size-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.size-item {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.4rem 0.25rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  min-width: 3.6rem;
  min-height: 2.75rem;
  color: inherit;
  font: inherit;
}

.size-item i {
  display: block;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--line-strong);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.size-item small {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.size-item:hover i,
.size-item[aria-pressed="true"] i {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

.size-item[aria-pressed="true"] small {
  color: var(--accent-ink);
  font-weight: 600;
}

.size-detail {
  margin-top: 1.15rem;
  padding-top: 1.05rem;
  border-top: 1px solid var(--line);
}

.size-detail h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--ink);
}

.size-detail p {
  margin: 0;
  color: var(--muted);
  max-width: 40rem;
}

.size-detail .when {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.size-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  margin: 0.7rem 0 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.compare {
  display: grid;
  gap: 0.55rem;
  margin: 1.2rem 0;
}

.compare div {
  display: grid;
  grid-template-columns: 10.5rem 1fr auto;
  gap: 0.7rem;
  align-items: center;
  font-size: 0.88rem;
}

.compare b {
  font-weight: 500;
}

.compare span.bar {
  display: block;
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.compare span.bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}

.compare em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.78rem;
}
