:root {
  color-scheme: light dark;
  --background: #f5f7f5;
  --surface: #ffffff;
  --text: #182018;
  --muted: #536253;
  --green: #1eb515;
  --green-dark: #0b6510;
  --link: #0a6f10;
  --warning: #815300;
  --border: #d8e3d8;
  --code: #eef5ee;
  --stripe: #f8faf8;
  --shadow: rgba(13, 45, 13, 0.12);
  --header-background: #ffffff;
  --header-text: #182018;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --background: #0d120d;
    --surface: #151d15;
    --text: #eaf4ea;
    --muted: #a9b9a9;
    --link: #63df5a;
    --warning: #f0b94f;
    --border: #2b3b2b;
    --code: #101810;
    --stripe: #121a12;
    --shadow: rgba(0, 0, 0, 0.3);
    --header-background: #050805;
    --header-text: #d9efd9;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0d120d;
  --surface: #151d15;
  --text: #eaf4ea;
  --muted: #a9b9a9;
  --link: #63df5a;
  --warning: #f0b94f;
  --border: #2b3b2b;
  --code: #101810;
  --stripe: #121a12;
  --shadow: rgba(0, 0, 0, 0.3);
  --header-background: #050805;
  --header-text: #d9efd9;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: var(--link);
}

a:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
}

.skip-link {
  background: var(--surface);
  left: 1rem;
  padding: 0.6rem 0.8rem;
  position: fixed;
  top: -5rem;
  z-index: 100;
}

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

header {
  background: var(--header-background);
  border-bottom: 6px solid var(--green);
  padding: 1.5rem 1rem 1.25rem;
  text-align: center;
}

.brand {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.brand .logo {
  height: auto;
  image-rendering: pixelated;
  width: 56px;
}

.brand h1,
.brand-name {
  aspect-ratio: 292 / 104;
  background: url("assets/pype_wordmark.png") center / contain no-repeat;
  color: transparent;
  display: block;
  font-size: 0;
  margin: 0;
  width: clamp(160px, 24vw, 210px);
}

header p {
  color: var(--header-text);
  margin: 0.5rem auto 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.25rem;
}

.button {
  border: 2px solid #5ce752;
  border-radius: 4px;
  color: var(--header-text);
  font-weight: 700;
  padding: 0.55rem 0.85rem;
  text-decoration: none;
}

.button.primary,
.button:hover {
  background: #0b6510;
  color: #ffffff;
}

nav {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 0.55rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

nav a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

nav a:hover {
  color: var(--green);
}

nav a.current {
  color: var(--green);
}

.theme-toggle {
  background: var(--code);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  margin-left: 0;
  padding: 0.25rem 0.6rem;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: var(--link);
  color: var(--link);
}

main {
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
}

main > section + section {
  margin-top: 3.5rem;
}

main > section > h2 {
  margin-top: 0;
}

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

h1,
h2,
h3 {
  line-height: 1.25;
}

h2 {
  border-bottom: 3px solid var(--green);
  margin-top: 3rem;
  padding-bottom: 0.35rem;
}

main > h1,
.docs-content > h1 {
  margin-top: 0;
}

h1 + h2 {
  margin-top: 1.5rem;
}

.compact {
  padding-block: 0.75rem;
}

.compact .brand .logo {
  width: 48px;
}

.compact .brand h1,
.compact .brand-name {
  width: clamp(145px, 20vw, 180px);
}

.compact > p,
.compact > .actions {
  display: none;
}

.lede {
  color: var(--muted);
  font-size: 1.15rem;
}

.workflow {
  counter-reset: step;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 24px var(--shadow);
  padding: 1rem;
}

.step::before {
  background: var(--green);
  border-radius: 50%;
  color: #041004;
  content: counter(step);
  counter-increment: step;
  display: grid;
  font-weight: 900;
  height: 2rem;
  place-items: center;
  width: 2rem;
}

.docs-layout {
  align-items: start;
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr) 230px;
}

.docs-content {
  min-width: 0;
}

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  position: sticky;
  top: 5rem;
}

.toc strong {
  display: block;
  margin-bottom: 0.5rem;
}

.toc a {
  display: block;
  padding: 0.25rem 0;
  text-decoration: none;
}

.method-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 1.25rem 0;
  padding: 1.1rem;
}

.method-card h3 {
  margin-top: 0;
}

.citation {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
}

.signature {
  border-left: 5px solid var(--green);
}

.source-link {
  display: inline-block;
  margin-bottom: 0.75rem;
}

.gallery {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}

.gallery figure {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 24px var(--shadow);
  margin: 0;
  overflow: hidden;
}

.gallery img {
  background: #ffffff;
  display: block;
  height: auto;
  width: 100%;
}

.gallery figcaption {
  padding: 0.8rem 1rem 1rem;
}

.full-resolution {
  display: block;
  font-weight: 700;
  margin-top: 0.5rem;
}

.comparison {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--green);
  border-radius: 4px;
  box-shadow: 0 8px 24px var(--shadow);
  min-width: 0;
  padding: 1rem;
}

.card h3 {
  font-size: 1rem;
  margin-top: 0;
  overflow-wrap: anywhere;
}

.card > :last-child,
.step > :last-child,
.method-card > :last-child {
  margin-bottom: 0;
}

.card h3 code {
  white-space: normal;
  word-break: break-word;
}

pre,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

pre {
  background: var(--code);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
  padding: 1rem;
}

code {
  background: var(--code);
  overflow-wrap: anywhere;
  padding: 0.1rem 0.3rem;
  word-break: break-word;
}

pre code {
  background: transparent;
  overflow-wrap: normal;
  padding: 0;
  word-break: normal;
  white-space: pre;
}

table {
  border-collapse: collapse;
  display: block;
  margin: 1rem 0 2rem;
  overflow-x: auto;
  width: 100%;
}

caption {
  color: var(--muted);
  font-weight: 700;
  padding: 0 0 0.5rem;
  text-align: left;
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--code);
}

tbody tr:nth-child(even) {
  background: var(--stripe);
}

.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--green-dark);
  padding: 0.8rem 1rem;
}

.status {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
}

.status.strong {
  color: var(--link);
}

.status.partial {
  color: var(--warning, #815300);
}

.status.planned {
  color: var(--muted);
}

footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  padding: 2rem 1rem;
  text-align: center;
}

@media (max-width: 900px) {
  nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .docs-layout {
    grid-template-columns: 1fr;
  }

  .toc {
    order: -1;
    position: static;
  }
}

@media (max-width: 650px) {
  header {
    padding-top: 1.25rem;
  }

  nav {
    gap: 0.65rem 1rem;
    position: static;
  }

  main {
    padding-inline: 0.8rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    min-width: 130px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
