/* =============================================
   Math & Spelling Practice App — styles.css
   ============================================= */

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

:root {
  --blue-50:  #E6F1FB;
  --blue-200: #85B7EB;
  --blue-600: #185FA5;
  --blue-800: #0C447C;
  --green-50: #EAF3DE;
  --green-600: #3B6D11;
  --red-50:   #FCEBEB;
  --red-600:  #A32D2D;
  --gray-100: #F1EFE8;
  --gray-200: #D3D1C7;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font: system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  background: #f9f9f7;
  color: #1a1a1a;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ── Layout ── */
.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.screen { display: none; }
.screen.active { display: block; }

/* ── Typography ── */
h1 {
  font-size: 22px;
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 14px;
  color: #666;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* ── Grids ── */
.lang-grid,
.grade-grid,
.subject-grid,
.topic-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.lang-grid     { grid-template-columns: repeat(2, 1fr); }
.grade-grid    { grid-template-columns: repeat(3, 1fr); }
.subject-grid  { grid-template-columns: repeat(2, 1fr); }
.topic-grid    { grid-template-columns: repeat(2, 1fr); }

/* ── Card Buttons ── */
.card-btn {
  background: #fff;
  border: 0.5px solid #ccc;
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.card-btn:hover {
  background: #f5f5f3;
  border-color: #aaa;
}

.card-btn.selected {
  border: 2px solid var(--blue-600);
  background: var(--blue-50);
}

.card-btn .flag { font-size: 28px; }
.card-btn .icon { font-size: 24px; }

.card-btn .label {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
}

.card-btn .desc {
  font-size: 12px;
  color: #777;
}

.lang-card { padding: 24px 16px; }

/* ── Buttons ── */
.btn-primary {
  background: var(--blue-600);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover   { background: var(--blue-800); }
.btn-primary:disabled {
  background: #ddd;
  color: #999;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: #666;
  border: 0.5px solid #ccc;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: #f5f5f3; }

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Top bar / pill ── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.lang-pill {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 0.5px solid #ccc;
  color: #666;
  background: #f5f5f3;
  cursor: pointer;
  white-space: nowrap;
}

.lang-pill:hover { background: #fff; }

/* ── Disclaimer ── */
.disclaimer-box {
  background: #fff;
  border: 0.5px solid #ccc;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.disclaimer-box .dis-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  margin-bottom: 10px;
}

.disclaimer-box p {
  font-size: 13px;
  color: #555;
  line-height: 1.7;
  margin-bottom: 10px;
}

.disclaimer-box p:last-child { margin-bottom: 0; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 1.25rem;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--blue-600);
}

.checkbox-row label {
  font-size: 13px;
  color: #555;
  line-height: 1.6;
  cursor: pointer;
}

/* ── Progress & Session ── */
.progress-bar {
  height: 6px;
  background: #e8e8e5;
  border-radius: 3px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--blue-600);
  border-radius: 3px;
  transition: width 0.3s;
}

.session-info {
  font-size: 13px;
  color: #666;
}

/* ── Question Card ── */
.question-card {
  background: #fff;
  border: 0.5px solid #ddd;
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.question-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.question-text {
  font-size: 28px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1.4;
}

.question-hint {
  font-size: 14px;
  color: #aaa;
  margin-top: 10px;
}

/* ── Answer Choices ── */
.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 1.5rem;
}

.choice-btn {
  background: #fff;
  border: 0.5px solid #ccc;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 17px;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.choice-btn:hover:not(:disabled) {
  background: #f5f5f3;
  border-color: #aaa;
}

.choice-btn.correct {
  background: var(--green-50);
  border: 2px solid var(--green-600);
  color: var(--green-600);
}

.choice-btn.wrong {
  background: var(--red-50);
  border: 2px solid var(--red-600);
  color: var(--red-600);
}

.choice-btn:disabled { cursor: default; }

/* ── Spelling Input ── */
.spelling-letters {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.75rem 0 1rem;
}

.letter-tile {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #f0f0ee;
  border: 0.5px solid #ccc;
  font-size: 16px;
  font-weight: 500;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.type-input-wrap {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.type-input-wrap input {
  flex: 1;
  font-size: 20px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 0.5px solid #ccc;
  padding: 10px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  font-family: var(--font);
}

.type-input-wrap input:focus {
  box-shadow: 0 0 0 2px var(--blue-600);
  border-color: var(--blue-600);
}

/* ── Feedback ── */
.feedback-bar {
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 1rem;
  text-align: center;
  display: none;
}

.feedback-bar.correct {
  background: var(--green-50);
  color: var(--green-600);
}

.feedback-bar.wrong {
  background: var(--red-50);
  color: var(--red-600);
}

/* ── Results ── */
.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.stat-card {
  flex: 1;
  background: #f0f0ee;
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.stat-card .val {
  font-size: 24px;
  font-weight: 500;
  color: #1a1a1a;
}

.stat-card .lbl {
  font-size: 12px;
  color: #777;
  margin-top: 2px;
}

.badge-area {
  text-align: center;
  font-size: 15px;
  color: #555;
  margin-bottom: 1.5rem;
}

/* ── Contact / Suggestions ── */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: #333;
}

.form-label .required {
  color: var(--red-600);
}

.form-input {
  border: 0.5px solid #ccc;
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  color: #1a1a1a;
  background: #fff;
  transition: box-shadow 0.15s, border-color 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 2px var(--blue-50);
}

select.form-input { cursor: pointer; }

.form-textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}

.form-hint {
  font-size: 12px;
  color: #888;
}

.contact-notice {
  background: #f5f5f3;
  border: 0.5px solid #ddd;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  color: #555;
  line-height: 1.6;
}

.contact-success {
  background: var(--green-50);
  border: 0.5px solid var(--green-600);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--green-600);
  text-align: center;
  margin-top: 0.5rem;
}

/* ── Floating Contact Button ── */
.contact-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  transition: background 0.15s, transform 0.15s;
  z-index: 100;
}

.contact-fab:hover {
  background: var(--blue-800);
  transform: scale(1.08);
}

.contact-fab.hidden { display: none; }

/* ── Language Welcome ── */
.lang-welcome {
  text-align: center;
  margin-bottom: 2rem;
  padding-top: 1rem;
}

.lang-welcome h1 { font-size: 26px; }
.lang-welcome .subtitle { font-size: 16px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .grade-grid { grid-template-columns: repeat(2, 1fr); }
  .choices-grid { grid-template-columns: 1fr; }
  .stats-row { gap: 8px; }
  .question-text { font-size: 22px; }
  .lang-grid { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 20px; }
}

/* ══════════════════════════════════════════
   TIMER
   ══════════════════════════════════════════ */

.question-card-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.question-card-inner > div:first-child {
  flex: 1;
  text-align: left;
}

.timer-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.timer-svg {
  width: 52px;
  height: 52px;
  transform: rotate(0deg);
}

.timer-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 500;
  color: #3B6D11;
  line-height: 1;
  pointer-events: none;
}

/* Animate the ring smoothly */
#timer-ring-fill {
  transition: stroke-dashoffset 0.9s linear, stroke 0.3s;
}

/* ══════════════════════════════════════════
   STREAK BADGE
   ══════════════════════════════════════════ */

.practice-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.streak-badge {
  font-size: 14px;
  font-weight: 500;
  color: #BA7517;
  background: #FAEEDA;
  border: 0.5px solid #EF9F27;
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   RESULTS — 4-column stat grid
   ══════════════════════════════════════════ */

.stats-row {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .question-card-inner {
    flex-direction: column-reverse;
    align-items: center;
  }

  .question-card-inner > div:first-child {
    text-align: center;
  }
}

/* ══════════════════════════════════════════
   FAB TOOLBAR (fixed bottom-right)
   ══════════════════════════════════════════ */

.fab-toolbar {
  position: fixed;
  bottom: 24px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 200;
}

/* ── Contact FAB ── */
.contact-fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue-600);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  transition: background 0.15s, transform 0.15s;
}

.contact-fab:hover {
  background: var(--blue-800);
  transform: scale(1.08);
}

/* ── Sound toggle pill ── */
.sound-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 0.5px solid #ccc;
  border-radius: 24px;
  padding: 5px 10px 5px 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
  cursor: pointer;
  user-select: none;
}

.sound-toggle-label {
  font-size: 16px;
  line-height: 1;
  min-width: 20px;
  text-align: center;
}

/* ── Toggle switch ── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #ccc;
  transition: background 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--blue-600);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}

/* ── Accessibility: focus ring on toggle ── */
.toggle-switch input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 2px var(--blue-600);
}

/* ── Parent label hint (shown on hover, desktop only) ── */
@media (hover: hover) {
  .sound-toggle-wrap::before {
    content: attr(data-label);
    position: absolute;
    right: calc(100% + 8px);
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
  }
  .sound-toggle-wrap:hover::before { opacity: 1; }
}

/* ══════════════════════════════════════════
   SKIP / I DON'T KNOW BUTTON
   ══════════════════════════════════════════ */

.btn-skip {
  background: transparent;
  color: #888;
  border: 0.5px dashed #bbb;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex: 1;
}

.btn-skip:hover {
  background: #f5f5f3;
  color: #555;
  border-color: #aaa;
  border-style: solid;
}
