/* Duke's Satisfactory — FICSIT industrial theme.
   No external fonts/assets (offline + Docker safe). System fonts, uppercase
   accents and FICSIT orange evoke the in-game HUD. */
:root {
  color-scheme: dark;
  --bg:        #0e1013;
  --bg-panel:  #171a1f;
  --bg-panel2: #1d2127;
  --line:      #2a2f37;
  --line-hi:   #3a414c;
  --orange:    #f89b3c;   /* FICSIT primary */
  --orange-dk: #c9761f;
  --amber:     #ffc061;
  --text:      #e7e9ec;
  --muted:     #9aa4b2;
  --dim:       #6b7480;
  --good:      #57c060;
  --bad:       #e05a4d;
  --hazard: repeating-linear-gradient(-45deg, #f89b3c 0 10px, #1a1206 10px 20px);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -10%, #1a1e24 0%, var(--bg) 60%) fixed;
  color: var(--text);
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .8rem 1.2rem;
  background: linear-gradient(180deg, #14171c, #111318);
  border-bottom: 2px solid var(--orange-dk);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.ficsit-mark { color: var(--orange); font-size: 1.5rem; text-shadow: 0 0 12px rgba(248,155,60,.5); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  font-size: 1.05rem; color: #fff;
}
.brand-hint { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint-label { color: var(--orange); font-weight: 700; }
.status { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.pill {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--line-hi);
}
.pill-unknown { color: var(--dim); }
.pill-online  { color: var(--good); border-color: rgba(87,192,96,.5); background: rgba(87,192,96,.08); }
.pill-offline { color: var(--bad);  border-color: rgba(224,90,77,.5);  background: rgba(224,90,77,.08); }
.count { font-weight: 700; color: var(--amber); }
.updated { font-size: 11.5px; color: var(--dim); }

main { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }

/* Brandmark hero */
.brandmark { text-align: center; margin: .5rem 0 1.5rem; }
.brandmark-logo { max-width: 300px; width: 60%; height: auto; filter: drop-shadow(0 4px 16px rgba(0,0,0,.5)); }
.brandmark-logo.missing { display: none; }

/* Card grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card {
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel2));
  border: 1px solid var(--line);
  border-top: 2px solid var(--orange-dk);
  border-radius: 6px; padding: 0;
  overflow: hidden;
}
.card h3 {
  margin: 0; padding: .6rem .9rem;
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--orange); background: rgba(248,155,60,.06);
  border-bottom: 1px solid var(--line);
}
.card .body { padding: .8rem .9rem; }

/* Rows / stats */
.row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.row:last-child { border-bottom: none; }
.k { color: var(--muted); }
.v { font-weight: 700; text-align: right; }
.v.big { font-size: 1.35rem; color: var(--amber); }
.muted { color: var(--dim); }
.pending {
  color: var(--dim); font-size: 13px; display: flex; align-items: center; gap: .5rem;
}
.pending::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--hazard); flex-shrink: 0; }

.player-item { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 6px var(--good); }
.player-item .hp { margin-left: auto; color: var(--muted); font-size: 12px; }

/* Production list */
.prod-list { margin-top: .5rem; }
.prod-list.scroll { max-height: 230px; overflow-y: auto; scrollbar-gutter: stable; padding-right: 4px; }
.alt-list { max-height: 240px; overflow-y: auto; scrollbar-gutter: stable; padding-right: 4px; }
.prod-item { display: flex; justify-content: space-between; gap: .8rem; padding: .25rem 0; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 13px; }
.prod-item:last-child { border-bottom: none; }
.pi-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-rate { color: var(--amber); font-weight: 600; white-space: nowrap; }
.pi-pct { color: var(--dim); font-weight: 400; font-size: 11px; }

/* Alert / ok lines */
.alert { margin-top: .6rem; padding: .35rem .5rem; border-radius: 4px; font-size: 12.5px; font-weight: 600;
  color: var(--bad); background: rgba(224,90,77,.1); border: 1px solid rgba(224,90,77,.4); }
.ok-line { margin-top: .6rem; font-size: 12px; color: var(--good); }

/* Wide card (progression) */
.card.wide { grid-column: 1 / -1; margin-bottom: 1rem; }

/* Progress bar */
.bar { height: 6px; background: #0c0e11; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; margin-top: .35rem; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--orange-dk), var(--orange)); }

/* Space Elevator */
.se-head { font-weight: 700; color: var(--amber); margin: .2rem 0 .5rem; }
.se-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem 1rem; margin-bottom: 1rem; }
.se-row { display: flex; justify-content: space-between; font-size: 13px; }

/* Tech tiers */
.tiers-head { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .8rem 0 .5rem; }
.tiers-head.sub { color: var(--dim); }
.tier-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.tier { min-width: 56px; text-align: center; padding: .4rem .5rem; border-radius: 5px; border: 1px solid var(--line); }
.tier-n { font-weight: 800; font-size: 13px; }
.tier-frac { font-size: 11px; color: var(--muted); }
.tier-done { background: rgba(87,192,96,.12); border-color: rgba(87,192,96,.5); }
.tier-done .tier-n { color: var(--good); }
.tier-partial { background: rgba(248,155,60,.12); border-color: rgba(248,155,60,.5); }
.tier-partial .tier-n { color: var(--orange); }
.tier-none { opacity: .55; }

/* Milestones (pending detail + done chips) */
.ms-pending { padding: .5rem .6rem; margin-bottom: .4rem; background: rgba(248,155,60,.06); border: 1px solid var(--line); border-left: 3px solid var(--orange); border-radius: 4px; }
.ms-name { font-size: 13px; margin-bottom: .3rem; }
.ms-items { display: flex; flex-wrap: wrap; gap: .3rem .6rem; }
.mi { font-size: 12px; color: var(--muted); }
.mi b { color: var(--amber); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { font-size: 11.5px; padding: .2rem .5rem; border-radius: 999px; border: 1px solid var(--line); }
.chip-done { color: var(--good); background: rgba(87,192,96,.08); border-color: rgba(87,192,96,.35); }
.chip-pending { color: var(--muted); }

/* Footer / release notes */
.foot { margin-top: 1.5rem; text-align: center; color: var(--dim); font-size: 12px; }
/* Power graph sparkline (click to open the detailed modal) */
.spark-wrap { margin: .2rem 0 .3rem; background: #0c0e11; border: 1px solid var(--line); border-radius: 4px; padding: 4px; cursor: pointer; position: relative; }
.spark-wrap:hover { border-color: var(--orange-dk); }
.spark-wrap::after { content: "⤢"; position: absolute; top: 2px; right: 5px; font-size: 11px; color: var(--dim); }
.spark { width: 100%; height: 44px; display: block; }
.spark-legend { display: flex; gap: 1rem; font-size: 11px; color: var(--muted); margin-bottom: .5rem; }
.spark-legend .lg { display: inline-flex; align-items: center; gap: .3rem; }
.spark-legend .lg i { width: 12px; height: 2px; display: inline-block; border-radius: 1px; }

/* Detailed in-game-style power graph modal */
.modal-wide { width: min(800px, 100%); }
.power-modal-body { padding: 14px 16px 18px; }
.pg-wrap { display: flex; gap: 14px; background: #fbfbfb; border-radius: 8px; padding: 12px; align-items: stretch; }
.pg-graph-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pg-graph-svg { width: 100%; height: 300px; display: block; }
.pg-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 10px 4px 2px; border-top: 1px solid #ececec; margin-top: 8px; }
.pg-lg { display: inline-flex; align-items: center; gap: 6px; color: #555; font-size: 13px; }
.pg-lg i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.pg-lg b { color: #111; }
.pg-battery { display: flex; flex-direction: column; align-items: center; padding: 2px 4px; }
.pg-batt-bar { display: flex; flex-direction: column; gap: 4px; width: 44px; flex: 1; min-height: 200px; border: 2px solid #2a2a2a; border-radius: 4px; padding: 4px; background: #fff; }
.pg-seg { flex: 1; background: #e4e4e4; border-radius: 2px; }
.pg-seg.on { background: #4a4a4a; }
.pg-batt-pct { font-weight: 800; font-size: 20px; color: #111; margin-top: 6px; }
.pg-batt-mwh { font-size: 11px; color: #777; }
@media (max-width: 560px) { .pg-wrap { flex-direction: column; } .pg-batt-bar { flex-direction: row; min-height: 40px; } }

/* Per-circuit breakdown in the Power card */
.circuit-list { margin-top: .2rem; }
.circuit { display: flex; justify-content: space-between; gap: .8rem; padding: .2rem 0; font-size: 12.5px; }
.circuit.circ-fuse { color: var(--bad); }

/* Collapsible accordion (Space Elevator + tech tiers) */
.accordion { display: flex; flex-direction: column; gap: 4px; margin-bottom: .8rem; }
.acc-item { border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--bg-panel); }
.acc-head { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; cursor: pointer;
  background: none; border: none; color: var(--text); font: inherit; padding: .5rem .7rem; }
.acc-head:hover { background: rgba(255,255,255,.03); }
.acc-arrow { color: var(--muted); transition: transform .15s; font-size: 11px; }
/* direct-child selectors so nesting collapses independently (each item owns its panel) */
.acc-item.open > .acc-head .acc-arrow { transform: rotate(90deg); }
.acc-title { font-weight: 700; color: var(--muted); }      /* incomplete = b&w/dim */
.acc-complete > .acc-head .acc-title { color: var(--good); } /* complete = colored */
.acc-frac { margin-left: auto; font-size: 12px; color: var(--muted); }
.acc-frac.frac-done { color: var(--good); }
.acc-panel { display: none; padding: .4rem .7rem .6rem; border-top: 1px solid var(--line); }
.acc-item.open > .acc-panel { display: block; }
/* Nested accordion (phases inside Space Elevator, tiers inside Tech Tiers) */
.acc-panel .accordion { margin-bottom: 0; }
.acc-panel .acc-item { background: var(--bg); }

/* Unlock rows (milestones / research nodes): b&w when todo, color when done */
.unlock { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; font-size: 13px; flex-wrap: wrap; }
.unlock .u-check { width: 16px; text-align: center; flex-shrink: 0; }
.unlock.done { color: var(--text); }
.unlock.done .u-check { color: var(--good); }
.unlock.todo { color: var(--dim); }
.u-items { display: inline-flex; flex-wrap: wrap; gap: .3rem .6rem; margin-left: auto; }

/* Master-detail (MAM: tree list -> tree contents) */
.md-layout { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 1rem; }
.md-left { display: flex; flex-direction: column; gap: 3px; max-height: 340px; overflow-y: auto; }
.mam-tree { display: flex; justify-content: space-between; gap: .5rem; align-items: center; text-align: left;
  cursor: pointer; background: var(--bg-panel); border: 1px solid var(--line); border-radius: 5px;
  padding: .4rem .6rem; color: var(--muted); font: inherit; }
.mam-tree:hover { background: rgba(255,255,255,.03); }
.mam-tree.sel { border-color: var(--orange); background: rgba(248,155,60,.08); color: var(--text); }
.mam-tree.tree-done .mt-name { color: var(--good); }
.mt-frac { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.md-right { min-height: 120px; max-height: 340px; overflow-y: auto; scrollbar-gutter: stable; border-left: 1px solid var(--line); padding-left: 1rem; padding-right: 1.1rem; }
.md-title { font-weight: 700; color: var(--orange); margin-bottom: .5rem; font-size: 13px; }
@media (max-width: 560px) {
  .md-layout { grid-template-columns: 1fr; }
  .md-right { border-left: none; border-top: 1px solid var(--line); padding-left: 0; padding-top: .6rem; }
}

/* Version button + release-notes modal (Valheim-style popup) */
.version-btn {
  background: none; border: none; color: var(--orange); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline dotted; text-underline-offset: 2px;
}
.version-btn:hover { color: var(--text); }
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 12, 0.72); padding: 20px; backdrop-filter: blur(3px);
}
.modal-card {
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel2));
  border: 1px solid var(--line); border-top: 2px solid var(--orange-dk); border-radius: 10px;
  width: min(560px, 100%); max-height: 82vh; display: flex; flex-direction: column;
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--orange); }
.modal-close { background: none; border: none; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.changelog-body { padding: 8px 18px 16px; overflow-y: auto; }
.cl-entry { padding: 12px 0; border-bottom: 1px solid var(--line); }
.cl-entry:last-child { border-bottom: none; }
.cl-ver { display: flex; align-items: baseline; gap: 10px; font-weight: 700; color: var(--orange); }
.cl-date { margin-left: auto; color: var(--dim); font-weight: 400; font-size: 12px; }
.cl-notes { margin: 8px 0 0; padding-left: 18px; list-style: disc; color: var(--muted); }
.cl-notes li { margin: .2rem 0; }
