/* Base styles and the reusable parts of the design system (see DESIGN.md):
   .panel (iron plate), .paper, .screen (scrap-terminal), .nameplate, .tag, .hazard, .caution, .taped, .note-plate, .btn.
   Every value comes from tokens.css. */

/* Bundled fonts (SIL Open Font License 1.1, licences next to the files). No CDN: works offline. */
@font-face {
  font-family: "Big Shoulders Stencil";
  src: url("/fonts/big-shoulders-stencil-latin-wght.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-hyperlegible-next-latin-wght.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("/fonts/atkinson-hyperlegible-mono-latin-wght.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--iron-900);
  background-image: var(--tex-grain), linear-gradient(180deg, var(--iron-850), var(--iron-900) 420px);
  color: var(--dust);
  font: 17px/var(--leading) var(--font-body);
  font-optical-sizing: auto;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 750; line-height: var(--leading-tight); margin: 0 0 0.5em; text-wrap: balance; }
h1 { font-size: var(--text-3xl); letter-spacing: 0.01em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p, li, dd { text-wrap: pretty; }
p { margin: 0 0 0.9em; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.92em; }
code { background: var(--iron-950); border: 1px solid var(--iron-600); border-radius: 2px; padding: 0.05em 0.35em; overflow-wrap: anywhere; }
pre { background: var(--iron-950); border: 1px solid var(--iron-600); border-radius: var(--radius-plate); padding: var(--space-3) var(--space-4); overflow-x: auto; line-height: 1.45; }
pre code { background: none; border: 0; padding: 0; overflow-wrap: normal; }
ul, ol { padding-left: 1.3em; margin: 0 0 0.9em; }
li { margin: 0.2em 0; }
strong { color: var(--dust-bright); font-weight: 700; }
hr { border: 0; height: 2px; background: var(--iron-600); margin: var(--space-5) 0; }
img, svg { max-width: 100%; }

/* Keyboard focus: sky-green ring on iron, ink ring on paper */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.paper :focus-visible, .paper:focus-visible { outline-color: var(--focus-on-paper); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ── Iron plate: four rivets, a bevel, a brushed surface ───────────────────── */
.panel {
  position: relative;
  background-color: var(--iron-800);
  background-image: var(--tex-brushed);
  border: var(--border-plate);
  border-radius: var(--radius-plate);
  padding: var(--space-5) var(--space-5);
  box-shadow: var(--shadow-plate);
}
.panel::before {
  content: "";
  position: absolute; inset: 6px;
  pointer-events: none;
  --r: radial-gradient(circle at 50% 50%, var(--rivet) 0 2px, var(--iron-950) 2.5px 3.5px, transparent 4px);
  background: var(--r) top left / 8px 8px no-repeat, var(--r) top right / 8px 8px no-repeat,
              var(--r) bottom left / 8px 8px no-repeat, var(--r) bottom right / 8px 8px no-repeat;
}
.panel > :last-child { margin-bottom: 0; }
.panel h2 { color: var(--rust-text); }

/* ── Paper: what characters hand you ────────────────────────────────────── */
.paper {
  position: relative;
  background-color: var(--paper);
  background-image: var(--tex-grain);
  color: var(--ink);
  border-radius: var(--radius-paper);
  box-shadow: var(--shadow-paper);
}
.paper strong { color: var(--ink); }
.paper a { color: var(--ink-link); }
.paper a.btn { color: var(--on-rust); text-decoration: none; }
.paper a.btn.secondary { color: var(--dust); }
.paper code { background: #2b1f1314; border-color: #2b1f1333; color: var(--ink); }
.paper .muted, .paper .faint { color: var(--ink-dim); }

/* ── Scrap-terminal screen: teal lives here only ───────────────────────── */
.screen {
  position: relative;
  background-color: var(--screen);
  background-image: var(--tex-scanlines);
  color: var(--neon);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  border: 1px solid var(--screen-edge);
  border-radius: var(--radius-screen);
  box-shadow: inset 0 0 0 4px var(--iron-950), inset 0 0 24px #000000b3, 0 0 0 3px var(--iron-700), var(--shadow-press);
  padding: var(--space-4) var(--space-5);
}
.screen a { color: var(--neon); }
.screen .bad { color: var(--alarm); }

/* ── Nameplate: the real n8n term, in English ──────────────────────────── */
.nameplate {
  display: inline-block;
  padding: 2px 10px;
  font: 700 var(--text-sm)/1.35 var(--font-body);
  color: var(--steel-ink);
  background: linear-gradient(180deg, #d4cebf, var(--steel));
  border: 1px solid #6e675a;
  border-radius: 2px;
  box-shadow: inset 0 1px 0 #ffffff80, 0 1px 0 #00000080;
}

/* ── Stencil label (status words) ─────────────────────────────────────── */
.tag {
  display: inline-block; vertical-align: middle;
  padding: 0 8px;
  font: 700 var(--text-sm)/1.5 var(--font-display);
  letter-spacing: 0.02em;
  border: 2px solid currentColor;
  border-radius: 2px;
}
.tag.neon { color: var(--neon); } .tag.rust { color: var(--rust-text); } .tag.sky { color: var(--sky); }
.tag.dim { color: var(--dust-faint); } .tag.amber { color: var(--amber); }

/* ── Hazard tape: the game's signature. Yellow and black, in small doses ── */
.hazard { background: var(--tex-hazard); }
/* A caution sign: black stencil on amber, between two strips of tape */
.caution {
  color: var(--ink);
  border-block: 6px solid transparent;
  background: linear-gradient(var(--amber), var(--amber)) padding-box, var(--tex-hazard) border-box;
}
/* A plate with a strip of tape along its top edge */
.taped::after {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 6px;
  border-radius: var(--radius-plate) var(--radius-plate) 0 0;
  background: var(--tex-hazard);
  pointer-events: none;
}
.taped::before { top: 10px; } /* the top rivets clear the tape */
/* Every page title signs off with a strip of tape, as wide as its text */
main h1 { width: fit-content; }
main h1::after {
  content: "";
  display: block;
  height: 8px; margin-top: var(--space-3);
  background: var(--tex-hazard);
}
::selection { background: var(--amber); color: var(--ink); }

/* ── Note plate: icon + text on a small plate (needs the companion, which URL...) */
.note-plate {
  display: flex; gap: var(--space-3); align-items: flex-start;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--iron-850);
  border: 1px dashed var(--amber);
  border-radius: var(--radius-plate);
}
.note-plate > .icon { color: var(--amber); flex: none; margin-top: 3px; }
.note-plate > div > :last-child, .note-plate > p:last-child { margin-bottom: 0; }

/* In-world term next to the real n8n term */
.term-pair { color: var(--dust-dim); font-size: 0.92em; }

.muted { color: var(--dust-dim); }
.faint { color: var(--dust-faint); }
.ok { color: var(--sky); }
.screen .ok { color: var(--neon); }
.bad { color: var(--alarm); }

/* ── Buttons: rust-painted plates with stencilled words ───────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 6px 20px;
  font: 750 var(--text-lg)/1.1 var(--font-display); letter-spacing: 0.02em;
  text-align: center; text-decoration: none;
  color: var(--on-rust); background: var(--rust);
  border: 1px solid var(--rust-deep); border-radius: var(--radius-control);
  box-shadow: inset 0 1px 0 #ffffff26, 0 3px 0 var(--rust-deep), 0 4px 0 var(--iron-950);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.btn:hover { background: var(--rust-deep); color: var(--on-rust); text-decoration: none; }
.btn:active { transform: translateY(3px); box-shadow: inset 0 1px 0 #ffffff1a, 0 0 0 var(--rust-deep), 0 1px 0 var(--iron-950); }
.btn:disabled { color: var(--dust-faint); background: var(--iron-700); border-color: var(--iron-600); box-shadow: none; cursor: not-allowed; transform: none; }
.btn.secondary, .btn.rust.secondary {
  color: var(--dust); background: var(--iron-700); border-color: var(--iron-500);
  box-shadow: inset 0 1px 0 #ffffff14, 0 3px 0 var(--iron-950);
}
.btn.secondary:hover { background: var(--iron-600); color: var(--dust); }
.btn.secondary:active { box-shadow: inset 0 1px 0 #ffffff14, 0 0 0 var(--iron-950); }
.btn.secondary:disabled { color: var(--dust-faint); background: var(--iron-800); }
/* The amber key: leaves a place (the X over n8n). Rust stays the main action. */
.btn.amber { color: var(--ink); background: var(--amber); border-color: var(--amber-deep); box-shadow: inset 0 1px 0 #ffffff40, 0 3px 0 var(--amber-deep), 0 4px 0 var(--iron-950); }
.btn.amber:hover { color: var(--ink); background: var(--coin-light); }
.btn.amber:active { box-shadow: inset 0 1px 0 #ffffff40, 0 0 0 var(--amber-deep), 0 1px 0 var(--iron-950); }
.btn.small { min-height: 36px; padding: 4px 14px; font-size: var(--text-md); }
.btn .icon { flex: none; }

/* Inline SVG icons (components/Icon.svelte) */
.icon { width: 1em; height: 1em; vertical-align: -0.125em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
input[type="text"], input[type="url"], input[type="search"], input[type="email"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  font: inherit; color: var(--dust);
  background: var(--iron-950); border: 1px solid var(--iron-500); border-radius: var(--radius-control);
  box-shadow: inset 0 2px 0 #00000080;
}
input::placeholder { color: var(--dust-faint); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
label { display: block; font-weight: 700; margin-bottom: 6px; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--rust); }

details > summary { cursor: pointer; }
details > summary:hover { color: var(--dust); }

/* Motion: everything settles instantly for people who asked for less movement */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
.icon-play path, .icon-stop path { fill: currentColor; stroke-width: 1.5; }
