/* ===========================================================
   Math4Me — stylesheet
   A friendly, fast, real-world approach to math, grades 1–6.
   =========================================================== */

:root {
  --indigo-900: #211f54;
  --indigo-700: #2b2d82;
  --indigo-500: #4d4fc4;
  --indigo-100: #e8e8fb;

  --sun: #ffb703;
  --sun-dark: #e09400;
  --coral: #fb5607;
  --mint: #06a67e;
  --mint-light: #e4f9f2;

  --g1: #ef476f;
  --g2: #f3722c;
  --g3: #f9c74f;
  --g4: #06a67e;
  --g5: #118ab2;
  --g6: #6a4c93;

  --cream: #fffaf2;
  --paper: #ffffff;
  --ink: #201f33;
  --ink-soft: #565575;
  --line: #ece8f5;

  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(33, 31, 84, 0.08);
  --shadow-hover: 0 14px 32px rgba(33, 31, 84, 0.14);
  --max: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  font-size: 17px;
}

h1, h2, h3, h4 {
  font-family: "Baloo 2", "Inter", sans-serif;
  color: var(--indigo-900);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1em; }
a { color: var(--indigo-500); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { padding-left: 1.3em; }
li { margin-bottom: 0.4em; }
img { max-width: 100%; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: var(--max);
  margin: 0 auto;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Baloo 2", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--indigo-900);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo .dot { color: var(--coral); }

.nav-toggle {
  display: none;
  background: none;
  border: 2px solid var(--indigo-700);
  border-radius: var(--radius-sm);
  width: 42px;
  height: 38px;
  cursor: pointer;
  color: var(--indigo-700);
  font-size: 1.3rem;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.main-nav > li { position: relative; list-style: none; }
.main-nav > li > a, .nav-btn {
  display: inline-block;
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--indigo-900);
  font-size: 0.95rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.main-nav > li > a:hover, .nav-btn:hover, .nav-btn[aria-expanded="true"] {
  background: var(--indigo-100);
  text-decoration: none;
}
.main-nav .current { background: var(--indigo-100); }

.dropdown { position: relative; }
.dropdown-panel {
  display: none;
  position: absolute;
  top: 110%;
  left: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  padding: 8px;
  min-width: 240px;
  z-index: 50;
}
.dropdown.open .dropdown-panel { display: block; }
.dropdown-panel a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.92rem;
}
.dropdown-panel a:hover { background: var(--mint-light); text-decoration: none; }
.dropdown-panel .grade-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

@media (max-width: 880px) {
  .nav-toggle { display: block; }
  .main-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    order: 3;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    margin-top: 10px;
  }
  .nav-bar.open .main-nav { display: flex; }
  .main-nav > li { width: 100%; }
  .main-nav > li > a, .nav-btn { display: block; width: 100%; text-align: left; }
  .dropdown-panel { position: static; box-shadow: none; border: none; padding: 0 0 0 14px; width: 100%; }
  .dropdown.open .dropdown-panel { display: block; }
}

/* ---------- hero ---------- */
.hero {
  padding: 56px 0 44px;
  background: linear-gradient(180deg, var(--indigo-100) 0%, var(--cream) 100%);
  border-bottom: 1px solid var(--line);
}
.hero.small { padding: 40px 0 32px; }
.hero-icon {
  color: var(--coral);
  background: var(--paper);
  border: 1px solid var(--indigo-100);
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.eyebrow {
  display: inline-block;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--indigo-500);
  background: var(--paper);
  border: 1px solid var(--indigo-100);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero p.lead {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 62ch;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  align-items: center;
}
@media (max-width: 800px) { .hero-grid { grid-template-columns: 1fr; } }

.btn {
  display: inline-block;
  background: var(--coral);
  color: #fff;
  font-weight: 700;
  padding: 13px 24px;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: 0 6px 16px rgba(251, 86, 7, 0.3);
}
.btn:hover { background: #e04f06; text-decoration: none; }
.btn.ghost {
  background: transparent;
  color: var(--indigo-700);
  border: 2px solid var(--indigo-700);
  box-shadow: none;
  padding: 11px 22px;
}
.btn.ghost:hover { background: var(--indigo-100); }
.btn-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 22px; }

/* ---------- sections & cards ---------- */
main { display: block; }
.section { padding: 48px 0; }
.section.alt { background: var(--paper); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { max-width: 68ch; margin-bottom: 30px; }
.section-head p { color: var(--ink-soft); }

.grid {
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.grade-card { border-top: 6px solid var(--accent, var(--indigo-500)); }
.grade-card .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent, var(--indigo-500));
  color: #fff;
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  margin-bottom: 12px;
}
.grade-card a.stretch::after { content: ""; position: absolute; inset: 0; }
.grade-card { position: relative; }

/* trick blocks */
.trick {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 6px solid var(--mint);
  border-radius: var(--radius-sm);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.trick h3 { margin-bottom: 6px; }
.trick .when {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--mint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.trick .example {
  background: var(--mint-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 10px;
  font-size: 0.97rem;
}
.trick .example strong { color: var(--mint); }

.topic-card .topic-icon {
  color: var(--coral);
  background: var(--indigo-100);
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.mistake {
  background: #fff4e9;
  border: 1px solid #f7c98f;
  border-left: 6px solid var(--sun-dark);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin: 20px 0;
}
.mistake .mistake-tag {
  font-weight: 700;
  color: var(--sun-dark);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.mistake p { margin-bottom: 6px; }
.mistake p:last-child { margin-bottom: 0; }

.realworld {
  background: linear-gradient(135deg, var(--indigo-700), var(--indigo-500));
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 28px;
  margin: 28px 0;
}
.realworld h3 { color: #fff; }
.realworld .tag {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.challenge {
  background: #fff8e6;
  border: 1px dashed var(--sun-dark);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin: 24px 0;
}
.challenge summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--sun-dark);
}
.challenge .answer { margin-top: 10px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.pill {
  background: var(--indigo-100);
  color: var(--indigo-700);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
}

.callout {
  background: var(--indigo-100);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 0.95rem;
}

.cheat-sheet { display: flex; flex-direction: column; gap: 12px; }
.cheat-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  color: var(--ink);
}
.cheat-row:hover { border-color: var(--indigo-500); text-decoration: none; box-shadow: var(--shadow); }
.cheat-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--indigo-100);
  color: var(--coral);
  display: flex; align-items: center; justify-content: center;
}
.cheat-body h3 { margin-bottom: 6px; color: var(--indigo-900); }
.cheat-body ul { margin: 0; padding-left: 1.1em; }
.cheat-body li { margin-bottom: 2px; color: var(--ink-soft); font-size: 0.94rem; }

@media print {
  .site-header, .site-footer, .related, .hero .btn-row { display: none; }
  .cheat-row { break-inside: avoid; box-shadow: none; }
}

.glossary-heading { margin-top: 36px; padding-bottom: 8px; border-bottom: 2px solid var(--indigo-100); }
.glossary-heading:first-of-type { margin-top: 0; }
.glossary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  margin: 18px 0 10px;
}
.glossary-term {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.glossary-term h3 { font-size: 1.05rem; margin-bottom: 6px; color: var(--indigo-700); }
.glossary-term p { margin-bottom: 6px; font-size: 0.94rem; }
.glossary-term .example-line { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 0; }

table.simple { border-collapse: collapse; width: 100%; margin: 16px 0; }
table.simple th, table.simple td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}
table.simple th { background: var(--indigo-100); }

.related {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}
.related .grid { margin-top: 14px; }
.related a.card { display: block; font-weight: 700; color: var(--indigo-900); }
.related a.card:hover { text-decoration: none; }
.related a.card span { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.88rem; margin-top: 4px; }

/* breadcrumb */
.crumb { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 14px; }
.crumb a { color: var(--ink-soft); }

/* CTA band */
.cta-band {
  background: var(--indigo-900);
  color: #fff;
  padding: 56px 0;
  text-align: center;
}
.cta-band h2 { color: #fff; }
.cta-band p { color: #cfcdf0; max-width: 56ch; margin: 0 auto 8px; }

/* footer */
.site-footer {
  background: var(--indigo-900);
  color: #cfcdf0;
  padding: 44px 0 24px;
  font-size: 0.92rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 28px;
  margin-bottom: 30px;
}
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.site-footer h4 { color: #fff; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.site-footer a { color: #cfcdf0; }
.site-footer a:hover { color: #fff; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 8px; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  color: #a6a3d1;
  font-size: 0.85rem;
}

/* skip link for accessibility */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--coral);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .section { padding: 34px 0; }
}
