/* Design tokens — aligned with research */
:root,
[data-theme="light"] {
  color-scheme: light;
  --white: #FFFFFF;
  --snow: #FAFBFC;
  --ash: #F2F3F5;
  --mist: #E8EAED;
  --smoke: #C4C8CF;
  --slate: #8A8F98;
  --graphite: #5C6370;
  --ink: #1A1D23;
  --blue-pale: #EDF2FF;
  --blue-light: #B4C6FC;
  --blue: #4A6CF7;
  --blue-deep: #2A4AD4;
  --blue-ink: #1B2F80;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Russo One", var(--font);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-hero: clamp(1.75rem, 4vw, 2.5rem);

  --sp-sm: 0.75rem;
  --sp-md: 1.25rem;
  --sp-lg: 2rem;
  --sp-xl: 3.5rem;
  --content-max: 52rem;
  --content-pad-x: clamp(1.25rem, 4vw, 2rem);
  --header-h: 3.75rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --white: #14171c;
  --snow: #1a1d23;
  --ash: #242830;
  --mist: #2e333c;
  --smoke: #5c6370;
  --slate: #9aa0a8;
  --graphite: #c4c8cf;
  --ink: #f2f3f5;
  --blue-pale: #0f1218;
  --blue-light: #3d4f8c;
  --blue: #7b93f8;
  --blue-deep: #a8b8fc;
  --blue-ink: #c5d0ff;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--header-h);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--blue-pale);
}

a {
  color: var(--blue-deep);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--blue);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

img,
video {
  display: block;
  max-width: 100%;
}

.shell {
  width: min(100%, calc(var(--content-max) + 2 * var(--content-pad-x)));
  margin: 0 auto;
  padding-left: var(--content-pad-x);
  padding-right: var(--content-pad-x);
}

/* ---- Header ---- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--white) 92%, transparent);
  border-bottom: 1px solid var(--mist);
  box-shadow: inset 0 -2px 0 var(--blue-light);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  min-height: var(--header-h);
}

.header-back,
.header-title,
.header-link {
  font-size: var(--fs-sm);
  font-weight: 450;
  color: var(--slate);
  transition: color 0.2s ease;
}

.header-back:hover,
.header-title:hover,
.header-link:hover {
  color: var(--ink);
}

.header-title {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.header-nav {
  display: flex;
  gap: var(--sp-md);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--mist);
  border-radius: 8px;
  background: var(--snow);
  color: var(--graphite);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--smoke);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.theme-icon {
  display: none;
}

[data-theme="light"] .theme-icon-moon,
:root:not([data-theme]) .theme-icon-moon {
  display: block;
}

[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.header-burger {
  display: none;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--mist);
  border-radius: 8px;
  background: var(--snow);
}

.burger-line {
  display: block;
  width: 14px;
  height: 1.5px;
  background: var(--graphite);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-header.nav-open .burger-line:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}

.site-header.nav-open .burger-line:nth-child(2) {
  opacity: 0;
}

.site-header.nav-open .burger-line:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

/* ---- Main column (research-like card) ---- */
.site-main {
  flex: 1;
  box-sizing: border-box;
  width: min(calc(100% - 1.5rem), calc(var(--content-max) + 2 * var(--content-pad-x)));
  margin: var(--sp-md) auto var(--sp-lg);
  padding: var(--sp-lg) var(--content-pad-x) var(--sp-xl);
  background: var(--white);
  border: 1px solid var(--mist);
  border-radius: 12px;
}

.block {
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.block + .block {
  margin-top: var(--sp-xl);
  padding-top: var(--sp-xl);
  border-top: 1px solid var(--mist);
}

.hero-brand {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}

.hero-lead,
.section-lead {
  margin: 0 0 1.5rem;
  color: var(--graphite);
  font-size: var(--fs-lg);
  line-height: 1.5;
}

.section-kicker {
  margin: 0 0 0.35rem;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.section-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

/* ---- Hero stats (author-stat sizes/colors/fonts/hover, original copy) ---- */
.hero-gates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  gap: 0;
}

.hero-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 13rem;
  padding: 3.5rem var(--sp-sm) 1.25rem;
  text-align: center;
  border-right: 1px solid var(--mist);
  background: none;
  cursor: pointer;
}

.hero-stat:first-child {
  padding-left: 0;
}

.hero-stat:last-child {
  padding-right: 0;
  border-right: none;
}

.hero-stat-value {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.3em;
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #fff;
  white-space: nowrap;
  transition: color 0.2s ease, transform 0.2s ease;
}

[data-theme="light"] .hero-stat-value {
  color: var(--ink);
}

.hero-stat-suffix {
  color: var(--blue);
  transition: color 0.2s ease;
}

.hero-stat:hover .hero-stat-value,
.hero-stat:focus-visible .hero-stat-value {
  transform: translateY(-1px);
}

.hero-stat:hover .hero-stat-suffix,
.hero-stat:focus-visible .hero-stat-suffix {
  color: var(--blue);
}

.hero-stat:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
  border-radius: 4px;
}

.hero-stat-desc {
  display: block;
  margin: 0;
  max-width: 16rem;
  height: calc(var(--fs-sm) * 1.45 * 3);
  font-size: var(--fs-sm);
  font-weight: 400;
  line-height: 1.45;
  color: var(--slate);
  overflow: hidden;
}

@media (max-width: 600px) {
  .hero-stat-value {
    flex-direction: column;
    align-items: center;
    gap: 0;
    white-space: normal;
  }
}

/* Stack on very narrow: full width keeps desc within ~3 lines */
@media (max-width: 480px) {
  .hero-gates {
    grid-template-columns: 1fr;
  }

  .hero-stat {
    border-right: none;
    border-bottom: 1px solid var(--mist);
    padding-left: 0;
    padding-right: 0;
  }

  .hero-stat:last-child {
    border-bottom: none;
  }

  .hero-stat-desc {
    max-width: none;
  }
}

.hero-stat-arrow {
  display: block;
  margin-top: 0.75rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--blue-deep);
  transition: color 0.2s ease;
}

.hero-stat:hover .hero-stat-arrow,
.hero-stat:focus-visible .hero-stat-arrow {
  color: var(--blue);
}

.hero-stat-interactive .ssd-tryit {
  top: 0.35rem;
  left: 0.35rem;
  transform: none;
}

@media (max-width: 720px) {
  .hero-stat-interactive .ssd-tryit {
    display: none;
  }

  .hero-stat {
    min-height: 0;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
}

@media (hover: hover) and (pointer: fine) {
  .hero-stat-interactive:hover .ssd-tryit:not(:hover),
  .hero-stat-interactive:focus-within .ssd-tryit:not(:hover) {
    padding-right: 0.72rem;
  }

  .hero-stat-interactive:hover .ssd-tryit:not(:hover) .ssd-tryit-txt,
  .hero-stat-interactive:focus-within .ssd-tryit:not(:hover) .ssd-tryit-txt {
    max-width: 0;
    margin-left: 0;
    opacity: 0;
  }
}

/* Window lighting open button */
.gate {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--mist);
  border-radius: 12px;
  background: var(--snow);
  text-align: left;
  transition: transform 0.25s var(--ease), border-color 0.2s ease, box-shadow 0.25s ease;
}

.gate:hover,
.gate:focus-visible {
  transform: translateY(-2px);
  border-color: var(--blue-light);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--blue) 12%, transparent);
  outline: none;
}

.gate-index {
  margin-bottom: 0.55rem;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.gate-title {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.gate-desc {
  margin: 0;
  color: var(--graphite);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.gate-arrow {
  margin-top: 0.85rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--blue-deep);
}

.gate-solo {
  margin-top: 0.25rem;
}

/* ---- Stacked media ---- */
.media-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.media-item + .media-item {
  margin-top: 1.75rem;
}

.media-meta h3 {
  margin: 0 0 0.2rem;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--ink);
}

.media-meta p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--graphite);
}

.video-frame {
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--mist);
  background: #0b0d0f;
  aspect-ratio: 1 / 1;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.demo-embed {
  display: block;
  width: 100%;
  min-height: 36rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
}

/* ---- Inline demos (as on research) ---- */
.article-demo {
  margin: 0.5rem 0 0;
  display: flex;
  justify-content: center;
  width: 100%;
}

.article-demo .ssd {
  --ssd-w: min(100%, 50rem);
  width: var(--ssd-w);
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 0;
  cursor: default;
  border-color: var(--blue);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 28%, transparent);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.article-demo .ssd:hover,
.article-demo .ssd:focus-within {
  border-color: var(--mist);
  box-shadow: none;
}

.ssd-tryit {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  height: 2.75rem;
  padding: 0 1.15rem 0 0.72rem;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font: 600 1.05rem / 1 var(--font);
  letter-spacing: 0.03em;
  text-transform: lowercase;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  overflow: hidden;
  transition: padding 0.55s ease;
}

.ssd-tryit::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue) 40%, transparent);
  animation: ssd-tryit-pulse 2.4s ease-in-out infinite;
}

.ssd-tryit-ico {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: block;
}

.ssd-tryit-txt {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 5.5rem;
  margin-left: 0.5rem;
  overflow: hidden;
  opacity: 1;
  white-space: nowrap;
  transition:
    max-width 0.55s ease,
    margin-left 0.55s ease,
    opacity 0.4s ease;
}

@media (hover: hover) and (pointer: fine) {
  .ssd:hover .ssd-tryit:not(:hover),
  .ssd:focus-within .ssd-tryit:not(:hover) {
    padding-right: 0.72rem;
  }

  .ssd:hover .ssd-tryit:not(:hover) .ssd-tryit-txt,
  .ssd:focus-within .ssd-tryit:not(:hover) .ssd-tryit-txt {
    max-width: 0;
    margin-left: 0;
    opacity: 0;
  }
}

.ssd:has(.ssd-btn) .ssd-tryit::before {
  animation-name: ssd-tryit-pulse-hot;
  animation-duration: 0.9s;
}

@keyframes ssd-tryit-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue) 40%, transparent);
  }
  50% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--blue) 0%, transparent);
  }
}

@keyframes ssd-tryit-pulse-hot {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue) 55%, transparent);
  }
  50% {
    box-shadow: 0 0 0 14px color-mix(in srgb, var(--blue) 0%, transparent);
  }
}

.article-demo .ssd *,
.article-demo .ssd svg,
.article-demo .ssd svg * {
  cursor: default;
}

.article-demo .ssd-btn,
.article-demo .ssd-btn *,
.article-demo .ssd-replay,
.article-demo .ssd-replay *,
.article-demo .ssd-tryit,
.article-demo .ssd-tryit * {
  cursor: pointer;
}

.article-demo .ssd-btn {
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.22s cubic-bezier(0.33, 1, 0.68, 1);
}

.article-demo .ssd-btn:hover {
  border-color: rgb(123, 147, 248);
  color: #fff;
  background: rgb(123, 147, 248);
  box-shadow: 0 4px 16px color-mix(in srgb, rgb(123, 147, 248) 40%, transparent);
  transform: translateY(-1px) scale(1.04);
}

.article-demo .ssd-btn:hover b,
.article-demo .ssd-btn:hover small {
  color: #fff;
}

.article-demo .ssd-btn:active {
  transform: translateY(0) scale(1.03);
  box-shadow: 0 2px 10px color-mix(in srgb, rgb(123, 147, 248) 35%, transparent);
  background: rgb(123, 147, 248);
  border-color: rgb(123, 147, 248);
  color: #fff;
}

.article-demo .ssd-btn:focus-visible {
  outline: 2px solid rgb(123, 147, 248);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ssd-tryit::before {
    animation: none;
  }
}

/* ---- Overlay (window lighting only) ---- */
.demo-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #0b0d0f;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.demo-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.demo-overlay-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.65rem var(--content-pad-x);
  background: color-mix(in srgb, #0b0d0f 92%, transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f2f3f5;
}

.demo-overlay-title {
  font-size: var(--fs-sm);
  font-weight: 500;
}

.demo-overlay-close {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f2f3f5;
  font-size: 1.1rem;
  line-height: 1;
}

.demo-overlay-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.demo-overlay iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b0d0f;
}

body.demo-open {
  overflow: hidden;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--mist);
  font-size: var(--fs-sm);
  color: var(--slate);
}

.site-footer-inner {
  padding-top: var(--sp-lg);
  padding-bottom: var(--sp-xl);
}

.site-footer a {
  color: var(--slate);
}

.site-footer a:hover,
.site-footer .is-active {
  color: var(--ink);
}

.footer-sep {
  margin: 0 0.35rem;
  color: var(--smoke);
}

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .site-main {
    width: min(calc(100% - 1rem), calc(var(--content-max) + 2 * var(--content-pad-x)));
    margin-top: 0.75rem;
    padding-top: var(--sp-md);
  }

  .header-burger {
    display: inline-flex;
  }

  .header-nav {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem var(--content-pad-x) 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--mist);
  }

  .site-header.nav-open .header-nav {
    display: flex;
  }

  .header-nav .header-link {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--mist);
    font-size: var(--fs-base);
  }

  .header-nav .header-link:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 520px) {
  .header-back {
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero-lead,
  .section-lead {
    font-size: var(--fs-base);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .gate,
  .hero-stat-value,
  .demo-overlay {
    transition: none;
  }
}
