/* ═══════════════════════════════════════
   Wonsuk Choi — the building
   Same palette as the written site; the canvas does the rest.
   ═══════════════════════════════════════ */

:root {
  --bg:     #05070d;
  --text:   #e8edf5;
  --dim:    #8c97ac;
  --faint:  #5a6479;
  --cy5:    #38bdf8;
  --pe:     #f472b6;
  --fitc:   #4ade80;
  --dapi:   #818cf8;
  --stroke: rgba(255,255,255,0.10);
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* `hidden` is only a UA `display:none`, so any rule that sets display — the
   panel is a grid, the stick is a block — silently un-hides the element. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  overflow: hidden;
  /* stop the pull-to-refresh / rubber-band that fires when a thumb drags the
     stick past the top of the screen */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* no 300ms double-tap-to-zoom on the controls */
button, a, kbd { touch-action: manipulation; }

#stage {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: crosshair;      /* clicking engages mouse-look */
}
html.touch #stage { cursor: default; }
html.locked #stage { cursor: none; }
/* once the mouse is driving the view, the invitation to click is noise */
html.locked .look-hint { opacity: 0.25; }
.look-hint {
  color: var(--cy5);
  transition: opacity 0.3s var(--ease);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--faint);
}

/* ── HUD ─────────────────────────────── */
.hud {
  position: fixed; left: 0; right: 0;
  z-index: 5;
  display: flex; align-items: center;
  gap: 18px;
  padding: 14px clamp(14px, 3vw, 28px);
  pointer-events: none;
}
.hud a, .hud button { pointer-events: auto; }

.hud-top {
  top: 0;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(5,7,13,0.88), rgba(5,7,13,0));
  padding-top: max(14px, env(safe-area-inset-top));
}
.hud-room b {
  display: block;
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.hud-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }
.seen b { color: var(--cy5); }
.seen b.done { color: var(--fitc); }

.ghost {
  color: var(--dim);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(8px);
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.ghost:hover { color: var(--text); border-color: var(--cy5); }

/* the two HUD links don't fit across a 390px screen at full length */
.ghost .sm { display: none; }
@media (max-width: 560px) {
  .ghost .lg { display: none; }
  .ghost .sm { display: inline; }
}

.hud-bottom {
  bottom: 0;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  background: linear-gradient(to top, rgba(5,7,13,0.88), rgba(5,7,13,0));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.hud-bottom .dim { color: rgba(90,100,121,0.7); }
kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 2px 6px;
  margin-right: 2px;
  color: var(--dim);
  border: 1px solid var(--stroke);
  border-radius: 5px;
  background: rgba(255,255,255,0.04);
}

/* ── interaction prompt ──────────────── */
#prompt {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  z-index: 6;
  padding: 9px 18px;
  color: var(--fitc);
  font-size: 0.72rem;
  border: 1px solid rgba(74,222,128,0.35);
  border-radius: 99px;
  background: rgba(6,14,10,0.85);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  pointer-events: none;
}

/* ── touch controls ──────────────────── */
#stick {
  position: fixed;
  z-index: 6;
  width: 108px; height: 108px;
  margin: -54px 0 0 -54px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#stick.on { opacity: 1; }
#stick-nub {
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(56,189,248,0.35);
  border: 1px solid rgba(56,189,248,0.6);
}

#action-btn {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px));
  z-index: 6;
  display: none;
  width: 72px; height: 72px;
  font-size: 1.5rem;
  color: var(--faint);
  border: 1px solid var(--stroke);
  border-radius: 50%;
  background: rgba(10,16,26,0.8);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s, transform 0.25s var(--ease);
}
#action-btn.live {
  color: var(--fitc);
  border-color: rgba(74,222,128,0.55);
  background: rgba(10,26,18,0.9);
  transform: scale(1.06);
}
/* Touch layout, keyed off the class game.js sets — never off a second
   `pointer: coarse` query that could disagree with the one the JS read. */
html.touch #action-btn { display: block; }
html.touch .hud-bottom { display: none; }   /* no keyboard to press */
html.touch #prompt {
  /* clear of the action button, which sits bottom-right and would otherwise
     land on top of a centred prompt on a narrow screen */
  bottom: max(184px, calc(env(safe-area-inset-bottom) + 184px));
  max-width: calc(100vw - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* landscape phone: the bars eat most of a 390px-tall viewport */
@media (max-height: 540px) {
  html.touch #action-btn {
    width: 58px; height: 58px; font-size: 1.2rem;
    bottom: max(14px, calc(env(safe-area-inset-bottom) + 14px));
    right: max(14px, env(safe-area-inset-right));
  }
  html.touch #prompt {
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    left: 0; right: 86px;
    transform: none;
    margin-left: 16px;
    max-width: none;
    text-align: center;
  }
  .hud-top { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .hud-room b { font-size: 0.86rem; }
  #room-sub { display: none; }
}

/* The room subtitle is the widest thing in the bar and the least load-bearing.
   Dropping it below 900px leaves the links comfortable room — at 768px the
   full bar needed 767 of 768 available pixels. */
@media (max-width: 900px) {
  #room-sub { display: none; }
}

/* ── exhibit panel ───────────────────── */
.panel-scrim {
  position: fixed; inset: 0;
  z-index: 20;
  display: grid; place-items: center;
  padding: clamp(16px, 4vw, 48px);
  background: rgba(3,5,10,0.72);
  backdrop-filter: blur(6px);
}
.panel {
  position: relative;
  width: min(620px, 100%);
  max-height: 82vh;
  max-height: 82dvh;              /* dvh where supported: iOS URL bar */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;   /* don't scroll the page behind it */
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: linear-gradient(160deg, #0d1522, #080c14);
  box-shadow: 0 40px 90px -30px rgba(0,0,0,0.95);
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  padding-right: 34px;
}
#p-sub { margin-bottom: 20px; color: var(--cy5); }
#p-body p { color: var(--dim); line-height: 1.72; font-size: 0.94rem; margin-bottom: 13px; }
#p-body b { color: var(--text); font-weight: 600; }
#p-body em { color: var(--text); font-style: italic; }
#p-body a { color: var(--cy5); overflow-wrap: anywhere; }
#p-body .muted { color: var(--faint); font-size: 0.86rem; font-style: italic; }
#p-body .award {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: #fbbf24;
  padding: 2px 8px;
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 5px;
}
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 20px; }
.tags span {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--faint);
  padding: 5px 11px;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
}
#p-close {
  position: absolute; top: 16px; right: 16px;
  width: 34px; height: 34px;
  font-size: 1.3rem; line-height: 1;
  color: var(--dim);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
#p-close:hover { color: var(--text); border-color: var(--pe); }

/* ── text fallback ───────────────────── */
.text-dump {
  position: fixed; inset: 0;
  z-index: 30;
  overflow-y: auto;
  padding: clamp(24px, 6vw, 80px) clamp(20px, 6vw, 80px) 120px;
  background: var(--bg);
}
.text-dump section { max-width: 70ch; margin: 0 auto 56px; }
.text-dump h2 {
  font-family: var(--font-display);
  font-size: 1.9rem; font-weight: 600;
  padding-bottom: 14px; margin-bottom: 26px;
  border-bottom: 1px solid var(--stroke);
}
.text-dump article { margin-bottom: 34px; }
.text-dump h3 { font-family: var(--font-display); font-size: 1.12rem; margin-bottom: 4px; }
.text-dump .sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--cy5); margin-bottom: 12px; }
.text-dump p { color: var(--dim); line-height: 1.75; margin-bottom: 11px; font-size: 0.95rem; }
.text-dump .tags { font-family: var(--font-mono); font-size: 0.7rem; color: var(--faint); }
.text-dump b { color: var(--text); }
.text-dump em { color: var(--text); font-style: italic; }

@media (max-width: 720px) {
  .hud-top { align-items: flex-start; }
  .hud-right { gap: 8px; }
  .hud-right .seen { display: none; }
  .hud-room b { font-size: 0.92rem; }
  .ghost { padding: 8px 11px; }        /* thumb-sized tap targets */
  .panel { padding: 26px 20px 22px; }
  .panel h2 { font-size: 1.28rem; }
}
@media (max-height: 500px) {
  .panel { max-height: 92dvh; padding: 20px 20px 18px; }
  .panel h2 { font-size: 1.15rem; margin-bottom: 4px; }
  #p-sub { margin-bottom: 12px; }
  #p-body p { margin-bottom: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation: none !important; }
}
