/* ============================================================
   NumberTeacher – Material-inspired playful theme
   Matches the Galileo AI design (home.html)
   Mobile-first, large touch targets for small fingers
   ============================================================ */

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* Design colour tokens */
  --clr-bg:              #fffbff;
  --clr-surface:         #fffbff;
  --clr-surface-dim:     #eee686;
  --clr-surface-low:     #fffae1;
  --clr-surface-container: #fef6a5;
  --clr-surface-high:    #f9f19b;
  --clr-surface-highest: #f3eb91;

  --clr-primary:         #776300;
  --clr-primary-dim:     #695700;
  --clr-primary-container: #ffd709;
  --clr-primary-fixed:   #ffd709;
  --clr-primary-fixed-dim: #efc900;
  --clr-on-primary:      #ffffff;
  --clr-on-primary-container: #5b4b00;

  --clr-secondary:       #00725a;
  --clr-secondary-dim:   #00654f;
  --clr-secondary-container: #00fcca;
  --clr-secondary-fixed-dim: #00edbd;
  --clr-on-secondary:    #ffffff;
  --clr-on-secondary-container: #005b47;

  --clr-tertiary:        #b300b3;
  --clr-tertiary-dim:    #9e009e;
  --clr-tertiary-container: #ff81f5;
  --clr-on-tertiary:     #ffffff;
  --clr-on-tertiary-container: #5b005b;

  --clr-error:           #be2d06;
  --clr-error-container: #f95630;

  --clr-text:            #3d3905;
  --clr-text-variant:    #6b662f;
  --clr-outline:         #878248;
  --clr-outline-variant: #c2bb7b;
  --clr-white:           #ffffff;

  /* Convenience aliases matching old code */
  --clr-green:           #06d6a0;
  --clr-red:             #ef476f;
  --clr-blue:            #3b82f6;
  --clr-muted:           #6b662f;
  --clr-card:            #ffffff;

  --radius-sm:  12px;
  --radius-md:  16px;
  --radius-lg:  32px;
  --radius-xl:  50px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);

  --font-headline: 'Plus Jakarta Sans', 'Nunito', sans-serif;
  --font-body:     'Be Vietnam Pro', 'Nunito', sans-serif;
  --font:          var(--font-body);

  --tap-min: 64px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* ── Decorative Orbs ─────────────────────────────────────── */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  opacity: .12;
  z-index: -1;
  pointer-events: none;
}
.orb-1 { width: 24rem; height: 24rem; top: -5rem; left: -5rem; background: var(--clr-tertiary); }
.orb-2 { width: 20rem; height: 20rem; top: 50%; right: -5rem; background: var(--clr-secondary); }
.orb-3 { width: 16rem; height: 16rem; bottom: 0; left: 25%; background: var(--clr-primary); }

/* ── Screens (SPA navigation) ────────────────────────────── */
.screen {
  display: none;
  width: 100%;
  max-width: 700px;
  padding: 20px 16px 40px;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: fadeIn .3s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════
   HOME SCREEN
   ══════════════════════════════════════════════════════════ */

/* ── Hero Title ──────────────────────────────────────────── */
.home-title {
  margin-top: 32px;
  text-align: center;
}
.home-title h1 {
  font-family: var(--font-headline);
  font-size: clamp(2.8rem, 10vw, 5rem);
  font-weight: 900;
  line-height: 1.05;
  color: var(--clr-primary);
  letter-spacing: -.02em;
}
.home-title p {
  font-family: var(--font-headline);
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 700;
  color: var(--clr-text-variant);
  margin-top: 8px;
}

/* ── Range Selector ──────────────────────────────────────── */
.range-section {
  width: 100%;
  text-align: center;
  margin-top: 8px;
}
.range-section h2 {
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 900;
  color: var(--clr-text-variant);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 16px;
}
.range-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.range-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  border-bottom: 6px solid transparent;
  background: var(--clr-surface-low);
  font-family: var(--font-headline);
  cursor: pointer;
  transition: transform .2s, border-bottom-width .1s, translate .1s;
  -webkit-tap-highlight-color: transparent;
}
.range-btn:hover { transform: scale(1.04); }
.range-btn:active { transform: scale(.97); border-bottom-width: 0; translate: 0 6px; }

.range-number {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 900;
  line-height: 1;
}
.range-label {
  font-family: var(--font-body);
  font-size: .65rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 3px 12px;
  border-radius: var(--radius-xl);
}

/* Individual range card colours */
.range-basis {
  border-bottom-color: var(--clr-primary-container);
}
.range-basis .range-number { color: var(--clr-primary); }
.range-basis .range-label {
  background: var(--clr-primary-fixed);
  color: var(--clr-primary-dim);
}

.range-gemiddeld {
  background: var(--clr-secondary-container);
  border-bottom-color: var(--clr-secondary-dim);
}
.range-gemiddeld .range-number { color: var(--clr-on-secondary-container); }
.range-gemiddeld .range-label {
  background: var(--clr-secondary-fixed-dim);
  color: var(--clr-on-secondary-container);
}

.range-expert {
  background: var(--clr-surface-highest);
  border-bottom-color: var(--clr-outline);
}
.range-expert .range-number { color: var(--clr-on-primary-container); }
.range-expert .range-label {
  background: var(--clr-primary-fixed-dim);
  color: var(--clr-on-primary-container);
}

/* ── Star Badge (moves to selected range) ────────────────── */
.star-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--clr-tertiary-container);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: scale(0);
  transition: opacity .25s, transform .25s cubic-bezier(.175,.885,.32,1.275);
  pointer-events: none;
}
.star-badge .material-symbols-outlined {
  font-size: 20px;
  color: var(--clr-white);
}
.range-btn.selected .star-badge {
  opacity: 1;
  transform: scale(1);
}

/* Highlight ring on selected range */
.range-btn.selected {
  outline: 3px solid var(--clr-primary-container);
  outline-offset: 3px;
}

/* ── Mode Cards ──────────────────────────────────────────── */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  width: 100%;
}
@media (min-width: 540px) {
  .mode-cards { grid-template-columns: 1fr 1fr; }
}

.mode-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--clr-card);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform .3s, box-shadow .3s;
  text-decoration: none;
  color: var(--clr-text);
  border: none;
  font-family: var(--font-body);
}
.mode-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.mode-card:active { transform: scale(.98); }

/* Visual / header area of each card */
.card-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 20px;
  transition: transform .4s;
}
.mode-card:hover .card-visual { transform: scale(1.06); }

.listen-visual { background: #d5f5f0; }
.speak-visual  { background: #fce4ec; }

.card-icon-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-icon-circle .material-symbols-outlined {
  font-size: 40px;
}
.listen-circle {
  background: var(--clr-secondary-fixed-dim);
  box-shadow: 0 6px 20px rgba(0,114,90,.25);
}
.listen-circle .material-symbols-outlined { color: var(--clr-on-secondary-container); }

.speak-circle {
  background: var(--clr-tertiary-container);
  box-shadow: 0 6px 20px rgba(179,0,179,.25);
}
.speak-circle .material-symbols-outlined { color: var(--clr-white); }

.card-mode-title {
  font-family: var(--font-headline);
  font-size: 1.8rem;
  font-weight: 900;
}
.listen .card-mode-title { color: var(--clr-secondary); }
.speak  .card-mode-title { color: var(--clr-tertiary); }

/* Body / text area */
.card-body {
  padding: 20px 24px 24px;
}
.card-body p {
  font-size: .95rem;
  font-weight: 700;
  color: var(--clr-text-variant);
  line-height: 1.5;
  margin-bottom: 16px;
}

/* CTA button */
.card-cta {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-xl);
  border: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--clr-white);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background .2s, transform .1s;
}
.card-cta:active { transform: scale(.96); }
.listen-cta { background: var(--clr-secondary); }
.listen-cta:hover { background: var(--clr-secondary-dim); }
.speak-cta  { background: var(--clr-tertiary); }
.speak-cta:hover  { background: var(--clr-tertiary-dim); }


/* ══════════════════════════════════════════════════════════
   EXERCISE SCREENS (Listen & Read)
   ══════════════════════════════════════════════════════════ */

/* ── Back Button ─────────────────────────────────────────── */
.back-btn {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-xl);
  border: 2px solid var(--clr-outline-variant);
  background: transparent;
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 700;
  color: var(--clr-muted);
  cursor: pointer;
  transition: all .15s ease;
}
.back-btn:hover { background: var(--clr-card); color: var(--clr-text); }

/* ── Generic Card Container ──────────────────────────────── */
.card {
  background: var(--clr-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 24px 20px;
  width: 100%;
}

/* ── Mode 1: Listen ──────────────────────────────────────── */
.listen-prompt { text-align: center; }
.listen-prompt p.label {
  font-size: .85rem;
  font-weight: 700;
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 14px;
}
.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 36px;
  border-radius: var(--radius-xl);
  border: none;
  background: linear-gradient(135deg, var(--clr-secondary), var(--clr-secondary-dim));
  color: var(--clr-white);
  font-family: var(--font-body);
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .15s, box-shadow .15s;
}
.speak-btn:hover  { transform: scale(1.05); box-shadow: var(--shadow-lg); }
.speak-btn:active { transform: scale(.95); }
.speak-btn .icon  { font-size: 1.6rem; }
.speak-btn.playing {
  background: linear-gradient(135deg, var(--clr-primary-fixed), var(--clr-primary-fixed-dim));
  color: var(--clr-text);
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* Answer bar */
.answer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 76px;
  padding: 12px 16px;
  background: var(--clr-surface-low);
  border-radius: var(--radius-md);
  border: 3px dashed var(--clr-outline-variant);
  flex-wrap: wrap;
}
.answer-bar.has-answer { border-color: var(--clr-secondary); border-style: solid; }
.answer-bar .answer-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--clr-outline);
  text-transform: uppercase;
  letter-spacing: .07em;
  width: 100%;
  text-align: center;
}
.answer-digit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--clr-secondary);
  color: var(--clr-white);
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
  animation: popIn .15s cubic-bezier(.175,.885,.32,1.275);
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Digit pad */
.digit-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.digit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  border-radius: var(--radius-sm);
  border: none;
  background: var(--clr-blue);
  color: var(--clr-white);
  font-family: var(--font-body);
  font-size: 1.6rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .1s, box-shadow .1s;
  user-select: none;
}
.digit-btn:hover  { transform: scale(1.08); box-shadow: var(--shadow-md); }
.digit-btn:active { transform: scale(.93); }

/* Colour each digit differently */
.digit-btn[data-digit="0"] { background: #6c5ce7; }
.digit-btn[data-digit="1"] { background: #e17055; }
.digit-btn[data-digit="2"] { background: #00b894; }
.digit-btn[data-digit="3"] { background: #0984e3; }
.digit-btn[data-digit="4"] { background: #fdcb6e; color: var(--clr-text); }
.digit-btn[data-digit="5"] { background: #e84393; }
.digit-btn[data-digit="6"] { background: #00cec9; }
.digit-btn[data-digit="7"] { background: #a29bfe; }
.digit-btn[data-digit="8"] { background: #ff7675; }
.digit-btn[data-digit="9"] { background: #55efc4; color: var(--clr-text); }

.erase-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  border-radius: var(--radius-sm);
  border: 2px solid var(--clr-outline-variant);
  background: var(--clr-surface-low);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all .1s;
  grid-column: span 1;
}
.erase-btn:hover  { background: var(--clr-red); color: var(--clr-white); border-color: var(--clr-red); }
.erase-btn:active { transform: scale(.92); }

/* Action row */
.action-row {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-submit {
  flex: 1;
  max-width: 280px;
  min-height: var(--tap-min);
  border-radius: var(--radius-xl);
  border: none;
  background: var(--clr-green);
  color: var(--clr-white);
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .15s, opacity .15s;
}
.btn-submit:hover   { transform: scale(1.04); }
.btn-submit:active  { transform: scale(.96); }
.btn-submit:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-confirm {
  flex: 1;
  max-width: 280px;
  min-height: var(--tap-min);
  border-radius: var(--radius-xl);
  border: none;
  background: var(--clr-green);
  color: var(--clr-white);
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .15s, opacity .15s;
}
.btn-confirm:hover   { transform: scale(1.04); }
.btn-confirm:active  { transform: scale(.96); }
.btn-confirm:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-next {
  flex: 1;
  max-width: 280px;
  min-height: var(--tap-min);
  border-radius: var(--radius-xl);
  border: none;
  background: var(--clr-primary);
  color: var(--clr-on-primary);
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .15s;
  display: none;
}
.btn-next:hover  { transform: scale(1.04); }
.btn-next:active { transform: scale(.96); }
.btn-next.visible { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

/* ── Mode 2: Speak / Read ────────────────────────────────── */
.number-display {
  text-align: center;
  padding: 32px 20px;
  background: linear-gradient(135deg, var(--clr-tertiary), var(--clr-tertiary-dim));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--clr-white);
}
.number-display .big-number {
  font-family: var(--font-headline);
  font-size: clamp(5rem, 20vw, 8rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
}
.number-display .instruct {
  font-size: 1rem;
  opacity: .85;
  margin-top: 8px;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
}
.choice-btn {
  min-height: 72px;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 3px solid transparent;
  background: var(--clr-card);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-body);
  font-size: clamp(.9rem, 3.5vw, 1.15rem);
  font-weight: 700;
  color: var(--clr-text);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s;
  text-align: center;
  word-break: break-word;
  hyphens: auto;
}
.choice-btn:hover  { transform: scale(1.04); box-shadow: var(--shadow-md); }
.choice-btn:active { transform: scale(.96); }
.choice-btn.selected {
  border-color: var(--clr-secondary);
  background: #d5f5f0;
  box-shadow: var(--shadow-md);
  transform: scale(1.04);
}
.choice-btn .choice-icon { margin-right: 4px; }
.choice-btn.correct {
  background: var(--clr-green);
  border-color: #04b386;
  color: var(--clr-white);
}
.choice-btn.wrong {
  background: var(--clr-red);
  border-color: #c73057;
  color: var(--clr-white);
  animation: shake .4s ease;
}
.choice-btn:disabled { cursor: not-allowed; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}


/* ══════════════════════════════════════════════════════════
   FEEDBACK & OVERLAYS
   ══════════════════════════════════════════════════════════ */

.feedback-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.feedback-overlay.show { opacity: 1; pointer-events: all; }
.feedback-overlay .emoji {
  font-size: clamp(5rem, 20vw, 9rem);
  animation: bounceIn .4s cubic-bezier(.175,.885,.32,1.275);
}
.feedback-overlay .msg {
  font-family: var(--font-headline);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 900;
  color: var(--clr-white);
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  text-align: center;
  padding: 0 20px;
}
.feedback-overlay .sub-msg {
  font-size: 1rem;
  color: rgba(255,255,255,.85);
  text-align: center;
}

@keyframes bounceIn {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}

/* ── Confetti Canvas ─────────────────────────────────────── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}

/* ── Screen Titles ───────────────────────────────────────── */
.screen-title {
  font-family: var(--font-headline);
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 900;
}
.screen-subtitle {
  font-size: .9rem;
  color: var(--clr-muted);
  text-align: center;
  margin-top: -12px;
}

/* ── Utilities ───────────────────────────────────────────── */
.hidden { display: none !important; }
.w-full { width: 100%; }
.text-center { text-align: center; }

/* ── Responsive tweaks ───────────────────────────────────── */
@media (max-width: 380px) {
  .digit-pad { grid-template-columns: repeat(4, 1fr); }
  .choice-grid { grid-template-columns: 1fr; }
  .range-buttons { grid-template-columns: 1fr; }
}
