:root {
  --night: #0b1d17;
  --cream: #f3ece0;
  --muted: rgba(203, 207, 200, 0.62);
  --rule: rgba(203, 207, 200, 0.18);
  --serif: "Cormorant Garamond", Garamond, Georgia, serif;
  --script: "Pinyon Script", cursive;

  /* The same motion language as the letter: slow out, settled in */
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

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

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  background: var(--night);
  color: var(--cream);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 1px solid rgba(243, 236, 224, 0.7);
  outline-offset: 6px;
}

/* Double hairline frame, like a printed card border */
.frame {
  position: fixed;
  inset: max(14px, env(safe-area-inset-top)) 14px 14px;
  border: 1px solid var(--rule);
  pointer-events: none;
  z-index: 5;
}

.frame::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--rule);
  opacity: 0.5;
}

.page {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 34px clamp(28px, 4vw, 52px);
}

.page > * { min-width: 0; }

/* ---------- Header ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  text-decoration: none;
}

.mark { width: 30px; height: 30px; }

.nav {
  display: flex;
  gap: 34px;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.3s ease;
}

.nav a:hover,
.nav a[aria-current="page"] { color: var(--cream); }

.weather {
  margin: 0;
  font-style: italic;
  font-size: 15px;
  color: var(--muted);
}

/* ---------- Arrival ---------- */

.arrival {
  position: relative;
  display: grid;
  place-items: center;
  padding: 28px 0;
  text-align: center;
}

/* The chart sits behind the words, faint, as a plate does behind a title page */
.chart {
  position: absolute;
  width: min(92vw, 78vh);
  opacity: 0.4;
  pointer-events: none;
}

.copy {
  position: relative;
  display: grid;
  justify-items: center;
}

.eyebrow {
  margin: 0 0 14px;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}

.title {
  margin: 0;
  font-weight: 400;
  font-size: clamp(44px, 8vw, 84px);
  line-height: 1;
  letter-spacing: 0.4em;
  padding-left: 0.4em;
  text-transform: uppercase;
}

.lede {
  max-width: 30em;
  margin: 22px 0 34px;
  font-style: italic;
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.5;
  color: var(--muted);
  text-wrap: balance;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px 30px;
}

.btn {
  padding: 15px 30px 15px calc(30px + 0.3em);
  border: 1px solid rgba(203, 207, 200, 0.45);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-decoration: none;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.btn:hover {
  border-color: rgba(243, 236, 224, 0.85);
  background: rgba(243, 236, 224, 0.04);
}

.quiet {
  font-style: italic;
  font-size: 17px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.3s ease;
}

.quiet:hover { color: var(--cream); }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.facts > div + div { border-left: 1px solid var(--rule); }

.facts dt {
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.facts dd {
  margin: 6px 0 0;
  font-style: italic;
  font-size: 17px;
}

/* ---------- The map ---------- */

.map-view {
  --map-ink: rgba(243, 236, 224, 0.82);
  --map-paper: #0d231b;

  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 34px;
  align-items: center;
  padding-top: 26px;
}

.atlas {
  position: relative;
  border: 1px solid var(--rule);
  color: var(--map-ink);
}

.atlas-view { overflow: hidden; }

.plate {
  display: block;
  width: 100%;
  max-height: calc(100svh - 150px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Your footprints, and the ring that marks where you stand */
.trail { color: var(--cream); pointer-events: none; }

.you { transition: transform 75ms linear; }

/* Everyone else: the same footprints in a quieter ink, each keyed by a numeral to the list */
.others { color: var(--map-ink); }
.visitor { transition: opacity 2.4s ease; }
.visitor.gone { opacity: 0; }
.visitor .steps { opacity: 0.5; transition: opacity 0.3s ease; }
.visitor-mark { opacity: 0.9; transition: transform 75ms linear; }

.visitor-numeral {
  fill: currentColor;
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  font-weight: 600;
  stroke: var(--map-paper);
  stroke-width: 3.5px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.visitor.lit { color: var(--cream); }
.visitor.lit .steps { opacity: 0.9; }

.whereabouts {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-style: italic;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

/* Places answer to the pointer: their names brighten, and a chosen one is circled */
.place { cursor: pointer; outline: none; }
.place .hit { fill: transparent; }
.place text { transition: fill 0.3s ease; }

.place:hover text,
.place:focus-visible text,
.place.chosen text { fill: var(--cream); }

.ring {
  fill: none;
  stroke: var(--cream);
  stroke-width: 0.7;
  stroke-opacity: 0.7;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.3s var(--ease);
}

.ring.on {
  stroke-dashoffset: 0;
  transition-duration: 0.9s;
}

.place:focus-visible .hit {
  stroke: var(--cream);
  stroke-width: 0.6;
  stroke-dasharray: 2 4;
}

/* Her note on a place: a small engraved card beside it */
.card {
  position: absolute;
  z-index: 2;
  width: 290px;
  padding: 22px 24px 24px;
  background: var(--night);
  border: 1px solid rgba(203, 207, 200, 0.4);
  box-shadow: inset 0 0 0 4px var(--night), inset 0 0 0 5px rgba(203, 207, 200, 0.16), 0 18px 40px rgba(0, 0, 0, 0.45);
  color: var(--cream);
  opacity: 0;
  translate: 0 6px;
  transition: opacity 0.4s var(--ease), translate 0.4s var(--ease);
}

.card.shown {
  opacity: 1;
  translate: 0 0;
  transition-duration: 0.6s;
}

.card-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 9px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.card-close svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
}

.card-close:hover { color: var(--cream); }

.card-kicker {
  margin: 0 0 8px;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-name {
  margin: 0;
  font-weight: 400;
  font-size: 26px;
  line-height: 1.15;
}

.card-sub {
  margin: 2px 0 0;
  font-style: italic;
  font-size: 16px;
  color: var(--muted);
}

.card-body {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 17px;
  line-height: 1.5;
}

/* Her remarks, written in at the top of the map as she passes judgement, then let go */
.remark {
  position: absolute;
  z-index: 1;
  top: 18px;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 2px;
  width: max-content;
  max-width: min(460px, 56%);
  margin: 0;
  text-align: center;
  pointer-events: none;
  translate: -50% 6px;
  opacity: 0;
  transition: opacity 0.9s var(--ease), translate 0.9s var(--ease);
  text-shadow: 0 0 8px var(--map-paper), 0 0 16px var(--map-paper);
}

.remark.shown {
  translate: -50% 0;
  opacity: 1;
}

.remark-words {
  font-family: var(--script);
  font-size: 30px;
  line-height: 1.25;
  white-space: pre-line;
  text-wrap: balance;
  color: var(--cream);
}

.remark-by {
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

/* The legend: the places, or the present company */
.tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--rule);
}

.tabs button {
  margin-bottom: -1px;
  padding: 0 0 9px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.tabs button:hover,
.tabs [aria-selected="true"] { color: var(--cream); }
.tabs [aria-selected="true"] { border-bottom-color: rgba(243, 236, 224, 0.7); }

.tally {
  margin-left: 2px;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0;
}

/* Both lists share one place, so the legend keeps its size whichever is showing */
.panels { display: grid; }
.panels > .panel { grid-area: 1 / 1; }
.panels > .panel[hidden] { display: block; visibility: hidden; }

.legend .count {
  margin: 16px 0 18px;
  font-size: 34px;
  line-height: 1.1;
}

/* Who is here, in the order she noticed them */
.register {
  margin: 0;
  padding: 0;
  list-style: none;
}

.register li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  padding: 9px 0;
  border-top: 1px solid var(--rule);
  font-size: 16px;
  line-height: 1.3;
}

.register .who { display: grid; }

.register small,
.register .numeral {
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
}

.register .numeral { padding-top: 2px; }

.ring-glyph {
  display: block;
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border: 1px solid var(--cream);
  border-radius: 50%;
}

.register li[data-visitor]:hover .who > span { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.register .more {
  display: block;
  font-style: italic;
  font-size: 15px;
  color: var(--muted);
}

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

.gazetteer li { border-top: 1px solid var(--rule); }

.gazetteer button {
  display: grid;
  width: 100%;
  padding: 9px 0;
  border: 0;
  background: none;
  color: var(--cream);
  font: inherit;
  font-size: 16px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.gazetteer small {
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
}

.gazetteer button:hover span,
.gazetteer button.chosen span { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ---------- Visas: a form, and its inevitable answer ---------- */

.office {
  display: grid;
  justify-items: center;
  padding: 40px 0 24px;
}

.application,
.decision {
  width: min(100%, 600px);
}

.form-head {
  margin-bottom: 30px;
  text-align: center;
}

.heading {
  margin: 0;
  font-weight: 400;
  font-size: clamp(34px, 5vw, 46px);
  line-height: 1.1;
}

.form-meta,
.decision .eyebrow { font-variant-numeric: lining-nums; }

.form-meta {
  margin: 12px 0 0;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-note {
  max-width: 30em;
  margin: 14px auto 0;
  font-style: italic;
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted);
}

.field {
  min-width: 0;
  margin: 0;
  padding: 18px 0 22px;
  border: 0;
  border-top: 1px solid var(--rule);
}

.field legend {
  float: left;
  width: 100%;
  margin-bottom: 14px;
  padding: 0;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.line {
  width: 100%;
  padding: 4px 0 8px;
  border: 0;
  border-bottom: 1px solid rgba(203, 207, 200, 0.4);
  border-radius: 0;
  background: none;
  color: var(--cream);
  font: inherit;
  font-style: italic;
  font-size: 22px;
  outline: none;
  transition: border-color 0.3s ease;
}

.line::placeholder { color: rgba(203, 207, 200, 0.38); }
.line:focus { border-bottom-color: rgba(243, 236, 224, 0.85); }

.choices {
  clear: both;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
}

.choices.stacked { grid-template-columns: minmax(0, 1fr); }

.choice {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 18px;
  line-height: 1.35;
  cursor: pointer;
}

/* Small engraved rings and squares, filled with a dot when chosen */
.choice input {
  flex: none;
  position: relative;
  top: 1px;
  width: 13px;
  height: 13px;
  margin: 0;
  border: 1px solid rgba(203, 207, 200, 0.6);
  border-radius: 50%;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.choice.tick input { border-radius: 0; }

.choice input:checked {
  border-color: var(--cream);
  background: var(--cream);
  box-shadow: inset 0 0 0 2.5px var(--night);
}

.choice input:focus-visible { outline-offset: 4px; }
.choice:hover input { border-color: var(--cream); }

.form-foot {
  display: grid;
  justify-items: center;
  padding-top: 26px;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.form-foot .btn,
.decision .btn {
  background: none;
  color: var(--cream);
  font-family: inherit;
  cursor: pointer;
}

/* The decision: her answer in an engraved cartouche, with the reason beneath */
.decision {
  display: grid;
  justify-items: center;
  padding-top: 20px;
  text-align: center;
  outline: none;
}

.decision[hidden] { display: none; }

.cartouche {
  display: grid;
  place-items: center;
  width: min(100%, 380px);
  margin: 22px 0 26px;
}

.cartouche > * { grid-area: 1 / 1; }

.cartouche svg {
  width: 100%;
  fill: none;
  stroke: var(--cream);
  stroke-width: 1.1;
  overflow: visible;
}

.cartouche .thin {
  stroke-width: 0.6;
  stroke-opacity: 0.6;
}

.verdict {
  margin: 0;
  padding-left: 0.4em;
  font-weight: 400;
  font-size: clamp(26px, 4.4vw, 34px);
  letter-spacing: 0.4em;
  text-transform: uppercase;
}

.dear {
  margin: 0;
  font-style: italic;
  font-size: 19px;
  color: var(--muted);
}

.reason {
  max-width: 24em;
  margin: 10px 0 0;
  font-size: clamp(22px, 3vw, 27px);
  line-height: 1.4;
  text-wrap: balance;
}

.signed {
  display: grid;
  justify-items: center;
  gap: 2px;
  margin: 26px 0 34px;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.sign {
  font-family: var(--script);
  font-weight: 400;
  font-size: 34px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cream);
}

/* ---------- The Sorting: five questions and a foregone conclusion ---------- */

.sorting {
  display: grid;
  place-items: center;
  padding: 40px 0 24px;
}

.stage {
  display: grid;
  justify-items: center;
  width: min(100%, 640px);
  text-align: center;
  outline: none;
}

.stage[hidden] { display: none; }

.houses {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  margin: 34px 0 36px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  list-style: none;
}

.houses li {
  display: grid;
  gap: 4px;
  padding: 0 12px;
}

.houses li + li { border-left: 1px solid var(--rule); }
.houses span { font-size: 19px; }

.houses small {
  font-style: italic;
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
}

.sorting .btn {
  background: none;
  color: var(--cream);
  font-family: inherit;
  cursor: pointer;
}

.progress {
  margin: 0;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: lining-nums;
}

/* One hairline per question, drawn in as each is reached */
.ticks {
  display: flex;
  gap: 8px;
  margin: 14px 0 34px;
  padding: 0;
  list-style: none;
}

.ticks li {
  width: 28px;
  height: 1px;
  background: var(--rule);
  transition: background 0.6s var(--ease);
}

.ticks li.done { background: var(--cream); }

.question {
  margin: 0 0 28px;
  font-weight: 400;
  font-size: clamp(28px, 4.2vw, 38px);
  line-height: 1.2;
  text-wrap: balance;
}

.answers {
  display: grid;
  width: min(100%, 480px);
}

.answer {
  padding: 14px 8px;
  border: 0;
  border-top: 1px solid var(--rule);
  background: none;
  color: var(--cream);
  font: inherit;
  font-size: 19px;
  line-height: 1.35;
  cursor: pointer;
  transition: color 0.4s ease, opacity 0.4s ease;
}

.answer:last-child { border-bottom: 1px solid var(--rule); }
.answer:hover:not(:disabled) { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.answer:disabled { cursor: default; color: var(--muted); opacity: 0.55; }
.answer.picked { color: var(--cream); opacity: 1; font-style: italic; }

/* Her verdict on each answer, a line beneath in script */
.said {
  min-height: 1.4em;
  margin: 22px 0 0;
  font-family: var(--script);
  font-size: 28px;
  line-height: 1.4;
  opacity: 0;
  translate: 0 6px;
  transition: opacity 0.7s var(--ease), translate 0.7s var(--ease);
}

.said.shown {
  opacity: 1;
  translate: 0 0;
}

.ponder {
  width: 120px;
  margin: 10px 0 26px;
  fill: none;
  stroke: var(--cream);
  stroke-width: 0.8;
}

.ponder .thin { stroke-width: 0.5; stroke-opacity: 0.55; }

.ponder-line {
  margin: 0 0 10px;
  font-style: italic;
  font-size: clamp(20px, 2.6vw, 24px);
  color: var(--muted);
}

.seal-mark {
  width: 74px;
  height: 74px;
  margin-bottom: 22px;
}

.surprise {
  margin: 18px 0 6px;
  font-family: var(--script);
  font-size: clamp(30px, 4vw, 40px);
}

.stage .actions { margin-top: 30px; }

/* ---------- Drawing in ----------
   Hidden only when scripts run; .ready is added once the type has loaded. */

.js .draw {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}

.js .appear,
.js .rise { opacity: 0; }

.ready .draw { animation: draw var(--t, 1.2s) var(--ease) var(--d, 0s) forwards; }
.ready .appear { animation: appear var(--t, 0.5s) ease var(--d, 0s) forwards; }
.ready .rise { animation: rise 1.2s var(--ease-out) var(--d, 0s) forwards; }

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

@keyframes appear {
  to { opacity: 1; }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .draw { stroke-dashoffset: 0; }
  .js .appear,
  .js .rise { opacity: 1; }
  .ready .draw,
  .ready .appear,
  .ready .rise { animation: none; }
  .remark { translate: -50% 0; }
}

@media (max-width: 900px) {
  .nav,
  .weather { display: none; }

  .bar { justify-content: center; }
  .title { font-size: 11vw; letter-spacing: 0.24em; padding-left: 0.24em; }
  .eyebrow { max-width: 22em; letter-spacing: 0.24em; line-height: 1.7; }
  .lede { font-size: 19px; }
  .facts { grid-template-columns: 1fr; gap: 12px; }
  .facts > div + div { border-left: 0; }

  /* The map keeps a readable scale and scrolls sideways; cards sit along the bottom */
  .map-view { grid-template-columns: minmax(0, 1fr); gap: 24px; align-content: start; }
  .plate { height: min(58svh, 500px); max-height: none; }

  .remark { top: 12px; max-width: calc(100% - 32px); }

  .office,
  .sorting { padding-top: 28px; }
  .houses { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 0; }
  .houses li:nth-child(3) { border-left: 0; }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .remark-words { font-size: 26px; }

  .card {
    position: fixed;
    left: 16px !important;
    right: 16px;
    top: auto !important;
    bottom: 16px;
    width: auto;
  }
}
