/* Pythonator website. Colours are taken from the application icon (a navy and chartreuse cobra); the type is a
   serif for reading, a grotesque for headings and a monospace for code. Sizes follow a 1.2 ratio from 17px. */

:root {
  /* palette, from the icon */
  --navy-900: #06172a;
  --navy-800: #0a2238;
  --navy-700: #003050;
  --blue-600: #106080;
  --blue-500: #207090;
  --blue-300: #8dbfd3;
  --lime-400: #c0d070;
  --lime-300: #d4e28c;
  --olive-600: #6f7d3c;
  --olive-500: #809050;
  --tongue: #b03a2e;

  /* light theme */
  --bg: #f4f1e8;
  --bg-raised: #fbf9f3;
  --bg-sunk: #ebe6d8;
  --ink: #142230;
  --ink-soft: #46535e;
  --ink-faint: #75808a;
  --rule: #d8d1bf;
  --link: #0d5876;
  --link-hover: #003050;
  --mark: #c0d070;
  --mark-soft: rgba(192, 208, 112, 0.32);
  --heading: #003050;
  --code-bg: #ece7d9;
  --code-ink: #23313d;
  --pre-bg: #0a2238;
  --pre-ink: #dbe4dd;
  --shadow: 0 1px 0 rgba(20, 34, 48, 0.05), 0 12px 32px -18px rgba(6, 23, 42, 0.35);

  /* type */
  --font-text: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-head: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  --font-code: "IBM Plex Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --step--1: 0.833rem;
  --step-0: 1rem;
  --step-1: 1.2rem;
  --step-2: 1.44rem;
  --step-3: 1.728rem;
  --step-4: 2.074rem;
  --step-5: 2.488rem;
  --measure: 68ch;
  --radius: 3px;
  --top: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #06172a;
    --bg-raised: #0a2238;
    --bg-sunk: #041120;
    --ink: #dfe5dc;
    --ink-soft: #a9b6b8;
    --ink-faint: #7b8b93;
    --rule: #1d3a52;
    --link: #a9d0e0;
    --link-hover: #d4e28c;
    --mark: #c0d070;
    --mark-soft: rgba(192, 208, 112, 0.18);
    --heading: #e8eddc;
    --code-bg: #0e2a42;
    --code-ink: #d9e3d6;
    --pre-bg: #031020;
    --pre-ink: #dbe4dd;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 36px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #06172a;
  --bg-raised: #0a2238;
  --bg-sunk: #041120;
  --ink: #dfe5dc;
  --ink-soft: #a9b6b8;
  --ink-faint: #7b8b93;
  --rule: #1d3a52;
  --link: #a9d0e0;
  --link-hover: #d4e28c;
  --mark: #c0d070;
  --mark-soft: rgba(192, 208, 112, 0.18);
  --heading: #e8eddc;
  --code-bg: #0e2a42;
  --code-ink: #d9e3d6;
  --pre-bg: #031020;
  --pre-ink: #dbe4dd;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 36px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

/* -- base ---------------------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--step-0)/1.62 var(--font-text);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--link-hover); text-decoration-color: var(--mark); text-decoration-thickness: 2px; }
code, kbd, pre { font-family: var(--font-code); font-size: 0.86em; }
kbd {
  display: inline-block; padding: 0 0.4em; border: 1px solid var(--rule); border-bottom-width: 2px;
  border-radius: var(--radius); background: var(--bg-raised); font-size: 0.8em; line-height: 1.6;
}
::selection { background: var(--mark); color: var(--navy-900); }
:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; }
.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }

/* -- buttons ------------------------------------------------------------------------------------------- */

.button {
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.55em 1.05em; border: 1px solid var(--navy-700); border-radius: var(--radius);
  background: var(--navy-700); color: #f4f1e8;
  font: 600 var(--step--1)/1.2 var(--font-head); letter-spacing: 0.01em; text-decoration: none;
}
.button:hover { background: var(--blue-600); border-color: var(--blue-600); color: #fff; text-decoration: none; }
.button.small { padding: 0.42em 0.85em; }
.button.big { font-size: var(--step-0); padding: 0.7em 1.25em; }
.button.ghost { background: transparent; color: var(--heading); border-color: var(--rule); }
.button.ghost:hover { border-color: var(--mark); background: var(--mark-soft); color: var(--heading); }
:root[data-theme="dark"] .button:not(.ghost) { background: var(--lime-400); border-color: var(--lime-400); color: var(--navy-900); }
:root[data-theme="dark"] .button:not(.ghost):hover { background: var(--lime-300); border-color: var(--lime-300); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .button:not(.ghost) { background: var(--lime-400); border-color: var(--lime-400); color: var(--navy-900); }
  :root:not([data-theme="light"]) .button:not(.ghost):hover { background: var(--lime-300); border-color: var(--lime-300); }
}

/* -- top bar ------------------------------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: saturate(140%) blur(8px);
}
.topbar-inner { height: 100%; display: flex; align-items: center; gap: 24px; width: min(1400px, 100% - 32px); margin-inline: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--heading); text-decoration: none; font: 700 var(--step-1)/1 var(--font-head); letter-spacing: -0.01em; }
.brand:hover { color: var(--heading); text-decoration: none; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topnav > a:not(.button) {
  padding: 6px 10px; color: var(--ink-soft); text-decoration: none;
  font: 500 var(--step--1)/1 var(--font-head); border-bottom: 2px solid transparent;
}
.topnav > a:not(.button):hover, .topnav > a[aria-current="page"] { color: var(--heading); border-bottom-color: var(--mark); }
.topnav .gh { display: inline-flex; align-items: center; gap: 6px; }
.topnav .button { margin-left: 8px; }
.theme-toggle {
  display: inline-grid; place-items: center; width: 34px; height: 34px; margin-left: 4px;
  border: 1px solid var(--rule); border-radius: var(--radius); background: transparent; color: var(--ink-soft); cursor: pointer;
}
.theme-toggle:hover { color: var(--heading); border-color: var(--mark); }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

/* -- landing page -------------------------------------------------------------------------------------- */

.intro { padding: 72px 0 40px; border-bottom: 1px solid var(--rule); }
.intro-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px; align-items: center; }
.kicker {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 22px;
  font: 600 var(--step--1)/1 var(--font-head); letter-spacing: 0.08em; text-transform: uppercase; color: var(--olive-500);
}
.kicker img { width: 22px; height: 22px; }
.intro h1 {
  margin: 0 0 22px; color: var(--heading);
  font: 700 clamp(2.1rem, 4.4vw, 3.3rem)/1.06 var(--font-head); letter-spacing: -0.025em;
}
.intro h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--mark-soft) 62%); }
.intro .lead { margin: 0 0 30px; max-width: 52ch; font-size: var(--step-1); line-height: 1.55; color: var(--ink-soft); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.facts { margin: 26px 0 0; font: 500 var(--step--1)/1.5 var(--font-head); color: var(--ink-faint); }
.facts code { font-size: 0.95em; color: var(--ink-soft); }
.frame { margin: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg-raised); box-shadow: var(--shadow); overflow: hidden; }
.frame img { width: 100%; }
.frame figcaption { padding: 10px 14px; border-top: 1px solid var(--rule); font-size: var(--step--1); color: var(--ink-faint); }

.runtimes { padding: 18px 0; border-bottom: 1px solid var(--rule); }
.runtimes ul { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; padding: 0; list-style: none; font: 500 var(--step--1)/1.6 var(--font-head); color: var(--ink-soft); }
.runtimes li::before { content: "▸ "; color: var(--olive-500); }

.section { padding: 72px 0; border-bottom: 1px solid var(--rule); }
.section-head { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; margin-bottom: 36px; }
.num { font: 600 var(--step--1)/1.4 var(--font-head); letter-spacing: 0.08em; text-transform: uppercase; color: var(--olive-500); }
.num.label { margin: 0 0 12px; }
.section-head h2 { margin: 0 0 10px; font: 700 var(--step-4)/1.12 var(--font-head); letter-spacing: -0.02em; color: var(--heading); }
.section-head p { margin: 0; max-width: var(--measure); color: var(--ink-soft); }

.spec { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.spec > div { padding: 22px 22px 24px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.spec h3 { margin: 0 0 8px; font: 600 var(--step-1)/1.25 var(--font-head); color: var(--heading); }
.spec p { margin: 0 0 10px; font-size: 0.95rem; color: var(--ink-soft); }
.spec a { font: 500 var(--step--1)/1 var(--font-head); }

.os-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.os-table th, .os-table td { padding: 14px 16px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.os-table th { font: 600 var(--step--1)/1.3 var(--font-head); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint); }
.os-table td:first-child { font: 600 var(--step-0)/1.4 var(--font-head); color: var(--heading); white-space: nowrap; }

.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: start; }
.pair.wide-right { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
.pair h3 { margin: 0 0 10px; font: 600 var(--step-2)/1.2 var(--font-head); color: var(--heading); }
.pair p, .pair li { color: var(--ink-soft); }
.pair ul { padding-left: 1.1em; }
.pair li { margin: 0.3em 0; }
.pair li::marker { color: var(--olive-500); }

.terminal {
  margin: 0; padding: 18px 20px; border-radius: var(--radius); background: var(--pre-bg); color: var(--pre-ink);
  font: 400 0.9rem/1.7 var(--font-code); overflow-x: auto;
}
.terminal .prompt { color: var(--lime-400); user-select: none; }

/* -- documentation ------------------------------------------------------------------------------------- */

.docs-shell {
  display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; gap: 48px;
  width: min(1400px, 100% - 32px); margin-inline: auto;
}
.sidebar, .toc { position: sticky; top: var(--top); align-self: start; max-height: calc(100vh - var(--top)); overflow-y: auto; padding: 32px 0 40px; }
.sidebar-toggle { display: none; }
.nav-group { margin-bottom: 22px; }
.nav-title { margin: 0 0 8px; font: 600 0.72rem/1.2 var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; color: var(--olive-500); }
.sidebar nav a {
  display: block; padding: 5px 10px; margin-left: -10px; border-left: 2px solid transparent;
  font: 500 0.9rem/1.35 var(--font-head); color: var(--ink-soft); text-decoration: none;
}
.sidebar nav a:hover { color: var(--heading); border-left-color: var(--rule); }
.sidebar nav a[aria-current="page"] { color: var(--heading); border-left-color: var(--mark); background: var(--mark-soft); }
.toc nav a { display: block; padding: 3px 0; font: 400 0.82rem/1.4 var(--font-head); color: var(--ink-faint); text-decoration: none; }
.toc nav a.sub { padding-left: 12px; }
.toc nav a:hover { color: var(--heading); }
.toc nav a.active { color: var(--heading); font-weight: 600; }
.toc:has(nav:empty) { visibility: hidden; }
.content { min-width: 0; padding: 36px 0 72px; }
.page-meta { max-width: var(--measure); margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--rule); font: 500 var(--step--1)/1 var(--font-head); }
.page-meta a { color: var(--ink-faint); text-decoration: none; }
.page-meta a:hover { color: var(--heading); }

.prose { max-width: 78ch; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-head); color: var(--heading); letter-spacing: -0.015em; }
.prose h1 { margin: 0 0 18px; font-size: var(--step-5); line-height: 1.08; font-weight: 700; }
.prose h2 { margin: 2.4em 0 0.6em; padding-top: 0.6em; border-top: 1px solid var(--rule); font-size: var(--step-3); line-height: 1.2; font-weight: 700; }
.prose h3 { margin: 1.9em 0 0.5em; font-size: var(--step-1); line-height: 1.3; font-weight: 600; }
.prose h4 { margin: 1.6em 0 0.4em; font-size: var(--step-0); font-weight: 600; }
.prose h1 + p { font-size: var(--step-1); line-height: 1.55; color: var(--ink-soft); }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; max-width: var(--measure); }
.prose li { margin: 0.28em 0; }
.prose li::marker { color: var(--olive-500); }
.prose li > ul, .prose li > ol { margin: 0.3em 0; }
.prose strong { font-weight: 600; color: var(--heading); }
.prose .anchor { margin-left: 0.4em; color: var(--ink-faint); text-decoration: none; opacity: 0; font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus { opacity: 1; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.prose img { border: 1px solid var(--rule); border-radius: var(--radius); }
.prose p[align="center"] { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: none; }
.prose p[align="center"] img { display: inline-block; }
.prose blockquote { margin: 0 0 1em; padding: 0.2em 0 0.2em 1em; border-left: 3px solid var(--mark); color: var(--ink-soft); }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose :not(pre) > code { padding: 0.08em 0.32em; border-radius: var(--radius); background: var(--code-bg); color: var(--code-ink); overflow-wrap: anywhere; }
.prose pre { position: relative; margin: 0 0 1.2em; padding: 16px 18px; border-radius: var(--radius); background: var(--pre-bg); color: var(--pre-ink); overflow-x: auto; line-height: 1.6; }
.prose pre code { font-size: 0.84rem; background: none; padding: 0; color: inherit; }
.copy {
  position: absolute; top: 8px; right: 8px; padding: 3px 9px; border: 1px solid rgba(219, 228, 221, 0.25);
  border-radius: var(--radius); background: var(--navy-800); color: var(--pre-ink);
  font: 500 0.72rem/1.4 var(--font-head); cursor: pointer; opacity: 0;
}
.prose pre:hover .copy, .copy:focus { opacity: 1; }
.copy:hover { border-color: var(--lime-400); color: var(--lime-300); }
.prose table { display: block; width: max-content; max-width: 100%; overflow-x: auto; margin: 0 0 1.4em; border-collapse: collapse; font-size: 0.92rem; line-height: 1.5; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose th { font: 600 0.78rem/1.3 var(--font-head); letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); border-bottom: 2px solid var(--rule); }
.prose tbody tr:hover td { background: var(--mark-soft); }

/* code colours, the same in both themes because code blocks are always dark */
.tok-k { color: #d4e28c; }
.tok-s { color: #a9d0e0; }
.tok-c { color: #7f9398; font-style: italic; }
.tok-n { color: #e7b07a; }
.tok-f { color: #f2efe3; }
.tok-p { color: #c79bd8; }

/* -- footer -------------------------------------------------------------------------------------------- */

.footer { border-top: 1px solid var(--rule); background: var(--bg-sunk); }
.footer-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px;
  width: min(1400px, 100% - 32px); margin-inline: auto; padding: 28px 0;
  font-size: var(--step--1); color: var(--ink-faint);
}
.footer strong { font-family: var(--font-head); color: var(--heading); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--font-head); }
.footer-links a { color: var(--ink-soft); text-decoration: none; }
.footer-links a:hover { color: var(--heading); }

/* -- narrower screens ---------------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: 230px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 960px) {
  .intro-grid, .pair, .pair.wide-right { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .section-head { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .spec { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { position: static; max-height: none; padding: 16px 0 0; overflow: visible; }
  .sidebar-toggle {
    display: flex; width: 100%; justify-content: space-between; align-items: center; padding: 10px 12px;
    border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg-raised); color: var(--heading);
    font: 600 var(--step--1)/1 var(--font-head); cursor: pointer;
  }
  .sidebar nav { display: none; padding: 16px 4px 4px 14px; }
  .sidebar.open nav { display: block; }
  .topnav > a:not(.button):not([aria-current]) { display: none; }
  .topnav .gh span { display: none; }
}
@media (max-width: 600px) {
  .spec { grid-template-columns: minmax(0, 1fr); }
  .intro { padding-top: 44px; }
  .section { padding: 52px 0; }
  .topnav > a[aria-current] { display: none; }
  .os-table td:first-child { white-space: normal; }
  .os-table th, .os-table td { padding: 12px 8px; overflow-wrap: anywhere; }
  .os-table { table-layout: fixed; }
  .prose h1 { font-size: var(--step-4); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
