/* ==========================================================
   memory.css — renn's room is the home of the dream
   The room itself is painted and lit on a canvas (memory/*.js);
   this is everything laid over it: the buttons on the things in
   the room, the handwriting, the title card, the captions, and
   how rooms surface once the camera has travelled to them.
   ========================================================== */

.memory-canvas,
.memory-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 1.4s ease;
}

.memory-fallback {
  width: auto;
  height: auto;
  transform-origin: 0 0;
  filter: sepia(0.25) saturate(1.1);
}

.memory-canvas.is-hidden { opacity: 0; }

/* the night sea only exists out of the window */
.sky,
.life {
  opacity: 0;
  transition: opacity 1.8s ease 0.3s;
}

.is-outside .sky,
.is-outside .life { opacity: 1; }
.grain,
.cursor-glow { display: none; }
.is-outside .grain { display: block; }

/* ---------- the room ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 5;
  min-height: 0;
  transition: opacity 0.6s ease 0.2s;
}

body:not([data-view="home"]) .scene {
  opacity: 0;
  filter: none;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.hotspots {
  position: absolute;
  inset: 0;
}

.hotspot {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  border-radius: 18px;
  outline: none;
  cursor: pointer;
  will-change: transform;
}

.hotspot:focus-visible {
  box-shadow: 0 0 0 2px rgb(255 236 200 / 0.85), 0 0 30px rgb(255 214 160 / 0.5);
}

/* a small warm dot, so you know things can be touched */
.hot-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  translate: -50% -50%;
  background: rgb(255 240 210 / 0.9);
  box-shadow: 0 0 0 4px rgb(255 230 190 / 0.18), 0 0 18px 4px rgb(255 210 150 / 0.5);
  opacity: 0;
  animation: dot-breathe 3.2s ease-in-out infinite;
  transition: opacity 0.6s ease;
}

.memory-ready .hot-dot { opacity: 0.55; }
.hotspot:hover .hot-dot,
.hotspot:focus-visible .hot-dot { opacity: 0; }
.hotspot[data-view="guitar"] .hot-dot { top: 42%; }
.hotspot[data-view="wishes"] .hot-dot { top: 40%; }

@keyframes dot-breathe {
  50% { scale: 1.5; box-shadow: 0 0 0 7px rgb(255 230 190 / 0.1), 0 0 26px 8px rgb(255 210 150 / 0.35); }
}

.hot-label {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  font: 700 1.7rem/1 var(--hand);
  color: #fff8ec;
  white-space: nowrap;
  text-shadow: 0 0 18px rgb(255 190 120 / 0.9), 0 2px 6px rgb(40 20 10 / 0.7);
  pointer-events: none;
  opacity: 0;
  translate: -50% -100%;
  transition: opacity 0.35s ease;
}

.hot-label.is-on { opacity: 1; animation: ink 0.6s var(--ease-out); }

/* the film's opening title */
.title-card {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 3;
  width: max-content;
  max-width: 92vw;
  translate: -50% -50%;
  text-align: center;
  pointer-events: none;
  transition: opacity 2.4s ease, filter 2.4s ease;
}

.title-card::before {
  content: '';
  position: absolute;
  inset: -30% -20%;
  z-index: -1;
  background: radial-gradient(ellipse, rgb(40 20 10 / 0.45), transparent 65%);
}

.title-card .dream-title {
  font-size: clamp(3rem, 9vw, 7.6rem);
  color: #fff6e6;
  text-shadow: 0 0 30px rgb(255 200 140 / 0.8), 0 0 90px rgb(255 160 90 / 0.5), 0 2px 10px rgb(60 30 10 / 0.5);
  opacity: 0;
}

.title-card .t-rest { font-size: 0.62em; }

.title-card .dream-sub {
  color: #ffe9c9;
  opacity: 0;
}

.title-card.is-playing .dream-title { animation: title-in 2.6s ease both 0.2s; }
.title-card.is-playing .dream-sub { animation: title-in 2.6s ease both 1s; }

/* the tape rewinding to zero */
.rewind {
  margin-bottom: 10px;
  font: 400 clamp(1.4rem, 3.4vw, 2.4rem)/1 ui-monospace, 'Courier New', monospace;
  letter-spacing: 0.08em;
  color: #fff3de;
  text-shadow: 2px 0 0 rgb(255 0 60 / 0.45), -2px 0 0 rgb(0 200 255 / 0.45), 0 0 18px rgb(255 190 120 / 0.8);
  font-variant-numeric: tabular-nums;
  transition: opacity 1.2s ease 1.6s, font-size 0.8s ease;
}

.title-card.is-rewinding .rewind { font-size: clamp(2.2rem, 6vw, 4.4rem); }
.title-card.is-rewinding .rw-sign { animation: osd-blink 0.4s steps(1) infinite; }
.title-card.is-playing .rewind { opacity: 0.55; }
.rw-sign { font-size: 0.8em; }

.title-card .t-name span.is-playable { pointer-events: auto; }
.title-card.is-gone { opacity: 0; filter: blur(12px); }
.title-card.is-gone * { pointer-events: none !important; }

@keyframes title-in {
  from { opacity: 0; filter: blur(14px); letter-spacing: 0.08em; }
  to   { opacity: 1; filter: none; }
}

/* a caption at the bottom, like an old home video */
.memory-caption {
  position: absolute;
  left: 24px;
  bottom: 20px;
  z-index: 2;
  max-width: min(60ch, 70vw);
  font: italic 400 1rem/1.4 var(--serif);
  color: rgb(255 244 228 / 0.85);
  text-shadow: 0 1px 6px rgb(30 15 5 / 0.8);
  pointer-events: none;
}

.corner-home .tape-counter {
  margin-left: 8px;
  font: 400 0.95rem/1 ui-monospace, 'Courier New', monospace;
  letter-spacing: 0.06em;
  color: #ffd49a;
  text-shadow: 0 0 10px rgb(255 170 100 / 0.6);
  font-variant-numeric: tabular-nums;
}

.keys-owner {
  margin-top: 16px;
  font: 600 1.15rem/1 var(--hand);
  text-align: center;
}

.keys-owner a { color: #7a3f6a; }

.cap-place { font: 600 1.35rem/1 var(--hand); font-style: normal; color: #fff3de; }
.dream-clock { display: block; margin-top: 4px; opacity: 0.75; font-size: 0.92rem; }

.scene-hint {
  bottom: auto;
  top: 60px;
  left: 50%;
  font-size: 1.25rem;
  color: rgb(255 244 228 / 0.8);
  text-shadow: 0 1px 8px rgb(30 15 5 / 0.8);
  animation: ink 1.5s ease both 5.5s;
}

.tuned-home {
  top: auto;
  bottom: 22px;
  left: auto;
  right: 22px;
  color: #fff3de;
  background: rgb(40 22 12 / 0.35);
  backdrop-filter: blur(6px);
}

.has-walkman .memory-caption { bottom: 170px; }
.has-walkman .tuned-home { bottom: 170px; }

/* where the camera is going, written on the way */
.travel-caption {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 40;
  translate: -50% -50%;
  font: italic 300 clamp(1.6rem, 4vw, 2.8rem)/1.1 var(--serif);
  color: #fff7ea;
  text-align: center;
  text-shadow: 0 0 30px rgb(255 190 120 / 0.9), 0 2px 12px rgb(30 15 5 / 0.8);
  pointer-events: none;
  opacity: 0;
}

.travel-caption.is-on { animation: travel 2.6s ease both; }

@keyframes travel {
  0%   { opacity: 0; filter: blur(10px); letter-spacing: 0.06em; }
  25%  { opacity: 1; filter: none; letter-spacing: 0; }
  70%  { opacity: 1; filter: none; }
  100% { opacity: 0; filter: blur(8px); }
}

/* ---------- rooms surface over the room ---------- */
.view.is-waiting { opacity: 0; pointer-events: none; }

.view.is-opening {
  animation: surface 1.1s var(--ease-out) both;
  transform-origin: 50% 40%;
}

@keyframes surface {
  from { opacity: 0; filter: blur(12px) brightness(1.4); transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; filter: none; transform: none; }
}

.view.is-closing {
  animation: sink 0.45s ease forwards;
}

@keyframes sink {
  to { opacity: 0; filter: blur(10px); transform: scale(1.015); }
}

/* rooms sit on the room, not a sky: a soft dark shelter for the words */
.view-title {
  text-shadow: 0 0 34px rgb(255 190 120 / 0.55), 0 2px 16px rgb(20 10 5 / 0.8);
}

.view-lede,
.view-foot {
  text-shadow: 0 1px 10px rgb(20 10 5 / 0.9);
}

.view-close {
  padding: 6px 14px 8px;
  border-radius: 999px;
  background: rgb(30 16 8 / 0.35);
  backdrop-filter: blur(6px);
}

.view-inner::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgb(20 10 6 / 0.35), transparent 70%);
}

/* left alone, the memory fades (the engine washes it out) */
html.is-drifting .scene::after {
  content: 'the memory is fading. move to come back.';
  position: fixed;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  font: italic 300 clamp(1.4rem, 3vw, 2.2rem)/1.2 var(--serif);
  color: #fff6e8;
  text-shadow: 0 0 24px rgb(255 190 120 / 0.8);
  animation: ink 4s ease 3s both;
}

html.is-drifting .hot-dot,
html.is-drifting .memory-caption { opacity: 0; transition: opacity 6s ease; }

/* ---------- phones ---------- */
@media (max-width: 760px), (max-height: 540px) {
  .scene {
    display: block;
    padding: 0;
  }

  .tuned-home {
    position: absolute;
    right: 12px;
    bottom: 14px;
    max-width: 60vw;
    font-size: 1rem;
  }

  .scene-hint {
    position: absolute;
    top: 64px;
    left: 50%;
    translate: -50% 0;
    width: 90vw;
    white-space: normal;
    font-size: 1.1rem;
  }

  .memory-caption { left: 14px; bottom: 16px; max-width: 48vw; }
  .dream-clock { display: none; }
  .hot-label { font-size: 1.4rem; }
}

.reduce-motion .hot-dot { animation: none; }

/* ==========================================================
   THE CAMERA PANEL
   ========================================================== */
.cam-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: min(360px, 92vw);
  padding: 18px 18px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: #f6ead8;
  background: linear-gradient(180deg, rgb(26 16 10 / 0.82), rgb(14 9 6 / 0.9));
  backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: -20px 0 60px rgb(0 0 0 / 0.5), inset 1px 0 0 rgb(255 220 170 / 0.12);
  translate: 105% 0;
  transition: translate 0.55s var(--ease-out);
}

.cam-panel.is-open { translate: 0 0; }

.cam-head { display: flex; align-items: center; justify-content: space-between; }
.cam-title { font: italic 300 2.2rem/1 var(--serif); text-shadow: 0 0 24px rgb(255 180 110 / 0.6); }

.cam-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.5rem;
  color: #f6ead8;
}

.cam-close:hover { background: rgb(255 255 255 / 0.1); }
.cam-lede { margin: 4px 0 14px; font: 500 1.1rem/1.25 var(--hand); opacity: 0.7; }

.cam-looks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.cam-look {
  padding: 6px 11px 7px;
  border-radius: 999px;
  font: 700 1.05rem/1 var(--hand);
  color: #f6ead8;
  background: rgb(255 255 255 / 0.06);
  box-shadow: inset 0 0 0 1px rgb(255 220 170 / 0.2);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.cam-look:hover { background: rgb(255 255 255 / 0.12); }

.cam-look[aria-pressed="true"] {
  color: #2a1a10;
  background: linear-gradient(135deg, #ffd49a, #ff9f6a);
  box-shadow: 0 0 18px rgb(255 160 90 / 0.55);
}

.cam-toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 8px; }

.cam-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 1.1rem/1 var(--hand);
  cursor: pointer;
}

.cam-toggle input { position: absolute; opacity: 0; pointer-events: none; }

.cam-switch {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.15);
  transition: background-color 0.25s ease;
}

.cam-switch::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f6ead8;
  transition: translate 0.3s var(--spring);
}

.cam-toggle input:checked + .cam-switch { background: #ff9f6a; }
.cam-toggle input:checked + .cam-switch::after { translate: 16px 0; }
.cam-toggle input:focus-visible + .cam-switch { box-shadow: 0 0 0 2px #ffd49a; }

.cam-group {
  margin: 10px 0 0;
  padding: 8px 0 0;
  border: 0;
  border-top: 1px solid rgb(255 220 170 / 0.14);
}

.cam-group legend {
  padding: 0 6px 0 0;
  font: italic 400 1rem/1 var(--serif);
  color: #ffc98f;
  opacity: 0.85;
}

.cam-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  padding: 6px 0;
  font: 500 0.92rem/1.2 var(--pencil);
}

.cam-row.is-off { opacity: 0.4; pointer-events: none; }
.cam-val { font: 600 0.85rem/1 var(--pencil); color: #ffd49a; font-variant-numeric: tabular-nums; }

.cam-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.cam-row input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff9f6a var(--fill, 50%), rgb(255 255 255 / 0.15) var(--fill, 50%));
}

.cam-row input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff9f6a var(--fill, 50%), rgb(255 255 255 / 0.15) var(--fill, 50%));
}

.cam-row input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: #fff3e2;
  box-shadow: 0 0 12px rgb(255 170 100 / 0.8);
  -webkit-appearance: none;
  appearance: none;
}

.cam-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: #fff3e2;
  box-shadow: 0 0 12px rgb(255 170 100 / 0.8);
}

.cam-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }

#cameraBtn[aria-expanded="true"] { color: #ffd49a; text-shadow: 0 0 12px rgb(255 170 100 / 0.8); }

/* the shutter: a quick white flash when a photo is taken */
html.is-shutter::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #fff;
  pointer-events: none;
  animation: shutter 0.6s ease-out forwards;
}

@keyframes shutter {
  from { opacity: 0.85; }
  to   { opacity: 0; }
}

/* ---------- the tape's on-screen display ---------- */
.vhs-osd {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: none;
  pointer-events: none;
  font: 400 clamp(1rem, 2.2vw, 1.6rem)/1.15 ui-monospace, 'VT323', 'Courier New', monospace;
  letter-spacing: 0.06em;
  color: #f4f4f0;
  text-shadow: 2px 0 0 rgb(255 0 60 / 0.55), -2px 0 0 rgb(0 200 255 / 0.55), 0 0 6px rgb(255 255 255 / 0.4);
}

.is-vhs .vhs-osd { display: block; }
.vhs-osd > span { position: absolute; }
.osd-play { left: 5vw; top: 9vh; animation: osd-blink 1.6s steps(1) infinite; }
.osd-count { right: 5vw; top: 9vh; }
.osd-sp { right: 5vw; top: calc(9vh + 1.4em); }
.osd-date { left: 5vw; bottom: 16vh; }

@keyframes osd-blink { 50% { opacity: 0.25; } }

@media (max-width: 560px) {
  .cam-word { display: none; }
  .cam-panel { width: 100vw; }
}

/* no rounded corners anywhere: square edges only */
*, *::before, *::after { border-radius: 0 !important; }

/* the bits the room has left, next to the counter */
.corner-home .bits-left {
  margin-left: 6px;
  font: 400 0.72em/1 ui-monospace, Menlo, 'Courier New', monospace;
  letter-spacing: 0.08em;
  opacity: 0.55;
}
.corner-home .bits-left.is-flipping { animation: bits-flip 0.6s steps(3) 1; }
@keyframes bits-flip {
  0%, 66% { opacity: 1; color: #fff; }
  33% { opacity: 0.2; }
}
