/* 고운바탕(OFL)을 이 미리보기에 나오는 글자만 잘라 둔 두 벌 — 보통 · 굵게(강조 줄 · 움터 글자는 진짜 굵은 글꼴).
   예전 umteo-serif-ko.woff 에는 화면 글 90자가 없어 기기 명조로 섞여 보였다. 글을 고치면 scratchpad story_fonts.py 처럼 다시 자른다(chars.txt) */
@font-face {
  font-family: UmteoSerif;
  src: url("fonts/umteo-serif-story-regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: UmteoSerif;
  src: url("fonts/umteo-serif-story-bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: UmteoSans;
  src: url("/assets/fonts/umteo-sans.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #fbf7ef;
  --ink: #4a3628;
  --ground: #efe5d6;
  --surface: #fbf3e8;
  --muted: #65544b;
  --line: #d4beaa;
  --accent: #355646;
  --on-accent: #fff7eb;
  --focus: #285b78;
  --desk-light: #f9f1e6;
  --desk-shadow: #ddc7b4;
  --book-shadow: #60432e30;
  --serif: UmteoSerif, "Nanum Myeongjo", "Batang", serif;
  --sans: UmteoSans, "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #241e2c;
    --surface: #322836;
    --muted: #ded1c5;
    --line: #6b5262;
    --accent: #c1d6b8;
    --on-accent: #252e26;
    --focus: #b9d6f2;
    --desk-light: #4b3744;
    --desk-shadow: #191726;
    --book-shadow: #130f1866;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 0; }
body {
  margin: 0;
  isolation: isolate;
  color: var(--muted);
  background: radial-gradient(ellipse at 36% 0%, var(--desk-light), var(--ground) 58%, var(--desk-shadow));
  font-family: var(--sans);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: .52;
  background: var(--desk-image, none) center / cover;
  pointer-events: none;
}

button, a { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.preview {
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
}

.masthead { width: 100%; line-height: 24px; text-align: center; }
.wordmark { font-family: var(--serif); font-weight: 700; letter-spacing: .06em; }
.player { width: min(calc(100vw - 16px), calc((100svh - 132px) * .5625)); min-width: 0; }

.book {
  position: relative;
  isolation: isolate;
  aspect-ratio: 9 / 16;
  box-shadow: 0 12px 30px var(--book-shadow), 0 2px 4px var(--book-shadow);
  border-radius: 7px;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

.stage, .scenes, .scene, .art, .cover-art, .art > img:not(.memory, .feather), .cover-art > img,
.grain, .turn, .pano, .pano-light {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage { overflow: hidden; isolation: isolate; background: var(--paper); }
.cover-art { z-index: 1; }
.cover-idle .cover-art > img { animation: cover-light 6s ease-in-out infinite; }
@keyframes cover-light {
  0%, 100% { opacity: 1; }
  50% { opacity: .94; }
}
.scenes { z-index: 2; }
.scene { overflow: hidden; background: var(--paper); }
.art > img:not(.memory, .feather), .cover-art > img { object-fit: cover; object-position: var(--focus-point, center); }
.art { transform-origin: var(--focus-point, center); }
.scene[data-id="4"] > .art > img { filter: saturate(.85); }

.grain {
  z-index: 7;
  opacity: .072;
  background-image: var(--paper-image, none);
  background-size: 420px 420px;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.cover-action {
  position: absolute;
  z-index: 9;
  inset-block: 27% 20%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: min(75%, 310px);
  text-align: center;
}

.cover-title {
  margin: 0;
  font: 700 clamp(33px, 8.6vw, 45px)/1.1 var(--serif);
  color: #3d4836;
  letter-spacing: .035em;
  text-shadow: 0 0 9px #fcf2db;
}

.primary, .secondary {
  min-height: 44px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1.3;
  font-size: 14px;
  font-weight: 670;
  white-space: nowrap;
  text-decoration: none;
}

.primary { color: var(--on-accent); background: var(--accent); }
.primary:hover { filter: brightness(1.09); }
.secondary { color: #4a3628; background: #fff8ec; border-color: #cbb6a1; }
.secondary:hover { background: #f0e3d2; }

.controls {
  margin-top: 8px;
  padding: 3px 5px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 3px 8px var(--book-shadow);
}

.progress {
  margin: 0;
  height: 14px;
  width: 100%;
  display: block;
  accent-color: var(--accent);
  border-radius: 12px;
}

.control-row { display: flex; align-items: center; gap: 3px; }
.control {
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 44px;
  padding: 3px 8px;
  font-size: 13px;
  white-space: nowrap;
}
.control:hover { border-color: var(--line); }
.control-main { font-weight: 750; min-width: 54px; color: var(--accent); }
.time { margin-left: auto; white-space: nowrap; font-size: 12px; font-variant-numeric: tabular-nums; padding-right: 5px; }
.message { margin: 6px 0 0; font-size: 14px; }

.caption {
  z-index: 8;
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 54px);
  /* 2026-11-11 대표 'PC 에서 글자가 너무 연해 그림과 대비가 안 좋아 흐려 보인다' — 더 진한 먹색 + 종이색 번짐(글자 둘레)으로
     그림 위 어느 자리에서도 글자가 떠 보이게. 글 자리 그림 대비는 가장 진한 곳 기준 2.1~10:1 이라 번짐 없이 색만으로는 모자랐다 */
  color: #2e2018;
  font: 400 clamp(20px, 5.35vw, 22px)/1.6 var(--serif);
  letter-spacing: .02em;
  text-shadow: 0 0 1px #fbf7efe6, 0 0 8px #fbf7efd9, 0 0 18px #fbf7ef99;
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-wrap: balance;
  text-align: center;
  pointer-events: none;
}

.caption-text { position: relative; display: block; }
.caption.strong { font-weight: 700; }
.portrait-break { display: block; }
.desktop-space { display: none; }

.effect, .moon, .memory, .feather { position: absolute; pointer-events: none; }
.effect {
  width: 36%;
  aspect-ratio: 1;
  background: radial-gradient(ellipse, var(--glow-color, #ffdf9a) 0%, transparent 67%);
  transform: translate(-50%, -50%);
  opacity: 0;
}
.effect.hand { width: 40%; }
.effect.phone { width: 31%; --glow-color: #a9b9d6; }
.effect.warm { width: 48%; --glow-color: #ffd78d; }
.effect.sunbeam {
  height: 21%;
  transform-origin: left center;
  background: linear-gradient(90deg, #ffda8c, #ffdd91 52%, #ffc364 86%, #ffd884);
  mask-image: radial-gradient(ellipse 58% 51% at 43% 50%, #000 32%, #000b 61%, transparent 95%);
}
.effect.rainbow {
  height: 9%;
  transform-origin: left center;
  background: linear-gradient(180deg, #f9a6a0 13%, #ffdc88 33%, #d1e4a8 51%, #a3d9e6 67%, #c0abe6 85%);
  mask-image: radial-gradient(ellipse 56% 48% at 50% 50%, #000 30%, #0008 65%, transparent 96%);
}
.effect.rain {
  aspect-ratio: auto;
  overflow: hidden;
  background: none;
  mask-image: radial-gradient(ellipse, #000 16%, transparent 78%);
}
.effect.rain::before {
  content: "";
  position: absolute;
  inset: -18px;
  background: repeating-linear-gradient(106deg, transparent 0 12px, #d6e8ff9c 13px, transparent 14px 23px);
  transform: translateY(var(--rain-shift, 0px));
}

.moon {
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background-repeat: no-repeat;
  background-size: 400% 100%;
}
.memory {
  width: 23%;
  aspect-ratio: 1;
  object-fit: contain;
  transform: translate(-50%, -50%);
  filter: sepia(.14) hue-rotate(175deg) saturate(.55);
  mask-image: url("img/bloom.webp");
  mask-position: center;
  mask-repeat: no-repeat;
}
.feather { width: 12%; max-width: 104px; height: auto; filter: drop-shadow(0 0 9px #ffe5a6aa); }

.pano { overflow: hidden; background: var(--paper); }
.pano-track { position: absolute; left: 0; will-change: transform; }
.pano-track img { display: block; position: absolute; top: 0; height: 100%; }
.pano-portrait {
  position: absolute;
  top: -1px;
  left: 0;
  height: calc(100% + 2px);
  width: auto;
  max-width: none;
  aspect-ratio: 16 / 9;
  will-change: transform, opacity;
}
.pano-light { background: radial-gradient(ellipse at 83% 42%, #fff7cb, #fff2d47a 48%, transparent 79%); pointer-events: none; }

.turn { z-index: 6; perspective: 950px; pointer-events: none; overflow: hidden; }
.turn-strip {
  position: absolute;
  top: 0;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform, opacity;
}
.turn-strip.reverse { transform-origin: right center; }
.strip-front, .strip-back { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; }
.strip-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #47314b52, transparent 43%, #fff4d68f);
  opacity: var(--turn-shade, 0);
}
.strip-picture { position: absolute; top: 0; height: 100%; background-repeat: no-repeat; background-size: cover; }
.strip-back { transform: rotateY(180deg); background: #f2e4d2 var(--paper-back, none) center / 360px; }
.turn-shadow { position: absolute; inset: 0; background: linear-gradient(90deg, #3d283453, transparent 80%); pointer-events: none; }

.end-card {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  padding: 22px 22px 34px;
  background: radial-gradient(ellipse, #fff8eafc 39%, #fcf4e6ee 66%, #f6e3cde8);
  color: #4a3628;
  text-align: center;
}
.end-notebook { width: min(60%, 200px); max-height: 34%; object-fit: contain; }
.end-card::before {
  position: absolute;
  right: 7%;
  top: 6%;
  width: clamp(32px, 10%, 62px);
  aspect-ratio: 1;
  background: url("img/moons.webp") 0 50% / 400% 100% no-repeat;
  opacity: .6;
  content: "";
  pointer-events: none;
}
.end-copy { display: grid; justify-items: center; gap: 6px; }
.end-note {
  margin: 0;
  font: 400 clamp(18px, 5vw, 23px)/1.55 var(--serif);
  word-break: keep-all;
  text-wrap: balance;
}
.end-brand { margin: 10px 0 2px; font: 700 41px/1.15 var(--serif); letter-spacing: .06em; }
.sprout-mark { position: absolute; width: 8px; height: 8px; margin: 1px 0 0 2px; border-radius: 100% 0 100% 0; background: #789268; }
.end-feature { margin: 0; font-size: 13px; line-height: 1.55; }
.end-feature span { display: block; }
.end-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.end-actions .primary { color: #2e1a0e; background: #f2b896; border: 1.5px solid #86461f; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 900px) and (orientation: landscape) {
  .player { width: min(calc(100vw - 48px), calc((100svh - 132px) * 16 / 9), 1500px); }
  .book { aspect-ratio: 16 / 9; border-radius: 9px; }
  .cover-action { inset-block: 25% 19%; }
  .cover-title { font-size: clamp(38px, 4vw, 61px); }
  /* PC 가로 — 화면이 커서 24px 고정은 작고 가늘었다: 화면 폭에 맞춰 키우고, 글 뒤에 미색 종이 조각을 늘 깐다 */
  .caption { font-size: clamp(26px, 2.1vw, 34px); bottom: 6%; left: 8%; transform: none; max-width: 80%; text-align: left; }
  .caption::before {
    /* 수채 번짐처럼 가장자리가 흐린 미색 조각 — 네모 상자로 보이지 않게 둥근 타원 그러데이션 + 흐림 */
    position: absolute;
    inset: -18px -40px;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(closest-side, #fbf6eaeb 62%, #fbf6ea99 82%, #fbf6ea00 100%);
    filter: blur(8px);
    content: "";
  }
  .portrait-break { display: none; }
  .desktop-space { display: inline; }
  .memory { width: 17%; }
  .end-card { flex-direction: row; gap: 30px; padding: 36px; }
  .end-notebook { width: 28%; max-width: 315px; max-height: 71%; }
  .end-brand { font-size: 48px; margin-top: 14px; }
  .end-feature span { display: inline; }
  .controls { padding-inline: 12px; }
}

/* 둘째 줄(then) — 첫 줄 아래에 덧붙는 줄 (2026-11-11 '글이 너무 짧게 떴다가 없어진다') */
.caption-then { position: relative; display: block; margin-top: .25em; }
.caption-then.strong { font-weight: 700; }
