:root {
  --ink: #02131f;
  --deep: #041e30;
  --foam: #eaf6fb;
  --foam-66: rgba(234, 246, 251, 0.66);
  --foam-45: rgba(234, 246, 251, 0.45);
  --line: rgba(234, 246, 251, 0.22);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-ui: "Jost", "Avenir Next", system-ui, sans-serif;
  /* 4px spacing scale */
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-7: 28px;
  --s-8: 32px;
  --s-11: 44px;
  --s-12: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  overflow: hidden;
}

html {
  /* no double tap zoom, no grey flash on tap */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--foam);
}

/* the scene owns every gesture: drag looks, tap feeds, hold swims */
.a-canvas {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* a look drag keeps its grab hand even when it crosses the HUD */
.is-grabbing,
.is-grabbing * {
  cursor: grabbing !important;
}

/* soft cinematic frame over the scene, lets clicks through */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background:
    linear-gradient(rgba(146, 205, 233, 0.09), rgba(146, 205, 233, 0) 26%),
    radial-gradient(130% 100% at 50% 42%, rgba(0, 0, 0, 0) 58%, rgba(1, 12, 22, 0.36) 100%);
}

/* ---------- intro ---------- */

#intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  text-align: center;
  background: radial-gradient(120% 90% at 50% 0%, #0a3a55 0%, #052338 46%, #02131f 100%);
  transition: opacity 1.1s ease;
}

/* Gyozan logo animation: small, top center. The canvas carries its own transparency
   (js/intro-logo.js keys the black out), so no blend mode is needed. */
#intro-logo-src {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#intro-logo {
  position: absolute;
  top: calc(var(--s-7) + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: clamp(96px, 22vw, 136px);
  height: auto;
  pointer-events: none;
}

#intro.gone {
  opacity: 0;
  pointer-events: none;
}

.intro-inner {
  padding: 0 var(--s-7);
}

h1.title {
  margin: 0 0 var(--s-4);
  font: italic 300 clamp(54px, 11vw, 108px)/1.02 var(--font-display);
  color: var(--foam);
  text-wrap: balance;
}

/* one unit with the title: its gap to the title stays under half its gap to the button */
.sub {
  max-width: 34ch;
  margin: 0 auto var(--s-12);
  font: 300 16px/1.5 var(--font-ui);
  letter-spacing: 0.04em;
  color: var(--foam-66);
  text-wrap: balance;
}

#dive {
  font: 400 13px/1 var(--font-ui);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--foam);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  /* extra left padding balances the trailing letter-space */
  padding: var(--s-4) var(--s-11) var(--s-4) var(--s-12);
  cursor: pointer;
  transition: background-color 0.35s ease, border-color 0.35s ease, transform 0.35s ease;
}

#dive:hover, #dive:focus-visible {
  background: rgba(234, 246, 251, 0.08);
  border-color: rgba(234, 246, 251, 0.5);
  transform: translateY(-1px);
}

#dive:active {
  transform: scale(0.97);
  transition-duration: 0.12s;
}

#dive:focus-visible {
  outline: 1px solid var(--foam-66);
  outline-offset: 4px;
}

.ps {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--s-12) + var(--safe-bottom));
  margin: 0;
  font: 300 12px/1.6 var(--font-ui);
  letter-spacing: 0.06em;
  color: rgba(234, 246, 251, 0.34);
  padding: 0 calc(var(--s-7) + var(--safe-right)) 0 calc(var(--s-7) + var(--safe-left));
  text-wrap: balance;
}

/* landscape phones: pull the dedication and the note apart from the edges */
@media (max-height: 520px) {
  h1.title { margin-bottom: var(--s-3); font-size: 56px; }
  .sub { margin-bottom: var(--s-8); }
  .ps { bottom: calc(var(--s-11) + var(--safe-bottom)); }
  #intro-logo { top: calc(var(--s-3) + var(--safe-top)); width: 88px; }
}

/* portfolio link: small, bottom center, above the intro and the hud */
#credit {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(var(--s-2) + var(--safe-bottom));
  transform: translateX(-50%);
  padding: var(--s-2) var(--s-3);
  font: 300 11px/1 var(--font-ui);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(234, 246, 251, 0.45);
  text-decoration: none;
  transition: color 0.35s ease;
}

#credit:hover, #credit:focus-visible {
  color: var(--foam);
}

#credit:focus-visible {
  outline: 1px solid var(--foam-66);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- hud ---------- */

#hud > * {
  position: fixed;
  z-index: 30;
  transition: opacity 0.9s ease;
}

.ui-hidden > * {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* wordmark sits on the centre line of the round controls */
#wordmark {
  top: calc(var(--s-4) + var(--safe-top));
  left: calc(var(--s-7) + var(--safe-left));
  height: var(--s-11);
  display: flex;
  align-items: center;
  font: italic 300 17px/1 var(--font-display);
  letter-spacing: 0.06em;
  color: var(--foam-66);
  user-select: none;
  pointer-events: none;
}

#controls {
  top: calc(var(--s-4) + var(--safe-top));
  right: calc(var(--s-5) + var(--safe-right));
  display: flex;
  gap: var(--s-2);
}

.hud-btn {
  box-sizing: border-box;
  width: var(--s-11);
  height: var(--s-11);
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(4, 30, 48, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--foam);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease, transform 0.15s ease-out;
}

.hud-btn:hover, .hud-btn:focus-visible {
  border-color: rgba(234, 246, 251, 0.5);
}

.hud-btn:focus-visible {
  outline: 1px solid var(--foam-66);
  outline-offset: 3px;
}

.hud-btn:active {
  transform: scale(0.94);
}

#motion[aria-pressed="false"] {
  color: var(--foam-66);
}

#hint {
  left: 50%;
  bottom: calc(var(--s-11) + var(--safe-bottom));
  transform: translateX(-50%);
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100vw - var(--s-5) * 2 - var(--safe-left) - var(--safe-right));
  text-align: center;
  font: 300 12.5px/1 var(--font-ui);
  letter-spacing: 0.14em;
  color: rgba(234, 246, 251, 0.78);
  background: rgba(4, 30, 48, 0.4);
  border: 1px solid rgba(234, 246, 251, 0.14);
  padding: var(--s-3) var(--s-5);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}

#hint.show {
  opacity: 1;
}

/* phones and narrow windows: the look instruction on top, the rest below */
[data-device="mobile"] #hint {
  line-height: 1.6;
  padding: var(--s-2) var(--s-5);
  border-radius: var(--s-7);
}

[data-device="mobile"] .hint-line {
  display: block;
}

[data-device="mobile"] .hint-sep {
  display: none;
}

@media (max-width: 720px) {
  #hint {
    line-height: 1.6;
    padding: var(--s-2) var(--s-5);
    border-radius: var(--s-7);
  }

  .hint-line { display: block; }
  .hint-sep { display: none; }
}

@media (max-width: 480px) {
  #hint { font-size: 11px; letter-spacing: 0.1em; }
}

@media (prefers-reduced-motion: reduce) {
  #intro, #dive, #hint, #hud > *, .hud-btn { transition: none; }
}
