/* CarmenHelp — F P Caillet analysis. Palette validated with the dataviz validator
   (3-slot categorical, light mode: ALL CHECKS PASS; aqua carries a contrast WARN, so every
   chart ships direct labels AND a table view, which is the documented relief). */
:root {
  color-scheme: light;
  --surface-0: #ffffff;
  --surface-1: #fcfcfb;
  --surface-2: #f4f3ef;
  --line:      #e3e2dd;
  --line-2:    #cfcec8;
  --ink:       #0b0b0b;
  --ink-2:     #52514e;
  --muted:     #8a8880;
  --s1: #2a78d6;  /* blue   */
  --s2: #eb6834;  /* orange */
  --s3: #1baf7a;  /* aqua   */
  --good: #1baf7a; --warn: #eda100; --bad: #e34948;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #232322;
    --line: #35342f; --line-2: #4a4944;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8e84;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --good: #199e70; --warn: #c98500; --bad: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #232322;
  --line: #35342f; --line-2: #4a4944;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8e84;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --good: #199e70; --warn: #c98500; --bad: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--surface-0); color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--s1); }

/* ---------- shell ---------- */
header {
  position: sticky; top: 0; z-index: 30; background: var(--surface-1);
  border-bottom: 1px solid var(--line);
}
.bar { max-width: 1380px; margin: 0 auto; padding: 12px 20px; display: flex;
       align-items: baseline; gap: 16px; flex-wrap: wrap; }
.brand { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-weight: 400; }
nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
nav button {
  font: inherit; font-size: 13px; color: var(--ink-2); background: none; border: 0;
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
}
nav button:hover { background: var(--surface-2); color: var(--ink); }
nav button[aria-current="true"] { background: var(--s1); color: #fff; }
nav button:focus-visible, .tt:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--s1); outline-offset: 2px;
}
.tt { font: inherit; font-size: 12px; color: var(--ink-2); background: var(--surface-2);
      border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; cursor: pointer; }

main { max-width: 1380px; margin: 0 auto; padding: 22px 20px 80px; }
.view { display: none; }
.view.on { display: block; }

h1 { font-size: 24px; margin: 4px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 30px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
h3 { font-size: 14px; margin: 20px 0 8px; }
p.lede { color: var(--ink-2); max-width: 78ch; }
p { max-width: 84ch; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2);
       padding: 1px 5px; border-radius: 4px; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
         gap: 10px; margin: 14px 0 6px; }
.tile { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px;
        padding: 12px 14px; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tile .v { font-size: 21px; font-weight: 650; margin-top: 3px; letter-spacing: -.02em;
           font-variant-numeric: tabular-nums; }
.tile .s { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px;
      background: var(--surface-1); }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 7px 11px; text-align: left; border-bottom: 1px solid var(--line);
         white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2);
     font-weight: 600; z-index: 2; cursor: pointer; user-select: none; }
th.no { cursor: default; }
th .ind { color: var(--s1); margin-left: 4px; }
tbody tr:hover td { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono);
         font-size: 11.5px; }
td.wrap { white-space: normal; min-width: 320px; max-width: 620px; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px;
        border: 1px solid var(--line-2); }
.pill.good { border-color: var(--good); color: var(--good); }
.pill.bad  { border-color: var(--bad);  color: var(--bad); }
.pill.warn { border-color: var(--warn); color: var(--warn); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
           margin: 12px 0; padding: 10px 12px; background: var(--surface-1);
           border: 1px solid var(--line); border-radius: 10px; }
.filters label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column;
                 gap: 3px; text-transform: uppercase; letter-spacing: .05em; }
select, input[type="search"] {
  font: inherit; font-size: 12.5px; color: var(--ink); background: var(--surface-0);
  border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 8px; min-width: 120px;
}
input[type="search"] { min-width: 220px; }
.pager { display: flex; gap: 8px; align-items: center; margin: 10px 0; font-size: 12.5px;
         color: var(--ink-2); flex-wrap: wrap; }
.pager button { font: inherit; font-size: 12.5px; padding: 5px 11px; border-radius: 7px;
                border: 1px solid var(--line-2); background: var(--surface-1); color: var(--ink);
                cursor: pointer; }
.pager button[disabled] { opacity: .4; cursor: default; }

/* ---------- charts ---------- */
.chart { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px;
         padding: 14px; margin: 12px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart::after { content: ""; display: block; }
.chart h3 { margin: 0 0 2px; }
.chart .sub { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-2);
          margin-top: 8px; align-items: center; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block;
            margin-right: 5px; vertical-align: -1px; }
/* Heatmaps must NOT shrink to fit a phone: at 390px a 890px chart scales to 44% and its 9.5px
   labels become 4px. The chart container scrolls horizontally instead, which keeps every cell
   legible at any width. */
svg { display: block; height: auto; }
.chart svg { min-width: 0; }
svg text { font-family: inherit; }
.cellrect { transition: opacity .1s; }
.cellrect:hover { opacity: .72; }

/* ---------- docs ---------- */
.doclist { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.doccard { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px;
           padding: 12px 14px; cursor: pointer; }
.doccard:hover { border-color: var(--s1); }
.doccard .t { font-weight: 600; font-size: 13px; }
.doccard .m { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
#docbody { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px;
           padding: 18px 20px; margin-top: 12px; }
#docbody table { font-size: 11.5px; }
#docbody h1 { font-size: 19px; } #docbody h2 { font-size: 15px; } #docbody h3 { font-size: 13.5px; }
#docbody pre { background: var(--surface-2); padding: 10px 12px; border-radius: 8px;
               overflow-x: auto; font-size: 11.5px; }
#docbody blockquote { border-left: 3px solid var(--s1); margin: 10px 0; padding: 2px 0 2px 12px;
                      color: var(--ink-2); }
.tip { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--s2);
       border-radius: 8px; padding: 10px 13px; margin: 12px 0; font-size: 13px; max-width: 90ch; }
.loading { color: var(--muted); padding: 30px 0; }
/* ---------- narrow viewports ---------- */
@media (max-width: 900px) {
  .bar { padding: 10px 14px; gap: 10px; }
  main { padding: 16px 14px 60px; }
  nav { margin-left: 0; width: 100%; order: 3; }
  nav button { flex: 1 1 auto; padding: 8px 10px; font-size: 12.5px; }
  #theme { margin-left: auto; }
  h1 { font-size: 20px; } h2 { font-size: 15px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .tile .v { font-size: 18px; }
  .filters { padding: 9px 10px; gap: 7px; }
  .filters label { flex: 1 1 132px; }
  select, input[type="search"] { width: 100%; min-width: 0; }
  td.wrap { min-width: 200px; max-width: 78vw; }
  .doclist { grid-template-columns: 1fr; }
  #docbody { padding: 14px; }
  .pager { font-size: 12px; gap: 6px; }
}
@media (max-width: 520px) {
  .brand { font-size: 13.5px; }
  .brand span { display: block; font-size: 11.5px; }
  nav button { font-size: 12px; padding: 7px 8px; }
  th, td { padding: 6px 8px; }
  table { font-size: 12px; }
}
/* scroll affordance: tables and charts that overflow get a subtle inset shadow on the right */
.tw, .chart { background-image: linear-gradient(to left, rgba(0,0,0,.06), rgba(0,0,0,0) 22px);
              background-attachment: local, scroll; }

/* table-view disclosure under each chart (no inline styles: CSP is style-src 'self') */
details.tv { margin-top: 6px; }
details.tv > summary { cursor: pointer; }
details.tv .tw { margin-top: 8px; }

/* ---------- executive summary: a paged journey, one idea per page ---------- */
.ex { max-width: 900px; }
.ex .step { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.ex h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 10px; }
.ex .say { font-size: 16.5px; line-height: 1.5; color: var(--ink); max-width: 68ch;
           border-left: 3px solid var(--s1); padding-left: 14px; margin: 14px 0 18px; }
.ex h2 { border: 0; padding-top: 0; margin: 22px 0 8px; font-size: 15px; }
.big { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
       margin: 14px 0; }
.big .m { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px;
          padding: 13px 15px; }
.big .m .lab { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.big .m .num { font-size: 25px; font-weight: 660; letter-spacing: -.025em; margin-top: 3px;
               font-variant-numeric: tabular-nums; }
.big .m .cap { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; }
.num.dn { color: var(--bad); } .num.up { color: var(--good); } .num.fl { color: var(--ink-2); }
.bars { margin: 10px 0; }
.bar-row { display: grid; grid-template-columns: 132px minmax(80px,1fr) auto; gap: 10px;
           align-items: center; padding: 5px 0; font-size: 12.5px; }
.bar-row .lab { color: var(--ink-2); }
.bar-track { background: var(--surface-2); border-radius: 5px; height: 20px; position: relative;
             overflow: hidden; }
.bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px;
                white-space: nowrap; display: flex; gap: 7px; align-items: center;
                justify-content: flex-end; }
.verdict { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-2);
           color: var(--muted); }
.verdict.real { border-color: var(--bad); color: var(--bad); }
.verdict.noise { border-color: var(--line-2); color: var(--muted); }
.journey { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
           margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.journey button { font: inherit; font-size: 13px; padding: 9px 16px; border-radius: 8px;
                  border: 1px solid var(--line-2); background: var(--surface-1); color: var(--ink);
                  cursor: pointer; }
.journey button.next { background: var(--s1); border-color: var(--s1); color: #fff; font-weight: 560; }
.journey button[disabled] { opacity: .35; cursor: default; }
.journey .dots { display: flex; gap: 5px; margin-left: auto; }
.journey .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2);
                   display: block; }
.journey .dots i.on { background: var(--s1); }
.caveat { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--warn);
          border-radius: 8px; padding: 11px 14px; margin: 14px 0; font-size: 13px; max-width: 76ch; }
.srcnote { font-size: 11.5px; color: var(--muted); margin-top: 10px; max-width: 76ch; }
@media (max-width: 900px) {
  .ex h1 { font-size: 21px; } .ex .say { font-size: 15px; }
  .bar-row { grid-template-columns: 104px 1fr; }
  .bar-row .val { grid-column: 2; text-align: left; }
  .journey button { flex: 1 1 auto; }
}

/* trend charts scroll rather than shrink, same rule as the heatmaps */
.chart h3 + .sub { margin-bottom: 10px; }
.chart svg text { font-family: inherit; }

.legend i { border: 1px solid var(--line-2); }
.chart svg circle, .chart svg rect, .chart svg path { shape-rendering: geometricPrecision; }

.legend i.sw1 { background: var(--s1); }
.legend i.sw2 { background: var(--s2); }
.legend i.sw3 { background: var(--s3); }

/* ---- narrow-screen bar rows ----
   The base row is label | bar | value, with the value kept on one line. Below ~430px the value
   (percentage + n + verdict pill) cannot fit beside a usable bar, so the row stacks and the value
   is allowed to wrap. Measured at 320px: without this the verdict pill overflows by 16px. */
@media (max-width: 430px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; padding: 7px 0 9px; }
  .bar-row .lab { font-weight: 600; color: var(--ink); }
  .bar-row .val { grid-column: 1; justify-content: flex-start; white-space: normal;
                  flex-wrap: wrap; text-align: left; }
  .bar-row .verdict { white-space: normal; }
  .big { grid-template-columns: 1fr; }
}
