/*
 * testz.dev — design system.
 *
 * System fonts only: no webfont means no external request, no CSP exception,
 * no layout shift and no third party learning who reads this site.
 * Light and dark are both first-class, driven by prefers-color-scheme.
 */

:root {
  --bg: #fbfbfa;
  --bg-raised: #ffffff;
  --bg-sunken: #f2f2f0;
  --border: #dededa;
  --border-strong: #c4c4be;
  --text: #1c1c1a;
  --text-muted: #63635e;
  --accent: #0f5f52;
  --accent-soft: #e2f0ec;
  --warn-bg: #fdf6e3;
  --warn-border: #d9c48a;
  --code-bg: #f2f2f0;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --measure: 46rem;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --bg-raised: #1b1e23;
    --bg-sunken: #101216;
    --border: #2b3037;
    --border-strong: #3d444d;
    --text: #e6e6e3;
    --text-muted: #979ba2;
    --accent: #5bd0b6;
    --accent-soft: #17302b;
    --warn-bg: #2a2418;
    --warn-border: #5c4d28;
    --code-bg: #101216;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  display: grid;
  grid-template-columns: minmax(0, 16rem) minmax(0, 1fr);
  min-height: 100vh;
}

@media (max-width: 62rem) {
  body {
    grid-template-columns: minmax(0, 1fr);
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius);
}

/* ---- Sidebar ---------------------------------------------------------- */

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-sunken);
  padding: 1.75rem 1.25rem 3rem;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
}

@media (max-width: 62rem) {
  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.brand {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 1.75rem;
}

.brand .tld {
  color: var(--accent);
}

.nav-group {
  margin-bottom: 1.5rem;
}

.nav-group h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.nav-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-group li {
  margin: 0;
}

.nav-group a {
  display: block;
  padding: 0.28rem 0.55rem;
  margin-left: -0.55rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.45;
}

.nav-group a:hover,
.nav-group a:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
}

/* ---- Layout ----------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 14rem);
  gap: 2.5rem;
  padding: 3rem 2.5rem 5rem;
  min-width: 0;
}

@media (max-width: 78rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 40rem) {
  .layout {
    padding: 2rem 1.25rem 3rem;
  }
}

main {
  min-width: 0;
}

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

.toc {
  position: sticky;
  top: 3rem;
  align-self: start;
  font-size: 0.85rem;
  border-left: 1px solid var(--border);
  padding-left: 1.1rem;
}

@media (max-width: 78rem) {
  .toc {
    display: none;
  }
}

.toc h2 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

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

.toc a {
  display: block;
  padding: 0.2rem 0;
  color: var(--text-muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--accent);
}

/* ---- Typography ------------------------------------------------------- */

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  line-height: 1.25;
  letter-spacing: -0.015em;
  scroll-margin-top: 1.5rem;
}

.prose h1 {
  font-size: 2.1rem;
  margin: 0 0 1.25rem;
}

.prose h2 {
  font-size: 1.4rem;
  margin: 2.75rem 0 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.prose h3 {
  font-size: 1.1rem;
  margin: 2rem 0 0.6rem;
}

.prose h4 {
  font-size: 0.97rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-muted);
}

.anchor {
  margin-left: 0.4rem;
  color: var(--border-strong);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.12s ease-in-out;
}

h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

.prose p {
  margin: 0 0 1.1rem;
}

.prose a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.prose ul,
.prose ol {
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

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

.prose blockquote p:last-child {
  margin-bottom: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ---- Code ------------------------------------------------------------- */

code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.32em;
  overflow-wrap: break-word;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.2rem;
  font-size: 0.85rem;
  line-height: 1.55;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}

.diagram {
  margin: 0 0 1.5rem;
}

.diagram figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -0.6rem;
}

.mermaid-source {
  border-style: dashed;
}

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

.table-scroll {
  overflow-x: auto;
  margin: 0 0 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
}

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

th {
  background: var(--bg-sunken);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ---- Notices ---------------------------------------------------------- */

.notice {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0 0 1.4rem;
  font-size: 0.92rem;
}

.notice-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  border-left-color: var(--warn-border);
}

.notice ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.notice p:last-child {
  margin-bottom: 0;
}

/* ---- whoami panel ----------------------------------------------------- */

.whoami-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.4rem;
}

.whoami-section {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.whoami-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.whoami-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.8rem;
}

.whoami-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.whoami-list dt {
  color: var(--text-muted);
  white-space: nowrap;
}

.whoami-list dd {
  margin: 0;
  min-width: 0;
}

.whoami-list code {
  overflow-wrap: anywhere;
}

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

/* ---- Footer ----------------------------------------------------------- */

.page-footer {
  max-width: var(--measure);
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.83rem;
  color: var(--text-muted);
}

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

.build-meta {
  font-size: 0.78rem;
}

/* ---- Motion ----------------------------------------------------------- */

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
