:root {
  --bg: #121314;
  --bg-2: #1b1c1f;
  --bg-3: #24262a;
  --ink: #ebe8e1;
  --ink-2: #b8b5ad;
  --line: #3a3c41;
  --mesh: #a5aab0;
  --x: #e2805a;
  --y: #aac56e;
  --z: #93a9db;
  --stone: #4a463f;
  --plaster: #d9d5cc;
  --steel: #2a2b2e;
  --wood: #6b4f3e;
  --header-h: 56px;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --step-0: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --step-1: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
  --step-2: clamp(1.75rem, 1.4rem + 1.6vw, 2.75rem);
  --step-3: clamp(2.5rem, 1.8rem + 3.4vw, 4.75rem);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 8px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--mesh); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--z); outline-offset: 3px; border-radius: 2px; }
i.ax { font-style: normal; font-family: var(--mono); font-weight: 600; }
.ax-x { color: var(--x); }
.ax-y { color: var(--y); }
.ax-z { color: var(--z); }

.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 4px; }
.skip:focus { top: 12px; }

/* Header */
.top {
  position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  background: var(--bg);
  border-block-end: 1px solid var(--line);
}
.mark { display: inline-flex; align-items: center; min-height: 44px; font: 300 1.25rem/1 var(--sans); letter-spacing: 0.04em; text-decoration: none; white-space: nowrap; }
.mark b { font-weight: 600; letter-spacing: 0.12em; }
.mark .dot { color: var(--ink-2); }
.mark i.ax { font-size: 0.85em; }
.top nav ul { display: flex; gap: 0; list-style: none; margin: 0; padding: 0; }
.top nav a {
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; justify-content: center;
  padding: 0 10px; font-size: 0.875rem; text-decoration: none; color: var(--ink-2); border-radius: 4px;
}
.top nav a:hover, .top nav a[aria-current="true"] { color: var(--ink); background: var(--bg-3); }

/* Layout: sticky model beside the story */
.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.stage {
  position: sticky; top: 0; height: 100vh; height: 100svh;
  border-inline-end: 1px solid var(--line);
  background: radial-gradient(120% 80% at 40% 40%, #1c1e21 0%, var(--bg) 70%);
  overflow: hidden;
}
#model { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
#model.dragging { cursor: grabbing; }
.readout {
  position: absolute; inset-inline-start: 20px; inset-block-start: calc(var(--header-h) + 16px);
  display: flex; flex-direction: column; gap: 2px;
  font: 500 0.8125rem/1.4 var(--mono); color: var(--ink-2); pointer-events: none;
}
#ro-name { color: var(--ink); }
.views { position: absolute; inset-inline-start: 20px; inset-block-end: 20px; display: flex; gap: 6px; }
.views button {
  min-width: 44px; min-height: 44px; padding: 0 12px;
  font: 600 0.875rem/1 var(--mono); color: var(--ink-2);
  background: rgb(36 38 42 / 0.9); border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.views button:hover { color: var(--ink); border-color: var(--mesh); }
.views button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.views .dusk { margin-inline-start: 10px; letter-spacing: 0.04em; display: inline-flex; align-items: center; gap: 6px; }
.views .dusk .l-day, .views .dusk .l-dusk { text-underline-offset: 5px; text-decoration-thickness: 2px; }
.views .dusk[aria-pressed="false"] .l-day { color: var(--ink); text-decoration-line: underline; }
.views .dusk[aria-pressed="true"] { border-color: #f7c480; }
.views .dusk[aria-pressed="true"] .l-dusk { color: #f7c480; text-decoration-line: underline; }
/* The hint sits above the view buttons and never takes a click (on a narrow stage it used to cover the day / dusk switch). */
.hint { position: absolute; inset-inline-start: 20px; inset-block-end: 74px; margin: 0; font: 0.75rem/1.3 var(--mono); color: var(--ink-2); pointer-events: none; }
.hint .h-touch { display: none; }
@media (hover: none) { .hint .h-fine { display: none; } .hint .h-touch { display: inline; } }

.story { padding-block-start: var(--header-h); }
.chapter {
  min-height: 92vh; min-height: 92svh;
  padding: clamp(40px, 8vh, 96px) clamp(20px, 4vw, 64px);
  border-block-end: 1px solid var(--line);
  max-width: 44rem;
}
.kicker { margin: 0 0 12px; font: 600 0.8125rem/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
h1, h2, h3 { font-family: var(--sans); line-height: 1.1; margin: 0 0 20px; }
h1 { font-size: var(--step-3); font-weight: 300; letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); font-weight: 300; }
h3 { font-size: var(--step-1); font-weight: 500; margin-block: 32px 12px; }
p { margin: 0 0 16px; color: var(--ink); }
.lede { font-size: var(--step-1); line-height: 1.45; color: var(--ink); font-weight: 300; }
q { quotes: "“" "”"; }
.small { font-size: 0.875rem; color: var(--ink-2); }
.scroll-cue { margin-block-start: 48px; font: 0.8125rem/1 var(--mono); color: var(--ink-2); }

blockquote { margin: 28px 0; padding-inline-start: 20px; border-inline-start: 2px solid var(--mesh); }
blockquote p { font-size: var(--step-1); font-weight: 300; line-height: 1.4; margin-bottom: 8px; }
blockquote footer { font: 0.8125rem/1.4 var(--mono); color: var(--ink-2); }

.boxes { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 18px; }
.boxes li { display: grid; grid-template-columns: 3.2rem 1fr; gap: 12px; align-items: start; }
.boxes .n { font: 600 1.4rem/1 var(--mono); color: var(--mesh); padding-top: 6px; }
.boxes h3 { margin: 0 0 6px; }
.boxes p { margin: 0; color: var(--ink-2); }
.boxes h3 a { text-decoration: none; }
.boxes h3 a::after { content: " →"; color: var(--ink-2); font-size: 0.8em; }
.boxes h3 a:hover { text-decoration: underline; }
.swatches { margin: 28px 0 0; }
/* columns sized in rem so they widen with the text size (fixed quarters clipped "Caesarstone" at 200% text) */
.swatches ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 12px; }
.swatches li { font-size: 0.8125rem; color: var(--ink-2); line-height: 1.3; }
.swatches li span { display: block; height: 56px; border-radius: 4px; border: 1px solid var(--line); margin-bottom: 6px; }
.swatches figcaption { margin-top: 10px; font-size: 0.8125rem; color: var(--ink-2); }
@media (max-width: 560px) { .swatches ul { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); } }

.materials { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 10px; }
.materials li { display: flex; align-items: center; gap: 12px; color: var(--ink-2); }
.sw { width: 28px; height: 18px; border-radius: 3px; border: 1px solid var(--line); flex: none; }
.sw-stone { background: var(--stone); }
.sw-plaster { background: var(--plaster); }
.sw-steel { background: var(--steel); }
.sw-mesh { background: repeating-linear-gradient(45deg, #8d9298 0 2px, #2a2b2e 2px 5px); }
.sw-wood { background: var(--wood); }

.strata { margin: 24px 0; display: grid; gap: 0; }
.strata div { padding: 14px 0; border-block-start: 1px solid var(--line); }
.strata dt { font-weight: 500; }
.strata .lvl { display: inline-block; min-width: 6.5rem; font: 600 0.875rem/1 var(--mono); color: var(--z); }
.strata dd { margin: 6px 0 0 6.5rem; color: var(--ink-2); }

.cracks { margin: 28px 0 0; }
.cracks canvas { width: 100%; height: auto; aspect-ratio: 16 / 9; display: block; background: #1a1714; border: 1px solid var(--line); border-radius: 6px; }
.cracks figcaption { margin-top: 10px; font-size: 0.875rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cracks button {
  min-height: 40px; padding: 0 14px; font: 600 0.8125rem/1 var(--mono); color: var(--ink);
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.cracks button:hover { border-color: var(--mesh); }

.ticks { padding: 0; margin: 16px 0; list-style: none; display: grid; gap: 12px; }
.ticks li { padding-inline-start: 18px; position: relative; color: var(--ink-2); }
.ticks li::before { content: ""; position: absolute; inset-inline-start: 0; top: 0.7em; width: 8px; height: 2px; background: var(--z); }
.ticks b { color: var(--ink); font-weight: 600; }

.coords { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 8px 0 20px; }
.coords div { background: var(--bg); padding: 16px; }
.coords dt { font: 600 0.75rem/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.coords dd { margin: 6px 0 0; font: 300 var(--step-1)/1.1 var(--sans); }

.credits { display: grid; gap: 12px; margin: 0; }
.credits dt { font: 600 0.75rem/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.credits dd { margin: 2px 0 0; }
.plain { padding-inline-start: 20px; color: var(--ink-2); }
.plain li { margin-bottom: 6px; }
.press { list-style: none; padding: 0; margin: 0 0 16px; columns: 2; column-gap: 24px; }
.press li { break-inside: avoid; padding: 6px 0; }
.press a { display: inline-block; min-height: 24px; }
.press span { font: 0.75rem/1 var(--mono); color: var(--ink-2); margin-inline-start: 6px; }

.foot {
  padding: 40px max(20px, env(safe-area-inset-left)) calc(40px + env(safe-area-inset-bottom));
  border-block-start: 1px solid var(--line); text-align: center; color: var(--ink-2);
}
.foot p { color: var(--ink-2); margin-bottom: 8px; }

/* Tablet and phone: the model stays pinned at the top while the story scrolls under it */
@media (max-width: 960px) {
  .layout { display: block; }
  .stage {
    position: sticky; top: var(--header-h); z-index: 5;
    height: 42vh; height: 42svh;
    border-inline-end: 0; border-block-end: 1px solid var(--line);
  }
  .story { padding-block-start: 0; }
  .chapter { min-height: 0; max-width: none; padding-block: 40px 56px; }
  .readout { inset-block-start: 12px; inset-inline-start: 14px; font-size: 0.75rem; }
  .views { inset-inline-start: 12px; inset-block-end: 10px; }
  .hint { display: none; }
  .layout { padding-block-start: var(--header-h); }
  html { scroll-padding-top: calc(var(--header-h) + 42vh + 8px); scroll-padding-top: calc(var(--header-h) + 42svh + 8px); }
}
@media (max-width: 560px) {
  .top nav li:nth-child(1), .top nav li:nth-child(8) { display: none; }
  .top nav a { padding: 0 4px; min-width: 36px; }
  .top { gap: 8px; padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .mark { font-size: 0.95rem; }
  .coords dd { font-size: 1.2rem; }
  .press { columns: 1; }
  .strata dd { margin-inline-start: 0; }
}

/* Easter eggs: the maps of Red Rock Canyon and the Strip */
.egg-back {
  position: absolute; inset-inline-start: 20px; inset-block-end: 20px; z-index: 3; min-height: 44px; padding: 0 14px;
  font: 600 0.875rem/1 var(--mono); color: var(--ink); background: rgb(36 38 42 / 0.92); border: 1px solid var(--ink); border-radius: 6px; cursor: pointer;
}
.egg-back[hidden] { display: none; }
.stage.in-map .views [data-goto], .stage.in-map .hint { display: none; }
.stage.in-map .views { inset-inline-start: auto; inset-inline-end: 20px; }
.stage.in-map canvas { cursor: grab; }
/* keyboard and screen-reader route to the maps: out of sight until focused, like the skip link */
.egg-go button { position: absolute; inset-inline-start: 20px; inset-block-end: 74px; z-index: 4; transform: translateY(200vh); min-height: 44px; padding: 0 14px;
  font: 600 0.875rem/1 var(--mono); color: var(--bg); background: var(--ink); border: 0; border-radius: 6px; }
.egg-go button:focus-visible { transform: none; }
.stage.in-map .egg-go { display: none; }
@media (max-width: 960px) { .stage.in-map { height: 62vh; height: 62svh; } .egg-back { inset-inline-start: 12px; inset-block-end: 10px; } .stage.in-map .views { inset-inline-end: 12px; } .egg-go button { inset-inline-start: 12px; inset-block-end: 64px; } }
/* The map's own controls: turn left, turn right, plan or 3D (stacked at the right edge, above the credit band) */
.mapctls { display: none; position: absolute; inset-inline-end: 12px; inset-block-end: 112px; z-index: 3; flex-direction: column; gap: 6px; }
.stage.in-map .mapctls { display: flex; }
.mapctls button { min-width: 44px; min-height: 44px; padding: 0 10px; font: 600 0.95rem/1 var(--mono); color: var(--ink); background: rgb(36 38 42 / 0.92); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.mapctls button:hover { border-color: var(--mesh); }
.mapctls button[aria-pressed="true"] { border-color: var(--ink); }
/* The map panel takes the story column while a map is open */
.map-panel { position: fixed; z-index: 15; inset-block: var(--header-h) 0; inset-inline-end: 0; width: calc(100vw / 2.25); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-inline-start: 1px solid var(--line); padding: clamp(32px, 6vh, 72px) clamp(20px, 4vw, 64px) 48px; }
.map-panel[hidden], .map-panel section[hidden] { display: none; }
.map-panel h2:focus { outline: none; }
.map-panel .places { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }
.map-panel .places li { display: grid; gap: 4px; justify-items: start; }
.map-panel .places span { font-size: 0.9375rem; line-height: 1.45; color: var(--ink-2); }
.map-panel .places button { min-height: 40px; padding: 0 12px; font: 500 0.875rem/1.2 var(--sans); color: var(--ink); background: var(--bg-3); border: 1px solid var(--line); border-radius: 20px; cursor: pointer; }
.map-panel .places button:hover { border-color: var(--mesh); }
.map-panel .panel-back { min-height: 44px; padding: 0 14px; font: 600 0.875rem/1 var(--mono); color: var(--ink); background: transparent; border: 1px solid var(--ink); border-radius: 6px; cursor: pointer; }
.map-panel dl { margin: 0 0 20px; }
.map-panel dt { font-weight: 600; margin-top: 12px; }
.map-panel dd { margin: 4px 0 0; color: var(--ink-2); }
@media (max-width: 960px) {
  .map-panel { width: auto; inset-inline: 0; inset-block-start: calc(var(--header-h) + 62vh); inset-block-start: calc(var(--header-h) + 62svh); border-inline-start: 0; border-block-start: 1px solid var(--line); padding: 20px 16px 32px; }
  .mapctls { inset-block-end: 104px; }
}
/* Landscape phones: keep text and controls clear of the notch and the home indicator. */
@supports (padding: max(0px)) {
  .chapter { padding-inline: max(clamp(20px, 4vw, 64px), env(safe-area-inset-left)) max(clamp(20px, 4vw, 64px), env(safe-area-inset-right)); }
  @media (max-width: 960px) {
    .views { inset-inline-start: max(12px, env(safe-area-inset-left)); }
    .readout { inset-inline-start: max(14px, env(safe-area-inset-left)); }
  }
}
/* The narrowest phones (320 to 359 px): the x, y and z chapters stay one tap away on the model's own buttons. */
@media (max-width: 359px) {
  .top nav li:nth-child(5), .top nav li:nth-child(6), .top nav li:nth-child(7) { display: none; }
  .views { gap: 4px; }
  .views button { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
