/*
 * forgecode.uk: the colours are Forge's own. Molten is the default; Plain is
 * the app's black-and-white high-contrast theme. Heat colours are kept for what
 * is active, running or connected, as in the app.
 */

/* Fonts are served from this site (no requests to Google). All four are SIL Open Font License. */
@font-face { font-family: 'Big Shoulders Display'; font-style: normal; font-weight: 700 900; font-display: swap; src: url(fonts/big-shoulders-display.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/ibm-plex-sans.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-italic.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/jetbrains-mono.woff2) format('woff2'); }


:root {
  color-scheme: dark;
  --bg: #120c0a;
  --panel: #170e0b;
  --raised: #1d120e;
  --border: #3a2017;
  --line: #5a3322;
  --ink: #f3e2d4;
  --muted: #b39787;
  --heat-1: #ffcf5c;
  --heat-2: #ffb02e;
  --heat-3: #ff6a1a;
  --heat-4: #e8431d;
  --on-heat: #1a0904;
  --ok: #9fcf7a;
  --link: #ffc857;
  --glow: drop-shadow(0 0 10px #ff6a1a99);
  --spark-glow: drop-shadow(0 0 5px #ffb02e);
  --grid: #ff6a1a12;

  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --text: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --code: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  --gutter: clamp(16px, 4vw, 56px);
}

:root[data-theme="plain"] {
  --bg: #000000;
  --panel: #000000;
  --raised: #000000;
  --border: #8a8a8a;
  --line: #ffffff;
  --ink: #ffffff;
  --muted: #d6d6d6;
  --heat-1: #ffffff;
  --heat-2: #ffffff;
  --heat-3: #ffffff;
  --heat-4: #ffffff;
  --on-heat: #000000;
  --ok: #ffffff;
  --link: #ffffff;
  --glow: none;
  --spark-glow: none;
  --grid: transparent;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--heat-1); }

:focus-visible { outline: 2px solid var(--heat-1); outline-offset: 3px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 20; background: var(--heat-2); color: var(--on-heat); padding: 8px 12px; }

h1, h2 { font-family: var(--display); font-weight: 900; text-transform: uppercase; margin: 0; }

/* ======================= top bar ======================= */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font: 900 28px/1 var(--display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mark { width: 28px; height: 28px; fill: var(--ink); }
.mark .mark-heat { fill: var(--heat-3); }

.top nav { display: flex; gap: 20px; margin-left: auto; font-size: 15px; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover { color: var(--ink); }

.theme-toggle {
  background: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 12px;
  font: 500 14px var(--text);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--heat-2); }

@media (max-width: 900px) {
  .top { flex-wrap: wrap; }
  .top nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; gap: 16px; }
  .theme-toggle { margin-left: auto; }
}

/* ======================= hero ======================= */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 4vw, 64px);
  align-items: center;
  max-width: 1360px;
  margin: 0 auto;
  padding: clamp(40px, 7vw, 104px) var(--gutter) clamp(48px, 7vw, 96px);
}

.hero h1 {
  font-size: clamp(52px, 7vw, 104px);
  line-height: 0.9;
  letter-spacing: -0.005em;
  margin-bottom: 28px;
}

.lede { font-size: clamp(18px, 1.7vw, 21px); max-width: 32em; margin: 0 0 30px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.aside { color: var(--muted); font-size: 15px; margin: 22px 0 0; }

.btn {
  display: inline-block;
  padding: 13px 22px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: 600 16px var(--text);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--heat-2); color: var(--ink); }
.btn-hot { background: var(--heat-3); border-color: var(--heat-3); color: var(--on-heat); }
.btn-hot:hover { background: var(--heat-2); border-color: var(--heat-2); color: var(--on-heat); }
.btn-small { padding: 7px 14px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* the little Forge window */
.window {
  border: 1px solid var(--line);
  background: var(--panel);
  scroll-margin-top: 90px;
}
.win-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.win-mark { font: 900 18px/1 var(--display); text-transform: uppercase; letter-spacing: 0.06em; color: var(--heat-2); }
.win-tasks { display: flex; gap: 2px; }
.win-tasks span { padding: 3px 10px; color: var(--muted); }
.win-tasks .on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--heat-3); }
.win-run {
  margin-left: auto;
  background: var(--heat-3);
  color: var(--on-heat);
  border: 0;
  border-radius: 0;
  padding: 5px 14px;
  font: 600 13px var(--text);
  cursor: pointer;
}
.win-run:hover { background: var(--heat-2); }
.win-run:disabled { opacity: 0.7; cursor: default; }

.win-graph {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  border-bottom: 1px solid var(--border);
}
.win-graph svg { display: block; width: 100%; height: auto; }

.g-wires use { fill: none; stroke: var(--line); stroke-width: 1.6; }
.g-wires .box-wire { stroke: var(--heat-3); stroke-dasharray: 5 4; }
.g-wires .box-wire.live { stroke: var(--heat-1); stroke-width: 2.6; stroke-dasharray: none; filter: var(--spark-glow); }

.g-node rect { fill: var(--raised); stroke: var(--line); stroke-width: 1.2; transition: stroke 0.5s, filter 0.5s; }
.g-node text { fill: var(--ink); font: 600 14px var(--code); }
.g-box rect { fill: var(--bg); stroke: var(--heat-3); stroke-width: 1.5; }
.g-box text { fill: var(--heat-2); font-family: var(--text); }
.g-dot { fill: var(--bg); stroke: var(--line); transition: fill 0.3s; }
.g-box.ok .g-dot { fill: var(--ok); stroke: none; }
.g-node.at rect { stroke: var(--heat-1); stroke-width: 2.6; filter: var(--glow); transition: none; }
.g-node.was rect { stroke: var(--heat-3); }
.spark { fill: var(--heat-1); filter: var(--spark-glow); }

:root[data-theme="plain"] .g-node.at rect { stroke-width: 3.5; }

.win-out {
  margin: 0;
  min-height: 7.6em;
  padding: 10px 14px;
  font: 13px/1.6 var(--code);
  color: var(--muted);
  white-space: pre-wrap;
}
.win-out .ok { color: var(--ok); }
.win-out .out-cmd { color: var(--ink); }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
}

/* ======================= sections ======================= */
.band { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--panel); }
.band-inner { max-width: 1240px; margin: 0 auto; padding: clamp(48px, 7vw, 96px) var(--gutter); }

.what { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.what h2 { font-size: clamp(48px, 7vw, 96px); line-height: 0.9; }
.what-text p { margin: 0 0 18px; max-width: 62ch; }
.what-text p:last-child { margin-bottom: 0; }
@media (max-width: 860px) { .what { grid-template-columns: 1fr; } }

.feature {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(56px, 8vw, 112px) var(--gutter) 0;
  scroll-margin-top: 70px;
}
.feature:last-of-type { padding-bottom: clamp(56px, 8vw, 112px); }
.feature h2 {
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.9;
  margin-bottom: 24px;
  max-width: 18ch;
  text-wrap: balance;
}
.feature-text { max-width: 64ch; margin: 0 0 36px; font-size: 18px; }


/* ======================= API box demo ======================= */
.apibox {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  border: 1px solid var(--line);
  background: var(--panel);
}
.ab-settings { padding: 18px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.ab-head { font: 900 26px/1 var(--display); text-transform: uppercase; color: var(--heat-2); letter-spacing: 0.02em; }
.ab-row { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.ab-field {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  padding: 5px 8px;
  font: 13px var(--code);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ab-method { color: var(--heat-2); font-weight: 600; margin-right: 8px; }
.ab-test { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ab-result { font: 13px var(--code); color: var(--ok); }
.ab-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.ab-fields legend { font-size: 14px; color: var(--muted); padding: 0; margin-bottom: 6px; }
.ab-fields label { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; font-size: 14px; cursor: pointer; }
.ab-fields label.nested { padding-left: 26px; }
.ab-fields input { accent-color: var(--heat-3); margin: 0; transform: translateY(1px); }
.ab-fields .name { font-family: var(--code); }
.ab-fields .sample { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ab-empty { color: var(--muted); font-size: 14px; margin: 0; }

.ab-output { display: flex; flex-direction: column; min-width: 0; }
.ab-tab { padding: 6px 14px; font: 12px var(--code); color: var(--muted); border-bottom: 1px solid var(--border); background: var(--raised); }
.ab-code {
  margin: 0;
  padding: 14px;
  min-height: 300px;
  overflow: auto;
  font: 12.5px/1.6 var(--code);
  color: var(--ink);
  background: var(--bg);
}
.ab-code .kw { color: var(--heat-2); }
.ab-code .str { color: var(--ok); }
.ab-code .com { color: var(--muted); }
.ab-code .changed { background: #ff6a1a26; }
:root[data-theme="plain"] .ab-code .changed { background: none; text-decoration: underline; }
.ab-csv { padding: 12px 14px; overflow-x: auto; background: var(--bg); }
.ab-csv table { border-collapse: collapse; font: 12.5px var(--code); }
.ab-csv th, .ab-csv td { border: 1px solid var(--border); padding: 3px 8px; text-align: left; white-space: nowrap; }
.ab-csv th { color: var(--heat-2); }

@media (max-width: 900px) {
  .apibox { grid-template-columns: 1fr; }
  .ab-settings { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ======================= tasks ======================= */
.tasks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.task { margin: 0; }
.task figcaption { font-size: 15px; color: var(--muted); margin-top: 10px; }
.task figcaption strong { display: block; color: var(--ink); font: 700 24px/1.1 var(--display); text-transform: uppercase; }

.mini {
  display: grid;
  aspect-ratio: 4 / 3;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--border);
}
.mini .p {
  background: var(--bg);
  font: normal 10px var(--code);
  color: var(--muted);
  padding: 4px;
  overflow: hidden;
}
.mini .p.hot { color: var(--heat-2); box-shadow: inset 0 0 0 1px var(--heat-3); }
.mini-code { grid-template: "side main right" 3fr "side drawer right" 1fr / 1fr 2.4fr 1.1fr; }
.mini-connect { grid-template: "side main right" 3fr "drawer drawer drawer" 1fr / 1fr 3fr 0.9fr; }
.mini-debug { grid-template: "main right" 3fr "drawer drawer" 1fr / 1.7fr 1fr; }
.mini-run { grid-template: "main right" 3fr "drawer drawer" 1.2fr / 1.5fr 1fr; }
.side { grid-area: side; }
.main { grid-area: main; }
.right { grid-area: right; }
.drawer { grid-area: drawer; }

@media (max-width: 900px) { .tasks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .tasks { grid-template-columns: 1fr; } }

/* ======================= roadmap ======================= */
.tiers { list-style: none; margin: 0; padding: 0; counter-reset: tier; }
.tier {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 96px;
  gap: 20px;
  align-items: start;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  counter-increment: tier;
}
.tier:last-child { border-bottom: 1px solid var(--border); }
.tier::before {
  content: counter(tier);
  font: 900 56px/0.9 var(--display);
  color: var(--line);
}
.tier.full::before { color: var(--heat-3); }
.tier h3 { font: 700 26px/1.1 var(--display); text-transform: uppercase; margin: 0 0 4px; }
.tier p { margin: 0 0 12px; color: var(--muted); font-size: 15px; max-width: 70ch; }
.tier .count { font: 600 15px var(--code); color: var(--muted); text-align: right; padding-top: 6px; }
.squares { display: flex; flex-wrap: wrap; gap: 4px; }
.sq { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--line); vertical-align: -1px; }
.sq.done { background: var(--heat-3); border-color: var(--heat-3); }
.legend { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.legend .sq:nth-child(2) { margin-left: 14px; }
@media (max-width: 640px) {
  .tier { grid-template-columns: 40px minmax(0, 1fr); }
  .tier::before { font-size: 40px; }
  .tier .count { grid-column: 2; text-align: left; padding: 0; }
}

/* ======================= build ======================= */
.steps { margin: 0 0 32px; padding-left: 1.4em; max-width: 64ch; }
.steps li { padding-left: 6px; margin-bottom: 14px; }
.steps li::marker { font: 900 22px var(--display); color: var(--heat-3); }
.steps p { margin: 0 0 8px; }
.cmd {
  margin: 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  font: 14px/1.6 var(--code);
  overflow-x: auto;
}

/* ======================= footer ======================= */
.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 28px var(--gutter);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 15px;
}
.foot p { margin: 0; }
.foot .privacy { flex-basis: 100%; order: 3; font-size: 14px; }

/* ======================= reduced motion ======================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .g-node rect, .g-dot { transition: none; }
  #sparks { display: none; }
}

.download-os { font-family: var(--display); text-transform: uppercase; font-size: 28px; margin: 28px 0 8px; }
.steps code { font-family: var(--code); font-size: 0.9em; padding: 1px 5px; border: 1px solid var(--border); }

.steps .note { color: var(--muted); font-size: 15px; }
