/* Blue Star Labs — Case File 01 */
:root {
  --navy: #0C2742;
  --blue: #0C447C;
  --bright: #378ADD;
  --gold: #E0A21B;
  --gold-soft: #F6E3B4;
  --bg: #F4F8FC;
  --card: #FFFFFF;
  --ink: #0C2742;
  --ink-soft: rgba(12, 39, 66, 0.72);
  --ink-faint: rgba(12, 39, 66, 0.45);
  --line: rgba(12, 39, 66, 0.12);
  --red: #C43E2F;
  --red-soft: #FBEAE7;
  --green: #2E7D4F;
  --green-soft: #E6F4EC;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: 17px;
}

/* ---------- nav ---------- */
#topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 28px;
  background: rgba(244, 248, 252, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--navy); font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand svg { width: 22px; height: 22px; color: var(--gold); }
.brand em { font-style: normal; color: var(--blue); }
.navlinks { display: flex; gap: 18px; margin-left: auto; }
.navlinks a { color: var(--ink-soft); text-decoration: none; font-size: 0.88rem; font-weight: 500; }
.navlinks a:hover { color: var(--bright); }
.cta-mini {
  background: var(--navy); color: #fff; text-decoration: none;
  font-size: 0.85rem; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  white-space: nowrap;
}
.cta-mini:hover { background: var(--blue); }
#progressbar { position: sticky; top: 53px; z-index: 49; height: 3px; background: transparent; }
#progressfill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), var(--bright)); transition: width 0.1s linear; }

@media (max-width: 860px) {
  .navlinks { display: none; }
  #topnav { justify-content: space-between; }
}

/* ---------- hero ---------- */
.hero {
  max-width: 880px; margin: 0 auto; padding: 96px 24px 72px; text-align: center;
}
.eyebrow {
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--blue);
}
.hero h1 {
  font-family: var(--serif); font-weight: 700; letter-spacing: -0.02em;
  font-size: clamp(2.6rem, 7vw, 4.6rem); line-height: 1.05; margin: 18px 0 20px;
}
.hero .sub { font-size: clamp(1.05rem, 2.5vw, 1.3rem); color: var(--ink-soft); max-width: 620px; margin: 0 auto; }
.hero .sub strong { color: var(--navy); }
.synthetic-chip {
  display: inline-flex; align-items: flex-start; gap: 10px; text-align: left;
  margin-top: 32px; max-width: 560px;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold);
  border-radius: 10px; padding: 12px 16px; font-size: 0.85rem; color: var(--ink-soft);
}
.synthetic-chip svg { width: 20px; height: 20px; flex: none; color: var(--gold); margin-top: 2px; }
.scroll-hint { display: block; width: fit-content; margin: 44px auto 0; color: var(--blue); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.scroll-hint span { display: inline-block; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* ---------- chapters ---------- */
.chapter {
  max-width: 880px; margin: 0 auto; padding: 72px 24px;
  border-top: 1px solid var(--line);
}
.chapter.wide { max-width: 1080px; }
.kicker {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 8px;
}
.kicker::before { content: "★ "; }
.chapter h2 {
  font-family: var(--serif); font-weight: 700; letter-spacing: -0.015em;
  font-size: clamp(1.7rem, 4.5vw, 2.5rem); line-height: 1.15; margin-bottom: 16px;
}
.lede { font-size: 1.12rem; color: var(--ink-soft); margin-bottom: 28px; max-width: 720px; }
.chapter > p { margin-bottom: 16px; max-width: 720px; }

/* facts strip */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 28px 0; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 14px; text-align: center; }
.fact b { display: block; font-family: var(--serif); font-size: 1.7rem; color: var(--blue); line-height: 1.2; }
.fact span { font-size: 0.8rem; color: var(--ink-faint); }

/* ---------- spreadsheet mock ---------- */
.sheet-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: 0 10px 30px rgba(12, 39, 66, 0.08);
  margin: 8px 0 24px;
}
.sheet-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #1E6B41; color: #fff; padding: 9px 14px;
}
.sheet-title { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: rgba(255,255,255,0.14); color: #fff; border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px; padding: 4px 12px 4px 5px; font: 600 0.8rem var(--sans);
}
.toggle .knob {
  width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s ease;
}
.toggle[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.toggle[aria-pressed="true"] .knob { transform: translateX(3px); background: var(--navy); }
.formula-bar {
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #D5DCE4; background: #F8FAFC;
  padding: 5px 12px; font-family: var(--mono); font-size: 0.78rem;
}
.cell-ref { min-width: 34px; color: var(--ink-soft); border-right: 1px solid #D5DCE4; padding-right: 10px; }
.fx { font-style: italic; color: var(--ink-faint); }
#fbar-content { color: var(--navy); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sheet { overflow-x: auto; }
.sheet table { border-collapse: collapse; width: 100%; font-size: 0.78rem; min-width: 760px; }
.sheet th, .sheet td {
  border: 1px solid #E1E6EC; padding: 3px 8px; text-align: left; white-space: nowrap;
  font-family: var(--sans); background: #fff; height: 24px;
}
.sheet th {
  background: #F1F4F8; color: var(--ink-faint); font-weight: 600; text-align: center;
  font-size: 0.72rem; width: 34px;
}
.sheet td.hdr { background: var(--gold-soft); font-weight: 700; color: var(--navy); }
.sheet td.banner { background: var(--navy); color: #fff; font-weight: 700; letter-spacing: 0.04em; }
.sheet td.lbl { font-weight: 600; }
.sheet td.formula { font-family: var(--mono); color: #1A7A3C; font-size: 0.74rem; }
.sheet td.reject { color: var(--red); font-weight: 700; }
.sheet td.pass { color: var(--green); font-weight: 600; }
.sheet tr.hl td { background: #FFF8E7; }

/* callouts */
.callout {
  border-radius: 12px; padding: 22px 24px; margin: 24px 0;
  background: var(--card); border: 1px solid var(--line);
}
.callout h3 { font-family: var(--serif); font-size: 1.25rem; margin-bottom: 8px; }
.callout.warn { border-left: 5px solid var(--red); background: #FFF9F8; }
.callout.gold { border-left: 5px solid var(--gold); background: #FFFBF0; }
.callout p + p { margin-top: 10px; }

/* ---------- file pile ---------- */
.pile-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin: 12px 0 24px; }
@media (max-width: 760px) { .pile-grid { grid-template-columns: 1fr; } }
.filepile {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; max-height: 380px; overflow: hidden; position: relative;
}
.filepile::after {
  content: "…and " attr(data-more) " more"; position: absolute; bottom: 0; left: 0; right: 0;
  padding: 26px 16px 12px; font-size: 0.8rem; color: var(--ink-faint); font-style: italic;
  background: linear-gradient(transparent, #fff 55%);
}
.filerow { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-family: var(--mono); font-size: 0.76rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filerow svg { width: 14px; height: 14px; flex: none; color: #1E6B41; }
.pile-stats { display: flex; flex-direction: column; gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; display: flex; align-items: baseline; gap: 12px;
}
.stat b { font-family: var(--serif); font-size: 1.9rem; color: var(--blue); min-width: 86px; text-align: right; }
.stat.bad b { color: var(--red); }
.stat span { font-size: 0.85rem; color: var(--ink-soft); }

/* ---------- power bi wall ---------- */
.pbi-panel {
  background: #20242B; border-radius: 12px; overflow: hidden; margin: 12px 0 24px;
  box-shadow: 0 10px 30px rgba(12, 39, 66, 0.15);
}
.pbi-head { background: #16181D; color: #C9D1D9; font: 600 0.8rem var(--sans); padding: 9px 16px; }
.pbi-log { list-style: none; padding: 14px 16px; }
.pbi-log li {
  font-family: var(--mono); font-size: 0.76rem; color: #C9D1D9; line-height: 1.5;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; gap: 10px; align-items: flex-start;
}
.pbi-log li:last-child { border-bottom: none; }
.tag { flex: none; font: 700 0.66rem var(--sans); padding: 2px 8px; border-radius: 4px; margin-top: 1px; }
.tag.err { background: rgba(244, 81, 30, 0.18); color: #FF8A65; }
.tag.warn { background: rgba(224, 162, 27, 0.18); color: #E0A21B; }

.cost-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 24px 0; }
.cost { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-align: center; }
.cost b { display: block; font-family: var(--serif); font-size: 1.9rem; color: var(--red); }
.cost span { font-size: 0.82rem; color: var(--ink-soft); }

/* ---------- pipeline ---------- */
.pipeline-panel {
  background: var(--navy); border-radius: 14px; padding: 22px; margin: 8px 0 24px;
  box-shadow: 0 14px 40px rgba(12, 39, 66, 0.25);
}
.pipe-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-bottom: 18px; }
.btn-primary {
  background: var(--gold); color: var(--navy); border: none; cursor: pointer;
  font: 700 1rem var(--sans); padding: 13px 26px; border-radius: 999px;
  text-decoration: none; display: inline-block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(224, 162, 27, 0.4); }
.btn-primary:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.btn-primary.big { font-size: 1.15rem; padding: 16px 36px; }
.pipe-counters { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.pc { text-align: right; }
.pc span { display: block; font-family: var(--mono); font-size: 1.35rem; font-weight: 600; color: var(--gold); line-height: 1.2; }
.pc label { font-size: 0.7rem; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 0.08em; }
.pipe-stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
@media (max-width: 760px) { .pipe-stages { grid-template-columns: 1fr 1fr; } .pipe-counters { margin-left: 0; } }
.stage {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px; padding: 10px 12px; font-size: 0.74rem; color: rgba(255,255,255,0.75);
  position: relative; transition: all 0.25s ease;
}
.stage b { display: block; color: #fff; font-size: 0.8rem; margin-bottom: 2px; }
.stage.active { border-color: var(--gold); background: rgba(224, 162, 27, 0.12); box-shadow: 0 0 0 1px var(--gold); }
.stage.done { border-color: rgba(120, 200, 150, 0.5); }
.stage.done::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: #7BC896; font-weight: 700; }
.pipe-log {
  background: #081A2E; border-radius: 10px; height: 190px; overflow-y: auto;
  padding: 12px 14px; font-family: var(--mono); font-size: 0.73rem; line-height: 1.6;
  color: #9FB6CC;
}
.pipe-log .ok { color: #7BC896; }
.pipe-log .fix { color: var(--gold); }
.pipe-log .flag { color: #FF9E80; }
.pipe-log:empty::before { content: "Idle. Press Run to crawl the audit folder."; color: rgba(255,255,255,0.3); font-style: italic; }

.result-h { font-family: var(--serif); font-size: 1.5rem; margin: 30px 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  background: var(--green-soft); color: var(--green); border: 1px solid rgba(46,125,79,0.25);
  font-size: 0.8rem; font-weight: 600; padding: 5px 12px; border-radius: 999px;
}
.chip.flag { background: var(--red-soft); color: var(--red); border-color: rgba(196,62,47,0.25); }
.clean-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.clean-table { border-collapse: collapse; width: 100%; font-size: 0.78rem; min-width: 720px; }
.clean-table th {
  background: var(--navy); color: #fff; font-weight: 600; text-align: left;
  padding: 8px 12px; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.02em;
}
.clean-table td { padding: 6px 12px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 0.74rem; white-space: nowrap; }
.clean-table td.r { color: var(--red); font-weight: 700; }
.clean-table td.g { color: var(--green); font-weight: 600; }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 22px 14px; margin-bottom: 20px;
  box-shadow: 0 6px 20px rgba(12, 39, 66, 0.05);
}
.chart-grid .chart-card { margin-bottom: 0; }
.chart-head h3 { font-family: var(--serif); font-size: 1.18rem; margin-bottom: 6px; }
.chart-head p { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 12px; max-width: 640px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { font: 500 10px var(--sans); fill: var(--ink-faint); }
.chart .anno { font: 600 10.5px var(--sans); fill: var(--navy); }
.chart .anno-line { stroke: var(--ink-faint); stroke-dasharray: 3 3; stroke-width: 1; fill: none; }

/* heatmap */
.hm-grid { display: grid; gap: 4px; font-size: 0.78rem; }
.hm-cell {
  border-radius: 6px; padding: 10px 6px; text-align: center; font-weight: 600;
  font-family: var(--mono); font-size: 0.78rem; cursor: default;
  transition: transform 0.1s ease;
}
.hm-cell:hover { transform: scale(1.04); }
.hm-lab { display: flex; align-items: center; font-weight: 600; font-family: var(--sans); font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-head { text-align: center; font-weight: 600; color: var(--ink-faint); font-size: 0.75rem; align-self: end; padding-bottom: 4px; }

/* ---------- ROI ---------- */
.roi-panel {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px;
}
@media (max-width: 800px) { .roi-panel { grid-template-columns: 1fr; } }
.slider-row { margin-bottom: 20px; }
.slider-row label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.slider-row .hint { font-weight: 400; color: var(--ink-faint); font-size: 0.8rem; }
.slider-row input[type="range"] { width: calc(100% - 64px); vertical-align: middle; accent-color: var(--blue); }
.slider-row output { display: inline-block; width: 56px; text-align: right; font-family: var(--mono); font-weight: 600; color: var(--blue); }
.roi-out { border-left: 1px solid var(--line); padding-left: 28px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
@media (max-width: 800px) { .roi-out { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 20px; } }
.roi-big span { font-family: var(--serif); font-size: 2.6rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.roi-big.gold span { color: var(--gold); }
.roi-big label { display: block; font-size: 0.82rem; color: var(--ink-soft); }
.fineprint { font-size: 0.8rem; color: var(--ink-faint); margin-top: 12px; }

/* ---------- plant / positioning ---------- */
.principle {
  font-family: var(--serif); font-size: clamp(1.4rem, 3.5vw, 2rem); font-weight: 700;
  border-left: 5px solid var(--gold); padding: 8px 0 8px 22px; margin: 30px 0;
  line-height: 1.3;
}
.principle span { display: block; font-family: var(--sans); font-weight: 400; font-size: 1rem; color: var(--ink-soft); margin-top: 6px; }
.arch { display: grid; grid-template-columns: 1fr auto 1.2fr auto 1fr; gap: 10px; align-items: stretch; margin: 24px 0 34px; }
@media (max-width: 800px) { .arch { grid-template-columns: 1fr; } .arch-arrow { transform: rotate(90deg); justify-self: center; } }
.arch-node { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.arch-node.hi { border: 2px solid var(--gold); background: #FFFBF0; }
.arch-node h4 { font-size: 0.95rem; margin-bottom: 6px; }
.arch-node p { font-size: 0.82rem; color: var(--ink-soft); }
.arch-arrow { align-self: center; font-size: 1.5rem; color: var(--gold); font-weight: 700; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 10px 0 34px; }
@media (max-width: 760px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.pos-card h4 { font-family: var(--serif); font-size: 1.1rem; margin-bottom: 8px; color: var(--blue); }
.pos-card p { font-size: 0.9rem; color: var(--ink-soft); }

/* downloads */
.downloads { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.downloads h3 { font-family: var(--serif); font-size: 1.3rem; margin-bottom: 6px; }
.downloads > p { font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 16px; }
.dl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .dl-grid { grid-template-columns: 1fr; } }
.dl {
  display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dl:hover { border-color: var(--bright); background: #F7FAFE; }
.dl-ic { flex: none; width: 34px; height: 34px; border-radius: 8px; background: #EAF0F7; display: grid; place-items: center; font-size: 1rem; color: var(--blue); }
.dl.clean .dl-ic { background: var(--green-soft); color: var(--green); font-weight: 700; }
.dl strong { display: block; font-size: 0.88rem; }
.dl em { font-style: normal; font-size: 0.76rem; color: var(--ink-faint); }

/* teasers */
.teaser-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
@media (max-width: 760px) { .teaser-grid { grid-template-columns: 1fr; } }
.teaser { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; position: relative; }
.teaser .tno { position: absolute; top: 14px; right: 18px; font-family: var(--serif); font-size: 1.6rem; color: rgba(12,39,66,0.1); font-weight: 700; }
.teaser h4 { font-size: 1rem; margin-bottom: 6px; }
.teaser p { font-size: 0.86rem; color: var(--ink-soft); }

/* final CTA */
.cta-final { text-align: center; padding-bottom: 100px; }
.cta-final h2 { font-size: clamp(2rem, 6vw, 3.2rem); }
.cta-final .lede { margin-left: auto; margin-right: auto; }
.cta-final .btn-primary { margin-top: 10px; }

footer {
  border-top: 1px solid var(--line); padding: 28px 24px 40px; text-align: center;
  font-size: 0.8rem; color: var(--ink-faint);
}
footer a { color: inherit; }

/* tooltip */
#tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--navy); color: #fff; font-size: 0.75rem; line-height: 1.45;
  padding: 8px 11px; border-radius: 8px; max-width: 240px;
  box-shadow: 0 8px 20px rgba(12,39,66,0.3);
}
#tooltip b { color: var(--gold); }

/* reveal-on-scroll — chapters are VISIBLE by default; JS adds .pre only to
   below-the-fold chapters once it's safely running, so a JS failure (or a
   crawler / old browser) still gets the full page */
.chapter.pre { opacity: 0; transform: translateY(14px); }
.chapter.vis { opacity: 1; transform: none; transition: opacity 0.55s ease, transform 0.55s ease; }
@media (prefers-reduced-motion: reduce) {
  .chapter.pre { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}
