/* ============================================
   KIDS WORKSHEET SYSTEM - Shared Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Patrick+Hand&display=swap');

:root {
  --primary: #5b4fcf;
  --accent1: #ff6b6b;
  --accent2: #ffd93d;
  --accent3: #6bcb77;
  --accent4: #4d96ff;
  --light-bg: #f8f7ff;
  --card-bg: #ffffff;
  --text: #2d2d2d;
  --muted: #777;
  --border: #e0daf8;
  --level1: #6bcb77;
  --level2: #4d96ff;
  --level3: #ff6b6b;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(91,79,207,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 217, 61, 0.24), transparent 20%),
    radial-gradient(circle at top right, rgba(77, 150, 255, 0.12), transparent 18%),
    var(--light-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

/* ---- PAGE LAYOUT ---- */
.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 24px;
}

body.worksheet-body .page {
  max-width: 920px;
}

/* ---- HEADER ---- */
.ws-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--primary), #7b73e6);
  color: #fff;
  border-radius: 22px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 14px 40px rgba(91,79,207,0.18);
}
.ws-header .emoji { font-size: 2.4rem; }
.ws-header h1 { font-size: 1.55rem; font-weight: 800; margin: 0; }
.ws-header .meta { font-size: 0.85rem; opacity: 0.85; margin-top: 2px; }

.level-badge {
  margin-left: auto;
  padding: 6px 16px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 0.9rem;
  white-space: nowrap;
}
.level-badge.l1 { background: var(--level1); color: #fff; }
.level-badge.l2 { background: var(--level2); color: #fff; }
.level-badge.l3 { background: var(--level3); color: #fff; }

/* ---- SECTION ---- */
.section {
  background: var(--card-bg);
  border-radius: 18px;
  border: 2px solid var(--border);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(91,79,207,0.08);
}
.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .num {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* ---- INSTRUCTIONS ---- */
.instructions {
  background: linear-gradient(90deg, #fffbe6, #fffef6);
  border-left: 4px solid var(--accent2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  margin-bottom: 16px;
  color: #5a4a00;
}

/* ---- ANSWER LINES ---- */
.line {
  border-bottom: 2.5px solid #c5bef7;
  min-height: 38px;
  margin: 8px 0;
  border-radius: 2px;
}
.line-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.line-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.line-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.prompt-grid {
  display: grid;
  gap: 14px;
}

.prompt-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prompt-card,
.workspace-box {
  background: #fbfbff;
  border: 1px solid rgba(91,79,207,0.10);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
}

.workspace-box p,
.prompt-card p {
  margin: 0 0 8px;
}

.worksheet-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.worksheet-list.compact {
  line-height: 1.6;
}

.answer-field {
  border: none;
  border-bottom: 2.5px solid #c5bef7;
  background: transparent;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.3rem;
  width: 100%;
  min-height: 42px;
  padding: 8px 6px 4px;
  outline: none;
  color: var(--text);
  border-radius: 8px 8px 2px 2px;
}
.answer-field:focus {
  border-color: var(--primary);
  background: rgba(91,79,207,0.04);
}

/* ---- WORD BOXES ---- */
.word-box {
  display: inline-block;
  border: 2.5px solid var(--primary);
  border-radius: 8px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 1.1rem;
  background: #f0eeff;
  margin: 4px;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: #f8f7ff;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.word-bank .label {
  width: 100%;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ---- MATCHING ---- */
.match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}
.match-item {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 1rem;
  background: #f8f7ff;
  min-width: 120px;
  text-align: center;
}
.match-line {
  flex: 1;
  border-bottom: 2px dashed #c5bef7;
}

/* ---- MULTIPLE CHOICE ---- */
.choice-list {
  list-style: none;
  margin-top: 8px;
}
.choice-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 1rem;
  border: 2px solid var(--border);
  transition: border-color 0.2s;
}
.choice-list li:hover { border-color: var(--primary); }
.choice-circle {
  width: 24px; height: 24px;
  border: 2px solid #c5bef7;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800;
}

/* ---- MATH ---- */
.math-problem {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  margin: 10px 0;
}
.math-answer {
  border: none;
  border-bottom: 3px solid var(--primary);
  width: 64px;
  min-height: 42px;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  background: transparent;
  outline: none;
  font-family: 'Nunito', sans-serif;
  border-radius: 8px 8px 2px 2px;
}
.math-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.math-card {
  background: #f8f7ff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- NUMBER LINE ---- */
.number-line {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 16px 0;
  overflow-x: auto;
}
.num-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 38px;
}
.num-tick .tick { width: 2px; height: 14px; background: var(--primary); }
.num-tick .label { font-weight: 700; font-size: 0.9rem; margin-top: 4px; }
.num-line-bar { flex: 1; height: 4px; background: var(--primary); }

/* ---- TABLES ---- */
.ws-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 1rem;
}
.ws-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
}
.ws-table td {
  border: 1.5px solid var(--border);
  padding: 10px 14px;
  vertical-align: middle;
}
.ws-table tr:nth-child(even) td { background: #f8f7ff; }

/* ---- WRITING LINES ---- */
.writing-lines {
  margin-top: 10px;
}
.writing-line {
  border-bottom: 2px solid #c5bef7;
  height: 44px;
  margin-bottom: 4px;
  position: relative;
}
.writing-line::after {
  content: '';
  position: absolute;
  bottom: 50%;
  left: 0; right: 0;
  border-bottom: 1px dashed #e0daf8;
}

/* ---- PASSAGE BOX ---- */
.passage {
  background: linear-gradient(180deg, #fcfbff, #f6f7ff);
  border-left: 5px solid var(--accent4);
  border-radius: 16px;
  padding: 18px 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  line-height: 1.9;
  margin-bottom: 16px;
  color: #2d2d2d;
  box-shadow: inset 0 0 0 1px rgba(77, 150, 255, 0.08);
}
.passage strong { color: var(--primary); }

/* ---- LOGIC / PUZZLE ---- */
.puzzle-box {
  background: linear-gradient(135deg, #f0eeff 0%, #fff9e6 100%);
  border: 2px solid var(--accent2);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.puzzle-box .clue {
  font-size: 0.95rem;
  font-style: italic;
  color: #555;
  margin-bottom: 8px;
}

/* ---- FOOTER ---- */
.ws-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 2px dashed var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}
.ws-footer .star { color: var(--accent2); font-size: 1rem; }
.name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.name-field {
  border: none;
  border-bottom: 2px solid #c5bef7;
  width: 160px;
  font-family: 'Patrick Hand', cursive;
  font-size: 1rem;
  background: transparent;
  outline: none;
  min-height: 38px;
  padding: 6px 4px 2px;
}

.worksheet-focus {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(245, 248, 255, 0.98));
  box-shadow: 0 10px 28px rgba(34, 52, 78, 0.08);
  border: 1px solid rgba(91,79,207,0.12);
}

.worksheet-focus-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--primary);
}

.worksheet-focus-text {
  margin-top: 6px;
  font-size: 1rem;
  color: #31414d;
}

.worksheet-curriculum-card {
  margin-bottom: 20px;
  padding: 18px 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(91,79,207,0.12);
  box-shadow: 0 14px 36px rgba(34, 52, 78, 0.08);
}

.worksheet-curriculum-card h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: var(--primary);
}

.worksheet-curriculum-meta {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.worksheet-curriculum-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.worksheet-curriculum-pane {
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8f7ff;
  border: 1px solid rgba(91,79,207,0.10);
}

.worksheet-curriculum-pane h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #344b84;
}

.worksheet-curriculum-pane p,
.worksheet-curriculum-pane li {
  font-size: 0.94rem;
  color: #3b4750;
}

.worksheet-curriculum-pane ul {
  margin: 0;
  padding-left: 18px;
}

.worksheet-helper-note {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--muted);
}

.mobile-helpbar {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(77, 150, 255, 0.08);
  border: 1px solid rgba(77, 150, 255, 0.16);
  color: #28456e;
  font-size: 0.92rem;
}

.worksheet-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  text-decoration: none;
  font-weight: 800;
  color: var(--primary);
}

.worksheet-back-link:hover {
  text-decoration: underline;
}

.worksheet-set-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}

.worksheet-set-label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 4px;
}

.worksheet-set-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  color: var(--primary);
  background: rgba(91,79,207,0.06);
  border: 1px solid rgba(91,79,207,0.14);
}

.worksheet-set-link.current {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---- PRINT STYLES ---- */
@media print {
  body { background: #fff; }
  .page { max-width: 100%; padding: 12px 18px; }
  .ws-header { background: #5b4fcf !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .section { box-shadow: none; border: 1.5px solid #ccc; }
  .no-print { display: none !important; }
  .answer-field, .math-answer, .name-field { border-bottom-color: #999; }
  .choice-list li:hover { border-color: var(--border); }
  a { text-decoration: none; }
  .ws-footer { border-top: 1px solid #ccc; }
  .worksheet-curriculum-card.no-print,
  .worksheet-helper-note.no-print,
  .worksheet-back-link.no-print,
  .worksheet-set-nav.no-print,
  .mobile-helpbar.no-print { display: none !important; }
}

/* ---- NAV BUTTONS (index only) ---- */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.nav-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-decoration: none;
  color: var(--text);
  display: block;
  box-shadow: var(--shadow);
}
.nav-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(91,79,207,0.18);
  border-color: var(--primary);
}
.nav-card .icon { font-size: 2.5rem; margin-bottom: 8px; }
.nav-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 4px; }
.nav-card p { font-size: 0.82rem; color: var(--muted); }
.nav-card .badges { display: flex; gap: 4px; justify-content: center; margin-top: 8px; }
.nav-card .badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}
.badge.l1 { background: #e6f9ec; color: #227738; }
.badge.l2 { background: #e8f1ff; color: #1a4fac; }
.badge.l3 { background: #ffe8e8; color: #b02020; }

/* ---- PROGRESS TRACKER ---- */
.tracker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.tracker-row:last-child { border-bottom: none; }
.tracker-check {
  width: 26px; height: 26px;
  border: 2.5px solid var(--primary);
  border-radius: 8px;
  flex-shrink: 0;
}
.tracker-label { flex: 1; font-weight: 600; font-size: 0.95rem; }
.tracker-level { font-size: 0.8rem; color: var(--muted); }
.star-row { display: flex; gap: 4px; }
.star-row span { font-size: 1.1rem; color: #ddd; cursor: pointer; }
.star-row span.lit { color: var(--accent2); }

@media (max-width: 720px) {
  .page {
    padding: 18px 14px 28px;
  }

  .ws-header,
  .ws-footer,
  .name-line {
    flex-direction: column;
    align-items: flex-start;
  }

  .worksheet-curriculum-grid {
    grid-template-columns: 1fr;
  }

  .prompt-grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .math-grid {
    grid-template-columns: 1fr;
  }

  .ws-table,
  .ws-table tbody,
  .ws-table tr,
  .ws-table td,
  .ws-table th {
    display: block;
    width: 100%;
  }

  .ws-table thead {
    display: none;
  }

  .ws-table tr {
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
    overflow: hidden;
  }

  .ws-table td {
    border: 0;
    border-bottom: 1px solid var(--border);
  }

  .ws-table tr td:last-child {
    border-bottom: 0;
  }

  .answer-field,
  .math-answer,
  .name-field {
    font-size: 16px;
  }
}
