/* ============================================================
   경제 탐험대 — 유자 마을 이야기 층 (P4-B · 디자인 시스템 v4 「햇살 든 유자」)

   js/story.js 가 그리는 이야기 화면(?story=1). 체험 무대와 같은 틀 — 캔버스 위 미색 카드 한 장.
   - 접두는 ec-st- 만. yj- 는 DS 이름공간이라 있는 것(yj-btn · yj-seg · yj-tag)만 빌린다.
   - 색·그림자·모서리·움직임·간격은 토큰 이름으로만. HEX 를 적지 않는다.
   - 고른 것 = 유자 200 면 + 600 테두리 · 열쇠 조각 = 유자 100 칸 + 먹 선. 원색 유자는 진행 막대에만.
   - 전자칠판(.ec-st--tv, ?story=1&tv=1): 글자 28px 이상, 선택지를 크게.
   ============================================================ */

.ec-st {
  --ec-st-text: 19px;
  --ec-st-body: var(--yj-t-body);
  --ec-st-h: 24px;
  --ec-st-choice-h: 64px;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--yj-canvas);
  color: var(--yj-ink);
  font-family: var(--yj-font-ui);
  font-size: var(--ec-st-body);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
}
.ec-st *, .ec-st *::before, .ec-st *::after { box-sizing: border-box; }
.ec-st :focus-visible { outline: 2px solid var(--yj-yuja-600); outline-offset: 2px; }
.ec-st-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── 헤더 56 — 왼쪽 위 장 제목 · 장소 ───────────────── */
.ec-st-bar {
  position: sticky; top: 0; z-index: 5; flex: none;
  display: flex; align-items: center; gap: var(--yj-s2);
  height: 56px;
  padding: 0 var(--yj-s2);
  padding-top: var(--yj-safe-t);
  box-sizing: content-box;
  background: var(--yj-card);
  border-bottom: 1px solid var(--yj-line);
}
.ec-st-bar__btn { flex: none; }
.ec-st-bar__title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: var(--yj-s2); }
.ec-st-bar__ch { flex: none; font-size: var(--yj-t-label); font-weight: 700; letter-spacing: .04em; color: var(--yj-yuja-ink); }
.ec-st-bar__grade { flex: none; align-self: center; }   /* 6~8장 — 5~6학년 이야기 표지(연계 규약 R11) */
.ec-st-bar__name {
  min-width: 0; font-family: var(--yj-font-serif); font-size: 18px; font-weight: 600; color: var(--yj-ink-deep);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ec-st-bar__place {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--yj-t-small); font-weight: 600; color: var(--yj-sub); white-space: nowrap;
}
.ec-st-bar__menu { flex: none; }
.ec-st-bar__track { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; }
.ec-st-bar__fill {
  height: 100%; background: var(--yj-yuja-500);
  transform-origin: left center;
  transition: transform var(--yj-m-slow) var(--yj-ease);
}
@media (max-width: 560px) {
  .ec-st-bar__place { display: none; }
}

/* ── 위 줄 — 열쇠 조각 8칸 · 가진 것 ─────────────────── */
.ec-st-top {
  width: 100%; max-width: 760px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--yj-s2) var(--yj-s4);
  padding: var(--yj-s3) var(--yj-s4) 0;
}
.ec-st-top__me { display: inline-flex; align-items: center; gap: var(--yj-s3); }
.ec-st-keys { display: inline-flex; align-items: center; gap: var(--yj-s2); }
.ec-st-keys svg { display: block; width: 240px; height: 30px; overflow: visible; }
.ec-st-keys--big { display: flex; }
.ec-st-keys--big svg { width: min(100%, 432px); height: auto; aspect-ratio: 8 / 1; }
.ec-st-keys__n { font-size: var(--yj-t-small); font-weight: 700; color: var(--yj-sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ec-st-key__cell { fill: var(--yj-card); stroke: var(--yj-line); stroke-width: 1; }
.ec-st-key__seg { stroke: var(--yj-line-strong); stroke-width: 1.6; stroke-dasharray: 2 3; }
.ec-st-key.is-got .ec-st-key__cell { fill: var(--yj-yuja-100); stroke: var(--yj-yuja-600); }
.ec-st-key.is-got .ec-st-key__seg { stroke: var(--yj-ink-deep); stroke-width: 2.4; stroke-dasharray: none; }
.ec-st-keys.is-whole .ec-st-key__cell { fill: var(--yj-yuja-200); }
.ec-st-key { transform-box: fill-box; transform-origin: center; }
.ec-st-key.is-new { animation: ec-st-pop var(--yj-m-slow) var(--yj-ease) both; }
.ec-st-key.is-new .ec-st-key__seg { animation: ec-st-draw var(--yj-m-slow) var(--yj-ease) both; }
@keyframes ec-st-pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes ec-st-draw { 0% { stroke-width: 0; } 100% { stroke-width: 2.4; } }

.ec-st-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.ec-st-stat {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 12px; border-radius: var(--yj-r-full);
  background: var(--yj-card); border: 1px solid var(--yj-line);
  font-size: var(--yj-t-small); color: var(--yj-ink);
}
.ec-st-stat__k { color: var(--yj-sub); font-weight: 600; }
.ec-st-stat strong { font-weight: 700; color: var(--yj-ink-deep); font-variant-numeric: tabular-nums; }
.ec-st-stat__d { font-size: var(--yj-t-cap); font-weight: 700; }
.ec-st-stat.is-up .ec-st-stat__d { color: var(--yj-leaf-ink); }
.ec-st-stat.is-down .ec-st-stat__d { color: var(--yj-orange-ink); }
.ec-st-stat--items { max-width: 100%; }
.ec-st-items { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 본문 카드 ───────────────────────────────────────── */
.ec-st-main { flex: 1; padding: var(--yj-s3) var(--yj-s4) calc(var(--yj-s6) + var(--yj-safe-b)); }
.ec-st-card {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: var(--yj-s5);
  background: var(--yj-card);
  border: 1px solid var(--yj-line);
  border-radius: var(--yj-r-lg);
  box-shadow: var(--yj-sh-1);
  outline: none;
  opacity: 0; transform: translateY(4px);
  transition: opacity var(--yj-m-mid) var(--yj-ease), transform var(--yj-m-mid) var(--yj-ease);
}
.ec-st-card.is-in { opacity: 1; transform: none; }
.ec-st-card > div { display: flex; flex-direction: column; gap: var(--yj-s4); }
@media (min-width: 720px) {
  .ec-st-card { padding: var(--yj-s6); }
}
@media (prefers-reduced-motion: reduce) {
  .ec-st-card, .ec-st-bar__fill { transition: none; }
  .ec-st-key.is-new, .ec-st-key.is-new .ec-st-key__seg { animation: none; }
}

/* ── 글자 ─────────────────────────────────────────────── */
.ec-st-label { margin: 0; font-size: var(--yj-t-label); font-weight: 700; letter-spacing: .04em; color: var(--yj-yuja-ink); }
.ec-st-h {
  margin: 0; display: flex; align-items: center; gap: var(--yj-s3); flex-wrap: wrap;
  font-family: var(--yj-font-serif); font-size: var(--ec-st-h); font-weight: 600;
  line-height: 1.4; letter-spacing: -.03em; color: var(--yj-ink-deep);
}
.ec-st-h--xl { font-size: clamp(26px, 4vw, 32px); }
.ec-st-sub { margin: 0; font-family: var(--yj-font-serif); font-size: var(--yj-t-body); font-weight: 600; color: var(--yj-ink-deep); }
.ec-st-text { margin: 0; font-size: var(--ec-st-text); line-height: 1.8; color: var(--yj-ink-deep); }
.ec-st-scene.is-narr .ec-st-text { font-family: var(--yj-font-serif); }
.ec-st-scene.is-npc .ec-st-text {
  padding: var(--yj-s3) var(--yj-s4);
  background: var(--yj-yuja-50); border-radius: var(--yj-r-sm);
  border-left: 2px solid var(--yj-yuja-500);
}
.ec-st-ask { margin: 0; font-weight: 700; color: var(--yj-ink-deep); font-size: var(--ec-st-body); }
.ec-st-note { margin: 0; font-size: var(--ec-st-body); color: var(--yj-sub); }
.ec-st-msg { margin: 0; min-height: 1.6em; font-size: var(--ec-st-body); color: var(--yj-ink); }
.ec-st-say { margin: 0; font-size: var(--ec-st-body); line-height: 1.75; color: var(--yj-ink-deep); }

/* 말하는 사람 — 색 + 동물 선 그림 */
.ec-st-who { display: flex; align-items: center; gap: var(--yj-s3); }
.ec-st-who__name { font-weight: 700; color: var(--yj-ink-deep); }
.ec-st-av {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: var(--yj-r-full);
  border: 1px solid var(--yj-line-strong); color: var(--yj-ink-deep);
  background: var(--yj-canvas);
}
.ec-st-av--lg { width: 88px; height: 88px; }
.ec-st-av--sm { width: 32px; height: 32px; }
.ec-st-av--yuja { background: var(--yj-yuja-200); }
.ec-st-av--cream { background: var(--yj-yuja-100); }
.ec-st-av--leaf { background: var(--yj-leaf-tint); }
.ec-st-av--orange { background: var(--yj-orange-tint); }
.ec-st-av--rose { background: var(--yj-book-tint); }
.ec-st-av--sand { background: var(--yj-canvas); }

.ec-st-extra {
  margin: 0; padding: var(--yj-s3) var(--yj-s4); list-style: none;
  display: flex; flex-wrap: wrap; gap: var(--yj-s2) var(--yj-s4);
  background: var(--yj-canvas); border-radius: var(--yj-r-sm);
  font-weight: 600; color: var(--yj-ink-deep);
}

/* ── 선택지 (숫자 키) ─────────────────────────────────── */
.ec-st-choices { display: grid; gap: var(--yj-s3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) {
  .ec-st-choices--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ec-st-choices--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.ec-st-choice {
  display: flex; align-items: center; gap: var(--yj-s3);
  min-height: var(--ec-st-choice-h);
  padding: var(--yj-s3) var(--yj-s4);
  font: inherit; font-size: var(--ec-st-body); text-align: left; color: var(--yj-ink-deep);
  background: var(--yj-card); border: 1px solid var(--yj-line-strong); border-radius: var(--yj-r-lg);
  cursor: pointer;
  transition: background-color var(--yj-m-fast) var(--yj-ease), border-color var(--yj-m-fast) var(--yj-ease), transform var(--yj-m-fast) var(--yj-ease);
}
.ec-st-choice:hover:not(:disabled) { background: var(--yj-yuja-50); border-color: var(--yj-yuja-600); }
.ec-st-choice:active:not(:disabled) { transform: scale(.98); }
.ec-st-choice:disabled { cursor: default; }
.ec-st-choice.is-picked { background: var(--yj-yuja-200); border-color: var(--yj-yuja-600); box-shadow: inset 0 0 0 1px var(--yj-yuja-600); }
.ec-st-choice.is-gaveup { color: var(--yj-sub); border-style: dashed; background: transparent; }
.ec-st-choice__n {
  flex: none; width: 28px; height: 28px; border-radius: var(--yj-r-full);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--yj-t-cap); font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--yj-canvas); color: var(--yj-sub);
}
.ec-st-choice.is-picked .ec-st-choice__n { background: var(--yj-yuja-500); color: var(--yj-on-action); }
.ec-st-choice__t { min-width: 0; }

/* 포기한 것 — 고른 뒤 반드시 보이는 라벨 */
.ec-st-after { display: flex; flex-direction: column; gap: var(--yj-s3); }
.ec-st-after[hidden] { display: none; }
.ec-st-gaveup {
  margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--yj-s2);
  padding: var(--yj-s3) var(--yj-s4);
  border: 1px dashed var(--yj-line-strong); border-radius: var(--yj-r-sm);
  font-size: var(--ec-st-body); color: var(--yj-ink);
}
.ec-st-gaveup__k {
  flex: none; padding: 2px 10px; border-radius: var(--yj-r-full);
  background: var(--yj-orange-tint); color: var(--yj-orange-ink);
  font-size: var(--yj-t-cap); font-weight: 700;
}

/* ── 아래 줄 단추 ─────────────────────────────────────── */
.ec-st-actions {
  display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center;
  gap: var(--yj-s2); margin-top: var(--yj-s2);
}
.ec-st-actions .yj-btn--primary { min-width: 160px; }
.ec-st-actions .ec-ic { flex: none; }
.ec-st-actions a.yj-btn { text-decoration: none; }

/* ── 마을 일(체험) 카드 ───────────────────────────────── */
.ec-st-job {
  display: flex; align-items: center; gap: var(--yj-s4);
  padding: var(--yj-s4);
  border: 1px solid var(--yj-yuja-600); border-radius: var(--yj-r-lg);
  background: var(--yj-yuja-100);
}
.ec-st-job.is-soon { border: 1px dashed var(--yj-line-strong); background: var(--yj-canvas); }
.ec-st-job__ic {
  flex: none; width: 56px; height: 56px; border-radius: var(--yj-r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--yj-card); color: var(--yj-yuja-ink);
}
.ec-st-job.is-soon .ec-st-job__ic { color: var(--yj-sub); }
.ec-st-job__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ec-st-job__k { font-size: var(--yj-t-label); font-weight: 700; letter-spacing: .04em; color: var(--yj-yuja-ink); }
.ec-st-job.is-soon .ec-st-job__k { color: var(--yj-sub); }
.ec-st-job__name { font-family: var(--yj-font-serif); font-size: 20px; font-weight: 600; color: var(--yj-ink-deep); }
.ec-st-job__meta { font-size: var(--ec-st-body); color: var(--yj-sub); }

/* ── 장 끝 · 결말 ─────────────────────────────────────── */
.ec-st-recap { display: flex; flex-direction: column; gap: var(--yj-s2); }
.ec-st-recap ul, .ec-st-walk { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--yj-s2); }
.ec-st-recap li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--yj-s3);
  padding: var(--yj-s2) var(--yj-s3);
  background: var(--yj-canvas); border-radius: var(--yj-r-sm);
}
.ec-st-recap__pick { font-weight: 700; color: var(--yj-ink-deep); }
.ec-st-recap__gave { display: inline-flex; align-items: baseline; gap: var(--yj-s2); color: var(--yj-ink); }
.ec-st-walk { counter-reset: ec-st-walk; }
.ec-st-walk li { counter-increment: ec-st-walk; color: var(--yj-ink-deep); }
.ec-st-walk li::before {
  content: counter(ec-st-walk); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: var(--yj-r-full);
  background: var(--yj-yuja-200); color: var(--yj-ink-deep);
  font-size: var(--yj-t-cap); font-weight: 700;
}
.ec-st-ending .ec-st-h .ec-st-av, .ec-st-done .ec-st-h .ec-st-av { width: 56px; height: 56px; }

/* ── 메뉴 ─────────────────────────────────────────────── */
.ec-st-resume {
  display: flex; align-items: center; gap: var(--yj-s3);
  padding: var(--yj-s3) var(--yj-s4);
  background: var(--yj-yuja-50); border-radius: var(--yj-r-sm);
}
.ec-st-resume p { margin: 0; font-weight: 600; color: var(--yj-ink-deep); }
.ec-st-confirm {
  display: flex; flex-direction: column; gap: var(--yj-s2);
  padding: var(--yj-s4); border: 1px solid var(--yj-line-strong); border-radius: var(--yj-r-sm);
}
.ec-st-confirm[hidden] { display: none; }
.ec-st-confirm p { margin: 0; color: var(--yj-ink-deep); }
.ec-st-grade { display: flex; flex-wrap: wrap; align-items: center; gap: var(--yj-s2) var(--yj-s3); }
.ec-st-grade__k { font-size: var(--yj-t-small); font-weight: 600; color: var(--yj-sub); }
.ec-st-grade__note { font-size: var(--yj-t-small); color: var(--yj-sub); }
.ec-st-grade .yj-seg > * {
  position: relative; height: 44px; padding: 0 16px;
  font: inherit; font-size: var(--yj-t-small); border: 0; background: transparent; cursor: pointer; color: var(--yj-ink);
  border-radius: var(--yj-r-full);
}
.ec-st-grade .yj-seg > .is-on { background: var(--yj-yuja-200); box-shadow: inset 0 0 0 1px var(--yj-yuja-600); color: var(--yj-ink-deep); font-weight: 700; }
.ec-st-chaps { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--yj-s2); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .ec-st-chaps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ec-st-chap {
  width: 100%; min-height: 64px;
  display: flex; align-items: center; gap: var(--yj-s3);
  padding: var(--yj-s3) var(--yj-s4);
  font: inherit; text-align: left; color: var(--yj-ink-deep);
  background: var(--yj-card); border: 1px solid var(--yj-line-strong); border-radius: var(--yj-r-sm);
  cursor: pointer;
  transition: background-color var(--yj-m-fast) var(--yj-ease), border-color var(--yj-m-fast) var(--yj-ease);
}
.ec-st-chap:hover { background: var(--yj-yuja-50); border-color: var(--yj-yuja-600); }
.ec-st-chap__n { flex: none; width: 40px; font-weight: 700; color: var(--yj-yuja-ink); font-variant-numeric: tabular-nums; }
.ec-st-chap__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ec-st-chap__name { font-family: var(--yj-font-serif); font-weight: 600; }
.ec-st-chap__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--yj-t-small); color: var(--yj-sub); }
.ec-st-chap__key { flex: none; width: 28px; display: inline-flex; justify-content: center; color: var(--yj-ink-deep); }
.ec-st-chap.is-got .ec-st-chap__key { color: var(--yj-yuja-ink); }

/* ── 아바타 고르기 ────────────────────────────────────── */
.ec-st-pick__me { display: flex; justify-content: center; }
.ec-st-opts { display: grid; gap: var(--yj-s2); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 560px) { .ec-st-opts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ec-st-opt {
  min-height: 56px;
  display: flex; align-items: center; gap: var(--yj-s2);
  padding: var(--yj-s2) var(--yj-s3);
  font: inherit; color: var(--yj-ink-deep);
  background: var(--yj-card); border: 1px solid var(--yj-line-strong); border-radius: var(--yj-r-sm);
  cursor: pointer;
}
.ec-st-opt:hover { background: var(--yj-yuja-50); }
.ec-st-opt.is-on { background: var(--yj-yuja-200); border-color: var(--yj-yuja-600); box-shadow: inset 0 0 0 1px var(--yj-yuja-600); font-weight: 700; }
.ec-st-swatch { flex: none; width: 28px; height: 28px; border-radius: var(--yj-r-full); border: 1px solid var(--yj-line-strong); }

/* ══ 전자칠판 모드 (?story=1&tv=1) — 글자 28 이상 · 선택지 크게 ══ */
.ec-st--tv {
  --ec-st-text: 34px;
  --ec-st-body: 30px;
  --ec-st-h: 44px;
  --ec-st-choice-h: 120px;
}
.ec-st--tv .ec-st-card, .ec-st--tv .ec-st-top { max-width: 1600px; }
.ec-st--tv .ec-st-card { padding: var(--yj-s6) var(--yj-s7); }
.ec-st--tv .ec-st-bar__name, .ec-st--tv .ec-st-bar__ch, .ec-st--tv .ec-st-bar__place,
.ec-st--tv .ec-st-label, .ec-st--tv .ec-st-stat, .ec-st--tv .ec-st-stat__d, .ec-st--tv .ec-st-keys__n,
.ec-st--tv .ec-st-gaveup__k, .ec-st--tv .ec-st-job__k, .ec-st--tv .ec-st-chap__meta, .ec-st--tv .yj-tag,
.ec-st--tv .ec-st-grade__k, .ec-st--tv .ec-st-grade__note, .ec-st--tv .ec-st-grade .yj-seg > *,
.ec-st--tv .ec-st-sub, .ec-st--tv .ec-st-chap, .ec-st--tv .ec-st-opt, .ec-st--tv .ec-st-who__name { font-size: 28px; }
.ec-st--tv .ec-st-job__name { font-size: 34px; }
.ec-st--tv .ec-st-choices--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ec-st--tv .ec-st-choices--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ec-st--tv .ec-st-choice__n { width: 48px; height: 48px; font-size: 28px; }
.ec-st--tv .ec-st-keys svg { width: 384px; height: 48px; }
.ec-st--tv .ec-st-top__me .ec-st-av { width: 56px; height: 56px; }
.ec-st--tv .ec-st-keys--big svg { width: min(100%, 768px); height: auto; }
.ec-st--tv .ec-st-av { width: 72px; height: 72px; }
.ec-st--tv .ec-st-av svg { width: 48px; height: 48px; }
.ec-st--tv .yj-btn { height: 72px; font-size: 28px; padding: 0 36px; }
.ec-st--tv .yj-btn--icon { width: 56px; height: 56px; padding: 0; }
.ec-st--tv .ec-st-bar .yj-btn { height: 48px; padding: 0 16px; }
.ec-st--tv .ec-st-bar .yj-btn--icon { width: 48px; padding: 0; }
.ec-st--tv .ec-st-grade .yj-seg > * { height: 56px; }

@media print {
  .ec-st-bar, .ec-st-actions { display: none !important; }
  .ec-st, .ec-st-card { background: none; box-shadow: none; }
}
