/* Shared site foundations and components. Page-specific CSS loads after this file. */

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-400.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-700.woff2") format("woff2");
}

:root {
  --ink: #111;
  --muted: #666;
  --faint: #999;
  --rule: #ccc;
  --wash: #f4f4f4;
  --bg: #fff;
  --radius: 8px;
  --radius-control: 10px;
  --horizontal-rule-wash: linear-gradient(to right, transparent, var(--wash) 15%, var(--wash) 85%, transparent);
  --vertical-rule: linear-gradient(to bottom, transparent, var(--rule) 15%, var(--rule) 85%, transparent);
  --horizontal-rule: linear-gradient(to right, transparent, var(--rule) 15%, var(--rule) 85%, transparent);
  --horizontal-rule-active: linear-gradient(to right, transparent, var(--ink) 15%, var(--ink) 85%, transparent);
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
}

hr {
  border: none;
  height: 1px;
  background: var(--horizontal-rule);
  margin: 0 0 4rem;
}

main > section[id],
main > [data-toc],
[data-toc-sub] {
  scroll-margin-top: 5rem;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin: 0 0 1rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 2.5rem 0 0.5rem;
}

:where(.home-page > section:not(:first-of-type), .justrust-page > section:not(.hero)) p {
  margin: 0 0 1rem;
  max-width: none;
}

.section-intro {
  margin-bottom: 3rem;
}

.section-title {
  font-size: 2.25rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0 0 2.5rem;
}

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  border-image: var(--horizontal-rule) 1;
}

a:hover {
  border-bottom-color: var(--ink);
  border-image-source: var(--horizontal-rule-active);
}

.footer-brand {
  margin-top: 0.65rem;
  color: var(--muted);
}

.yc-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  color: var(--muted);
  vertical-align: middle;
}

.yc-logo {
  width: 1.1em;
  height: 1.1em;
  border-radius: 2px;
  display: block;
}

.home-page > section:first-of-type,
.hero {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.home-page > section:first-of-type h1,
.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.home-page > section:first-of-type > p:first-of-type,
.hero > p:first-of-type {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.home-page > section:first-of-type canvas,
.hero canvas {
  display: block;
  margin: 0.25rem auto 0.5rem;
}

/* Animation artwork stays unboxed, including during drag and keyboard input. */
canvas,
canvas:focus,
canvas:focus-visible {
  outline: none;
  box-shadow: none;
}

.home-page > section:first-of-type p,
.hero p {
  margin: 1.25rem 0 0;
  font-size: 0.95rem;
}

.home-page > section:first-of-type p.hero-subtagline {
  max-width: 60ch;
  margin-top: 0.75rem;
  color: var(--muted);
}

.home-page > section:first-of-type p.hero-brand,
.hero p.hero-brand {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.install-command {
  display: inline-flex;
  align-items: stretch;
  margin-top: 1.75rem;
  border: 1px solid var(--rule);
  background: var(--wash);
  max-width: 100%;
  border-radius: var(--radius-control);
  overflow: hidden;
}

.install-command pre {
  margin: 0;
  padding: 0.75rem 1.25rem;
  overflow-x: auto;
}

.install-command code {
  font-family: inherit;
  font-size: 0.9rem;
  white-space: nowrap;
}

.copy-button {
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg);
  border: none;
  border-left: 1px solid var(--rule);
  padding: 0 1rem;
  cursor: pointer;
  min-width: 5.5em;
}

.copy-button:hover {
  color: var(--ink);
}

.install-bar {
  position: fixed;
  left: 0;
  right: 0;
  top: 1rem;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transform: translateY(-200%);
  transition: transform 0.25s ease;
  will-change: transform;
  z-index: 10;
}

.install-bar.visible {
  transform: translateY(0);
}

.install-bar .install-command {
  margin-top: 0;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.install-bar pre {
  padding: 0.5rem 1rem;
}

.download-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.section-intro > p {
  margin: 0;
  max-width: none;
  font-size: 1.05rem;
  color: var(--muted);
}

/* Body copy follows the same containing column as its figures and tables. */
main > section:not(:first-of-type) p {
  max-width: none;
}

.ram-race {
  display: grid;
  gap: 1.75rem;
  margin: 1.5rem 0 1rem;
}

.ram-race-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.ram-race-mode,
.ram-race-ratio {
  font-weight: 700;
}

.ram-race-ratio {
  text-align: right;
  white-space: nowrap;
}

.ram-race-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr 6.5rem;
  align-items: center;
  gap: 0.75rem;
  margin: 0.35rem 0;
  color: var(--muted);
}

.ram-race-row.winner {
  color: var(--ink);
  font-weight: 700;
}

.ram-race-track {
  height: 14px;
  background: var(--wash);
  border-radius: 7px;
  overflow: hidden;
}

.ram-race-bar {
  display: block;
  height: 100%;
  width: var(--ram-width);
  min-width: 4px;
  background: var(--faint);
  border-radius: 7px;
}

.ram-race-row.winner .ram-race-bar {
  background: var(--ink);
}

.ram-race-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ram-race-armed .ram-race-bar {
  width: 0;
}

.ram-race-armed.ram-race-run .ram-race-bar {
  width: var(--ram-width);
  transition: width 1.4s cubic-bezier(0.33, 1, 0.68, 1);
}

footer {
  margin-top: 9rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.page-toc {
  z-index: 20;
  position: fixed;
  top: 50%;
  left: 1.5rem;
  transform: translateY(-50%);
  max-height: 80vh;
  overflow-y: auto;
  font-size: 0.72rem;
  line-height: 1.5;
  background: var(--vertical-rule) left center / 1px 100% no-repeat;
  padding-left: calc(1rem + 1px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s;
  will-change: opacity;
}

.page-toc a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.page-toc.visible {
  opacity: 1;
  visibility: visible;
}

.page-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-toc li {
  margin: 0.15rem 0;
}

.page-toc li.toc-sub {
  padding-left: 1rem;
}

.page-toc a {
  color: var(--faint);
  border-bottom: none;
  display: block;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-toc a:hover,
.page-toc a.active {
  color: var(--ink);
  border-bottom: none;
}

.home-page > section + section,
.justrust-page > section + section {
  margin-top: 9rem;
}

@media (max-width: 720px) {
  .home-page > section + section,
  .justrust-page > section + section,
  footer {
    margin-top: 6rem;
  }

  .ram-race-row {
    grid-template-columns: 7.5rem 1fr 4.5rem;
    gap: 0.5rem;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  main {
    padding: 0 1rem 4rem;
  }

  .home-page > section:first-of-type,
  .hero {
    min-height: 70vh;
  }

  .home-page > section:first-of-type h1,
  .hero h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .section-title {
    font-size: 1.75rem;
  }

  .home-page > section:first-of-type .install-command code,
  .hero .install-command code {
    font-size: 0.78rem;
  }

  .home-page > section:first-of-type .install-command pre,
  .hero .install-command pre {
    padding: 0.75rem 0.9rem;
  }

  .home-page > section:not(:first-of-type) .install-command code,
  .justrust-page > section:not(.hero) .install-command code {
    font-size: 0.82rem;
  }

  .ram-race-head {
    font-size: 0.9rem;
  }
}

.page-toc.compact {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .install-bar,
  .page-toc {
    transition-duration: 0.01ms;
  }
}
