/* Stack — design-system tokens and component classes. Forked from the
   Industry design system: same blueprint frame, same ramp/token architecture,
   same component vocabulary — recolored to a steel-teal accent, reset to
   JetBrains Mono over Source Serif 4, and extended with one new component
   (.term, see the bottom of this file) for the one thing Industry never
   needed: showing terminal output. This file is the source of truth for the
   system's look; retune it here and see readme.md. */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;600;700&family=Source+Serif+4:wght@400;500;600&display=swap');

:root {
  --color-bg: #eef4f2;
  --color-surface: #e4ece9;
  --color-text: #141a1a;
  --color-accent: #1c8f7f;
  --color-accent-2: #2fa290;
  --color-divider: color-mix(in srgb, #141a1a 16%, transparent);

  /* Tonal ramps — same shared-lightness-scale approach as Industry's, hand-
     tuned to a teal hue (~172) instead of steel-blue (~210), so the same
     step of any role still matches the others in visual value. */
  --color-neutral-100: #f1f6f5;
  --color-neutral-200: #e3eae8;
  --color-neutral-300: #d0dad7;
  --color-neutral-400: #b2c0bc;
  --color-neutral-500: #93a19d;
  --color-neutral-600: #768480;
  --color-neutral-700: #5a6663;
  --color-neutral-800: #3f4947;
  --color-neutral-900: #29302e;

  --color-accent-100: #e6f5f1;
  --color-accent-200: #c5e6dd;
  --color-accent-300: #99d0c2;
  --color-accent-400: #68b6a4;
  --color-accent-500: #3f9a87;
  --color-accent-600: #1e8172;
  --color-accent-700: #166257;
  --color-accent-800: #10473f;
  --color-accent-900: #0a2e29;

  --color-accent-2-100: #e6f5f1;
  --color-accent-2-200: #cbe9e0;
  --color-accent-2-300: #a6d8c9;
  --color-accent-2-400: #7dc2b0;
  --color-accent-2-500: #57a897;
  --color-accent-2-600: #398b7b;
  --color-accent-2-700: #296a5e;
  --color-accent-2-800: #1b4b42;
  --color-accent-2-900: #10312b;

  --font-heading: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --font-heading-weight: 600;
  --font-body: "Source Serif 4", Georgia, "Iowan Old Style", serif;

  --space-1: 3.4px;
  --space-2: 6.8px;
  --space-3: 10.2px;
  --space-4: 13.6px;
  --space-6: 20.4px;
  --space-8: 27.2px;

  --radius-sm: 2px;
  --radius-md: 3px;
  --radius-lg: 6px;

  /* Elevation — derived from the ground, same formula as Industry, re-based
     on this system's own darkest neutral step. */
  --shadow-sm: 0 1px 2px color-mix(in srgb, #29302e 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #29302e 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #29302e 22%, transparent);

  color-scheme: light dark;
}

/* — dark band — a deliberate addition beyond Industry, which ships one band
   only. Same ramp values throughout (100=lightest hex, 900=darkest hex,
   fixed regardless of band); only the role tokens (bg/surface/text/accent/
   divider/shadow) are redefined here, so every page and component inherits
   dark mode with zero further edits — nothing below this block references
   the dark tokens directly. Hover/pressed states still borrow the same
   accent-600/700 ramp steps used in the light band (a slight darkening on
   press rather than a re-tuned lightening curve) — a deliberate
   simplification, not a fully re-derived dark interaction model, since this
   environment has no way to render and visually check a bespoke one. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #12161a;
    --color-surface: #1a2026;
    --color-text: #e9edee;
    --color-accent: #3fc7ae;
    --color-accent-2: #52d1ba;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 3px 10px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --color-bg: #12161a;
  --color-surface: #1a2026;
  --color-text: #e9edee;
  --color-accent: #3fc7ae;
  --color-accent-2: #52d1ba;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 3px 10px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] {
  --color-bg: #eef4f2;
  --color-surface: #e4ece9;
  --color-text: #141a1a;
  --color-accent: #1c8f7f;
  --color-accent-2: #2fa290;
  --shadow-sm: 0 1px 2px color-mix(in srgb, #29302e 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #29302e 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #29302e 22%, transparent);
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: var(--font-heading-weight); }

.blueprint {
  position: relative;
  border: 1px solid var(--color-divider);
  border-radius: 0;
}
.blueprint.term { overflow: visible; }
.blueprint > .corner {
  position: absolute; width: 11px; height: 11px;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.blueprint > .corner::before, .blueprint > .corner::after {
  content: ""; position: absolute; background: currentColor;
}
.blueprint > .corner::before { left: 5px; top: 0; width: 1px; height: 100%; }
.blueprint > .corner::after  { top: 5px; left: 0; width: 100%; height: 1px; }
.blueprint > .corner.tl { top: -6px; left: -6px; }
.blueprint > .corner.tr { top: -6px; right: -6px; }
.blueprint > .corner.bl { bottom: -6px; left: -6px; }
.blueprint > .corner.br { bottom: -6px; right: -6px; }

/* ══════════════════════════════════════════════════════════════════════════
   Components — built with the tokens above. Plain CSS on plain HTML: no
   JavaScript, no build step. Each class is documented in readme.md and
   demonstrated in foundations/ and components/.
   ══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.6; font-weight: 400; }
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 var(--space-2);
}
h1 { font-size: 40px; }
h2 { font-size: 31px; }
h3 { font-size: 24px; }
h4 { font-size: 19px; }
h5 { font-size: 15px; }
h6 { font-size: 12px; }
h6 { letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent-700); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
figure { margin: 0; }
figcaption {
  font-size: 11px; margin-top: var(--space-1);
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
code { font-family: var(--font-heading); font-size: 0.9em; }
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* — rules — */
.hr {
  height: 1px; border: 0; margin: var(--space-4) 0;
  background: var(--color-divider);
}

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 13px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent-700); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-block { width: 100%; margin-top: var(--space-2); }

/* — forms — */
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-family: var(--font-heading); font-size: 13px; color: var(--color-text);
  caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.radio input, .seg-opt input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.radio .dot {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--color-divider);
}
.radio:hover .dot { border-color: var(--color-accent); }
.radio input:checked + .dot {
  border-color: var(--color-accent); background: var(--color-accent);
  box-shadow: inset 0 0 0 4px var(--color-bg);
}
.radio input:focus-visible + .dot { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.seg {
  display: inline-flex; overflow: hidden;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.seg-opt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 12.5px; cursor: pointer;
}
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt:has(input:checked) { background: var(--color-accent); color: var(--color-bg); }
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: -2px; }

/* — cards — */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface);
}
.card-kicker { font-family: var(--font-heading); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent-700); }
.card-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 16px; line-height: 1.25;
}
.card-body { margin: 0; font-family: var(--font-body); font-size: 13.5px; opacity: 0.82; flex: 1; }
.card-meta {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* — tags — */
.tag {
  display: inline-flex; align-items: center; font-family: var(--font-heading); font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px;
  border-radius: calc(var(--radius-md) * 0.75);
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-accent-2 { background: var(--color-accent-2-100); color: var(--color-accent-2-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent-700); }

/* — navigation — */
.nav {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: none;
}
.nav-brand {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 17px; margin-right: auto;
}
/* — logo + wordmark, sat together as one unit; .nav-brand keeps working
   alone (bare text, no mark) wherever a page doesn't need the lockup — */
.nav-lockup { display: flex; align-items: center; gap: var(--space-2); margin-right: auto; }
.nav-lockup .nav-brand { margin-right: 0; }
.nav-mark { width: 20px; height: 16px; flex: none; display: block; }

/* — theme toggle: the one component in this system with real behavior
   (see readme.md "Theme" — everything else is native-element state, this
   needs a few lines of script to persist a choice and read it back). Shows
   the icon for the mode a click switches TO. */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
.nav a { color: inherit; text-decoration: none; font-family: var(--font-heading); font-size: 13px; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--color-accent-700); }

/* — tables — */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-family: var(--font-heading); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: var(--space-2); border-bottom: 1px solid var(--color-divider);
}
.table td {
  padding: var(--space-2);
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }

/* — dialog — */
.dialog-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent);
}
.dialog {
  width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-lg);
}
.dialog-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 18px;
}
.dialog-body { font-family: var(--font-body); font-size: 14px; opacity: 0.85; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* — terminal (new in Stack — Industry never needed this; the one component
     this fork adds rather than just recolors, because showing real command
     output is central to what this product is) — */
.term { display: flex; flex-direction: column; background: var(--color-surface); }
.term-bar {
  display: flex; align-items: center; gap: 6px;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}
.term-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-divider); }
.term-name {
  margin-left: 6px; font-family: var(--font-heading); font-size: 11px;
  letter-spacing: 0.04em; color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.term-body {
  margin: 0; padding: var(--space-4); font-family: var(--font-heading);
  font-size: 13px; line-height: 1.75; white-space: pre; overflow-x: auto;
  color: color-mix(in srgb, var(--color-text) 88%, transparent);
}
.term-prompt, .term-ok { color: var(--color-accent-700); }
.term-dim { color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.term-copy {
  margin-left: auto; flex: none; display: inline-flex; align-items: center;
  font-family: var(--font-heading); font-size: 11px; letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  background: transparent; border: 1px solid var(--color-divider);
  padding: 2px 8px; cursor: pointer; border-radius: var(--radius-sm);
}
.term-copy:hover { color: var(--color-accent-700); border-color: var(--color-accent); }
.term-copy:disabled { color: var(--color-accent-700); border-color: var(--color-accent); cursor: default; }
.installline-copy {
  margin-left: var(--space-2); flex: none; display: inline-flex; align-items: center;
  font-family: var(--font-heading); font-size: 11px; letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  background: transparent; border: 1px solid var(--color-divider);
  padding: 2px 8px; cursor: pointer; border-radius: var(--radius-sm);
}
.installline-copy:hover { color: var(--color-accent-700); border-color: var(--color-accent); }
.installline-copy:disabled { color: var(--color-accent-700); border-color: var(--color-accent); cursor: default; }

/* — blueprint frame: components are wireframe objects (see .blueprint and
     .corner above) — square, transparent, hairline-bordered — */
.card, .btn, .input, .tag, .seg, .dialog, .term { border-radius: 0; }
.card, .dialog, .term { background: transparent; border: 1px solid var(--color-divider); }
.btn { border: 1px solid var(--color-divider); }
.btn-primary { border-color: var(--color-accent); }
.btn-ghost { border-color: transparent; }

/* — site chrome, added for stackenv.dev (not part of the component-library
   demos) — sticky nav with real multi-page links, and a docs sidebar layout
   used by every page under /docs/. — */
.site-nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--color-divider);
}
/* Nav overflow handling: the brand lockup, theme toggle, and primary CTA
   stay pinned (flex: none) and always visible; the plain link group scrolls
   horizontally instead of wrapping or getting squeezed off-screen — keeps
   nav height fixed (matters for .docs-side's sticky top offset) and every
   link reachable at any width, no hamburger/JS needed. */
.nav { flex-wrap: nowrap; }
.nav-lockup, .nav .theme-toggle, .nav > .btn-primary { flex: none; }
.nav-links {
  display: flex; align-items: center; gap: var(--space-4);
  overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { flex: none; }
.docs-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-8); align-items: start; }
.docs-side { position: sticky; top: 64px; display: flex; flex-direction: column; gap: var(--space-1); padding-block: var(--space-4); }
.docs-side .side-group { margin-top: var(--space-4); }
.docs-side .side-group:first-child { margin-top: 0; }
.docs-side h6 { margin: 0 0 var(--space-2); color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.docs-side a { display: block; padding: 4px 0; font-family: var(--font-heading); font-size: 13px; color: color-mix(in srgb, var(--color-text) 78%, transparent); }
.docs-side a:hover, .docs-side a[aria-current="page"] { color: var(--color-accent-700); }
.docs-main { min-width: 0; padding-block: var(--space-8); max-width: 72ch; }
.docs-main h2 { margin-top: var(--space-8); }
.docs-main h2:first-child { margin-top: 0; }
.docs-main h3 { margin-top: var(--space-6); }
.docs-main .table { margin: var(--space-4) 0; }
.docs-main .term { margin: var(--space-4) 0; }
@media (max-width: 820px) { .docs-layout { grid-template-columns: 1fr; } .docs-side { position: static; } }

/* Wide tables (the manifest field-reference tables especially — four
   columns of prose) get their own horizontal scroll on narrow viewports
   instead of forcing the whole page to scroll sideways. */
.table-wrap { overflow-x: auto; margin: var(--space-4) 0; }
.table-wrap .table { margin: 0; min-width: 480px; }
