/* ============================================================
   KIJOONG — UNDER CONSTRUCTION · mono-cube
   One volt cube in real 3D (three.js). Minimal, quiet, refined.
   Paper/ink + the single volt blue. Dark + reduced-motion aware.
   ============================================================ */

:root {
  --paper: #ffffff;
  --ink: #0a0a0a;
  --ink-soft: #6b6b6b;
  --ink-faint: #b9b7b0;
  --volt: #1400ff;

  --font-display: "Archivo", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a0a0a;
    --ink: #f4f3ee;
    --ink-soft: #a3a099;
    --ink-faint: #4a4843;
    --volt: #3a2bff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(24px, 4vw, 44px) clamp(24px, 5vw, 64px);
}

/* ---------- meta rows (top + bottom) ---------- */
.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: clamp(10px, 1.05vw, 12px);
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.brand { color: var(--ink); letter-spacing: 0.24em; }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--volt); }
.status::before {
  content: "";
  width: 7px; height: 7px;
  background: var(--volt);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

.meta--bottom a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--volt);
  padding-bottom: 1px;
}
.meta--bottom a:hover, .meta--bottom a:focus-visible { color: var(--volt); outline: none; }

/* footer: 3 columns so the centre item sits at true viewport centre
   (space-between would offset it, since the side labels differ in width) */
.meta--bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.meta--bottom > :first-child { justify-self: start; }
.meta--bottom > .snd { justify-self: center; }
.meta--bottom > :last-child { justify-self: end; }

/* sound toggle (centre of the footer row) */
.snd {
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
}
.snd::before { content: ""; width: 6px; height: 6px; background: var(--volt); }
.snd.muted { color: var(--ink-faint); }
.snd.muted::before { background: var(--ink-faint); }
.snd:hover, .snd:focus-visible { color: var(--volt); outline: none; }

/* ---------- hero: cube + caption, centred in the 1fr row ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vh, 44px);
  min-height: 0;
}

.cube-host {
  width: min(520px, 74vw);
  height: clamp(240px, 42vh, 420px);
  touch-action: none;              /* let drag own the gesture on touch */
}
.cube-host canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
.cube-host.dragging canvas { cursor: grabbing; }

.caption { text-align: center; }

/* technical mono voice — the title speaks in the same type as the labels.
   Always ONE line (mono is wide; wrapping looked awkward). */
.title {
  margin: 0 0 16px;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  font-size: clamp(0.9rem, 2vw, 1.3rem);
  letter-spacing: 0.13em;
  line-height: 1.4;
}
.sub {
  margin: 0;
  font-family: var(--font-mono);
  text-transform: lowercase;
  font-size: clamp(0.8rem, 1.5vw, 0.92rem);
  letter-spacing: 0.03em;
  line-height: 1.65;
  color: var(--ink-soft);
  text-wrap: balance;      /* keeps the two lines even, no orphan */
}
.hint {
  margin: 16px 0 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transition: opacity 0.6s ease;
}
.hint.hide { opacity: 0; }

/* ---------- entrance (JS reveals; CSS-only fade) ---------- */
.js .hero, .js .meta { opacity: 0; transform: translateY(8px); }
.revealed .hero, .revealed .meta {
  opacity: 1; transform: none;
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.revealed .meta--bottom { transition-delay: 0.12s; }

/* ---------- fallback: no WebGL / no JS → a calm CSS cube ---------- */
.cube-fallback, .no-webgl .cube-host {
  position: relative;
  display: grid;
  place-items: center;
}
.no-webgl .cube-host::after {
  content: "";
  width: clamp(96px, 16vw, 150px);
  aspect-ratio: 1;
  background: var(--volt);
  transform: rotate(-4deg);
  box-shadow: 0 30px 60px -30px color-mix(in srgb, var(--volt) 60%, transparent);
}

/* ---------- mobile: a layout of its own, not just a shrink ---------- */
@media (max-width: 600px) {
  .stage {
    padding: clamp(18px, 6vw, 26px) clamp(16px, 5vw, 22px) clamp(20px, 5vw, 28px);
  }
  /* top bar keeps its two corners (brand left / status right) — mirrors the
     bottom corners for a deliberate frame around the centred hero (not a
     monotonous centre column) */
  .meta--top { gap: 12px; }
  .hero { gap: clamp(18px, 5vh, 30px); }
  .cube-host {
    width: 88vw;
    height: min(50vh, 88vw);   /* fits short phones too; camera auto-fits any ratio */
  }
  .caption { max-width: 94vw; }
  /* keep the title on ONE line across phones (no awkward wrap) */
  .title { font-size: clamp(0.78rem, 3.5vw, 1.02rem); letter-spacing: 0.05em; white-space: nowrap; }
  .sub { font-size: clamp(0.78rem, 3.2vw, 0.92rem); letter-spacing: 0.02em; }
  .hint { margin-top: 14px; }
  /* footer: SOUND ON on its own row, EST + email pinned to the two corners.
     Gives the bottom left/right structure (less "all centred") AND keeps the
     sound toggle well clear of the email so they can't be mis-tapped. */
  .meta--bottom {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "sound sound"
      "est   mail";
    row-gap: 22px;
    column-gap: 12px;
    align-items: center;
  }
  .meta--bottom > :first-child { grid-area: est; justify-self: start; }
  .meta--bottom > .snd { grid-area: sound; justify-self: center; }
  .meta--bottom > :last-child { grid-area: mail; justify-self: end; }
  /* bigger invisible tap target for the sound toggle (no underline to disturb) */
  .snd { padding: 10px 14px; margin: -10px -14px; }
}

@media (prefers-reduced-motion: reduce) {
  .status::before { animation: none; opacity: 1; }
  .revealed .hero, .revealed .meta { transition: none; }
}
