/* The Math App: static site experiment (Home, Students, Teachers) */

:root {
  --accent: #0056d2;
  --accent-dark: #0045a8;
  --accent-soft: #e6eefb;
  --ink: #17201a;
  --ink-2: #47524a;
  --ink-3: #6b766e;
  --paper: #fbfaf6;
  --card: #ffffff;
  --line: #e3e1d8;
  --hl: #f2ee8c;          /* the app's yellow row highlight */
  --ph-bg: #fff4a8;       /* review placeholders */
  --ph-line: #d4b800;
  --confirm: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 32, 26, .06), 0 8px 24px rgba(23, 32, 26, .07);
  --max: 1140px;
  --head: "Source Sans 3", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--head); line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.3rem, 5.2vw, 3.8rem); font-weight: 700; }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
kbd {
  font: 600 .82em/1 var(--body);
  background: #fff; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: .18em .42em;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
section { padding: 88px 0; }
.section-alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.lede { font-size: 1.2rem; color: var(--ink-2); max-width: 40em; }
.center { text-align: center; }
.center .lede { margin-left: auto; margin-right: auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(251, 250, 246, .92); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 28px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 700 1.15rem/1 var(--head); letter-spacing: -0.01em; white-space: nowrap; flex: none; }
.site-header .btn { white-space: nowrap; flex: none; }
.nav a { white-space: nowrap; }
.brand img { width: 42px; height: 42px; border-radius: 9px; box-shadow: 0 1px 3px rgba(23, 32, 26, .25); }
.nav { display: flex; gap: 26px; margin-left: auto; }
.nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .97rem; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1.1rem/1 var(--head); text-decoration: none; cursor: pointer;
  padding: 15px 24px; border-radius: 6px; border: 2px solid transparent;
  transition: background .15s, color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn-sm { padding: 10px 18px; font-size: 1rem; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; margin-top: 28px; }
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.small-print { font-size: .9rem; color: var(--ink-3); margin-top: 12px; }

/* ---------- Hero ---------- */
.hero { padding: 72px 0 88px; }
.hero-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 56px; align-items: center; }
/* Home hero: full-width headline banner, then the hero video (text panel left third, editor right two thirds).
   .vframe uses container units (cqw) so everything inside scales with the frame, like a real video. */
.hero-video { padding: 0 0 56px; }
.hero-title { background: #fff; border-bottom: 1px solid var(--line); padding: 18px 0; margin-bottom: 24px; text-align: center; }
.hero-title h1 { margin: 0; font-size: clamp(1.7rem, 3.2vw, 2.7rem); }
.vframe {
  container-type: inline-size; position: relative; aspect-ratio: 16 / 9;
  width: min(100%, calc((100svh - 196px) * 16 / 9)); margin: 0 auto;
  display: grid; grid-template-columns: 1fr 2fr; background: #111; border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 4px rgba(23, 32, 26, .08), 0 24px 60px rgba(23, 32, 26, .18);
}
.vpanel {
  background: #969696; color: #000; padding: 4cqw 2.6cqw 4cqw 3cqw;
  font: 400 1.75cqw/1.45 var(--body); display: flex; flex-direction: column; justify-content: center;
}
.vpanel p { margin: 0 0 1.4cqw; }
.vpanel p:last-child { margin-bottom: 0; }
.vpanel b { color: #000; font: 700 1.9cqw/1.2 var(--head); }
.vpanel .vurl { font: 700 1.9cqw/1.2 var(--head); margin-bottom: 2cqw; }
.vmedia { position: relative; min-height: 0; overflow: hidden; background: #d6d6d6; }
.vmedia img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.hero-ph { display: table; margin: 14px auto 0; }
.hero.hero-stacked .hero-grid { grid-template-columns: 1fr; text-align: center; }
.hero.hero-stacked .lede { margin: 0 auto; }
.hero.hero-stacked .btn-row { justify-content: center; }

.window {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 4px rgba(23, 32, 26, .08), 0 24px 60px rgba(23, 32, 26, .16);
  border: 1px solid var(--line);
}
.window-bar { display: flex; gap: 6px; padding: 10px 12px; background: #eceae2; }
.window-bar span { width: 10px; height: 10px; border-radius: 50%; background: #cfccc1; }
figure { margin: 0; }
figcaption { font-size: .92rem; color: var(--ink-3); margin-top: 14px; text-align: center; font-style: italic; }
.photo { border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.photo img { width: 100%; }

/* ---------- Video ---------- */
.video-frame { max-width: 960px; margin: 36px auto 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #000; }
.video-frame video { display: block; width: 100%; height: auto; }

/* ---------- Fork ---------- */
.fork-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 40px; }
.fork-card {
  display: flex; flex-direction: column; border-radius: 12px; overflow: hidden;
  text-decoration: none; color: var(--ink); background: #f2f5fa;
  transition: transform .15s, box-shadow .15s;
}
.fork-card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(0, 39, 97, .06), 0 18px 40px rgba(0, 39, 97, .12); }
.fork-body { display: flex; flex-direction: column; gap: 14px; flex: 1; padding: 44px 44px 46px; }
.fork-card h3 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); margin: 0; }
.fork-card p { color: var(--ink-2); margin: 0; font-size: 1.05rem; }
.fork-list, .card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; color: var(--ink-2); font-size: 1.05rem; line-height: 1.45; }
.card-list { font-size: .98rem; gap: 4px; margin-top: 8px; }
.fork-list li, .card-list li { position: relative; padding-left: 22px; }
.fork-list li::before, .card-list li::before { content: ""; position: absolute; left: 4px; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.fork-card .go { display: inline-flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 18px; font: 700 1.1rem/1 var(--head); color: var(--accent); }
.fork-card .go svg { width: 20px; height: 20px; transition: transform .15s; }
.fork-card:hover .go svg { transform: translateX(4px); }

/* ---------- Before / after ---------- */
.ba-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 28px; margin-top: 40px; align-items: stretch; }
.ba-grid figure { display: flex; flex-direction: column; }
.ba-grid .photo { flex: 1; display: flex; align-items: center; justify-content: center; background: #fff; }
.ba-grid .photo img { width: 100%; height: 100%; object-fit: contain; max-height: 520px; }

/* ---------- Cards & features ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 26px; box-shadow: var(--shadow); }
.card h3 { margin-bottom: .4em; }
.card p { color: var(--ink-2); margin: 0; font-size: .98rem; }
.feature-grid { display: flex; flex-wrap: wrap; justify-content: center; }
.feature-grid > .card { flex: 0 1 calc((100% - 40px) / 3); }

/* Split rows (text + image) */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; }
.split + .split { margin-top: 80px; }
.split.flip > :first-child { order: 2; }

/* Steps */
.steps { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 8px; }
.steps strong { display: block; font-family: var(--head); font-size: 1.12rem; }
.steps span { color: var(--ink-2); }
.steps span strong { display: inline; font-size: inherit; color: var(--ink); }
.key-icon { display: inline-block; height: 1.5em; width: auto; vertical-align: middle; margin: -3px 2px 0; border-radius: 3px; }

.ticks { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 14px; }
.ticks li { position: relative; padding-left: 32px; color: var(--ink-2); }
.ticks li::before {
  content: ""; position: absolute; left: 0; top: .32em; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.3l2.6 2.5L12 5.4' fill='none' stroke='%230056d2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat;
}

/* Audience blocks on Teachers */
.audience { display: grid; grid-template-columns: 220px 1fr; gap: 40px; padding: 40px 0; border-top: 1px solid var(--line); }
.audience:first-of-type { border-top: 0; }
.audience h3 { font-size: 1.5rem; }

/* Example cards */
.ex-card { text-decoration: none; color: var(--ink); padding: 0; overflow: hidden; display: flex; flex-direction: column; transition: transform .15s; }
.ex-card:hover { transform: translateY(-3px); }
.ex-card img { aspect-ratio: 16 / 10; object-fit: cover; object-position: top left; width: 100%; border-bottom: 1px solid var(--line); }
.ex-card div { padding: 18px 22px 22px; }
.ex-card small { color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }
.ex-card h3 { margin: 4px 0 0; font-size: 1.1rem; }

/* Q&A callout */
.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 28px 30px; margin-top: 40px; }
.callout h3 { margin-bottom: .35em; }
.callout p { margin: 0; color: var(--ink-2); }

/* ---------- Testimonials (template; kept hidden) ---------- */
.quote-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 36px; }
blockquote { margin: 0; }
.quote p { font-size: 1.08rem; color: var(--ink); }
.quote cite { font-style: normal; color: var(--ink-3); font-size: .92rem; }

/* ---------- Download strip ---------- */
.download { background: var(--ink); color: #f3f4ef; }
.download h2 { color: #fff; }
.download .lede { color: #c5cbc4; }
.platforms { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-top: 40px; }
.platform {
  background: #222d25; border: 1px solid #34413a; border-radius: var(--radius);
  padding: 22px 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.platform svg { width: 34px; height: 34px; color: #8ab4ff; }
.platform h3 { color: #fff; font-size: 1.05rem; margin: 0; }
.platform .links { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: auto; }
.dl {
  display: block; padding: 10px 12px; border-radius: 6px; background: var(--accent); color: #fff;
  font: 700 1rem/1.25 var(--head); text-decoration: none;
}
.dl:hover { background: var(--accent-dark); }
.dl small { display: block; font-family: var(--body); font-weight: 500; color: rgba(255, 255, 255, .78); font-size: .78rem; }
.play-badge img { height: 54px; width: auto; margin: 0 auto; }
.download-notes { margin-top: 26px; font-size: .9rem; color: #aab3aa; text-align: center; }
.download-notes p { margin: 0 0 4px; }

/* ---------- Footer ---------- */
.site-footer { background: #0f1611; color: #aab3aa; padding: 56px 0 40px; font-size: .95rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 10px 24px; padding: 0 0 20px; }
.footer-links a { color: #d6dbd4; text-decoration: none; }
.footer-links a:hover { color: #fff; text-decoration: underline; }
.footer-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.footer-meta a { color: #d6dbd4; }
a.soon { opacity: .6; cursor: help; }

/* ---------- Review markers (remove before going live) ---------- */
.ph {
  display: block; background: var(--ph-bg); border: 2px dashed var(--ph-line); color: #5c4d00;
  border-radius: 10px; padding: 12px 14px; font-size: .92rem; line-height: 1.45; margin-top: 14px;
}
.ph::before { content: "PLACEHOLDER"; display: block; font: 700 .7rem/1 var(--body); letter-spacing: .1em; margin-bottom: 6px; }
span.ph { display: inline-block; padding: 2px 8px; margin: 10px 0 0; border-width: 1px; }
span.ph::before { content: none; }
.confirm {
  display: inline-block; font: 700 .68rem/1 var(--body); letter-spacing: .08em; color: #fff;
  background: var(--confirm); border-radius: 4px; padding: 4px 6px; vertical-align: 2px; margin-left: 6px;
}

/* ---------- Examples page ---------- */
.ex-hero { padding-bottom: 56px; }
.ex-hero .small-print { max-width: 46em; }
.subject-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.subject-nav a {
  padding: 8px 14px; border-radius: 6px; background: var(--accent-soft); color: var(--accent);
  font: 600 .95rem/1 var(--head); text-decoration: none;
}
.subject-nav a:hover { background: var(--accent); color: #fff; }

.solution {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 32px; align-items: start;
  padding: 36px 0; border-top: 1px solid var(--line); scroll-margin-top: 90px;
}
.solution:first-of-type { border-top: 0; padding-top: 12px; }
.solution .video-frame, .howto .video-frame, .step .video-frame { margin: 0; max-width: none; }
.solution-text small { color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; }
.solution-text h3 { font-size: 1.5rem; margin: 4px 0 12px; }
.steps-box { grid-column: 1 / -1; }

.rich { color: var(--ink-2); font-size: .98rem; }
.rich + .rich { margin-top: 10px; }
.rich p { margin: 0 0 8px; }
.rich ul { margin: 6px 0; padding-left: 20px; }
.rich li { margin: 4px 0; }
.rich li.sub { list-style: none; }

details.howto { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
details.howto + details.howto { margin-top: 10px; }
details.howto summary {
  cursor: pointer; list-style: none; padding: 16px 52px 16px 20px; position: relative;
  font: 650 1.05rem/1.3 var(--head); color: var(--ink);
}
details.howto summary::-webkit-details-marker { display: none; }
details.howto summary::after {
  content: "+"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font: 700 1.1rem/1 var(--body);
}
details.howto[open] summary::after { content: "\2212"; }
details.howto summary:hover { color: var(--accent); }
.howto-body { padding: 0 20px 20px; display: grid; gap: 14px; }
.howto-body > .video-frame { max-width: 760px; }
.tag { white-space: nowrap; font: 600 .72rem/1 var(--body); color: var(--ink-3); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; margin-left: 8px; vertical-align: 2px; }
.group-title { font-size: 1.25rem; margin: 36px 0 12px; }
.wrap > .group-title:first-child { margin-top: 0; }
.howto-list { max-width: 900px; }

.steps-box { background: var(--paper); }
.step-list { list-style: none; margin: 0; padding: 0 20px 20px; display: grid; gap: 22px; }
.step { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.step-text strong { display: block; font-family: var(--head); color: var(--accent); margin-bottom: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid, .split { grid-template-columns: 1fr; gap: 40px; }
  .split.flip > :first-child { order: 0; }
  .feature-grid > .card { flex-basis: calc((100% - 20px) / 2); }
  .platforms { grid-template-columns: repeat(3, 1fr); }
  .audience { grid-template-columns: 1fr; gap: 8px; }
  .solution, .step { grid-template-columns: 1fr; gap: 18px; }
}
@media (min-width: 721px) and (max-width: 960px) {
  /* Tablets: fit logo, five menu items and the button on one line */
  .site-header .wrap { gap: 16px; }
  .nav { gap: 16px; }
  .nav a { font-size: .92rem; }
}
@media (min-width: 721px) and (max-width: 879px) {
  /* Narrow tablets: logo + button on top, the full menu on a second row */
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 0; gap: 0 12px; }
  .site-header .btn { margin-left: auto; }
  .nav { order: 3; width: 100%; margin: 0; justify-content: space-between; padding: 8px 0 6px; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  section { padding: 44px 0; }
  h2 { font-size: 1.75rem; }
  .lede { font-size: 1.05rem; }

  /* Header: logo + button on one row, menu on the next */
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 0; gap: 0 12px; }
  .site-header .btn { margin-left: auto; }
  .brand img { width: 36px; height: 36px; }
  .nav { order: 3; width: 100%; margin: 0; gap: 0 8px; justify-content: space-between; padding: 6px 0 4px; }
  /* Shrink only when the five links would not fit (about 368px and narrower), so they never run together */
  .nav a { font-size: min(.92rem, calc((100vw - 64px) * .0485)); padding: 6px 0; }
  /* Pages: the Download free button sits right above. Portal (index.html#download): teachers already have the app, Home is one tap away */
  .nav a[href$="#download"] { display: none; }

  /* Hero */
  .hero { padding: 28px 0 44px; }
  .hero-grid, .split { gap: 28px; }
  .split + .split { margin-top: 44px; }

  /* Home hero on phones: the 4:5 video version with the text panel on top */
  .hero-video { padding: 0 0 40px; }
  .hero-title { padding: 14px 0; margin-bottom: 18px; }
  .hero-title h1 { font-size: 1.6rem; }
  .vframe { width: 100%; aspect-ratio: 4 / 5; grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .vpanel { padding: 4.5cqw 5cqw 4cqw; font-size: 4cqw; line-height: 1.38; justify-content: flex-start; }
  .vpanel p { margin: 0 0 2.2cqw; }
  .vpanel b { font-size: 4.3cqw; }
  .vpanel .vurl { display: none; }

  /* Buttons: full width, easy to tap */
  .btn-row { flex-direction: column; align-items: stretch; gap: 12px; margin-top: 24px; }
  .btn-row .btn { width: 100%; padding: 16px 20px; }
  .btn-row .text-link { text-align: center; padding: 6px 0; }
  .hero .small-print { text-align: center; }

  /* Cards and grids */
  .card-grid { gap: 12px; margin-top: 28px; }
  .card { padding: 22px 20px; }
  .ex-card { padding: 0; }
  .fork-grid, .ba-grid, .quote-grid { grid-template-columns: 1fr; gap: 16px; margin-top: 28px; }
  .feature-grid > .card { flex-basis: 100%; }
  .fork-body { padding: 26px 22px 28px; }
  .audience { padding: 28px 0; }
  .callout { padding: 22px 20px; margin-top: 28px; }

  /* Before / after: keep the handwritten photo from filling the screen */
  .ba-grid .photo img { max-height: 380px; object-fit: cover; object-position: top; }
  .video-frame { margin-top: 24px; }

  /* Download: one compact row per device */
  .platforms { grid-template-columns: 1fr; gap: 10px; margin-top: 28px; }
  .platform { flex-direction: row; align-items: center; text-align: left; padding: 14px 16px; gap: 12px; }
  .platform svg { width: 28px; height: 28px; flex: none; }
  .platform h3 { flex: 1; min-width: 0; font-size: 1rem; }
  .platform .links { width: auto; flex: 0 0 46%; min-width: 0; margin-top: 0; }
  .platform .dl { text-align: center; }
  .platform .play-badge img { height: 46px; margin: 0 0 0 auto; }
  .download-notes { margin-top: 20px; }

  /* Examples */
  .ex-hero { padding-bottom: 40px; }
  .ex-hero .btn-row { flex-direction: row; }
  .ex-hero .btn-row .btn { width: auto; flex: 1; padding: 14px 10px; }
  .solution { padding: 28px 0; }
  details.howto summary { padding: 14px 48px 14px 16px; font-size: 1rem; }
  .howto-body, .step-list { padding: 0 14px 16px; }

  /* Footer */
  .site-footer { padding: 40px 0 32px; }
  .footer-links { gap: 4px 20px; }
  .footer-links a { padding: 6px 0; }
  .footer-meta { flex-direction: column; }
}

@media (max-width: 360px) {
  .site-header .btn-sm { padding: 9px 12px; font-size: .92rem; }
}
