/* React Native architecture essay: a fixed 3D stage with chapter cards scrolling over it */

.rn { background: var(--mineral); }

#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  display: block;
  pointer-events: none;
}

.rn main { position: relative; z-index: 1; }
.rn .site-header { z-index: 20; }
.rn .site-footer { position: relative; z-index: 2; background: var(--mineral); }

/* Layer rail: one unbroken spectral line, one node per chapter */

.rail {
  position: fixed;
  z-index: 3;
  top: 50%;
  left: clamp(0.75rem, 1.6vw, 1.75rem);
  transform: translateY(-50%);
  display: none;
}
.rail ol { position: relative; margin: 0; padding: 0; list-style: none; display: grid; gap: 0.15rem; }
.rail ol::before {
  content: "";
  position: absolute;
  top: 1.1rem;
  bottom: 1.1rem;
  left: 0.6rem;
  width: 1px;
  background: var(--line-dark-strong);
}
.rail a {
  position: relative;
  min-height: 2.2rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--muted-dark);
  text-decoration: none;
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.rail a::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  margin-left: 0.33rem;
  border: 1px solid var(--line-dark-strong);
  border-radius: 999px;
  background: var(--mineral);
  transition: background var(--fast) var(--ease-out), border-color var(--fast) var(--ease-out), transform var(--fast) var(--ease-out);
}
.rail span { display: none; }
.rail b {
  font-weight: 700;
  opacity: 0;
  transform: translateX(-0.4rem);
  transition: opacity var(--normal) var(--ease-out), transform var(--normal) var(--ease-out);
}
.rail:hover b, .rail:focus-within b, .rail a[aria-current] b { opacity: 1; transform: none; }
.rail a[aria-current] { color: var(--porcelain); }
.rail a[aria-current]::before { background: var(--spectral); border-color: var(--spectral); transform: scale(1.25); }
.rail a:hover::before { border-color: var(--porcelain); }

/* Chapters */

.chapter {
  min-height: 100vh;
  min-height: 100svh;
  padding: 7rem var(--gutter) 5rem;
  display: flex;
  align-items: center;
}

.card {
  width: min(33rem, 40vw);
  margin-left: clamp(2.5rem, 5vw, 6rem);
  padding: clamp(1.75rem, 2.6vw, 2.5rem);
  border: 1px solid var(--line-dark);
  background: oklch(13% 0.018 225 / 0.9);
  color: var(--muted-dark);
  font-size: var(--t-body);
  line-height: 1.65;
}
.card > :last-child { margin-bottom: 0; }
.card p { margin: 0 0 1.1rem; }
.card strong, .card b { color: var(--porcelain); font-weight: 700; }
.card code {
  padding: 0.05em 0.35em;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: var(--raised);
  color: var(--porcelain);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
}
.card a:not(.text-link) { color: var(--porcelain); text-decoration-color: var(--scarlet); text-underline-offset: 0.2em; }

.card-hero { width: min(40rem, 46vw); border: 0; background: transparent; padding: 0; }
.chapter-hero { min-height: 100vh; min-height: 100svh; }

.rn-title {
  margin: 1.25rem 0 0;
  color: var(--porcelain);
  font-family: var(--serif);
  font-size: clamp(2.9rem, 5.6vw, 5.8rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}
.rn-title em { color: var(--scarlet); }
.rn-lead { margin: 1.75rem 0 0 !important; max-width: 36ch; color: var(--muted-dark); font-size: var(--t-lead); line-height: 1.55; }
.rn-byline { margin: 2rem 0 0; display: flex; flex-wrap: wrap; gap: 1rem 2.25rem; }
.rn-byline div { display: grid; gap: 0.2rem; }
.rn-byline dt { color: var(--muted-dark); font-size: var(--t-label); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.75; }
.rn-byline dd { margin: 0; color: var(--porcelain); font-weight: 650; }
.rn-cue { margin: 2.75rem 0 0 !important; display: flex; align-items: center; gap: 0.9rem; color: var(--porcelain); font-size: 0.9375rem; font-weight: 650; }
.rn-cue span { width: 1px; height: 2.6rem; background: linear-gradient(var(--spectral), transparent); animation: rn-cue 1.8s var(--ease-in) infinite; transform-origin: top; }
@keyframes rn-cue { 0% { transform: scaleY(0); } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

.kicker {
  margin: 0 0 1rem !important;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  color: var(--porcelain);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.kicker span { color: var(--spectral); font-variant-numeric: tabular-nums; }

.card h2 {
  margin: 0 0 1.25rem;
  color: var(--porcelain);
  font-family: var(--serif);
  font-size: clamp(2rem, 3.1vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}
.card h3 {
  margin: 1.75rem 0 0.6rem;
  color: var(--porcelain);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.steps { margin: 0 0 1.25rem; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 0.85rem; }
.steps li { position: relative; padding-left: 2.4rem; counter-increment: step; }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.15em;
  color: var(--spectral);
  font-size: var(--t-label);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.ticks { margin: 0 0 1.25rem; padding: 0; list-style: none; display: grid; gap: 0.55rem; }
.ticks li { position: relative; padding-left: 1.5rem; }
.ticks li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 0.6rem; height: 1px; background: var(--spectral); }
.ticks-warn li::before { background: var(--scarlet); }

.parts { margin: 0 0 1.25rem; display: grid; gap: 0; border-top: 1px solid var(--line-dark); }
.parts div { padding: 0.8rem 0; display: grid; grid-template-columns: 9.5rem 1fr; gap: 1rem; border-bottom: 1px solid var(--line-dark); }
.parts dt { color: var(--porcelain); font-weight: 700; line-height: 1.5; }
.parts dd { margin: 0; line-height: 1.55; }

.callout { padding-left: 1.1rem; border-left: 2px solid var(--scarlet); color: var(--porcelain); }
.note { padding: 0.9rem 1rem; border: 1px solid var(--line-dark); color: var(--porcelain); font-size: 0.9375rem; }
.caption { color: var(--muted-dark); font-size: 0.875rem; opacity: 0.85; }

.remember {
  margin: 1.6rem 0 0 !important;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-dark-strong);
  color: var(--porcelain);
}
.remember b {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--spectral) !important;
  font-size: var(--t-label);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Controls */

.toggle { margin: 0 0 1.25rem; display: inline-flex; padding: 0.25rem; border: 1px solid var(--line-dark-strong); border-radius: 999px; }
.toggle button,
.replay {
  min-height: 44px;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-dark);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--fast) var(--ease-out), color var(--fast) var(--ease-out);
}
.toggle button:hover { color: var(--porcelain); }
.toggle button[aria-pressed="true"] { background: var(--porcelain); color: var(--mineral); }
.replay {
  margin: 0.25rem 0 1.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--scarlet);
  color: var(--mineral);
}
.replay:hover { background: var(--scarlet-bright); }
.replay:active { transform: translateY(1px); }
.replay svg { width: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; }

.journey { margin: 0 0 1.25rem; padding: 0; list-style: none; display: grid; gap: 0; border-top: 1px solid var(--line-dark); }
.journey li {
  position: relative;
  padding: 0.7rem 0 0.7rem 2.2rem;
  border-bottom: 1px solid var(--line-dark);
  transition: color var(--normal) var(--ease-out);
}
.journey li::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 1.15rem;
  width: 0.6rem;
  height: 0.6rem;
  border: 1px solid var(--line-dark-strong);
  border-radius: 999px;
  transition: background var(--normal) var(--ease-out), border-color var(--normal) var(--ease-out), box-shadow var(--normal) var(--ease-out);
}
.journey li.done::before { background: var(--muted-dark); border-color: var(--muted-dark); }
.journey li[aria-current="step"] { color: var(--porcelain); }
.journey li[aria-current="step"]::before { background: var(--scarlet); border-color: var(--scarlet); box-shadow: 0 0 0 4px oklch(65% 0.24 25 / 0.22); }

/* Closing */

.map { margin: 1.75rem 0 0; }
.map a { display: block; border: 1px solid var(--line-dark); background: var(--raised); }
.map img { width: 100%; height: auto; }
.map figcaption { margin-top: 0.7rem; color: var(--muted-dark); font-size: 0.8125rem; }
.author { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--line-dark-strong); }
.chapter-end { padding-bottom: 8rem; }

.fallback-map { display: none; margin: 2.5rem 0 0; }
.no-webgl .fallback-map { display: block; }
.no-webgl #stage { display: none; }
.no-webgl .chapter { min-height: 0; }
.no-webgl .card, .no-webgl .card-hero { width: min(44rem, 100%); }

@media (min-width: 1180px) {
  .rail { display: block; }
}

@media (max-width: 899px) {
  .chapter { min-height: 0; padding: 58svh var(--gutter) 2rem; align-items: flex-start; }
  .chapter-hero { padding-top: 7rem; padding-bottom: 46svh; }
  .card, .card-hero { width: 100%; margin-left: 0; }
  .card { background: oklch(13% 0.018 225 / 0.95); }
  .parts div { grid-template-columns: 1fr; gap: 0.25rem; }
  .no-webgl .chapter { padding-top: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .rn-cue span { animation: none; }
  .rail b, .rail a::before, .journey li, .journey li::before { transition: none; }
}
