/* 짬짬이 그림책 — 전자칠판 8~9m 거리 기준.
   읽기 화면 글은 그림 폭에 맞춰 커집니다(1920 폭에서 약 50px, PRD 5장 '본문 최소 40px 상당').
   글자 크기는 화면(vw)이 아니라 그림(cqw) 기준입니다 — 4:3 화면에서 그림이 작아지면 글도 같이 작아져야 띠가 그림 밖으로 넘치지 않습니다. */

:root {
  --brand: #6A9A1F;        /* 풀빛 — 2026-11-14 퀴즈 초록 #12A57C 등 가족 색과 나란히 보고 확정(PRD 12장 8단계) */
  --brand-deep: #4E7614;
  --brand-pale: #EEF5DF;
  --go: #3F6212;           /* 누르는 단추. 흰 글자 대비 7:1 */
  --ink: #1F2A16;
  --dim: #5E6B52;
  --bg: #F6F3E8;
  --card: #FFFFFF;
  --line: #DCD8C6;
  --paper: 255, 252, 240;  /* 글 띠 — 크림색 종이 */
}

@font-face {
  font-family: 'Pretendard Variable';
  font-style: normal;
  font-weight: 45 920;
  font-display: swap;
  src: url('../assets/fonts/PretendardVariable.subset.woff2') format('woff2-variations');
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", "Pretendard", "Malgun Gothic", -apple-system, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- 상단바 (그리기 css 와 같은 틀, 띠 색만 다름) */
:root { --wrap: 1180px; --gutter: 32px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: var(--wrap); margin: 0 auto; padding: 0.9rem var(--gutter);
  background: var(--brand);
  box-shadow: 0 10px 24px rgba(52, 78, 12, 0.22);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: #fff; letter-spacing: -0.01em; }
.brand-icon { width: 46px; height: 46px; display: inline-flex; flex: none; }
.brand-icon img { width: 46px; height: 46px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 1.45rem; font-weight: 900; color: #fff; }
.brand-sub { font-size: 0.8rem; font-weight: 600; color: #F1F8E2; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; flex: none; }
.topbar .icon-btn {
  width: 3rem; height: 3rem; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-pale); color: var(--brand-deep);
  border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 12px;
}
.topbar .icon-btn svg { width: 1.6rem; height: 1.6rem; }
.topbar .icon-btn:hover { background: #fff; }
.topbar .icon-btn:focus-visible { outline: 3px solid #FFD34D; outline-offset: 2px; }

@media (max-width: 640px) { :root { --gutter: 20px; } }
@media (min-width: 1600px) {
  html { font-size: 23px; }
  :root { --wrap: 1560px; --gutter: 40px; }
}

/* ---------------------------------------------------------------- 서가 */
.shelf { padding: 0 var(--gutter) 8vh; max-width: var(--wrap); margin: 0 auto; }
.cta-strip {
  background: var(--card); border-bottom: 1px solid var(--line);
  margin: 0 calc(-1 * var(--gutter)) 3vh; padding: 0.85rem var(--gutter);
}
.cta-copy { margin: 0; font-size: 0.95rem; font-weight: 600; color: #4A5340; }
.cta-copy b { color: var(--brand-deep); font-weight: 900; }

.grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.book {
  width: 100%; display: block; text-align: left; position: relative;
  background: var(--card); border: 2px solid var(--line); border-radius: 18px;
  padding: 10px 10px 14px;
}
.book:hover { border-color: var(--brand); }
.book:focus-visible { outline: 4px solid var(--brand); outline-offset: 3px; }
.book img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-radius: 10px; background: var(--brand-pale); }
.book .name { font-size: clamp(19px, 1.5vw, 26px); font-weight: 800; margin: 10px 4px 2px; }
.book .facts { font-size: clamp(14px, 1.1vw, 19px); color: var(--dim); font-weight: 600; margin: 0 4px; }
.book .stamp {
  position: absolute; top: 18px; right: 18px; transform: rotate(-8deg);
  border: 3px solid #C2410C; color: #C2410C; background: rgba(255, 255, 255, .85);
  font-weight: 900; font-size: 15px; padding: .1em .5em; border-radius: 8px;
}
/* 오늘의 그림책 */
.today {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--card); border: 2px solid var(--brand); border-radius: 18px;
  padding: 12px 18px 12px 12px; margin: 0 0 18px;
}
.today img { width: clamp(150px, 16vw, 260px); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--brand-pale); }
.today-text { flex: 1 1 220px; min-width: 0; }
.today-text p { margin: 0; }
.today-kicker { font-size: clamp(14px, 1.05vw, 19px); font-weight: 800; color: var(--brand-deep); }
.today-title { font-size: clamp(22px, 1.9vw, 34px); font-weight: 900; letter-spacing: -.02em; }
.today-facts { font-size: clamp(14px, 1.05vw, 19px); color: var(--dim); font-weight: 600; }

/* 필터 */
.filters { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 0 0 20px; }
.filter { display: flex; align-items: center; gap: 10px; }
.filter .opt-name { min-width: 0; }
.filter .seg button { font-size: clamp(15px, 1.05vw, 19px); padding: .45em .8em; }
.empty { font-size: 1.05rem; color: var(--dim); font-weight: 600; margin: 2vh 0; }
.link-btn { border: 0; background: none; padding: 0 .3em; font: inherit; color: var(--brand-deep); text-decoration: underline; cursor: pointer; }

.site-footer { margin-top: 6vh; padding-top: 2vh; border-top: 1px solid var(--line); color: var(--dim); font-size: 0.9rem; }
.site-footer p { margin: 0.3em 0; }
.site-footer .credit { font-size: 0.75rem; }

/* ---------------------------------------------------------------- 표지 */
.cover {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 2.5vw; padding: 3vh 2.5vw; max-width: 1900px; margin: 0 auto; align-items: center;
}
.cover-pic img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  border-radius: 22px; box-shadow: 0 6px 0 var(--line); background: var(--brand-pale);
}
.side { display: flex; flex-direction: column; gap: 1.4vh; min-width: 0; }
.kicker { font-size: clamp(16px, 1.2vw, 22px); font-weight: 700; color: var(--brand-deep); margin: 0; }
.side h2 { font-size: clamp(34px, 3.2vw, 62px); margin: 0; letter-spacing: -.02em; }
.blurb { font-size: clamp(18px, 1.5vw, 28px); font-weight: 600; color: var(--dim); margin: 0; word-break: keep-all; }

.options { display: flex; flex-direction: column; gap: 10px; margin: 1.2vh 0 .4vh; }
.opt { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.opt-name { font-size: clamp(16px, 1.2vw, 22px); font-weight: 700; min-width: 5em; }
.mode-note { margin: 0 0 .4vh; font-size: clamp(15px, 1.1vw, 20px); color: var(--dim); font-weight: 600; word-break: keep-all; }

.seg { display: inline-flex; flex-wrap: wrap; border: 2px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); }
.seg button {
  border: 0; background: transparent; padding: .55em .9em;
  font-size: clamp(16px, 1.2vw, 22px); font-weight: 700; color: var(--dim);
}
.seg button[aria-pressed="true"] { background: var(--go); color: #fff; }
.seg button:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }

.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 1.2vh; }
.btn {
  border: 2px solid var(--line); background: var(--card); border-radius: 14px;
  padding: .6em .9em; font-size: clamp(16px, 1.2vw, 22px); font-weight: 700;
  display: inline-flex; align-items: center; gap: .5em;
}
.btn:hover { border-color: var(--ink); }
.btn:focus-visible { outline: 4px solid var(--brand); outline-offset: 3px; }
.btn-go { background: var(--go); border-color: var(--go); color: #fff; }
.btn-go:hover { background: #33500e; border-color: #33500e; }
.btn-quiet { color: var(--dim); }
.btn-big { padding: .75em 1.4em; font-size: clamp(20px, 1.6vw, 30px); }
.credit { font-size: clamp(13px, .95vw, 16px); color: var(--dim); margin: .6vh 0 0; }
.offline { font-size: clamp(14px, 1vw, 18px); color: var(--dim); font-weight: 600; margin: .4vh 0 0; }
.offline .link-btn { font-weight: 700; }
.offline .link-btn[disabled] { text-decoration: none; color: var(--dim); cursor: default; }
kbd {
  font: inherit; font-size: .75em; font-weight: 700; opacity: .7;
  border: 1.5px solid currentColor; border-radius: 6px; padding: 0 .35em;
}

@media (max-width: 900px) {
  .cover { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- 읽기 */
.read {
  position: fixed; inset: 0; background: #14170F;
  display: grid; place-items: center; overflow: hidden;
}
.read:not(.show-controls) { cursor: none; }

/* 16:9 무대 — 16:9 화면에서는 화면 가득, 다른 비율에서는 위아래(또는 좌우)에 검은 여백 */
.stage {
  position: relative; overflow: hidden;
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  container-type: inline-size;
}
.pic {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .45s ease;   /* 넘김은 가벼운 페이드만(PRD 9장) */
}
.pic.on { opacity: 1; }

/* 글 띠 — 높이는 글 줄 수만큼. 한 줄에 한 문장 */
.band {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1.1cqw 5cqw 1.5cqw;
  background: rgba(var(--paper), .87);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, .06);
}
.lines {
  margin: 0; display: flex; flex-direction: column; align-items: center; gap: .1em;
  text-align: center; word-break: keep-all; line-height: 1.36;
  font-size: 2.6vw; font-size: 2.6cqw;
}
.line { font-weight: 560; transition: opacity .2s; }
/* 지금 읽는 문장을 굵게(PRD F3). 나머지는 살짝 흐리게 해 멀리서도 어디를 읽는지 보이게 합니다 */
.lines.speaking .line { opacity: .62; }
.lines.speaking .line.now { opacity: 1; font-weight: 820; }
.band.title .lines { font-size: 4.4vw; font-size: 4.4cqw; }
.band.title .line { font-weight: 860; }
.read.teacher .lines { font-size: 3.2vw; font-size: 3.2cqw; }   /* 선생님이 읽기 — 글은 크게(PRD 4.1) */
.read.teacher .line { font-weight: 640; }

/* 진행 점 — 오른쪽 아래, 작게 */
.dots {
  position: absolute; right: 1.4cqw; bottom: 1cqw; margin: 0; padding: 0;
  list-style: none; display: flex; gap: .45cqw;
}
.dots li {
  width: .62cqw; height: .62cqw; border-radius: 50%;
  background: rgba(31, 42, 22, .22); box-shadow: 0 0 0 1px rgba(255, 255, 255, .7);
}
.dots li.on { background: var(--brand-deep); }

.state, .toast {
  position: absolute; top: 1.4cqw; margin: 0;
  background: rgba(20, 23, 15, .78); color: #fff; font-weight: 700;
  font-size: 1.5cqw; padding: .45em 1em; border-radius: 999px;
}
.state { left: 1.4cqw; }
.toast { right: 1.4cqw; }

/* 그림 위에 겹치는 카드 — 질문·다 읽었어요·원래 이야기·나가기 확인 */
.over {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(20, 24, 14, .42);
}
.over .card {
  background: #FFFCF2; border-radius: 2cqw; padding: 2.6cqw 3.6cqw;
  max-width: 82%; text-align: center; box-shadow: 0 1cqw 3cqw rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; align-items: center; gap: 1.1cqw;
}
.card-kicker { margin: 0; font-size: 1.7cqw; font-weight: 800; color: var(--brand-deep); }
.card-big { margin: 0; font-size: 3.3cqw; font-weight: 820; line-height: 1.35; word-break: keep-all; }
.done-big { font-size: 4.6cqw; }
.card-note { margin: 0; font-size: 1.9cqw; font-weight: 700; color: var(--dim); }
.over .bar { margin-top: .4cqw; justify-content: center; }
.over .btn { font-size: 1.5cqw; }
.over .btn-big { font-size: 1.9cqw; }
.timer-row { display: flex; align-items: center; gap: .8cqw; flex-wrap: wrap; justify-content: center; }
.timer-name { font-size: 1.5cqw; font-weight: 700; color: var(--dim); }
.timer { font-size: 3cqw; font-weight: 860; min-width: 3.4em; font-variant-numeric: tabular-nums; }
.timer.end { color: #C2410C; }

/* 조작 막대 — 평소에는 숨기고, 마우스를 움직이거나 화면을 누르면 3초 보입니다 */
.controls {
  position: absolute; top: 1.2vh; left: 50%; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  width: max-content; max-width: 96vw; padding: 8px; border-radius: 16px;
  background: rgba(20, 23, 15, .72);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.read.show-controls .controls { opacity: 1; pointer-events: auto; }
.controls button {
  border: 0; background: transparent; color: #fff; border-radius: 10px;
  padding: .5em .8em; font-size: clamp(14px, 1.05vw, 21px); font-weight: 700;
  display: inline-flex; align-items: center; gap: .45em;
}
.controls button:hover { background: rgba(255, 255, 255, .14); }
.controls button:focus-visible { outline: 3px solid #D9F99D; outline-offset: -3px; }

/* ---------------------------------------------------------------- 이 책 정보 */
.info {
  border: 0; border-radius: 20px; padding: 28px 32px; max-width: min(640px, 92vw);
  color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.info::backdrop { background: rgba(20, 24, 14, .45); }
.info h3 { margin: 0 0 14px; font-size: 1.5rem; }
.info dl { margin: 0 0 18px; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; }
.info dt { font-weight: 800; color: var(--brand-deep); }
.info dd { margin: 0; line-height: 1.5; word-break: keep-all; }
.info form { display: flex; justify-content: flex-end; }
