/* Storm Night case site. Same family as the other Tidewell cases; storm-blue accent, four unit-state colours. */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --sunk: #eef1f5;
  --text: #17202b;
  --muted: #586473;
  --border: #d9dfe7;
  --accent: #24508f;
  --accent-contrast: #ffffff;
  --ok: #1e7b4f;
  --warn: #9a5b00;
  --risk: #b3261e;
  /* unit states */
  --s-open: #d1495b;
  --s-held: #9b59b6;
  --s-conf: #d99a00;
  --s-sailed: #2e9e6a;
  --s-gone: #98a2b3;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --wrap: 1180px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d131b; --surface: #141c26; --sunk: #0f1620; --text: #e6ebf1; --muted: #9aa6b4; --border: #263241;
    --accent: #8fb4f0; --accent-contrast: #0d131b; --ok: #5cc28f; --warn: #e0a84a; --risk: #f08a82;
    --s-open: #ef6f7e; --s-held: #c39be0; --s-conf: #f2c14e; --s-sailed: #4fc58f; --s-gone: #5d6878;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d131b; --surface: #141c26; --sunk: #0f1620; --text: #e6ebf1; --muted: #9aa6b4; --border: #263241;
  --accent: #8fb4f0; --accent-contrast: #0d131b; --ok: #5cc28f; --warn: #e0a84a; --risk: #f08a82;
  --s-open: #ef6f7e; --s-held: #c39be0; --s-conf: #f2c14e; --s-sailed: #4fc58f; --s-gone: #5d6878;
  --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; font-size: 17px; overflow-x: hidden; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img, svg { max-width: 100%; height: auto; }
code, .mono { font-family: var(--mono); font-size: .9em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.measure { max-width: 70ch; }
.small { font-size: 14px; color: var(--muted); }
.note { font-size: 14px; color: var(--muted); font-style: italic; }
.hidden { display: none !important; }

.site-header { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 56px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; }
.site-header nav { display: flex; gap: 4px 16px; flex-wrap: wrap; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { color: var(--text); }

.hero { padding: 64px 0 32px; }
.eyebrow { color: var(--muted); font-size: 14px; letter-spacing: .02em; margin: 0 0 8px; }
h1 { font-size: clamp(30px, 5.4vw, 52px); line-height: 1.1; margin: 0 0 16px; letter-spacing: -0.015em; }
h2 { font-size: clamp(22px, 3vw, 30px); line-height: 1.2; margin: 0 0 14px; }
h3 { font-size: 18px; margin: 6px 0 4px; }
.lede { font-size: clamp(18px, 2.4vw, 21px); color: var(--muted); max-width: 62ch; margin: 0 0 24px; }
.section { padding: 44px 0; border-top: 1px solid var(--border); }
.sub-hero { padding: 40px 0 12px; }
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.crumbs a { color: var(--muted); }

.cta-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn.small-btn { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.grid { display: grid; gap: 16px; }
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cards-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card p { margin: 0; color: var(--muted); }
.card h3 { margin-top: 0; }
.stat { font-size: clamp(28px, 4vw, 38px); font-weight: 750; line-height: 1.1; letter-spacing: -0.01em; }
.stat .from { color: var(--muted); font-weight: 600; font-size: .6em; }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 4px; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.risk { color: var(--risk); } .chip.muted { color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }

.journey { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.journey a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); font-weight: 600; font-size: 15px; height: 100%; }
.journey a:hover { border-color: var(--accent); }
.step-no { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); font-size: 13px; flex: none; }

.site-footer { border-top: 1px solid var(--border); padding: 28px 0 48px; color: var(--muted); font-size: 14px; }

/* ---------- War room ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); margin: 8px 0 18px; }
.tabs button { font: inherit; font-size: 15px; font-weight: 600; padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 0 0 14px; }
.clock { font-family: var(--mono); font-size: 22px; font-weight: 700; min-width: 7.5ch; }
.controls input[type="range"] { flex: 1 1 240px; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: 14px; padding: 6px 12px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }
.dot.open { background: var(--s-open); } .dot.held { background: var(--s-held); } .dot.conf { background: var(--s-conf); } .dot.sailed { background: var(--s-sailed); } .dot.gone { background: var(--s-gone); }
.dot.ring { background: transparent; border: 2px solid var(--text); }

.replay { display: grid; gap: 16px; }
.lane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lane-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.lane-h h2 { font-size: 17px; margin: 0; }
.lane-b { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 0; }
@media (max-width: 820px) { .lane-b { grid-template-columns: 1fr; } }
.lane canvas { display: block; width: 100%; height: auto; background: var(--sunk); }
.meters { padding: 12px 14px; display: grid; gap: 8px; align-content: start; border-left: 1px solid var(--border); }
@media (max-width: 820px) { .meters { border-left: 0; border-top: 1px solid var(--border); } }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 14px; }
.meter b { font-variant-numeric: tabular-nums; font-size: 15px; }
.bar { grid-column: 1 / 3; height: 7px; background: var(--sunk); border-radius: 4px; overflow: hidden; position: relative; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .15s linear; }
.bar i.over { background: var(--risk); }
.bar .cap { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .6; }
.ticker { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; font-family: var(--mono); color: var(--muted); }
.ticker li { padding: 3px 0; border-top: 1px dashed var(--border); }
.ticker li.alert { color: var(--risk); } .ticker li.good { color: var(--ok); }

/* Board */
.board-head { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.board-head .counts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); }
.board-head .counts b { color: var(--text); }
.board-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 920px) { .board-grid { grid-template-columns: minmax(0, 1fr); } }
.board-grid > *, .board-grid .grid > * { min-width: 0; }
.board-grid .grid { grid-template-columns: minmax(0, 1fr); }
.facts dd { min-width: 0; overflow-wrap: anywhere; }
.panel-b { overflow-wrap: anywhere; }
.cap-table td { font-size: 14px; }
.cap-table .bar { height: 8px; min-width: 70px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); align-items: center; }
.filters button { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.filters input { font: inherit; font-size: 14px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); flex: 1 1 140px; min-width: 0; }
.ulist { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.urow { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; width: 100%; text-align: left; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--border); border-left: 4px solid transparent; background: none; font: inherit; color: inherit; cursor: pointer; }
.urow:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.urow[aria-current="true"] { background: color-mix(in srgb, var(--accent) 11%, transparent); border-left-color: var(--accent); }
.urow .id { font-family: var(--mono); font-size: 13px; }
.urow .what { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow .to { font-family: var(--mono); font-size: 13px; font-weight: 700; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-h h2, .panel-h h3 { font-size: 16px; margin: 0; }
.panel-b { padding: 14px; }
.reasons { list-style: none; margin: 8px 0 0; padding: 0; font-family: var(--mono); font-size: 13px; }
.reasons li { padding: 4px 0 4px 10px; border-left: 3px solid var(--border); margin: 2px 0; }
.reasons li.rule { border-left-color: var(--accent); }
.reasons li.final { border-left-color: var(--ok); font-weight: 700; }
.reasons li.bad { border-left-color: var(--risk); color: var(--risk); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 14px; margin: 8px 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.form-row select { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 100%; }
.msg { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 12px; font-size: 14px; }
.msg .mh { background: var(--sunk); padding: 6px 12px; font-size: 13px; color: var(--muted); }
.msg .mb { padding: 10px 12px; white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; }
.audit { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* Policy lab */
.policy-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.policy { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.policy[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.policy .owner { font-size: 13px; color: var(--muted); }
.hbars { display: grid; gap: 6px; margin-top: 10px; }
.hbar { display: grid; grid-template-columns: 1fr auto; font-size: 13px; gap: 2px 8px; }
.hbar .bar { height: 6px; }

/* Tour */
.tour { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 50; width: min(760px, calc(100vw - 24px)); background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 10px 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: 0 10px 32px rgb(0 0 0 / 30%); }
.tour p { margin: 0; font-size: 15px; flex: 1 1 320px; }
.tour .tour-step { font-size: 12px; opacity: .7; display: block; }
.tour-actions { display: flex; gap: 6px; }
.tour button { font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 999px; border: 1px solid currentColor; background: transparent; color: inherit; cursor: pointer; }
.tour button:disabled { opacity: .4; }
.tour-flash { animation: flash 1.4s ease-out 1; }
@keyframes flash { from { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 65%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .tour-flash { animation: none; } html { scroll-behavior: auto; } .bar i { transition: none; } }

/* Trace explorer */
.trace-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.trace { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 26px; padding: 14px; min-width: max-content; }
.trace svg.edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.tcol h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.tnode { display: block; width: 100%; text-align: left; font: inherit; font-size: 12px; line-height: 1.25; padding: 5px 7px; margin: 0 0 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; position: relative; z-index: 1; }
.tnode b { font-family: var(--mono); font-size: 11.5px; display: block; }
.tnode span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.tnode.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.tnode.sel { box-shadow: 0 0 0 2px var(--accent); }
.trace.dim .tnode:not(.on) { opacity: .28; }
.tpanel { position: sticky; top: 70px; }

/* Process: BPMN + event storming */
.bpmn-figure { margin: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; overflow-x: auto; }
.bpmn-figure img { max-width: none; width: 1500px; height: auto; display: block; }
.bpmn-figure figcaption { color: #586473; font-size: 14px; margin-top: 8px; }
.es-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; padding: 0; margin: 0 0 12px; font-size: 14px; }
.es-legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.board-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px; }
.es-board { display: grid; grid-auto-flow: column; grid-auto-columns: 180px; gap: 12px; min-width: max-content; }
.es-col { display: flex; flex-direction: column; gap: 8px; }
.es-col h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 2px; }
.sticky { color: #17202b; padding: 7px 9px; border-radius: 3px; font-size: 13.5px; line-height: 1.3; box-shadow: 0 1px 2px rgb(0 0 0 / 18%); }
.s-event { background: #f6a04d; } .s-command { background: #7db3e8; } .s-actor { background: #f5e27a; } .s-policy { background: #c9a9e9; } .s-read { background: #9fd8a5; } .s-hot { background: #b8322a; color: #fff; transform: rotate(-1.5deg); }

/* Numbers page */
.tornado .row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr); gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.tornado .track { position: relative; height: 18px; }
.tornado .seg-l, .tornado .seg-h { position: absolute; top: 2px; height: 14px; }
.tornado .seg-l { background: var(--s-open); border-radius: 3px 0 0 3px; }
.tornado .seg-h { background: var(--s-sailed); border-radius: 0 3px 3px 0; }
.tornado .mid { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
.tornado .zero { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--risk); }
.slider-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 2px 10px; align-items: center; margin: 10px 0; font-size: 14px; }
.slider-row input { grid-column: 1 / 3; accent-color: var(--accent); width: 100%; }
.slider-row output { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.big-npv { font-size: clamp(32px, 5vw, 46px); font-weight: 800; letter-spacing: -0.02em; }

@media print { .site-header, .cta-row, .tour, .controls { display: none; } body { background: #fff; } }
td.mono, .mono { white-space: nowrap; }
.policy { display: flex; flex-direction: column; justify-content: flex-start; }
