/* Node Factory docs — visual identity taken from the game UI:
   deep navy canvas with "+" grid, dark cut-corner panels, brand orange header tabs,
   green circuit frames around node screens, resource colors from ResourceColorSettings. */
:root {
  --bg: #080a19;
  --bg-2: #0e1022;
  --panel: #14151c;
  --panel-2: #1b1c24;
  --panel-3: #25262e;
  --line: #2f3040;
  --text: #eceef6;
  --muted: #9aa0b8;
  --faint: #626883;
  --orange: #ec782c;
  --orange-2: #c15e1f;
  --orange-soft: rgba(236, 120, 44, .14);
  --green: #27ca81;
  --money: #48e84a;
  --research: #3fde91;
  --red: #cf2626;
  --cyan: #54f8ff;
  --yellow: #ffdc5e;
  --radius: 4px;
  --cut: 14px;
  --maxw: 1180px;
  --font-head: "Chakra Petch", "Segoe UI", sans-serif;
  --font-body: "Rajdhani", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  color: var(--text);
  font: 500 18px/1.55 var(--font-body);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(60, 70, 190, .22), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(236, 120, 44, .07), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M24 20v8M20 24h8' stroke='%23ffffff' stroke-opacity='.07' stroke-width='1'/%3E%3C/svg%3E");
  background-attachment: fixed, fixed, scroll;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; display: block; }
a { color: var(--orange); text-decoration: none; }
a:hover { color: #ff9a55; text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: clamp(2rem, 4.6vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-top: 2.2em; }
h3 { font-size: 1.25rem; margin-top: 1.6em; }
h2 .tag, h3 .tag { color: var(--orange); }
p { margin: 0 0 1em; }
strong, b { color: #fff; font-weight: 700; }
code, kbd { font-family: var(--font-mono); font-size: .86em; }
code { background: var(--panel-3); padding: .1em .4em; border-radius: 3px; color: #ffd2b3; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.hl { color: var(--orange); font-weight: 700; }
.money { color: var(--money); font-weight: 700; }
.research { color: var(--research); font-weight: 700; }

.skip { position: absolute; left: -999px; top: 0; background: var(--orange); color: #000; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(8, 10, 25, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header::after { /* orange accent bar like window headers */
  content: ""; position: absolute; left: 0; bottom: -1px; width: 220px; height: 2px;
  background: linear-gradient(90deg, var(--orange), transparent);
}
.nav-wrap { max-width: var(--maxw); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-family: var(--font-head); font-weight: 700; }
.brand:hover { text-decoration: none; color: #fff; }
.brand img { height: 34px; width: auto; }
.brand span { font-size: .8rem; color: var(--muted); font-weight: 500; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  color: var(--muted); font-family: var(--font-head); font-weight: 600; font-size: .92rem;
  padding: 8px 12px; border-radius: 3px; text-transform: uppercase; letter-spacing: .04em;
}
.nav a:hover { color: #fff; background: var(--panel-2); text-decoration: none; }
.nav a[aria-current="page"] { color: #fff; background: var(--orange-soft); box-shadow: inset 0 -2px 0 var(--orange); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: #fff; padding: 6px 10px; border-radius: 3px; font: inherit; cursor: pointer; }
@media (max-width: 920px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--bg-2); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
}

/* ---------------------------------------------------------------- layout */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
main { padding-bottom: 80px; }
.page-head { padding: 56px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.page-head p { color: var(--muted); max-width: 760px; font-size: 1.12rem; }
.eyebrow { font-family: var(--font-head); color: var(--orange); text-transform: uppercase; letter-spacing: .18em; font-size: .8rem; font-weight: 700; margin-bottom: 10px; display: block; }

.with-toc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; }
.toc { position: sticky; top: 90px; font-size: .95rem; border-left: 1px solid var(--line); padding-left: 14px; max-height: calc(100vh - 110px); overflow: auto; }
.toc strong { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; color: var(--faint); display: block; margin-bottom: 8px; }
.toc a { display: block; color: var(--muted); padding: 3px 0; }
.toc a:hover, .toc a.active { color: var(--orange); text-decoration: none; }
@media (max-width: 920px) { .with-toc { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 520px) { td.keys { white-space: normal; } th, td { padding: 8px 10px; } .panel { padding: 16px; } .stats { grid-template-columns: repeat(2, 1fr); } }

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 32px; align-items: center; }
.split.rev { grid-template-columns: .9fr 1.1fr; }
@media (max-width: 820px) { .split, .split.rev { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- panel (cut corners, orange tab) */
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  padding: 20px 22px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.panel::before { /* orange header tab */
  content: ""; position: absolute; top: 0; left: 0; width: 64px; height: 3px; background: var(--orange);
}
.panel::after { /* diagonal edge on the cut corner */
  content: ""; position: absolute; top: 0; right: 0; width: calc(var(--cut) * 1.414); height: 1px;
  background: var(--line); transform-origin: right top; transform: rotate(45deg) translateX(0);
}
.panel > :last-child { margin-bottom: 0; }
.panel h3:first-child, .panel h4:first-child { margin-top: 0; }
.panel.glow { border-color: rgba(236, 120, 44, .5); box-shadow: inset 0 0 40px rgba(236, 120, 44, .06); }

.callout { border-left: 3px solid var(--orange); background: var(--orange-soft); padding: 12px 16px; margin: 1.2em 0; border-radius: 0 var(--radius) var(--radius) 0; }
.callout.tip { border-color: var(--green); background: rgba(39, 202, 129, .1); }
.callout.warn { border-color: var(--red); background: rgba(207, 38, 38, .12); }
.callout > :last-child { margin-bottom: 0; }
.callout b:first-child { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .95rem;
  padding: 12px 22px; color: #0b0b12; background: var(--orange); border: 0; cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.btn:hover { background: #ff8d42; color: #000; text-decoration: none; }
.btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px var(--orange); }
.btn.ghost:hover { background: var(--orange-soft); color: #fff; }

/* ---------------------------------------------------------------- hero */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-bg { position: absolute; inset: 0; background: url("../img/hero.webp") center/cover no-repeat; opacity: .55; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,10,25,.2), var(--bg) 96%); }
.hero-in { position: relative; z-index: 1; padding: 72px 16px 64px; max-width: var(--maxw); margin: 0 auto; text-align: center; }
.hero-logo { width: min(560px, 90%); height: auto; margin: 0 auto 18px; filter: drop-shadow(0 8px 30px rgba(0,0,0,.6)); }
.hero p.lead { font-size: 1.3rem; max-width: 720px; margin: 0 auto 26px; color: #d7dbea; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-banner { margin: 42px auto 0; max-width: 900px; border: 1px solid var(--line); }

/* ---------------------------------------------------------------- media */
.media { position: relative; background: #000; border: 1px solid var(--line); }
.media video, .media img { width: 100%; height: auto; }
.media figcaption, figure figcaption { font-size: .9rem; color: var(--muted); padding: 8px 2px 0; background: var(--bg); }
figure { margin: 0 0 1.4em; }
.clip { aspect-ratio: 1 / 1; object-fit: cover; }
.shot { border: 1px solid var(--line); }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* ---------------------------------------------------------------- key caps */
kbd {
  display: inline-block; min-width: 1.9em; text-align: center;
  padding: 2px 8px; margin: 0 1px;
  font: 700 .82rem/1.5 var(--font-head); color: #fff; text-transform: uppercase;
  background: linear-gradient(180deg, #2d2e38, #1c1d25);
  border: 1px solid #454657; border-bottom-width: 3px; border-radius: 4px;
}
kbd.mouse { border-color: var(--orange-2); color: var(--orange); }
.plus { color: var(--faint); margin: 0 2px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--panel); margin: 1em 0 1.6em; }
table { width: 100%; border-collapse: collapse; font-size: .98rem; }
th, td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--font-head); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; white-space: nowrap; }
th[data-sort] { cursor: pointer; }
th[data-sort]:hover { color: #fff; }
th[aria-sort="ascending"]::after { content: " ▲"; color: var(--orange); }
th[aria-sort="descending"]::after { content: " ▼"; color: var(--orange); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.keys { white-space: nowrap; }

/* ---------------------------------------------------------------- resource chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 5px; margin: 2px 2px;
  border-radius: 999px; font-weight: 600; font-size: .9rem; white-space: nowrap;
  background: color-mix(in srgb, var(--c, #888) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, #888) 55%, transparent);
  color: #fff;
}
.chip .amt { font-family: var(--font-head); color: var(--c); filter: brightness(1.35); }
.dot { width: 12px; height: 12px; flex: none; background: var(--c, #888); box-shadow: 0 0 8px var(--c); }
.dot.circle { border-radius: 50%; }
.dot.square { border-radius: 2px; }
.dot.rotate { border-radius: 2px; transform: rotate(45deg) scale(.85); }
.dot.triangle { clip-path: polygon(50% 0, 100% 100%, 0 100%); box-shadow: none; }
.dot.octa { clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); box-shadow: none; }
.swatch { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- node cards (styled like in-game nodes) */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.search {
  flex: 1 1 240px; background: var(--panel); border: 1px solid var(--line); color: #fff;
  padding: 10px 14px; font: 600 1rem var(--font-body); border-radius: 3px;
}
.search:focus { outline: none; border-color: var(--orange); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line); padding: 7px 12px; cursor: pointer;
  font: 700 .82rem var(--font-head); text-transform: uppercase; letter-spacing: .05em; border-radius: 3px;
}
.filter:hover { color: #fff; }
.filter[aria-pressed="true"] { background: var(--orange); color: #000; border-color: var(--orange); }

.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.node { background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; scroll-margin-top: 90px; }
.node:target { outline: 2px solid var(--orange); }
.node-head {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, #f08a44, var(--orange) 55%, var(--orange-2));
  color: #1a0d04; padding: 6px 12px; font: 700 1rem var(--font-head);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 100%, 0 100%);
  margin-right: 28%;
}
.node-head .cat { margin-left: auto; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; opacity: .75; }
.node-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.node-top { display: flex; gap: 14px; align-items: flex-start; }
.screen {
  flex: none; width: 76px; height: 76px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #16304a, #070c18 75%);
  border: 2px solid #1f7a4a; box-shadow: 0 0 0 3px #0c2217, 0 0 16px rgba(39, 202, 129, .25), inset 0 0 18px rgba(84, 248, 255, .18);
  border-radius: 6px;
}
.screen img { width: 46px; height: 46px; filter: drop-shadow(0 0 6px rgba(84, 248, 255, .55)); }
.node-desc { font-size: .98rem; color: #cfd3e3; margin: 0; }
.recipe { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px; background: #0c0d14; border: 1px solid var(--line); }
.recipe .arrow { color: var(--orange); font-weight: 700; margin: 0 4px; }
.recipe .none { color: var(--faint); font-size: .9rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--panel-2); padding: 6px 8px; border: 1px solid var(--line); }
.stat b { display: block; font: 700 1rem var(--font-head); }
.stat span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.node details { border-top: 1px dashed var(--line); padding-top: 8px; font-size: .95rem; }
.node summary { cursor: pointer; color: var(--orange); font-family: var(--font-head); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.node details dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; }
.node dt { color: var(--muted); }
.node dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.heat-cold { color: var(--cyan); } .heat-ok { color: #54ff5e; } .heat-warm { color: var(--yellow); } .heat-hot { color: #ff463c; }

/* ---------------------------------------------------------------- flow diagram */
.flow { width: 100%; height: auto; }
.flow text { font-family: var(--font-head); font-weight: 700; fill: #fff; }
.flow .sub { font-family: var(--font-body); font-weight: 600; fill: var(--muted); }

/* ---------------------------------------------------------------- formulas & calculators */
.eq { background: #0c0d14; border: 1px solid var(--line); border-left: 3px solid var(--orange); padding: 14px 18px; margin: 12px 0 16px; overflow-x: auto; }
.eq .katex-display { margin: .3em 0; }
.eq-note { font-size: .92rem; color: var(--muted); margin-top: -6px; }
.src { font-family: var(--font-mono); font-size: .75rem; color: var(--faint); }
.calc { display: grid; gap: 12px; }
.calc label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); font-weight: 600; }
.calc input, .calc select {
  background: #0c0d14; border: 1px solid var(--line); color: #fff; padding: 9px 12px; font: 700 1rem var(--font-head); border-radius: 3px; width: 100%;
}
.calc input:focus, .calc select:focus { outline: none; border-color: var(--orange); }
.calc .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.result { background: var(--orange-soft); border: 1px solid rgba(236, 120, 44, .45); padding: 12px 14px; font-family: var(--font-head); }
.result big { display: block; font-size: 1.6rem; color: #fff; }
.result small { color: var(--muted); font-family: var(--font-body); }

/* ---------------------------------------------------------------- heat bar */
.heatbar { display: flex; height: 34px; border: 1px solid var(--line); margin: 12px 0 4px; font: 700 .72rem var(--font-head); }
.heatbar div { display: grid; place-items: center; color: #000; text-align: center; line-height: 1.1; padding: 0 2px; }
.heatlabels { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }

/* ---------------------------------------------------------------- steps & tips */
.steps { counter-reset: s; display: grid; gap: 22px; }
.step { display: grid; grid-template-columns: 260px 1fr; gap: 22px; align-items: center; }
.step h3 { margin-top: 0; }
.step h3::before { counter-increment: s; content: counter(s, decimal-leading-zero); color: var(--orange); margin-right: 10px; font-size: 1rem; vertical-align: middle; }
@media (max-width: 720px) { .step { grid-template-columns: 1fr; } }
.tip-card h3 { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; margin-top: 0; }
.tip-card h3 img { width: 26px; height: 26px; }
.badge { display: inline-block; font: 700 .7rem var(--font-head); padding: 2px 8px; text-transform: uppercase; letter-spacing: .08em; background: var(--panel-3); color: var(--muted); border-radius: 2px; }
.badge.early { background: rgba(39, 202, 129, .18); color: var(--green); }
.badge.mid { background: rgba(255, 220, 94, .14); color: var(--yellow); }
.badge.late { background: rgba(207, 38, 38, .2); color: #ff7a7a; }
.badge.prestige { background: rgba(214, 104, 31, .22); color: #ffae70; }

.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature img { width: 40px; height: 40px; flex: none; padding: 7px; background: var(--orange-soft); border: 1px solid rgba(236,120,44,.4); }
.feature h3 { margin: 0 0 4px; font-size: 1.1rem; }
.feature p { margin: 0; color: var(--muted); font-size: 1rem; }
.feature a { color: inherit; }

/* ---------------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); padding: 36px 0; color: var(--muted); font-size: .95rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: space-between; }
.site-footer img { height: 30px; width: auto; opacity: .85; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--orange); }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }

.to-top { position: fixed; right: 16px; bottom: 16px; width: 42px; height: 42px; display: grid; place-items: center; background: var(--orange); color: #000; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { text-decoration: none; color: #000; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print { .site-header, .site-footer, .toc, .to-top { display: none; } body { background: #fff; color: #000; } }

/* ---------------------------------------------------------------- Steam buy buttons */
.steam-btn {
  display: inline-flex; align-items: center; gap: 8px; flex: none; margin-left: 10px;
  padding: 8px 14px; color: #fff; font: 700 .85rem var(--font-head); text-transform: uppercase; letter-spacing: .05em;
  background: linear-gradient(180deg, #2a475e, #1b2838); border: 1px solid #66c0f4;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.steam-btn:hover { color: #fff; text-decoration: none; background: linear-gradient(180deg, #3d6c8d, #2a475e); }
.steam-btn img { width: 18px; height: 18px; }
@media (max-width: 920px) { .steam-btn { margin-left: 8px; } }
@media (max-width: 420px) { .steam-btn span { display: none; } .steam-btn { padding: 8px 10px; } }
.btn.steam { background: linear-gradient(180deg, #75b022, #588a1b); color: #fff; }
.btn.steam:hover { background: linear-gradient(180deg, #8ed12a, #6aa51f); color: #fff; }
.btn.steam img { width: 20px; height: 20px; }
.steam-cta { display: grid; grid-template-columns: 360px 1fr; gap: 32px; align-items: center; margin-top: 56px; padding: 32px; }
.steam-cta h2 { margin-top: 0; }
@media (max-width: 760px) { .steam-cta { grid-template-columns: 1fr; text-align: center; } .steam-cta img { margin: 0 auto; max-width: 280px; } }
