/* 집현전 한글 탐험 — 글자연구소 / 한글날 시간여행 (lab) */

/* ------------------------------------------------------------ */
/* 공통                                                          */
/* ------------------------------------------------------------ */
.lab-stage { position: relative; }
.lab-stage .match-title b { color: var(--blue); }
.lab-svg { display: block; width: 72px; height: 72px; flex: 0 0 auto; overflow: visible; }
.lab-svg text { font-family: var(--font); font-weight: 900; }
.lab-hi > * {
  fill: rgba(245, 184, 46, .28);
  stroke: #e0a100;
  stroke-width: 2.4;
  stroke-dasharray: 4 3;
}
.lab-jamo { display: inline-block; font-size: 52px; font-weight: 900; line-height: 1; letter-spacing: 0; }
.lab-org { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.lab-desc { flex: 1 1 auto; min-width: 0; font-size: 18px; font-weight: 800; line-height: 1.35; }
.lab-sound {
  display: inline-block; margin: 0 6px 2px 0; padding: 0 8px;
  background: var(--sky); border: 2px solid var(--blue); border-radius: 999px;
  color: var(--blue); font-size: 14px; font-weight: 900; line-height: 1.5;
}
.lab-arae { font-size: 1.25em; }
.lab-arae-in { display: inline-block; font-size: 1.5em; line-height: .8; color: var(--gold-2); vertical-align: -.05em; }
.lab-next { min-width: 200px; }

/* 연결 카드 크기 */
.lab-basic .match,
.lab-cji .match { grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); }
.lab-basic .btn.match-item,
.lab-cji .btn.match-item { min-height: 80px; padding-top: 3px; padding-bottom: 3px; }
.lab-basic .match-col,
.lab-cji .match-col { gap: 10px; }
.lab-basic .btn.match-item.match-a { background: linear-gradient(180deg, #fffdf6, #f7e7c4); }
.lab-basic .btn.match-item.selected,
.lab-cji .btn.match-item.selected { background: var(--sky); }
.lab-basic .btn.match-item.matched .lab-hi > * { stroke: var(--green); fill: rgba(47, 158, 68, .18); }

/* 천지인 */
.lab-cji .lab-svg { width: 96px; height: 72px; }
.lab-cji-j { font-size: 64px; }
.lab-cji-j.lab-arae { font-size: 88px; line-height: .8; }
.lab-cji .btn.match-item { min-height: 96px; }

/* ------------------------------------------------------------ */
/* 비밀 발견 카드                                                 */
/* ------------------------------------------------------------ */
.lab-discover {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 0%, #fff6d0 0%, var(--paper) 60%);
}
.lab-discover-head { display: flex; align-items: center; gap: 10px; }
.lab-discover-head h2 { font-size: 32px; font-weight: 900; text-shadow: 0 3px 0 var(--gold); }
.lab-discover-icon { font-size: 36px; }
.lab-discover-text { font-size: 20px; font-weight: 800; color: var(--ink-2); }
.lab-figs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; width: 100%; }
.lab-fig {
  margin: 0; padding: 8px 6px 10px;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 0;
}
.lab-fig-art { width: 100%; max-width: 140px; }
.lab-fig-art .lab-svg { width: 100%; height: auto; aspect-ratio: 1 / 1; }
.lab-fig figcaption { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; justify-content: center; }
.lab-fig-j { font-size: 28px; font-weight: 900; color: var(--blue); line-height: 1; }
.lab-fig-name { font-size: 15px; font-weight: 800; color: var(--ink-2); }
.lab-ov {
  fill: rgba(43, 95, 173, .72);
  stroke: rgba(255, 255, 255, .9); stroke-width: 1.2; paint-order: stroke;
  transform-box: fill-box; transform-origin: center;
  opacity: 0;
  animation: lab-ov-in .7s var(--ease-pop) both;
  animation-delay: var(--d, 0s);
}
@keyframes lab-ov-in {
  0% { opacity: 0; transform: scale(1.8); }
  100% { opacity: 1; transform: scale(1); }
}

/* ------------------------------------------------------------ */
/* 단계 전환 카드                                                 */
/* ------------------------------------------------------------ */
.lab-stagecard {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; max-width: 720px; margin-left: auto; margin-right: auto;
}
.lab-stage-badge {
  display: inline-block; padding: 2px 16px;
  background: var(--navy); color: #fff; border-radius: 999px;
  font-weight: 900; font-size: 16px; letter-spacing: 1px;
}
.lab-stage-title { font-size: 28px; font-weight: 900; }
.lab-stage-text { font-size: 19px; font-weight: 700; color: var(--ink-2); max-width: 560px; }
.lab-stage-text:empty { display: none; }

/* 식: ㄱ + 획 = ? */
.lab-eq { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.lab-eq .tile { width: 72px; height: 72px; font-size: 44px; }
.lab-eq .tile.lab-arae { font-size: 60px; }
.lab-eq .slot { width: 72px; height: 72px; color: var(--ink-2); }
.lab-op { font-size: 32px; font-weight: 900; color: var(--ink-2); }
.lab-stroke-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; min-height: 48px;
  background: #fff; border: 3px dashed var(--gold-2); border-radius: 14px;
  font-size: 20px; font-weight: 900; color: #8a5a00;
}
.lab-stroke-line { display: inline-block; width: 24px; height: 6px; border-radius: 3px; background: var(--ink); }
/* 획 개수를 정하지 않는 칩 (ㅁ·ㅂ·ㅇ처럼 '하나'가 아닌 문제) */
.lab-stroke-any .emoji { font-size: 22px; line-height: 1; }
/* 천지인 조합: ㆍ가 위/아래에 붙을 때는 세로로 쌓는다 */
.lab-vstack { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.lab-vstack .tile { width: 60px; height: 60px; font-size: 38px; }
.lab-vstack .tile.lab-arae { font-size: 52px; }
.lab-op.lab-op-v { font-size: 24px; line-height: 1; }

/* 가획 문제 보기 */
.lab-q .answers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lab-q .answers .btn.option { font-size: 46px; min-height: 92px; font-weight: 900; line-height: 1; }
.lab-q .q-card { gap: 14px; }
.lab-q-lead { text-align: center; font-size: 20px; font-weight: 900; color: var(--ink-2); margin-bottom: 12px; }

/* 가획 정리 표 */
.lab-family { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 620px; }
.lab-frow {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 6px 12px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
}
.lab-frow.with-note { background: var(--gold-soft); border-color: var(--gold-2); }
.lab-fcells { display: flex; align-items: center; gap: 8px; }
.lab-ftile.tile { width: 50px; height: 50px; font-size: 30px; border-radius: 12px; }
.lab-ftile.base { background: linear-gradient(180deg, #ffe27a 0%, var(--gold) 100%); }
.lab-ftile.old { background: #f3ece0; border-style: dashed; color: var(--ink-2); box-shadow: none; }
.lab-arrow { font-size: 22px; font-weight: 900; color: var(--ink-2); }
.lab-fnote { font-size: 17px; font-weight: 800; color: #6b4300; }
/* 태블릿 가로(1024x768)처럼 낮은 화면: 정리 카드가 한 화면에 들어가도록 세로 여백을 줄인다
   (아래 600px 이하 규칙이 뒤에 있어 좁은 화면에서는 그쪽이 이긴다) */
@media (max-height: 800px) {
  .lab-stagecard { padding-top: 14px; padding-bottom: 14px; gap: 10px; }
  .lab-stage-title { font-size: 26px; }
  .lab-family { gap: 6px; }
  .lab-frow { padding: 3px 12px; }
  .lab-ftile.tile { width: 44px; height: 44px; font-size: 27px; }
}

/* ------------------------------------------------------------ */
/* 한글날 시간여행 — 두루마리                                      */
/* ------------------------------------------------------------ */
.lab-scroll {
  position: relative;
  margin: 12px 4px;
  padding: 20px 18px 22px;
  background:
    repeating-linear-gradient(0deg, rgba(107, 74, 43, .04) 0 2px, rgba(0, 0, 0, 0) 2px 6px),
    linear-gradient(180deg, #fffaf0 0%, #f8e8c6 100%);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.lab-scroll::before, .lab-scroll::after {
  content: ""; position: absolute; left: -8px; right: -8px; height: 16px;
  background: linear-gradient(180deg, #d19155 0%, #a86b33 55%, #7d4a1f 100%);
  border: 3px solid var(--ink); border-radius: 10px;
  pointer-events: none;
}
.lab-scroll::before { top: -10px; }
.lab-scroll::after { bottom: -10px; }
.lab-scroll > * { position: relative; }

.lab-tt .match { grid-template-columns: minmax(0, .6fr) minmax(0, 1.4fr); gap: 12px 20px; }
.lab-tt .match-col { gap: 10px; }
.lab-tt .btn.match-item { min-height: 60px; }
.lab-tt .btn.match-item.match-a { background: #fff; }
.lab-tt-year { font-size: 24px; font-weight: 900; color: #8a2a1a; letter-spacing: -.3px; }
.lab-tt .btn.match-item.matched .lab-tt-year { color: #1d5a2a; }
.lab-tt .btn.match-item.match-b { justify-content: flex-start; text-align: left; }
.lab-tt-event { font-size: 17px; font-weight: 800; line-height: 1.35; }
.lab-tt .match-col-title { font-size: 19px; color: #8a2a1a; }

/* 연표 요약 */
.lab-timeline-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.lab-tl-title { font-size: 28px; font-weight: 900; text-shadow: 0 3px 0 var(--gold); }
.lab-tl-sub { font-weight: 800; color: var(--ink-2); }
.lab-timeline {
  list-style: none; position: relative;
  width: 100%; max-width: 720px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 0 8px;
  text-align: left;
}
.lab-timeline::before {
  content: ""; position: absolute; left: 13px; top: 10px; bottom: 14px;
  width: 4px; border-radius: 2px; background: var(--wood-2);
}
.lab-tl-row {
  position: relative;
  display: grid; grid-template-columns: 30px 110px minmax(0, 1fr); align-items: center; gap: 8px;
  animation: lab-tl-in .45s ease both;
  animation-delay: var(--d, 0s);
}
.lab-tl-dot {
  width: 20px; height: 20px; margin-left: 5px; border-radius: 50%;
  background: var(--gold); border: 3px solid var(--ink);
  box-shadow: 0 0 0 3px #fffaf0;
}
.lab-tl-year {
  justify-self: start;
  padding: 3px 10px;
  background: #8a2a1a; color: #fff;
  border-radius: 10px;
  font-weight: 900; font-size: 18px; white-space: nowrap;
}
.lab-tl-text { font-size: 17px; font-weight: 700; line-height: 1.4; }
@keyframes lab-tl-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}
.lab-ttq .q-visual { font-size: 64px; }
/* 확인 문제 보기: 문장 보기라 세로 한 줄씩, 모두 같은 높이로 (한 보기만 두 줄로 튀어 보이지 않게) */
.lab-ttq .answers,
.lab-ttq .answers.three { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; max-width: 600px; margin-left: auto; margin-right: auto; width: 100%; }
.lab-ttq .answers .btn.option { min-height: 64px; font-size: 20px; line-height: 1.3; }

/* ------------------------------------------------------------ */
/* 반응형                                                        */
/* ------------------------------------------------------------ */
@media (max-width: 760px) {
  .lab-figs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .lab-org { flex-direction: column; align-items: center; text-align: center; gap: 4px; }
  .lab-svg { width: 58px; height: 58px; }
  .lab-cji .lab-svg { width: 76px; height: 57px; }
  .lab-desc { font-size: 14px; }
  .lab-sound { display: block; margin: 0 auto 2px; width: max-content; max-width: 100%; font-size: 12px; }
  .lab-jamo { font-size: 42px; }
  .lab-cji-j { font-size: 52px; }
  .lab-cji-j.lab-arae { font-size: 70px; }
  .lab-basic .match, .lab-cji .match { grid-template-columns: minmax(0, .6fr) minmax(0, 1.4fr); }
  .lab-discover-head h2 { font-size: 26px; }
  .lab-discover-text { font-size: 17px; }
  .lab-fig-j { font-size: 22px; }
  .lab-fig-name { font-size: 13px; }
  .lab-stage-title { font-size: 23px; }
  .lab-stage-text { font-size: 17px; }
  .lab-eq { gap: 6px; }
  .lab-eq .tile, .lab-eq .slot { width: 58px; height: 58px; font-size: 34px; }
  .lab-eq .tile.lab-arae { font-size: 48px; }
  .lab-op { font-size: 24px; }
  .lab-vstack .tile { width: 48px; height: 48px; font-size: 30px; }
  .lab-vstack .tile.lab-arae { font-size: 42px; }
  .lab-op.lab-op-v { font-size: 20px; }
  .lab-stroke-chip { font-size: 17px; padding: 4px 8px; }
  .lab-q .answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-q .answers .btn.option { font-size: 40px; min-height: 76px; }
  .lab-ftile.tile { width: 42px; height: 42px; font-size: 25px; }
  .lab-fnote { font-size: 15px; }
  .lab-scroll { padding: 18px 10px 20px; }
  .lab-tt .match { grid-template-columns: minmax(0, .55fr) minmax(0, 1.45fr); gap: 10px 10px; }
  .lab-tt-year { font-size: 16px; white-space: nowrap; letter-spacing: -.5px; }
  .lab-tt .match-col.left .btn.match-item { padding-left: 26px; padding-right: 4px; }
  .lab-tt-event { font-size: 14px; }
  .lab-tl-row { grid-template-columns: 26px minmax(0, 1fr); }
  .lab-tl-year { grid-column: 2; }
  .lab-tl-text { grid-column: 2; font-size: 15px; }
  .lab-tl-dot { grid-row: 1; margin-left: 3px; }
  .lab-timeline::before { left: 11px; }
  .lab-tl-title { font-size: 23px; }
  .lab-next { min-width: 0; width: 100%; max-width: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .lab-ov { opacity: 1; animation: none !important; }
  .lab-tl-row { animation: none !important; }
}
