/* =========================================================
   공통 스타일
   - 색·글꼴 토큰, 기본 리셋
   - 모든 장면이 함께 쓰는 구조: .scene(스크롤 구간) > .sticky-screen(고정 화면)
   - 공통 헤더/푸터
   장면 고유의 스타일은 css/scenes/sXX.css 에 둔다.
   ========================================================= */

/* 글꼴: Noto Sans KR (public/fonts, 페이지에 쓰인 글자만 포함 → tools/build_fonts.py) */
@font-face { font-family: "Noto Sans KR"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/noto-sans-kr-400.woff2") format("woff2"); }
@font-face { font-family: "Noto Sans KR"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/noto-sans-kr-500.woff2") format("woff2"); }
@font-face { font-family: "Noto Sans KR"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/noto-sans-kr-700.woff2") format("woff2"); }
@font-face { font-family: "Noto Sans KR"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/noto-sans-kr-800.woff2") format("woff2"); }
@font-face { font-family: "Noto Sans KR"; font-weight: 900; font-style: normal; font-display: swap; src: url("../fonts/noto-sans-kr-900.woff2") format("woff2"); }

:root {
  /* 시안 색: 탄 종이 같은 검은 배경, 크림색 글자, 선명한 피 빨강, 낡은 금 */
  --bg: #16110f;
  --bg-deep: #0e0a09;
  --fg: #efe6d6;
  --fg-soft: #d8cfc0;
  --muted: #8f857a;
  --line: #3a302a;
  --line-soft: #2a221e;
  --red: #e5262b;
  --red-deep: #8f1a17;
  --gold: #d6a23a;
  --gold-deep: #9a6d1c;
  --dim: #3d342d;


  --font: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --gutter: clamp(16px, 4vw, 64px);
  --header-h: 64px;
  --top-space: var(--header-h);   /* 장면 내용이 시작하는 높이 */
  --toolbar: 0px;                 /* 모바일 주소창 높이 (주소창이 숨으면 화면이 이만큼 길어진다) */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.5;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1, h2, h3, p { margin: 0; }
em { font-style: normal; }
button, input, output { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 장면 공통 구조 ---------- */

/* 스크롤 구간. 높이는 장면마다 --scene-length 로 정한다 (예: 400vh) */
.scene {
  position: relative;
  height: var(--scene-length, 300vh);
}

/* 스크롤 구간 동안 화면에 고정되는 영역
   배경: 탄 종이 같은 검은 바탕 이미지 (img/bg.jpg — 입자 · 긁힌 자국 · 위쪽 물방울 무늬 포함) */
@supports (height: 100svh) {
  :root { --toolbar: calc(100lvh - 100svh); }
}

/* 높이는 주소창이 숨었을 때 기준(100vh = 100lvh)으로 잡아 배경·바닥이 늘 화면 끝까지 닿게 하고,
   내용은 아래쪽 여백에 --toolbar 를 더해 주소창이 보일 때 화면(100svh) 안에 들어오게 한다.
   주소창이 나타나거나 숨어도 크기가 바뀌지 않아 다시 계산하지 않는다. */
.sticky-screen {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh;
  overflow: hidden;
  isolation: isolate;
  background: #16110f url("../img/bg.jpg") center / cover no-repeat;
}

/* 화면 아래 붉은 바닥과 철조망 (img/floor.png, 가로로 이어 붙임) */
.sticky-screen::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: clamp(70px, 10vh, 112px);
  background: url("../img/floor.png") center bottom / auto 100% repeat-x;
  pointer-events: none;
  z-index: -1;
}

/* SVG 필터 정의는 화면에 보이지 않게 */
.fx-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 낡은 인쇄 느낌 글자: 점 구멍 + 아래로 번진 붉은 그림자 */
.fx-print {
  color: var(--fg);
  text-shadow: 2px 3px 0 var(--red-deep);
  filter: url(#fx-grain);
}

/* 장면이 끝날 때 화면을 어둡게 덮는 막 (투명도는 장면 스크립트가 조절) */
.scene-curtain {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--bg-deep);
  opacity: 0;
  pointer-events: none;
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: calc(20px + var(--toolbar));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- 공통 헤더 ---------- */

.story-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--header-h);
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(to bottom, rgba(22, 17, 15, 0.85), rgba(22, 17, 15, 0));
  pointer-events: none;
}

.story-scene-label {
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.story-steps {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.story-step {
  position: relative;
  width: clamp(16px, 3vw, 40px);
  height: 3px;
  background: var(--line-soft);
  overflow: hidden;
}

/* --fill: 0~1, 해당 장면의 진행률 */
.story-step::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gold);
  transform-origin: left;
  transform: scaleX(var(--fill, 0));
}

/* ---------- 공통 푸터 ---------- */

.story-footer {
  min-height: 60vh;
  padding: 120px var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  border-top: 1px solid var(--line-soft);
}

.story-footer-next {
  font-size: clamp(20px, 3vw, 32px);
  font-weight: 700;
}

.story-footer-note {
  color: var(--muted);
}

@media (max-width: 640px) {
  :root { --header-h: 52px; }
  .story-header { flex-direction: column; justify-content: center; align-items: flex-start; gap: 6px; }
  .story-scene-label { font-size: 11px; }
}

/* ---------- 터치 화면: 한 번 쓸면 다음 상태에서 멈춘다 ----------
   단계형 장면은 상태마다 .snap-point 를 둔다 (js/script.js 가 만든다).
   손가락으로 세게 쓸어도 상태를 건너뛰지 않아 전환이 겹치지 않는다. */
.snap-point {
  position: absolute;
  left: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

@media (pointer: coarse) {
  html { scroll-snap-type: y mandatory; }
  .scene,
  .snap-point { scroll-snap-align: start; scroll-snap-stop: always; }   /* .scene: JS 가 지점을 만들기 전에도 장면 시작에서 멈춤 */
  .story-footer { scroll-snap-align: end; }
}
