/* -------------------------------------------------------------
   Capstone - Commodity Finance OS
   Dark-first. :root carries the dark palette; light is redefined
   under prefers-color-scheme AND under [data-theme="light"].
   ------------------------------------------------------------- */

:root {
  --ground:      #0a1424;
  --ground-deep: #060e1a;
  --panel:       #101f36;
  --panel-hi:    #16294480;
  --line:        #1e3050;
  --line-strong: #2b4470;

  --tx:    #e7edf7;
  --tx-2:  #a3b5d1;
  --tx-3:  #6f83a6;

  --brass:      #d9a441;
  --brass-hi:   #eec06a;
  --brass-fill: #d9a441;
  --brass-fill-hi: #eec06a;
  --on-brass:   #180f02;
  --brass-dim:  #7a6026;
  --brass-wash: #d9a4411a;

  --blue:      #6ea3f8;
  --blue-wash: #6ea3f81f;

  --ok:    #46b783;
  --bad:   #e0685c;
  --steel: #8497b8;

  /* Product vignettes render on the app's real light canvas in both
     themes - a deliberate single-theme island, fully specified. */
  --vg-bg:     #ffffff;
  --vg-sunk:   #f5f7fa;
  --vg-line:   #e3e8f0;
  --vg-tx:     #141f33;
  --vg-tx-2:   #56657f;
  --vg-navy:   #1d3b8b;
  --vg-navy-w: #eef2fb;
  --vg-ok:     #0a8a4f;
  --vg-ok-w:   #e7f5ee;
  --vg-bad:    #b3261e;
  --vg-bad-w:  #fbeceb;

  --shadow: 0 24px 60px -28px #00060fcc;
  --rule: 1px solid var(--line);
  --rule-hero: #16274280;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ground:      #eef1f6;
    --ground-deep: #e3e8f0;
    --panel:       #ffffff;
    --panel-hi:    #ffffff;
    --line:        #d5dce8;
    --line-strong: #b9c4d6;

    --tx:    #0f1b2d;
    --tx-2:  #465874;
    --tx-3:  #6b7c98;

    --brass:      #8a6a1f;
    --brass-hi:   #6d5316;
    --brass-fill: #8a6a1f;
    --brass-fill-hi: #6d5316;
    --on-brass:   #fffdf5;
    --brass-dim:  #c9ad70;
    --brass-wash: #c58e2a1f;

    --blue:      #1d3b8b;
    --blue-wash: #1d3b8b14;

    --ok:    #0a8a4f;
    --bad:   #b3261e;
    --steel: #5b6778;

    --shadow: 0 22px 50px -30px #16243d40;
    --rule-hero: #e4e9f2;
  }
}

:root[data-theme="light"] {
  --ground:      #eef1f6;
  --ground-deep: #e3e8f0;
  --panel:       #ffffff;
  --panel-hi:    #ffffff;
  --line:        #d5dce8;
  --line-strong: #b9c4d6;

  --tx:    #0f1b2d;
  --tx-2:  #465874;
  --tx-3:  #6b7c98;

  --brass:      #8a6a1f;
  --brass-hi:   #6d5316;
  --brass-fill: #8a6a1f;
  --brass-fill-hi: #6d5316;
  --on-brass:   #fffdf5;
  --brass-dim:  #c9ad70;
  --brass-wash: #c58e2a1f;

  --blue:      #1d3b8b;
  --blue-wash: #1d3b8b14;

  --ok:    #0a8a4f;
  --bad:   #b3261e;
  --steel: #5b6778;

  --shadow: 0 22px 50px -30px #16243d40;
  --rule-hero: #e4e9f2;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--tx);
  font-family: Archivo, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { text-wrap: balance; margin: 0; }

.wrap {
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 56px);
}

/* -- Mono utility --------------------------------------------- */
.mono {
  font-family: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0;
}

/* -- Masthead ------------------------------------------------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: var(--rule);
}
.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 62px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  text-decoration: none;
}
.brand b {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -.004em;
}
.brand span {
  font-family: "IBM Plex Mono", monospace;
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--tx-3);
}
.mast-nav {
  display: flex;
  gap: 26px;
  align-items: center;
  font-size: .88rem;
  color: var(--tx-2);
}
.mast-nav a { text-decoration: none; }
.mast-nav a:hover { color: var(--brass); }
@media (max-width: 820px) { .mast-nav .hide-sm { display: none; } }
@media (max-width: 520px) { .brand span { display: none; } }

/* -- Bands ---------------------------------------------------- */
.band { padding-block: clamp(64px, 8vw, 116px); border-top: var(--rule); }
.band[id], main [id] { scroll-margin-top: 84px; }
.band:first-of-type { border-top: 0; }
.band-head { display: grid; gap: 18px; max-width: 74ch; }
.band h2 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.8rem, 3.1vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -.011em;
}
.lede {
  font-size: clamp(1.02rem, 1.3vw, 1.14rem);
  color: var(--tx-2);
  max-width: 64ch;
  margin: 0;
}
.band p { margin: 0; }

/* -- Hero ----------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: clamp(54px, 7.2vw, 104px) clamp(48px, 6vw, 84px);
  background:
    radial-gradient(120% 90% at 82% -10%, var(--brass-wash) 0%, transparent 58%),
    repeating-linear-gradient(to bottom, transparent 0 39px, var(--rule-hero) 39px 40px),
    linear-gradient(180deg, var(--ground-deep), var(--ground) 70%);
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 160px;
  background: linear-gradient(180deg, transparent, var(--ground));
  pointer-events: none;
}
.hero .wrap { position: relative; z-index: 2; }
.hero-grid { display: grid; gap: clamp(26px, 3.4vw, 40px); max-width: 60ch; }
h1 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.6rem, 6.1vw, 4.35rem);
  line-height: 1.02;
  letter-spacing: -.016em;
}
h1 em { font-style: italic; color: var(--brass); }
.hero .lede { font-size: clamp(1.06rem, 1.5vw, 1.24rem); max-width: 56ch; }

.cta-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 2px;
  font-size: .93rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.btn-primary { background: var(--brass-fill); color: var(--on-brass); border-color: var(--brass-fill); }
.btn-primary:hover { background: var(--brass-fill-hi); border-color: var(--brass-fill-hi); }
.btn-ghost { border-color: var(--line-strong); color: var(--tx); }
.btn-ghost:hover { border-color: var(--brass); color: var(--brass); }
.btn .arw { font-family: "IBM Plex Mono", monospace; }

/* -- Stage rail ----------------------------------------------- */
.rail-frame {
  margin-top: clamp(38px, 5vw, 62px);
  border: var(--rule);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--panel) 70%, transparent));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rail-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: var(--rule);
  font-size: .78rem;
  color: var(--tx-3);
}
.rail-caption .mono { color: var(--tx-2); }
.rail {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin: 0;
  padding: 26px 20px 24px;
  gap: 0;
  position: relative;
}
.node { position: relative; display: grid; gap: 9px; justify-items: start; padding-right: 12px; }
.node::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line-strong);
}
.node:last-child::before { right: 100%; }
.node .dot {
  position: relative;
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--ground);
  display: grid;
  place-items: center;
  font-size: 9px;
  color: var(--ground);
  z-index: 1;
}
.node.done .dot { background: var(--brass-fill); border-color: var(--brass-fill); color: var(--on-brass); }
.node.now  .dot { border-color: var(--brass); box-shadow: 0 0 0 4px var(--brass-wash); }
.node.now  .dot::after {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brass);
}
.node .n { font-family: "IBM Plex Mono", monospace; font-size: .66rem; letter-spacing: .12em; color: var(--tx-3); }
.node .lbl { font-size: .86rem; color: var(--tx-2); line-height: 1.25; }
.node.done .lbl, .node.now .lbl { color: var(--tx); }
.node.now .lbl { color: var(--brass); }
@media (max-width: 760px) and (min-width: 461px) {
  .rail { grid-template-columns: repeat(3, 1fr); row-gap: 26px; }
  .node:nth-child(3)::before { right: 100%; }
}
@media (max-width: 460px) {
  .rail { grid-template-columns: repeat(2, 1fr); row-gap: 26px; }
  .node:nth-child(2n)::before { right: 100%; }
}

.gate {
  border-top: var(--rule);
  background: var(--panel-hi);
  padding: 16px 20px;
  display: grid;
  gap: 8px;
}
.gate-line { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: .87rem; }
.gate-btn {
  font-size: .8rem;
  border: 1px solid var(--brass);
  color: var(--brass);
  border-radius: 2px;
  padding: 4px 11px;
  white-space: nowrap;
}
.gate-why { color: var(--tx-2); }
.gate-why b { color: var(--tx); font-weight: 500; }
.gate-note { font-size: .78rem; color: var(--tx-3); }

/* -- Thesis strip --------------------------------------------- */
.thesis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  background: var(--line);
  border: var(--rule);
  border-radius: 3px;
  margin-top: 42px;
  overflow: hidden;
}
.thesis > div { background: var(--ground); padding: 24px; display: grid; gap: 8px; align-content: start; }
.thesis h3 { font-size: .95rem; font-weight: 600; letter-spacing: .005em; }
.thesis p { font-size: .89rem; color: var(--tx-2); }

/* -- Feature bands -------------------------------------------- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: clamp(30px, 4.5vw, 64px);
  align-items: center;
}
.split.flip { grid-template-columns: minmax(0, 1.14fr) minmax(0, 0.86fr); }
.split.flip > .col-copy { order: 2; }
@media (max-width: 940px) {
  .split, .split.flip { grid-template-columns: 1fr; }
  .split.flip > .col-copy { order: 0; }
}
.col-copy { display: grid; gap: 18px; align-content: start; }
.col-copy h2 { margin-top: 4px; }

.points { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 14px; }
.points li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  font-size: .93rem;
  color: var(--tx-2);
  align-items: start;
}
.points li b { color: var(--tx); font-weight: 500; }
.points .tick {
  font-family: "IBM Plex Mono", monospace;
  color: var(--brass);
  font-size: .8rem;
  line-height: 1.7;
}

/* -- Product vignettes (always paper) ------------------------- */
.vg {
  background: var(--vg-bg);
  color: var(--vg-tx);
  border: 1px solid var(--vg-line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
  font-size: 14px;
}
.vg-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--vg-line);
  background: var(--vg-sunk);
  font-size: .74rem;
  color: var(--vg-tx-2);
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: .05em;
}
.vg-bar .crumb { color: var(--vg-navy); }
.vg-body { padding: 16px 16px 18px; display: grid; gap: 14px; }

.phase { display: grid; gap: 8px; }
.phase-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--vg-tx-2);
  font-family: "IBM Plex Mono", monospace;
}
.rows { display: grid; gap: 6px; }
.row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--vg-line);
  border-radius: 3px;
  background: var(--vg-bg);
}
.row.blocked { background: var(--vg-sunk); }
.row .mark { font-size: .8rem; text-align: center; }
.row .mark.ok  { color: var(--vg-ok); }
.row .mark.wait { color: var(--vg-tx-2); }
.row .ttl { font-size: .86rem; line-height: 1.3; }
.row .ttl small { display: block; color: var(--vg-tx-2); font-size: .74rem; }
.chip {
  font-family: "IBM Plex Mono", monospace;
  font-size: .68rem;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 2px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip-navy { background: var(--vg-navy-w); color: var(--vg-navy); border-color: #c7d5ee; }
.chip-ok   { background: var(--vg-ok-w);   color: var(--vg-ok);   border-color: #b9e4cf; }
.chip-bad  { background: var(--vg-bad-w);  color: var(--vg-bad);  border-color: #f0c7c4; }
.chip-mute { background: var(--vg-sunk);   color: var(--vg-tx-2); border-color: var(--vg-line); }

/* contract diff */
.diff { display: grid; gap: 10px; }
.term {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  padding: 11px 12px;
  border: 1px solid var(--vg-line);
  border-left: 3px solid var(--vg-navy);
  border-radius: 3px;
}
.term .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--vg-tx-2); font-family: "IBM Plex Mono", monospace; }
.term .v { font-family: "IBM Plex Mono", monospace; font-size: .9rem; font-variant-numeric: tabular-nums; }
.term .v s { color: var(--vg-tx-2); text-decoration-thickness: 1px; margin-right: 8px; }
.term .note {
  grid-column: 1 / -1;
  font-size: .8rem;
  color: var(--vg-tx-2);
  border-top: 1px dashed var(--vg-line);
  padding-top: 8px;
  font-style: italic;
}
.term.same { border-left-color: var(--vg-line); }

/* ledger table */
.tbl { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tbl th {
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: .7rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--vg-tx-2);
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--vg-line);
}
.tbl td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--vg-line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; padding-right: 0; }
.scroll-x { overflow-x: auto; }

.meter { display: grid; gap: 9px; }
.meter-top { display: flex; justify-content: space-between; font-size: .78rem; color: var(--vg-tx-2); }
.meter-track { height: 7px; background: var(--vg-sunk); border-radius: 99px; overflow: hidden; position: relative; }
.meter-fill { height: 100%; background: var(--vg-navy); border-radius: 99px; }
.meter-fill.over { background: var(--vg-bad); }
.meter-limit { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #ffffff; box-shadow: 0 0 0 1px #56657f; z-index: 1; }

/* -- Seats ---------------------------------------------------- */
.seats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--line);
  border: var(--rule);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 40px;
}
@media (min-width: 1024px) { .seats { grid-template-columns: repeat(5, 1fr); } }
.seat { background: var(--ground); padding: 22px 18px; display: grid; gap: 10px; align-content: start; }
.seat .who { font-family: "IBM Plex Mono", monospace; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); }
.seat h3 { font-size: 1rem; font-weight: 600; }
.seat p { font-size: .84rem; color: var(--tx-2); }
.seat .mods { font-size: .74rem; color: var(--tx-3); font-family: "IBM Plex Mono", monospace; border-top: var(--rule); padding-top: 10px; }

/* -- Care list ------------------------------------------------ */
.care { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 30px 52px; margin-top: 42px; max-width: 1000px; }
.care article { display: grid; gap: 8px; align-content: start; border-top: 2px solid var(--brass-dim); padding-top: 16px; }
.care h3 { font-size: .95rem; font-weight: 600; }
.care p { font-size: .89rem; color: var(--tx-2); }
.care .kbd {
  font-family: "IBM Plex Mono", monospace;
  background: var(--brass-wash);
  border: 1px solid var(--brass-dim);
  color: var(--brass);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: .82em;
}

/* -- Close ---------------------------------------------------- */
.close {
  background:
    radial-gradient(90% 120% at 15% 0%, var(--brass-wash), transparent 60%),
    var(--ground-deep);
  border-top: var(--rule);
}
.close-grid { display: grid; gap: 26px; justify-items: start; }
.close-grid > * { max-width: 60ch; }
.close h2 { font-size: clamp(2rem, 4vw, 3.1rem); }
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.agenda li { display: grid; grid-template-columns: 3.2rem 1fr; gap: 14px; font-size: .92rem; color: var(--tx-2); align-items: baseline; }
.agenda .t { font-family: "IBM Plex Mono", monospace; font-size: .78rem; color: var(--brass); }

footer { border-top: var(--rule); background: var(--ground-deep); }
footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  justify-content: space-between;
  align-items: center;
  padding-block: 26px;
  font-size: .8rem;
  color: var(--tx-3);
}

/* -- Motion --------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .72s cubic-bezier(.2,.7,.3,1) backwards; }
.d1 { animation-delay: .05s; } .d2 { animation-delay: .15s; } .d3 { animation-delay: .25s; }
.d4 { animation-delay: .35s; } .d5 { animation-delay: .5s; }
.rail .node { animation: rise .5s ease backwards; }
.rail .node:nth-child(1) { animation-delay: .60s; }
.rail .node:nth-child(2) { animation-delay: .68s; }
.rail .node:nth-child(3) { animation-delay: .76s; }
.rail .node:nth-child(4) { animation-delay: .84s; }
.rail .node:nth-child(5) { animation-delay: .92s; }
.rail .node:nth-child(6) { animation-delay: 1.00s; }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.3,1); }
.reveal.seen { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .rise, .rail .node { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { scroll-behavior: auto !important; }
}
html { scroll-behavior: smooth; }
