/* ============================================================
   el_tokens.css — 알풀과학 초등(el) 트랙 디자인 토큰 + 공통 셸
   기준: CLAUDE.md (Navy/White/Gold, Pretendard/Outfit, 8px 그리드)
   원칙: 풀블리드 스테이지, 직접 조작, 스프링 모션, 보라 그라데이션 금지
   ============================================================ */

:root {
  /* ── 팔레트 ───────────────────────────── */
  --el-bg: #f8fafc;
  --el-surface: #ffffff;
  --el-ink: #1e293b;
  --el-ink-soft: #64748b;
  --el-ink-faint: #94a3b8;
  --el-gold: #f59e0b;
  --el-gold-deep: #d97706;
  --el-gold-soft: #fef3c7;
  --el-sky: #38bdf8;
  --el-sky-deep: #0284c7;
  --el-sky-soft: #e0f2fe;
  --el-mint: #34d399;
  --el-mint-deep: #059669;
  --el-mint-soft: #d1fae5;
  --el-coral: #fb7185;
  --el-coral-deep: #e11d48;
  --el-coral-soft: #ffe4e6;
  --el-wood: #e8b765;
  --el-wood-deep: #c08a3e;
  --el-border: #e2e8f0;
  --el-stage: linear-gradient(180deg, #ffffff 0%, #e0f2fe 100%);

  /* ── 타이포 (초등 가독 크기) ───────────── */
  --el-font-body: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --el-font-display: "Outfit", "Pretendard", system-ui, sans-serif;
  --el-text-sm: 16px;
  --el-text-md: 18px;
  --el-text-lg: 22px;
  --el-text-xl: 28px;
  --el-text-hero: 40px;

  /* ── 8px 그리드 / 라운딩 / 그림자 ─────── */
  --el-sp-1: 8px;  --el-sp-2: 16px; --el-sp-3: 24px;
  --el-sp-4: 32px; --el-sp-6: 48px;
  --el-r-chip: 12px; --el-r-card: 16px; --el-r-pill: 9999px;
  --el-shadow-sm: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --el-shadow-md: 0 10px 24px -8px rgba(15, 23, 42, 0.14);

  /* ── 모션 / 터치 ──────────────────────── */
  --el-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --el-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --el-dur-fast: 150ms; --el-dur-base: 240ms; --el-dur-slow: 400ms;
  --el-tap-min: 48px;
}

/* ── 페이지 기본 ─────────────────────────── */
.el-page {
  margin: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--el-font-body);
  font-size: var(--el-text-md);
  color: var(--el-ink);
  background: var(--el-bg);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  overscroll-behavior: none;
}
.el-stage-wrap { position: fixed; inset: 0; background: var(--el-stage); }
.el-stage-wrap canvas { display: block; width: 100%; height: 100%; }

/* ── 셸 오버레이 ─────────────────────────── */
.el-shell { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.el-shell > * { pointer-events: auto; }

.el-topbar {
  position: absolute; top: var(--el-sp-2); left: var(--el-sp-2); right: var(--el-sp-2);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--el-sp-1);
  pointer-events: none;
}
.el-topbar > * { pointer-events: auto; }

.el-titlechip {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--el-surface);
  border: 1px solid var(--el-border);
  border-radius: var(--el-r-card);
  box-shadow: var(--el-shadow-sm);
  padding: 10px 18px;
  max-width: min(60vw, 420px);
}
.el-titlechip .el-unit {
  font-size: 13px; font-weight: 600; color: var(--el-gold-deep);
  letter-spacing: 0.02em;
}
.el-titlechip strong {
  font-size: var(--el-text-lg); font-weight: 700; line-height: 1.25;
  letter-spacing: -0.01em;
}

.el-controls { display: flex; align-items: center; gap: var(--el-sp-1); }

/* 단계 도트 */
.el-stepdots {
  display: flex; gap: 4px;
  background: var(--el-surface);
  border: 1px solid var(--el-border);
  border-radius: var(--el-r-pill);
  box-shadow: var(--el-shadow-sm);
  padding: 4px;
}
.el-dot {
  display: flex; align-items: center; gap: 6px;
  min-height: 40px; min-width: 40px;
  padding: 0 14px;
  border: 0; border-radius: var(--el-r-pill);
  background: transparent;
  font-family: var(--el-font-body);
  font-size: 15px; font-weight: 600; color: var(--el-ink-soft);
  cursor: pointer;
  transition: background var(--el-dur-base) var(--el-ease-out), color var(--el-dur-base) var(--el-ease-out), transform var(--el-dur-base) var(--el-ease-spring);
}
.el-dot:hover { background: var(--el-gold-soft); color: var(--el-ink); }
.el-dot.on { background: var(--el-gold); color: #fff; transform: scale(1.04); }
.el-dot .el-dot-num {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  font-size: 13px; font-weight: 700;
}
.el-dot.on .el-dot-num { background: rgba(255, 255, 255, 0.28); }

/* 아이콘 버튼 */
.el-iconbtn {
  display: grid; place-items: center;
  width: var(--el-tap-min); height: var(--el-tap-min);
  border: 1px solid var(--el-border); border-radius: var(--el-r-pill);
  background: var(--el-surface); color: var(--el-ink-soft);
  box-shadow: var(--el-shadow-sm);
  cursor: pointer;
  transition: transform var(--el-dur-fast) var(--el-ease-spring), color var(--el-dur-fast), background var(--el-dur-fast);
}
.el-iconbtn:hover { color: var(--el-ink); background: var(--el-gold-soft); }
.el-iconbtn:active { transform: scale(0.92); }
.el-iconbtn svg { width: 22px; height: 22px; }

/* 힌트 말풍선 */
.el-hint {
  position: absolute; bottom: var(--el-sp-3); left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 620px);
  text-align: center;
}
.el-hint-bubble {
  display: inline-block;
  background: var(--el-ink); color: #fff;
  font-size: var(--el-text-md); font-weight: 500; line-height: 1.5;
  padding: 12px 22px;
  border-radius: var(--el-r-card);
  box-shadow: var(--el-shadow-md);
  transition: opacity var(--el-dur-base) var(--el-ease-out), transform var(--el-dur-base) var(--el-ease-spring);
}
.el-hint.el-hint-pop .el-hint-bubble { animation: el-hint-pop var(--el-dur-slow) var(--el-ease-spring); }
@keyframes el-hint-pop {
  0% { transform: translateY(8px) scale(0.96); opacity: 0.4; }
  100% { transform: none; opacity: 1; }
}

/* 토스트 */
.el-toastwrap {
  position: absolute; top: 86px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.el-toast {
  background: var(--el-surface); color: var(--el-ink);
  border: 1px solid var(--el-border);
  font-size: var(--el-text-sm); font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--el-r-pill);
  box-shadow: var(--el-shadow-md);
  animation: el-toast-in var(--el-dur-base) var(--el-ease-spring);
}
.el-toast.el-out { opacity: 0; transform: translateY(-6px); transition: all var(--el-dur-base) var(--el-ease-out); }
@keyframes el-toast-in {
  from { transform: translateY(-10px) scale(0.95); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* 도움말 모달 */
.el-modal {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, 0.45);
  z-index: 30;
}
.el-modal[hidden] { display: none; }
.el-modal-card {
  background: var(--el-surface);
  border-radius: var(--el-r-card);
  box-shadow: var(--el-shadow-md);
  padding: var(--el-sp-4);
  max-width: min(92vw, 520px);
  max-height: 80vh; overflow: auto;
  animation: el-toast-in var(--el-dur-slow) var(--el-ease-spring);
}
.el-modal-card h2 {
  margin: 0 0 var(--el-sp-2);
  font-family: var(--el-font-display);
  font-size: var(--el-text-xl); font-weight: 700; letter-spacing: -0.01em;
}
.el-modal-card .el-modal-body { font-size: var(--el-text-md); line-height: 1.7; color: var(--el-ink-soft); }
.el-modal-card .el-modal-body strong { color: var(--el-ink); }
.el-modal-card .el-modal-body kbd {
  font-family: var(--el-font-body); font-size: 14px; font-weight: 700;
  background: var(--el-bg); border: 1px solid var(--el-border); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 8px;
}
.el-modal-close {
  margin-top: var(--el-sp-3);
  min-height: var(--el-tap-min);
  width: 100%;
  border: 0; border-radius: var(--el-r-pill);
  background: var(--el-gold); color: #fff;
  font-family: var(--el-font-body);
  font-size: var(--el-text-md); font-weight: 700;
  cursor: pointer;
  transition: transform var(--el-dur-fast) var(--el-ease-spring), background var(--el-dur-fast);
}
.el-modal-close:hover { background: var(--el-gold-deep); }
.el-modal-close:active { transform: scale(0.97); }

/* 컨페티 */
.el-confetti-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.el-confetti {
  position: absolute; top: -16px;
  width: 10px; height: 14px;
  border-radius: 3px;
  background: var(--c, var(--el-gold));
  left: var(--x, 50%);
  animation: el-confetti-fall var(--dur, 1.4s) cubic-bezier(0.3, 0.4, 0.6, 1) forwards;
}
@keyframes el-confetti-fall {
  0% { transform: translateY(-10vh) rotate(0) ; opacity: 1; }
  100% { transform: translateY(110vh) rotate(var(--rot, 540deg)); opacity: 0.9; }
}

/* 포커스 / 모션 감소 / 모바일 */
.el-shell :focus-visible, .el-page :focus-visible {
  outline: 3px solid var(--el-gold);
  outline-offset: 2px;
  border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
  .el-shell *, .el-confetti { animation: none !important; }
  .el-dot, .el-iconbtn, .el-hint-bubble { transition-timing-function: var(--el-ease-out) !important; }
}
@media (max-width: 640px) {
  .el-topbar { flex-wrap: wrap; }
  .el-titlechip {
    flex: 1 1 100%;
    max-width: none;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    padding: 8px 14px;
  }
  .el-titlechip .el-unit { white-space: nowrap; font-size: 12px; }
  .el-titlechip strong {
    font-size: var(--el-text-md);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
  }
  .el-controls { margin-left: auto; }
  .el-dot { padding: 0 10px; }
  .el-dot .el-dot-label { display: none; }
  .el-iconbtn { width: 44px; height: 44px; }
  .el-hint-bubble { font-size: var(--el-text-sm); padding: 10px 16px; }
}
