/* AlignThree - alignthree.com
   One stylesheet, no external requests, no build step beyond build.py. */

/* ---------- tokens ---------- */
:root {
  --bg:          #fbfbfd;
  --bg-raised:   #ffffff;
  --bg-sunken:   #f2f3f7;
  --border:      #e2e4ec;
  --border-soft: #edeef4;
  --text:        #16181d;
  --text-muted:  #5b6070;
  --text-faint:  #868c9e;
  --accent:      #4c46d6;
  --accent-hi:   #6a63f0;
  --accent-soft: #eeedfd;
  --accent-line: #cfcdf8;
  --warn-soft:   #fff6e8;
  --warn-line:   #f0d7ae;
  --code-bg:     #f5f6fa;
  --code-text:   #262a35;
  --shadow-sm:   0 1px 2px rgba(20, 22, 30, .05), 0 1px 1px rgba(20, 22, 30, .04);
  --shadow-md:   0 4px 16px rgba(20, 22, 30, .07), 0 1px 3px rgba(20, 22, 30, .05);
  --shadow-lg:   0 18px 50px rgba(20, 22, 30, .10), 0 3px 10px rgba(20, 22, 30, .05);

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

  --shell:  1140px;
  --measure: 74ch;
  --radius: 12px;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0e0f14;
    --bg-raised:   #16181f;
    --bg-sunken:   #121319;
    --border:      #272a35;
    --border-soft: #1e212a;
    --text:        #e9eaf0;
    --text-muted:  #a0a6b8;
    --text-faint:  #767d92;
    --accent:      #9c97ff;
    --accent-hi:   #b5b1ff;
    --accent-soft: #1c1b3a;
    --accent-line: #34327a;
    --warn-soft:   #2a2113;
    --warn-line:   #574326;
    --code-bg:     #12141a;
    --code-text:   #d6d9e3;
    --shadow-sm:   0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md:   0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg:   0 18px 50px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  --bg:          #0e0f14;
  --bg-raised:   #16181f;
  --bg-sunken:   #121319;
  --border:      #272a35;
  --border-soft: #1e212a;
  --text:        #e9eaf0;
  --text-muted:  #a0a6b8;
  --text-faint:  #767d92;
  --accent:      #9c97ff;
  --accent-hi:   #b5b1ff;
  --accent-soft: #1c1b3a;
  --accent-line: #34327a;
  --warn-soft:   #2a2113;
  --warn-line:   #574326;
  --code-bg:     #12141a;
  --code-text:   #d6d9e3;
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg:   0 18px 50px rgba(0, 0, 0, .55);
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
a:hover { color: var(--accent-hi); }

h1, h2, h3, h4, h5 { line-height: 1.25; font-weight: 640; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 2.1rem; margin: 0 0 .6em; letter-spacing: -.03em; }
h2 { font-size: 1.5rem; margin: 2.4em 0 .7em; letter-spacing: -.022em; }
h3 { font-size: 1.16rem; margin: 2em 0 .5em; }
h4 { font-size: 1rem; margin: 1.7em 0 .4em; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-size: .82rem; }

p { margin: 0 0 1.05em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.6em 0; }
img, svg, video { max-width: 100%; height: auto; }

.shell { max-width: var(--shell); margin-inline: auto; padding-inline: 24px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.site-header .shell { display: flex; align-items: center; gap: 28px; width: 100%; }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 660; font-size: 1.02rem; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; flex: none;
}
.brand:hover { color: var(--text); }
.brand .tm { font-size: .58em; vertical-align: super; color: var(--text-faint); font-weight: 500; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a {
  padding: 6px 11px; border-radius: 8px; font-size: .92rem; font-weight: 500;
  color: var(--text-muted); text-decoration: none; white-space: nowrap;
}
.nav a:hover { background: var(--bg-sunken); color: var(--text); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-raised); color: var(--text-muted);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }
.icon-btn svg { width: 16px; height: 16px; }
:root[data-theme="dark"] .icon-sun, .icon-moon { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

#nav-toggle { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 19px; border-radius: 10px;
  font-size: .95rem; font-weight: 560; text-decoration: none;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hi); color: #fff; }
.btn-ghost { background: var(--bg-raised); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--text-faint); color: var(--text); }

/* ---------- hero ---------- */
.hero { padding: 84px 0 28px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -40% 0 auto; height: 620px;
  background: radial-gradient(58% 50% at 50% 42%, var(--accent-soft) 0%, transparent 72%);
  opacity: .85; pointer-events: none; z-index: -1;
}
.hero-inner { max-width: 780px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 13px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent); font-size: .81rem; font-weight: 560;
  letter-spacing: .01em; margin-bottom: 22px;
}
.hero h1 {
  font-size: clamp(2.3rem, 5.4vw, 3.5rem);
  letter-spacing: -.04em; line-height: 1.08; margin-bottom: .38em;
}
.hero .lede { font-size: clamp(1.08rem, 2vw, 1.28rem); color: var(--text-muted); max-width: 68ch; margin-bottom: 1.5em; }
.hero .lede strong { color: var(--text); font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.hero-note { font-size: .87rem; color: var(--text-faint); margin-top: 18px; }

/* ---------- section furniture ---------- */
.section { padding: 68px 0; }
.section-sunken { background: var(--bg-sunken); border-block: 1px solid var(--border-soft); }
.section-head { max-width: 66ch; margin-bottom: 38px; }
.section-head h2 { margin-top: 0; font-size: clamp(1.5rem, 3vw, 1.95rem); letter-spacing: -.03em; }
.section-head p { color: var(--text-muted); margin-bottom: 0; }
.kicker {
  font-size: .78rem; font-weight: 640; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 10px;
}

/* ---------- cards ---------- */
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 .45em; font-size: 1.04rem; }
.card p  { margin: 0; color: var(--text-muted); font-size: .95rem; }
.card p + p { margin-top: .7em; }
.card-mark {
  display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 15px;
  border-radius: 9px; background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line);
}
.card-mark svg { width: 17px; height: 17px; }

a.card { text-decoration: none; color: inherit; display: block; }
a.card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-md); color: inherit; }
a.card h3 { color: var(--accent); }
a.card .card-more { display: block; margin-top: .9em; font-size: .87rem; font-weight: 560; color: var(--accent); }

/* ---------- code ---------- */
code, kbd, samp, pre { font-family: var(--mono); }
:not(pre) > code {
  background: var(--code-bg); color: var(--code-text);
  border: 1px solid var(--border-soft);
  padding: .12em .38em; border-radius: 5px;
  font-size: .875em; white-space: nowrap;
}
kbd {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px;
  padding: .1em .42em; font-size: .84em; color: var(--text);
  white-space: nowrap;
}
pre {
  background: var(--code-bg); color: var(--code-text);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 17px 19px; margin: 0 0 1.3em;
  overflow-x: auto; font-size: .855rem; line-height: 1.62;
  -webkit-overflow-scrolling: touch;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }

.code-window {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-lg); background: var(--bg-raised);
}
.code-window-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 14px; background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
}
.code-window-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex: none; }
.code-window-bar .name {
  margin-left: 6px; font-family: var(--mono); font-size: .78rem; color: var(--text-faint);
}
.code-window pre { border: 0; border-radius: 0; margin: 0; background: var(--bg-raised); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; margin: 0 0 1.5em; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { font-weight: 620; color: var(--text); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-sunken); }
table code { white-space: nowrap; }

/* ---------- blockquote / callout ---------- */
blockquote {
  margin: 0 0 1.4em; padding: 14px 18px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--text);
}
blockquote > :last-child { margin-bottom: 0; }

.note {
  padding: 15px 18px; border-radius: var(--radius);
  background: var(--warn-soft); border: 1px solid var(--warn-line);
  font-size: .93rem; margin: 0 0 1.5em;
}
.note > :last-child { margin-bottom: 0; }
.note strong { color: var(--text); }

/* ---------- docs layout ---------- */
.docs { display: grid; grid-template-columns: 232px minmax(0, 1fr) 200px; gap: 44px; align-items: start; padding: 40px 0 90px; }

.docs-nav { position: sticky; top: calc(var(--header-h) + 26px); font-size: .92rem; }
.docs-nav .group { margin-bottom: 22px; }
.docs-nav .group-label {
  font-size: .72rem; font-weight: 660; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint); margin: 0 0 9px; padding-inline: 10px;
}
.docs-nav ul { list-style: none; margin: 0; padding: 0; }
.docs-nav a {
  display: block; padding: 6px 10px; border-radius: 7px;
  color: var(--text-muted); text-decoration: none; font-weight: 500;
}
.docs-nav a:hover { background: var(--bg-sunken); color: var(--text); }
.docs-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 580; }

.docs-main { min-width: 0; max-width: var(--measure); }
.docs-main > h1:first-child { margin-top: 0; }
.docs-main h2 { scroll-margin-top: calc(var(--header-h) + 16px); padding-top: .35em; border-top: 1px solid var(--border-soft); }
.docs-main h3, .docs-main h4 { scroll-margin-top: calc(var(--header-h) + 16px); }
.docs-main ul, .docs-main ol { padding-left: 1.35em; margin: 0 0 1.15em; }
.docs-main li { margin-bottom: .38em; }
.docs-main li > ul, .docs-main li > ol { margin-top: .38em; }

.doc-lede { font-size: 1.08rem; color: var(--text-muted); margin-bottom: 1.6em; }

.doc-toc { position: sticky; top: calc(var(--header-h) + 26px); font-size: .87rem; }
.doc-toc .group-label {
  font-size: .72rem; font-weight: 660; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint); margin: 0 0 9px;
}
.doc-toc ul { list-style: none; margin: 0; padding: 0; }
.doc-toc li { margin-bottom: 1px; }
.doc-toc a {
  display: block; padding: 4px 0 4px 12px; color: var(--text-muted);
  text-decoration: none; border-left: 2px solid var(--border-soft);
  overflow: hidden; text-overflow: ellipsis;
}
.doc-toc a:hover { color: var(--accent); border-left-color: var(--accent-line); }

.doc-foot {
  margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--border);
  font-size: .88rem; color: var(--text-faint);
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border-soft); background: var(--bg-sunken);
  padding: 44px 0 34px; font-size: .9rem; color: var(--text-muted);
}
.footer-grid { display: flex; flex-wrap: wrap; gap: 40px; justify-content: space-between; margin-bottom: 30px; }
.footer-col h4 { margin: 0 0 .7em; color: var(--text); font-size: .78rem; }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: .38em; }
.footer-col a { color: var(--text-muted); text-decoration: none; }
.footer-col a:hover { color: var(--accent); }
.footer-legal { border-top: 1px solid var(--border); padding-top: 22px; font-size: .84rem; color: var(--text-faint); max-width: 78ch; }
.footer-legal p { margin: 0 0 .5em; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .docs { grid-template-columns: 210px minmax(0, 1fr); gap: 34px; }
  .doc-toc { display: none; }
}

@media (max-width: 780px) {
  body { font-size: 16px; }
  .hero { padding: 56px 0 20px; }
  .section { padding: 50px 0; }

  .docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 22px; }
  .docs-nav {
    position: static; margin-bottom: 30px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-raised); padding: 8px 6px;
  }
  .docs-nav .group { margin-bottom: 8px; }
  .docs-nav .group:last-child { margin-bottom: 0; }

  /* Nav collapses behind the hamburger. */
  #nav-toggle:checked ~ .nav { display: flex; }
  .nav {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg-raised); border-bottom: 1px solid var(--border);
    padding: 10px 16px 14px; box-shadow: var(--shadow-md);
  }
  .nav a { padding: 9px 12px; font-size: .97rem; }
  .nav-toggle-label {
    display: inline-grid; place-items: center; margin-left: auto;
    width: 34px; height: 34px; border: 1px solid var(--border);
    border-radius: 9px; background: var(--bg-raised); color: var(--text-muted); cursor: pointer;
  }
  .nav-toggle-label svg { width: 17px; height: 17px; }
}

@media (min-width: 781px) {
  .nav-toggle-label { display: none; }
}

@media print {
  .site-header, .docs-nav, .doc-toc, .site-footer, .hero-actions { display: none; }
  .docs { grid-template-columns: 1fr; }
  body { font-size: 11pt; }
  a { color: inherit; text-decoration: none; }
}
