/* Parameters page. On top of tokens.css, scenario_results.css (page head) and
   calibration.css (the document pages' frame: page tokens, head card, main
   column, headings). From the 2026-10-21 sketches (ives-notes
   parameters-page/sketches_2026-10-21): sketch 3's tiles and two-column
   cards beside sketch 2's sticky index. Light mode only, as the host applet. */

.params-page {
  height: auto;   /* a scrolling document, not the map's full-height frame */
  /* Tier hues: one per tier, badge fill / badge text / row rule. */
  --tier-study-bg: #dcebfb;      --tier-study-fg: #174f8f;      --tier-study: #2a78d6;
  --tier-calibrated-bg: var(--gold-soft); --tier-calibrated-fg: #6b4d00; --tier-calibrated: var(--gold);
  --tier-scenario-bg: #eadcf5;   --tier-scenario-fg: #5b2d82;   --tier-scenario: #8e5bb5;
  --tier-loader-bg: #d4eef0;     --tier-loader-fg: #1d5f67;     --tier-loader: var(--tint-b);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.calib-main.p-main { max-width: 1320px; }
/* The filter hides rows, sections and headings with [hidden]; the phone's
   stacked rows set `display`, which would otherwise beat the UA's rule. */
.params-page [hidden] { display: none !important; }
.p-main h2 small, .p-sec { font-weight: 400; color: var(--ink-muted); font-family: var(--mono); font-size: 11px; }

/* ---- intro line: tier legend | Advanced switch ---- */
.p-intro-line {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 8px 0 6px; font-size: 12px; color: var(--ink-secondary);
}
.p-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.p-leg { white-space: nowrap; }
.p-adv { margin-left: auto; font-size: 13px; color: var(--n-33); font-weight: 600; }

/* ---- two columns: sticky index | body ---- */
.p-two { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; margin-top: 10px; }
.p-toc {
  position: sticky; top: 12px; align-self: start; font-size: 12.5px;
  max-height: calc(100vh - 24px); overflow-y: auto; padding-right: 4px;
}
.p-toc-head { font-size: 11px; font-weight: 700; color: var(--label-em); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 4px; }
.p-toc a { display: block; padding: 4px 0; color: var(--n-33); text-decoration: none; }
.p-toc a:hover { color: var(--brand-ink); text-decoration: underline; }
.p-toc a small { display: block; color: var(--ink-muted); font-size: 11px; }
.p-toc-adv { margin-top: 10px; border-top: 1px solid var(--hairline); padding-top: 6px; }
.p-toc-adv a.p-toc-all { font-weight: 700; }
.p-toc-adv a.p-toc-sec {
  display: flex; align-items: center; padding: 2px 0;
  font-family: var(--mono); font-size: 11.5px; overflow: hidden; white-space: nowrap;
}
.p-toc-adv a.p-toc-sec small { display: inline; margin-left: auto; padding-left: 6px; }
.p-toc-adv a.p-toc-studydef { font-style: italic; }
.p-toc-file { font-size: 11px; font-weight: 700; color: var(--label-em); margin: 10px 0 2px; border-bottom: 1px solid var(--hairline); overflow-wrap: anywhere; }
.p-dot {
  font-style: normal; font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  background: var(--gold-soft); color: var(--brand-ink); border-radius: 999px; padding: 0 6px; margin-left: 6px;
}

/* ---- tiles ---- */
.p-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 0 0 4px; }
.p-tile { background: var(--surface); border: 1px solid var(--hairline); border-radius: 8px; padding: 10px 12px; }
.p-tile b { display: block; font-size: 12px; color: var(--label-em); }
.p-tile span { display: block; font-size: 22px; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; }
.p-tile small { display: block; font-size: 11px; color: var(--ink-muted); }
.p-tile-study { border-left: 4px solid var(--tier-study); }
.p-tile-calibrated { border-left: 4px solid var(--tier-calibrated); }
.p-tile-scenario { border-left: 4px solid var(--tier-scenario); }
.p-tile-loader { border-left: 4px solid var(--tier-loader); }

/* ---- badges ---- */
.p-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; line-height: 1.5;
  padding: 0 7px; border-radius: 999px; white-space: nowrap; margin-right: 4px; vertical-align: 1px;
}
.p-default { background: var(--ground-band); color: var(--n-66); font-weight: 600; }
.p-study { background: var(--tier-study-bg); color: var(--tier-study-fg); }
.p-calibrated { background: var(--tier-calibrated-bg); color: var(--tier-calibrated-fg); }
.p-scenario { background: var(--tier-scenario-bg); color: var(--tier-scenario-fg); }
.p-loader { background: var(--tier-loader-bg); color: var(--tier-loader-fg); }
.p-studydef { background: transparent; color: var(--n-55); border: 1px dashed var(--n-aa); font-weight: 600; margin-left: 4px; }
.p-src { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); margin-right: 6px; overflow-wrap: anywhere; }
.p-def { color: var(--ink-muted); font-size: 11px; font-family: var(--mono); }
.p-nodef { color: var(--ink-muted); font-size: 10.5px; font-style: italic; }
.p-empty { color: var(--ink-muted); }

/* A non-default value inside a grid or matrix: a tint and a rule in its
   tier's hue; the title names the tier, file and codebase default. */
.p-cell { padding: 0 3px; border-radius: 2px; cursor: help; }
.p-cell-study { background: var(--tier-study-bg); box-shadow: inset 2px 0 var(--tier-study); }
.p-cell-calibrated { background: var(--tier-calibrated-bg); box-shadow: inset 2px 0 var(--tier-calibrated); }
.p-cell-scenario { background: var(--tier-scenario-bg); box-shadow: inset 2px 0 var(--tier-scenario); }
.p-cell-loader { background: var(--tier-loader-bg); box-shadow: inset 2px 0 var(--tier-loader); }

/* ---- curated cards ---- */
.p-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 14px; align-items: start; }
.p-card { background: var(--surface); border: 1px solid var(--hairline); border-radius: 8px; padding: 12px 14px; margin: 8px 0; min-width: 0; }
.p-card header { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.p-main .p-card h3 { margin: 0 6px 0 0; color: var(--heading); font-size: 13.5px; }
.p-headline { font-size: 24px; font-weight: 700; color: var(--heading); margin: 6px 0 0; font-variant-numeric: tabular-nums; line-height: 1.2; }
.p-headline.p-word { font-size: 18px; }
.p-headline.p-word code { font-family: var(--mono); font-size: 16px; }
.p-headline.p-list { font-size: 18px; }
.p-sep { color: var(--ink-muted); font-weight: 400; }
.p-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; }
.p-chips code { font-family: var(--mono); font-size: 11px; background: var(--ground-band); border-radius: 3px; padding: 1px 5px; }
.p-unit { font-size: 11.5px; color: var(--ink-muted); margin: 1px 0 2px; }
.p-sum { font-size: 12.5px; color: var(--ink-secondary); margin: 6px 0; max-width: 72ch; }
.p-calib { font-size: 12px; color: var(--tier-calibrated-fg); margin: 4px 0; }
.p-basis { font-size: 12px; color: var(--ink-secondary); border-left: 3px solid var(--hairline); padding-left: 8px; margin: 4px 0; max-width: 72ch; }
.p-card footer { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 11.5px; }
.p-key { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); overflow-wrap: anywhere; }
.p-doc { color: var(--label-em); font-weight: 600; text-decoration: none; }
.p-doc:hover { text-decoration: underline; }
.p-nodoc { color: var(--ink-muted); font-weight: 400; }
.p-bars { margin: 8px 0 2px; max-width: 420px; }
.p-bar { display: grid; grid-template-columns: minmax(70px, max-content) 1fr 40px; gap: 8px; align-items: center; font-size: 11.5px; margin: 2px 0; }
.p-bar span:first-child { font-family: var(--mono); font-size: 11px; color: var(--n-55); }
.p-bt { background: var(--ground-band); height: 10px; border-radius: 2px; }
.p-bt i { display: block; height: 100%; background: var(--series-modeled); border-radius: 2px; }
.p-bar b { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- nested values: grids, matrices, lists of tables ---- */
.p-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 1px 10px; margin: 2px 0; font-size: 11.5px; }
.p-kv dt { font-family: var(--mono); color: var(--ink-muted); font-size: 11px; }
.p-kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.p-kv .p-kv { margin: 0 0 2px; }
.p-matrix-wrap { max-width: 100%; overflow-x: auto; }
.p-matrix { border-collapse: collapse; font-size: 11px; margin: 4px 0; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.p-matrix th, .p-matrix td { padding: 1px 6px; text-align: right; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.p-matrix tbody th { text-align: left; font-weight: 600; color: var(--label-em); }
.p-matrix thead th { color: var(--ink-muted); font-weight: 600; }
.p-matrix td.p-absent { color: var(--n-bb); text-align: center; }
.p-matrix tr.p-xrow { display: none; }
.p-matrix.p-all tr.p-xrow { display: table-row; }
.p-matrix.p-all tr.p-more-row { display: none; }
.p-more-row td { text-align: left; border-bottom: 0; }
.p-more { font: inherit; font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: var(--label-em); background: none; border: 0; padding: 2px 0; cursor: pointer; }
.p-lod div { padding-left: 10px; text-indent: -10px; }

/* ---- Scenarios card ---- */
.p-scen { border-top: 1px solid var(--hairline); padding: 6px 0; }
.p-main .p-scen h3 { margin: 4px 0; font-family: var(--mono); font-size: 13px; color: var(--heading); }
.p-chip { font-family: var(--font-ui); font-size: 10.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-left: 4px; background: var(--ground-band); color: var(--n-55); }
.p-chip-unbuilt { background: transparent; border: 1px dashed var(--n-aa); }
.p-diff { list-style: none; padding: 0; margin: 2px 0; font-size: 12.5px; }
.p-diff li { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; padding: 3px 0; }
.p-diff code { font-family: var(--mono); font-size: 12px; }
.p-diff small { color: var(--ink-muted); font-family: var(--mono); font-size: 11px; }
.p-ftag { border: 1px solid var(--hairline); border-radius: 3px; padding: 0 4px; }
.p-arrow { margin-left: auto; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---- Advanced: filter + per-section tables ---- */
.p-adv-block { margin-top: 8px; }
.p-search {
  position: sticky; top: 0; z-index: 5; background: var(--page);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--hairline); margin: 8px 0 4px;
}
.p-search input[type=search] {
  flex: 1 1 280px; font: inherit; font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--n-cc); border-radius: 5px; background: var(--n-ff);
}
.p-search label { font-size: 12px; color: var(--ink-secondary); display: flex; gap: 4px; align-items: center; cursor: pointer; }
.p-count { font-size: 11.5px; color: var(--ink-muted); }
.p-main h3.p-file { font-family: var(--mono); font-size: 13px; margin: 20px 0 4px; color: var(--heading); }
.p-file small, .p-file-sub small { font-family: var(--font-ui); font-weight: 400; color: var(--ink-muted); font-size: 11.5px; }
.p-file-sub { font-size: 12px; color: var(--label-em); margin: 14px 0 4px; }
.p-nomatch { font-size: 12.5px; color: var(--ink-muted); margin: 10px 0; }
.p-secd { border: 1px solid var(--hairline); border-radius: 6px; background: var(--surface); margin: 6px 0; }
.p-secd > summary { cursor: pointer; padding: 7px 10px; font-size: 13px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.p-secd > summary b { font-family: var(--mono); color: var(--heading); }
.p-meta { font-size: 11.5px; color: var(--ink-muted); }
.p-meta em { color: var(--brand-ink); font-style: normal; font-weight: 700; }
.p-hcom { font-size: 11.5px; color: var(--ink-secondary); margin: 0 10px 6px; font-style: italic; max-width: 100ch; }
.p-notes { margin: 0 10px 6px; font-size: 11.5px; color: var(--ink-secondary); }
.p-notes summary { cursor: pointer; color: var(--label-em); font-weight: 600; }
.p-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.p-table th {
  text-align: left; font-size: 11px; color: var(--ink-muted); font-weight: 600;
  padding: 4px 8px; background: var(--th-bg); position: sticky; top: 50px; z-index: 1;
}
.p-table th:nth-child(1) { width: 21%; }
.p-table th:nth-child(2) { width: 27%; }
.p-table th:nth-child(3) { width: 17%; }
.p-table td { padding: 5px 8px; border-top: 1px solid var(--hairline); vertical-align: top; overflow-wrap: anywhere; }
.p-k code { font-family: var(--mono); font-size: 11.5px; color: var(--brand-ink); }
.p-star { color: var(--gold-deep); margin-left: 4px; }
.p-v { font-family: var(--mono); font-size: 11.5px; }
.p-table tr.p-tier-study td:first-child { box-shadow: inset 3px 0 var(--tier-study); }
.p-table tr.p-tier-calibrated td:first-child { box-shadow: inset 3px 0 var(--tier-calibrated); }
.p-table tr.p-tier-scenario td:first-child { box-shadow: inset 3px 0 var(--tier-scenario); }
.p-table tr.p-tier-loader td:first-child { box-shadow: inset 3px 0 var(--tier-loader); }
.p-table tr.p-tier-mixed td:first-child { box-shadow: inset 3px 0 var(--n-88); }
.p-o .p-badge { margin-bottom: 2px; }
.p-o .p-src, .p-o .p-def, .p-o .p-nodef { display: block; }
.p-com { color: var(--ink-secondary); font-size: 11.5px; }
.p-none { color: var(--ink-muted); }
.p-pre { white-space: pre-wrap; }
.p-subc { margin-top: 4px; white-space: pre-wrap; }
.p-subc code { font-family: var(--mono); font-size: 10.5px; color: var(--brand-ink); }
.p-cw:not(.p-open) .p-ctext {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.p-cw:not(.p-open) .p-ctext > div { display: inline; }
.p-cmore { font: inherit; font-size: 11px; font-weight: 600; color: var(--label-em); background: none; border: 0; padding: 0; cursor: pointer; }

/* ---- phone ---- */
@media (max-width: 760px) {
  .p-intro-line { margin-top: 6px; }
  .p-adv { margin-left: 0; font-size: 14px; }
  .p-adv input { width: 18px; height: 18px; }
  .p-two { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  /* The index becomes a strip of chips, in the flow (not sticky: the filter
     bar is the one sticky strip on a phone). */
  .p-toc {
    position: static; display: flex; gap: 6px; overflow-x: auto; white-space: nowrap;
    max-height: none; padding: 6px 0 8px; border-bottom: 1px solid var(--hairline);
    -webkit-overflow-scrolling: touch;
  }
  .p-toc-head, .p-toc-file { display: none; }
  .p-toc a, .p-toc-adv a.p-toc-sec {
    flex: none; display: inline-flex; align-items: center; min-height: 32px;
    border: 1px solid var(--hairline); border-radius: 999px; padding: 2px 12px; background: var(--surface);
  }
  .p-toc a small { display: none; }
  .p-toc-adv { display: contents; }
  body:not(.adv-on) .p-toc-adv { display: none !important; }
  .p-toc-adv a.p-toc-sec small { display: none; }
  .p-tiles { grid-template-columns: 1fr 1fr; gap: 6px; }
  .p-tile { padding: 8px 10px; }
  .p-tile span { font-size: 18px; }
  .p-grid2 { grid-template-columns: minmax(0, 1fr); }
  .p-arrow { margin-left: 0; flex-basis: 100%; }
  .p-search input[type=search] { font-size: 16px; }   /* no iOS zoom-on-focus */
  .p-table, .p-table tbody, .p-table tr, .p-table td { display: block; width: auto; }
  .p-table thead { display: none; }
  .p-table tr { border-top: 1px solid var(--hairline); padding: 6px 8px 6px 10px; }
  .p-table td { border: 0; padding: 1px 0; }
  /* The row rule moves from the first cell to the stacked row. */
  .p-table tr.p-tier-study { box-shadow: inset 3px 0 var(--tier-study); }
  .p-table tr.p-tier-calibrated { box-shadow: inset 3px 0 var(--tier-calibrated); }
  .p-table tr.p-tier-scenario { box-shadow: inset 3px 0 var(--tier-scenario); }
  .p-table tr.p-tier-loader { box-shadow: inset 3px 0 var(--tier-loader); }
  .p-table tr.p-tier-mixed { box-shadow: inset 3px 0 var(--n-88); }
  .p-table tr td:first-child { box-shadow: none !important; }
  .p-o .p-src, .p-o .p-def, .p-o .p-nodef { display: inline; margin-left: 4px; }
  .p-table .p-o .p-default { display: none; }
  .p-bar { grid-template-columns: minmax(60px, max-content) 1fr 36px; }
}
