/* Simplesaurus: the app's own style. Inter Medium (never bold), white
   surfaces with a soft shadow, one blue for the key words.

   Every scroll effect is a CSS scroll-driven animation (scroll() and view()
   timelines), so there is no JavaScript. They sit inside
   @supports (animation-timeline: view()) and prefers-reduced-motion, so
   without them the page is the same content, still and complete. */

@font-face {
  font-family: "Inter";
  src: url("assets/Inter.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

/* Typed custom properties, so they can be animated. */
@property --strike {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 100%;
}

:root {
  /* The plesiosaur logo's colours: Deep Teal, Lagoon, Off-White. */
  --deep-teal: #0F4C5C;
  --lagoon: #5FB3B3;
  --off-white: #F4F8F7;

  --bg: var(--off-white);
  --text: #1F2124;
  --muted: #5F6368;
  --border: #DADCE0;
  --accent: var(--deep-teal);
  /* Highlighted words: Deep Teal lifted toward Lagoon, to stand apart from body text. */
  --accent-text: color-mix(in oklab, var(--deep-teal) 72%, var(--lagoon));
  --soft: color-mix(in oklab, var(--lagoon) 16%, white);
  --red: #C5221F;
  --green: #137333;
  --white: #fff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 12px 32px -8px rgb(0 0 0 / 0.16);
  --shadow-big: 0 2px 4px rgb(0 0 0 / 0.05), 0 30px 80px -20px rgb(0 0 0 / 0.28);
  --radius: 16px;
  --mono: ui-monospace, "DejaVu Sans Mono", "SF Mono", Menlo, Consolas, monospace;
  --page: min(1180px, 100% - 48px);
  --ease: linear(0, 0.04 6%, 0.19 14%, 0.5 30%, 0.8 50%, 0.94 70%, 1);

  color-scheme: light;
}

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

html { scroll-padding-top: 80px; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1, h2, h3, h4 {
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
b { font-weight: 600; }
em { font-style: normal; color: var(--accent-text); }
img, video { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); }

/* ---------- Shared pieces ---------- */

.mark { width: auto; height: 32px; flex: none; }
.mark.big { height: 1.25em; }
.mark.huge { height: 150px; margin: 0 auto; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--white);
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 6px 18px -6px color-mix(in oklab, var(--accent) 70%, transparent);
  transition: translate 0.2s var(--ease), background-color 0.2s;

  &:hover { translate: 0 -2px; background: color-mix(in oklab, var(--accent) 88%, black); }
  &:focus-visible { outline: 3px solid color-mix(in oklab, var(--accent) 40%, transparent); outline-offset: 3px; }
  &.small { padding: 8px 18px; font-size: 15px; }
  /* Two lines: the action, then the platforms in small type. */
  &.stacked {
    flex-direction: column;
    gap: 1px;
    padding: 10px 28px 11px;
    line-height: 1.25;

    & small { font-size: 13px; font-weight: 400; opacity: 0.8; }
  }
  &.ghost {
    background: var(--white);
    color: var(--text);
    box-shadow: var(--shadow);
    &:hover { background: var(--white); }
  }
}

.window {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-big);
  overflow: hidden;
  outline: 1px solid rgb(0 0 0 / 0.06);
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.eyebrow {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.section-head {
  max-width: 760px;
  margin: 0 auto 64px;
  text-align: center;

  & h2 { font-size: clamp(34px, 5vw, 58px); }
  & p:not(.eyebrow) { margin-top: 20px; font-size: 20px; color: var(--muted); }
}

.section-head.statement {
  max-width: 900px;
  margin-top: 120px;

  & h2 { font-size: clamp(28px, 3.6vw, 44px); line-height: 1.25; }
}

.feature {
  width: var(--page);
  margin: 0 auto;
  padding: 160px 0 40px;
}

.footnote {
  margin-top: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

/* Typed text: its width grows in whole characters. */
.typed {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  font-family: var(--mono);
}

/* ---------- Header and progress ---------- */

.progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  z-index: 20;
  display: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 14px max(24px, (100% - 1180px) / 2);
  /* Frosted glass: mostly see-through, heavily blurred, with a light edge. */
  background: rgb(255 255 255 / 0.32);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  box-shadow: inset 0 -1px 0 rgb(255 255 255 / 0.55), 0 1px 0 rgb(0 0 0 / 0.04);

  & .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
  }
  & nav {
    display: flex;
    gap: 24px;
    margin-left: auto;

    & a { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500; }
    & a:hover { color: var(--accent); }
  }
}
@media (width < 760px) {
  .site-header nav { display: none; }
  .site-header .button { margin-left: auto; }
}

/* ---------- Hero ---------- */

.hero {
  padding: 96px 0 120px;
  text-align: center;
  position: relative;
  isolation: isolate;
  margin-top: -64px;
  padding-top: 160px;
}
.hero-copy {
  width: var(--page);
  margin: 0 auto;

  & h1 {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    font-size: clamp(46px, 8vw, 96px);
  }
  & .tagline { margin-top: 18px; font-size: clamp(24px, 3vw, 34px); font-weight: 500; }
  & .lede { max-width: 640px; margin: 22px auto 0; font-size: 20px; color: var(--muted); }
  & .cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 36px; }
  & .facts { margin-top: 22px; font-size: 15px; color: var(--muted); }
}

/* Underwater caustics behind the title: a blue wash with two layers of
   rippling light (assets/caustics.svg) drifting different ways, so the
   network of light shifts like sunlight through moving water. */
.caustics {
  position: absolute;
  /* Starts above the hero, so the water reaches the top of the window behind the bar. */
  inset: -100px 0 auto;
  height: calc(min(1000px, 120vh) + 100px);
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--lagoon) 34%, white) 0%,
    color-mix(in oklab, var(--lagoon) 20%, white) 45%,
    transparent 100%);
  mask-image:
    linear-gradient(180deg, #000 55%, transparent 100%),
    linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-composite: intersect;

  & span {
    position: absolute;
    inset: -600px;
    background: url("assets/caustics.svg") 0 0 / 512px;
    opacity: 0.6;
  }
  & span + span {
    background-size: 704px;
    opacity: 0.4;
    transform: rotate(23deg);
  }
}
@media (prefers-reduced-motion: no-preference) {
  /* One whole tile per loop, so each layer repeats without a seam. */
  .caustics span { animation: drift-a 38s linear infinite; }
  .caustics span + span { animation: drift-b 53s linear infinite; }
}
@keyframes drift-a { to { transform: translate(512px, 512px); } }
@keyframes drift-b {
  from { transform: rotate(23deg) translate(0, 0); }
  to { transform: rotate(23deg) translate(-704px, 704px); }
}

/* The title arrives on page load (@starting-style needs no script). */
@media (prefers-reduced-motion: no-preference) {
  .hero-copy > * {
    transition: opacity 0.9s var(--ease), translate 0.9s var(--ease);
    @starting-style { opacity: 0; translate: 0 24px; }
  }
  .hero-copy > :nth-child(2) { transition-delay: 0.1s; }
  .hero-copy > :nth-child(3) { transition-delay: 0.2s; }
  .hero-copy > :nth-child(4) { transition-delay: 0.3s; }
  .hero-copy > :nth-child(5) { transition-delay: 0.4s; }
}

.hero-window {
  width: min(1180px, 100% - 32px);
  margin: 72px auto 0;
  transform-origin: 50% 0;
}

/* ---------- Tour ---------- */

.tour-wrap { width: var(--page); margin: 0 auto; padding-top: 120px; }

.tour-stage { display: none; }

.tour-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 96px;
}
.step {
  display: grid;
  gap: 28px;

  & h3 { font-size: 30px; }
  & p { margin-top: 12px; color: var(--muted); }
}
.step-n {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
}

/* ---------- Diagrams ---------- */

/* ---------- Citations ---------- */

.cite-demo {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 32px;
  align-items: start;
}
.field {
  padding: 12px 14px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  font-size: clamp(12px, 1.3vw, 15px);
  box-shadow: 0 0 0 4px var(--soft);

  & .typed { width: calc(var(--chars) * 1ch); }
}
.found {
  margin-top: 22px;
  padding: 18px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 16px;
}

.page {
  padding: 44px 48px;

  & h3 { font-size: 30px; margin-bottom: 14px; }
  & h4 { font-size: 22px; margin-bottom: 10px; }
}
.cite-link {
  font: inherit;
  color: inherit;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 4px;

  &:hover { color: var(--accent); }
}
.hint { margin-top: 16px; font-size: 15px; color: var(--muted); }

/* The source pops up beside the citation that opened it (anchor positioning). */
.ref-pop {
  inset: auto;
  max-width: 380px;
  margin: 10px 0;
  padding: 20px;
  border: 0;
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-big);
  font-size: 15px;
  color: var(--text);
  position-anchor: --knuth;
  position-area: bottom span-right;
  position-try-fallbacks: flip-block, flip-inline;

  & a { display: inline-block; margin-top: 10px; }

  opacity: 1;
  translate: 0 0;
  transition: opacity 0.25s, translate 0.25s var(--ease), display 0.25s allow-discrete, overlay 0.25s allow-discrete;
  @starting-style { opacity: 0; translate: 0 -6px; }
}
.ref-pop:not(:popover-open) { opacity: 0; translate: 0 -6px; }
@supports not (position-area: bottom) {
  .ref-pop { inset: 0; margin: auto; height: fit-content; }
}

@media (width < 820px) {
  .cite-demo { grid-template-columns: 1fr; }
  .page { padding: 32px 24px; }
}

/* ---------- Suggestions ---------- */

.suggest-demo { max-width: 820px; margin: 0 auto; }
.mode-pill {
  display: inline-flex;
  gap: 8px;
  padding: 6px 14px;
  margin-bottom: 26px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
}
.sentence { font-size: clamp(22px, 2.6vw, 30px); line-height: 1.5; }
del {
  color: var(--red);
  text-decoration: none;
  background: linear-gradient(var(--red), var(--red)) no-repeat 0 58% / var(--strike) 2px;
  background-color: color-mix(in oklab, var(--red) 8%, transparent);
}
ins {
  margin-left: 0.25em;
  color: var(--green);
  text-decoration: underline 2px;
  text-underline-offset: 5px;
  background: color-mix(in oklab, var(--green) 9%, transparent);
  display: inline-block;
}
.choices {
  display: flex;
  gap: 12px;
  margin-top: 30px;

  & label {
    padding: 9px 20px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg);
    transition: background-color 0.2s, color 0.2s;
    &:hover { background: var(--soft); color: var(--accent); }
    &:has(:focus-visible) { outline: 2px solid var(--accent); }
  }
  & label:first-child { background: var(--accent); color: var(--white); }
  & input { position: absolute; opacity: 0; pointer-events: none; }
  & .reset { display: none; margin-left: auto; }
}
/* :has() lets the choice change the sentence above it. */
.suggest-demo:has([value="accept"]:checked) {
  & del { display: none; }
  & ins { margin-left: 0; color: inherit; background: none; text-decoration: none; }
}
.suggest-demo:has([value="reject"]:checked) {
  & ins { display: none; }
  & del { color: inherit; background: none; }
}
.suggest-demo:has([value="accept"]:checked, [value="reject"]:checked) {
  & .choices label:not(.reset) { display: none; }
  & .choices .reset { display: block; margin-left: 0; }
  & .mode-pill { background: #E6F4EA; color: var(--green); }
}

/* ---------- Claude ---------- */

.claude-demo {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 40px;
  align-items: start;
}
.terminal {
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-big);
  overflow: hidden;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
}
.term-head {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  font-family: "Inter", sans-serif;
  font-size: 14px;
  text-align: center;
  color: var(--muted);
}
.term-body {
  padding: 22px;
  display: grid;
  gap: 8px;

  & p { overflow-wrap: anywhere; }
  & .cmd { color: var(--text); margin-top: 8px; }
  & .cmd:first-child { margin-top: 0; }
  & .out { color: var(--muted); }
  & .no { color: var(--red); }
  & .yes { color: var(--green); }
  & .receipt { color: var(--accent); background: var(--soft); padding: 4px 8px; border-radius: 6px; }
}
.claude-side h3 { font-size: 28px; }
.checks {
  margin: 22px 0 28px;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 12px;

  & li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 10px;
    color: var(--muted);
  }
  & li::before {
    content: counter(step);
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--soft);
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
  }
}
@media (width < 900px) {
  .claude-demo { grid-template-columns: 1fr; }
}

/* ---------- Sources beside writing ---------- */

.split {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  min-height: 380px;
  max-width: 1000px;
  margin: 0 auto;
}
.split-source {
  padding: 32px;
  background: #E9EBEF;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--border);
}
.split-doc {
  padding: 40px 44px;
  display: flex;
  flex-direction: column;
  gap: 14px;

  & h4 { font-size: 26px; }
}
.bar {
  display: block;
  height: 10px;
  width: var(--w);
  border-radius: 5px;
  background: rgb(0 0 0 / 0.1);
}
.split-doc .bar { background: rgb(0 0 0 / 0.07); }
.mark-bar { background: color-mix(in oklab, #F9AB00 55%, transparent); }
.gap { height: 12px; }
.cite-chip { color: var(--accent); }
@media (width < 700px) {
  .split { grid-template-columns: 1fr; }
}

/* ---------- Markdown anywhere ---------- */

.markdown { padding: 160px 0 40px; }
.markdown .section-head { width: var(--page); }
.track-viewport {
  --edge: max(24px, (100vw - 1180px) / 2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--edge);
  scrollbar-width: none;
  /* Room for the cards' shadows, which the scrolling box would otherwise cut off. */
  padding: 30px 0 90px;
  margin: -20px 0 -50px;

  &::-webkit-scrollbar { display: none; }
  &:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
}
.gallery-controls {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  width: var(--page);
  margin: 20px auto 0;
}
.arrow {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow);
  color: var(--accent);
  font: 500 22px/1 "Inter", sans-serif;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, opacity 0.2s, scale 0.2s var(--ease);

  &:hover:not(:disabled) { background: var(--accent); color: var(--white); }
  &:active:not(:disabled) { scale: 0.94; }
  &:focus-visible { outline: 3px solid color-mix(in oklab, var(--accent) 40%, transparent); outline-offset: 3px; }
  &:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
}
.track {
  display: flex;
  gap: 28px;
  width: max-content;
  margin: 0;
  padding: 0 var(--edge);
  list-style: none;

  & li { scroll-snap-align: start; }
  & figure {
    margin: 0;
    width: min(560px, 80vw);
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-big);
    overflow: hidden;
  }
  & figcaption {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 15px;
    font-weight: 500;
  }
  & li:first-child figcaption { color: var(--accent); }
}

/* ---------- Export ---------- */

.export-demo {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
}
.word-page {
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 30%;
  border-radius: 4px;
  box-shadow: var(--shadow-big);
  rotate: 4deg;
}
.formats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 110px 0 0;
  padding: 0;
  list-style: none;

  & li {
    padding: 8px 18px;
    border-radius: 999px;
    background: var(--white);
    box-shadow: var(--shadow);
    font-size: 15px;
    font-weight: 500;
  }
  & li:last-child { background: var(--accent); color: var(--white); }
}
@media (width < 700px) {
  .word-page { right: -8px; bottom: -40px; width: 38%; }
}

/* ---------- Extras ---------- */

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

  & li {
    padding: 24px;
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
    color: var(--muted);
    font-size: 16px;
  }
  & b { display: block; margin-bottom: 6px; color: var(--text); font-size: 19px; font-weight: 500; }
}

/* ---------- Film ---------- */

.film-window { max-width: 1000px; margin: 0 auto; }
.film-window video { width: 100%; }

/* ---------- Download ---------- */

.download {
  padding: 200px 24px 180px;
  display: grid;
  place-items: center;
}
.end-card {
  text-align: center;
  /* A grid item: without this the install command, which doesn't wrap,
     would widen it past a phone's screen. */
  min-width: 0;
  max-width: 100%;

  & h2 { margin-top: 28px; font-size: clamp(36px, 6vw, 68px); color: var(--accent); }
  & .platforms { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 44px; }
  & .facts { margin-top: 26px; color: var(--muted); }
}

/* macOS and Windows until their builds are out: the button's shape, no fill, not clickable. */
.button.soon {
  flex-direction: column;
  gap: 1px;
  padding: 10px 28px 11px;
  line-height: 1.25;
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: default;

  &:hover { translate: none; background: transparent; }
  & small { font-size: 13px; font-weight: 400; }
}

/* Linux: the install command and the packages. */
.linux-install {
  max-width: 640px;
  margin: 28px auto 0;
  padding: 24px 28px;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: left;
  font-size: 16px;

  &.closed { display: none; }
  & p { margin: 0; }
  & .lead { font-weight: 500; }
  & .command {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 14px;
    padding: 10px 10px 10px 16px;
    border-radius: 10px;
    background: var(--soft);
  }
  & code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--mono); font-size: 15px; color: var(--accent); }
  & .copy {
    flex: none;
    padding: 6px 14px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: var(--white);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;

    &:focus-visible { outline: 3px solid color-mix(in oklab, var(--accent) 40%, transparent); outline-offset: 2px; }
  }
  & .hint, & .packages { color: var(--muted); font-size: 15px; }
  & .packages { margin-top: 10px; }
  & a { color: var(--accent-text); }
}

@media (width < 700px) {
  .linux-install { padding: 18px 16px; }
  .linux-install code { font-size: 13px; }
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 28px max(24px, (100% - 1180px) / 2);
  border-top: 1px solid var(--border);
  font-size: 15px;
  color: var(--muted);

  & span { display: inline-flex; align-items: center; gap: 8px; }
  & .mark { width: auto; height: 22px; }
}

/* =====================================================================
   Scroll-driven animations
   ===================================================================== */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  @supports (animation-timeline: view()) {

    /* Reading progress along the top. */
    .progress {
      display: block;
      animation: grow-x linear both;
      animation-timeline: scroll(root);
    }

    /* The header gains its edge once the page moves. */
    .site-header {
      animation: header-edge linear both;
      animation-timeline: scroll(root);
      animation-range: 0 160px;
    }

    /* Hero: the title lifts away and the window lays flat. */
    /* The water lags behind the page (parallax) and fades as you leave it. */
    .caustics {
      animation: sink linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100vh;
    }
    .hero-copy {
      animation: lift-away linear both;
      animation-timeline: scroll(root);
      animation-range: 0 60vh;
    }
    .hero-window {
      animation: hero-flat linear both;
      animation-timeline: scroll(root);
      animation-range: 0 90vh;
    }

    /* Anything marked .reveal rises in as it enters. */
    .reveal {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 30%;
    }

    /* --- Tour: one window stays put; each step's own view timeline
           fades its shot in and out (timeline-scope lifts the names up
           to .tour, so the stage, a sibling, can use them). --- */
    @media (width >= 960px) {
      .tour {
        timeline-scope: --s1, --s2, --s3, --s4;
        display: grid;
        grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
        gap: 64px;
      }
      .tour-stage {
        display: block;
        grid-column: 2;
        grid-row: 1;
        position: sticky;
        top: max(88px, calc(50vh - 230px));
        align-self: start;
        aspect-ratio: 16 / 10;

        & img {
          position: absolute;
          inset: 0;
          width: 100%;
          height: 100%;
          object-fit: cover;
          transform-origin: var(--ox) var(--oy);
          animation: shot linear both;
          animation-range: cover 0% cover 100%;
        }
        & img:nth-child(1) { animation-name: shot-first; animation-timeline: --s1; }
        & img:nth-child(2) { animation-timeline: --s2; }
        & img:nth-child(3) { animation-timeline: --s3; }
        & img:nth-child(4) { animation-name: shot-last; animation-timeline: --s4; }
      }
      .tour-steps { grid-column: 1; grid-row: 1; gap: 0; }
      .step {
        min-height: 90vh;
        align-content: center;

        & .shot { display: none; }
        & .step-text {
          animation: step-focus linear both;
          animation-timeline: view();
          animation-range: cover 0% cover 100%;
        }
      }
      .step:nth-child(1) { view-timeline: --s1 block; }
      .step:nth-child(2) { view-timeline: --s2 block; }
      .step:nth-child(3) { view-timeline: --s3 block; }
      .step:nth-child(4) { view-timeline: --s4 block; }
      /* The first step is already in place when the tour arrives. */
      .step:first-child .step-text { animation-name: step-focus-first; }
    }

    /* --- Citations: the DOI is pasted, then the reference is found. --- */
    .citations { view-timeline: --cite block; }
    .field .typed {
      animation: type steps(var(--chars), end) both;
      animation-timeline: --cite;
      animation-range: cover 25% cover 38%;
    }
    .found {
      animation: rise linear both;
      animation-timeline: --cite;
      animation-range: cover 40% cover 46%;
    }
    .cite-demo .page {
      animation: slide-in-right linear both;
      animation-timeline: --cite;
      animation-range: cover 22% cover 40%;
    }
    @media (width < 820px) {
      .cite-demo .page { animation-name: rise; }
    }

    /* --- Suggestions: the strike draws across, the new word lands. --- */
    .suggestions { view-timeline: --suggest block; }
    del {
      animation: strike linear both;
      animation-timeline: --suggest;
      animation-range: cover 35% cover 45%;
    }
    ins {
      animation: drop-in linear both;
      animation-timeline: --suggest;
      animation-range: cover 44% cover 50%;
    }
    .suggest-demo {
      animation: rise linear both;
      animation-timeline: --suggest;
      animation-range: cover 15% cover 32%;
    }

    /* --- Claude: the terminal prints line by line as you scroll. --- */
    .terminal { view-timeline: --term block; }
    .term-body p {
      animation: print linear both;
      animation-timeline: --term;
      animation-range: cover calc(18% + var(--i) * 3.5%) cover calc(20% + var(--i) * 3.5%);
    }
    .checks li {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 20% cover 35%;
    }

    /* --- Sources: the reading panel opens from the left. --- */
    .split { view-timeline: --split block; }
    .split {
      animation: rise linear both;
      animation-timeline: --split;
      animation-range: entry 0% cover 30%;
    }
    .split-source {
      animation: open-panel linear both;
      animation-timeline: --split;
      animation-range: cover 20% cover 42%;
    }
    .mark-bar {
      animation: highlight linear both;
      animation-timeline: --split;
      animation-range: cover 40% cover 48%;
    }
    .cite-chip {
      animation: flash linear both;
      animation-timeline: --split;
      animation-range: cover 46% cover 52%;
    }

    /* --- Markdown: cards grow in as they slide in from the right edge
           of the gallery (a view timeline on the sideways scroller). --- */
    .track figure {
      animation: card-in linear both;
      animation-timeline: view(inline);
      animation-range: entry 0% entry 100%;
    }

    /* --- Export: the Word page slides out of the window. --- */
    .export-demo { view-timeline: --export block; }
    .export-window {
      animation: lay-flat linear both;
      animation-timeline: --export;
      animation-range: entry 0% cover 40%;
    }
    .word-page {
      animation: page-out linear both;
      animation-timeline: --export;
      animation-range: cover 35% cover 55%;
    }
    .formats li {
      animation: pop linear both;
      animation-timeline: view();
      animation-range: entry calc(10% + var(--i) * 8%) entry calc(60% + var(--i) * 8%);
    }

    /* --- Extras: the cards rise in a ripple. --- */
    .extras-grid li {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry calc(var(--i) * 4%) cover calc(20% + var(--i) * 3%);
    }

    .film-window {
      animation: lay-flat linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 40%;
    }

    /* --- End card: grows into place. --- */
    .end-card {
      animation: settle linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 45%;
    }
  }
}

/* ---------- Keyframes ---------- */

@keyframes grow-x { from { scale: 0 1; } to { scale: 1 1; } }

@keyframes header-edge {
  to {
    background: rgb(255 255 255 / 0.55);
    box-shadow: inset 0 -1px 0 rgb(255 255 255 / 0.6), 0 1px 0 rgb(0 0 0 / 0.06), 0 8px 24px -14px rgb(0 0 0 / 0.25);
  }
}

@keyframes sink { to { translate: 0 35vh; opacity: 0.25; } }

@keyframes lift-away { to { opacity: 0; translate: 0 -24px; } }

@keyframes hero-flat {
  from { transform: perspective(1800px) rotateX(12deg) scale(0.95); }
  to { transform: none; }
}

@keyframes lay-flat {
  from { transform: perspective(1600px) rotateX(22deg) scale(0.9); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

@keyframes rise {
  from { opacity: 0; translate: 0 48px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes settle {
  from { opacity: 0; scale: 0.85; }
  to { opacity: 1; scale: 1; }
}

/* Tour shots: fade in, an eased push, fade out. */
@keyframes shot {
  0%, 22% { opacity: 0; scale: 1; }
  36%, 64% { opacity: 1; }
  78%, 100% { opacity: 0; scale: 1.12; }
}
@keyframes shot-first {
  0%, 64% { opacity: 1; }
  0% { scale: 1; }
  78%, 100% { opacity: 0; scale: 1.12; }
}
@keyframes shot-last {
  0%, 22% { opacity: 0; scale: 1; }
  36%, 100% { opacity: 1; }
  100% { scale: 1.12; }
}
@keyframes step-focus-first {
  0%, 60% { opacity: 1; translate: 0 0; }
  80%, 100% { opacity: 0.2; translate: 0 -40px; }
}
@keyframes step-focus {
  0%, 20% { opacity: 0.2; translate: 0 40px; }
  40%, 60% { opacity: 1; translate: 0 0; }
  80%, 100% { opacity: 0.2; translate: 0 -40px; }
}

@keyframes type { from { width: 0; } }

@keyframes pop {
  from { opacity: 0; scale: 0.7; }
  to { opacity: 1; scale: 1; }
}
@keyframes slide-in-right {
  from { opacity: 0; translate: 60px 0; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes strike { from { --strike: 0%; } to { --strike: 100%; } }
@keyframes drop-in {
  from { opacity: 0; translate: 0 -0.6em; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes print {
  from { opacity: 0; translate: -8px 0; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes flash {
  from { opacity: 0; background: color-mix(in oklab, var(--accent) 35%, transparent); }
  to { opacity: 1; }
}

@keyframes open-panel {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes highlight {
  from { background: rgb(0 0 0 / 0.1); }
}

@keyframes page-out {
  from { opacity: 0; translate: -40% 30%; rotate: -6deg; scale: 0.8; }
  to { opacity: 1; translate: 0 0; rotate: 4deg; scale: 1; }
}

/* ---------- Built on open source ---------- */

.oss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;

  & a {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 4px;
    height: 100%;
    padding: 26px 14px 22px;
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
    color: var(--text);
    text-align: center;
    text-decoration: none;
    transition: translate 0.25s var(--ease), box-shadow 0.25s;

    &:hover { translate: 0 -4px; box-shadow: var(--shadow-big); }
    &:focus-visible { outline: 3px solid color-mix(in oklab, var(--accent) 40%, transparent); outline-offset: 3px; }
  }
  & img {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    object-fit: contain;
  }
  & img.wide { width: 84px; }
  & b { font-size: 17px; font-weight: 500; }
  & span { font-size: 14px; color: var(--muted); line-height: 1.4; }
}
.oss-more {
  margin: 28px 0 40px;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* The tiles rise in a ripple, and each logo takes its colour as it arrives. */
    .oss-grid li {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry calc(var(--i) * 3%) cover calc(18% + var(--i) * 2%);
    }
    .oss-grid img {
      animation: colour-in linear both;
      animation-timeline: view();
      animation-range: entry 40% cover 40%;
    }
  }
}
@keyframes colour-in {
  from { filter: grayscale(1) opacity(0.5); scale: 0.8; }
  to { filter: none; scale: 1; }
}

/* The diagram carousel: full-bleed, like the Markdown gallery. */
.dg-gallery {
  width: 100vw;
  margin-left: calc(50% - 50vw);
}
.track-viewport { position: relative; }
.track .dg-card {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  width: min(520px, 84vw);
  height: 100%;
  padding: 22px 24px 26px;
  background: var(--white);

  & figcaption {
    padding: 0 0 14px;
    border: 0;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }
}
.track > li { display: flex; }
/* Each drawing's text shrinks to fit its card: --cols is its widest line,
   and a monospace character is about 0.61em wide (cqi: the card's width). */
.dg-src, .dg-art {
  --fit: calc((100cqi - 30px) / (var(--cols) * 0.61));
  margin: 0;
  font-family: var(--mono);
  white-space: pre;
  overflow-x: auto;
}
.dg-src {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--accent);
  font-size: min(12.5px, var(--fit));
  line-height: 1.5;
}
.dg-art {
  flex: 1;
  display: grid;
  place-items: center;
  margin-top: 14px;
  padding: 18px 12px;
  border-radius: 10px;
  background: #F6F7F9;
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
  font-size: min(12.5px, var(--fit));
  line-height: 1.25;
}

/* ---------- Citation manager ---------- */

.ai-check {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.ai-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;

  & .card-label { margin: 0; }
}
.local-badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: #E6F4EA;
  color: var(--green);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.meter {
  height: 8px;
  margin: 14px 0 10px;
  border-radius: 4px;
  /* Human, some AI, much AI: the three bands of the result. */
  background: linear-gradient(90deg,
    color-mix(in oklab, var(--green) 18%, white) 0 40%,
    color-mix(in oklab, #F9AB00 22%, white) 40% 70%,
    color-mix(in oklab, var(--red) 18%, white) 70%);
  overflow: hidden;

  & span {
    display: block;
    width: 24%;
    height: 100%;
    border-radius: 4px;
    background: var(--green);
    transform-origin: left;
  }
}
.verdict { color: var(--green); font-weight: 500; font-size: 16px; }

.style-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 26px;

  & label {
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--bg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;

    &:hover { color: var(--accent); }
    &:has(:checked) { background: var(--accent); color: var(--white); }
    &:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
  }
  & input { position: absolute; opacity: 0; pointer-events: none; }
}

/* :has() swaps the in-text citation and the reference list to the chosen style. */
.cite-page [data-style] { display: none; }
.cite-page:has([value="apa"]:checked) [data-style~="apa"],
.cite-page:has([value="harvard"]:checked) [data-style~="harvard"],
.cite-page:has([value="chicago"]:checked) [data-style~="chicago"],
.cite-page:has([value="mla"]:checked) [data-style~="mla"],
.cite-page:has([value="ieee"]:checked) [data-style~="ieee"] { display: inline; }

.refs {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 15px;
}

.cite-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: -24px 0 56px;
  padding: 0;
  list-style: none;
  counter-reset: point;

  & li {
    counter-increment: point;
    padding: 26px 24px 24px;
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
    color: var(--muted);
    font-size: 16px;
  }
  & li::before {
    content: counter(point);
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: var(--soft);
    color: var(--accent);
    font-size: 15px;
    font-weight: 500;
  }
  & b { display: block; margin-bottom: 8px; color: var(--text); font-size: 19px; font-weight: 500; }
  & a { color: var(--accent-text); text-underline-offset: 3px; }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* The four points rise in a ripple. */
    .cite-points li {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry calc(var(--i) * 5%) cover calc(22% + var(--i) * 3%);
    }
    /* After the reference is found, the AI check fills its meter. */
    .ai-check {
      animation: rise linear both;
      animation-timeline: --cite;
      animation-range: cover 44% cover 48%;
    }
    .meter span {
      animation: fill-meter linear both;
      animation-timeline: --cite;
      animation-range: cover 47% cover 54%;
    }
    .verdict {
      animation: rise linear both;
      animation-timeline: --cite;
      animation-range: cover 53% cover 56%;
    }
  }
}
@keyframes fill-meter { from { scale: 0 1; } to { scale: 1 1; } }

/* ---------- GitHub link under "built on open source" ---------- */

.gh-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--white);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  transition: translate 0.2s var(--ease), color 0.2s, box-shadow 0.2s;

  &:hover { translate: 0 -2px; color: var(--accent); box-shadow: var(--shadow-big); }
  &:focus-visible { outline: 3px solid color-mix(in oklab, var(--accent) 40%, transparent); outline-offset: 3px; }
}

/* ---------- Export presets: a miniature page for each style ---------- */

.presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 28px 22px;
  margin: -16px 0 0;
  padding: 0;
  list-style: none;

  & li { display: grid; align-content: start; gap: 6px; font-size: 14px; color: var(--muted); line-height: 1.45; }
  & b { margin-top: 12px; color: var(--text); font-size: 17px; font-weight: 500; }
}

/* A sheet of A4: grey bars stand for lines of text. */
.mini {
  position: relative;
  aspect-ratio: 1 / 1.414;
  padding: 14% 12% 0;
  overflow: hidden;
  border-radius: 4px;
  background: var(--white);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: translate 0.25s var(--ease), box-shadow 0.25s;
  container-type: inline-size;

  li:hover & { translate: 0 -6px; box-shadow: var(--shadow-big); }

  & .ln { display: block; height: 3px; border-radius: 2px; background: #D9DDE2; flex: none; }
  & .ln:nth-child(4n) { width: 78%; }
  & .t { color: var(--text); font-weight: 600; font-size: 9cqi; line-height: 1.15; }
  & .foot { position: absolute; bottom: 5%; left: 0; right: 0; text-align: center; font-size: 5.5cqi; color: var(--muted); }
}
.p-simplesaurus {
  font-family: "Inter", sans-serif;
  & .h2 { display: block; height: 5px; width: 55%; margin-top: 6px; border-radius: 2px; background: #9AA3AD; box-shadow: 0 3px 0 -2px #D0D5DB; }
  & .tbl { display: block; height: 22px; margin: 4px 0; border-radius: 2px;
    background: linear-gradient(#DCE5EE 0 6px, transparent 6px), repeating-linear-gradient(#fff 0 5px, #E6E9ED 5px 6px); outline: 1px solid #E1E5EA; }
  & .foot { text-align: right; padding-right: 12%; }
}
.p-academic {
  font-family: "Times New Roman", Times, serif;
  justify-content: center;
  align-items: center;
  padding-top: 0;
  text-align: center;
  & .t { font-size: 8cqi; font-weight: 700; margin-bottom: 10%; }
  & .by { display: block; height: 3px; width: 50%; border-radius: 2px; background: #C9CDD2; }
  & .by.short { width: 34%; }
  & .pg { position: absolute; top: 6%; right: 9%; font-size: 5.5cqi; color: var(--text); }
}
.p-school {
  font-family: Arial, Helvetica, sans-serif;
  gap: 9px;
  & .t { font-weight: 700; font-size: 8cqi; margin-bottom: 4px; }
}
.p-report {
  padding: 0;
  & .cover {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    padding: 12%;
    background: linear-gradient(160deg, var(--deep-teal), color-mix(in oklab, var(--deep-teal) 70%, var(--lagoon)));
  }
  & .t { color: var(--white); font-size: 10.5cqi; }
  & .sub { display: block; height: 3px; width: 45%; border-radius: 2px; background: rgb(255 255 255 / 0.6); }
}
.p-book {
  font-family: Georgia, "Times New Roman", serif;
  padding-top: 30%;
  & .ch { text-align: center; font-size: 7.5cqi; font-style: italic; color: var(--text); margin-bottom: 8%; }
  /* The drop cap spans the first two lines, which are indented to make room for it. */
  & .drop { position: absolute; left: 12%; top: 56cqi; font-size: 11cqi; line-height: 1; color: var(--text); }
  & .ln:nth-child(4n) { width: auto; }
  & .drop + .ln, & .drop + .ln + .ln { margin-left: 17%; }
  & .ln:nth-child(9) { margin-left: 8%; }
}
.p-compact {
  padding-top: 13%;
  gap: 3.5px;
  & .head { position: absolute; top: 4%; left: 8%; right: 8%; height: 4px; border-bottom: 1px solid #D0D5DB; }
  & .ln { height: 2px; }
  & .foot { text-align: right; padding-right: 8%; font-size: 5cqi; }
}

.export-then {
  max-width: 760px;
  margin: 64px auto 48px;
  text-align: center;
  font-size: 18px;
  color: var(--muted);
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* The pages are dealt out one after another. */
    .presets li {
      animation: deal linear both;
      animation-timeline: view();
      animation-range: entry calc(5% + var(--i) * 6%) cover calc(25% + var(--i) * 3%);
    }
  }
}
@keyframes deal {
  from { opacity: 0; translate: 0 60px; rotate: -4deg; }
  to { opacity: 1; translate: 0 0; rotate: 0deg; }
}
