/* ============================================================
   Diligent Mathematics — Design System
   ============================================================ */
:root {
  --navy: #0f2a4a;
  --navy-700: #16375f;
  --blue: #1f6feb;
  --blue-600: #1a5fd0;
  --teal: #0d9488;
  --amber: #d97706;
  --rose: #be123c;
  --green: #15803d;
  --ink: #16202c;
  --muted: #5b6b7d;
  --line: #e3e8ef;
  --bg: #f6f8fb;
  --card: #ffffff;
  --easy: #15803d;
  --medium: #0d9488;
  --hard: #d97706;
  --ext: #be123c;
  --shadow: 0 1px 2px rgba(16,32,44,.06), 0 6px 20px rgba(16,32,44,.06);
  --radius: 14px;
  --maxw: 1060px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(120deg, var(--navy), var(--navy-700));
  color: #fff;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 12px rgba(15,42,74,.25);
}
.site-header .bar {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: radial-gradient(circle at 30% 30%, #4f9bff, #1f6feb 60%, #16375f);
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.brand .title { font-weight: 700; font-size: 1.15rem; letter-spacing: .2px; }
.brand .title small { display: block; font-weight: 400; font-size: .72rem; opacity: .8; letter-spacing: 2px; text-transform: uppercase; }
.site-header nav { margin-left: auto; display: flex; gap: 6px; }
.site-header nav a {
  color: #dbe7f7; padding: 8px 12px; border-radius: 8px; font-size: .92rem;
}
.site-header nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 26px 18px 80px; }
.hero {
  background: linear-gradient(120deg, #eaf1fb, #f6f8fb);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 28px; margin-bottom: 26px;
}
.hero h1 { margin: 0 0 6px; font-size: 1.9rem; color: var(--navy); }
.hero p { margin: 0; color: var(--muted); max-width: 62ch; }

/* ---------- Topic grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.topic-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.topic-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(16,32,44,.12); text-decoration: none; }
.topic-card .tag { font-size: .7rem; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); font-weight: 700; }
.topic-card h3 { margin: 0; color: var(--navy); font-size: 1.15rem; }
.topic-card p { margin: 0; color: var(--muted); font-size: .9rem; flex: 1; }
.topic-card .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: .72rem; padding: 3px 9px; border-radius: 999px; background: #eef3fb; color: var(--navy-700); font-weight: 600; }
.chip.soon { background: #f3f4f6; color: #9aa5b1; }
.progress-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* ---------- Topic page ---------- */
.topic-head { margin-bottom: 18px; }
.topic-head .crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.topic-head h1 { margin: 0; color: var(--navy); font-size: 1.8rem; }
.topic-head .sub { color: var(--muted); margin-top: 4px; }
.syll { display: inline-block; background: #eef3fb; color: var(--navy-700); border-radius: 8px; padding: 4px 10px; font-size: .8rem; margin-top: 10px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin: 20px 0 22px; }
.tab-btn {
  border: none; background: none; padding: 10px 16px; font-size: .96rem; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to {opacity:1; transform:none;} }

/* ---------- Notes / prose ---------- */
.note-section {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.note-section h2 { color: var(--navy); margin-top: 0; font-size: 1.25rem; }
.note-section h3 { color: var(--navy-700); font-size: 1.05rem; }
.callout {
  border-left: 4px solid var(--blue); background: #f2f7ff; border-radius: 8px;
  padding: 12px 16px; margin: 14px 0;
}
.callout.key { border-left-color: var(--teal); background: #effcf9; }
.callout.warn { border-left-color: var(--amber); background: #fff8ec; }
.formula { text-align: center; background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; padding: 10px; margin: 12px 0; }

/* ---------- Examples ---------- */
.example {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--teal);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.example h3 { margin: 0 0 6px; color: var(--teal); font-size: 1.02rem; }
.example .problem { font-weight: 500; }
.steps { margin-top: 10px; }
.reveal-btn {
  background: var(--navy); color: #fff; border: none; border-radius: 8px; padding: 8px 16px;
  font-size: .88rem; cursor: pointer; margin-top: 8px;
}
.reveal-btn:hover { background: var(--navy-700); }
.solution { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.solution[hidden] { display: none; }
.step { margin: 6px 0; }
.step .label { font-weight: 700; color: var(--navy-700); }

/* ---------- Practice / Quiz ---------- */
.tier-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tier-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 16px;
  font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--muted);
}
.tier-btn[data-tier="easy"].active { background: var(--easy); color:#fff; border-color: var(--easy); }
.tier-btn[data-tier="medium"].active { background: var(--medium); color:#fff; border-color: var(--medium); }
.tier-btn[data-tier="hard"].active { background: var(--hard); color:#fff; border-color: var(--hard); }
.tier-btn[data-tier="extension"].active { background: var(--ext); color:#fff; border-color: var(--ext); }
.tier-desc { color: var(--muted); font-size: .9rem; margin-bottom: 16px; }

.q-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.q-card .q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.q-num { font-weight: 700; color: var(--navy); }
.q-source { font-size: .74rem; color: var(--muted); background: #f1f5f9; padding: 2px 8px; border-radius: 6px; }
.q-prompt { margin: 8px 0 12px; }
.options { display: grid; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; background: #fff;
}
.opt:hover { border-color: var(--blue); }
.opt input { accent-color: var(--blue); }
.opt.correct { border-color: var(--green); background: #f0fdf4; }
.opt.wrong { border-color: var(--rose); background: #fff1f2; }
.answer-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.answer-row input[type=text] {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; min-width: 160px;
}
.btn {
  background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 9px 16px;
  font-weight: 600; font-size: .9rem; cursor: pointer;
}
.btn:hover { background: var(--blue-600); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f4f7fb; }
.feedback { margin-top: 10px; font-weight: 600; }
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--rose); }
.worked { margin-top: 12px; padding: 12px 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
.worked[hidden] { display: none; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; }
.site-footer .inner { max-width: var(--maxw); margin: 0 auto; padding: 20px 18px; color: var(--muted); font-size: .85rem; display:flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.5rem; }
  .site-header nav { display: none; }
  .wrap { padding: 18px 14px 70px; }
}

/* ---------- Print (worksheets) ---------- */
@media print {
  .site-header, .site-footer, .tabs, .tier-nav, .toolbar, .reveal-btn, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .q-card, .example, .note-section { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .worked, .solution { display: block !important; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
