/*
  Octod website styles.

  Colors come from the Tokyo Night theme: Day in light mode, Night in dark mode.
  Type is JetBrains Mono for headings, buttons, and code, and IBM Plex Sans for
  reading text. Both are under the SIL Open Font License and served from /fonts.

  The token blocks below are read by scripts/check-contrast.mjs. Keep one token
  per line, and keep the two dark blocks identical.
*/

/* ---------- Fonts ---------- */

/* One file covers every weight of JetBrains Mono. */
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/ibm-plex-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/ibm-plex-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */

/* Light mode: Tokyo Night Day. Reading text is the dark slate from Tokyo Night
   Light, because Day's own text color only just reaches 4.5:1 on its background. */
:root {
  color-scheme: light;
  --bg: #e1e2e7;
  --surface: #d0d5e3;
  --hairline: #a8aecb;
  --text: #343b58;
  --muted: #414868;
  --link: #3760bf;
  --focus: #7847bd;
  --selection: #b7c1e3;
  --node: #343b58;
  --node-fill: #d0d5e3;
  --accepted: #587539;
  --proposed: #8c6c3e;
  --code-bg: #1a1b26;
  --code-bar: #16161e;
  --show-sun: none;
  --show-moon: block;
}

/* Dark mode: Tokyo Night. This block applies when the visitor's system asks for dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1b26;
    --surface: #16161e;
    --hairline: #3b4261;
    --text: #c0caf5;
    --muted: #a9b1d6;
    --link: #7aa2f7;
    --focus: #bb9af7;
    --selection: #283457;
    --node: #a9b1d6;
    --node-fill: #16161e;
    --accepted: #9ece6a;
    --proposed: #e0af68;
    --code-bg: #16161e;
    --code-bar: #0c0e14;
    --show-sun: block;
    --show-moon: none;
  }
}

/* Dark mode again, for when the visitor picks it with the switch. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1b26;
  --surface: #16161e;
  --hairline: #3b4261;
  --text: #c0caf5;
  --muted: #a9b1d6;
  --link: #7aa2f7;
  --focus: #bb9af7;
  --selection: #283457;
  --node: #a9b1d6;
  --node-fill: #16161e;
  --accepted: #9ece6a;
  --proposed: #e0af68;
  --code-bg: #16161e;
  --code-bar: #0c0e14;
  --show-sun: block;
  --show-moon: none;
}

/* The same in both modes. Oaty (the octopus) and the main button keep their colors, and
   code panels are always Tokyo Night. */
:root {
  --octo: #ff9e64;
  --octo-line: #c53b53;
  --octo-eye: #ffffff;
  --octo-ink: #16161e;
  --code-line: #292e42;
  --code-text: #c0caf5;
  --code-comment: #a9b1d6;
  --code-keyword: #bb9af7;
  --code-type: #2ac3de;
  --code-string: #9ece6a;
  --code-number: #ff9e64;
  --code-key: #7aa2f7;
  --code-option: #7dcfff;

  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-display: var(--font-mono);
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 40rem;
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[id] {
  scroll-margin-top: 5.5rem;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

/* Headings are monospace, which runs wide and leaves a full character between
   words. They are set tight, with the words pulled closer together. */
h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.035em;
  word-spacing: -0.18em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.125rem, 1.25rem + 3.6vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.05em;
}

h2 {
  font-size: clamp(1.5rem, 1.25rem + 1.1vw, 2rem);
}

h3 {
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

/* Lists start with no spacing of their own. :where() keeps this rule from
   outranking the spacing rules further down. */
:where(ul, ol, dl) {
  margin: 0;
  padding: 0;
}

a {
  color: var(--link);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

strong {
  font-weight: 600;
}

code,
pre {
  font-family: var(--font-mono);
}

/* Inline identifiers such as a column name. */
:not(pre) > code {
  padding: 0.08em 0.35em;
  border-radius: 0.3em;
  background: var(--surface);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

.wrap {
  width: min(100% - 2 * var(--gutter), 72rem);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  background: var(--text);
  color: var(--bg);
}

.skip-link:focus {
  top: 0.75rem;
}

/* ---------- Oaty and the wordmark ---------- */

/* Holds the shared drawings. It takes no space on the page. */
.sprite {
  position: absolute;
  overflow: hidden;
}

.o-skin {
  fill: var(--octo);
  stroke: var(--octo-line);
}

.o-eye {
  fill: var(--octo-eye);
  stroke: var(--octo-line);
}

.o-ink {
  fill: var(--octo-ink);
}

.o-tooth {
  fill: var(--octo-eye);
  stroke: var(--octo-ink);
}

.o-mouth {
  fill: none;
  stroke: var(--octo-ink);
}

.wordmark-lines {
  fill: none;
  stroke: currentColor;
}

/* ---------- Button ---------- */

/* The main button wears Oaty's colors in both modes. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.6rem 1.4rem;
  border: 2px solid var(--octo-line);
  border-radius: 999px;
  background: var(--octo);
  color: var(--octo-ink);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  word-spacing: -0.18em;
  line-height: 1.2;
  text-decoration: none;
}

.button:hover {
  filter: brightness(1.07);
}

.button:active {
  transform: translateY(1px);
}

.button-small {
  min-height: 2.5rem;
  padding: 0.35rem 1rem;
  font-size: 0.875rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
}

.site-header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-right: auto;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 2.6rem;
  height: 2.6rem;
}

.brand-word {
  display: block;
  width: 5.5rem;
  height: auto;
}

.site-nav {
  display: none;
  gap: 1.6rem;
}

.site-nav a {
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav a:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
}

.site-header .button {
  display: none;
}

@media (min-width: 40rem) {
  .site-header .button {
    display: inline-flex;
  }
}

@media (min-width: 66rem) {
  .site-nav {
    display: flex;
    margin-right: 0.75rem;
  }
}

/* The light and dark switch needs JavaScript, so it only shows when scripts run. */
.theme-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.js .theme-toggle {
  display: inline-flex;
}

.theme-toggle:hover {
  background: var(--surface);
}

.theme-toggle svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun {
  display: var(--show-sun);
}

.theme-toggle .icon-moon {
  display: var(--show-moon);
}

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

.hero {
  padding-block: clamp(2.75rem, 6vw, 5.5rem) clamp(3.5rem, 7vw, 6rem);
}

/* minmax(0, 1fr) lets a column shrink below its widest child, so a long code
   line or a wide table scrolls inside its own box and never widens the page. */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3.5rem;
  align-items: center;
}

@media (min-width: 64rem) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 4rem;
  }
}

.hero-lede {
  max-width: 34rem;
  margin-top: 1.5rem;
  font-size: 1.25rem;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 2rem;
}

.hero-actions a:not(.button) {
  font-weight: 500;
}

.hero-hint {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.hero-status {
  max-width: 34rem;
  margin-top: 2.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
}

/* ---------- The map in the hero ---------- */

.map {
  margin: 0;
}

.map svg {
  display: block;
  width: 100%;
  max-width: 33rem;
  height: auto;
  margin-inline: auto;
  overflow: visible;
}

.map-arm-under {
  fill: none;
  stroke: var(--octo-line);
}

.map-arm-over {
  fill: none;
  stroke: var(--octo);
}

.map-plug {
  fill: var(--octo);
  stroke: var(--octo-line);
}

.map-db {
  fill: var(--node-fill);
  stroke: var(--node);
}

.map-db-name {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  text-anchor: middle;
}

.map-link {
  fill: none;
}

.map-link-accepted {
  stroke: var(--accepted);
}

.map-link-proposed {
  stroke: var(--proposed);
}

.map-badge-accepted {
  fill: var(--accepted);
}

.map-badge-proposed {
  fill: var(--proposed);
}

.map-badge-mark {
  fill: none;
  stroke: var(--bg);
}

.map-badge-dot {
  fill: var(--bg);
}

.map-callout {
  max-width: 33rem;
  margin: 1.25rem auto 0;
  padding: 0.9rem 1.1rem 1rem;
  border: 2px dashed var(--proposed);
  border-radius: 0.75rem;
}

.map-callout-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  word-spacing: -0.18em;
}

.map-callout p + p {
  margin-top: 0.3rem;
}

.map figcaption {
  max-width: 33rem;
  margin: 0.9rem auto 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* One sequence on load: the arms reach the databases, then the links appear.
   The hidden starting state lives only in the keyframes ("backwards" holds it
   during each delay), so if animations never run, everything is simply visible. */
@media (prefers-reduced-motion: no-preference) {
  .map .draw {
    stroke-dasharray: 1;
    animation: map-draw 0.65s cubic-bezier(0.6, 0, 0.2, 1) backwards;
  }

  .map .fade {
    animation: map-fade 0.4s ease-out backwards;
  }

  .map .t1 { animation-delay: 0.2s; }
  .map .t2 { animation-delay: 0.35s; }
  .map .t3 { animation-delay: 0.85s; }
  .map .t4 { animation-delay: 1s; }
  .map .t5 { animation-delay: 1.5s; }
  .map .t6 { animation-delay: 1.7s; }
  .map .t7 { animation-delay: 1.9s; }

  @keyframes map-draw {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
  }

  @keyframes map-fade {
    from { opacity: 0; }
  }

  html {
    scroll-behavior: smooth;
  }
}

/* ---------- Sections ---------- */

.section {
  padding-block: clamp(3.5rem, 7vw, 5.5rem);
  border-top: 1px solid var(--hairline);
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem 3rem;
}

@media (min-width: 62rem) {
  .section-grid {
    grid-template-columns: minmax(0, 17rem) minmax(0, 1fr);
  }
}

.section-body > * + * {
  margin-top: 1.5rem;
}

.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: 1rem;
}

.lead {
  font-size: 1.1875rem;
  line-height: 1.5;
}

/* A plain list with one of Oaty's sucker dots as its marker. */
.dots {
  max-width: var(--measure);
  list-style: none;
}

.dots li {
  position: relative;
  padding-left: 1.9rem;
}

.dots li + li {
  margin-top: 0.7rem;
}

.dots li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.47em;
  width: 0.72rem;
  height: 0.72rem;
  border: 2px solid var(--octo-line);
  border-radius: 50%;
  background: var(--octo);
}

/* ---------- What you get ---------- */

.feature + .feature {
  margin-top: 4rem;
}

.feature > p {
  max-width: var(--measure);
  margin-top: 0.7rem;
}

.example {
  margin: 1.5rem 0 0;
}

.example figcaption {
  max-width: var(--measure);
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--code-line);
  border-radius: 0.75rem;
  background: var(--code-bg);
  color: var(--code-text);
}

.panel-bar {
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--code-line);
  background: var(--code-bar);
  color: var(--code-comment);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.panel pre {
  margin: 0;
  padding: 1rem 1.1rem 1.15rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  tab-size: 2;
}

.panel pre:focus-visible {
  outline-offset: -3px;
}

.tok-c { color: var(--code-comment); }
.tok-k { color: var(--code-keyword); }
.tok-t { color: var(--code-type); }
.tok-s { color: var(--code-string); }
.tok-n { color: var(--code-number); }
.tok-p { color: var(--code-key); }
.tok-o { color: var(--code-option); }

/* ---------- Term and description rows ---------- */

.rows > div {
  display: grid;
  gap: 0.2rem 2rem;
  padding-block: 1rem;
  border-top: 1px solid var(--hairline);
}

.rows > div:last-child {
  border-bottom: 1px solid var(--hairline);
}

@media (min-width: 44rem) {
  .rows > div {
    grid-template-columns: 13rem minmax(0, 1fr);
  }
}

.rows dt {
  font-weight: 600;
}

.rows dd {
  max-width: var(--measure);
  margin: 0;
}

/* ---------- Steps ---------- */

.steps {
  max-width: 44rem;
  list-style: none;
  counter-reset: step;
}

.steps li {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: 0 0.75rem;
  align-items: baseline;
  padding-block: 0.95rem;
  border-top: 1px solid var(--hairline);
  counter-increment: step;
}

.steps li:last-child {
  border-bottom: 1px solid var(--hairline);
}

.steps li::before {
  content: counter(step);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.85rem 1.5rem 0.85rem 0;
  border-top: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

thead th {
  border-top: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 1px solid var(--hairline);
}

tbody th {
  font-weight: 600;
}

.table-prices {
  min-width: 34rem;
}

.table-prices .price {
  font-family: var(--font-display);
  font-weight: 700;
}

.table-prices th:nth-child(2),
.table-prices td:nth-child(2) {
  white-space: nowrap;
}

.table-tools {
  min-width: 30rem;
}

.table-tools tbody th {
  font-weight: 400;
  white-space: nowrap;
}

/* ---------- Questions ---------- */

.faq {
  max-width: 46rem;
}

.faq details {
  border-top: 1px solid var(--hairline);
}

.faq details:last-child {
  border-bottom: 1px solid var(--hairline);
}

.faq summary {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  flex: none;
  font-family: var(--font-mono);
  font-weight: 400;
}

.faq details[open] summary::after {
  content: "\2212";
}

.faq details p {
  max-width: var(--measure);
  padding-bottom: 1.25rem;
}

/* ---------- Closing and footer ---------- */

.closing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}

.site-footer {
  padding-block: 2.5rem 3rem;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 0.9375rem;
}

.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.site-footer .brand {
  margin-right: 0;
}

.site-footer p + p {
  margin-top: 0.3rem;
}

/* ---------- Not-found page ---------- */

.lost {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  padding-block: clamp(4rem, 12vw, 8rem);
  text-align: center;
}

.lost svg {
  width: 9rem;
  height: 9rem;
}

.lost p {
  max-width: 30rem;
}
