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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--font-body);
  overflow-wrap: anywhere;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-notebook);
  line-height: 1.2;
}

a {
  color: var(--indigo);
  text-underline-offset: 0.2em;
}

button, input, select, textarea {
  font: inherit;
}

img, svg {
  max-width: 100%;
}

.wrap {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.nav .wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  padding-block: 0.75rem;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--indigo);
  font-weight: 600;
  text-decoration: none;
}

.nav a:hover,
.nav a:focus-visible {
  text-decoration: underline;
}

.nav .brand {
  font-family: var(--font-notebook);
  font-size: 1.25rem;
  text-decoration: none;
}

.nav nav[aria-label="Main navigation"] {
  display: flex;
  gap: 0 1.25rem;
}

.menu {
  min-width: 0;
}

.menu summary {
  min-width: 44px;
  min-height: 44px;
  color: var(--indigo);
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 641px) {
  .menu summary {
    display: none;
  }

  /* Keep the same links visible on desktop while the phone disclosure is closed. */
  .menu::details-content {
    display: contents;
    content-visibility: visible;
  }
}

.nav nav[aria-label="Main navigation"] a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--terracotta);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  height: 40px;
  margin-left: auto;
  gap: 4px;
}

.nav .mode-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 12px;
  border: 1.5px solid var(--indigo);
  border-radius: 18px;
  background: var(--button-fill);
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 12px;
  border: 1.5px solid var(--indigo);
  border-radius: 18px;
  background: var(--button-fill);
  color: var(--indigo);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn.on,
.btn--on,
.btn[aria-pressed="true"] {
  background: var(--indigo);
  color: var(--button-on-text);
}

.nav .mode-switch a[aria-current="page"] {
  background: var(--indigo);
  color: var(--button-on-text);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.card {
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
}

.tag {
  display: inline-block;
  border: 1px solid var(--terracotta);
  border-radius: 20px;
  padding: 2px 8px;
  margin-bottom: 10px;
  color: var(--terracotta-text);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stop {
  padding-block: 2.5rem;
  scroll-margin-top: 6rem;
}

.stop + .stop {
  border-top: 2px dashed var(--line);
}

.stop-intro {
  display: grid;
  align-items: center;
  gap: 2rem;
}

.stop-copy {
  min-width: 0;
  max-width: 38rem;
}

.stop-copy .tag,
.stop-copy h2 {
  margin-top: 0;
}

.stop-copy p:last-child {
  margin-bottom: 0;
}

.stop-intro .illus {
  width: 100%;
  max-width: 24rem;
  justify-self: center;
}

.stop-intro .illus svg,
.journey-scene .illus svg {
  display: block;
  width: 100%;
  height: auto;
}

.stop > [data-component] {
  margin-top: 2rem;
}

@media (min-width: 900px) {
  .stop {
    padding-block: 4.5rem;
  }

  .stop-intro {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 3rem;
  }

  .stop:nth-of-type(even) .stop-intro {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  }

  .stop:nth-of-type(even) .illus {
    grid-column: 1;
    grid-row: 1;
  }

  .stop:nth-of-type(even) .stop-copy {
    grid-column: 2;
    grid-row: 1;
  }
}

.illus {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  height: auto;
  border: 1px dashed var(--terracotta);
  border-radius: 8px;
  background: var(--paper-2);
}

.fn,
[data-component],
.journey-page .step {
  background: var(--paper-2);
  border-radius: 10px;
  padding: 16px;
}

.layers,
.stack-stages {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  margin-top: 8px;
}

.stack-stages .stack-stage {
  display: contents;
}

.stack-stage h3 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

[data-component="stack"] > .layers:empty {
  display: none;
}

.ly {
  border-left: 5px solid var(--layer-n, var(--notebook-layer-1));
  border-radius: 4px;
  padding: 6px 10px;
  background: var(--paper-2);
}

.illus svg [fill="#fbf6ee"] {
  fill: var(--paper-2);
}

.layer-card summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
}

.layer-card summary::-webkit-details-marker {
  display: none;
}

.layer-card summary::after {
  content: "+";
  color: var(--indigo);
}

.layer-card[open] summary::after {
  content: "−";
}

.layer-card summary small {
  margin-left: auto;
  color: var(--note-text);
  font-size: 0.8rem;
  text-align: right;
}

.layer-card p {
  margin-block: 8px;
}

.signal-lane {
  display: block;
  position: relative;
  min-width: 0;
  margin: 14px 0 4px;
}

.signal-lane svg {
  display: block;
  width: 100%;
  height: 140px;
  overflow: visible;
}

.signal-lane .signal-markers {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.signal-path {
  fill: none;
  stroke: var(--terracotta);
  stroke-width: 2;
  stroke-dasharray: 6 5;
  vector-effect: non-scaling-stroke;
}

/* Fixed-size notebook steps share the SVG route's coordinates. */
.signal-step {
  visibility: hidden;
}

.steps {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.st {
  position: absolute;
  top: 55px;
  transform: translateX(-50%);
  text-align: center;
  font-size: 11px;
  line-height: 1.25;
}

.st .c {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0 auto 4px;
  border: 2px solid var(--indigo);
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--indigo);
  font-weight: 700;
}

.st.fail .c {
  border-color: var(--terracotta);
  background: var(--failure-fill);
  color: var(--failure-number);
}

.stall {
  position: absolute;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  width: max-content;
  color: var(--terracotta-text);
  font-size: 10px;
  font-weight: 700;
}

.signal-lane text {
  fill: var(--ink);
  font: 12px var(--font-body);
}

.signal-lane .need-glow,
.signal-lane .need-core {
  fill: var(--turmeric);
  vector-effect: non-scaling-stroke;
}

.signal-lane .need-glow {
  stroke: rgba(217, 146, 43, .25);
  stroke-width: 24;
}

.signal-lane .need-core {
  stroke: var(--turmeric);
  stroke-width: 14;
}

.signal-lane .solution {
  fill: var(--turmeric);
  stroke: rgba(217, 146, 43, .25);
  stroke-width: 10;
  paint-order: stroke fill;
  vector-effect: non-scaling-stroke;
}

.signal-lane .solution {
  fill: var(--indigo);
  stroke: var(--paper-2);
  stroke-width: 2;
}

.signal-controls,
.signal-breaks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.signal-breaks {
  flex-basis: 100%;
}

.signal-controls .btn {
  max-width: 100%;
}

.signal-controls [aria-pressed="true"] {
  background: var(--indigo);
  color: var(--button-on-text);
}

.signal-status {
  border-left: 3px solid var(--indigo);
  padding-left: 0.75rem;
}

.chain li {
  margin-block: 0.5rem;
}

.chain .failure {
  display: block;
  color: var(--terracotta-text);
}

.failures {
  padding-left: 1.25rem;
}

.failures li {
  margin-block: 0.75rem;
}

.failure-toggle {
  max-width: 100%;
  text-align: left;
}

.note {
  font-size: 0.8rem;
  margin-top: 8px;
  color: var(--note-on-paper);
  font-style: italic;
}

.fn .note,
[data-component] .note,
.journey-page .step .note {
  color: var(--note-text);
}

.landing,
.explore-chooser {
  padding-block: var(--page-space);
}

.landing-hero {
  position: relative;
  max-width: 48rem;
}

.landing-copy {
  padding-top: 8px;
}

.hut {
  position: absolute;
  right: 20px;
  top: 18px;
  width: 70px;
  height: 56px;
  opacity: .85;
}

.landing-copy > .tag {
  max-width: calc(100% - 100px);
}

.landing h1 {
  padding-top: 28px;
  max-width: var(--hero-measure);
  margin: 0;
  font-size: var(--hero-size);
  font-weight: 400;
  line-height: var(--notebook-leading);
}

.landing .lede {
  max-width: var(--lede-measure);
  margin-block: var(--space-4) var(--space-5);
  font-size: var(--lede-size);
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.landing-actions .btn {
  padding: 4px 12px;
  font-weight: 600;
}

.landing-scene {
  margin-bottom: 12px;
}

.lane {
  position: relative;
  width: 100%;
  height: 66px;
}

.lane .track {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  height: 2px;
  background: repeating-linear-gradient(90deg, #b5653a 0 6px, transparent 6px 11px);
}

.lane .node {
  position: absolute;
  top: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--indigo);
}

.lane .node:last-of-type {
  margin-left: min(0px, calc(4% - 22px));
}

.lane .lbl {
  position: absolute;
  top: 38px;
  color: var(--lane-label);
  font: 11px var(--font-body);
  white-space: nowrap;
  transform: translateX(-30%);
}

.lane .lbl:first-of-type {
  transform: none;
}

.lane .lbl:nth-last-child(2) {
  left: auto !important;
  right: 0;
  transform: none;
}

.lane .need-dot {
  position: absolute;
  top: 17px;
  left: 46%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d9922b;
  box-shadow: 0 0 0 4px rgba(217, 146, 43, .25);
}

.landing-scene[data-motion] .need-dot {
  animation: travel 4.2s ease-in-out infinite;
  animation-play-state: paused;
}

.landing-scene[data-motion="running"] .need-dot {
  animation-play-state: running;
}

@keyframes travel {
  0% { left: 0; opacity: 0; }
  8% { opacity: 1; }
  45% { left: 46%; }
  55% { left: 46%; }
  92% { opacity: 1; }
  100% { left: 96%; opacity: 0; }
}

.landing-motion {
  margin: 0 0 16px;
  font-size: var(--small-size);
}

.landing-motion[hidden] {
  display: none;
}

.landing-status {
  margin-top: clamp(4rem, 8vw, 6rem);
  padding: var(--space-4);
  border-block: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: var(--small-size);
}

.landing-status p {
  margin: 0;
}

.explore-chooser > h1 {
  margin: 0 0 var(--space-3);
  font-size: var(--title-size);
  font-weight: 400;
}

.composites-label {
  margin: 0 0 var(--space-5);
}

.roles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.role {
  display: block;
  min-width: 0;
  padding: var(--space-4);
  color: var(--ink);
  text-decoration: none;
}

.role:hover {
  border-color: var(--indigo);
}

.role .illus svg {
  display: block;
  width: 100%;
  height: auto;
}

.role-kind {
  margin-top: var(--space-4);
}

.role h2 {
  margin-block: var(--space-1) var(--space-3);
  color: var(--indigo);
  font-size: var(--card-title-size);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.role p {
  margin: 0;
}

.journey {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 2rem;
}

.journey-page > h1 {
  margin-bottom: 0.75rem;
}

.journey-scene {
  display: grid;
  align-items: center;
  gap: 14px;
}

.journey-copy {
  min-width: 0;
}

.journey-copy > .scene {
  margin-top: 0;
}

.journey-progress {
  margin-top: 0;
}

.journey-page .step {
  margin-block: 16px;
}

.journey-page .step[hidden] {
  display: none;
}

@media (min-width: 900px) {
  .journey {
    grid-template-columns: minmax(0, 1fr) 15rem;
    gap: 14px;
  }

  .journey-scene:has(.illus) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.journey-main,
.journey-rail {
  min-width: 0;
}

.journey .choices,
.journey-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.journey .choices .btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  border-radius: 18px;
}

.journey-controls .btn:disabled {
  color: var(--ink-soft);
  border-color: var(--ink-soft);
  cursor: default;
}

.journey-result {
  border-left: 3px solid var(--indigo);
  padding-left: 0.75rem;
}

.journey-tally {
  font-size: 0.8rem;
}

.journey-reading dt {
  font-weight: 600;
}

.journey-reading dd {
  margin: 0 0 1rem;
}

.journey-layers {
  list-style: none;
  padding: 0;
  margin: 0;
}

.journey-chip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.875rem;
}

.journey-chip.is-lit {
  outline: 1px solid var(--layer-n);
}

.journey-chip-status {
  color: var(--note-text);
  font-size: 0.8rem;
}

.journey-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.journey-heading {
  scroll-margin-top: 12rem;
}

.footer {
  margin-top: 3rem;
  padding-block: 2rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 641px) and (max-width: 899px) {
  .nav .wrap {
    gap: 0.5rem;
  }

  .nav .brand {
    font-size: 1.125rem;
  }

  .nav nav {
    font-size: 0.875rem;
  }

  .nav nav[aria-label="Main navigation"] {
    gap: 0 0.6rem;
  }

  .nav .mode-switch a {
    padding-inline: 0.55rem;
  }
}

@media (max-width: 640px) {
  .nav .wrap {
    gap: 0.5rem;
    padding-block: 0.5rem;
  }

  .nav .brand {
    font-size: 1.125rem;
    white-space: nowrap;
  }

  .mode-switch {
    order: 2;
    font-size: 0.9375rem;
  }

  .nav .mode-switch a {
    padding-inline: 0.65rem;
  }

  .menu {
    order: 3;
  }

  .menu summary {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
    list-style: none;
  }

  .menu summary::-webkit-details-marker {
    display: none;
  }

  .nav .menu nav[aria-label="Main navigation"] {
    display: none;
  }

  .nav .menu[open] nav[aria-label="Main navigation"] {
    display: flex;
    position: absolute;
    inset: 100% 0 auto;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 1rem;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }

  .landing-hero,
  .roles {
    grid-template-columns: minmax(0, 1fr);
  }

  .landing-hero {
    gap: var(--space-5);
  }

  .landing-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lane .need-dot {
    left: 46%;
    opacity: 1;
  }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
