/* The dashboard layout of turfLP 0.5.0: a settings column with a sticky Run
   bar beside a results column, each scrolling on its own. Colors, type and
   controls come from the SDK; the names below map the dashboard's own names
   onto SDK tokens, so both themes follow the SDK. */

:root {
  --bg: var(--surface-canvas);
  --surface: var(--surface-panel);
  --hover: var(--surface-hover);
  --selected: var(--surface-selected);
  --ink: var(--text-primary);
  --ink-2: var(--text-secondary);
  --line: var(--border-default);
  --line-strong: var(--border-strong);
  --grid: color-mix(in srgb, var(--text-primary) 8%, transparent);
  --focus: var(--focus-ring);
  --series: var(--chart-1);
  /* Product colors in the order of the 0.5.0 dashboard, whose neighbors pass
     the color vision checks in both themes. Later products share --turf-other. */
  --turf-cat-1: var(--chart-1);
  --turf-cat-2: var(--chart-3);
  --turf-cat-3: var(--chart-4);
  --turf-cat-4: var(--chart-5);
  --turf-cat-5: var(--chart-2);
  --turf-cat-6: var(--chart-6);
  --turf-cat-7: var(--chart-8);
  --turf-cat-8: var(--chart-7);
  --turf-other: var(--chart-12);
  --bar-out: color-mix(in srgb, var(--text-secondary) 30%, var(--surface-panel));
  --danger: var(--danger-text);
  --tip-bg: var(--surface-ink);
  --tip-ink: var(--text-on-ink-primary);
}
:root[data-theme="dark"] {
  --tip-bg: var(--text-primary);
  --tip-ink: var(--surface-canvas);
}

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
}

.app h2, .app h3, .app h4, .app p, .app dl, .app dd { margin: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--ink-2); }
.boot { padding: 24px; }

/* Layout */

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 0;
}

/* The two columns scroll on their own; Run stays in view. */
.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
  overflow-y: auto;
  position: relative;
}
.results-pane {
  overflow-y: auto;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
.results-pane > :last-child { margin-top: auto; }
/* The SDK footer has no inline padding; inside the pane it lines up with the results. */
.results-pane .app-footer { padding-inline: 40px; }
@media (max-width: 880px) { .results-pane .app-footer { padding-inline: 16px; } }

.run-bar {
  position: sticky;
  bottom: 0;
  z-index: var(--layer-sticky);
  margin: auto -24px 0;
  padding: 12px 24px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.run-bar button { width: 100%; }
.run-bar .hint:empty { display: none; }

.side-block h2 { font-size: 16px; line-height: 24px; font-weight: 600; margin-bottom: 12px; }

fieldset.side-block { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.side-block legend { padding: 0; }

.results {
  padding: 32px 40px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1440px;
  min-width: 0;
}

@media (max-width: 880px) {
  .app { height: auto; display: block; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px 16px 0; overflow: visible; }
  .results-pane { overflow: visible; }
  .run-bar { margin: 0 -16px; padding: 12px 16px 14px; }
  .results { padding: 24px 16px 48px; }
}

/* Data */

.field-label { display: block; font-size: 14px; line-height: 20px; font-weight: 500; margin-bottom: 8px; }

/* The size sits beside the name, so each example takes one line. */
.examples { margin: 0 -12px; }
.examples .selectable-list { --selectable-row-min: 36px; --selectable-row-pad: 8px 12px; }
.examples .selectable-list-text { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px; }
.examples .selectable-list-meta { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* A compact drop zone: the sidebar has room for one line of help. */
.drop { margin-top: 16px; font-size: 14px; line-height: 20px; }
.drop .file-picker-dropzone { min-height: 0; padding: 16px; background: var(--bg); }
.drop .drop-icon { display: none; }
.drop .file-picker-dropzone { padding: 10px 12px; gap: 2px; }
/* The visible line under it says the same; the label stays the accessible name. */
.drop .drop-target strong {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.hint { margin-top: 8px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.hint.is-error { color: var(--danger); }

.data-info { margin-top: 16px; font-size: 14px; line-height: 20px; display: flex; flex-direction: column; gap: 4px; }
.data-name { font-weight: 600; overflow-wrap: anywhere; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; cursor: pointer; }

/* Settings */

.setting { margin-bottom: 24px; }
.setting input[type="number"] { width: 5.5rem; }
.range .field { margin: 0; }
.range { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }

.fixed-filter { margin-bottom: 8px; }
.fixed-list {
  max-height: 15rem;
  overflow-y: auto;
  padding: 0 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.fixed-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: 13px;
  line-height: 20px;
  cursor: pointer;
}
.fixed-item:hover { background: var(--hover); }
.fixed-item.is-disabled { color: var(--ink-2); cursor: default; }
.fixed-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fixed-reach { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fixed-none { padding: 4px 12px; font-size: 13px; }
.fixed-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.fixed-sort {
  padding: 2px 6px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 150ms var(--motion-easing), color 150ms var(--motion-easing);
}
.fixed-sort:hover { background: var(--hover); color: var(--ink); }
.fixed-sort:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.fixed-sort.is-active { color: var(--ink); font-weight: 600; }

.stage-fields {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 12px;
  font-size: 14px;
}
.stage-fields label, .stage-fixed { color: var(--ink-2); }
.stage-fields > span:not(.stage-fixed) { padding-left: 13px; min-height: 40px; display: flex; align-items: center; }

/* Results */


.headline { display: flex; flex-direction: column; gap: 8px; }
.headline-title { font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.headline-products { font-size: 16px; line-height: 26px; max-width: 72ch; }
.headline .muted { font-size: 14px; }
.stats { margin: 8px 0 4px; max-width: 32rem; }

.is-stale .headline, .is-stale .panel-block { opacity: 0.55; }

.panel-block {
  container-type: inline-size;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px 24px;
  min-width: 0;
}
.block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 16px;
}
.block-title { display: flex; flex-direction: column; gap: 2px; max-width: 70ch; }
.block-head h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
.block-head p { font-size: 13px; line-height: 18px; }
.comparison { display: flex; flex-direction: column; gap: 6px; max-width: 70ch; margin-bottom: 24px; }
.deep-dive > .block-title { margin-bottom: 12px; }
.deep-dive > .block-title p { font-size: 13px; line-height: 18px; }
.sub-title { font-size: 14px; line-height: 20px; font-weight: 600; }
.panel-block > .hint, .panel-block > .panel-note { margin-top: 12px; }

/* Charts */

.chart { position: relative; min-height: 240px; }
.plot { display: block; overflow: visible; }
.plot .grid { stroke: var(--grid); stroke-width: 1; }
.plot .axis { stroke: var(--line-strong); stroke-width: 1; }
.plot .tick, .plot .axis-title { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.plot .ceiling { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.6; }
.plot .ceiling-label { fill: var(--ink-2); font-size: 12px; }
.plot .curve-line, .plot .frontier-line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .curve-area { fill: var(--series); fill-opacity: 0.08; }
.plot .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.plot .dot-selected { stroke: var(--ink); stroke-width: 2; }
.plot .dot-label { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plot .end-label { fill: var(--ink-2); font-size: 12px; font-weight: 500; }
.plot .chosen-mark { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.plot .baseline-mark { fill: var(--surface); stroke: var(--ink-2); stroke-width: 2; }
.plot .crosshair { stroke: var(--line-strong); stroke-width: 1; }
.plot .hit { fill: transparent; cursor: pointer; outline: none; }
.plot .hit:focus-visible { stroke: var(--focus); stroke-width: 2; rx: 6px; }
.plot .column { transition: opacity 150ms var(--motion-easing); }
.plot .column.is-dim { opacity: 0.72; }
.plot .column.is-hover { opacity: 1; }

.contrib-host { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.contrib-title { font-size: 14px; line-height: 20px; font-weight: 600; margin-bottom: 8px; }
.contrib { width: 100%; max-width: 32rem; border-collapse: collapse; font-size: 13px; line-height: 20px; font-variant-numeric: tabular-nums; }
.contrib th, .contrib td { padding: 3px 0; text-align: left; font-weight: 400; }
.contrib thead th { color: var(--ink-2); font-size: 12px; line-height: 18px; border-bottom: 1px solid var(--line); }
.contrib .num { text-align: right; padding-left: 16px; white-space: nowrap; }
.contrib tbody .name { overflow-wrap: anywhere; }
.contrib-swatch { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 3px; vertical-align: -1px; }

.tooltip {
  position: absolute;
  z-index: var(--layer-tooltip);
  max-width: 300px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--tip-bg);
  color: var(--tip-ink);
  font-size: 13px;
  line-height: 18px;
  box-shadow: var(--shadow-overlay);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.tip-strong { font-weight: 600; }
.tip-muted { opacity: 0.8; }

/* Tables */

.table-wrap { overflow-x: auto; margin: 0 -8px; }
.panel-block > .table-wrap:not(:first-child) { margin-top: 16px; }
.results-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.results-table th {
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.results-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.results-table tr:last-child td { border-bottom: 0; }
.results-table .num { text-align: right; white-space: nowrap; }
.results-table th.num { text-align: right; }
.results-table .products { min-width: 16rem; }
.results-table .sub { color: var(--ink-2); }
.results-table tbody tr[tabindex] { cursor: pointer; transition: background-color 120ms var(--motion-easing); }
.results-table tbody tr[tabindex]:hover { background: var(--hover); }
.results-table tbody tr.is-selected, .results-table tbody tr.is-selected:hover { background: var(--selected); }
.results-table tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.results-table .is-pending td { color: var(--ink-2); }



/* Product bars */

.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--ink-2); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.swatch-in { background: var(--series); }
.swatch-out { background: var(--bar-out); margin-left: 12px; }

.bars-host { position: relative; }
.bars { display: grid; gap: 2px; margin: 0 -8px; }
@container (min-width: 880px) {
  .bars { display: block; columns: 2; column-gap: 40px; }
  .bar-row { break-inside: avoid; margin-bottom: 2px; grid-template-columns: minmax(6rem, 11rem) minmax(0, 1fr) 3.75rem; }
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(6rem, 14rem) minmax(0, 1fr) 3.75rem;
  align-items: center;
  gap: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 20px;
  outline-offset: -2px;
}
.bar-row:hover { background: var(--hover); }
.bar-row:focus-visible { outline: 2px solid var(--focus); }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: block; min-width: 0; }
.bar-fill { display: block; height: 12px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--series); }
.bar-value { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.is-in .bar-name { font-weight: 600; }
.is-out .bar-name { color: var(--ink-2); }
.is-out .bar-fill { background: var(--bar-out); }

@media (max-width: 520px) {
  .panel-block { padding: 16px 16px 20px; }
  .contrib .num { padding-left: 8px; }
  .bar-row { grid-template-columns: minmax(5rem, 8rem) minmax(0, 1fr) 3.25rem; gap: 8px; }
  .headline-title { font-size: 22px; line-height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .fixed-sort, .plot .column, .results-table tbody tr[tabindex] { transition: none; }
}

@media (forced-colors: active) {
  .bar-fill, .swatch-in, .contrib-swatch { background: Highlight; forced-color-adjust: none; }
  .is-out .bar-fill, .swatch-out { background: GrayText; }
  .plot .curve-line, .plot .frontier-line { stroke: Highlight; }
  .plot .dot { fill: Highlight; }
  .plot .segment { fill: Highlight !important; }
}
