/* The home page (index.html, assets/js/home.js): the hero's entrance, the findings numbers with their small charts, the
   benchmark summary as live charts, and the hover polish of the cards. The design tokens come from main.css; the
   colours of the methods are those of the paper's benchmark figures (graphics/py/benchmark_bars.py). */

:root {
  --home-daedalus: #6aa8ea;
  --home-gaot: #f08c4e;
  --home-rigno: #5cc28a;
  --home-oom: #ff6b6b;
  --home-limit: rgba(255, 107, 107, 0.55);
  --home-glow: rgba(52, 211, 153, 0.13);
  --home-mark: rgba(52, 211, 153, 0.22);
}
:root[data-theme="light"] {
  --home-daedalus: #2f6fb8;
  --home-gaot: #d9621c;
  --home-rigno: #2e8b4a;
  --home-oom: #c92a2a;
  --home-limit: rgba(201, 42, 42, 0.5);
  --home-glow: rgba(5, 150, 105, 0.09);
  --home-mark: rgba(5, 150, 105, 0.16);
}

/* the hero's entrance: its lines rise in one after another, the title's gradient drifts */
@keyframes home-rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
.hero-intro > * { animation: home-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.hero-intro > :nth-child(1) { animation-delay: 0.05s; }
.hero-intro > :nth-child(2) { animation-delay: 0.15s; }
.hero-intro > :nth-child(3) { animation-delay: 0.32s; }
.hero-intro > :nth-child(4) { animation-delay: 0.4s; }
.hero-intro > :nth-child(5) { animation-delay: 0.5s; }
.hero-intro > :nth-child(6) { animation-delay: 0.62s; }
.hero-visual { animation: home-rise 1.1s 0.2s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.hero-caption { transition: opacity 0.4s; }
@keyframes home-drift { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
.hero h1 .gradient-text {
  background-image: linear-gradient(110deg, #bbf7d0 0%, #34d399 25%, #22d3ee 50%, #34d399 75%, #bbf7d0 100%);
  background-size: 200% 100%; animation: home-drift 9s ease-in-out infinite alternate;
}
:root[data-theme="light"] .hero h1 .gradient-text {
  background-image: linear-gradient(110deg, #059669 0%, #0d9488 25%, #0891b2 50%, #0d9488 75%, #059669 100%);
}
.logos img { transition: transform 0.25s, filter 0.25s; }
.logos img:hover { transform: translateY(-2px) scale(1.04); }

/* the TL;DR's key phrases are marked by a highlighter stroke once it shows */
.tldr b {
  background-image: linear-gradient(transparent 62%, var(--home-mark) 62%, var(--home-mark) 92%, transparent 92%);
  background-repeat: no-repeat; background-size: 0% 100%; transition: background-size 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.tldr b:first-child { background-image: none; }
.tldr.lit b { background-size: 100% 100%; }
.tldr.lit b:nth-of-type(2) { transition-delay: 0.25s; }
.tldr.lit b:nth-of-type(3) { transition-delay: 0.6s; }

/* the number cards: a soft light follows the pointer, and each carries a small chart of its number */
.home-stats .stat { position: relative; overflow: hidden; display: flex; flex-direction: column; transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s; }
.home-stats .stat::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), var(--home-glow), transparent 70%);
}
.home-stats .stat:hover { transform: translateY(-3px); border-color: rgba(var(--accent-rgb), 0.45); box-shadow: 0 18px 40px -28px rgba(var(--accent-rgb), 0.6); }
.home-stats .stat:hover::before { opacity: 1; }
.home-stats .stat .label { flex: 1; }
.stat-viz { margin-top: 16px; }
@media (max-width: 560px) { .home-stats { grid-template-columns: minmax(0, 1fr); } }

.pips { display: grid; gap: 6px; }
.pips .row { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; color: var(--muted); }
.pips .row b { width: 54px; flex: none; font-weight: 600; color: var(--text-soft); }
.pips .marks { display: flex; flex-wrap: wrap; gap: 3px; }
.pips .marks i {
  width: 7px; height: 7px; border-radius: 2px; background: rgba(var(--ink-rgb), 0.14);
  transform: scale(0.3); opacity: 0; transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.35s, background 0.35s;
  transition-delay: calc(var(--k) * 28ms);
}
.pips.on .marks i { transform: none; opacity: 1; }
.pips.on .marks i.win { background: var(--accent); }

.ratio { display: grid; gap: 5px; }
.ratio .row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 38px; align-items: center; gap: 8px; font-size: 0.72rem; color: var(--muted); }
.ratio .row b { font-weight: 600; color: var(--text-soft); }
.ratio .bar { height: 7px; border-radius: 4px; background: rgba(var(--ink-rgb), 0.07); overflow: hidden; }
.ratio .bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--c); transition: width 1s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: var(--d, 0s); }
.ratio.on .bar i { width: var(--w); }
.ratio .row span:last-child { text-align: right; font-family: var(--mono); color: var(--text); }

.stat-viz.synth { display: block; width: 100%; height: 46px; }


/* the benchmark summary as live charts */
.home-bench { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
@media (max-width: 960px) { .home-bench { grid-template-columns: 1fr; } }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin-bottom: 10px; }
.chart-title { font-weight: 700; color: var(--text); font-size: 0.98rem; }
.chart-title small { color: var(--muted); font-weight: 500; font-size: 0.78rem; margin-left: 4px; }
.chart-head .segmented { width: auto; }
.chart-head .segmented button { white-space: nowrap; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; cursor: default; transition: opacity 0.2s; }
.chart-legend span.dim { opacity: 0.35; }
.chart-legend svg { width: 26px; height: 12px; flex: none; overflow: visible; }
.chart-legend .swatch { width: 12px; height: 10px; border-radius: 3px; flex: none; }
.chart-box { position: relative; }
.home-chart { display: block; width: 100%; touch-action: pan-y; }
.home-chart.perf { aspect-ratio: 1 / 0.74; }
.home-chart.acc { aspect-ratio: 1 / 0.7; }
@media (max-width: 960px) { .home-chart.perf { aspect-ratio: 1 / 0.8; } .home-chart.acc { aspect-ratio: 1 / 0.95; } }
@media (max-width: 520px) { .home-chart.perf { aspect-ratio: 1 / 1.05; } .home-chart.acc { aspect-ratio: 1 / 1.35; } }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2; min-width: 120px; max-width: 290px; padding: 8px 10px; border-radius: 10px;
  background: var(--menu-bg); border: 1px solid var(--border-strong); box-shadow: 0 12px 30px -16px var(--shadow);
  font-size: 0.76rem; color: var(--text); line-height: 1.45; backdrop-filter: blur(6px);
}
.chart-tip b { display: block; margin-bottom: 2px; }
.chart-tip .r { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.chart-tip .r i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.chart-tip .r span:last-child { margin-left: auto; padding-left: 10px; font-family: var(--mono); }

/* the gallery: cards rise in when the set changes, and the error flashes when the partitions change */
@keyframes home-card-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.gallery-card.enter { animation: home-card-in 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--k, 0) * 70ms); }
@keyframes home-flash { 0% { color: var(--strong); text-shadow: 0 0 12px rgba(var(--cyan-rgb), 0.9); transform: scale(1.12); } 100% { transform: none; } }
.gallery-card .metric { display: inline-block; transform-origin: right center; }
.gallery-card .metric.flash { animation: home-flash 0.7s ease-out; }
.gallery-card { transition: transform 0.25s, border-color 0.25s; }
.gallery-card:hover { transform: translateY(-3px); border-color: rgba(var(--accent-rgb), 0.4); }

/* the journey's caption cross-fades between stages; the tabs lift on hover */
@keyframes home-caption { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stage-caption.swap { animation: home-caption 0.5s ease both; }
.stage-tab { transition: transform 0.2s, border-color 0.2s; }
.stage-tab:hover { transform: translateY(-2px); }

/* the explorer's thumbnails and the findings */
.ex-thumbs canvas { transition: border-color 0.2s, transform 0.2s; }
.ex-thumbs canvas:hover { transform: scale(1.05); }
.finding { transition: transform 0.25s, border-color 0.25s; }
.finding:hover { transform: translateY(-3px); border-color: rgba(var(--accent-rgb), 0.4); }
.finding .icon { transition: box-shadow 0.3s; }
.finding:hover .icon { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12); }

/* the demo cards: the picture zooms a little and a light follows the pointer */
.demo-card .thumb { transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.demo-card:hover .thumb { transform: scale(1.05); }
.demo-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s; z-index: 1;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%), var(--home-glow), transparent 70%);
}
.demo-card:hover::before { opacity: 1; }
.demo-card .go { transition: transform 0.25s; }
.demo-card:hover .go { transform: translateX(4px); }

/* the final state at once: ?static and reduced motion */
.static .hero-intro > *, .static .hero-visual, .static .hero h1 .gradient-text, .static .gallery-card.enter, .static .stage-caption.swap { animation: none; }
.static .tldr b, .static .pips .marks i, .static .ratio .bar i { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .hero-intro > *, .hero-visual, .hero h1 .gradient-text, .gallery-card.enter, .gallery-card .metric.flash, .stage-caption.swap { animation: none; }
  .tldr b, .pips .marks i, .ratio .bar i { transition: none; }
  .home-stats .stat:hover, .finding:hover, .demo-card:hover .thumb, .gallery-card:hover { transform: none; }
}

/* the hero's visual: the square stage of the animation, then the field switch (the radial-sine field or Daedalus's
   face), then the caption, all in the flow so that they never overlap; the canvas overhangs the stage by 7% on every
   side (less than the grid's gap), which leaves room for the glows of the disk and the lenses (hero.js lays the drawing
   out in the stage) */
.hero-visual { aspect-ratio: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hero-stage { position: relative; width: 100%; aspect-ratio: 1; }
.hero-visual .hero-stage canvas { position: absolute; left: -7%; top: -7%; width: 114%; height: 114%; }
.hero-switch { display: flex; width: max-content; position: relative; z-index: 1; }
.hero-visual .hero-caption {
  position: relative; z-index: 1; bottom: auto; left: auto; transform: none; white-space: normal; text-align: center; max-width: 100%;
}

/* the authors on one line on a wide screen; a name never breaks inside */
.authors span { white-space: nowrap; }
@media (min-width: 1200px) { .authors { font-size: 0.94rem; } }
@media (max-width: 520px) { .hero-visual .hero-caption { border-radius: 16px; } }

/* the geometry switch of the performance chart: a small track with a sliding knob, off by default */
.geo-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); cursor: pointer; user-select: none; margin-left: auto; }
.geo-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.geo-switch .track { position: relative; width: 34px; height: 19px; border-radius: 999px; background: rgba(var(--ink-rgb), 0.16); border: 1px solid var(--border); transition: background 0.2s; }
.geo-switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--text); transition: transform 0.2s; }
.geo-switch input:checked + .track { background: var(--accent-deep); }
.geo-switch input:checked + .track::after { transform: translateX(15px); background: #fff; }
.geo-switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.geo-switch:has(input:checked) { color: var(--text); }

/* the headline captions above their cards, and the accuracy pair side by side */
.headlines-note.lead-note { margin: 2px 0 14px; }
.stats.acc.home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .stats.acc.home-stats { grid-template-columns: minmax(0, 1fr); } }

/* the training functions under the gallery's title, as wide as the title; its pause button keeps to the right end */
.titled-strip { display: table; margin: 0 auto; max-width: 100%; }
.titled-strip h2 { margin-bottom: 14px; }
.gallery-synth-wrap { padding-right: 40px; margin-bottom: 18px; }
.gallery-synth { display: block; width: 100%; height: 64px; }
.gallery-synth-wrap .stage-play { right: 0; bottom: 14px; width: 32px; height: 32px; }
.gallery-synth-wrap .stage-play svg { width: 13px; height: 13px; }
.hero-stage .stage-play { right: 2%; bottom: 2%; }

/* the home page's performance cards in two labelled rows, training (four cards) and inference (three cards of the
   same width): the row's name written vertically in a narrow first column */
.stats.seven.rows { grid-template-columns: 30px repeat(4, minmax(0, 1fr)); }
.stats.seven.rows > .stat:last-child { grid-column: auto; }
.stats.seven.rows .row-label { display: flex; align-items: center; justify-content: center; }
.stats.seven.rows .row-label span {
  writing-mode: vertical-rl; transform: rotate(180deg); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--perf-ink);
}
@media (max-width: 1100px) {
  .stats.seven.rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.seven.rows .row-label { grid-column: 1 / -1; justify-content: flex-start; }
  .stats.seven.rows .row-label span { writing-mode: horizontal-tb; transform: none; }
}
@media (max-width: 560px) { .stats.seven.rows { grid-template-columns: minmax(0, 1fr); } }

/* links under the accuracy card, to the interactive accuracy benchmark of the operator-learning article */
.stat-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 0.86rem; font-weight: 600; }
.stat-links a { color: var(--acc-ink); text-decoration: none; }
.stat-links a:hover { text-decoration: underline; }
/* the "See more" card in the free slot of the inference row: the site's green, linking to all performance results */
.stats.perf .stat.see-more {
  display: flex; flex-direction: column; justify-content: center; gap: 10px; text-decoration: none; color: inherit;
  background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.16), rgba(var(--accent-rgb), 0.04)); border-color: rgba(var(--accent-rgb), 0.5);
  transition: transform 0.25s, border-color 0.25s, background 0.25s;
}
.stats.perf .stat.see-more:hover { transform: translateY(-3px); border-color: var(--accent); background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.24), rgba(var(--accent-rgb), 0.06)); }
.see-more-title { font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.see-more-arrow { font-size: 1.6rem; color: var(--accent); transition: transform 0.25s; }
.stats.perf .stat.see-more:hover .see-more-arrow { transform: translateX(6px); }
/* the home page's demo cards: covers two-thirds as tall as on the other pages, cropped to their centre */
.demo-card .thumb { aspect-ratio: 1200 / 503; }
/* the home page's demo cards, compact: a short cover, a description of at most two lines with "Open" at the end of its
   last line, and the section's lead wide enough for two lines */
#demos .lead { max-width: 980px; }
.demo-card .thumb { aspect-ratio: 1200 / 430; margin-bottom: 14px; }
.demo-card .demo-foot { display: flex; align-items: flex-end; gap: 12px; }
.demo-card .demo-foot p { flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.demo-card .demo-foot .go { margin-top: 0; white-space: nowrap; }
/* on the narrowest phones "Open" goes below the description, which keeps the full width of the card */
@media (max-width: 380px) { .demo-card .demo-foot { flex-direction: column; align-items: flex-start; gap: 8px; } }

/* the articles: a list of links in two columns, each its title, an overview of one sentence and "Read" */
.article-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
@media (max-width: 760px) { .article-list { grid-template-columns: minmax(0, 1fr); } }
.article-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 16px; row-gap: 4px;
  align-items: end; color: var(--text); text-decoration: none; padding: 18px 20px; transition: transform 0.25s, border-color 0.25s; }
.article-link h3 { grid-column: 1 / -1; margin: 0; font-size: 1.05rem; }
.article-link p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.article-link .go { color: var(--accent); font-weight: 600; font-size: 0.88rem; white-space: nowrap; transition: transform 0.25s; }
.article-link:hover { transform: translateY(-3px); border-color: var(--accent); }
.article-link:hover .go { transform: translateX(4px); }
@media (prefers-reduced-motion: reduce) { .article-link, .article-link .go { transition: none; } .article-link:hover, .article-link:hover .go { transform: none; } }

/* the game cards' thumbnails: one canvas each, filling the cover (home-arcade.js), with no fade over it (the drawings are
   not photographs, and their lower part matters) */
.game-thumb { background: rgba(var(--ink-rgb), 0.03); }
.game-thumb::after { display: none; }
.game-thumb .gt-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* the static demo covers (the fallback of the animated ones below) drift slowly (a zoom and a pan, every card at its own
   phase) with a band of light sweeping over them, paused by their section's button and never with reduced motion */
#demos .demo-card .thumb { background-size: 112%; animation: cover-drift 18s ease-in-out infinite alternate; }
#demos .demo-card:nth-child(3n + 2) .thumb { animation-delay: -6s; animation-duration: 21s; }
#demos .demo-card:nth-child(3n) .thumb { animation-delay: -12s; animation-duration: 24s; }
@keyframes cover-drift {
  0% { background-size: 112%; background-position: 10% 35%; }
  50% { background-size: 124%; background-position: 70% 60%; }
  100% { background-size: 114%; background-position: 95% 40%; }
}
#demos .demo-card .thumb::before { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.16) 50%, transparent 65%);
  transform: translateX(-120%); animation: cover-glint 7s ease-in-out infinite; }
#demos .demo-card:nth-child(3n + 2) .thumb::before { animation-delay: -2.3s; }
#demos .demo-card:nth-child(3n) .thumb::before { animation-delay: -4.6s; }
@keyframes cover-glint { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
@media (prefers-reduced-motion: reduce) { #demos .demo-card .thumb, #demos .demo-card .thumb::before { animation: none; } }
/* an animated cover (home-covers.js): its canvas, frames of the backbone's outputs, fills the cover in place of the
   static image, which then neither drifts nor glints, with no fade over it (its lower part, a track, matters) */
#demos .demo-card .thumb.animated { animation: none; background-image: none !important; }
#demos .demo-card .thumb.animated::before, #demos .demo-card .thumb.animated::after { display: none; }
#demos .demo-card .thumb .cover-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
