/* The pier: a full-screen scene with two choices. Tokens come from ../css/tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
body {
  overflow: hidden;
  background: var(--sky); color: var(--ink);
  font: 400 var(--step-body) / 1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ── The postcard: the pier drawn flat ───────────────────────────── */
.postcard, .scene { position: fixed; inset: 0; }
.postcard svg { width: 100%; height: 100%; display: block; }
.pc-sky { fill: var(--sky); }
.pc-far { fill: color-mix(in srgb, var(--fjord) 45%, var(--sky)); }
.pc-water { fill: var(--fjord); }
.pc-land { fill: var(--land); }
.pc-boathouse { fill: var(--flag-red); }
.pc-roof { fill: var(--ink); }
.pc-rocks { fill: color-mix(in srgb, var(--muted) 70%, var(--sky)); }
.pc-pier, .pc-post, .pc-table { fill: var(--wood); }
.pc-boat { fill: var(--paper); }
.pc-boat-top { fill: color-mix(in srgb, var(--paper) 80%, var(--ink)); }
.pc-laptop { fill: var(--ink); }

/* The 3D scene fades in over the postcard once its first frame is drawn. */
.scene { opacity: 0; transition: opacity var(--duration-page) var(--ease-out-snappy); }
.has-3d .scene { opacity: 1; }
.scene canvas { display: block; }
.scene .css3d { position: absolute; inset: 0; pointer-events: none; }

/* ── Bar ─────────────────────────────────────────────────────────── */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 2.5vw, 32px);
}
.wordmark {
  padding: 9px 12px; margin-left: -12px; text-decoration: none;
  font: 800 26px/1 var(--font-display); letter-spacing: -0.03em;
  background: color-mix(in srgb, var(--paper) 70%, transparent); border-radius: 999px;
}
.bar__actions { display: flex; gap: 8px; }
.icon-button {
  display: inline-flex; align-items: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 0 12px;
  border-radius: 999px; background: color-mix(in srgb, var(--paper) 80%, transparent);
  font-size: var(--step-small); font-weight: 600;
  transition: background-color var(--duration-fast) var(--ease-out-snappy), transform var(--duration-instant) var(--ease-out-snappy);
}
.icon-button:hover { background: var(--paper); }
.icon-button:active { transform: scale(0.97); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-button[hidden] { display: none; }
.mood__moon { display: none; }
:root[data-mood="night"] .mood__sun { display: none; }
:root[data-mood="night"] .mood__moon { display: block; }

/* ── Intro and the two choices ───────────────────────────────────── */
.intro {
  position: fixed; left: 50%; bottom: clamp(24px, 6vh, 64px); z-index: 4; translate: -50% 0;
  width: min(560px, calc(100% - 32px)); padding: 24px 28px;
  background: var(--paper); border: 4px double var(--ink); text-align: center;
}
.intro h1 { font: 800 clamp(30px, 4vw, 44px) / 1 var(--font-display); letter-spacing: -0.03em; }
.intro__lede { margin-top: 8px; color: var(--muted); }
.choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 18px; }
.choice {
  display: inline-flex; flex-direction: column; align-items: flex-start; min-height: 44px; padding: 10px 18px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; border-radius: 4px;
  transition: background-color var(--duration-fast) var(--ease-out-snappy), transform var(--duration-instant) var(--ease-out-snappy);
}
.choice:hover, .choice.is-hot { background: color-mix(in srgb, var(--accent) 84%, #000); }
.choice:active { transform: scale(0.97); }
.choice__verb { font: 700 18px/1.2 var(--font-display); }
.choice__what { font-size: var(--step-small); }
.status { margin-top: 12px; font-size: var(--step-small); color: var(--muted); }
.status:empty { display: none; }

/* With 3D running, the intro shrinks to a corner and the choices float in the scene. */
.has-3d .intro {
  left: clamp(16px, 2.5vw, 32px); bottom: clamp(16px, 3vh, 32px); translate: none;
  width: auto; max-width: 360px; padding: 16px 20px; text-align: left;
  pointer-events: none;
}
.has-3d .intro h1 { font-size: 26px; }
.has-3d .intro__lede { font-size: var(--step-small); }
.has-3d .choices { position: static; margin: 0; }
.has-3d .choice {
  position: fixed; left: 0; top: 0; pointer-events: auto;
  transform: translate(var(--x, -999px), var(--y, -999px)) translate(-50%, -100%);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.25); /* taste-skill-ignore: it floats over a 3D scene */
}
.has-3d .choice::after { /* a little pointer down to the object */
  content: ""; position: absolute; left: 50%; bottom: -8px; translate: -50% 0;
  border: 8px solid transparent; border-bottom: 0; border-top-color: var(--accent);
}
.has-3d .choice.is-offscreen, .has-3d .choice:not(.is-placed) { opacity: 0; pointer-events: none; }

/* Leaving: the scene carries the step in; everything else steps aside. */
.is-stepping .bar, .is-stepping .intro, .is-stepping .choice {
  opacity: 0; transition: opacity var(--duration-base) var(--ease-out-snappy);
}
.veil {
  position: fixed; inset: 0; z-index: 10; background: var(--paper); opacity: 0; pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-in-out-smooth);
}
.veil.is-on { opacity: 1; }

/* Standing up: the third way in, a plain outlined button with its key. */
.stand-up {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px;
  margin-top: 12px; padding: 8px 16px; border: 2px solid var(--ink); border-radius: 4px;
  font: 700 16px/1.2 var(--font-display); color: var(--ink); background: var(--paper);
  transition: background-color var(--duration-fast) var(--ease-out-snappy), transform var(--duration-instant) var(--ease-out-snappy);
}
.stand-up:hover { background: var(--shallow); }
.stand-up:active { transform: scale(0.97); }
.stand-up kbd {
  padding: 2px 7px; border-radius: 3px; background: var(--ink); color: var(--paper); font: 700 12px/1.3 var(--font-text);
}
@media (pointer: coarse) { .stand-up kbd { display: none; } }
.has-3d .stand-up { pointer-events: auto; }
.stand-up[hidden], .is-walking .stand-up { display: none; }
.walk-hint { display: none; margin-top: 8px; font-size: var(--step-small); color: var(--muted); }

/* Walking: the intro shrinks to a corner card and the two choices sit in it as buttons. */
.has-3d.is-walking .intro h1 { font-size: 20px; }
.has-3d.is-walking .intro__lede { display: none; }
.has-3d.is-walking .walk-hint { display: block; }
.has-3d.is-walking .choices { display: flex; justify-content: flex-start; margin-top: 10px; }
.has-3d.is-walking .choice {
  position: static; transform: none; box-shadow: none; opacity: 1; pointer-events: auto; padding: 8px 14px;
}
.has-3d.is-walking .choice::after { display: none; }
.has-3d.is-walking .choice__what { display: none; }

/* Mouse look: a small crosshair marks the middle of the view while it holds the pointer. */
.crosshair {
  position: fixed; left: 50%; top: 50%; z-index: 3; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 1.5px var(--ink); pointer-events: none; display: none;
}
.is-locked .crosshair { display: block; }
#look-toggle[aria-pressed="true"] { background: var(--paper); }

/* The prompt over the nearest find. */
.find-prompt {
  position: fixed; left: 0; top: 0; z-index: 4;
  transform: translate(var(--x, -999px), var(--y, -999px)) translate(-50%, -100%);
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 4px;
  font: 600 var(--step-small) / 1.2 var(--font-text);
}
.find-prompt kbd {
  min-width: 24px; padding: 2px 6px; border-radius: 3px; text-align: center;
  background: var(--accent); color: var(--accent-ink); font: 700 13px/1.2 var(--font-text);
}
.find-prompt:active { scale: 0.97; }
.find-prompt[hidden] { display: none; }
@media (pointer: coarse) { .find-prompt kbd { display: none; } }

/* The panel: the content of a find, over the dimmed and stilled scene (staging). */
.scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--ink); opacity: 0; transition: opacity var(--duration-slow) var(--ease-out-snappy);
}
.has-panel .scene::after { opacity: 0.22; }
.panel {
  position: fixed; z-index: 6; top: 76px; right: clamp(16px, 2.5vw, 32px);
  width: min(440px, calc(100% - 32px)); max-height: calc(100% - 100px); overflow: auto;
  padding: 24px 28px 28px; background: var(--paper); border: 4px double var(--ink);
  animation: panel-in var(--duration-slow) var(--ease-out-snappy);
}
.panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; translate: 12px 0; } }
.panel__close { float: right; margin: -8px -12px 0 12px; border: 1px solid var(--rule); }
.panel__kicker { font-size: var(--step-small); color: var(--muted); }
.panel h2 { margin-top: 4px; font: 800 30px/1.05 var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
.panel__content > p:not(.panel__kicker) { margin-top: 12px; }
.panel__tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.panel__tags li { padding: 2px 10px; border-radius: 999px; background: var(--shallow); font-size: var(--step-small); }
.panel__password code { padding: 2px 8px; background: var(--shallow); border-radius: 3px; font-weight: 600; }
.panel__links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 20px !important; }
.panel__links a { display: inline-flex; align-items: center; min-height: 44px; }
.panel__open {
  padding: 0 16px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600;
}
.panel__open:hover { background: color-mix(in srgb, var(--accent) 84%, #000); }
@media (max-width: 640px) {
  .panel {
    top: auto; right: 0; bottom: 0; left: 0; width: auto; max-height: 72vh;
    border-width: 4px 0 0; border-style: double; animation-name: sheet-in;
  }
  @keyframes sheet-in { from { translate: 0 24px; opacity: 0; } }
}

/* The find list. */
.find-list {
  position: fixed; z-index: 6; top: 72px; right: clamp(16px, 2.5vw, 32px);
  width: min(320px, calc(100% - 32px)); padding: 14px; background: var(--paper); border: 4px double var(--ink);
}
.find-list[hidden] { display: none; }
.find-list__title { padding: 0 8px 8px; font: 700 18px/1.2 var(--font-display); }
.find-list__items { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.find-list__items button {
  display: flex; width: 100%; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px; border-radius: 4px; text-align: left;
  transition: background-color var(--duration-fast) var(--ease-out-snappy);
}
.find-list__items button:hover, .find-list__items button:focus-visible { background: var(--shallow); }
.find-list__where { font-size: var(--step-small); color: var(--muted); }

/* The thumb joystick, where the left thumb lands. */
.joystick {
  position: fixed; left: 0; top: 0; z-index: 3; width: 112px; height: 112px; margin: -56px 0 0 -56px;
  border-radius: 50%; border: 2px solid color-mix(in srgb, var(--paper) 80%, transparent);
  background: color-mix(in srgb, var(--paper) 18%, transparent); pointer-events: none;
}
.joystick[hidden] { display: none; }
.joystick__knob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%; background: color-mix(in srgb, var(--paper) 85%, transparent);
}

@media (max-width: 640px) {
  .has-3d .intro { right: 16px; max-width: none; padding: 12px 16px; }
  .has-3d .intro__lede { display: none; }
  .icon-button__label { display: none; }
  .has-panel .intro { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .choice:active, .icon-button:active, .find-prompt:active, .stand-up:active { transform: none; scale: none; }
  .panel { animation: none; }
}
