/* demo.css — the standalone "여우구슬" dark side-scroller demo ONLY.
 * Loaded solely by demo.html; card.html/index.html never pay for it.
 * Landscape-first (INSIDE / Little Nightmares / LIMBO are all landscape);
 * a portrait visitor gets a rotate prompt instead of a broken layout. */

:root {
  --demo-bg: #05070f;
  --demo-ink: #e8e2d4;
  --demo-ink-dim: #9a94a8;
  --demo-gold: #f3c15f;
  --demo-panel: rgba(8, 10, 22, 0.88);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--demo-bg);
  color: var(--demo-ink);
  /* 명조(세리프)가 기본 — 설화를 '읽는' 게임이라 본문 전체가 문학 톤.
     INSIDE의 자막 미니멀리즘 + 한국 고전 소설 조판의 결합. */
  font-family: 'Noto Serif KR', 'Apple SD Gothic Neo', serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#demo-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* ---- boot screen ---- */
/* The attract-mode scene (canvas) idles BEHIND this — so the boot layer
 * is a scrim, not a wall: darker at the bottom where the text sits,
 * open at the top where the moon and the sitting fox live. */
/* Every vertical measure below is vh-clamped: a phone in landscape has
 * ~350-430px of height AFTER the browser chrome, and a fixed-size stack
 * clipped the bottom button clean off in a real device test
 * (2026-09-01). The layout must breathe down, never overflow. */
.demo-boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.8vh, 14px);
  background: linear-gradient(
    to bottom,
    rgba(5, 7, 15, 0.2) 0%,
    rgba(5, 7, 15, 0.45) 55%,
    rgba(5, 7, 15, 0.82) 100%
  );
  text-align: center;
  padding: clamp(8px, 2.5vh, 24px) 24px calc(clamp(8px, 2.5vh, 24px) + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow: hidden;
}
.demo-boot.is-hidden { display: none; }
.demo-boot-eyebrow {
  font-size: clamp(10px, 2.6vh, 12px);
  letter-spacing: 0.35em;
  color: var(--demo-ink-dim);
  margin: 0;
}
.demo-boot-title {
  font-size: clamp(26px, 11vh, 56px);
  font-weight: 700;
  letter-spacing: 0.18em;
  margin: 0;
  color: var(--demo-ink);
  text-shadow: 0 0 28px rgba(243, 193, 95, 0.25);
}
.demo-boot-sub {
  font-size: clamp(11px, 3vh, 13px);
  color: var(--demo-ink-dim);
  margin: 0 0 clamp(2px, 1vh, 14px);
  line-height: 1.6;
  word-break: keep-all;
}
.demo-boot button {
  font: inherit;
  font-size: clamp(13px, 3.4vh, 16px);
  padding: clamp(8px, 2.2vh, 13px) clamp(28px, 6vw, 46px);
  border-radius: 999px;
  border: 1px solid rgba(243, 193, 95, 0.5);
  background: rgba(8, 10, 22, 0.6);
  color: var(--demo-gold);
  cursor: pointer;
  letter-spacing: 0.12em;
  max-width: 88vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-boot button:active { background: rgba(243, 193, 95, 0.22); }
.demo-boot button.demo-btn-secondary {
  border-color: rgba(154, 148, 168, 0.4);
  background: transparent;
  color: var(--demo-ink-dim);
  font-size: 13px;
  padding: 10px 34px;
}

/* ---- chapter title card ---- */
.demo-chapter-card {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.demo-chapter-card.is-open { opacity: 1; pointer-events: auto; }
.demo-chapter-title {
  font-size: clamp(26px, 5.5vw, 44px);
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--demo-ink);
  text-shadow: 0 0 24px rgba(243, 193, 95, 0.3);
}

/* ---- caption / subtitle bar (INSIDE keeps text minimal + bottom) ---- */
.demo-caption {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%) translateY(8px);
  z-index: 20;
  max-width: min(78vw, 640px);
  padding: 12px 22px;
  border-radius: 10px;
  background: var(--demo-panel);
  border: 1px solid rgba(243, 193, 95, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  text-align: center;
}
.demo-caption.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  cursor: pointer;
}
.demo-caption p {
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--demo-ink);
  word-break: keep-all;
}
.demo-caption::after {
  content: '▸';
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--demo-gold);
  opacity: 0.8;
  animation: demo-caption-nudge 1.2s ease-in-out infinite;
}
@keyframes demo-caption-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

/* ---- controls ---- */
.demo-controls {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 25;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 calc(18px + env(safe-area-inset-left, 0px))
           calc(14px + env(safe-area-inset-bottom, 0px))
           calc(18px + env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.demo-controls-group {
  display: flex;
  gap: 14px;
  pointer-events: auto;
}
/* Idle buttons sink into the night (the moonlit scene is the point, not
 * the chrome); a pressed button lights up — the pressed state every
 * commercial virtual pad ships. */
.demo-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid rgba(232, 226, 212, 0.25);
  background: rgba(8, 10, 22, 0.55);
  color: var(--demo-ink);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}
.demo-btn:active {
  background: rgba(243, 193, 95, 0.2);
  border-color: rgba(243, 193, 95, 0.5);
  opacity: 0.95;
}
.demo-btn-hide {
  width: auto;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--demo-gold);
  border-color: rgba(243, 193, 95, 0.4);
}

/* ---- end screen ---- */
.demo-end {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(243, 193, 95, 0.1), transparent 55%),
    #000;
  text-align: center;
  padding: 24px;
}
.demo-end.is-open { display: flex; }
.demo-end-title {
  font-size: clamp(24px, 5vw, 40px);
  letter-spacing: 0.25em;
  margin: 0;
  color: var(--demo-ink);
}
.demo-end-sub {
  font-size: 14px;
  color: var(--demo-ink-dim);
  line-height: 1.8;
  margin: 0 0 10px;
  word-break: keep-all;
}
.demo-end button {
  font: inherit;
  font-size: 14px;
  padding: 11px 38px;
  border-radius: 999px;
  border: 1px solid rgba(243, 193, 95, 0.5);
  background: transparent;
  color: var(--demo-gold);
  cursor: pointer;
}

/* ---- pause: the one piece of chrome every mobile game must have ---- */
.demo-pause-btn {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  z-index: 26;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(232, 226, 212, 0.2);
  background: rgba(8, 10, 22, 0.5);
  color: var(--demo-ink-dim);
  font-size: 14px;
  letter-spacing: -2px;
  cursor: pointer;
  opacity: 0.5;
}
.demo-pause-btn:active { opacity: 1; color: var(--demo-gold); }

.demo-pause {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
}
.demo-pause.is-open { display: flex; }
.demo-pause-panel {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.6vh, 12px);
  min-width: 230px;
  padding: clamp(14px, 3vh, 24px) 30px;
  border-radius: 16px;
  background: var(--demo-panel);
  border: 1px solid rgba(243, 193, 95, 0.25);
  text-align: center;
}
.demo-pause-title {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: 0.25em;
  color: var(--demo-ink-dim);
}
.demo-pause-panel button {
  font: inherit;
  font-size: clamp(13px, 3vh, 15px);
  padding: clamp(8px, 2vh, 11px) 20px;
  border-radius: 999px;
  border: 1px solid rgba(243, 193, 95, 0.4);
  background: transparent;
  color: var(--demo-gold);
  cursor: pointer;
}
.demo-pause-panel button:active { background: rgba(243, 193, 95, 0.15); }
.demo-pause-panel .demo-pause-quiet {
  border-color: rgba(154, 148, 168, 0.35);
  color: var(--demo-ink-dim);
  font-size: clamp(11px, 2.6vh, 13px);
}

/* ---- autosave toast: the visible heartbeat of the save system ---- */
.demo-save-toast {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 22;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--demo-panel);
  border: 1px solid rgba(243, 193, 95, 0.25);
  color: var(--demo-gold);
  font-size: 12px;
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.demo-save-toast.is-shown {
  opacity: 1;
  transform: translateY(0);
}

/* ---- portrait rotate prompt ---- */
.demo-rotate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--demo-bg);
  text-align: center;
  padding: 32px;
}
.demo-rotate-icon { font-size: 44px; animation: demo-rotate-tilt 1.6s ease-in-out infinite; }
@keyframes demo-rotate-tilt {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
.demo-rotate p { margin: 0; font-size: 15px; color: var(--demo-ink-dim); line-height: 1.7; word-break: keep-all; }
@media (orientation: portrait) {
  .demo-rotate { display: flex; }
}

/* cross-link to the trio puzzle from the boot screen */
.demo-boot-cross {
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(232, 226, 212, 0.55);
  text-decoration: none;
  border-bottom: 1px solid rgba(243, 193, 95, 0.25);
  padding-bottom: 2px;
}
.demo-boot-cross:active { color: #f3c15f; }
