/* notjunk design system, v1. ONE file, byte-identical in both repos:
 *   notjunk.si (landing repo)     -> public/nj/nj.css
 *   app.notjunk.si (app repo)     -> pwa/nj/nj.css
 * Edit it in one place and copy it to the other (scripts/nj-ship-gate checks
 * the hashes match). Fonts: SIL OFL 1.1, self-hosted in /nj/fonts.
 *
 * Idea: a retired computer brought back to work. Board green, solder yellow,
 * keycap buttons you can feel, label-maker tape, and archie: the little
 * monitor with a face who lives on your old computer. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/nj/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/nj/fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  /* colour (every text pair here is >= 4.5:1; see docs in SKILL.md) */
  --nj-bg: #f3f5ef;          /* bench */
  --nj-surface: #ffffff;
  --nj-sunk: #e7ece4;
  --nj-ink: #14231c;
  --nj-ink-2: #4a5a52;
  --nj-line: #c9d3c6;
  --nj-brand: #0b6b4f;       /* board green */
  --nj-brand-ink: #ffffff;
  --nj-brand-soft: #e3f1e9;
  --nj-solder: #ffc53d;      /* solder yellow, always with ink text */
  --nj-coral: #c2412d;
  --nj-coral-soft: #fbe9e5;
  --nj-key-edge: #14231c;    /* keycap outline + drop */
  --nj-case: #e6e1d3;        /* archie's beige case */
  --nj-screen: #0f3d30;
  --nj-glow: #6ef2b4;

  /* type: Bricolage Grotesque for display, Atkinson Hyperlegible Next for reading */
  --nj-font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --nj-font-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nj-font-code: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* scale 1.25 from a 17px body; nothing smaller than 15px */
  --nj-t--1: 0.9375rem;
  --nj-t-0: 1.0625rem;
  --nj-t-1: 1.25rem;
  --nj-t-2: 1.5625rem;
  --nj-t-3: 1.953rem;
  --nj-t-4: 2.441rem;
  --nj-t-5: clamp(2.441rem, 8vw + 0.5rem, 4.2rem);

  /* space (4px base) */
  --nj-s-1: 4px; --nj-s-2: 8px; --nj-s-3: 12px; --nj-s-4: 16px;
  --nj-s-5: 24px; --nj-s-6: 32px; --nj-s-7: 48px; --nj-s-8: 72px;
  /* radii: small for chips, medium for fields/keys, large for sheets */
  --nj-r-1: 8px; --nj-r-2: 14px; --nj-r-3: 22px; --nj-r-pill: 999px;
  /* motion */
  --nj-ease: cubic-bezier(.2, .8, .2, 1);
  --nj-spring: cubic-bezier(.34, 1.56, .64, 1);
  --nj-fast: 120ms; --nj-med: 240ms; --nj-slow: 480ms;
  --nj-tap: 44px;
  --nj-safe-t: env(safe-area-inset-top, 0px);
  --nj-safe-b: env(safe-area-inset-bottom, 0px);
  --nj-safe-l: env(safe-area-inset-left, 0px);
  --nj-safe-r: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --nj-bg: #0c1713;
    --nj-surface: #14231c;
    --nj-sunk: #0f1d17;
    --nj-ink: #eaf2ec;
    --nj-ink-2: #a7b8ae;
    --nj-line: #2b4237;
    --nj-brand: #3dd69b;
    --nj-brand-ink: #06291d;
    --nj-brand-soft: #173a2d;
    --nj-coral: #ff8a75;
    --nj-coral-soft: #3a1f1a;
    --nj-key-edge: #000000;
    --nj-case: #cfc8b5;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.nj {
  margin: 0;
  background: var(--nj-bg);
  color: var(--nj-ink);
  font-family: var(--nj-font-body);
  font-size: var(--nj-t-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.nj :where(h1, h2, h3) {
  font-family: var(--nj-font-display);
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 var(--nj-s-3);
  text-wrap: balance;
}
.nj :where(p) { margin: 0 0 var(--nj-s-3); text-wrap: pretty; }
.nj :where(a) { color: var(--nj-brand); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.nj :where(code, pre, kbd) { font-family: var(--nj-font-code); }
.nj [tabindex="-1"]:focus { outline: none; box-shadow: none; }
.nj :where(a, button, input, textarea, select, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid var(--nj-solder);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--nj-key-edge);
  border-radius: var(--nj-r-1);
}
.nj :where(button, a, [role="button"]) { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.nj-hidden, .nj [hidden] { display: none !important; }
.nj-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nj-display { font-size: var(--nj-t-5); font-weight: 800; letter-spacing: -0.035em; line-height: 0.98; }
.nj-h1 { font-size: var(--nj-t-4); }
.nj-h2 { font-size: var(--nj-t-3); }
.nj-h3 { font-size: var(--nj-t-1); letter-spacing: -0.01em; }
.nj-lede { font-size: var(--nj-t-1); color: var(--nj-ink-2); max-width: 34ch; }
.nj-muted { color: var(--nj-ink-2); }
.nj-small { font-size: var(--nj-t--1); }

/* ---------- wordmark ---------- */
.nj-mark {
  display: inline-flex; align-items: center; gap: var(--nj-s-2);
  font-family: var(--nj-font-display); font-weight: 800; font-size: 1.375rem;
  letter-spacing: -0.03em; color: var(--nj-ink); text-decoration: none;
  min-height: var(--nj-tap);
}
.nj-mark .archie { width: 34px; height: 34px; }
.nj-mark .nj-logo { width: 32px; height: 32px; flex: none; }
.nj-doc a.nj-mark { color: var(--nj-ink); text-decoration: none; }

/* ---------- keycap buttons ---------- */
.nj-key {
  --k-bg: var(--nj-brand); --k-fg: var(--nj-brand-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--nj-s-2);
  min-height: 52px; min-width: var(--nj-tap); padding: 0 var(--nj-s-5);
  font: 700 var(--nj-t-0)/1 var(--nj-font-body);
  color: var(--k-fg); background: var(--k-bg);
  border: 2px solid var(--nj-key-edge); border-radius: var(--nj-r-2);
  box-shadow: 0 4px 0 var(--nj-key-edge);
  white-space: nowrap; flex-shrink: 0;
  text-decoration: none; cursor: pointer;
  transform: translateY(0);
  transition: transform var(--nj-fast) var(--nj-ease), box-shadow var(--nj-fast) var(--nj-ease), background var(--nj-med);
}
.nj-key:hover { filter: brightness(1.05); }
.nj-key:active, .nj-key[aria-pressed="true"].is-pressing { transform: translateY(3px); box-shadow: 0 1px 0 var(--nj-key-edge); }
.nj-key:disabled, .nj-key[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.nj-key--solder { --k-bg: var(--nj-solder); --k-fg: #14231c; }
.nj-key--plain { --k-bg: var(--nj-surface); --k-fg: var(--nj-ink); }
.nj-key--danger { --k-bg: var(--nj-coral); --k-fg: #fff; }
@media (prefers-color-scheme: dark) { .nj-key--danger { --k-fg: #2a0d07; } }
.nj-key--wide { width: 100%; }
.nj-key--sm { min-height: var(--nj-tap); padding: 0 var(--nj-s-4); font-size: var(--nj-t--1); box-shadow: 0 3px 0 var(--nj-key-edge); }
.nj-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--nj-tap); min-width: var(--nj-tap);
  background: none; border: 0; padding: 0 var(--nj-s-2); cursor: pointer;
  font: 700 var(--nj-t-0)/1.2 var(--nj-font-body); color: var(--nj-brand);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px;
}

/* ---------- fields ---------- */
.nj-field { display: grid; gap: var(--nj-s-2); }
.nj-label { font-weight: 700; }
.nj-input {
  width: 100%; min-height: 56px; padding: var(--nj-s-3) var(--nj-s-4);
  font: 400 1.125rem/1.3 var(--nj-font-body); color: var(--nj-ink);
  background: var(--nj-surface); border: 2px solid var(--nj-key-edge); border-radius: var(--nj-r-2);
  box-shadow: inset 0 3px 0 var(--nj-sunk);
}
.nj-input::placeholder { color: var(--nj-ink-2); opacity: 1; }
.nj-input:focus { outline: none; border-color: var(--nj-brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--nj-brand) 30%, transparent); }
.nj-check { display: flex; gap: var(--nj-s-3); align-items: flex-start; min-height: var(--nj-tap); padding-top: 10px; font-weight: 700; cursor: pointer; }
.nj-check input { width: 24px; height: 24px; margin: 0; accent-color: var(--nj-brand); flex: none; }

/* ---------- surfaces ---------- */
.nj-sheet {
  background: var(--nj-surface); border: 2px solid var(--nj-key-edge);
  border-radius: var(--nj-r-3); padding: var(--nj-s-5);
  box-shadow: 6px 6px 0 var(--nj-key-edge);
}
.nj-panel { background: var(--nj-surface); border: 1.5px solid var(--nj-line); border-radius: var(--nj-r-2); padding: var(--nj-s-4); }
.nj-note { border-radius: var(--nj-r-2); padding: var(--nj-s-3) var(--nj-s-4); background: var(--nj-brand-soft); color: var(--nj-ink); }
.nj-note--warn { background: var(--nj-coral-soft); border-left: 5px solid var(--nj-coral); }
.nj-note--warn strong { color: var(--nj-ink); }

/* label-maker tape: names of things (computers, agents) */
.nj-tape {
  display: inline-block; padding: 3px 12px 4px; border-radius: 3px;
  background: var(--nj-ink); color: var(--nj-bg);
  font: 700 var(--nj-t--1)/1.3 var(--nj-font-display); letter-spacing: 0.04em;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.12), inset 0 2px 0 rgba(0,0,0,.25);
  transform: rotate(-1.5deg);
}
.nj-tape--brand { background: var(--nj-brand); color: var(--nj-brand-ink); }

/* the 3-word code: one keycap per word */
.nj-code { display: flex; flex-wrap: wrap; gap: var(--nj-s-2); margin: 0; padding: 0; list-style: none; }
.nj-code > li {
  font: 700 1.375rem/1 var(--nj-font-code); padding: 14px 14px 12px;
  background: var(--nj-surface); color: var(--nj-ink);
  border: 2px solid var(--nj-key-edge); border-radius: var(--nj-r-1);
  box-shadow: 0 4px 0 var(--nj-key-edge);
  animation: nj-pop var(--nj-med) var(--nj-spring) both;
}
.nj-code > li:nth-child(2) { animation-delay: 60ms; }
.nj-code > li:nth-child(3) { animation-delay: 120ms; }
.nj-cmd {
  display: block; width: 100%; margin: 0; padding: var(--nj-s-4);
  font: 600 1.0625rem/1.4 var(--nj-font-code); color: #eaf2ec; background: #0f1d17;
  border-radius: var(--nj-r-2); border: 2px solid var(--nj-key-edge);
  white-space: pre-wrap; word-break: break-all; user-select: all;
}
.nj-cmd::before { content: "$ "; color: var(--nj-glow); }

/* status: a dot that breathes when online */
.nj-status { display: inline-flex; align-items: center; gap: var(--nj-s-2); font-weight: 700; }
.nj-status::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: var(--nj-ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nj-ink-2) 25%, transparent);
}
.nj-status[data-state="online"]::before { background: #1fa774; box-shadow: 0 0 0 3px rgba(31,167,116,.28); animation: nj-breathe 2.4s ease-in-out infinite; }
.nj-status[data-state="offline"]::before { background: var(--nj-coral); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nj-coral) 25%, transparent); }

/* step dots for one-thing-at-a-time flows */
.nj-progress { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.nj-progress li { height: 6px; flex: 1; border-radius: 3px; background: var(--nj-line); transition: background var(--nj-med); }
.nj-progress li.on { background: var(--nj-brand); }

/* choices (archie's multiple-choice questions, computer picker) */
.nj-choices { display: flex; flex-wrap: wrap; gap: var(--nj-s-2); }
.nj-choice {
  min-height: var(--nj-tap); padding: 8px 16px; cursor: pointer;
  font: 700 var(--nj-t-0)/1.2 var(--nj-font-body); color: var(--nj-ink);
  background: var(--nj-surface); border: 2px solid var(--nj-key-edge); border-radius: var(--nj-r-pill);
  transition: transform var(--nj-fast) var(--nj-spring), background var(--nj-fast);
}
.nj-choice:active { transform: scale(.96); }
.nj-choice[aria-pressed="true"], .nj-choice.is-picked { background: var(--nj-solder); color: #14231c; }

/* chat */
.nj-chat { display: flex; flex-direction: column; gap: var(--nj-s-3); }
.nj-msg { display: flex; gap: var(--nj-s-2); align-items: flex-end; max-width: 100%; animation: nj-rise var(--nj-med) var(--nj-ease) both; }
.nj-msg .archie { width: 32px; height: 32px; flex: none; }
.nj-bubble {
  max-width: min(78vw, 34rem); padding: 10px 14px; border-radius: 18px 18px 18px 6px;
  background: var(--nj-surface); border: 2px solid var(--nj-key-edge); color: var(--nj-ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.nj-msg--me { justify-content: flex-end; }
.nj-msg--me .nj-bubble { background: var(--nj-brand); color: var(--nj-brand-ink); border-radius: 18px 18px 6px 18px; }
.nj-bubble .nj-choices { margin-top: var(--nj-s-3); }
.nj-bubble-meta { display: block; font-size: var(--nj-t--1); color: var(--nj-ink-2); margin-bottom: 2px; font-weight: 700; }
.nj-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.nj-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--nj-ink-2); animation: nj-dot 1s infinite ease-in-out; }
.nj-typing i:nth-child(2) { animation-delay: .15s; } .nj-typing i:nth-child(3) { animation-delay: .3s; }

/* ---------- archie (inline SVG, see archie.js / archie.tsx) ---------- */
.archie { display: block; overflow: visible; }
.archie .a-case { fill: var(--nj-case); stroke: var(--nj-key-edge); stroke-width: 4; }
.archie .a-screen { fill: var(--nj-screen); stroke: var(--nj-key-edge); stroke-width: 3; }
.archie .a-eye { fill: var(--nj-glow); transform-box: fill-box; transform-origin: center; animation: nj-blink 5.5s infinite; }
.archie .a-mouth { fill: none; stroke: var(--nj-glow); stroke-width: 4; stroke-linecap: round; }
.archie .a-sleep { fill: none; stroke: var(--nj-glow); stroke-width: 4; stroke-linecap: round; opacity: 0; }
.archie .a-stand, .archie .a-foot { fill: var(--nj-case); stroke: var(--nj-key-edge); stroke-width: 4; stroke-linejoin: round; }
.archie .a-led { fill: #1fa774; }
.archie .a-zz { font: 800 18px var(--nj-font-display); fill: var(--nj-ink-2); opacity: 0; }
.archie[data-mood="offline"] .a-eye { opacity: 0; animation: none; }
.archie[data-mood="offline"] .a-sleep { opacity: 1; }
.archie .a-flat { fill: none; stroke: var(--nj-glow); stroke-width: 4; stroke-linecap: round; opacity: 0; }
.archie[data-mood="offline"] .a-mouth { opacity: 0; }
.archie[data-mood="offline"] .a-flat { opacity: 1; }
.archie[data-mood="offline"] .a-led { fill: var(--nj-coral); }
.archie[data-mood="offline"] .a-zz { opacity: 1; animation: nj-zz 2.6s ease-in-out infinite; }
.archie[data-mood="thinking"] .a-eyes { animation: nj-look 1.6s ease-in-out infinite; }
.archie[data-mood="happy"] .a-eye { transform: scaleY(.45); animation: none; }
.archie[data-mood="happy"] .archie-body { animation: nj-hop .6s var(--nj-spring) 2; transform-origin: 60px 110px; }
.archie[data-mood="waiting"] .a-led { animation: nj-breathe 1.2s infinite; fill: var(--nj-solder); }

/* skins: the colour a user picks for their agent */
.archie[data-skin="sky"] { --nj-screen: #12345c; --nj-glow: #8fd3ff; }
.archie[data-skin="grape"] { --nj-screen: #34205a; --nj-glow: #d6b8ff; }
.archie[data-skin="ember"] { --nj-screen: #4a1f0c; --nj-glow: #ffb36b; }
.archie[data-skin="bubble"] { --nj-screen: #5a1840; --nj-glow: #ffa8d8; }

@keyframes nj-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes nj-look { 0%, 100% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@keyframes nj-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } }
@keyframes nj-zz { 0%, 100% { transform: translateY(0); opacity: .9; } 50% { transform: translateY(-5px); opacity: .5; } }
@keyframes nj-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes nj-pop { from { transform: scale(.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nj-rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nj-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .nj *, .nj *::before, .nj *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- long text pages (/help, /legal): no inline <style>, so the strict CSP holds ---------- */
.nj-doc { max-width: 760px; margin: 0 auto; padding: 36px 20px 80px; line-height: 1.65; }
.nj-doc a { color: var(--nj-brand); overflow-wrap: anywhere; text-underline-offset: 3px; }
.nj-doc :is(p, li) a:not(.nj-mark) { display: inline-block; min-width: var(--nj-tap); text-align: center; padding-block: calc((var(--nj-tap) - 1lh) / 2); margin-block: calc((1lh - var(--nj-tap)) / 2); }
.nj-doc h1 { font-size: var(--nj-t-3); margin-top: var(--nj-s-5); }
.nj-doc h2 { font-size: var(--nj-t-2); border-bottom: 1px solid var(--nj-line); padding-bottom: 6px; margin-top: 36px; }
.nj-doc h3 { font-size: var(--nj-t-1); margin: 18px 0 4px; }
.nj-doc section { margin: 0 0 40px; }
.nj-doc :where(ul, ol) { margin: 6px 0 6px 18px; padding-left: 12px; }
.nj-doc :where(code, pre) { font-family: var(--nj-font-code); background: var(--nj-sunk); padding: 1px 5px; border-radius: 4px; }
.nj-doc pre { overflow-x: auto; }
.nj-doc small { color: var(--nj-ink-2); font-size: var(--nj-t--1); }
