/* =========================================================
   Number Sense — Main Stylesheet
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:        #0d0f14;
  --surface:   #161a24;
  --border:    #252c3d;
  --accent:    #f0c040;
  --accent2:   #4fc3f7;
  --correct:   #43e097;
  --wrong:     #f25c69;
  --text:      #e8eaf0;
  --muted:     #7a84a0;
  --radius:    16px;
  --shadow:    0 8px 40px rgba(0,0,0,.45);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Home: Hero Header ─────────────────────────────────── */
.hero-header {
  text-align: center;
  padding: 72px 24px 40px;
}

.hero-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--text);
}

.title-accent { color: var(--accent); }

.hero-sub {
  margin-top: 14px;
  font-size: 1.1rem;
  color: var(--muted);
}

/* ── Home: Skills Grid ─────────────────────────────────── */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 380px));
  gap: 24px;
  padding: 0 24px 80px;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
}

.skill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .2s, border-color .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.skill-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(240,192,64,.06) 0%, transparent 60%);
  pointer-events: none;
}

.skill-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 50px rgba(240,192,64,.15);
}

.skill-icon {
  font-size: 1.4rem;
  background: rgba(240,192,64,.12);
  border-radius: 12px;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--accent);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
}

.skill-info h2, .skill-info h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.skill-info p {
  font-size: .88rem;
  color: var(--muted);
  margin-top: 4px;
}

.skill-arrow {
  margin-left: auto;
  font-size: 1.4rem;
  color: var(--accent);
  opacity: .7;
  transition: transform .2s, opacity .2s;
}

.skill-card:hover .skill-arrow { transform: translateX(5px); opacity: 1; }

/* ── Practice Page ─────────────────────────────────────── */
.practice-body { background: var(--bg); }

.back-link {
  align-self: flex-start;
  margin: 24px 32px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  transition: color .15s;
}
.back-link:hover { color: var(--text); }

/* ── Stats Bar ─────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 24px 28px;
}

.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 8px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.stat-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 700; color: var(--correct); }
.stat-pill.stat-wrong .stat-value { color: var(--wrong); }
.stat-pill.stat-avg   .stat-value { color: var(--accent2); }

/* ── Arena ─────────────────────────────────────────────── */
.arena {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 44px 44px;
  width: min(560px, calc(100% - 48px));
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

/* ── Arena top row: label + difficulty pills ───────────── */
.arena-top-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.skill-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}

/* ── Difficulty Pills ──────────────────────────────────── */
.diff-pills {
  display: flex;
  gap: 6px;
}

.diff-pill {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .18s;
}

.diff-pill:hover { border-color: var(--accent); color: var(--accent); }

.diff-pill.active[data-diff="easy"]   { background: rgba(67,224,151,.15); border-color: var(--correct); color: var(--correct); }
.diff-pill.active[data-diff="medium"] { background: rgba(240,192,64,.15); border-color: var(--accent);  color: var(--accent); }
.diff-pill.active[data-diff="hard"]   { background: rgba(242,92,105,.15); border-color: var(--wrong);   color: var(--wrong); }

/* ── Timer ─────────────────────────────────────────────── */
.timer-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 99px;
  transform-origin: left;
  transition: background .3s;
}

.timer-text {
  font-family: 'Syne', sans-serif;
  font-size: .9rem;
  color: var(--muted);
  min-width: 44px;
  text-align: right;
}

/* ── Problem Box ───────────────────────────────────────── */
.problem-box {
  width: 100%;
  min-height: 120px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  transition: border-color .25s, background .25s;
  padding: 16px;
}

.problem-box.correct { border-color: var(--correct); background: rgba(67,224,151,.07); }
.problem-box.wrong   { border-color: var(--wrong);   background: rgba(242,92,105,.07); }

.problem-text {
  font-family: 'Syne', sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
  text-align: center;
}

/* ── Standard Answer Row ───────────────────────────────── */
.answer-row {
  width: 100%;
  display: flex;
  gap: 12px;
}

.answer-input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  outline: none;
  transition: border-color .2s;
  -moz-appearance: textfield;
}
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.answer-input:focus { border-color: var(--accent2); }

.submit-btn {
  background: var(--accent);
  color: #0d0f14;
  border: none;
  border-radius: 12px;
  padding: 14px 26px;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, opacity .15s;
}
.submit-btn:hover  { opacity: .88; transform: translateY(-1px); }
.submit-btn:active { transform: scale(.97); }
.submit-btn:disabled { opacity: .4; cursor: default; }

/* ── Fraction Input Row ─────────────────────────────────── */
#answer-row-fraction {
  width: 100%;
  align-items: flex-start;
}

.fraction-hint {
  font-size: .85rem;
  color: var(--muted);
  width: 100%;
}

.fraction-input-group {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.frac-box {
  flex: none;
  width: 90px;
  font-size: 1.2rem;
  padding: 10px 12px;
  text-align: center;
}

.frac-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.frac-top, .frac-bot { width: 80px; font-size: 1.1rem; padding: 8px 10px; }

.frac-line {
  width: 80px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.fraction-sub {
  font-size: .75rem;
  color: var(--muted);
  width: 100%;
  line-height: 1.5;
}

/* ── Lives / X's ───────────────────────────────────────── */
.lives-row { display: flex; gap: 16px; }

.life {
  font-size: 1.6rem;
  color: var(--border);
  transition: color .2s, transform .2s;
}

.life.used {
  color: var(--wrong);
  animation: pop .3s ease;
}

@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* ── Explanation Panel ─────────────────────────────────── */
.explanation-panel {
  width: 100%;
  background: rgba(242,92,105,.08);
  border: 1px solid var(--wrong);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeIn .35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.explanation-title { font-family: 'Syne', sans-serif; font-size: 1.1rem; color: var(--wrong); }
.explanation-body  { font-size: .95rem; color: var(--text); line-height: 1.7; }

.next-btn {
  align-self: flex-end;
  margin-top: 6px;
  background: var(--wrong);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-family: 'Syne', sans-serif;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.next-btn:hover { opacity: .85; }

/* ── Skills sections (grouped by category) ─────────────── */
.skills-wrapper {
  width: 100%;
  max-width: 1200px;
  padding: 0 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.skill-section { display: flex; flex-direction: column; gap: 20px; }

.section-heading {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.skill-section .skills-grid { padding: 0; }

/* ── Memorization hub banner ────────────────────────────── */
.mem-banner-wrap {
  width: 100%;
  max-width: 1200px;
  padding: 0 24px 12px;
}

.mem-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, rgba(79,195,247,.12) 0%, rgba(79,195,247,.04) 100%);
  border: 1px solid var(--accent2);
  border-radius: var(--radius);
  padding: 22px 28px;
  text-decoration: none;
  color: var(--text);
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 24px rgba(79,195,247,.1);
}

.mem-banner:hover { transform: translateY(-3px); box-shadow: 0 8px 36px rgba(79,195,247,.2); }
.mem-banner-icon  { font-size: 2.2rem; flex-shrink: 0; }

.mem-banner-text { display: flex; flex-direction: column; gap: 4px; }
.mem-banner-text strong { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--accent2); }
.mem-banner-text span   { font-size: .85rem; color: var(--muted); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 500px) {
  .arena { padding: 24px 16px 30px; }
  .problem-text { font-size: 1.8rem; }
  .arena-top-row { flex-direction: column; align-items: flex-start; }
  .fraction-input-group { flex-wrap: wrap; }
  .frac-box { width: 70px; }
}
