/* Newtonic site. Two classroom surfaces from the app: the indigo "stage" (blackboard) and graph paper. */

:root {
  --stage: #16134a;
  --stage-deep: #0d0b33;
  --stage-high: #2e2a8c;
  --chalk: #eef0ff;
  --haze: #a9acdb;
  --wire: #c9cbf5;
  --launch: #ff8a3d;
  --launch-press: #f2711f;
  --trail: #ff5c7a;
  --velocity: #46d684;

  --paper: #f6f7fc;
  --paper-grid: rgba(46, 42, 140, 0.07);
  --ink: #191a3d;
  --ink-soft: #4b4e73;
  --rule: #dadcef;
  --surface: #ffffff;

  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --math: "STIX Two Text", "Cambria Math", "Times New Roman", serif;

  --step--1: 0.875rem;
  --step-0: 1.125rem;
  --step-1: 1.375rem;
  --step-2: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
  --step-3: clamp(2.6rem, 1.4rem + 5.4vw, 5.5rem);

  --gutter: clamp(16px, 4vw, 40px);
  --max: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #100f30;
    --paper-grid: rgba(155, 152, 255, 0.06);
    --ink: #eef0ff;
    --ink-soft: #a9acdb;
    --rule: #2a2862;
    --surface: #17164a;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }

a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

:focus-visible { outline: 3px solid var(--launch); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }

.m { font-family: var(--math); font-style: italic; font-weight: 400; letter-spacing: 0; }
.m sub { font-size: 0.7em; font-style: normal; }

.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 12px; z-index: 10; background: var(--chalk); color: var(--stage); padding: 8px 14px; border-radius: 8px; }

/* Header */

.site-header { position: relative; z-index: 2; color: var(--chalk); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-block: 22px; }

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 700; font-size: 1.35rem; letter-spacing: -0.01em; font-variation-settings: "wdth" 92; }
.brand svg { width: 28px; height: 29px; }

.site-nav { display: flex; gap: clamp(14px, 3vw, 32px); font-size: var(--step--1); font-weight: 500; }
.site-nav a { text-decoration: none; color: var(--haze); }
.site-nav a:hover { color: var(--chalk); }

/* Stage (blackboard) surfaces */

.stage {
  position: relative;
  color: var(--chalk);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(1200px 600px at 78% 10%, rgba(46, 42, 140, 0.85), transparent 70%),
    linear-gradient(180deg, var(--stage) 0%, var(--stage-deep) 100%);
}

/* Hero */

.hero { position: relative; padding-bottom: clamp(56px, 9vw, 112px); overflow: hidden; }
.hero .wrap { position: relative; z-index: 1; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(28px, 5vw, 72px); align-items: center; padding-top: clamp(16px, 4vw, 48px); }

.hero h1 {
  margin: 0;
  font-size: var(--step-3);
  font-weight: 760;
  font-variation-settings: "wdth" 80;
  line-height: 0.94;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.hero .lead { margin: 28px 0 0; max-width: 34ch; font-size: var(--step-1); line-height: 1.45; color: var(--haze); }

.cta {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 36px; padding: 16px 26px;
  border-radius: 999px; background: var(--launch); color: #1a0d05;
  font-weight: 650; font-size: 1.05rem; text-decoration: none;
  box-shadow: 0 10px 30px -10px rgba(255, 138, 61, 0.7);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.cta:hover { background: #ff9a55; }
.cta:active { transform: translateY(1px); background: var(--launch-press); }
.cta-note { margin: 14px 0 0; font-size: var(--step--1); color: var(--haze); }

/* The lab: a working projectile simulation */

.lab {
  margin: 0;
  border-radius: 28px;
  background: linear-gradient(180deg, #121048 0%, #0b0a2c 100%);
  border: 1px solid rgba(201, 203, 245, 0.14);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 14px;
}

.lab-field { position: relative; }
.lab canvas { display: block; width: 100%; aspect-ratio: 2 / 1; border-radius: 18px; touch-action: none; cursor: crosshair; }
.lab-hint { position: absolute; top: 12px; right: 14px; margin: 0; font-size: 0.8rem; color: var(--haze); pointer-events: none; text-align: right; max-width: 60%; }

.readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 0; }
.readouts div { background: rgba(201, 203, 245, 0.07); border-radius: 12px; padding: 10px 12px; }
.readouts dt { font-size: 0.8rem; color: var(--haze); }
.readouts dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.readouts dd span { font-size: 0.85rem; font-weight: 500; color: var(--haze); margin-left: 3px; }

.controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 18px; align-items: end; margin-top: 14px; padding: 4px 6px 6px; }
.control label { display: flex; justify-content: space-between; gap: 12px; white-space: nowrap; font-size: 0.9rem; color: var(--haze); margin-bottom: 8px; }
.control output { color: var(--launch); font-weight: 600; font-variant-numeric: tabular-nums; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--launch) var(--fill, 50%), rgba(201, 203, 245, 0.18) var(--fill, 50%)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(201, 203, 245, 0.18); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--launch); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--chalk); border: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--chalk); border: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); }

.launch {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border: 0; border-radius: 999px;
  background: var(--launch); color: #1a0d05; font: inherit; font-weight: 650; font-size: 1rem; cursor: pointer;
}
.launch:hover { background: #ff9a55; }
.launch svg { width: 18px; height: 18px; }

/* Paper (graph paper) surfaces */

.paper-grid {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

.section { padding-block: clamp(72px, 10vw, 128px); }
.section h2 { margin: 0; font-size: var(--step-2); line-height: 1.05; font-weight: 720; font-variation-settings: "wdth" 86; letter-spacing: -0.02em; text-wrap: balance; }
.section .intro { margin: 18px 0 0; max-width: 58ch; color: var(--ink-soft); }

/* Three ways into every topic */

.ways .wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 96px); align-items: center; }

.tabs { display: inline-flex; margin-top: 36px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--rule); }
.tabs button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-soft); font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.tabs button .icon { width: 20px; height: 20px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.tabs button:not([aria-selected="true"]):hover { color: var(--ink); }

.tab-panel { margin-top: 26px; max-width: 46ch; }
.tab-panel h3 { margin: 0; font-size: var(--step-1); font-weight: 680; }
.tab-panel p { margin: 10px 0 0; color: var(--ink-soft); }

.phone {
  justify-self: center;
  width: min(100%, 340px);
  border-radius: 54px;
  padding: 11px;
  background: linear-gradient(160deg, #2b2a52, #0c0b22);
  box-shadow: 0 50px 90px -40px rgba(22, 19, 74, 0.55), inset 0 0 0 1.5px rgba(255, 255, 255, 0.12);
}
.phone .screens { position: relative; border-radius: 44px; overflow: hidden; aspect-ratio: 1320 / 2868; background: #000; }
.phone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.35s ease; }
.phone img.is-shown { opacity: 1; }

/* Fields */

.fields-grid { display: grid; gap: 56px; margin-top: 56px; }
.era { margin: 0; padding-bottom: 12px; border-bottom: 2px solid var(--ink); font-size: var(--step-1); font-weight: 700; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.era span { font-size: var(--step--1); font-weight: 500; color: var(--ink-soft); }
.era-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: clamp(32px, 6vw, 88px); }

.field { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-content: start; gap: 4px 16px; padding: 22px 0; border-bottom: 1px solid var(--rule); }
.field-icon { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--c); }
.field h4 { margin: 0; font-size: 1.15rem; font-weight: 680; display: flex; align-items: baseline; gap: 10px; }
.field h4 small { font-size: 0.85rem; font-weight: 500; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.field ul { list-style: none; margin: 4px 0 0; padding: 0; color: var(--ink-soft); font-size: 0.98rem; line-height: 1.55; }
.field li { display: inline; }
.field li + li::before { content: ", "; color: var(--ink-soft); }
.field li.is-free { color: var(--ink); }
.dot { display: inline-block; width: 7px; height: 7px; margin: 0 6px 0 1px; border-radius: 50%; background: var(--velocity); vertical-align: 0.1em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* iPad */

.ipad .wrap { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: clamp(32px, 6vw, 88px); align-items: center; }
.ipad h2 { color: var(--chalk); }
.ipad .intro { color: var(--haze); }
.tablet { border-radius: 36px; padding: 12px; background: linear-gradient(160deg, #2b2a52, #0c0b22); box-shadow: 0 50px 100px -50px rgba(0, 0, 0, 0.8), inset 0 0 0 1.5px rgba(255, 255, 255, 0.12); }
.tablet img { border-radius: 26px; }

/* Pricing */

.plans { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; margin-top: 52px; align-items: stretch; }
.plan { border-radius: 28px; padding: clamp(26px, 4vw, 44px); }
.plan h3 { margin: 0; font-size: var(--step-1); font-weight: 700; }
.plan .price { margin: 6px 0 0; color: var(--ink-soft); }
.plan ul { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 14px; }
.plan li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; }
.plan li .icon { color: var(--velocity); margin-top: 2px; }
.plan-free { background: var(--surface); border: 1px solid var(--rule); }
.plan-pro { color: var(--chalk); background: radial-gradient(700px 400px at 90% 0%, rgba(255, 138, 61, 0.22), transparent 60%), linear-gradient(160deg, var(--stage-high), var(--stage) 55%, var(--stage-deep)); }
.plan-pro .price { color: var(--haze); }
.plan-pro .cta { margin-top: 32px; }

/* Footer */

.site-footer { padding-block: 48px 56px; color: var(--haze); font-size: var(--step--1); }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.site-footer .brand { color: var(--chalk); font-size: 1.1rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 22px; }
.site-footer a { color: var(--haze); text-decoration: none; }
.site-footer a:hover { color: var(--chalk); }

/* Document pages (privacy, support) */

.doc-head { padding-block: 0 clamp(48px, 7vw, 80px); }
.doc-head h1 { margin: clamp(12px, 3vw, 32px) 0 0; font-size: clamp(2.4rem, 1.6rem + 3.4vw, 4rem); font-weight: 760; font-variation-settings: "wdth" 82; letter-spacing: -0.025em; line-height: 1; }
.doc-head p { margin: 16px 0 0; color: var(--haze); max-width: 56ch; font-size: var(--step-1); line-height: 1.45; }

.prose { max-width: 68ch; padding-block: clamp(48px, 7vw, 88px); }
.prose h2 { margin: 2.2em 0 0.4em; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--ink-soft); }
.prose strong { color: var(--ink); }
.prose a { color: var(--ink); }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 0.4em 0; }
.prose .summary { background: var(--surface); border: 1px solid var(--rule); border-radius: 20px; padding: 6px 26px; }

.faq details { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 20px; padding: 20px 0; font-weight: 650; font-size: 1.12rem; color: var(--ink); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-weight: 400; font-size: 1.5rem; line-height: 1; color: var(--ink-soft); transition: transform 0.2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 0 22px; }

.contact { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; margin-top: 28px; }
.contact .cta { margin-top: 0; }


/* Motion: gravity, chalk and a cradle that clicks. All of it stops for reduced motion. */

.doodles { position: absolute; inset: 0; pointer-events: none; }
.doodle {
  position: absolute; left: var(--x); top: var(--y);
  font-size: calc(1.4rem * var(--s)); color: var(--chalk); opacity: 0.09; white-space: nowrap;
  transform: translate3d(0, var(--shift, 0px), 0);
  animation: drift var(--t) ease-in-out infinite alternate;
}
@keyframes drift { from { translate: 0 -10px; rotate: -3deg; } to { translate: 12px 12px; rotate: 3deg; } }

.js .hero h1 .word { display: inline-block; animation: fall 0.9s both; animation-delay: calc(var(--i) * 90ms + 80ms); }
@keyframes fall {
  0% { opacity: 0; transform: translateY(-1.1em) rotate(-4deg); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  55% { opacity: 1; transform: translateY(0) rotate(0); animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1); }
  72% { transform: translateY(-0.12em); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  86% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1); }
  93% { transform: translateY(-0.03em); }
  100% { transform: translateY(0); }
}

.js .rise { animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }

.js [data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity 0.7s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: var(--d, 0ms); }
.js [data-reveal].is-in { opacity: 1; transform: none; }
.js .field[data-reveal] .field-icon { transform: scale(0.6); transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); transition-delay: calc(var(--d, 0ms) + 120ms); }
.js .field[data-reveal].is-in .field-icon { transform: none; }

@supports (animation-timeline: view()) {
  .phone, .tablet { animation: stand-up linear both; animation-timeline: view(); animation-range: entry 0% cover 42%; }
  @keyframes stand-up {
    from { transform: perspective(1400px) rotateX(16deg) rotateY(-12deg) translateY(60px) scale(0.94); }
    to { transform: perspective(1400px) rotateX(0) rotateY(0) translateY(0) scale(1); }
  }
}

/* Each field's glyph moves the way its physics does. */
.field-icon svg { transform-origin: 50% 50%; }
.field:hover .field-icon svg { animation: var(--move, lift) var(--dur, 1.2s) ease-in-out infinite; }
.field[data-field="mechanics"] { --move: slide; }
.field[data-field="gravitation"] { --move: spin; --dur: 3s; }
.field[data-field="fluids"] { --move: bob; }
.field[data-field="oscillations"] { --move: swing; }
.field[data-field="oscillations"] .field-icon svg { transform-origin: 50% 14%; }
.field[data-field="waves"] { --move: travel; --dur: 0.9s; }
.field[data-field="thermodynamics"] { --move: pulse; }
.field[data-field="electromagnetism"] { --move: flicker; --dur: 0.9s; }
.field[data-field="optics"] { --move: tilt; }
.field[data-field="relativity"] { --move: contract; }
.field[data-field="quantum"] { --move: tunnel; --dur: 1.6s; }
.field[data-field="atomic-nuclear"] { --move: spin; --dur: 2.4s; }
@keyframes lift { 50% { transform: translateY(-3px); } }
@keyframes slide { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(3px, -2px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 50% { transform: translateY(-3px) scaleY(1.04); } }
@keyframes swing { 0%, 100% { transform: rotate(16deg); } 50% { transform: rotate(-16deg); } }
@keyframes travel { 0%, 100% { transform: translateX(-2px); } 50% { transform: translateX(2px); } }
@keyframes pulse { 50% { transform: scale(1.14); } }
@keyframes flicker { 0%, 100% { opacity: 1; } 20% { opacity: 0.35; } 28% { opacity: 1; } 60% { opacity: 0.6; } }
@keyframes tilt { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes contract { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(0.62); } }
@keyframes tunnel { 0% { transform: translateX(-5px); opacity: 1; } 45% { opacity: 0.25; } 100% { transform: translateX(5px); opacity: 1; } }

/* Finale: the cradle */
.finale { text-align: center; overflow: hidden; }
.finale .wrap { display: flex; flex-direction: column; align-items: center; }
.finale h2 { color: var(--chalk); }
.finale .intro { color: var(--haze); margin-inline: auto; }
.finale .cta { margin-top: 32px; }
.cradle { width: min(70%, 300px); height: auto; margin-bottom: 40px; overflow: visible; }
.swing { transform-box: view-box; }
/* The bob swings back from the right stem and returns to click against it. */
.swing-n { transform-origin: 290px 284px; animation: swing-n 1.7s infinite; }
@keyframes swing-n {
  0% { transform: rotate(0deg); animation-timing-function: cubic-bezier(0.15, 0.55, 0.45, 1); }
  50% { transform: rotate(15deg); animation-timing-function: cubic-bezier(0.55, 0, 0.85, 0.45); }
  100% { transform: rotate(0deg); }
}
.spark { opacity: 0; }
.spark-n { animation: spark-n 1.7s infinite; }
@keyframes spark-n { 0% { opacity: 1; } 10%, 94% { opacity: 0; } 100% { opacity: 1; } }

.cta { transition: background-color 0.15s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease; }
.cta:hover { transform: translateY(-2px); box-shadow: 0 16px 36px -12px rgba(255, 138, 61, 0.8); }

/* Responsive */

@media (max-width: 920px) {
  .hero .wrap, .ways .wrap, .ipad .wrap, .plans, .era-fields { grid-template-columns: minmax(0, 1fr); }
  .hero .lead { max-width: 46ch; }
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .controls .launch { grid-column: 1 / -1; justify-content: center; }
  .ipad .tablet { order: 2; }
}

@media (max-width: 560px) {
  .site-nav a:not(:last-child) { display: none; }
  .lab { padding: 10px; border-radius: 22px; }
  .lab canvas { aspect-ratio: 3 / 2; border-radius: 14px; }
  .controls { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .readouts div { padding: 8px 10px; }
  .readouts dt { font-size: 0.72rem; white-space: nowrap; }
  .lab-hint { position: static; max-width: none; text-align: left; margin: 10px 4px 0; }
  .readouts dd { font-size: 1.1rem; }
  .tabs button { padding: 10px 13px; }
  .tabs button .icon { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .js [data-reveal], .js .field[data-reveal] .field-icon { opacity: 1; transform: none; }
}
