/* ============================================================
   DigitalKiddo™ Maths — Learning Centre Styles
   A simple, distraction-free digital textbook.
   Builds on assets/css/style.css design tokens.
   ============================================================ */

/* ---- Learning Hero ---------------------------------------- */
.learn-hero {
  background: linear-gradient(135deg, #6c63ff, #8b85ff 55%, #a29bfe);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  color: #fff;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.learn-hero::after {
  content: '📚'; position: absolute; right: -10px; bottom: -20px;
  font-size: 9rem; opacity: 0.12; transform: rotate(-12deg); pointer-events: none;
}
.learn-hero h1 { color: #fff; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.learn-hero p { color: rgba(255,255,255,0.9); margin-top: 0.4rem; max-width: 560px; font-size: 1.05rem; }
.learn-hero-stats {
  display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; position: relative; z-index: 1;
}
.learn-stat {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius); padding: 1rem 1.5rem; backdrop-filter: blur(4px); min-width: 160px;
}
.learn-stat .ls-num { font-family: 'Fredoka One', cursive; font-size: 2rem; line-height: 1; }
.learn-stat .ls-lbl { font-size: 0.85rem; opacity: 0.9; display: block; margin-top: 0.35rem; }
.learn-stat .ls-ico { font-size: 1.2rem; }

/* ---- Section headers -------------------------------------- */
.learn-section { margin-bottom: 1.75rem; }
.learn-section > h3 { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }

/* ---- Popular Learning Paths (Academies) ------------------- */
.academies-section { display: none; }   /* entire Popular Learning Paths section hidden by request */
.academies-head { margin-bottom: 1.1rem; }
.academies-head h3 { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.academies-sub { color: var(--gray-600); font-weight: 600; font-size: 1rem; margin: 0; }

.academy-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.academy-card {
  --ac-color: var(--primary);
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 0.55rem;
  background: var(--white);
  border: 2px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 1.85rem 1.25rem 1.5rem;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  opacity: 0;
  transform: translateY(12px);
  animation: academyIn 0.5s ease forwards;
  animation-delay: var(--ac-delay, 0ms);
}
@keyframes academyIn { to { opacity: 1; transform: translateY(0); } }

/* coloured accent band along the top */
.academy-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: var(--ac-color);
}
.academy-card:hover,
.academy-card:focus-visible {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 18px 42px color-mix(in srgb, var(--ac-color) 30%, transparent);
  border-color: var(--ac-color);
  outline: none;
}

.academy-icon {
  width: 78px; height: 78px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem; border-radius: 22px;
  background: color-mix(in srgb, var(--ac-color) 14%, var(--white));
  margin-top: 0.25rem;
}
.academy-title {
  font-family: 'Fredoka One', cursive; font-size: 1.2rem;
  color: var(--ac-color); margin: 0;
}
.academy-desc {
  font-size: 0.9rem; color: var(--gray-600); line-height: 1.45;
  margin: 0; flex: 1;
}
.academy-btn {
  margin-top: 0.45rem; font-weight: 800; font-size: 0.9rem; color: #fff;
  background: var(--ac-color);
  padding: 0.6rem 1.5rem; border-radius: 50px;
  transition: filter 0.2s ease;
}
.academy-card:hover .academy-btn { filter: brightness(1.06); }

/* Per-academy themes */
.academy-card[data-theme="blue"]   { --ac-color: #3b9dff; }
.academy-card[data-theme="orange"] { --ac-color: #ff9f43; }
.academy-card[data-theme="green"]  { --ac-color: #20bf6b; }
.academy-card[data-theme="purple"] { --ac-color: #a55eea; }

/* Responsive: tablet → 2 per row, mobile → 1 per row */
@media (max-width: 900px) { .academy-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .academy-grid { grid-template-columns: 1fr; } }

/* ---- Academy modal ---------------------------------------- */
.academy-modal { --ac-color: var(--primary); text-align: center; }
.academy-modal[data-theme="blue"]   { --ac-color: #3b9dff; }
.academy-modal[data-theme="orange"] { --ac-color: #ff9f43; }
.academy-modal[data-theme="green"]  { --ac-color: #20bf6b; }
.academy-modal[data-theme="purple"] { --ac-color: #a55eea; }

.academy-modal-icon {
  width: 84px; height: 84px; margin: 0 auto 0.75rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem; border-radius: 24px;
  background: color-mix(in srgb, var(--ac-color) 16%, var(--white));
}
.academy-modal-title {
  font-family: 'Fredoka One', cursive; color: var(--ac-color); margin-bottom: 0.35rem;
}
.academy-modal-desc { color: var(--gray-600); margin-bottom: 1.25rem; }
.academy-modal-topics-head {
  text-align: left; font-weight: 800; font-size: 0.95rem;
  color: var(--gray-600); margin-bottom: 0.55rem;
}
.academy-topic-list {
  list-style: none; margin: 0 0 1.5rem; padding: 0; text-align: left;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.85rem;
  max-height: 240px; overflow-y: auto;
}
.academy-topic-list li {
  position: relative; padding: 0.55rem 0.75rem 0.55rem 2rem;
  background: color-mix(in srgb, var(--ac-color) 7%, var(--white));
  border: 1px solid color-mix(in srgb, var(--ac-color) 20%, transparent);
  border-radius: 12px; font-size: 0.9rem; font-weight: 600; color: #2d3436;
}
.academy-topic-list li::before {
  content: '✦'; position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--ac-color); font-size: 0.8rem;
}
.academy-start {
  width: 100%;
  background: linear-gradient(135deg, var(--ac-color), color-mix(in srgb, var(--ac-color) 72%, #000)) !important;
  border: none !important;
}

@media (max-width: 480px) {
  .academy-topic-list { grid-template-columns: 1fr; }
}

/* ---- Year selector → collapsible accordion ---------------- */
.years-head { margin-bottom: 1.1rem; }
.years-head h3 { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.years-sub { color: var(--gray-600); font-weight: 600; font-size: 1rem; margin: 0; }

.year-accordion { display: flex; flex-direction: column; gap: 1rem; }

.year-item {
  --year-color: var(--primary);
  background: var(--white);
  border: 3px solid var(--gray-100);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.year-item:hover { border-color: color-mix(in srgb, var(--year-color) 40%, transparent); }
/* Expanded: highlighted background, stronger border, soft shadow */
.year-item.expanded {
  border-color: var(--year-color);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--year-color) 22%, rgba(0,0,0,0.06));
}

/* Header — the whole card is the clickable, touch-friendly tap target */
.year-card {
  width: 100%; display: flex; align-items: center; gap: 1rem;
  text-align: left; cursor: pointer; user-select: none;
  background: transparent; border: none; position: relative;
  padding: 1.25rem 1.4rem;
  transition: background 0.2s ease;
}
.year-card::before {
  content: ''; position: absolute; inset: 0; background: var(--year-color);
  opacity: 0; transition: opacity 0.25s ease; pointer-events: none;
}
.year-card.expanded::before { opacity: 0.06; }
.year-card:hover { background: color-mix(in srgb, var(--year-color) 6%, var(--white)); }
.year-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--year-color) 45%, transparent);
  outline-offset: -3px;
}
.year-card > * { position: relative; z-index: 1; }

/* Rotating chevron: ▶ collapsed → ▼ expanded */
.year-chevron {
  flex: 0 0 auto; width: 1.2rem; text-align: center;
  font-size: 1.05rem; line-height: 1; color: var(--year-color);
  transition: transform 0.3s ease;
}
.year-card.expanded .year-chevron { transform: rotate(90deg); }

.year-emoji { flex: 0 0 auto; font-size: 2.2rem; }
.year-head-text { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-width: 0; }
.year-name { font-family: 'Fredoka One', cursive; font-size: 1.35rem; line-height: 1.1; }
.year-sub { font-size: 0.82rem; color: var(--gray-600); font-weight: 700; }

/* Collapsible topics panel — smooth accordion animation */
.year-panel {
  max-height: 0; opacity: 0; overflow: hidden;
  padding: 0 1.4rem;
  transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
}
.year-panel.expanded {
  max-height: 5000px; opacity: 1;
  padding: 0.25rem 1.4rem 1.4rem;
}
.year-panel .topics-grid { margin-top: 0.25rem; }

/* Tablet / mobile — keep the header compact and tappable */
@media (max-width: 560px) {
  .year-card { gap: 0.75rem; padding: 1.1rem 1.1rem; }
  .year-emoji { font-size: 1.9rem; }
  .year-name { font-size: 1.2rem; }
  .year-panel { padding-left: 1.1rem; padding-right: 1.1rem; }
  .year-panel.expanded { padding-left: 1.1rem; padding-right: 1.1rem; }
}

/* ============================================================
   ✖️ Sifir Quick Reference — multiplication study guide
   ============================================================ */
.sifir-head { margin: 0; }
.sifir-header .sifir-head h3 { margin-bottom: 0.25rem; }
.sifir-sub { color: var(--gray-600); font-weight: 600; font-size: 1rem; margin: 0; }

/* ---- Collapsible accordion header ------------------------- */
.sifir-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  cursor: pointer; user-select: none;
  background: var(--white);
  border: 2px solid color-mix(in srgb, var(--primary) 14%, transparent);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 8%, transparent);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.sifir-header:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 32%, transparent);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--primary) 16%, transparent);
}
.sifir-header:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
  outline-offset: 2px;
}
.sifir-header:active { transform: translateY(0); }

/* "12 Sifir Available" pill */
.sifir-count {
  display: inline-block; margin-top: 0.6rem;
  font-size: 0.82rem; font-weight: 700; letter-spacing: 0.01em;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--white));
  border-radius: 999px; padding: 0.25rem 0.7rem;
}

/* Rotating chevron */
.sifir-chevron {
  flex: 0 0 auto;
  font-size: 1.9rem; line-height: 1; font-weight: 700;
  color: var(--primary);
  transition: transform 0.3s ease;
}
.sifir-header[aria-expanded="true"] .sifir-chevron { transform: rotate(180deg); }

/* ---- Collapsible content --------------------------------- */
.sifir-content {
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin-top 0.35s ease;
}
.sifir-content.expanded {
  max-height: 3000px; opacity: 1; margin-top: 1.1rem;
}


/* Responsive grid — 6 desktop · 4 tablet · 2 mobile */
.sifir-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
}

/* Per-card colour themes (repeat across all 12 cards). */
.sifir-card[data-color="blue"],   .sifir-modal[data-color="blue"]   { --c: #4dabf7; --c-ink: #1565a8; }
.sifir-card[data-color="green"],  .sifir-modal[data-color="green"]  { --c: #2bcb78; --c-ink: #128a4f; }
.sifir-card[data-color="orange"], .sifir-modal[data-color="orange"] { --c: #ff9f43; --c-ink: #c46a12; }
.sifir-card[data-color="purple"], .sifir-modal[data-color="purple"] { --c: #845ef7; --c-ink: #5a37c4; }
.sifir-card[data-color="yellow"], .sifir-modal[data-color="yellow"] { --c: #f7b500; --c-ink: #a87900; }
.sifir-card[data-color="pink"],   .sifir-modal[data-color="pink"]   { --c: #fd79a8; --c-ink: #c43e74; }

.sifir-card {
  --c: var(--primary); --c-ink: var(--primary);
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  text-align: center; cursor: pointer;
  background: color-mix(in srgb, var(--c) 9%, var(--white));
  border: 2px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-radius: var(--radius); padding: 1.1rem 0.9rem 1rem;
  min-height: 132px; /* touch-friendly */
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), box-shadow var(--transition), border-color var(--transition);
}
.sifir-card:hover, .sifir-card:focus-visible {
  transform: translateY(-5px);
  border-color: var(--c);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--c) 28%, transparent);
  outline: none;
}
.sifir-card:active { transform: translateY(-2px) scale(0.99); }
.sifir-card-mark { font-size: 1.5rem; line-height: 1; }
.sifir-card-title { font-family: 'Fredoka One', cursive; font-size: 1.2rem; color: var(--c-ink); }
.sifir-card-preview {
  display: flex; flex-direction: column; gap: 0.1rem;
  font-size: 0.82rem; font-weight: 700; color: var(--gray-600); line-height: 1.4;
}
.sifir-card-cta {
  margin-top: auto; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.3px;
  text-transform: uppercase; color: var(--c-ink);
  background: color-mix(in srgb, var(--c) 18%, var(--white));
  border-radius: 50px; padding: 0.28rem 0.8rem;
}

/* ---- Sifir modal (full table) ---- */
.modal-overlay .modal:has(.sifir-modal) { max-width: 480px; width: 100%; }
.sifir-modal { --c: var(--primary); --c-ink: var(--primary); width: 100%; }
.sifir-modal-head { text-align: center; margin-bottom: 1rem; }
.sifir-modal-mark { font-size: 2.6rem; }
.sifir-modal-title { font-size: 1.8rem; margin: 0.2rem 0 0.1rem; color: var(--c-ink); }
.sifir-modal-sub { font-size: 0.85rem; color: var(--gray-600); font-weight: 700; margin: 0; }

.sifir-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 1.1rem; }

.sifir-table {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
}
.sifir-row {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  background: color-mix(in srgb, var(--c) 8%, var(--gray-100));
  border: 2px solid color-mix(in srgb, var(--c) 16%, transparent);
  border-radius: var(--radius-sm); padding: 0.6rem 0.4rem;
  font-size: 1.15rem; font-weight: 800; color: var(--dark);
}
.sifir-eq { color: var(--gray-600); }
.sifir-equals { color: var(--c-ink); }
.sifir-product { font-family: 'Fredoka One', cursive; font-size: 1.3rem; color: var(--c-ink); }

body.large-text .sifir-card-preview { font-size: 0.95rem; }
body.large-text .sifir-row { font-size: 1.3rem; }

/* ============================================================
   📖 All Sifir Tables modal — responsive study-book layout
   ============================================================
   The shared `.modal` is normally capped at 500px and scrolls as a
   whole (which scrolls the close button + header out of view). For
   this modal we widen it and turn it into a flex column: a fixed
   header (title + jump chips) on top, the card grid as the only
   scrolling region below. The absolute close button then stays put. */
.modal.modal--sifir-all {
  max-width: min(1200px, 95vw);
  width: 95vw;
  max-height: 90vh;
  max-height: 90dvh;
  padding: 0;                 /* header/grid manage their own padding */
  overflow: hidden;           /* inner grid scrolls, not the modal */
  display: flex; flex-direction: column;
}
.sifir-modal--all {
  display: flex; flex-direction: column;
  min-height: 0; flex: 1;     /* fill the modal so the grid can scroll */
}

/* ---- Fixed header (never scrolls; close button sits over it) ---- */
.sifir-all-head {
  flex: 0 0 auto;
  padding: 1.4rem 3.25rem 1rem 1.5rem;   /* right pad clears the ✕ button */
  border-bottom: 2px solid var(--gray-100);
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.sifir-all-head .sifir-modal-title { text-align: left; margin: 0; }
.sifir-all-head .sifir-modal-sub { text-align: left; margin: 0.15rem 0 0; }

/* Quick-jump chips — smooth-scroll to a table */
.sifir-jump {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-top: 0.9rem;
}
.sifir-jump-btn {
  cursor: pointer; white-space: nowrap;
  font-size: 0.8rem; font-weight: 700; color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--white));
  border: 2px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: 50px; padding: 0.3rem 0.7rem;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.sifir-jump-btn:hover, .sifir-jump-btn:focus-visible {
  background: var(--primary); color: #fff; transform: translateY(-1px); outline: none;
}

/* ---- Scrolling card grid (the only scroll region) ---- */
.sifir-all-grid {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
}

.sifir-all-card {
  --c: var(--primary); --c-ink: var(--primary);
  display: flex; flex-direction: column;
  text-align: left; cursor: pointer;
  min-height: 320px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 7%, var(--white));
  border: 2px solid color-mix(in srgb, var(--c) 26%, transparent);
  border-radius: 18px; padding: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.sifir-all-card[data-color="blue"]   { --c: #4dabf7; --c-ink: #1565a8; }
.sifir-all-card[data-color="green"]  { --c: #2bcb78; --c-ink: #128a4f; }
.sifir-all-card[data-color="orange"] { --c: #ff9f43; --c-ink: #c46a12; }
.sifir-all-card[data-color="purple"] { --c: #845ef7; --c-ink: #5a37c4; }
.sifir-all-card[data-color="yellow"] { --c: #f7b500; --c-ink: #a87900; }
.sifir-all-card[data-color="pink"]   { --c: #fd79a8; --c-ink: #c43e74; }
.sifir-all-card:hover, .sifir-all-card:focus-visible {
  transform: translateY(-3px); outline: none;
  border-color: var(--c);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--c) 26%, transparent);
}
.sifir-all-title {
  display: block; margin-bottom: 0.7rem;
  font-family: 'Fredoka One', cursive; font-size: 1.15rem; color: var(--c-ink);
}

/* Rows listed one-per-line like a study book — easy to read. */
.sifir-table--mini { display: flex; flex-direction: column; gap: 0.3rem; }
.sifir-table--mini .sifir-row {
  justify-content: flex-start; gap: 0.5rem;
  font-size: 15px; line-height: 1.8; padding: 0.25rem 0.6rem;
}
.sifir-table--mini .sifir-product { font-size: 1rem; }

/* The auto-fit grid above naturally gives ~4-5 columns on desktop and
   ~2-3 on tablets. On phones we force a single comfortable column. */
@media (max-width: 560px) {
  .sifir-all-grid { grid-template-columns: 1fr; padding: 1rem 1.1rem 1.25rem; }
  .sifir-all-head { padding: 1.2rem 3rem 0.9rem 1.2rem; }
  .sifir-jump { gap: 0.35rem; }
}

/* ---- Topic toolbar (search + difficulty filter) ----------- */
.topics-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1.1rem; }
.learn-search-wrap { position: relative; flex: 1; min-width: 200px; }
.learn-search-wrap input {
  width: 100%; padding: 0.7rem 1rem 0.7rem 2.4rem; border: 2px solid var(--gray-200);
  border-radius: var(--radius); font-size: 0.95rem; transition: var(--transition);
}
.learn-search-wrap input:focus { outline: none; border-color: var(--primary); }
.learn-search-wrap::before { content: '🔍'; position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); }
.filter-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.filter-pill {
  padding: 0.5rem 0.95rem; border: 2px solid var(--gray-200); border-radius: 50px;
  font-size: 0.82rem; font-weight: 700; color: var(--gray-600); background: var(--white); transition: var(--transition);
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- Difficulty filter — hidden from UI (logic kept intact) ----
   To re-enable the difficulty filter in future, simply remove this rule. */
.difficulty-filter-container,
#difficultyFilter {
  display: none !important;
}

/* ---- Topics header (rich section header) ------------------ */
.topics-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.35rem;
}
.topics-heading { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.topics-tagline { margin: 0.35rem 0 0; color: var(--gray-600); font-size: 1.05rem; font-weight: 600; }
.topics-header-meta { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.topics-meta-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: color-mix(in srgb, var(--primary) 10%, var(--white));
  border: 2px solid color-mix(in srgb, var(--primary) 22%, transparent);
  color: var(--primary); font-weight: 800; font-size: 0.95rem;
  padding: 0.5rem 1rem; border-radius: 50px; white-space: nowrap;
}
.topics-meta-chip .tmc-num { font-family: 'Fredoka One', cursive; font-size: 1.15rem; line-height: 1; }
.topics-meta-chip--year {
  background: color-mix(in srgb, var(--green) 12%, var(--white));
  border-color: color-mix(in srgb, var(--green) 28%, transparent); color: #128a4f;
}

/* ---- Topic cards (colour-coded learning library) ---------- */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.35rem;
}

/* Per-card colour themes — assigned by topic id hash in learning.js. */
.topic-card[data-color="blue"]   { --c: #4dabf7; --c-ink: #1565a8; }
.topic-card[data-color="green"]  { --c: #2bcb78; --c-ink: #128a4f; }
.topic-card[data-color="orange"] { --c: #ff9f43; --c-ink: #c46a12; }
.topic-card[data-color="purple"] { --c: #845ef7; --c-ink: #5a37c4; }
.topic-card[data-color="yellow"] { --c: #f7b500; --c-ink: #a87900; }
.topic-card[data-color="pink"]   { --c: #fd79a8; --c-ink: #c43e74; }

.topic-card {
  --c: var(--primary); --c-ink: var(--primary);
  position: relative; background: var(--white);
  border: 2px solid color-mix(in srgb, var(--c) 18%, var(--gray-100));
  border-radius: var(--radius); padding: 1.6rem 1.4rem 1.4rem;
  cursor: pointer; display: flex; flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow var(--transition), border-color var(--transition);
  overflow: hidden;
  animation: topicCardIn 0.5s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: var(--card-delay, 0ms);
}
.topic-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 6px;
  background: var(--c); opacity: 0.9;
}
.topic-card:hover, .topic-card:focus-visible {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 16px 36px color-mix(in srgb, var(--c) 32%, transparent);
  border-color: var(--c); outline: none;
}
.topic-card:active { transform: translateY(-2px) scale(0.99); }

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

.topic-badge {
  align-self: flex-start; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.3px;
  text-transform: uppercase; color: var(--c-ink);
  background: color-mix(in srgb, var(--c) 16%, var(--white));
  padding: 0.28rem 0.7rem; border-radius: 50px; margin-bottom: 0.85rem;
}
.topic-icon-wrap {
  width: 72px; height: 72px; border-radius: 22px;
  background: color-mix(in srgb, var(--c) 16%, var(--white));
  display: flex; align-items: center; justify-content: center; margin-bottom: 0.75rem;
}
.topic-icon { font-size: 2.7rem; line-height: 1; }
.topic-title { margin: 0 0 0.4rem; font-size: 1.3rem; line-height: 1.25; color: var(--dark); }
.topic-desc { margin: 0 0 0.9rem; font-size: 0.95rem; line-height: 1.5; color: var(--gray-600); }
.topic-meta { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1.1rem; }
.topic-time {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; font-weight: 800;
  color: var(--c-ink); background: color-mix(in srgb, var(--c) 12%, var(--white));
  padding: 0.3rem 0.7rem; border-radius: 50px;
}
.topic-actions { display: flex; gap: 0.6rem; margin-top: auto; }
.topic-btn {
  flex: 1; padding: 0.7rem 0.6rem; border-radius: 50px; font-size: 0.9rem; font-weight: 800;
  cursor: pointer; transition: transform 0.15s ease, box-shadow var(--transition), background var(--transition);
  border: 2px solid transparent; white-space: nowrap;
}
.topic-btn--learn {
  background: var(--c); color: #fff;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 35%, transparent);
}
.topic-btn--learn:hover { filter: brightness(1.05); transform: translateY(-2px); }
.topic-btn--quiz {
  background: var(--white); color: var(--c-ink);
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
}
.topic-btn--quiz:hover { background: color-mix(in srgb, var(--c) 12%, var(--white)); transform: translateY(-2px); }
.topic-btn:active { transform: translateY(0) scale(0.96); }

/* ---- Empty state ------------------------------------------ */
.topics-empty {
  grid-column: 1/-1; text-align: center; padding: 3.5rem 1.5rem; color: var(--gray-600);
  background: color-mix(in srgb, var(--primary) 5%, var(--white));
  border: 2px dashed color-mix(in srgb, var(--primary) 25%, transparent); border-radius: var(--radius);
}
.topics-empty-emoji { font-size: 3.5rem; margin-bottom: 0.5rem; animation: topicCardIn 0.5s ease both; }
.topics-empty h4 { font-size: 1.35rem; margin-bottom: 0.35rem; color: var(--dark); }
.topics-empty p { font-size: 1rem; }

/* ---- Lesson Viewer (inside modal) ------------------------- */
.modal-overlay .modal:has(.lesson-viewer) { max-width: 620px; width: 100%; }
.lesson-viewer { width: 100%; }
.lv-head { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1rem; }
.lv-icon { font-size: 2.6rem; }
.lv-title { margin: 0; font-size: 1.4rem; text-align: left; }
.lv-sub { font-size: 0.8rem; color: var(--gray-600); font-weight: 700; }
.lv-steps { display: flex; gap: 6px; margin-bottom: 1.25rem; }
.lv-dot { flex: 1; height: 6px; border-radius: 20px; background: var(--gray-200); transition: var(--transition); }
.lv-dot.active { background: var(--primary); }
.lv-dot.done { background: var(--green); }
.lv-body { min-height: 240px; }
.lv-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 1.5rem; gap: 0.75rem; }
.lv-step-count { font-size: 0.8rem; color: var(--gray-600); font-weight: 700; }

.lv-intro { text-align: center; padding: 0.5rem 0; }
.lv-intro-emoji { font-size: 4rem; margin-bottom: 0.75rem; }
.lv-lead { font-size: 1.1rem; color: var(--dark); line-height: 1.6; }
.lv-readaloud {
  margin-top: 1rem; padding: 0.5rem 1rem; border: 2px solid var(--primary); color: var(--primary);
  border-radius: 50px; font-weight: 700; font-size: 0.85rem; background: var(--white); transition: var(--transition);
}
.lv-readaloud:hover { background: var(--primary); color: #fff; }

.lv-explain { background: var(--gray-100); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 0.85rem; }
.lv-visual {
  font-size: 1.3rem; text-align: center; padding: 0.85rem; background: var(--white);
  border-radius: var(--radius-sm); margin-bottom: 0.7rem; line-height: 1.5;
}
.lv-explain p { color: var(--dark); margin: 0; }

.lv-example { border: 2px solid var(--gray-100); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.85rem; }
.lv-example-q { font-weight: 800; display: flex; align-items: center; gap: 0.5rem; }
.lv-example-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0;
}
.lv-example-steps { margin: 0.6rem 0 0.6rem 2rem; color: var(--gray-600); font-size: 0.9rem; list-style: decimal; }
.lv-example-steps li { margin-bottom: 0.2rem; }
.lv-example-ans { background: rgba(38,222,129,0.1); border-radius: var(--radius-sm); padding: 0.5rem 0.85rem; font-size: 0.95rem; }

.lv-interactive-prompt { text-align: center; font-weight: 700; margin-bottom: 1rem; color: var(--primary); }
.lv-widget { display: flex; justify-content: center; }

.lv-quiz-intro, .lv-summary { text-align: center; }
.lv-quiz-emoji { font-size: 3.5rem; margin-bottom: 0.5rem; }
.lv-quiz-intro h4 { margin-bottom: 0.5rem; }
.lv-quiz-intro p { line-height: 1.6; }
.lv-quiz-intro .btn { margin-top: 1.25rem; }
.lv-summary { text-align: left; }
.lv-summary h4 { text-align: center; margin-bottom: 1rem; }
.lv-summary-list { display: flex; flex-direction: column; gap: 0.5rem; }
.lv-summary-list li { background: var(--gray-100); border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; font-weight: 600; }
.lv-summary-tip { text-align: center; font-size: 0.85rem; color: var(--gray-600); margin-top: 1rem; }

/* ---- Quick Quiz (self-practice — no scores saved) --------- */
.quiz-box { padding: 0.5rem 0; }
.quiz-progress { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; font-size: 0.8rem; font-weight: 700; color: var(--gray-600); }
.quiz-progress-bar { background: var(--gray-200); border-radius: 20px; height: 8px; overflow: hidden; }
.quiz-progress-bar div { height: 100%; background: var(--primary); border-radius: 20px; transition: width 0.4s ease; }
.quiz-q { font-family: 'Fredoka One', cursive; font-size: 1.3rem; text-align: center; margin-bottom: 1.25rem; }
.quiz-options { display: grid; gap: 0.65rem; }
.quiz-opt {
  padding: 0.9rem 1rem; border: 2px solid var(--gray-200); border-radius: var(--radius);
  font-size: 1rem; font-weight: 700; background: var(--white); transition: var(--transition); text-align: left;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--primary); transform: translateX(4px); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.correct { background: rgba(38,222,129,0.15); border-color: var(--green); color: #128a4f; }
.quiz-opt.wrong { background: rgba(255,107,107,0.12); border-color: var(--secondary); color: #c0392b; }
.quiz-hint { text-align: center; margin-top: 0.9rem; color: var(--orange); font-weight: 700; font-size: 0.9rem; min-height: 1.2rem; }

.quiz-result { text-align: center; padding: 0.5rem 0; }
.quiz-result-emoji { font-size: 4rem; }
.quiz-result h3 { margin: 0.25rem 0; }
.quiz-score-big {
  font-family: 'Fredoka One', cursive; font-size: 2.2rem; margin: 0.5rem 0;
  color: var(--primary);
}
.quiz-result.pass .quiz-score-big { color: var(--green); }
.quiz-result.fail .quiz-score-big { color: var(--orange); }
.quiz-result-actions { display: flex; gap: 0.6rem; justify-content: center; margin-top: 1.25rem; flex-wrap: wrap; }

/* ---- Interactive Widgets ---------------------------------- */
.lv-widget .w-feedback { text-align: center; margin-top: 0.85rem; font-weight: 700; color: var(--green); min-height: 1.3rem; }

/* Counters */
.w-counters { text-align: center; width: 100%; }
.w-counter-stage {
  min-height: 90px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center;
  background: var(--gray-100); border-radius: var(--radius); padding: 1rem;
}
.w-counter-emoji { font-size: 1.9rem; animation: pop 0.25s ease; }
.w-counter-empty { color: var(--gray-400); }
.w-counter-num { font-family: 'Fredoka One', cursive; font-size: 2.4rem; color: var(--primary); margin: 0.5rem 0; }
.w-counter-btns { display: flex; gap: 0.6rem; justify-content: center; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Number line */
.w-numberline { width: 100%; }
.w-nl-track { position: relative; display: flex; justify-content: space-between; padding: 1.5rem 0 0.5rem; }
.w-nl-track::before { content: ''; position: absolute; left: 0; right: 0; top: calc(1.5rem + 12px); height: 4px; background: var(--gray-200); border-radius: 20px; }
.w-nl-mark {
  position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%;
  background: var(--white); border: 2px solid var(--gray-200); font-size: 0.7rem; font-weight: 800; color: var(--gray-600);
}
.w-nl-mark.passed { border-color: var(--primary); }
.w-nl-mark.active { background: var(--primary); color: #fff; border-color: var(--primary); transform: scale(1.2); }
.w-nl-runner { position: absolute; top: -6px; transform: translateX(-50%); font-size: 1.5rem; transition: left 0.4s ease; }
.w-nl-btns { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 1rem; }
.w-nl-value { font-size: 0.9rem; }

/* Fraction */
.w-fraction { text-align: center; }
.w-fraction-pie { width: 180px; height: 180px; }
.w-frac-slice { fill: var(--gray-100); stroke: var(--white); stroke-width: 2; cursor: pointer; transition: fill 0.2s; }
.w-frac-slice:hover { fill: var(--gray-200); }
.w-frac-slice.on { fill: var(--primary); }
.w-frac-label { display: inline-flex; flex-direction: column; align-items: center; font-family: 'Fredoka One', cursive; font-size: 1.6rem; margin-top: 0.5rem; }
.w-frac-bar { width: 36px; height: 3px; background: var(--dark); margin: 2px 0; }

/* Money */
.w-money { text-align: center; width: 100%; }
.w-money-target { font-size: 1.05rem; margin-bottom: 0.35rem; }
.w-money-total { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.85rem; }
.w-money-total.hit strong { color: var(--green); }
.w-money-coins { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 0.85rem; }
.w-coin {
  width: 58px; height: 58px; border-radius: 50%; border: 3px solid var(--orange);
  background: radial-gradient(circle at 35% 30%, #ffe08a, var(--accent)); font-size: 0.68rem; font-weight: 800; color: #7a5901;
}
.w-coin.note { width: auto; padding: 0 0.9rem; height: 44px; border-radius: var(--radius-sm); border-color: var(--green); background: linear-gradient(135deg, #aef5cd, #79e8a8); color: #0f6b3c; }
.w-coin:hover { transform: translateY(-3px); }

/* Clock */
.w-clock { text-align: center; }
.w-clock-face { width: 190px; height: 190px; }
.w-clock-rim { fill: var(--white); stroke: var(--primary); stroke-width: 4; }
.w-clock-num { font-size: 12px; font-weight: 800; fill: var(--dark); text-anchor: middle; dominant-baseline: middle; font-family: 'Nunito'; }
.w-clock-hour { stroke: var(--dark); stroke-width: 5; stroke-linecap: round; }
.w-clock-min { stroke: var(--primary); stroke-width: 3; stroke-linecap: round; }
.w-clock-pin { fill: var(--secondary); }
.w-clock-readout { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: var(--primary); margin: 0.4rem 0; }
.w-clock-readout.hit { color: var(--green); }
.w-clock-ctrls { display: flex; gap: 1.25rem; justify-content: center; }
.w-clock-ctrls > div { display: flex; align-items: center; gap: 0.3rem; }
.w-clock-ctrls span { font-size: 0.8rem; font-weight: 700; margin-right: 0.2rem; }
.w-clock-ctrls .btn { width: 34px; padding: 0.3rem; }

/* Geometry */
.w-geometry { text-align: center; }
.w-geo-svg { width: 190px; height: 190px; }
.w-geo-shape { fill: color-mix(in srgb, var(--primary) 22%, transparent); stroke: var(--primary); stroke-width: 3; stroke-linejoin: round; transition: transform 0.4s ease; transform-box: fill-box; }
.w-geo-shape rect, .w-geo-shape polygon { fill: color-mix(in srgb, var(--primary) 18%, transparent); stroke: var(--primary); stroke-width: 3; }
.w-geo-fact { font-weight: 700; margin: 0.6rem 0 0.85rem; color: var(--gray-600); font-size: 0.9rem; }
.w-geo-ctrls { display: flex; gap: 0.6rem; justify-content: center; }

/* Drag & drop */
.w-dnd { display: flex; gap: 1.5rem; justify-content: center; }
.w-dnd-col { display: flex; flex-direction: column; gap: 0.6rem; flex: 1; max-width: 180px; }
.w-dnd-item, .w-dnd-drop {
  padding: 0.8rem; border-radius: var(--radius-sm); font-weight: 800; text-align: center; transition: var(--transition);
}
.w-dnd-item { background: var(--primary); color: #fff; cursor: grab; }
.w-dnd-item.sel { outline: 3px solid var(--accent); }
.w-dnd-item.matched { background: var(--green); cursor: default; opacity: 0.7; }
.w-dnd-drop { border: 2px dashed var(--gray-300, #cdd4e0); background: var(--gray-100); color: var(--gray-600); cursor: pointer; }
.w-dnd-drop.filled { border-style: solid; border-color: var(--green); background: rgba(38,222,129,0.12); color: #128a4f; }

/* ---- Accessibility: large text ---------------------------- */
body.large-text { font-size: 18px; }
body.large-text .lv-lead { font-size: 1.25rem; }
body.large-text .quiz-q { font-size: 1.5rem; }
body.large-text .quiz-opt { font-size: 1.15rem; }
#toggle-large-text.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Responsive ------------------------------------------- */
/* Tablet — 2 cards per row */
@media (max-width: 1024px) {
  .topics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Sifir — 4 cards per row on tablet */
  .sifir-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Mobile — single full-width column, comfortable spacing */
@media (max-width: 560px) {
  .topics-grid { grid-template-columns: 1fr; gap: 1rem; }
  .topics-header { align-items: flex-start; }
  .topic-card { padding: 1.5rem 1.3rem 1.3rem; }
  /* Sifir — 2 cards per row on mobile */
  .sifir-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
  .sifir-table { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .lv-nav { flex-wrap: wrap; }
  .w-dnd { gap: 0.85rem; }
  .quiz-result-actions { flex-direction: column; }
}

/* ---- Larger text mode — bigger card typography ------------ */
body.large-text .topic-title { font-size: 1.45rem; }
body.large-text .topic-desc { font-size: 1.05rem; }
body.large-text .topic-btn { font-size: 1rem; }

/* ---- Respect reduced-motion preference -------------------- */
@media (prefers-reduced-motion: reduce) {
  .topic-card { animation: none; }
  .topic-card:hover, .topic-card:focus-visible { transform: none; }
  .year-panel, .year-chevron, .year-card, .year-item { transition: none; }
  .uasa-card { transition: none; }
  .uasa-card:hover, .uasa-card:focus-visible { transform: none; }
}

/* ============================================================
   📄 Soalan Lepas UASA — static PDF folder links
   ============================================================ */
.uasa-section { margin-bottom: 1.75rem; }
.uasa-section .learn-section-header { margin-bottom: 1.1rem; }
.uasa-section .learn-section-header h3 {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem;
}
.uasa-section .learn-section-header p {
  color: var(--gray-600); font-weight: 600; font-size: 1rem; margin: 0;
}

.uasa-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.35rem;
}

/* Per-year accent colours — match the curriculum year colour-coding */
.uasa-card[data-year-color="orange"] { --uc: #f97316; }
.uasa-card[data-year-color="red"]    { --uc: #ef4444; }
.uasa-card[data-year-color="yellow"] { --uc: #eab308; }

.uasa-card {
  --uc: var(--primary);
  position: relative; display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 0.5rem;
  background: var(--white);
  border: 2px solid color-mix(in srgb, var(--uc) 18%, var(--gray-100));
  border-radius: var(--radius);
  padding: 1.85rem 1.4rem 1.4rem;
  cursor: pointer; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
/* coloured accent band along the top */
.uasa-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 6px;
  background: var(--uc); opacity: 0.9;
}
.uasa-card:hover, .uasa-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 16px 36px color-mix(in srgb, var(--uc) 30%, transparent);
  border-color: var(--uc); outline: none;
}
.uasa-card:active { transform: translateY(-1px) scale(0.99); }

.uasa-card-emoji { font-size: 2.8rem; line-height: 1; margin-bottom: 0.1rem; }
.uasa-card-title {
  font-family: 'Fredoka One', cursive; font-size: 1.35rem; line-height: 1.1;
  color: var(--uc);
}
.uasa-card-age { font-size: 0.82rem; font-weight: 700; color: var(--gray-600); }
.uasa-card-desc {
  font-size: 0.92rem; line-height: 1.5; color: var(--gray-600);
  margin: 0.3rem 0 0.9rem;
}
.uasa-card-cta {
  margin-top: auto; font-size: 0.85rem; font-weight: 800; color: #fff;
  background: var(--uc);
  padding: 0.55rem 1.4rem; border-radius: 50px;
}

body.large-text .uasa-card-desc { font-size: 1.02rem; }
body.large-text .uasa-card-title { font-size: 1.45rem; }

/* Responsive: tablet → 2 per row, mobile → 1 per row */
@media (max-width: 1024px) { .uasa-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 768px) {
  .uasa-grid { grid-template-columns: 1fr; gap: 1rem; }
}

/* ============================================================
   MOBILE UX REFINEMENT — additional phone-only polish (≤600px)
   ----------------------------------------------------------------
   This page is already thoroughly responsive (see the existing
   1024/900/768/640/560/480px breakpoints above) — two small gaps
   found, both minor.
   ============================================================ */
@media (max-width: 600px) {
  /* Hero stat pills had a 160px minimum, so on a phone only one fit
     per row with a lot of empty space beside it. A slightly smaller
     minimum lets two sit comfortably side by side. */
  .learn-hero { padding: 1.75rem 1.5rem; }
  .learn-stat { min-width: 130px; padding: 0.85rem 1.1rem; }

  /* Clock widget's hour/minute controls had no wrap safety net and
     sit right at the edge of fitting inside the lesson modal on the
     narrowest phones. */
  .w-clock-ctrls { flex-wrap: wrap; gap: 0.75rem; row-gap: 0.5rem; }
}
