/* =============================================================================
   Conjoint MVP — design system
   Brief: dark ground, faint quad-ruled coordinate grid (blue/violet), gold for
   emphasis, ultra-modern data-science register. The grid is the signature; the
   section nav is plotted as points along a coordinate axis.
   ============================================================================= */

:root {
  /* ground + structure */
  --bg:         #0a0b12;
  --bg-elev:    #11131d;
  --bg-elev-2:  #161a27;
  --grid-fine:  rgba(99, 102, 165, 0.055);
  --grid-major: rgba(116, 104, 188, 0.10);
  --line:       rgba(140, 150, 200, 0.14);
  --line-soft:  rgba(140, 150, 200, 0.08);

  /* ink */
  --ink:        #e7e9f3;
  --ink-dim:    #9aa0b8;
  --ink-faint:  #626a86;

  /* gold — the one bold accent, spent sparingly */
  --gold:       #ffce4f;
  --gold-deep:  #c9a227;
  --gold-glow:  rgba(255, 206, 79, 0.13);

  /* cool data accent — only for interactive / plotted elements */
  --cyan:       #5ad1ff;
  --cyan-soft:  rgba(90, 209, 255, 0.12);

  /* grid geometry */
  --cell: 30px;       /* quad-ruled cell size           */
  --major: 5;         /* heavier rule every N cells      */

  --maxw: 920px;
  --radius: 4px;      /* near-square, technical feel     */

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--bg);
  /* quad-ruled paper: fine grid + heavier major rules, on dark */
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-fine) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-fine) 1px, transparent 1px);
  background-size:
    calc(var(--cell) * var(--major)) calc(var(--cell) * var(--major)),
    calc(var(--cell) * var(--major)) calc(var(--cell) * var(--major)),
    var(--cell) var(--cell),
    var(--cell) var(--cell);
  background-position: -1px -1px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* faint vignette so the page reads as a plotted field, not a flat fill */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% -10%,
              transparent 55%, rgba(5, 5, 10, 0.7) 100%);
  z-index: 0;
}

.wrap { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ----------------------------------------------------------------- masthead */

.masthead {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, rgba(10,11,18,0.96), rgba(10,11,18,0.82));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.masthead__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 14px 24px;
}
.masthead__top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand__mark {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.18em;
  color: var(--gold); border: 1px solid var(--gold-deep);
  padding: 3px 7px; border-radius: var(--radius);
  text-transform: uppercase;
}
.brand__name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem;
  letter-spacing: 0.01em; color: var(--ink);
}
.brand__name small { color: var(--ink-faint); font-weight: 400; font-size: 0.78rem; }

/* ------------------------------------------------ nav: points on an axis */

.axisnav { margin-top: 14px; }
.axisnav__track {
  list-style: none; display: flex; align-items: flex-end;
  justify-content: space-between; gap: 0;
  margin: 0; padding: 0; position: relative;
}
/* first/last items sit flush with the content column's left/right edges */
.axisnav__item:first-child .axisnav__link { padding-left: 0; }
.axisnav__item:last-child .axisnav__link { padding-right: 0; }
/* the x-axis line the section points sit on */
.axisnav__track::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 9px;
  height: 1px; background: var(--line);
}
.axisnav__item { position: relative; }
.axisnav__link {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 4px 14px 0; text-decoration: none; min-width: 64px;
}
.axisnav__label {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.04em;
  color: var(--ink-dim); white-space: nowrap;
  transition: color 0.18s ease;
}
.axisnav__node {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg-elev-2); border: 1px solid var(--ink-faint);
  position: relative; z-index: 1; transition: all 0.18s ease;
}
.axisnav__link:hover .axisnav__label { color: var(--ink); }
.axisnav__link:hover .axisnav__node { border-color: var(--gold-deep); }

.axisnav__item--current .axisnav__node {
  background: var(--gold); border-color: var(--gold);
  box-shadow: 0 0 0 4px var(--gold-glow);
}
.axisnav__item--current .axisnav__label { color: var(--gold); }

.axisnav__item--locked .axisnav__link { cursor: not-allowed; }
.axisnav__item--locked .axisnav__label { color: var(--ink-faint); opacity: 0.55; }
.axisnav__item--locked .axisnav__node {
  border-style: dashed; opacity: 0.5; background: transparent;
}

/* ----------------------------------------------------------------- content */

main { padding: 56px 0 120px; position: relative; z-index: 1; }

.eyebrow {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--gold);
  display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 22px; height: 1px; background: var(--gold-deep);
}

h1, h2, h3 { font-family: var(--font-display); color: var(--ink); line-height: 1.18; }
h1 { font-size: clamp(2rem, 4.4vw, 3rem); font-weight: 600; letter-spacing: -0.01em; margin: 14px 0 18px; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); font-weight: 600; margin: 52px 0 14px; }
h3 { font-size: 1.08rem; font-weight: 600; color: var(--ink); margin: 30px 0 8px; }

.lede { font-size: 1.14rem; color: var(--ink-dim); text-align: justify; }
p { color: var(--ink-dim); text-align: justify; }
strong { color: var(--ink); font-weight: 600; }
a { color: var(--gold); text-decoration-color: var(--gold-deep); text-underline-offset: 3px; }

.coord {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-faint);
  letter-spacing: 0.08em;
}

/* cards / panels */
.panel {
  background: linear-gradient(180deg, var(--bg-elev), rgba(17,19,29,0.6));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin: 18px 0;
}

/* a results "deliverable": heading + export buttons + panel-backed visual */
.deliverable { margin-top: 34px; }
.dl-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.dl-bar > h2, .dl-bar > h3 { margin: 0; }
.deliverable > .panel { margin-top: 14px; }
.deliverable > #seg-output { margin-top: 14px; }
.dl-actions { display: inline-flex; gap: 6px; flex: 0 0 auto; }
.dl-btn {
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-dim);
  background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.dl-btn:hover { color: var(--gold); border-color: var(--gold-deep); }
.dl-btn:disabled { opacity: 0.5; cursor: default; }

/* compact inline control label (optimizer controls etc.) */
.ctl-lbl { margin: 0; text-transform: none; letter-spacing: 0; font-family: var(--font-mono); font-size: .74rem; color: var(--ink-dim); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.capability { border-left: 2px solid var(--gold-deep); padding-left: 16px; }
.capability h3 { margin-top: 0; }
.capability__n { font-family: var(--font-mono); color: var(--gold); font-size: 0.8rem; }

/* gold callout for the things that matter */
.callout {
  border: 1px solid var(--gold-deep);
  background: var(--gold-glow);
  border-radius: var(--radius);
  padding: 16px 18px; margin: 22px 0;
}
.callout .eyebrow { margin-bottom: 8px; }
.callout p { color: var(--ink); }

/* use-case chips */
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.chip {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.04em;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; color: var(--ink-dim); background: var(--bg-elev);
}
.chip--gold { border-color: var(--gold-deep); color: var(--gold); }

/* equations: MathJax inherits currentColor, so the wrapper sets the tone */
.eq {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-left: 2px solid var(--cyan);
  border-radius: var(--radius);
  padding: 6px 18px; margin: 16px 0; overflow-x: auto;
  color: var(--ink);
}
.eq--gold { border-left-color: var(--gold); }
.where { font-size: 0.92rem; }
.where dt { font-family: var(--font-mono); color: var(--cyan); display: inline; }
.where dd { display: inline; margin: 0 0 0 6px; color: var(--ink-dim); }
.where div { margin: 4px 0; }

ul.clean { list-style: none; padding-left: 0; }
ul.clean li { position: relative; padding-left: 20px; color: var(--ink-dim); margin: 7px 0; }
ul.clean li::before {
  content: "+"; position: absolute; left: 0; color: var(--gold);
  font-family: var(--font-mono);
}

.divider { height: 1px; background: var(--line); margin: 44px 0; border: 0; }

footer.foot {
  border-top: 1px solid var(--line); margin-top: 80px; padding: 24px 0;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-faint);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}

/* locked-section placeholder */
.locked {
  text-align: center; padding: 90px 24px;
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: rgba(17,19,29,0.4); margin-top: 40px;
}
.locked__mark {
  font-family: var(--font-mono); color: var(--ink-faint);
  font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.locked h1 { color: var(--ink-dim); }

/* a11y */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 50; background: var(--bg-elev); padding: 8px 12px; border: 1px solid var(--gold); border-radius: var(--radius); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------- forms & app controls */
.acct { color: var(--cyan); text-decoration: none; font-size: 0.72rem;
  letter-spacing: 0.08em; padding: 4px 10px; border: 1px solid var(--line);
  border-radius: 4px; transition: color 0.15s, border-color 0.15s, background 0.15s; }
.acct:hover { color: var(--cyan); border-color: var(--cyan);
  background: var(--cyan-soft); }

.flash { border-radius: var(--radius); padding: 11px 16px; margin: 16px 0; font-size: 0.92rem; border: 1px solid var(--line); }
.flash--ok    { border-color: rgba(90,209,255,.4); background: var(--cyan-soft); color: var(--ink); }
.flash--error { border-color: #b4524f; background: rgba(180,82,79,.14); color: #ffd9d6; }

.field { margin: 14px 0; }
.field label { display: block; font-family: var(--font-mono); font-size: 0.74rem;
  letter-spacing: 0.08em; color: var(--ink-dim); margin-bottom: 6px; text-transform: uppercase; }
input[type=text], input[type=email], input[type=password], input[type=number],
select, .input {
  width: 100%; background: #0d0f18; border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink); padding: 10px 12px;
  font-family: var(--font-body); font-size: 0.95rem;
}
input:focus, select:focus { border-color: var(--gold-deep); outline: none; box-shadow: 0 0 0 3px var(--gold-glow); }

/* continuous values are typed, not stepped: drop the native spin buttons so they
   don't overlap/clip the value, and let inputs be sized to content where set */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* compact select: custom chevron, sized to content (no native-arrow gap) */
.sel-compact {
  width: auto; min-width: 0;
  padding: 10px 30px 10px 12px;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%239aa0b8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 11px;
}
.help { font-size: 0.82rem; color: var(--ink-faint); margin-top: 5px; }

.btn {
  font-family: var(--font-mono); font-size: 0.82rem; letter-spacing: 0.06em;
  background: var(--gold); color: #1a1407; border: 0; border-radius: var(--radius);
  padding: 11px 20px; cursor: pointer; font-weight: 500;
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--ink-dim); border: 1px solid var(--line); }
.btn--ghost:hover { color: var(--gold); border-color: var(--gold-deep); }
.btn:disabled { opacity: 0.5; cursor: default; }
/* Secondary "export" action - cyan outline so it is findable without
   competing with the solid gold primary (Compute). */
.btn--cyan { background: transparent; color: var(--cyan);
  border: 1px solid rgba(90,209,255,.5); }
.btn--cyan:hover { border-color: var(--cyan); background: var(--cyan-soft); }
/* Simulator toolbar: compact so the full setup row + action cluster fit one
   line at laptop widths, keeping Compute as the far-right "period". */
.sim-toolbar .btn { padding: 9px 14px; font-size: 0.78rem; }
.sim-toolbar .sel-compact { padding: 9px 26px 9px 10px; }
.sim-toolbar .num { padding: 9px 10px; }
/* Simulator editor: center header + control on the attribute columns so a
   short label (Cost) locks vertically over its content-sized box. Product
   stays left (row label); Share/Revenue/Profit untouched (outputs). */
#sim-editor th.attr-col, #sim-editor td.attr-col { text-align: center; }
/* Currency picker: size to its content instead of the default select width. */
.sel-currency { padding-right: 28px; min-width: 0; }

.errs { color: #ffb3af; font-size: 0.82rem; margin-top: 5px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { flex: 1; text-align: center; padding: 10px; font-family: var(--font-mono);
  font-size: 0.78rem; color: var(--ink-faint); cursor: pointer; border-bottom: 2px solid transparent; background: none; border-top:0; border-left:0; border-right:0; }
.tab--on { color: var(--gold); border-bottom-color: var(--gold); }

/* study type option cards */
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0; }
@media (max-width: 760px) { .opts { grid-template-columns: 1fr; } }
.opt { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer;
  background: var(--bg-elev); transition: border-color .15s ease; }
.opt:hover { border-color: var(--gold-deep); }
.opt input { position: absolute; opacity: 0; }
.opt--on, .opt:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
.opt h3 { margin: 0 0 6px; font-size: 1rem; }
.opt p { font-size: 0.86rem; margin: 0; }

/* data tables */
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 14px 0; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
table.data th { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-dim); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-cell { position: relative; }
.bar-cell .bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gold-glow); border-right: 2px solid var(--gold); border-radius: 2px; }
.bar-cell span { position: relative; }

/* progress */
.progress { margin: 22px 0; }
.progress__track { height: 10px; background: #0d0f18; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width .3s ease; }
.progress__meta { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-dim); margin-top: 8px; }
.progress__pct { color: var(--gold); }

.codeblock { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-dim);
  background: #0d0f18; border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; }
.tag { font-family: var(--font-mono); font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-dim); }
.tag--done { border-color: rgba(90,209,255,.5); color: var(--cyan); }
.tag--run { border-color: var(--gold-deep); color: var(--gold); }
.tag--fail { border-color: #b4524f; color: #ffb3af; }

/* Endnotes / citations (Section 2 math references) */
.notes { margin-top: 40px; }
.notes__list { margin: 12px 0 0; padding-left: 1.5em; color: var(--ink-dim);
  font-size: 0.9rem; line-height: 1.55; }
.notes__list li { margin: 8px 0; }
.notes__list li em { color: var(--ink); }
.notes__back { margin-left: 6px; color: var(--gold); text-decoration: none; }
.fnref { font-size: 0.7em; line-height: 0; }
.fnref a { color: var(--gold); text-decoration: none; padding-left: 1px; }

/* Row-action links in .data tables (Select / Delete) - unified size, spaced by role */
.row-link { display: inline-block; font-family: var(--font-mono); font-size: 0.82rem;
  letter-spacing: 0.04em; text-decoration: none; padding: 2px 0; border: 0;
  background: transparent; cursor: pointer; }
.row-link--pick { color: var(--gold); }
.row-link--pick:hover, .row-link--pick:focus { color: var(--gold-deep); text-decoration: underline; }
.row-link--delete { color: #ff6b6b; }
.row-link--delete:hover, .row-link--delete:focus { color: #ff3d3d; text-decoration: underline; }
.row-link--muted { color: var(--ink-faint); cursor: default; }

/* Run-context line under the Section 6 title */
.runmeta { color: var(--ink-faint); font-size: 0.78rem; letter-spacing: 0.05em;
  margin: -6px 0 26px; }
