/* Beneath the Perfect Cone — journey, crystal and evidence surfaces.
   Shares the site's gold-on-ink palette; adds only what the descent needs.
   Layout rule for all three: one sheet at a time, never over the tab bar, and
   on a phone the sheet docks to the bottom edge above the safe area. */

:root {
  --beneath-sheet: rgba(9, 11, 18, 0.9);
  --beneath-edge: rgba(232, 184, 75, 0.3);
  --beneath-text: #ddd5c0;
  --beneath-minerals: #f2d789;
  --beneath-geophysics: #8fd0e8;
  --sheet-bottom: calc(var(--bar-h, 64px) + max(18px, env(safe-area-inset-bottom)) + 12px);
}

/* ---- sheets --------------------------------------------------------------- */

.sheet {
  position: fixed; z-index: 32;
  left: max(24px, env(safe-area-inset-left));
  bottom: var(--sheet-bottom);
  width: min(370px, calc(100vw - 48px));
  max-height: calc(100vh - var(--sheet-bottom) - var(--title-bottom, 90px) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 20px 16px;
  border: 1px solid var(--beneath-edge); border-radius: 16px;
  background: var(--beneath-sheet); backdrop-filter: blur(16px);
  color: var(--beneath-text); font-size: 13px; line-height: 1.55;
}
.sheet[hidden] { display: none; }
.sheet .sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sheet .badge {
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: #0a0d14; background: var(--gold-soft);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.sheet .kicker { color: var(--gold); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; }
.sheet h2 { color: #f1dfae; font-weight: 400; font-size: 20px; letter-spacing: 0.05em; margin: 6px 0 0; }
.sheet h2:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 4px; }
.sheet .rule { height: 1px; background: linear-gradient(90deg, var(--gold), transparent); margin: 10px 0 12px; }
.sheet .copy { margin: 0 0 12px; }
.sheet .row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
/* Back/Next stay reachable however long the copy runs: the sheet scrolls, the
   navigation does not scroll away with it. The strip is opaque, not a fade —
   a translucent one let the copy show through from underneath, which reads as
   two lines of text printed over each other. */
.sheet .nav-row {
  justify-content: space-between; margin-bottom: 0;
  position: sticky; bottom: -17px; z-index: 1;
  padding: 9px 0 8px;
  background: #0a0d15;
  border-top: 1px solid rgba(232, 184, 75, 0.12);
  /* A long station is scrollable, and the line the scroll happens to cut
     should fade under the strip rather than end mid-stroke. */
  box-shadow: 0 -22px 20px -6px #0a0d15;
}
.sheet .secondary-row { gap: 14px; }
.sheet .fine { font-size: 10.5px; color: #9a927f; margin: 8px 0 0; }
.sheet .result { margin: 2px 0 8px; color: var(--gold-soft); min-height: 1.2em; }
.sheet .result:empty { min-height: 0; }
.sheet .travelling { color: #9a927f; margin: 4px 0 10px; }
.sheet .chip.primary { background: rgba(232, 184, 75, 0.18); border-color: var(--gold); color: var(--gold-soft); }
.sheet .chip.action.on { background: rgba(232, 184, 75, 0.1); }
/* Unavailable controls look unavailable, wherever they are. This was scoped to
   .sheet, so the crystal dialog's gated Next rendered identical to a live
   button: pressing it did nothing and read as broken. */
.chip:disabled, .chip[aria-disabled='true'] { opacity: 0.35; cursor: default; }
.chip:disabled:hover, .chip[aria-disabled='true']:hover {
  border-color: rgba(232, 184, 75, 0.28); color: var(--beneath-text);
}
/* The reason the step is waiting, beside the control that is waiting. */
.step-gate { margin: 0 0 10px; font-size: 11.5px; color: #9a927f; font-style: italic; }
.step-gate:empty { margin: 0; }

.text-button, .link-button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--gold-soft); font-size: 11.5px; letter-spacing: 0.06em;
  text-decoration: underline; text-underline-offset: 3px;
}
.text-button:hover, .link-button:hover { color: var(--gold); }

.sheet .detail { margin-top: 10px; border-top: 1px solid rgba(232, 184, 75, 0.16); padding-top: 8px; }
.sheet .detail summary { cursor: pointer; color: var(--gold-soft); font-size: 11.5px; letter-spacing: 0.08em; }
.sheet .detail p { margin: 8px 0; font-size: 12.5px; }

.depth-readout { list-style: none; margin: 0 0 10px; padding: 0; font-size: 12px; }
.depth-readout li { padding-left: 14px; position: relative; color: #cfc6ae; }
.depth-readout li::before { content: '▾'; position: absolute; left: 0; color: var(--gold); font-size: 9px; top: 4px; }

/* Station progress: real buttons, labelled for a screen reader. */
.station-dots { list-style: none; display: flex; gap: 8px; margin: 0 0 12px; padding: 0; }
.station-dots .dot {
  width: 22px; height: 6px; padding: 0; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(232, 184, 75, 0.4); background: none;
}
.station-dots .dot.visited { background: rgba(232, 184, 75, 0.35); }
.station-dots .dot[aria-current='step'] { background: var(--gold); border-color: var(--gold); }

.intro-card { z-index: 34; }
.intro-points { margin: 0 0 14px; padding-left: 18px; }
.intro-points li { margin-bottom: 7px; }

/* ---- labels over the scene ------------------------------------------------ */

#beneath-labels { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
.beneath-label {
  position: absolute; top: 0; left: 0;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  font-size: 10.5px; letter-spacing: 0.06em;
  background: rgba(9, 11, 18, 0.74); border: 1px solid var(--beneath-edge);
  color: var(--beneath-text); transition: opacity 0.25s ease;
}
.beneath-label[data-kind='minerals'] { border-color: var(--beneath-minerals); color: var(--beneath-minerals); }
.beneath-label[data-kind='geophysics'] { border-color: var(--beneath-geophysics); color: var(--beneath-geophysics); }
.beneath-label[data-kind='dashed'] { border-style: dashed; }
.beneath-label[data-kind='fade'] { opacity: 0.75; font-style: italic; }

/* ---- modal dialogs (evidence, crystal) ------------------------------------ */

.evidence-scrim, .crystal-scrim {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(4, 5, 9, 0.72); backdrop-filter: blur(3px);
}
.evidence-scrim[hidden], .crystal-scrim[hidden] { display: none; }

.evidence-dialog, .crystal-dialog {
  width: min(560px, 100%); max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 22px 18px;
  border: 1px solid var(--beneath-edge); border-radius: 18px;
  background: rgba(9, 11, 18, 0.96);
  color: var(--beneath-text); font-size: 13px; line-height: 1.6;
}
.crystal-dialog { width: min(680px, 100%); }
.evidence-head, .crystal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.evidence-head .kicker, .crystal-head .kicker { color: var(--gold); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; }
.icon-button {
  background: none; border: 1px solid var(--beneath-edge); color: var(--beneath-text);
  width: 30px; height: 30px; border-radius: 999px; cursor: pointer; font-size: 15px; line-height: 1;
}
.icon-button:hover { border-color: var(--gold); color: var(--gold-soft); }
.evidence-dialog h2, .crystal-dialog h2 { color: #f1dfae; font-weight: 400; font-size: 21px; letter-spacing: 0.04em; margin: 8px 0 0; }
.evidence-dialog h2:focus-visible, .crystal-dialog h2:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 4px; }
.evidence-dialog .rule, .crystal-dialog .rule { height: 1px; background: linear-gradient(90deg, var(--gold), transparent); margin: 10px 0 14px; }

/* The four parts always appear in the same order and the same colours, so the
   difference between an observation and an inference is visible at a glance. */
.evidence-part { border-left: 2px solid; padding: 2px 0 2px 12px; margin-bottom: 12px; }
.evidence-part h3 { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; margin: 0 0 4px; font-weight: 500; }
.evidence-part p { margin: 0; }
.evidence-observed { border-color: #8fd0e8; } .evidence-observed h3 { color: #8fd0e8; }
.evidence-inferred { border-color: var(--gold); } .evidence-inferred h3 { color: var(--gold); }
.evidence-illustrated { border-color: #c79bd8; } .evidence-illustrated h3 { color: #c79bd8; }
.evidence-uncertain { border-color: #9a927f; } .evidence-uncertain h3 { color: #9a927f; }

.evidence-depths { margin: 14px 0; }
.evidence-depths h3 { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-soft); margin: 0 0 6px; }
.evidence-depths ul { list-style: none; margin: 0; padding: 0; }
.evidence-depths li { margin-bottom: 8px; font-size: 12.5px; }
.evidence-depths li b { display: block; color: #f1dfae; font-weight: 400; }
.evidence-depths li span { color: #9a927f; }
.evidence-sources { margin-top: 12px; }
.evidence-sources summary { cursor: pointer; color: var(--gold-soft); font-size: 11.5px; letter-spacing: 0.08em; }
.source-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12px; }
.source-list li { margin-bottom: 8px; }
.source-list a { color: var(--gold-soft); }
.source-list .locator { display: block; color: #9a927f; font-size: 11px; }
.evidence-index { list-style: none; margin: 6px 0 14px; padding: 0; }
.evidence-index li { margin-bottom: 6px; }
.evidence-intro, .evidence-more { font-size: 12px; color: #9a927f; }
.evidence-more a { color: var(--gold-soft); }
.evidence-scope { margin: 14px 0 0; font-size: 11px; color: #9a927f; border-top: 1px solid rgba(232, 184, 75, 0.16); padding-top: 10px; }
body.evidence-open .sheet { filter: brightness(0.7); }

/* ---- Follow a Crystal ------------------------------------------------------ */

.crystal-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 12px; }
.crystal-figure { margin: 0; }
.crystal-figure > svg { width: 100%; height: auto; display: block; border-radius: 12px; }
.crystal-figure .profile { margin-top: 10px; background: none; }
.illustration-label { font-size: 10.5px; color: #9a927f; margin: 6px 0 0; font-style: italic; }

/* The specimen and the thin section share one frame: zooming out swaps them. */
.specimen, .thin-section { transition: opacity 0.4s ease; }
#crystal[data-zoomed='false'] .thin-section { opacity: 0; }
#crystal[data-zoomed='true'] .specimen { opacity: 0; pointer-events: none; }
#crystal[data-reduced='true'] .specimen, #crystal[data-reduced='true'] .thin-section { transition: none; }

.figure-bg { fill: #141821; }
.specimen-outline { fill: #272c37; stroke: #6f6552; stroke-width: 1.5; stroke-dasharray: 6 5; }
.zone { stroke: #6f6552; stroke-width: 1.5; transition: opacity 0.35s ease, fill 0.35s ease; }
.zone-rim { fill: #7d7159; }
.zone-mantle { fill: #a2977c; }
.zone-core { fill: #cabf9f; }
.zone-hatch { stroke: none; pointer-events: none; }
/* Zones appear one at a time as they are revealed; the hatch and the labels
   follow the zone they belong to, so nothing is carried by colour alone. */
#crystal:not(.show-rim) .zone-rim, #crystal:not(.show-rim) .zone-hatch, #crystal:not(.show-rim) .label-rim,
#crystal:not(.show-mantle) .zone-mantle, #crystal:not(.show-mantle) .label-mantle,
#crystal:not(.show-core) .zone-core, #crystal:not(.show-core) .label-core { opacity: 0; }
.zone-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; fill: #1b1a14; text-anchor: middle; transition: opacity 0.35s ease; }
.label-rim { fill: #e7dcc2; }

.clue-ring { fill: none; stroke: var(--gold); stroke-width: 3; stroke-dasharray: 10 7; opacity: 0; }
#crystal.clue-found .clue-ring { opacity: 1; }
#crystal.clue-found .zone-rim { fill: #8d7d5f; }

.field-crystal { fill: #5d6474; stroke: #767f92; stroke-width: 0.8; }
.cluster-crystal { fill: #7b8395; stroke: #a7b0c4; stroke-width: 1; }
#crystal[data-step='rock'][data-zoomed='true'] .cluster .cluster-crystal { stroke: var(--gold); stroke-width: 1.6; }

.profile .axis { stroke: #6b6452; stroke-width: 1.2; }
.profile .axis-label { font-size: 9px; fill: #9a927f; letter-spacing: 0.08em; }
.profile .profile-line { fill: none; stroke: var(--gold); stroke-width: 2; }

.crystal-text .kicker { color: var(--gold); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; }
.crystal-text h2 { color: #f1dfae; font-weight: 400; font-size: 20px; letter-spacing: 0.04em; margin: 6px 0 0; }
.crystal-text .copy { margin: 0 0 12px; }
.step-controls { margin-bottom: 8px; }
.step-controls .chip { margin-bottom: 8px; }
.zone-notes { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; }
.zone-notes li { padding-left: 14px; position: relative; margin-bottom: 7px; }
.zone-notes li::before { content: '▸'; position: absolute; left: 0; color: var(--gold); font-size: 10px; top: 3px; }
.zone-notes b { color: #f1dfae; font-weight: 400; }

.choices { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.choices legend { padding: 0; margin-bottom: 8px; color: #f1dfae; font-size: 13px; }
.choice {
  text-align: left; cursor: pointer; padding: 9px 12px; border-radius: 12px;
  background: none; border: 1px solid rgba(232, 184, 75, 0.28); color: var(--beneath-text);
  font-size: 12.5px; line-height: 1.45;
}
.choice:hover { border-color: var(--gold); color: var(--gold-soft); }
.choice.on { border-color: var(--gold); background: rgba(232, 184, 75, 0.12); color: var(--gold-soft); }

.slider-label { display: block; font-size: 11.5px; color: var(--gold-soft); letter-spacing: 0.06em; margin-bottom: 6px; }
#crystal-blur { width: 100%; accent-color: var(--gold); }
.slider-ends { display: flex; justify-content: space-between; gap: 10px; font-size: 10.5px; color: #9a927f; margin: 4px 0 8px; }
.summary-list { list-style: none; margin: 0 0 12px; padding: 0; }
.summary-list li { padding-left: 16px; position: relative; margin-bottom: 8px; }
.summary-list li::before { content: '△'; position: absolute; left: 0; color: var(--gold); font-size: 10px; top: 4px; }

.observation { margin: 10px 0 12px; }
.observation[hidden] { display: none; }
.observation summary { cursor: pointer; color: var(--gold-soft); font-size: 11.5px; letter-spacing: 0.08em; }
.observation img { width: 100%; height: auto; margin-top: 10px; border-radius: 10px; }
.observation p { font-size: 12px; margin: 8px 0 0; }
.crystal-text .scope { border-top: 1px solid rgba(232, 184, 75, 0.16); padding-top: 8px; margin-top: 10px; }
.crystal-dialog .nav-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.crystal-dialog [hidden] { display: none; }

/* ---- focus, motion and small screens -------------------------------------- */

.sheet button:focus-visible, .sheet summary:focus-visible, .sheet a:focus-visible,
.evidence-dialog button:focus-visible, .evidence-dialog summary:focus-visible, .evidence-dialog a:focus-visible,
.crystal-dialog button:focus-visible, .crystal-dialog summary:focus-visible,
.crystal-dialog a:focus-visible, .crystal-dialog input:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px;
}

@media (max-width: 720px) {
  /* Phones: the sheet becomes a bottom drawer the full width of the screen. */
  .sheet {
    left: 0; right: 0; width: auto; border-radius: 16px 16px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    /* Flush on top of the bar, which sits its own 18px (or the safe area)
       above the bottom edge — otherwise the drawer laps over the controls. */
    bottom: calc(var(--bar-h, 64px) + max(18px, env(safe-area-inset-bottom)));
    /* Leave the mountain at least a third of a phone screen: the sheet scrolls
       inside itself rather than growing to fit its longest station. */
    max-height: min(46vh, calc(100vh - var(--bar-h, 64px) - 120px));
    padding: 14px 16px calc(12px + env(safe-area-inset-bottom));
  }
  .sheet h2 { font-size: 18px; }
  .crystal-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .evidence-dialog, .crystal-dialog { padding: 16px 16px 14px; }
}

/* Landscape phones are short: keep the sheet a side panel, never a drawer that
   eats the view. */
@media (max-height: 460px) and (orientation: landscape) {
  /* Above the bar, not over it: on a screen this short the two cannot share
     the bottom edge. */
  .sheet {
    left: max(12px, env(safe-area-inset-left)); right: auto;
    width: min(330px, 46vw); border-radius: 14px; border: 1px solid var(--beneath-edge);
    bottom: calc(var(--bar-h, 64px) + max(12px, env(safe-area-inset-bottom)) + 8px);
    max-height: calc(100vh - var(--bar-h, 64px) - 30px);
    padding: 12px 14px 10px;
  }
  .sheet h2 { font-size: 17px; }
  .sheet .rule { margin: 8px 0 9px; }
  .evidence-scrim, .crystal-scrim { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .beneath-label { transition: none; }
  .sheet, .evidence-dialog, .crystal-dialog { transition: none; }
}

/* ---- shareable discoveries ------------------------------------------------- */
/* One striking fact per station, offered once the visitor has actually made
   the discovery — with the caveat travelling on the card itself. */
.discovery {
  margin: 4px 0 12px; padding: 10px 12px;
  border: 1px solid rgba(232, 184, 75, 0.22); border-radius: 12px;
  background: rgba(232, 184, 75, 0.06);
}
.discovery-fact { margin: 0 0 8px; color: #f1dfae; font-size: 13.5px; line-height: 1.4; }
.chip.share { font-size: 11.5px; padding: 6px 12px; }
.crystal-dialog .discovery { margin-bottom: 14px; }
.discovery-link { margin: 8px 0 0; font-size: 11px; color: #9a927f; user-select: all; letter-spacing: 0.02em; }
.discovery-link span { color: var(--gold-soft); }

/* ---- the no-WebGL path ------------------------------------------------------ */
/* Not an apology page: the same explanations, the same evidence, and the
   crystal investigation in full — it was always drawn rather than rendered. */
body.no-webgl { overflow: auto; background: #0a0d14; }
body.no-webgl #bar, body.no-webgl #title, body.no-webgl #credits { display: none; }
#fallback {
  max-width: 720px; margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
  color: var(--beneath-text); font-size: 14px; line-height: 1.6;
}
#fallback h1 { color: #f1dfae; font-weight: 300; font-size: clamp(30px, 7vw, 46px); letter-spacing: 0.22em; margin: 8px 0 12px; }
#fallback h2 { color: #f1dfae; font-weight: 400; font-size: 20px; letter-spacing: 0.04em; margin: 0 0 14px; }
#fallback h3 { color: #f1dfae; font-weight: 400; font-size: 17px; margin: 4px 0 8px; }
#fallback .kicker { color: var(--gold); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; margin: 0; }
#fallback .lede { font-size: 16px; color: #e7e8e1; }
#fallback .fine { font-size: 12px; color: #9a927f; }
#fallback a { color: var(--gold-soft); }
.fallback-section { border-top: 1px solid rgba(232, 184, 75, 0.16); padding-top: 20px; margin-top: 28px; }
.fallback-station { border-left: 2px solid rgba(232, 184, 75, 0.25); padding-left: 14px; margin-bottom: 24px; }
.fallback-foot { border-top: 1px solid rgba(232, 184, 75, 0.16); margin-top: 30px; padding-top: 14px; font-size: 12px; color: #9a927f; }
