/* ==========================================================================
   Cascadia Deal Desk — page furniture.

   Layout carried over from cascadia.css in the Semiconductors module so the
   two read as siblings. The palette does NOT carry over: every token below
   is from the Cascadia design system v2.0. The old module's navy/blue tokens
   predate the system and are deliberately not used here.

   Rule 5.3: no text anywhere in a chart falls below 12px. Page furniture
   holds the same floor for consistency.
   Rule 5.7: light only. A dark palette would have to be separately authored
   and separately validated, so the page declares its scheme rather than
   letting the browser guess.
   ========================================================================== */

:root {
  color-scheme: light;                    /* Rule 5.7 */

  /* surfaces & ink — design system v2.0 */
  --paper:       #FCFCFA;   /* chart surface        */
  --page:        #F7F8F6;   /* page behind the cards */
  --basalt:      #232B27;   /* text ink             */
  --slate-moss:  #5B6660;   /* secondary ink        */
  --mist:        #E4E7E3;   /* rules, gridlines     */
  --spruce:      #16241D;   /* chrome only, never a chart background */

  /* categorical slots — fixed order, never re-dealt (Rule 2.3.1) */
  --evergreen:   #1E7A4C;
  --glacier:     #4C8BC0;
  --madrona:     #C05A2E;
  --lupine:      #7B68AE;
  --lichen:      #9C7A20;
  --rain:        #9AA6A0;   /* de-emphasis — only ever with a direct label */

  --ring:        rgba(35, 43, 39, 0.10);

  /* Sentiment. Rule 2.3.2: colour is never the only channel — every chip
     below also carries a sign or a word. */
  --up-ink:      #1E7A4C;
  --up-bg:       #E9F1EC;
  --down-ink:    #A8481F;
  --down-bg:     #F8EDE7;
  --flat-ink:    #5B6660;
  --flat-bg:     #EFF1EE;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans:  "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--basalt);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px 56px; }

a { color: var(--evergreen); }
a:focus-visible, button:focus-visible, select:focus-visible,
input:focus-visible, summary:focus-visible, th[role="button"]:focus-visible {
  /* Rule 5.3 + adopted AAA 2.4.13: >=2px, >=3:1, never clipped. */
  outline: 2px solid var(--evergreen);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- skip link (Rule 5.3 / keyboard) ---- */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--paper); color: var(--basalt);
  padding: 10px 14px; border: 1px solid var(--ring); z-index: 50;
}
.skip:focus { left: 8px; top: 8px; }

/* ---- header ---- */
.site-head { padding: 28px 0 4px; }
.kicker {
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--slate-moss); margin: 0 0 8px;
}
.kicker a { color: var(--slate-moss); text-decoration: none; }
.kicker a:hover { text-decoration: underline; }
.kicker .sep { opacity: 0.5; padding: 0 6px; }
.kicker a[aria-current="page"] { color: var(--basalt); font-weight: 600; }

h1 {
  font-family: var(--serif);
  font-size: clamp(23px, 4.5vw, 31px);
  margin: 0 0 8px; font-weight: 600; letter-spacing: -0.01em;
}
.subtitle {
  font-family: var(--serif);
  color: var(--slate-moss); margin: 0 0 12px; max-width: 68ch; font-size: 16.5px;
}
.asof {
  display: inline-block; font-size: 12.5px; color: var(--slate-moss);
  background: var(--paper); border: 1px solid var(--ring);
  border-radius: 999px; padding: 4px 12px;
}
.asof strong { color: var(--basalt); font-weight: 600; }

/* ---- synthetic-data disclosure — above the first number, unmissable ---- */
.disclosure-banner {
  display: flex; gap: 11px; align-items: flex-start;
  background: var(--paper);
  border: 1px solid var(--ring);
  border-left: 4px solid var(--madrona);
  border-radius: 3px;
  padding: 12px 16px; margin: 18px 0 6px;
  font-size: 13.5px; color: var(--basalt); max-width: 92ch;
}
.disclosure-banner .tag {
  font-size: 12px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--madrona); white-space: nowrap;
  padding-top: 1px;
}
.disclosure-banner p { margin: 0; }
.disclosure-banner .detail { color: var(--slate-moss); margin-top: 3px; }

/* ---- section headings ---- */
h2 {
  font-family: var(--serif);
  font-size: 19px; font-weight: 600; margin: 40px 0 4px;
}
h3 { font-family: var(--serif); font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.section-note { color: var(--slate-moss); font-size: 13.5px; margin: 0 0 16px; max-width: 80ch; }

/* the martini-glass stem is visually distinct from the filtered analysis */
.overview { border-top: 2px solid var(--evergreen); padding-top: 4px; }
.stage-label {
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--evergreen); font-weight: 700; margin: 20px 0 0;
}

/* ---- the finding sentence ---- */
.headline {
  font-family: var(--serif); font-size: clamp(19px, 2.6vw, 25px);
  line-height: 1.42; margin: 10px 0 6px; max-width: 30ch; font-weight: 600;
}
.headline .num { color: var(--evergreen); white-space: nowrap; }
.headline .num-gone { color: var(--madrona); white-space: nowrap; }
.headline-note { color: var(--slate-moss); font-size: 13.5px; margin: 0 0 4px; max-width: 74ch; }

/* ---- KPI cards — Rule 2.5: number, label, delta. Nothing else. ---- */
.kpi-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(214px, 1fr));
  margin-top: 14px;
}
.kpi {
  background: var(--paper); border: 1px solid var(--ring);
  border-radius: 4px; padding: 15px 17px 13px;
}
.kpi .label { font-size: 13px; color: var(--slate-moss); margin: 0 0 3px; }
.kpi .value {
  font-size: 27px; font-weight: 600; margin: 0; line-height: 1.18;
  font-variant-numeric: tabular-nums; letter-spacing: -0.015em;
}
.kpi .value .unit { font-size: 15px; font-weight: 500; color: var(--slate-moss); }
.kpi .foot { margin-top: 7px; font-size: 12px; color: var(--slate-moss); }
.kpi .chips { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px; }

/* variance chips — sign + word + colour, never colour alone (Rule 2.3.2) */
.chip {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-size: 12px; font-weight: 600; border-radius: 3px; padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}
.chip .tag { font-weight: 500; opacity: 0.85; }
.chip.up   { color: var(--up-ink);   background: var(--up-bg); }
.chip.down { color: var(--down-ink); background: var(--down-bg); }
.chip.flat { color: var(--flat-ink); background: var(--flat-bg); }

/* ---- controls ---- */
.controls {
  background: var(--paper); border: 1px solid var(--ring); border-radius: 4px;
  padding: 15px 17px; margin: 16px 0 6px;
  display: grid; gap: 16px 22px;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  align-items: end;
}
.controls .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.controls label { font-size: 12.5px; color: var(--slate-moss); font-weight: 600; }
.controls select, .controls input[type="date"] {
  font-family: var(--sans); font-size: 13.5px; color: var(--basalt);
  background: var(--paper); border: 1px solid var(--ring); border-radius: 3px;
  padding: 7px 9px; min-height: 34px;   /* Rule 5.3 target size */
  max-width: 100%;
}
.controls input[type="range"] { width: 100%; min-height: 24px; accent-color: var(--evergreen); }
.controls .range-row { display: flex; gap: 10px; align-items: center; }
.controls .range-row output {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px;
  min-width: 74px; text-align: right;
}
.btn-reset {
  font-family: var(--sans); font-size: 13px; color: var(--basalt);
  background: var(--paper); border: 1px solid var(--ring); border-radius: 3px;
  padding: 7px 13px; min-height: 34px; cursor: pointer;
}
.btn-reset:hover { border-color: var(--slate-moss); }

/* Rule 6.6 — a control that removes data says how much it removed. */
.filter-state {
  margin: 10px 0 0; padding: 9px 13px;
  background: var(--paper); border: 1px solid var(--ring);
  border-left: 3px solid var(--evergreen); border-radius: 3px;
  font-size: 13px; color: var(--basalt); max-width: 92ch;
}
.filter-state .muted { color: var(--slate-moss); }
.filter-state strong { font-variant-numeric: tabular-nums; }

/* ---- chart cards ---- */
/* align-items:start, not the grid default of stretch.
   Titles are functions of the filter state (Rule 6.4), so their line count
   changes as the reader filters. Under `stretch` a card's trailing whitespace
   is a function of its NEIGHBOUR's title length: filter the page and a card
   that did not change visibly resizes. That is the instability Rule 6.9 is
   about. The equal-height frame bought nothing in exchange, because plot
   heights are banked to the data (Rule 1.3) and cannot absorb the slack —
   the plot areas never aligned anyway. Cost accepted: ragged card bottoms. */
.chart-grid {
  display: grid; gap: 18px; grid-template-columns: 1fr 1fr;
  margin-top: 16px; align-items: start;
}
.chart-grid.one { grid-template-columns: 1fr; }
@media (max-width: 860px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--paper); border: 1px solid var(--ring);
  border-radius: 4px; padding: 15px 15px 11px; min-width: 0;
}
.chart-card .chart { width: 100%; }
.chart-card .rel {
  font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--slate-moss); margin: 0 0 8px;
}
.chart-card .rel b { color: var(--evergreen); font-weight: 700; }

/* Rule 5.1 — the data table, one keystroke away, never more than that. */
details.data-table { margin-top: 10px; border-top: 1px solid var(--mist); padding-top: 7px; }
details.data-table > summary {
  cursor: pointer; font-size: 12.5px; color: var(--evergreen);
  list-style: none; padding: 3px 0; min-height: 24px; display: inline-block;
}
details.data-table > summary::-webkit-details-marker { display: none; }
details.data-table > summary::before { content: "▸ "; }
details.data-table[open] > summary::before { content: "▾ "; }
details.data-table .scroll { max-height: 320px; overflow: auto; margin-top: 6px; }

table.data {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
table.data caption { text-align: left; color: var(--slate-moss); font-size: 12px; padding: 4px 0 7px; }
table.data th, table.data td { padding: 5px 9px; border-bottom: 1px solid var(--mist); text-align: left; }
table.data th {
  position: sticky; top: 0; background: var(--paper); color: var(--slate-moss);
  font-weight: 600; z-index: 1; text-align: left;
}
table.data td.num, table.data th.num { text-align: right; }
table.data tbody tr:hover td { background: #F4F6F3; }

/* ---- the exception table — the thing a finance team would actually use ---- */
.table-wrap { background: var(--paper); border: 1px solid var(--ring); border-radius: 4px; padding: 4px 4px 8px; margin-top: 14px; }
.table-scroll { max-height: 560px; overflow: auto; }
table.exceptions { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.exceptions caption { text-align: left; padding: 11px 12px 9px; font-size: 13px; color: var(--slate-moss); }
table.exceptions th, table.exceptions td { padding: 7px 7px; border-bottom: 1px solid var(--mist); white-space: nowrap; }
table.exceptions thead th {
  position: sticky; top: 0; background: var(--paper); z-index: 2;
  color: var(--slate-moss); font-weight: 600; text-align: left;
  border-bottom: 1px solid var(--ring); cursor: pointer; user-select: none;
}
table.exceptions thead th .dir { color: var(--evergreen); font-weight: 700; }
table.exceptions th.num, table.exceptions td.num { text-align: right; }
table.exceptions tbody tr:hover td { background: #F4F6F3; }
table.exceptions td.neg { color: var(--down-ink); }
.tag-approved {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  color: var(--up-ink); background: var(--up-bg); border-radius: 3px; padding: 1px 7px;
}
.tag-none { color: var(--slate-moss); font-size: 12px; }

/* Rule 6.8 — empty states are designed, never a blank frame. */
.empty-state {
  padding: 26px 18px; text-align: center; color: var(--slate-moss);
  font-size: 14px; background: var(--paper); border: 1px dashed var(--ring); border-radius: 4px;
}
.empty-state strong { color: var(--basalt); display: block; margin-bottom: 5px; font-size: 15px; }

/* ---- method block & disclosure footer ---- */
.method {
  background: var(--paper); border: 1px solid var(--ring); border-radius: 4px;
  padding: 8px 24px 18px; margin-top: 16px; font-size: 14px; color: var(--basalt);
}
.method h3 { margin: 18px 0 5px; }
.method p, .method li { color: var(--slate-moss); max-width: 88ch; }
.method p { margin: 6px 0; }
.method ul { padding-left: 1.2em; margin: 6px 0; }
.method li { margin: 6px 0; }
.method strong { color: var(--basalt); }
.method .callout {
  border-left: 3px solid var(--evergreen); padding: 2px 0 2px 13px; margin: 12px 0;
}
.method .callout p { color: var(--basalt); }

.disclosure {
  margin: 30px 0 0; padding-top: 16px; border-top: 1px solid var(--mist);
  font-size: 12.5px; color: var(--slate-moss); max-width: 92ch;
}

.cascadia-nav { margin-top: 4px; }
.cascadia-nav > [role="application"]:focus-visible {
  outline: 2px solid var(--evergreen); outline-offset: 2px;
}
.sm-panel.is-cursor { box-shadow: inset 0 0 0 2px var(--evergreen); }

/* visually hidden but available to assistive tech (Rule 5.1 layer 1) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- small multiples grid (customer page) ---- */
.sm-claim { font-family: var(--serif); font-size: 17px; margin: 16px 0 6px; max-width: 74ch; }
.sm-sub { font-size: 12.5px; color: var(--slate-moss); margin: 0 0 8px; }
.sm-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 4px; font-size: 12px; color: var(--slate-moss); }
.sm-key .k { display: inline-flex; align-items: center; gap: 6px; }
.sm-key .k::before { content: ""; width: 13px; height: 3px; background: var(--rain); flex: 0 0 13px; }
.sm-key .k-sel::before { height: 11px; width: 11px; background: transparent; border: 2px solid var(--evergreen); }
.sm-key .k-ero::before { height: 11px; width: 3px; background: var(--madrona); }
.sm-key .k-band::before { height: 9px; background: var(--rain); opacity: 0.30; }
.sm-key .k-gap::before { background: linear-gradient(90deg, var(--evergreen) 40%, transparent 40%, transparent 60%, var(--evergreen) 60%); }

.sm-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); margin-top: 14px; }
@media (max-width: 1000px) { .sm-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .sm-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px)  { .sm-grid { grid-template-columns: 1fr; } }
.sm-panel { background: var(--paper); border: 1px solid var(--ring); border-radius: 3px; padding: 8px 8px 5px; min-width: 0; }
.sm-panel .sm-chart { width: 100%; height: 118px; }
.sm-panel .sm-name { font-size: 12px; font-weight: 600; margin: 0 0 1px; }
.sm-panel .sm-stat { font-size: 12px; color: var(--slate-moss); margin: 0; font-variant-numeric: tabular-nums; }
.sm-panel.is-selected { border-color: var(--evergreen); box-shadow: inset 0 0 0 1px var(--evergreen); }
/* an erosion case: full compliance, falling margin. Marked with a rule and a
   word in the panel stat line, never by colour alone. */
.sm-panel.is-eroding { border-left: 3px solid var(--madrona); }
.sm-panel .sm-flag { color: var(--down-ink); font-weight: 600; }

/* ---- responsive (Rule 5.5): reflow at 320px, no two-dimensional scrolling ---- */
/* Eleven columns overflow the 1140px wrap at every desktop width, and the
   container is capped by the wrap rather than the viewport — so this fold is
   unconditional, not a breakpoint. Agreed price is derivable from quoted price
   plus variance, and variance percent from variance dollars; both stay in the
   per-chart data table and reappear in the narrow card list. */
table.exceptions th.fold, table.exceptions td.fold { display: none; }

@media (max-width: 1040px) {
  .wrap { padding: 0 14px 40px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 23px; }
  /* the exception table degrades to a card list rather than scrolling sideways */
  table.exceptions thead { display: none; }
  table.exceptions, table.exceptions tbody, table.exceptions tr, table.exceptions td { display: block; width: 100%; }
  table.exceptions tr {
    border: 1px solid var(--ring); border-radius: 3px;
    margin: 0 8px 9px; padding: 7px 3px; background: var(--paper);
  }
  table.exceptions td, table.exceptions td.fold {
    border: 0; padding: 3px 11px; white-space: normal;
    display: flex; justify-content: space-between; gap: 14px;
  }
  table.exceptions td::before {
    content: attr(data-label); color: var(--slate-moss); font-size: 12px; flex: 0 0 auto;
  }
  table.exceptions td.num { text-align: right; }
  .table-scroll { max-height: none; overflow: visible; }
}
@media (max-width: 400px) { .kpi-grid { grid-template-columns: 1fr; } }

/* Rule 5.6 — nothing moves for a reader who asked for that. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .controls, .btn-reset, details.data-table { display: none; }
  body { background: #fff; }
  .chart-card, .kpi, .method { break-inside: avoid; }
}
