/* ============================================================
   MATHIMATIONS — design tokens
   ============================================================ */
:root {
  --bg: #ffffff;
  --hero-bg: #F5F7FC;
  --ink: #1F2937;
  --ink-muted: #6B7280;
  --border: #E7EAF0;
  --border-strong: #D8DCE6;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 2px 10px rgba(15, 23, 42, .05);
  --shadow-hover: 0 10px 28px rgba(15, 23, 42, .10);
  --green: #22C55E;
  --dark-pill: #1F2937;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.display-font { font-family: "Poppins", "Inter", sans-serif; }
.icon-glyph { font-weight: 800; line-height: 1; font-family: "Poppins", sans-serif; }

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}

.navbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Poppins", sans-serif;
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -0.01em;
  margin-right: auto;
}

.logo-rainbow span:nth-child(1) { color: #3B82F6; }
.logo-rainbow span:nth-child(2) { color: #EC4899; }
.logo-rainbow span:nth-child(3) { color: #22C55E; }
.logo-rainbow span:nth-child(4) { color: #F59E0B; }
.logo .star-accent { color: #F59E0B; width: 16px; height: 16px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
}

.nav-links a { display: flex; align-items: center; gap: 6px; opacity: .85; transition: opacity .15s ease; }
.nav-links a:hover { opacity: 1; }
.nav-links svg { width: 16px; height: 16px; }

.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--ink); }

@media (max-width: 720px) {
  .nav-links { display: none; }
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  background: var(--hero-bg);
  padding: 64px 24px 56px;
}

.hero-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}

.hero h1 {
  font-family: "Poppins", sans-serif;
  font-size: clamp(34px, 5vw, 46px);
  line-height: 1.1;
  font-weight: 800;
  margin: 0 0 18px;
}
.hero h1 .l1 { color: #3B82F6; display: block; }
.hero h1 .l2 { color: #EC4899; display: block; }
.hero h1 .l3 { color: #22C55E; display: block; }

.hero p.lead {
  color: var(--ink-muted);
  font-size: 16px;
  max-width: 46ch;
  margin: 0 0 26px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 20px;
  max-width: 460px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.search-bar input {
  border: none; outline: none; flex: 1;
  font-size: 14.5px; font-family: inherit; color: var(--ink);
  background: transparent;
  min-width: 0;
}
.search-bar input::placeholder { color: #9CA3AF; }
.search-bar button {
  width: 40px; height: 40px; border-radius: 999px;
  border: none; background: #3B82F6; color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  padding: 8px;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 20;
}
.search-results.open { display: block; }
.search-results a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 14px;
}
.search-results a:hover { background: var(--hero-bg); }
.search-results .kind { margin-left: auto; font-size: 11px; color: var(--ink-muted); font-family: "JetBrains Mono", monospace; }
.search-empty { padding: 14px 12px; color: var(--ink-muted); font-size: 13.5px; }

.hero-art { display: flex; align-items: center; justify-content: center; }

/* ============================================================
   Sections / grids
   ============================================================ */
main, .section {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 24px 24px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 18px;
  margin: 0 0 18px;
}
.section-heading svg { width: 18px; height: 18px; color: #F59E0B; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

/* Topic / subtopic cards */
.entity-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-card);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.entity-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent, var(--border-strong));
}
.entity-card:focus-visible { outline: 2px solid var(--accent, #3B82F6); outline-offset: 3px; }

.entity-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}
.entity-icon.solid { background: var(--accent); color: #fff; }
.entity-icon.tint { background: color-mix(in srgb, var(--accent) 14%, white); }

.entity-body { min-width: 0; flex: 1; }
.entity-title { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 16.5px; color: var(--accent); margin-bottom: 4px; }
.entity-desc { font-size: 13.5px; color: var(--ink-muted); line-height: 1.45; }
.entity-count { margin-top: 10px; font-size: 12.5px; color: var(--ink-muted); }

.entity-chevron {
  position: absolute; top: 24px; right: 20px;
  color: var(--ink-muted);
  opacity: 0; transform: translateX(-4px);
  transition: opacity .15s ease, transform .15s ease;
}
.entity-card:hover .entity-chevron { opacity: 1; transform: translateX(0); }
.entity-chevron svg { width: 18px; height: 18px; }

/* Simulation list rows */
.sim-list { display: flex; flex-direction: column; gap: 14px; }

.sim-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-card);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.sim-row:hover { box-shadow: var(--shadow-hover); border-color: var(--accent, var(--border-strong)); }

.sim-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, white);
}

.sim-info { min-width: 0; flex: 1; }
.sim-name { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.sim-desc { font-size: 13px; color: var(--ink-muted); line-height: 1.4; }

.play-btn {
  flex-shrink: 0;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(34, 197, 94, .30);
  transition: transform .12s ease, box-shadow .12s ease;
}
.play-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(34, 197, 94, .38); }

.empty-state {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 32px 24px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
}

/* ============================================================
   Breadcrumb + page header (topic / subtopic pages)
   ============================================================ */
.page-header { padding: 32px 24px 8px; }
.page-header-inner { max-width: 1180px; margin: 0 auto; }

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--ink-muted);
  margin-bottom: 22px; flex-wrap: wrap;
}
.breadcrumb a { display: flex; align-items: center; gap: 4px; color: var(--ink-muted); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb a svg { width: 15px; height: 15px; }
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb .current { color: var(--ink); font-weight: 500; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 18px;
}
.back-btn:hover { border-color: var(--border-strong); }
.back-btn svg { width: 15px; height: 15px; }

.entity-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.entity-hero-left { display: flex; align-items: flex-start; gap: 16px; }

.entity-hero-icon {
  width: 60px; height: 60px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, white);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.entity-hero-title { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 28px; color: var(--accent); margin: 0 0 6px; }
.entity-hero-desc { color: var(--ink-muted); font-size: 15px; max-width: 52ch; }

.entity-hero-art svg { width: 90px; height: 90px; opacity: .9; }

/* ============================================================
   "Coming soon" promo banner
   ============================================================ */
.promo-banner {
  max-width: 1180px;
  margin: 24px auto 0;
  padding: 0 24px;
}
.promo-banner-inner {
  background: linear-gradient(120deg, #EEF2FF, #E0ECFF);
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.promo-text h3 { font-family: "Poppins", sans-serif; font-size: 19px; margin: 0 0 6px; color: #1E3A8A; }
.promo-text p { margin: 0 0 16px; color: #3B4A6B; font-size: 14px; max-width: 42ch; }
.promo-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #3B82F6; color: #fff; border: none;
  border-radius: 999px; padding: 11px 22px; font-weight: 600; font-size: 14px;
}
.promo-icon { width: 64px; height: 64px; border-radius: 999px; background: #FDE68A; display: flex; align-items: center; justify-content: center; color: #B45309; flex-shrink: 0; }
.promo-icon svg { width: 30px; height: 30px; }

/* ============================================================
   Footer
   ============================================================ */
footer.site-footer {
  max-width: 1180px;
  margin: 40px auto 0;
  padding: 36px 24px 40px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.2fr;
  gap: 32px;
}
.footer-brand .logo { margin-bottom: 10px; }
.footer-brand p { color: var(--ink-muted); font-size: 13.5px; max-width: 32ch; }
.footer-col h4 { font-family: "Poppins", sans-serif; font-size: 14px; margin: 0 0 12px; }
.footer-col a { display: block; color: var(--ink-muted); font-size: 13.5px; margin-bottom: 9px; }
.footer-col a:hover { color: var(--ink); }
.footer-subscribe { display: flex; gap: 8px; margin-top: 6px; }
.footer-subscribe input {
  flex: 1; min-width: 0; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 13.5px; font-family: inherit;
}
.footer-subscribe button {
  background: #3B82F6; color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 13.5px; font-weight: 600; flex-shrink: 0;
}
.footer-bottom {
  max-width: 1180px; margin: 0 auto; padding: 18px 24px 40px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  color: var(--ink-muted); font-size: 12.5px; border-top: 1px solid var(--border);
}
.footer-bottom a { margin-left: 16px; }

@media (max-width: 760px) {
  footer.site-footer { grid-template-columns: 1fr; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { order: -1; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 560px) {
  .navbar-inner { padding: 14px 16px; }
  .hero { padding: 40px 16px 36px; }
  main, .section, .page-header-inner, .promo-banner { padding-left: 16px; padding-right: 16px; }
  .card-grid { gap: 14px; grid-template-columns: 1fr; }
  .entity-card { padding: 18px; }
  .entity-hero-title { font-size: 22px; }
  .entity-hero-art { display: none; }
  footer.site-footer { padding: 28px 16px 32px; }
}


/* ============================================================
   Maths Tree page
   ============================================================ */
.mt-toolbar {
  max-width: 1180px; margin: 0 auto; padding: 0 24px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.mt-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; flex: 1; min-width: 220px; max-width: 360px;
  box-shadow: var(--shadow-card);
}
.mt-search svg { width: 16px; height: 16px; color: #9CA3AF; flex-shrink: 0; }
.mt-search input { border: none; outline: none; flex: 1; min-width: 0; font: inherit; font-size: 14px; background: transparent; color: var(--ink); }
.mt-search input::placeholder { color: #9CA3AF; }

.mt-viewtoggle {
  display: flex; background: var(--hero-bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.mt-viewbtn {
  border: none; background: transparent; color: var(--ink-muted);
  font-size: 13.5px; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  transition: background .15s ease, color .15s ease;
}
.mt-viewbtn.active { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-card); }

.mt-actions { display: flex; gap: 8px; margin-left: auto; }
.mt-actionbtn {
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px;
}
.mt-actionbtn:hover { border-color: var(--border-strong); }

/* ---- Tree map ---- */
.mt-mapwrap {
  max-width: 1180px; margin: 0 auto 40px; padding: 0 24px;
  position: relative;
}
.mt-mapcanvas {
  position: relative;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 45%, #F8FAFE 0%, #F1F4FA 100%);
  overflow: hidden; touch-action: none; cursor: grab;
  height: min(70vh, 640px);
}
.mt-mapcanvas.dragging { cursor: grabbing; }
.mt-mapcanvas svg { width: 100%; height: 100%; display: block; transform-origin: 0 0; }

.mt-mapcontrols {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px;
}
.mt-mapcontrols button {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--ink); font-size: 16px; font-weight: 700;
  box-shadow: var(--shadow-card); display: flex; align-items: center; justify-content: center;
}
.mt-mapcontrols button:hover { border-color: var(--border-strong); }

.mt-hint {
  position: absolute; bottom: 14px; left: 14px; z-index: 5;
  font-size: 12px; color: var(--ink-muted); background: rgba(255,255,255,.85);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
  pointer-events: none;
}

.mt-tree-link { fill: none; stroke-width: 1.8; opacity: .55; }

.mt-tree-node text { font-family: "Inter", sans-serif; user-select: none; }
.mt-tree-clickable { cursor: pointer; }
.mt-tree-clickable circle { transition: filter .15s ease; }
.mt-tree-clickable:hover circle { filter: brightness(1.1); }
.mt-tree-clickable:hover text { text-decoration: underline; }

.mt-tree-root-circle { fill: #1F2937; }
.mt-tree-root-label { font-family: "Poppins", sans-serif; font-weight: 800; font-size: 14px; fill: #1F2937; }

.mt-tree-branch-label { font-weight: 700; font-size: 13.5px; }

.mt-tree-sub-circle { fill: #fff; stroke-width: 2.2; }
.mt-tree-sub-label { font-weight: 600; font-size: 12.5px; fill: #374151; }

.mt-tree-topic-label { font-size: 12px; fill: #6B7280; }
.mt-tree-topic-label.has-sim { fill: var(--green); font-weight: 700; cursor: pointer; }
.mt-tree-topic-label.has-sim:hover { text-decoration: underline; }

/* ---- List view ---- */
.mt-listwrap { max-width: 900px; margin: 0 auto 60px; padding: 0 24px; display: flex; flex-direction: column; gap: 12px; }
.mt-branch-block { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--bg); }
.mt-branch-row {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer;
}
.mt-branch-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--accent); flex-shrink: 0; }
.mt-branch-row .mt-branch-name { font-family: "Poppins", sans-serif; font-weight: 700; font-size: 15.5px; color: var(--accent); }
.mt-branch-row .mt-branch-tagline { font-size: 12.5px; color: var(--ink-muted); margin-left: 4px; }
.mt-branch-row .mt-chevron { margin-left: auto; color: var(--ink-muted); transition: transform .15s ease; flex-shrink: 0; }
.mt-branch-block.open .mt-branch-row .mt-chevron { transform: rotate(90deg); }
.mt-sub-list { display: none; padding: 0 18px 14px 42px; flex-direction: column; gap: 4px; }
.mt-branch-block.open .mt-sub-list { display: flex; }
.mt-sub-block { border-left: 2px solid var(--border); padding-left: 14px; margin-bottom: 4px; }
.mt-sub-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; cursor: pointer; }
.mt-sub-row .mt-sub-name { font-weight: 600; font-size: 13.5px; }
.mt-sub-row .mt-chevron { margin-left: auto; color: var(--ink-muted); transition: transform .15s ease; }
.mt-sub-block.open .mt-sub-row .mt-chevron { transform: rotate(90deg); }
.mt-topic-list { display: none; flex-direction: column; gap: 4px; padding: 2px 0 8px; }
.mt-sub-block.open .mt-topic-list { display: flex; }
.mt-topic-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--ink-muted); padding: 6px 10px; border-radius: 8px;
}
.mt-topic-row.has-sim { background: color-mix(in srgb, var(--green) 10%, white); color: var(--ink); }
.mt-topic-row a.mt-try {
  flex-shrink: 0; font-size: 11px; font-weight: 700; color: #fff; background: var(--green);
  border-radius: 999px; padding: 3px 9px;
}
.mt-hidden { display: none !important; }

@media (max-width: 720px) {
  .mt-toolbar { padding: 0 16px 18px; }
  .mt-mapwrap, .mt-listwrap { padding: 0 16px; }
  .mt-drawer { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-width: none; max-height: 60vh; }
  .mt-drawer { transform: translateY(120%); }
  .mt-drawer.open { transform: translateY(0); }
}