/* ============================================================
   Spelling Bee Practice — Design Tokens
   Palette:
     --cream    #FFF8E7  background
     --ink      #1A1A2E  primary text
     --honey    #F4A300  primary accent (CTA, brand)
     --honey-dk #D98C00  accent hover/active
     --teal     #2D9596  success / correct
     --coral    #E85D4E  error / incorrect
     --soft-yl  #FFD166  highlight / progress
   Type:
     Display : 'Fredoka'        (headings, brand, hex word card)
     Body    : 'Inter'          (paragraphs, labels, controls)
     Mono    : 'JetBrains Mono' (counters, scores, percentages)
   ============================================================ */

:root {
  --cream: #FFF8E7;
  --cream-deep: #FCEFD2;
  --ink: #1A1A2E;
  --ink-soft: #4A4A63;
  --honey: #F4A300;
  --honey-dk: #D98C00;
  --teal: #2D9596;
  --teal-dk: #237677;
  --coral: #E85D4E;
  --coral-dk: #C8483B;
  --soft-yl: #FFD166;
  --card-radius: 28px;
  --shadow-soft: 0 12px 32px rgba(26, 26, 46, 0.08);
  --shadow-lift: 0 18px 40px rgba(244, 163, 0, 0.25);
}

[data-bs-theme="dark"] {
  --cream: #15131C;
  --cream-deep: #1D1A26;
  --ink: #F4F1EA;
  --ink-soft: #C7C3D8;
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 18px 40px rgba(244, 163, 0, 0.18);
}

* { box-sizing: border-box; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color .35s ease, color .35s ease;
}

/* ---------- decorative honeycomb backdrop ---------- */
.hive-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(244,163,0,0.10) 0, transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(45,149,150,0.08) 0, transparent 40%),
    radial-gradient(circle at 92% 85%, rgba(244,163,0,0.08) 0, transparent 35%),
    radial-gradient(circle at 6% 80%, rgba(232,93,78,0.06) 0, transparent 35%);
}

.app-shell { position: relative; z-index: 1; }

.btn-switch-view {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--cream);
  border: 1px solid rgba(26, 26, 46, 0.1);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}
.btn-switch-view:hover { background: rgba(244, 163, 0, 0.12); color: var(--ink); }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  background: var(--cream-deep);
  border-bottom: 2px solid rgba(244, 163, 0, 0.18);
}

.brand-hex-shape { fill: var(--honey); }
.brand-hex-letter {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 42px;
  fill: var(--ink);
}

.brand-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-tagline {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.btn-toggle-theme {
  border: 2px solid rgba(244, 163, 0, 0.3);
  background: transparent;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: transform .2s ease, background-color .2s ease;
}
.btn-toggle-theme:hover { background: rgba(244, 163, 0, 0.12); transform: rotate(15deg); }

/* ============================================================
   EYEBROW / SHARED TEXT STYLES
   ============================================================ */
.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--honey-dk);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

/* SEO intro paragraph — visible, keyword-relevant copy under the header */
.seo-intro {
  max-width: 640px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 1.5rem auto 0;
  padding: 0 1rem;
}

/* ============================================================
   SECTION 1+2 — SETUP PANEL
   ============================================================ */
.setup-panel {
  max-width: 560px;
  margin-top: 3rem;
}

.setup-card {
  background: var(--cream-deep);
  border-radius: var(--card-radius);
  padding: 2.5rem 2.25rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(244, 163, 0, 0.12);
}

.setup-heading {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.9rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.setup-sub {
  color: var(--ink-soft);
  font-size: 0.97rem;
  margin-bottom: 1.75rem;
}

.form-select, .form-control {
  border-radius: 14px;
  border: 2px solid rgba(26, 26, 46, 0.1);
  background-color: var(--cream);
  color: var(--ink);
  padding: 0.65rem 1rem;
}
.form-select:focus, .form-control:focus {
  border-color: var(--honey);
  box-shadow: 0 0 0 4px rgba(244, 163, 0, 0.18);
  background-color: var(--cream);
  color: var(--ink);
}

.btn-honey {
  background: var(--honey);
  border: none;
  color: var(--ink);
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  border-radius: 16px;
  padding: 0.75rem 1.5rem;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-lift);
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.btn-honey:hover:not(:disabled) {
  background: var(--honey-dk);
  transform: translateY(-2px);
  box-shadow: 0 22px 44px rgba(244, 163, 0, 0.32);
  color: var(--ink);
}
.btn-honey:active:not(:disabled) { transform: translateY(0); }
.btn-honey:disabled {
  background: rgba(244, 163, 0, 0.35);
  box-shadow: none;
  cursor: not-allowed;
}

.setup-hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
  min-height: 1.2em;
}

/* ============================================================
   SECTION 3 — QUIZ PANEL
   ============================================================ */
.quiz-panel { max-width: 640px; margin-top: 2.5rem; }

.quiz-progress-row {
  display: flex;
  align-items: center;
  margin-bottom: 1.75rem;
}

.progress-pill {
  background: var(--cream-deep);
  border-radius: 14px;
  padding: 0.5rem 1rem;
  text-align: center;
  border: 1px solid rgba(244, 163, 0, 0.15);
  min-width: 84px;
}
.progress-pill .progress-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-weight: 600;
}
.progress-pill .progress-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}
.score-pill .progress-value { color: var(--teal-dk); }

.progress {
  height: 10px;
  border-radius: 8px;
  background-color: rgba(244, 163, 0, 0.15);
}
.progress-bar {
  background: linear-gradient(90deg, var(--soft-yl), var(--honey));
  transition: width .4s ease;
}

/* ----- the honeycomb word card (signature element) ----- */
.word-stage {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.hex-card {
  position: relative;
  width: 260px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hex-shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 16px 30px rgba(244, 163, 0, 0.28));
}
.hex-shape polygon {
  fill: var(--cream-deep);
  stroke: var(--honey);
  stroke-width: 3;
  transition: fill .3s ease;
}

.hex-card.is-speaking .hex-shape polygon {
  animation: hexPulse 1.1s ease-in-out infinite;
}
@keyframes hexPulse {
  0%, 100% { fill: var(--cream-deep); }
  50% { fill: rgba(244, 163, 0, 0.22); }
}

.hex-content {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hex-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.6rem;
}

.speaker-btn {
  background: var(--honey);
  border: none;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  font-size: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(244, 163, 0, 0.4);
  transition: transform .15s ease;
  cursor: pointer;
}
.speaker-btn:hover { transform: scale(1.07); }
.speaker-btn:active { transform: scale(0.97); }
.speaker-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-repeat {
  background: transparent;
  border: 2px solid var(--honey);
  color: var(--ink);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.35rem 1.1rem;
  font-size: 0.85rem;
}
.btn-repeat:hover { background: rgba(244, 163, 0, 0.15); color: var(--ink); }
.btn-repeat:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- answer form ----- */
.answer-form { max-width: 420px; }

.spell-input {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.spell-input:disabled { background-color: rgba(26,26,46,0.04); }

/* ----- feedback alert ----- */
.feedback-alert {
  max-width: 420px;
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  text-align: center;
  font-size: 1.02rem;
  animation: feedbackIn .25s ease;
}
@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.feedback-alert.correct {
  background: rgba(45, 149, 150, 0.14);
  color: var(--teal-dk);
  border: 2px solid rgba(45, 149, 150, 0.35);
}
.feedback-alert.incorrect {
  background: rgba(232, 93, 78, 0.12);
  color: var(--coral-dk);
  border: 2px solid rgba(232, 93, 78, 0.32);
}
.feedback-alert .feedback-correction {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 0.25rem;
  opacity: 0.9;
}

/* ============================================================
   SECTION 4 — RESULTS PANEL
   ============================================================ */
.results-panel { max-width: 480px; margin-top: 3rem; }

.results-card {
  background: var(--cream-deep);
  border-radius: var(--card-radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(244, 163, 0, 0.12);
}

.results-heading {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 2rem;
  margin-bottom: 0;
}

.results-score-ring {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--honey) calc(var(--pct, 0) * 1%), rgba(244,163,0,0.14) 0);
  position: relative;
}
.results-score-ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--cream-deep);
}
.results-percent {
  position: relative;
  z-index: 1;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.7rem;
  color: var(--ink);
}

.results-fraction {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.results-message {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.missed-words .badge-word {
  background: rgba(232, 93, 78, 0.12);
  color: var(--coral-dk);
  border: 1px solid rgba(232, 93, 78, 0.3);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ============================================================
   SECTION 5 — HISTORY PANEL
   ============================================================ */
.history-panel { max-width: 720px; }

.history-heading {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.5rem;
}

.btn-clear-history {
  background: transparent;
  border: 2px solid rgba(232, 93, 78, 0.4);
  color: var(--coral-dk);
  border-radius: 999px;
  font-weight: 600;
  padding: 0.35rem 1rem;
}
.btn-clear-history:hover { background: rgba(232, 93, 78, 0.1); color: var(--coral-dk); }

.history-table-wrap {
  background: var(--cream-deep);
  border-radius: 20px;
  padding: 0.5rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(244, 163, 0, 0.12);
}

.table-history {
  margin-bottom: 0;
  background: transparent;
  color: var(--ink);
}
.table-history thead th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-bottom: 2px solid rgba(244, 163, 0, 0.2);
  padding: 0.9rem 1rem;
}
.table-history tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(26, 26, 46, 0.06);
  font-size: 0.92rem;
}
.table-history tbody tr:last-child td { border-bottom: none; }

.history-score-good { color: var(--teal-dk); font-weight: 700; }
.history-score-mid { color: var(--honey-dk); font-weight: 700; }
.history-score-low { color: var(--coral-dk); font-weight: 700; }

.history-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-top: 1.5rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

/* ============================================================
   SHUFFLE ANIMATION (word selection)
   ============================================================ */
.is-shuffling .hex-content { animation: shuffleFade .15s ease infinite alternate; }
@keyframes shuffleFade {
  from { opacity: 1; }
  to { opacity: 0.55; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 576px) {
  .setup-card, .results-card { padding: 2rem 1.5rem; }
  .hex-card { width: 220px; height: 220px; }
  .speaker-btn { width: 70px; height: 70px; font-size: 1.7rem; }
  .brand-title { font-size: 1.25rem; }
  .quiz-progress-row { flex-wrap: wrap; row-gap: 0.5rem; }
  .quiz-progress-row .progress { order: 3; flex-basis: 100%; margin: 0.5rem 0 0; }
}

/* ============================================================
   ACCESSIBILITY — reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .hex-card.is-speaking .hex-shape polygon,
  .is-shuffling .hex-content,
  .feedback-alert,
  .btn-toggle-theme {
    animation: none !important;
    transition: none !important;
  }
}

/* visible keyboard focus */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
