/* ================================================
   관용어 마스터 — 공유 디자인 시스템 CSS
   Based on DESIGN.md: Yuja EDU "친근한 교육 프리미엄" v2
   ================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;700&display=swap');

/* ─── Design Tokens ─────────────────────────────── */
:root {
  /* Yuja Lemon System */
  --color-yuja-lemon: #FFE135;
  --color-yuja-lemon-amber: #F5C800;
  --color-yuja-forest: #142814;
  --color-yuja-forest-mid: #1E3D1E;
  --color-yuja-lemon-tint: #FEFCE8;

  /* Leaf Green */
  --color-leaf-green: #4CAA48;
  --color-leaf-green-mid: #388E3C;
  --color-leaf-green-deep: #2D7A29;
  --color-leaf-green-light: #B8E0B5;
  --color-leaf-green-tint: #E8F5E7;

  /* Notion Canvas */
  --color-canvas: #FFFFFF;
  --color-canvas-cream: #F7F6F3;
  --color-surface: #F1F0EE;
  --color-surface-soft: #F8F7F5;
  --color-hairline: #E8E7E4;
  --color-hairline-strong: #D3D1CB;

  /* Text */
  --color-ink-deep: #1A1A1A;
  --color-ink: #37352F;
  --color-charcoal: #4B4945;
  --color-slate: #6F6E69;
  --color-steel: #9B9A97;
  --color-on-dark: #FFFFFF;
  --color-on-dark-muted: rgba(255, 255, 255, 0.70);

  /* Semantic */
  --color-success: #0F7B5C;
  --color-warning: #E67E22;
  --color-error: #C82014;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-subtle: rgba(15, 15, 15, 0.04) 0px 1px 2px;
  --shadow-card: rgba(15, 15, 15, 0.08) 0px 4px 12px 0px;
  --shadow-mockup: rgba(15, 15, 15, 0.18) 0px 20px 40px -8px;
  --shadow-modal: rgba(15, 15, 15, 0.14) 0px 14px 40px -8px;
  --shadow-frap: 0 0 6px rgba(0, 0, 0, 0.24), 0 8px 12px rgba(0, 0, 0, 0.14);

  /* Typography */
  --font-primary: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Noto Serif KR", "Malgun Gothic", serif;
  --letter-spacing-body: -0.01em;

  /* Transitions */
  --transition-btn: 150ms ease;
  --transition-card: 200ms ease;
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ───────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 1.60;
  letter-spacing: var(--letter-spacing-body);
  color: var(--color-ink);
  background-color: var(--color-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: var(--font-primary);
  border: none;
  background: none;
}

/* ─── Navigation ─────────────────────────────────── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-canvas);
  border-bottom: 1px solid var(--color-hairline);
  height: 64px;
  display: flex;
  align-items: center;
}

.nav-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 왕관유자 배움터 홈버튼 (공통 표준) */
.nav-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin-right: 4px;
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.15s ease;
}

.nav-home:hover {
  background: var(--color-yuja-lemon-tint);
}

.nav-home:active {
  transform: scale(0.95);
}

@media (max-width: 640px) {
  .nav-home .nav-home-label {
    display: none;
  }

  .nav-home {
    padding: 8px 10px;
  }
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--color-ink-deep);
}

.nav-logo-badge {
  background: var(--color-yuja-forest);
  color: var(--color-yuja-lemon);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-slate);
  transition: background var(--transition-btn), color var(--transition-btn);
}

.nav-link:hover {
  background: var(--color-surface);
  color: var(--color-ink);
}

.nav-link.active {
  background: var(--color-leaf-green-tint);
  color: var(--color-leaf-green-deep);
  font-weight: 600;
}

.nav-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-slate);
  transition: all var(--transition-btn);
}

.nav-back:hover {
  background: var(--color-surface);
  color: var(--color-ink);
}

/* ─── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-yuja-lemon-amber);
  color: var(--color-ink-deep);
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: var(--letter-spacing-body);
  padding: 14px 28px;
  border-radius: var(--radius-full);
  height: 50px;
  border: none;
  cursor: pointer;
  transition: background var(--transition-btn), transform var(--transition-btn), box-shadow var(--transition-btn);
}

.btn-primary:hover {
  background: #e6b800;
  box-shadow: var(--shadow-card);
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  height: 44px;
  border: 1px solid var(--color-hairline-strong);
  cursor: pointer;
  transition: all var(--transition-btn);
}

.btn-secondary:hover {
  background: var(--color-surface);
}

.btn-secondary:active {
  transform: scale(0.97);
}

.btn-leaf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-leaf-green);
  color: #fff;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  height: 50px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-btn);
}

.btn-leaf:hover {
  background: var(--color-leaf-green-mid);
  box-shadow: var(--shadow-card);
}

.btn-leaf:active {
  transform: scale(0.95);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background var(--transition-btn);
}

.btn-ghost:hover {
  background: var(--color-surface);
}

/* ─── Cards ───────────────────────────────────────── */
.card {
  background: var(--color-canvas);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-hairline);
  padding: 24px;
  transition: box-shadow var(--transition-card), transform var(--transition-card);
}

.card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

.card-cream {
  background: var(--color-canvas-cream);
}

.card-tint {
  background: var(--color-leaf-green-tint);
}

/* ─── Badges & Tags ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0;
}

.badge-green {
  background: var(--color-leaf-green);
  color: #fff;
}

.badge-lemon {
  background: var(--color-yuja-lemon);
  color: var(--color-ink-deep);
}

.badge-forest {
  background: var(--color-yuja-forest);
  color: var(--color-yuja-lemon);
}

.badge-orange {
  background: #F59E0B;
  color: #fff;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

.tag-category {
  background: var(--color-leaf-green-light);
  color: var(--color-leaf-green-deep);
}

.tag-body {
  background: #DBEAFE;
  color: #1D4ED8;
}

.tag-life {
  background: #FEF3C7;
  color: #B45309;
}

.tag-emotion {
  background: #FCE7F3;
  color: #9D174D;
}

.tag-proverb {
  background: #F5F3FF;
  color: #6D28D9;
}

/* ─── Form Inputs ─────────────────────────────────── */
.search-input {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  padding: 10px 16px 10px 44px;
  height: 44px;
  font-family: var(--font-primary);
  font-size: 14px;
  color: var(--color-ink);
  letter-spacing: var(--letter-spacing-body);
  transition: border-color var(--transition-btn), box-shadow var(--transition-btn);
  outline: none;
}

.search-input:focus {
  border-color: var(--color-leaf-green);
  box-shadow: 0 0 0 3px rgba(76, 170, 72, 0.12);
}

.search-input::placeholder {
  color: var(--color-steel);
}

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-steel);
  pointer-events: none;
}

/* ─── Layout Utilities ───────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}

.section {
  padding: 80px 0;
}

.section-sm {
  padding: 56px 0;
}

.section-lg {
  padding: 112px 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── Typography Helpers ──────────────────────────── */
.text-hero {
  font-size: 72px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -2px;
}

.text-display {
  font-size: 44px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -1px;
}

.text-h2 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.20;
  letter-spacing: -0.5px;
}

.text-h3 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
}

.text-h4 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.30;
}

.text-body {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.60;
}

.text-sm {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.50;
}

.text-slate { color: var(--color-slate); }
.text-steel { color: var(--color-steel); }
.text-ink { color: var(--color-ink); }
.text-ink-deep { color: var(--color-ink-deep); }
.text-leaf { color: var(--color-leaf-green); }
.text-lemon { color: var(--color-yuja-lemon-amber); }

/* ─── Dark Band ───────────────────────────────────── */
.band-dark {
  background: var(--color-yuja-forest);
  color: var(--color-on-dark);
}

/* ─── Modal Overlay ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-canvas);
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-mockup);
  transform: translateY(24px) scale(0.97);
  transition: transform var(--transition-smooth);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

/* ─── Progress Bar ────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-leaf-green) 0%, var(--color-yuja-lemon-amber) 100%);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Quiz Common Styles ──────────────────────────── */
.quiz-header {
  background: var(--color-canvas);
  border-bottom: 1px solid var(--color-hairline);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.quiz-score {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink-deep);
}

.quiz-score-num {
  background: var(--color-yuja-forest);
  color: var(--color-yuja-lemon);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 13px;
}

/* ─── Confetti Animation ──────────────────────────── */
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall 2.5s ease-in forwards;
  z-index: 999;
  pointer-events: none;
}

/* ─── Shake Animation ─────────────────────────────── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.shake {
  animation: shake 0.4s ease;
}

/* ─── Correct Flash ───────────────────────────────── */
@keyframes correct-flash {
  0% { background: var(--color-leaf-green-tint); }
  50% { background: var(--color-leaf-green-light); }
  100% { background: var(--color-leaf-green-tint); }
}

.correct-flash {
  animation: correct-flash 0.6s ease;
}

/* ─── Float In Animation ──────────────────────────── */
@keyframes float-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.float-in {
  animation: float-in 0.4s ease forwards;
}

@keyframes bounce-in {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

.bounce-in {
  animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ─── Flip Card ───────────────────────────────────── */
.flip-card {
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* ─── Footer ──────────────────────────────────────── */
.footer {
  background: var(--color-yuja-forest);
  color: var(--color-on-dark-muted);
  padding: 40px 0;
  text-align: center;
  font-size: 13px;
}

.footer-logo {
  color: var(--color-yuja-lemon);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
}

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
  .nav-links { display: none; }
  .container { padding: 0 24px; }
}

@media (max-width: 768px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .text-hero { font-size: 44px; }
  .text-display { font-size: 32px; }
  .container { padding: 0 16px; }
  .section { padding: 56px 0; }
  .modal { padding: 24px; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .text-hero { font-size: 36px; }
  .text-display { font-size: 28px; }
  .nav-inner { padding: 0 16px; }
}
