/* Home page: layout, the hero product's depth and the scroll reveals. Tokens and
   shared components come from base.css. Only transform and opacity animate. */

/* Reveals. A block starts turned back into the page and settles flat as it
   scrolls into view; the parent (.stage) supplies the perspective and --i
   staggers siblings. Scripting off: see the noscript block in index.html. */

.stage {
  perspective: 1200px;
}

.js .reveal {
  opacity: 0;
  transform: rotateX(14deg) translateZ(-120px) translateY(40px);
  transition:
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Hero */

.hero {
  padding: clamp(48px, 7vw, 96px) 0 clamp(56px, 7vw, 104px);
  /* The glow and the badge overhang the container; clip them at the viewport
     edge here so they never widen the page, even where the root clip is missing. */
  overflow-x: clip;
}

.hero-grid {
  display: grid;
  align-items: center;
  gap: 56px;
}

@media (min-width: 960px) {
  .hero-grid {
    grid-template-columns: minmax(0, 10fr) minmax(0, 11fr);
    gap: clamp(40px, 5vw, 80px);
  }
}

.hero-copy .lead {
  margin-top: 24px;
  max-width: 34ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}

.hero-product {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
}

/* The page's one decoration: a faint glow behind the product. */
.hero-product::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -14% -18%;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--accent-soft), transparent),
    radial-gradient(closest-side at 68% 32%, var(--accent-soft), transparent 78%);
  pointer-events: none;
}

.tilt {
  perspective: 1100px;
}

/* The card rotates as one transform (set by home.js); its children sit at
   different depths so they parallax against each other as it turns. */
.hero-card {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.hero-card > * {
  transform: translateZ(var(--z, 0));
}

.hero-card .q-meta {
  --z: 26px;
}

.hero-card .q-stem {
  --z: 44px;
}

.hero-card .choices {
  --z: 34px;
  pointer-events: none;
}

.hero-card .explanation {
  --z: 22px;
}

.hero-badge {
  --z: 60px;
  position: absolute;
  top: -14px;
  right: -4px;
  box-shadow: var(--shadow-m);
}

@media (max-width: 640px) {
  .hero-badge {
    right: 0;
  }
}

@keyframes hero-float {
  0%,
  100% {
    transform: translateY(0) rotateX(0) rotateY(0);
  }
  50% {
    transform: translateY(-10px) rotateX(2deg) rotateY(-2deg);
  }
}

@media (hover: none) {
  .hero-card {
    animation: hero-float 7s var(--ease-in-out) infinite;
  }
}

/* Sections */

.section {
  padding-block: clamp(40px, 5.5vw, 72px);
}

.section-last {
  padding-bottom: clamp(88px, 11vw, 150px);
}

.section-head {
  max-width: 760px;
  margin: 0 auto clamp(40px, 5vw, 64px);
  text-align: center;
}

.section-head .lead {
  margin-top: 20px;
}

.kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.kicker .eyebrow {
  margin: 0;
}

/* Stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stat {
  min-width: 0;
  padding: 28px 28px 24px;
}

.stat-num {
  display: block;
  font-size: clamp(36px, 4vw, 48px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-2);
}

/* Fan of question cards. The cards share one grid cell so they stack; each
   carries a stacked and a fanned transform and moves between them when the
   section reveals. */

.fan {
  --fan-w: 58%;
  --spread: 36%;
  display: grid;
  place-items: center;
  margin-top: clamp(40px, 5vw, 64px);
  padding: 32px 0 48px;
  perspective: 1200px;
}

@media (min-width: 720px) {
  .fan {
    --fan-w: 300px;
    --spread: 56%;
  }
}

.fan-card {
  grid-area: 1 / 1;
  width: var(--fan-w);
  padding: 18px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-m);
  transform: var(--fanned);
  transition: transform var(--dur-3) var(--ease-out);
  transition-delay: calc(200ms + var(--i, 0) * 90ms);
}

.js .fan:not(.is-visible) .fan-card {
  transform: var(--stacked);
}

.fan-card:nth-child(1) {
  --stacked: translate3d(0, 16px, -80px) rotate(-4deg);
  --fanned: translate3d(calc(-1 * var(--spread)), 4%, -40px) rotate(-9deg);
}

.fan-card:nth-child(2) {
  --stacked: translate3d(0, 8px, -40px);
  --fanned: translate3d(0, -2%, 0);
  z-index: 1;
}

.fan-card:nth-child(3) {
  --stacked: translate3d(0, 0, 0) rotate(4deg);
  --fanned: translate3d(var(--spread), 4%, -40px) rotate(9deg);
}

.fan.is-visible .fan-card {
  transform: var(--fanned);
}

.fan-tag {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.fan-stem {
  margin: 10px 0 14px;
  font-size: 14px;
  line-height: 1.45;
}

.fan-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
}

.fan-choices span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.fan-choices b {
  margin-right: 4px;
  color: var(--ink);
}

.fan-choices .is-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.fan-choices .is-correct b {
  color: var(--ok);
}

/* Mock test panel */

.mock {
  max-width: 780px;
  margin: 0 auto;
  overflow: hidden;
}

.mock-bar,
.mock-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding: 14px 20px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--ink-2);
}

.mock-bar {
  border-bottom: 1px solid var(--line);
}

.mock-foot {
  border-top: 1px solid var(--line);
}

.mock-timer {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.mock-tools {
  display: flex;
  gap: 8px;
}

.mock-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.mock-tool.is-on {
  border-color: var(--ink);
  color: var(--ink);
}

.mock-abc {
  letter-spacing: 0.06em;
  text-decoration: line-through;
}

.mock-body {
  display: grid;
  gap: 18px;
  padding: clamp(20px, 3vw, 32px);
}

/* The panel is a picture of the test, not a test: its choices do not react. */
.mock .choice {
  cursor: default;
}

.mock .choice:hover {
  border-color: var(--line);
}

.mock .choice.is-selected:hover {
  border-color: var(--ink);
}

.mock-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dot {
  position: relative;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--ink-3);
  border-radius: 50%;
  background: var(--surface);
}

.dot.is-answered {
  border-color: var(--ink);
  background: var(--ink);
}

.dot.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.dot.is-flagged::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.mock-btns {
  display: flex;
  gap: 8px;
}

.mock-btn {
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
}

.mock-btn.is-ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

/* Mastery bars */

.mastery-card {
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 32px);
}

.mastery {
  display: grid;
  gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mastery-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  font-size: 15px;
}

.mastery-name {
  font-weight: 600;
}

.mastery-pct {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.bar {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  display: block;
  width: var(--w, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left;
  transition: transform var(--dur-3) var(--ease-out);
  transition-delay: calc(200ms + var(--i, 0) * 90ms);
}

.js .mastery-card:not(.is-visible) .bar-fill {
  transform: scaleX(0);
}

/* Video tiles */

.videos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.video {
  overflow: hidden;
}

.video-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 24px),
    linear-gradient(135deg, var(--surface-2), var(--surface-3));
}

.video-thumb svg {
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.12));
}

.play-ring {
  fill: var(--surface);
}

.play-mark {
  fill: var(--ink);
}

.video-title {
  margin: 14px 18px 2px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.video-meta {
  margin: 0 18px 16px;
  font-size: 14px;
  color: var(--ink-2);
}

/* Open source */

.oss-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Footer */

/* Reduced motion and print: everything rests in its final state, nothing turns or floats. */

@media (prefers-reduced-motion: reduce), print {
  .reveal,
  .fan-card,
  .bar-fill {
    transition: none;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }

  .js .fan:not(.is-visible) .fan-card {
    transform: var(--fanned);
  }

  .js .mastery-card:not(.is-visible) .bar-fill {
    transform: scaleX(1);
  }

  .hero-card {
    animation: none;
  }
}
