@import url("typography.css");

:root {
  --night: #07090f;
  --night-2: #0f1420;
  --panel: #1c2336;
  --accent: #6b8cff;
  --accent-soft: #8fa8ff;
  --text: #e8ecf4;
  --muted: #9aa8c4;
  --scrim: rgba(4, 6, 14, 0.84);
  --glow: rgba(107, 140, 255, 0.4);
  --shape: rgba(90, 110, 160, 0.22);
  --shape-line: rgba(150, 170, 230, 0.55);
  --shape-hover: rgba(120, 150, 220, 0.4);
  --border: rgba(255, 255, 255, 0.14);
  --line: rgba(150, 170, 230, 0.22);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
  margin: 0;
  height: 100%;
  color: var(--text);
  background: var(--night);
}

body {
  overflow: hidden;
}

body.page-leaving {
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

body.page-enter {
  animation: pageIn 0.5s var(--ease);
}

@keyframes pageIn {
  from { opacity: 0; transform: scale(0.995); }
  to { opacity: 1; transform: scale(1); }
}

/* PROTOTYPE BADGE */
/* BACK TO ROOM — fixed bottom-left on every section page */
.room-back {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.room-back:hover,
.room-back:focus-visible {
  color: var(--text);
  border-color: var(--accent-soft);
  transform: translateX(-2px);
}

.room-back::before {
  content: "\2190";
  font-size: 15px;
}

/* LOGO (fixed corner, always home) */
.site-logo {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 110;
  padding: 8px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-family: var(--font);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  background: rgba(10, 14, 24, 0.55);
  opacity: 0.4;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease),
    border-color 0.3s, color 0.3s, box-shadow 0.3s;
}

.site-logo:hover,
.site-logo:focus-visible {
  opacity: 1;
  color: var(--text);
  border-color: var(--accent-soft);
  transform: scale(1.05) rotate(-1deg);
  box-shadow: 0 0 22px var(--glow);
}

/* ROOM + SCALABLE STAGE
   Stage keeps a fixed 16:9 layout so object positions never shift.
   It scales to fit the viewport (contain), centered. */
.room {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* perspective gives the room a subtle sense of depth */
  perspective: 1600px;
  perspective-origin: 50% 42%;
  background:
    radial-gradient(ellipse at 70% 25%, rgba(40, 60, 120, 0.18), transparent 55%),
    linear-gradient(180deg, #0c1120 0%, #07090f 70%, #05060b 100%);
}

/* vignette + ambient light shift sit behind the room content */
.room::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  box-shadow: inset 0 0 220px 60px rgba(0, 0, 0, 0.75);
  background: radial-gradient(ellipse at 70% 22%, rgba(70, 100, 180, 0.10), transparent 50%);
  animation: lightShift 14s ease-in-out infinite alternate;
}

@keyframes lightShift {
  0% { opacity: 0.85; }
  100% { opacity: 1; }
}

.stage {
  position: relative;
  z-index: 2;
  width: min(100vw, 177.78vh); /* 16:9 */
  height: min(56.25vw, 100vh);
  max-width: 1600px;
  max-height: 900px;
  /* parallax shift applied via --px / --py from JS */
  transform: translate3d(calc(var(--px, 0) * 1px), calc(var(--py, 0) * 1px), 0);
  transition: transform 0.25s var(--ease);
}

/* PERSPECTIVE LINES (floor + walls) */
.perspective {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* ART LAYERS — full-frame PNGs that stack and align exactly */
.room-art { position: absolute; inset: 0; z-index: 2; }
.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.4s var(--ease), filter 0.4s var(--ease);
  will-change: transform, filter;
}
.layer.is-hover {
  transform: scale(1.025);
  filter: brightness(1.16) drop-shadow(0 6px 22px var(--glow));
}

/* INVISIBLE HIT AREAS (positioned over each object) */
.hit {
  position: absolute;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  z-index: 20;
  border-radius: 12px;
}
.hit:focus-visible {
  outline: 2px dashed var(--accent-soft);
  outline-offset: 4px;
}
.hit__label {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 130%);
  white-space: nowrap;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent-soft);
  background: rgba(8, 11, 20, 0.82);
  padding: 4px 9px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}
.hit:hover .hit__label,
.hit:focus-visible .hit__label { opacity: 1; }

/* hit footprints (center-anchored, % of stage) */
.hit-window    { left: 33%; top: 21%; width: 34%; height: 38%; }
.hit-frame     { left: 64%; top: 27%; width: 16%; height: 34%; }
.hit-cabinet   { left: 83%; top: 40%; width: 22%; height: 40%; }
.hit-desk      { left: 80%; top: 70%; width: 28%; height: 36%; }
.hit-cd        { left: 47%; top: 55%; width: 12%; height: 38%; }
.hit-character { left: 14%; top: 56%; width: 15%; height: 68%; }
.hit-cat       { left: 46%; top: 85%; width: 24%; height: 24%; }

/* Subtle instruction: faint by default, clarifies on hover/focus */
.subtle-prompt {
  color: var(--muted);
  opacity: 0.28;
  transition: opacity 0.35s var(--ease);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
}
.subtle-prompt:hover,
.subtle-prompt:focus-within { opacity: 0.85; }

/* INTRO SEQUENCE: darkness -> logo -> line -> room */
.intro {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #04060b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  transition: opacity 1.1s var(--ease);
}
.intro.hide { opacity: 0; pointer-events: none; }

.intro__logo {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(180, 195, 235, 0.35);
  border-radius: 50%;
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0.3em;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 1.2s var(--ease), transform 1.2s var(--ease);
}
.intro.show-logo .intro__logo { opacity: 1; transform: scale(1); }

.intro__line {
  margin: 0;
  max-width: 600px;
  padding: 0 24px;
  text-align: center;
  font-family: var(--font);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(16px, 2.2vw, 22px);
  line-height: 1.55;
  color: #cdd6ea;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.intro.show-line .intro__line { opacity: 1; transform: translateY(0); }

/* Room hidden until intro completes, then fades up (dark -> light) */
.room { opacity: 0; transition: opacity 1.2s var(--ease); }
body.room-visible .room { opacity: 1; }
body:not(.intro-active) .room { opacity: 1; }

/* CHARACTER DIALOGUE — centered modal that darkens the room */
.vn-scrim {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(3, 5, 11, 0.82);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease);
}
.vn-scrim.open { opacity: 1; pointer-events: auto; }

.vn-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  width: min(var(--vn-w, 640px), 92vw);
  z-index: 90;
  /* art layers (.vn-box__art) anchor to this box */
  isolation: isolate;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--vn-pad-t, 34px) var(--vn-pad-r, 36px) var(--vn-pad-b, 34px) var(--vn-pad-l, 36px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}
.vn-box.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

/* your own dialogue panel art (from content/character.json → ui) */
.vn-box.has-art {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: var(--vn-pad-t) var(--vn-pad-r) var(--vn-pad-b) var(--vn-pad-l);
}
.vn-box.has-art.has-fixed-size {
  height: min(var(--vn-h, auto), 85vh);
  min-height: min(var(--vn-h, auto), 85vh);
}
.vn-box__art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.vn-box__bg,
.vn-box__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: none;
}
.vn-box__bg.is-on { display: block; }
.vn-box__frame.is-on {
  display: block;
  z-index: 1;
  pointer-events: none;
}
.vn-box__content {
  position: relative;
  z-index: 2;
  min-height: 0;
}

.vn-scrim.has-art {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.vn-box .vn-line {
  margin: 0 0 22px;
  font-family: var(--font);
  font-size: clamp(17px, 2.2vw, 22px);
  font-weight: 400;
  line-height: 1.55;
  color: var(--vn-text, var(--text));
}

.vn-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vn-actions button {
  padding: 15px 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font);
  font-size: clamp(15px, 1.7vw, 17px);
  font-weight: 500;
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
}

.vn-actions button:hover {
  background: rgba(143, 168, 255, 0.16);
  border-color: var(--accent-soft);
}

/* SECTION PAGES */
.section {
  position: relative;
  min-height: 100vh;
  padding: 76px 28px 48px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(40, 60, 120, 0.14), transparent 55%),
    linear-gradient(180deg, var(--night-2), var(--night));
  overflow-y: auto;
}

body.section-body { overflow: auto; }

.section__back {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--accent-soft);
  font-size: 13px;
  text-decoration: none;
}
.section__back:hover { text-decoration: underline; }

/* section titles: see typography.css .page-title */

.placeholder-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.placeholder-card {
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--shape-line);
  background: var(--shape);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.placeholder-card:hover { background: var(--shape-hover); transform: translateY(-2px); }

/* ARCHIVE */
.archive-years { display: flex; flex-direction: column; gap: 30px; }
.archive-year h2 {
  font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px;
}
.archive-row { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.book-shape {
  flex: 0 0 100px; height: 132px;
  border: 2px dashed var(--shape-line); background: var(--shape);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; padding: 8px;
  font-size: 10px; text-align: center;
  transition: background 0.2s, transform 0.2s;
}
.book-shape:hover { background: var(--shape-hover); transform: translateY(-4px); }
.book-shape img { width: 100%; height: 84px; object-fit: cover; margin-bottom: 6px; background: #333; }

/* NIGHT SKY — full screen, sky is the hero */
.sky-page { position: fixed; inset: 0; overflow: hidden; background: #05070d; }
.sky-wrap {
  position: absolute; inset: 0;
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 45% 80%, rgba(255,255,255,0.35), transparent),
    radial-gradient(ellipse at 50% 95%, #16203a, #05070d 70%);
  overflow: hidden; cursor: grab; touch-action: none;
}
.sky-wrap:active { cursor: grabbing; }
.sky-inner { position: absolute; width: 180%; height: 180%; left: -40%; top: -40%; }

/* subtle prompt + back over the sky */
.sky-prompt {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 20; text-align: center; pointer-events: auto;
}
.sky-back {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease),
    transform 0.25s var(--ease);
}
.sky-back:hover,
.sky-back:focus-visible {
  color: var(--text);
  border-color: var(--accent-soft);
  transform: translateX(-2px);
}
.sky-back::before {
  content: "\2190";
  font-size: 15px;
}
/* STAR PROJECTS — compass icon + title that circles on hover */
.star {
  --s: 1;
  position: absolute;
  width: calc(58px * var(--s));
  height: calc(58px * var(--s));
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 2;
}

.star__icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(180, 200, 255, 0.35));
  animation: star-twinkle 4.5s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  transition: transform 0.3s var(--ease), filter 0.3s var(--ease);
}

.star__glow {
  position: absolute;
  left: 50%; top: 50%;
  width: 160%; height: 160%;
  transform: translate(-50%, -50%) scale(0.5);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(160, 190, 255, 0.45), transparent 65%);
  opacity: 0;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
  pointer-events: none;
}

.star:hover .star__icon,
.star:focus-visible .star__icon {
  transform: scale(1.18) rotate(8deg);
  filter: drop-shadow(0 0 12px rgba(200, 215, 255, 0.8));
}
.star:hover .star__glow,
.star:focus-visible .star__glow {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* title on a fixed top arc — one phrase, fades only */
.star__label {
  position: absolute;
  left: 50%; top: 50%;
  width: calc(150px * var(--s));
  height: calc(150px * var(--s));
  margin-left: calc(-75px * var(--s));
  margin-top: calc(-75px * var(--s));
  opacity: 0;
  transition: opacity 0.45s var(--ease);
  pointer-events: none;
  overflow: visible;
}
.star__label-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.star__label text {
  font-family: var(--font);
  font-size: calc(15px * var(--s));
  letter-spacing: 0.06em;
  fill: #f2a6bd;
}

.star.is-label-active .star__label { opacity: 1; }
.star.is-label-fading .star__label { opacity: 0; }
@keyframes star-twinkle {
  0%, 100% { opacity: 0.78; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .star__icon { animation: none; }
  .star.is-label-active .star__label { animation: none; opacity: 1; }
}

/* MULTIMEDIA */
.hobby-shelf { display: flex; gap: 20px; flex-wrap: wrap; }
.hobby-shape {
  width: 120px; height: 104px; border: 2px dashed var(--shape-line); background: var(--shape);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; text-align: center; padding: 8px;
  transition: background 0.2s, transform 0.2s;
}
.hobby-shape:hover { background: var(--shape-hover); transform: scale(1.05); }
.strip-scroll { display: flex; gap: 12px; overflow-x: auto; padding: 8px 0 16px; }
.strip-item {
  flex: 0 0 210px; height: 150px; border: 2px dashed var(--shape-line); background: var(--shape);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; padding: 8px; text-align: center;
}

/* OVERLAY */
.overlay-root {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center;
  justify-content: center; padding: 24px; background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity 0.35s var(--ease);
}
.overlay-root.open { opacity: 1; pointer-events: auto; }
.overlay-panel {
  position: relative; width: min(920px, 100%); max-height: 90vh; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 24px; overflow-y: auto;
  transform: scale(0.94); opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}
.overlay-root.open .overlay-panel { transform: scale(1); opacity: 1; }
/* bottom-left back — closes an overlay and returns to the page underneath */
.overlay-back {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 250;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.overlay-back:hover,
.overlay-back:focus-visible {
  color: var(--text);
  border-color: var(--accent-soft);
  transform: translateX(-2px);
}
.overlay-back::before {
  content: "\2190";
  font-size: 15px;
}
.overlay-panel h2 { margin: 0 0 12px; font-size: 18px; }
.overlay-panel p { color: var(--muted); font-size: 14px; line-height: 1.55; }
.overlay-panel ul { color: var(--muted); font-size: 14px; line-height: 1.7; }

.overlay-panel--flipbook {
  width: min(1100px, 96vw); height: min(85vh, 800px); padding: 12px;
  display: flex; flex-direction: column;
}
.overlay-panel--flipbook iframe {
  flex: 1; width: 100%; border: none; border-radius: 8px; background: #2a2a2a; min-height: 400px;
}

@media (max-width: 700px) {
  .hotspot { font-size: 10px; padding: 4px; }
  .hotspot small { display: none; }
  .stage__hint { font-size: 9px; }
}
