/* a-shared — 2026-11-30 학습 화면 개선(상영관 컨셉을 안쪽까지). 공통 틀 담당만 고친다. 다른 화면 CSS 는 아래 이름을 가져다 쓴다.

   토큰(again.css :root 에 있는 것 + 여기서 더한 것)
     --lamp / --lamp-hi / --lamp-ink   불빛(앰버). 주 단추 바탕, 먹색 위 강조 글자
     --lamp-deep                       종이(밝은 바탕) 위에 쓰는 불빛 글자·선 (대비 확보용). 정답 표시 글자, 진행 표시 글자
     --lamp-wash                       종이 위 아주 옅은 불빛 바탕 (정답 칸 바탕, 지금 단계 바탕)
     --stage / --stage-2 / --on-stage / --on-stage-sub   먹색 틀·자막 띠 바탕과 그 위 글자
     --ok                              정답 = 불빛 (--lamp-deep 과 같음, 의미 이름)

   공통 부품
   .btn-hero          화면의 주 동작 하나. 지름 76px(휴대폰 68px) 불빛 동그라미, 안에 SVG 아이콘(ico()) 하나.
                      글자는 aria-label 로. 보이는 이름이 필요하면 .hero-act 로 감싸 아래 .hero-lab 에 짧게.
                      상태: .on 또는 [aria-pressed="true"] = 녹음/재생 중(녹음은 .rec.on → 빨강), :disabled 흐리게.
                      예) <div class="hero-act"><button class="btn-hero" aria-label="듣기">${ico('speaker')}</button><span class="hero-lab">듣기</span></div>
   .quietbar          주 단추 아래 조용한 작은 단추 줄. 안의 button / a 는 테두리·바탕 없음, 아이콘+짧은 글(lab()).
                      [aria-pressed="true"] 는 불빛 글자. 가운데 정렬, 줄바꿈 허용. 먹색 위(.stage 안)에서도 자동으로 맞춤.
                      예) <div class="quietbar"><button type="button">${lab('replay','다시')}</button><a href="…">${lab('right','다음')}</a></div>
   .scene-frame       먹색 틀 안의 장면 그림(영화 한 장면). 안에 <img> 또는 <video> 하나, 16:9 로 채움.
                      그림 위 아래쪽에 자막을 얹으려면 안에 <p class="subtitle over">…</p>.
                      그림 아래 먹색 띠로 붙이려면 .scene-frame 바로 다음에 .subtitle 을 둔다(틀과 한 덩어리로 이어짐).
   .subtitle          먹색 자막 띠. 안에 .en(큰 영어, 흰 글자) / .ko(작은 한국어, 흐린 글자). 가운데 정렬.
                      .subtitle.over = 그림 위 아래쪽 자막(반투명 먹색 바탕). .subtitle .en .hl = 불빛으로 짚는 낱말.
   .stage             종이 화면 안에 먹색 무대 덩어리를 둘 때(틀+자막+주 단추를 한 무대에). 둥근 모서리 먹색 바탕.
   .mark-ok           정답·완료 표시(불빛). 글자/아이콘에 붙인다.
   .blur-in           등장 하나: 흐릿→또렷(블러 인) 0.4초. 새로 나타나는 덩어리에 붙인다. 움직임 줄이기를 켜면 바로 끝 모습.

   움직임 기준(2026-12-01): 등장·전환은 모두 이즈 아웃(서서히 멈춤) 0.4초 하나 — var(--motion-t) var(--motion-e).
   등장은 블러 인 하나만. 녹음 중 깜빡임(hero-pulse)은 상태 표시라 그대로 둔다.
*/
:root {
  --lamp-deep: #8C5A17;
  --lamp-wash: #F6E7CF;
  --stage: var(--night); --stage-2: var(--night-2); --on-stage: var(--on-night); --on-stage-sub: var(--on-night-sub);
  --ok: var(--lamp-deep);
  --motion-t: .4s; --motion-e: var(--ease);   /* 이즈 아웃 0.4초 하나 (--ease = cubic-bezier(.2,.8,.2,1), tokens.css) */
}
@keyframes blur-in { from { opacity: 0; filter: blur(8px); } }
.blur-in { animation: blur-in var(--motion-t) var(--motion-e) both; }

/* ---------- 큰 동그라미 주 단추 ---------- */
.btn-hero { position: relative; display: inline-grid; place-items: center; width: 76px; height: 76px; padding: 0; border: 0; border-radius: 50%;
  background: var(--lamp); color: var(--lamp-ink); cursor: pointer; text-decoration: none; flex: none;
  box-shadow: 0 12px 24px -12px rgb(0 0 0 / .55);   /* 위치 있는 중립 그림자 — 색깔 빛 테두리(glow)는 쓰지 않는다 */
  transition: background-color var(--motion-t) var(--motion-e), box-shadow var(--motion-t) var(--motion-e), transform var(--motion-t) var(--motion-e); }
.btn-hero:hover { background: var(--lamp-hi); box-shadow: 0 16px 28px -12px rgb(0 0 0 / .6); }
.btn-hero:active { transform: scale(.96); }
.btn-hero .i { width: 30px; height: 30px; stroke-width: 1.9; }
.btn-hero .i path[d^="M8 5.6"], .btn-hero .i rect[width="11"] { fill: currentColor; } /* 재생·정지 모양은 채워서 */
.btn-hero.on, .btn-hero[aria-pressed="true"] { background: var(--lamp-hi); outline: 2px solid var(--lamp-hi); outline-offset: 4px; box-shadow: 0 14px 26px -12px rgb(0 0 0 / .6); }
.btn-hero.rec.on { background: var(--rec); color: #fff; outline: 2px solid var(--rec); outline-offset: 4px; box-shadow: 0 14px 26px -12px rgb(0 0 0 / .6); animation: hero-pulse 1.4s ease-in-out infinite; }
.btn-hero:disabled { opacity: .42; cursor: default; box-shadow: none; }
.btn-hero:focus-visible { outline: 2px solid var(--lamp-deep); outline-offset: 10px; }
html[data-mode="night"] .btn-hero:focus-visible, .stage .btn-hero:focus-visible { outline-color: var(--lamp); }
@keyframes hero-pulse { 50% { transform: scale(1.04); } }
.hero-act { display: inline-flex; flex-direction: column; align-items: center; gap: 12px; }
.hero-lab { font-size: 16px; font-weight: 500; line-height: 1.3; color: var(--ink-2); }
html[data-mode="night"] .hero-lab, .stage .hero-lab { color: var(--on-stage-sub); }

/* ---------- 조용한 작은 단추 줄 ---------- */
.quietbar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 6px; margin: 0; padding: 0; }
.quietbar > button, .quietbar > a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2); font-family: var(--font-ko); font-size: 16px; font-weight: 500; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--motion-t) var(--motion-e), color var(--motion-t) var(--motion-e); }
.quietbar .i { width: 18px; height: 18px; }
.quietbar > button:hover, .quietbar > a:hover { background: rgba(30, 27, 24, .05); color: var(--ink-1); }
.quietbar > [aria-pressed="true"] { color: var(--lamp-deep); }
.quietbar > [aria-pressed="true"] .i { fill: currentColor; }
.quietbar > button:disabled { opacity: .42; cursor: default; }
html[data-mode="night"] .quietbar > button, html[data-mode="night"] .quietbar > a, .stage .quietbar > button, .stage .quietbar > a { color: var(--on-stage-sub); }
html[data-mode="night"] .quietbar > button:hover, html[data-mode="night"] .quietbar > a:hover, .stage .quietbar > button:hover, .stage .quietbar > a:hover { background: rgba(238, 228, 215, .07); color: var(--on-stage); }
html[data-mode="night"] .quietbar > [aria-pressed="true"], .stage .quietbar > [aria-pressed="true"] { color: var(--lamp); }

/* ---------- 먹색 틀 안의 장면 ---------- */
.scene-frame { position: relative; margin: 0; padding: 10px; border-radius: 16px; background: var(--stage); isolation: isolate; }
.scene-frame > img, .scene-frame > video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--stage-2); }
.scene-frame::after { content: ''; position: absolute; inset: 10px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255, 244, 228, .07); pointer-events: none; }
.scene-frame + .subtitle { margin-top: -1px; border-radius: 0 0 16px 16px; }
.scene-frame:has(+ .subtitle) { border-radius: 16px 16px 0 0; padding-bottom: 0; }
.scene-frame:has(+ .subtitle)::after { bottom: 0; }

/* ---------- 자막 띠 ---------- */
.subtitle { margin: 0; padding: 18px 24px 22px; border-radius: 16px; background: var(--stage); color: var(--on-stage); text-align: center; }
.subtitle .en { display: block; font-family: var(--font-en); font-size: clamp(1.45rem, 2.6vw, 2rem); font-weight: 500; line-height: 1.3; letter-spacing: -.005em; color: var(--on-stage); }
.subtitle .ko { display: block; margin-top: 8px; font-family: var(--font-ko); font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--on-stage-sub); }
.subtitle .hl { color: var(--lamp); }
.subtitle.over { position: absolute; left: 50%; bottom: 22px; z-index: 2; width: max-content; max-width: calc(100% - 48px); transform: translateX(-50%);
  padding: 8px 16px 10px; border-radius: 8px; background: rgba(23, 20, 18, .78); }
.subtitle.over .en { font-size: clamp(1.05rem, 2vw, 1.5rem); }
.subtitle.over .ko { margin-top: 2px; font-size: 14px; }

/* ---------- 먹색 무대 덩어리 ---------- */
.stage { border-radius: 20px; background: var(--stage); color: var(--on-stage); }

/* ---------- 정답·완료 ---------- */
.mark-ok { color: var(--ok); }
html[data-mode="night"] .mark-ok, .stage .mark-ok, .subtitle .mark-ok { color: var(--lamp); }

@media (max-width: 560px) {
  .btn-hero { width: 68px; height: 68px; }
  .btn-hero .i { width: 28px; height: 28px; }
  .scene-frame { padding: 6px; border-radius: 12px; }
  .scene-frame::after { inset: 6px; border-radius: 6px; }
  .scene-frame > img, .scene-frame > video { border-radius: 6px; }
  .scene-frame + .subtitle { border-radius: 0 0 12px 12px; }
  .scene-frame:has(+ .subtitle) { border-radius: 12px 12px 0 0; }
  .subtitle { padding: 14px 16px 16px; }
  .subtitle.over { bottom: 12px; max-width: calc(100% - 24px); padding: 6px 10px 8px; }
  .quietbar { gap: 2px 0; }   /* 390 에서 단추 셋이 한 줄에 (글자 16px 그대로, 누르는 높이 44px) */
  .quietbar > button, .quietbar > a { gap: 5px; padding: 0 7px; }
}
@media (prefers-reduced-motion: reduce) { .btn-hero, .quietbar > button, .quietbar > a { transition: none; } .btn-hero.rec.on, .blur-in { animation: none; } }

/* ================= 위쪽 먹색 띠(frame) — 불빛으로 지금 단계와 진행 ================= */
.today-line { height: 3px; background: var(--night-3); }
.today-line::after { background: var(--lamp); transition: transform var(--motion-t) var(--motion-e); }
@media (prefers-reduced-motion: reduce) { .today-line::after { transition: none; } }
.bar-t small::before { background: var(--lamp); }
.steps li.on a { color: var(--lamp); }
.steps li.on .lbl { color: var(--lamp); }
.steps li.done a { color: var(--on-night); }
.steps li.done .n { background: transparent; border-color: color-mix(in srgb, var(--lamp) 45%, transparent); }
.bar .part-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--acc); }
/* PC: 여섯 칸 이름이 모두 보이게 — 폭이 모자라면(1280 미만) 단계 띠를 제목 아래 한 줄로 내린다 */
@media (min-width: 860px) and (max-width: 1279px) {
  .bar-in { grid-template-columns: auto minmax(0, 1fr); row-gap: 4px; padding-bottom: 8px; }
  .steps { grid-column: 1 / -1; flex-wrap: wrap; margin-left: -6px; }
}
/* 휴대폰: 여섯 칸은 진행 선 + 번호(14px)만, 지금 단계 이름은 그 아래 한 줄에 16px 로 하나만.
   이름은 화면 읽기 프로그램용으로 남긴다(숨김 처리만). 칸마다 누르는 높이 44px. */
@media (max-width: 859px) {
  .bar-in { padding-bottom: 10px; }
  .steps { position: relative; grid-column: 1 / -1; gap: 4px; padding-bottom: 26px; }
  .steps li { flex: 1; min-width: 0; }
  .steps a { flex-direction: column; align-items: center; justify-content: flex-start; gap: 7px; min-height: 44px; padding: 6px 0 0; border-radius: 6px; }
  .steps a::before { content: ''; align-self: stretch; height: 3px; border-radius: 2px; background: var(--night-3); }
  .steps li.done a::before { background: color-mix(in srgb, var(--lamp) 55%, var(--night)); }
  .steps li.on a::before { height: 4px; margin-top: -1px; background: var(--lamp); }
  .steps .n, .steps li.on .n, .steps li.done .n { width: auto; height: auto; border: 0; border-radius: 0; background: none; font-size: 14px; line-height: 18px; color: var(--on-night-sub); }
  .steps .n .i { width: 14px; height: 14px; vertical-align: -2px; }
  .steps li.on .n { color: var(--lamp); font-weight: 600; }
  .steps .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .steps li.on .lbl { left: 0; right: 0; bottom: 0; width: auto; height: 22px; clip: auto; font-size: 16px; line-height: 22px; color: var(--on-night); text-overflow: ellipsis; }
  .today-line { display: none; }
  /* 단계가 많은 날(1일째 9칸 등): 칸 폭이 44px 밑으로 줄지 않게 46px 이상으로 두고, 모자라면 단계 띠 안에서만 가로로 민다
     (페이지 전체는 가로로 넘치지 않음). 띠는 처음 그릴 때 늘 시작점에 있으므로, 지금 단계가 5번째 이후면
     시작점을 오른쪽 끝으로 바꿔(rtl + 순서 뒤집기 — 보이는 순서는 1→9 그대로) 지금 단계가 화면 안에 들게 한다.
     320 에서 다 보이는 칸은 5개 → 앞 1~5 / 뒤 5~9 둘 중 하나에 지금 단계가 반드시 든다. 칸이 다 들어가는 폭(768 등)에서는 모양 그대로. */
  .steps { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; }
  .steps::-webkit-scrollbar { display: none; }
  .steps li { flex: 1 0 46px; }
  .steps a:focus-visible { outline-offset: -2px; }   /* 띠가 넘침을 자르므로 초점 테두리는 칸 안쪽에 */
  .steps:has(> li.on:nth-child(n+5)) { direction: rtl; }
  .steps:has(> li.on:nth-child(n+5)) > li { direction: ltr; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(1) { order: -1; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(2) { order: -2; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(3) { order: -3; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(4) { order: -4; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(5) { order: -5; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(6) { order: -6; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(7) { order: -7; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(8) { order: -8; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(9) { order: -9; }
  .steps:has(> li.on:nth-child(n+5)) > li:nth-child(10) { order: -10; }
}
/* 건너뛴 단계(2026-12-01): 체크 대신 속이 빈 작은 원 — '다음'만 누르고 지나간 단계를 끝낸 단계와 구분한다 */
.steps li.skip a { color: var(--on-night-sub); }
.steps .ring0 { display: inline-block; width: 10px; height: 10px; border: 1.5px solid var(--on-night-sub); border-radius: 50%; box-sizing: border-box; }
@media (max-width: 859px) {
  .steps li.skip .n { width: auto; height: auto; border: 0; background: none; }
  .steps .ring0 { width: 11px; height: 11px; vertical-align: -1px; }
}

/* ================= 학습 화면 공통 틀(2026-12-01) — 단계를 넘겨도 판이 흔들리지 않게 =================
   1) 무대 폭·왼쪽 끝 하나: 모든 학습 화면의 .area 는 안쪽 폭 --stage-w(1040px), 양옆 여백 --gutter(PC 24 · 휴대폰 16).
      각 화면 CSS 는 자기 max-width 를 따로 두지 말고 var(--area-w)(.area 바깥 폭) / var(--stage-w)(그 안의 무대 상자 폭)를 쓴다.
      1440 화면에서 무대 왼쪽 끝 = 200px, 오른쪽 끝 = 1240px.
      장면 보기처럼 화면 키에 맞춰 스크린을 줄여야 하면, 무대 폭은 그대로 두고 --screen-max 로 스크린만 가운데에서 줄인다.
   2) 바탕 결 하나: 학습 화면(html[data-mode="paper"] — 이름은 예전 그대로, 지금은 어두운 상영관)도 첫 화면처럼 먹색 상영관.
      종이색 토큰(--paper · --surface · --ink-1~3 · --rule · --lamp-deep · --lamp-wash · --acc-ink)을 여기서 먹색 값으로 바꿔 끼운다.
      그래서 종이 위에 쓰던 카드·안내 줄·목록도 고칠 것 없이 먹색 결(어두운 말풍선 카드)로 바뀌고, 먹색 무대(.stage)와 바탕 사이 틈이 없다.
      장면 그림 속 흰 말풍선(.bubble)만 밝은 채로 둔다(--ink 는 바꾸지 않음).
   3) 글꼴 역할(토큰): --font-title 제목(고운바탕) · --font-en 영어 · --font-read 우리말 뜻(명조) · --font-ui 화면 글(고딕).
      고운바탕은 400 하나만 있어(700 은 굵기 600 상한을 넘음) 먹색 위 제목은 --title-stroke(글자 테두리 0.02em)로 반 단계 굵게,
      자간 --title-track. 학습 화면 제목은 .t-title 을 붙이거나 아래 목록에 넣는다. */
:root {
  --stage-w: 1040px; --gutter: 24px; --area-w: calc(var(--stage-w) + var(--gutter) * 2);
  --font-read: var(--font-serif); --font-ui: var(--font-ko);
  --title-stroke: .02em; --title-track: -.015em;
}
@media (max-width: 560px) { :root { --gutter: 16px; } }

/* 장면 스크린을 화면 키에 맞춰 줄일 때: 무대(왼쪽 끝·폭)는 그대로, 스크린만 가운데 */
.stage .screen { max-width: var(--screen-max, none); margin-inline: auto; }

/* ---------- 학습 화면 = 어두운 상영관 ---------- */
html[data-mode="paper"] {
  color-scheme: dark;
  --paper: var(--night); --paper-2: var(--night-2); --surface: var(--night-2);
  --ink-1: var(--on-night); --ink-2: var(--on-night-sub); --ink-3: #91887D;   /* 먹색 위 흐린 글자도 대비 4.5 이상 */
  --rule: var(--night-line); --rule-2: rgba(238, 228, 215, .22);
  --lamp-deep: var(--lamp); --lamp-wash: color-mix(in srgb, var(--lamp) 14%, var(--night));
  --soft: none;
}
html[data-mode="paper"] .view { --acc-ink: color-mix(in oklab, var(--acc) 72%, #fff); }
html[data-mode="paper"] .bar { box-shadow: 0 1px 0 var(--night-line); }
/* 종이 위 전제로 색을 박아 둔 공통 부품만 먹색 위 값으로 */
html[data-mode="paper"] .btn.solid { background: var(--on-night); color: var(--night); }
html[data-mode="paper"] .btn.solid:hover { background: #fff; }
html[data-mode="paper"] .btn.line { background: transparent; border-color: var(--night-line); color: var(--on-night); }
html[data-mode="paper"] .btn.line:hover { border-color: var(--on-night-dim); }
html[data-mode="paper"] .btn.quiet:hover, html[data-mode="paper"] .quietbar > button:hover, html[data-mode="paper"] .quietbar > a:hover { background: rgba(238, 228, 215, .07); color: var(--on-night); }
html[data-mode="paper"] .quietbar > button, html[data-mode="paper"] .quietbar > a { color: var(--on-night-sub); }
html[data-mode="paper"] .quietbar > [aria-pressed="true"] { color: var(--lamp); }
html[data-mode="paper"] .seg { background: rgba(238, 228, 215, .08); }
html[data-mode="paper"] .seg button { color: var(--on-night-sub); }
html[data-mode="paper"] .seg button[aria-pressed="true"] { background: rgba(238, 228, 215, .16); color: var(--on-night); box-shadow: none; }
html[data-mode="paper"] .ring.say, html[data-mode="paper"] .pass.first.cur > span { border-color: var(--lamp); background: color-mix(in srgb, var(--lamp) 14%, transparent); color: var(--lamp); }
html[data-mode="paper"] .hero-lab { color: var(--on-night-sub); }
html[data-mode="paper"] .btn-hero:focus-visible { outline-color: var(--lamp); }
html[data-mode="paper"] :focus-visible { outline-color: var(--lamp); }

/* ---------- 학습 화면 제목: 먹색 위 고운바탕에 힘을 ---------- */
.t-title, :where(html[data-mode="paper"]) :where(.sc-t, .rc-t, .rc-card-t, .end-t, .ctitle, .ad-dhead h1) {
  font-family: var(--font-title); font-weight: 400; letter-spacing: var(--title-track);
  -webkit-text-stroke: var(--title-stroke) currentColor; paint-order: stroke fill;
}

/* ================= 이어지는 이야기(2026-12-01, data/story.json · 영어만 · 소리 없음) =================
   세 곳 모두 같은 결: 등불색 작은 이름표(.st-k) + 영어 글(.en). 새 색 없이 상영관 토큰만.
   1) 지난 이야기 카드(#/d/N/story): 하루 첫 단계 앞 한 장. 영화 앞 자막처럼 가운데, 고운바탕 큰 글, 진한 단추 하나.
   2) 오늘의 상황(.story-setup): 장면 무대 맨 위(스크린 바로 위). 마무리 날은 장면 다시 보기 위 한 줄(.solo).
   3) 다음 이야기(.story-next): 하루 끝 화면 맨 아래(a-check.css). */
.story-card { max-width: 46rem; margin: 24px auto 0; padding: 64px 48px 48px; text-align: center; }
.st-k { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: .14em; color: var(--lamp); }
.story-card .st-prev { margin: 20px auto 0; max-width: 34ch; font-family: var(--font-title); font-weight: 400; font-size: clamp(1.4rem, 2.6vw, 1.95rem); line-height: 1.5; letter-spacing: -.005em; color: var(--on-stage);
  -webkit-text-stroke: var(--title-stroke) currentColor; paint-order: stroke fill; text-wrap: pretty; }
.story-card .st-act { display: flex; justify-content: center; margin-top: 40px; }
.story-card .st-act .btn.lamp .i { width: 20px; height: 20px; fill: none; stroke-width: 1.9; }
.story-setup { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.story-setup .en { font-family: var(--font-en); font-size: 18px; font-weight: 400; line-height: 1.5; color: var(--on-stage); text-wrap: pretty; }
.story-setup.solo { max-width: var(--stage-w); margin: 0 auto 8px; padding: 0 8px; }   /* 장면 다시 보기 글 왼쪽 끝(8px 안)에 맞춤 */
@media (max-width: 560px) {
  .story-card { margin-top: 8px; padding: 44px 22px 32px; }
  .story-card .st-act { margin-top: 32px; }
  .story-setup .en { font-size: 17px; }
  .story-setup.solo { padding: 0; margin-bottom: 20px; }
}
