/* gref.sh — dark-first docs chrome */

:root,
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elevated: #111111;
  --bg-code: #171717;
  --border: #262626;
  --text: #e5e5e5;
  --text-muted: #a3a3a3;
  --text-faint: #737373;
  --accent: #a3e635;
  --accent-dim: #65a30d;
  --link: #a3e635;
  --link-hover: #bef264;
  --header-h: 3.5rem;
  --prose-width: 46rem;
  --toc-width: 14rem;
  --radius: 8px;
  --shadow: 0 0 0 1px var(--border);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-code: #f4f4f5;
  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #52525b;
  --text-faint: #71717a;
  --accent: #65a30d;
  --accent-dim: #4d7c0f;
  --link: #4d7c0f;
  --link-hover: #3f6212;
  --shadow: 0 0 0 1px var(--border);
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

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

code,
pre,
.brand-mark,
.brand-name,
.spec-version-label {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: calc(var(--prose-width) + var(--toc-width) + 6rem);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  color: var(--accent);
  font-size: 1.1rem;
}

.brand-name {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.control-label {
  display: none;
}

@media (min-width: 640px) {
  .control-label {
    display: inline;
  }
}

.version-control select {
  appearance: none;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 1.75rem 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.version-control select:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  padding: 0;
}

.icon-btn:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

[data-theme="dark"] .icon-sun {
  display: none;
}

[data-theme="light"] .icon-moon {
  display: none;
}

/* Layout */

.page {
  max-width: calc(var(--prose-width) + var(--toc-width) + 6rem);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 960px) {
  .page {
    grid-template-columns: var(--toc-width) minmax(0, 1fr);
    gap: 2.5rem;
    padding-top: 2rem;
  }
}

.toc-panel {
  display: none;
}

@media (min-width: 960px) {
  .toc-panel {
    display: block;
  }
}

.toc-sticky {
  position: sticky;
  top: calc(var(--header-h) + 1.25rem);
}

.toc-heading {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.toc {
  font-size: 0.82rem;
  line-height: 1.35;
}

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

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.28rem 0.4rem 0.28rem 0.55rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
}

.toc a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--bg-elevated) 80%, transparent);
}

.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc .toc-h3 a {
  padding-left: 1.1rem;
  font-size: 0.78rem;
}

.toc-meta {
  margin: 1.25rem 0 0;
  font-size: 0.78rem;
}

.toc-meta a {
  color: var(--text-faint);
}

.content {
  min-width: 0;
  max-width: var(--prose-width);
}

.section-rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.spec-version-label {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

/* Prose */

.prose > :first-child {
  margin-top: 0;
}

.prose h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

.prose h2 {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 2.25rem 0 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.prose h2:first-child {
  border-top: 0;
  padding-top: 0;
}

.prose h3 {
  font-size: 1.05rem;
  font-weight: 650;
  margin: 1.75rem 0 0.5rem;
}

.prose h4 {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 1.5rem 0 0.4rem;
  color: var(--text-muted);
}

.prose p,
.prose ul,
.prose ol,
.prose table {
  margin: 0 0 1rem;
}

.prose li {
  margin: 0.25rem 0;
}

.prose li > ul,
.prose li > ol {
  margin-bottom: 0.25rem;
}

.prose strong {
  font-weight: 650;
  color: var(--text);
}

.prose blockquote {
  margin: 0 0 1rem;
  padding: 0.15rem 0 0.15rem 1rem;
  border-left: 3px solid var(--accent-dim);
  color: var(--text-muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose code {
  font-size: 0.88em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.prose pre {
  margin: 0 0 1.15rem;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.5;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: var(--text);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

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

.prose th {
  background: var(--bg-elevated);
  font-weight: 600;
}

.prose tr:nth-child(even) td {
  background: color-mix(in srgb, var(--bg-elevated) 55%, transparent);
}

/* Pitch tweaks on home */

.pitch h1 {
  /* readme fragment may not have h1; if it does, tone it */
}

.pitch > p:first-of-type {
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem 2.5rem;
}

.footer-inner {
  max-width: calc(var(--prose-width) + var(--toc-width) + 6rem);
  margin: 0 auto;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-inner p {
  margin: 0 0 0.35rem;
}

.footer-muted {
  color: var(--text-faint) !important;
}

/* Focus */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
