/* ============================================================
   Sharpebase — simulation design system
   Shared by the marketing home (index.html) and the platform.
   Light is the primary mode; dark is a selected, validated set
   of steps rather than an automatic flip.
   ============================================================ */

:root {
  color-scheme: light;

  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;

  /* surfaces */
  --plane:      #f0efec;
  --plane-2:    #e8e6e2;
  --surface:    #ffffff;
  --surface-2:  #f7f6f4;
  --surface-3:  #efeeea;

  /* ink */
  --ink:        #0b0b0b;
  --ink-2:      #52514e;
  --muted:      #898781;
  --faint:      #a8a69f;

  /* lines */
  --line:       #e3e1dc;
  --line-2:     #edebe6;
  --grid:       #e1e0d9;
  --axis:       #c3c2b7;

  /* categorical series (validated: adjacent CVD ΔE 9.1, normal 22.9) */
  --s1: #2a78d6;   /* blue    */
  --s2: #eb6834;   /* orange  */
  --s3: #1baf7a;   /* aqua    */
  --s4: #eda100;   /* yellow  */

  /* sequential blue ramp */
  --b100: #cde2fb; --b150: #b7d3f6; --b200: #9ec5f4; --b250: #86b6ef;
  --b300: #6da7ec; --b350: #5598e7; --b400: #3987e5; --b450: #2a78d6;
  --b500: #256abf; --b550: #1c5cab; --b600: #184f95; --b650: #104281;

  /* diverging poles + neutral midpoint */
  --pos:  #2a78d6;
  --neg:  #d03b3b;
  --mid:  #f0efec;

  /* status (fixed, never themed) */
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-bg: #e4f6e4; --warning-bg: #fdf1d8; --serious-bg: #fbe9e0; --critical-bg: #fae2e2;

  --track: #e9e7e3;          /* unfilled bar track */
  --ring: rgba(11,11,11,.10);

  --shadow-sm: 0 1px 2px rgba(20,20,10,.05), 0 1px 1px rgba(20,20,10,.04);
  --shadow-md: 0 4px 16px -6px rgba(20,20,10,.14), 0 1px 3px rgba(20,20,10,.05);
  --shadow-lg: 0 24px 60px -24px rgba(20,20,10,.28), 0 2px 8px rgba(20,20,10,.05);

  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 26px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:     #141413;  --plane-2: #1a1a19;
    --surface:   #1e1e1c;  --surface-2: #242422; --surface-3: #2a2a27;
    --ink:       #ffffff;  --ink-2: #c3c2b7; --muted: #898781; --faint: #6e6c66;
    --line:      #33332f;  --line-2: #2c2c2a; --grid: #2c2c2a; --axis: #383835;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --pos: #3987e5; --neg: #e66767; --mid: #383835;
    --good-bg: #14301a; --warning-bg: #33280d; --serious-bg: #33200f; --critical-bg: #331717;
    --track: #2e2e2b;
    --ring: rgba(255,255,255,.10);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 16px -6px rgba(0,0,0,.6), 0 1px 3px rgba(0,0,0,.4);
    --shadow-lg: 0 24px 60px -24px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --plane:     #141413;  --plane-2: #1a1a19;
  --surface:   #1e1e1c;  --surface-2: #242422; --surface-3: #2a2a27;
  --ink:       #ffffff;  --ink-2: #c3c2b7; --muted: #898781; --faint: #6e6c66;
  --line:      #33332f;  --line-2: #2c2c2a; --grid: #2c2c2a; --axis: #383835;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --pos: #3987e5; --neg: #e66767; --mid: #383835;
  --good-bg: #14301a; --warning-bg: #33280d; --serious-bg: #33200f; --critical-bg: #331717;
  --track: #2e2e2b;
  --ring: rgba(255,255,255,.10);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 16px -6px rgba(0,0,0,.6), 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 60px -24px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
::selection { background: var(--b150); color: #0b0b0b; }

/* ---------------- primitives ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  border: 1px solid transparent; background: var(--ink); color: var(--plane);
  font-size: 14.5px; font-weight: 500; letter-spacing: -.1px; cursor: pointer;
  transition: transform .18s var(--ease), opacity .18s var(--ease), background .18s var(--ease);
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); opacity: 1; }
.btn.sm { height: 32px; padding: 0 14px; font-size: 13.5px; }
.btn:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; letter-spacing: -.1px;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge.good     { background: var(--good-bg);     color: #0b6b0b; }
.badge.warning  { background: var(--warning-bg);  color: #7a5502; }
.badge.serious  { background: var(--serious-bg);  color: #8a4321; }
.badge.critical { background: var(--critical-bg); color: #8c1f1f; }
[data-theme="dark"] .badge.good { color: #6ede6e; }
[data-theme="dark"] .badge.warning { color: #f0c256; }
[data-theme="dark"] .badge.serious { color: #f0a781; }
[data-theme="dark"] .badge.critical { color: #f08a8a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.good { color: #6ede6e; }
  :root:not([data-theme="light"]) .badge.warning { color: #f0c256; }
  :root:not([data-theme="light"]) .badge.serious { color: #f0a781; }
  :root:not([data-theme="light"]) .badge.critical { color: #f08a8a; }
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.kicker {
  font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------------- result card ---------------- */

.card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 26px 28px 28px;
  position: relative;
}
.card-hd { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.card-hd h3 {
  margin: 0; font-size: 18.5px; line-height: 1.32; font-weight: 500; letter-spacing: -.35px;
  color: var(--ink); flex: 1;
}
.card-meta {
  margin: 7px 0 20px; font-size: 13px; color: var(--muted); letter-spacing: -.1px;
}
.card-foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12.5px; color: var(--muted);
}
.card-tools { display: flex; gap: 4px; }
.tool {
  height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tool:hover { background: var(--surface-2); color: var(--ink-2); }
.tool[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }

/* chart <-> table swap */
.viz-table { display: none; }
.card.as-table .viz-plot { display: none; }
.card.as-table .viz-table { display: block; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.dt th, table.dt td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-2); }
table.dt th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
table.dt td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------------- chart marks ---------------- */

.viz-plot { position: relative; }

.rows { display: flex; flex-direction: column; gap: 13px; }
.row { display: grid; grid-template-columns: minmax(120px, 40%) 1fr auto; align-items: center; gap: 16px; }
.row .lab { font-size: 14.5px; color: var(--ink-2); letter-spacing: -.15px; }
.row .track {
  position: relative; height: 15px; border-radius: 4px; background: var(--track); overflow: hidden;
}
.row .fill {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0;
  background: var(--b200); width: 0; transition: width .9s var(--ease);
}
.row.lead .fill { background: var(--s1); }
.row .val { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.row:hover .track { box-shadow: 0 0 0 2px var(--ring); }

.tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.tile {
  flex: 1 1 130px; background: var(--surface-2); border-radius: var(--r); padding: 12px 14px 11px;
}
.tile .t-lab { font-size: 11.5px; color: var(--muted); letter-spacing: -.05px; }
.tile .t-val { font-size: 27px; font-weight: 500; letter-spacing: -1px; line-height: 1.2; margin-top: 2px; }
.tile .t-val small { font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: -.2px; }
.tile .t-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 9px; height: 9px; border-radius: 2.5px; display: inline-block; }

/* diverging driver rows */
.div-rows { display: flex; flex-direction: column; gap: 11px; }
.div-row { display: grid; grid-template-columns: minmax(130px, 44%) 1fr 46px; align-items: center; gap: 14px; }
.div-row .lab { font-size: 14px; color: var(--ink-2); letter-spacing: -.15px; line-height: 1.3; }
.div-row .lane { position: relative; height: 16px; }
.lane-axis { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.div-bar {
  position: absolute; top: 0; bottom: 0; width: 0; background: var(--pos);
  transition: width .9s var(--ease);
}
.div-bar.pos { left: 50%; border-radius: 0 4px 4px 0; background: var(--pos); }
.div-bar.neg { right: 50%; border-radius: 4px 0 0 4px; background: var(--neg); }
.div-row .val { font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.div-row:hover .lane { box-shadow: 0 0 0 2px var(--ring); border-radius: 5px; }

/* segment stacks */
.seg-rows { display: flex; flex-direction: column; gap: 16px; }
.seg-lab { font-size: 13.5px; color: var(--ink-2); margin-bottom: 7px; display: flex; justify-content: space-between; gap: 12px; }
.seg-lab span { color: var(--muted); font-size: 12.5px; }
.seg-bar { display: flex; height: 30px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); }
.seg {
  width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden;
  transition: width .9s var(--ease);
}
.seg span { font-size: 11.5px; font-weight: 500; color: #fff; letter-spacing: -.1px; }
.seg:first-child { border-radius: 5px 0 0 5px; }
.seg:last-child { border-radius: 0 5px 5px 0; }

/* hero card */
.hero-card .hero-num { display: flex; align-items: baseline; gap: 10px; }
.hero-v { font-size: 62px; font-weight: 500; letter-spacing: -3px; line-height: 1.05; }
.hero-lab { font-size: 16px; color: var(--ink-2); margin-top: 6px; letter-spacing: -.2px; }
.hero-sub { font-size: 13.5px; color: var(--muted); margin-top: 14px; line-height: 1.55; }
.hero-sub b { color: var(--ink-2); font-weight: 500; }

/* verbatims */
.vb-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.vb-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vb-text {
  margin: 0; font-size: 16px; line-height: 1.62; color: var(--ink-2); letter-spacing: -.2px;
  animation: vbIn .35s var(--ease);
}
@keyframes vbIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.vb-who { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.vb-nav { display: flex; gap: 6px; margin-top: 16px; }
.vb-nav .tool { width: 34px; padding: 0; border: 1px solid var(--line); }

/* svg charts */
svg.radar, svg.curve { display: block; width: 100%; height: auto; overflow: visible; }
svg.radar text, svg.curve text { font-family: var(--sans); }

/* shared floating tooltip */
#viztip {
  position: fixed; z-index: 9000; pointer-events: none; opacity: 0;
  transform: translate(-50%, -100%) translateY(-10px);
  background: var(--ink); color: var(--plane);
  padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.4;
  box-shadow: var(--shadow-md); white-space: nowrap; transition: opacity .12s;
}
#viztip b { font-weight: 600; font-variant-numeric: tabular-nums; }
#viztip.on { opacity: 1; }

/* ---------------- mosaic ---------------- */

.mosaic { display: grid; gap: 4px; }
.mosaic i {
  display: block; border-radius: 4px; background: var(--b150);
  transition: background 1.2s var(--ease), opacity 1.2s var(--ease);
}

/* ---------------- utility ---------------- */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}
