/* Collection Health & Weeding Studio.
 *
 * The treemap is the page. Its fills are fixed rather than themed (see the
 * scale comment in weedingstudio.js): sage for a healthy section through
 * amber to oxblood for one that needs work. Surfaces, type and the accent
 * come from the site preset.
 */

.product[data-product="weeding-studio"] {
  --ws-line: color-mix(in srgb, var(--text) 15%, transparent);
  --ws-soft: color-mix(in srgb, var(--text) 4%, var(--surface));
  --ws-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ws-weed: #9b2f22; --ws-replace: #2f5f8a; --ws-mend: #8a5a00; --ws-move: #5b4a8a; --ws-keep: #2f6b3a;
  --ws-flag: #b4482a; --ws-worn: #2f6f8a;
}

.ws-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ws-pane { display: grid; gap: .9rem; min-width: 0; }
.ws-muted { color: var(--muted); font-size: .9rem; }
.ws-loading { color: var(--muted); padding: 2rem 0; }
.ws-empty { display: grid; gap: .6rem; max-width: 38rem; padding: 1rem 0; justify-items: start; }
.ws-empty h3 { margin: 0; }

.ws-field { display: grid; gap: .2rem; min-width: 0; }
.ws-field-label { font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.ws-grow { flex: 1 1 14rem; }

.ws-bar, .ws-tools, .ws-filters {
  display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: end;
}
.ws-bar { padding: .6rem .8rem; border: 1px solid var(--ws-line); border-radius: var(--radius); background: var(--ws-soft); }
.ws-bar select, .ws-tools select, .ws-filters select { max-width: 100%; }
.ws-bar-actions { margin-left: auto; display: flex; gap: .5rem; }

/* ── Headline figures ──────────────────────────────────────────────── */

.ws-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .5rem; }
.ws-kpi {
  display: grid; align-content: start; gap: .1rem; padding: .6rem .75rem;
  border: 1px solid var(--ws-line); border-radius: var(--radius); background: var(--surface);
}
.ws-kpi-value { font: 700 1.55rem/1.1 var(--font-heading); font-variant-numeric: tabular-nums; }
.ws-kpi-label { font-size: .85rem; color: var(--muted); }
.ws-kpi-sub { font-size: .78rem; color: var(--muted); }
.ws-kpi.tone-warn .ws-kpi-value { color: var(--ws-flag); }

/* ── Legend and breadcrumb ─────────────────────────────────────────── */

.ws-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; font-size: .82rem; color: var(--muted); margin-left: auto; }
.ws-ramp { display: inline-block; width: 9rem; height: .7rem; border-radius: 2px; border: 1px solid var(--ws-line); }
.ws-legend-note { flex-basis: 100%; text-align: right; }

.ws-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .35rem; font-size: .95rem; }
.ws-crumbs button[aria-current="location"] { color: var(--text); font-weight: 700; text-decoration: none; }
.ws-crumb-sep { color: var(--muted); }

/* ── The map and its side panel ────────────────────────────────────── */

.ws-map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1rem; align-items: start; }
@media (max-width: 1020px) { .ws-map-layout { grid-template-columns: minmax(0, 1fr); } }

.ws-treemap {
  position: relative; width: 100%; aspect-ratio: 5 / 3; min-height: 16rem;
  border: 1px solid var(--ws-line); border-radius: var(--radius); overflow: hidden; background: var(--ws-soft);
}
@media (max-width: 560px) { .ws-treemap { aspect-ratio: 4 / 5; } }
.ws-cell {
  position: absolute; display: flex; flex-direction: column; justify-content: flex-start; gap: .1rem;
  margin: 0; padding: .35rem .45rem; border: 0; border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), inset 0 0 0 2px rgba(35, 26, 18, .08);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  overflow: hidden; transition: filter .12s;
}
.ws-cell:hover { filter: brightness(1.04) saturate(1.08); }
.ws-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 2; }
.ws-cell.is-selected { box-shadow: inset 0 0 0 3px var(--text); z-index: 1; }
.ws-cell.is-unknown { background: repeating-linear-gradient(45deg, var(--ws-soft) 0 6px, var(--surface) 6px 12px); }
.ws-cell-name { font-weight: 700; font-size: .88rem; line-height: 1.15; }
.ws-cell-meta { font-size: .76rem; opacity: .85; font-variant-numeric: tabular-nums; }
.ws-cell.is-small { padding: .15rem .25rem; }
.ws-cell.is-small .ws-cell-name { font-size: .7rem; font-weight: 600; }
.ws-treemap-leaf { display: grid; place-content: center; gap: .8rem; height: 100%; padding: 1.5rem; text-align: center; justify-items: center; }

.ws-side {
  display: grid; gap: .55rem; padding: .85rem; border: 1px solid var(--ws-line);
  border-radius: var(--radius); background: var(--surface); min-width: 0;
}
.ws-eyebrow { margin: 0; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ws-side-title { margin: 0; font-size: 1.3rem; }
.ws-facts { display: grid; grid-template-columns: auto 1fr; gap: .15rem .7rem; margin: 0; font-size: .9rem; }
.ws-facts dt { color: var(--muted); }
.ws-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.ws-rule { margin: 0; font-size: .88rem; }
.ws-side-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.ws-scatter { margin: 0; display: grid; gap: .35rem; }
.ws-scatter-canvas { width: 100%; height: auto; aspect-ratio: 8 / 5; touch-action: none; cursor: crosshair;
  border: 1px solid var(--ws-line); border-radius: var(--radius); background: var(--surface); }
.ws-scatter-caption { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: center; font-size: .8rem; color: var(--muted); }
.ws-scatter-caption.is-picked { color: var(--text); font-size: .88rem; }
.ws-key::before { content: ""; display: inline-block; width: .6rem; height: .6rem; margin-right: .3rem; border-radius: 50%; vertical-align: -.05rem; }
.ws-key-flag::before { background: var(--ws-flag); }
.ws-key-worn::before { background: var(--ws-worn); }
.ws-key-ok::before { background: rgba(80, 90, 80, .45); }
.ws-key-decided::before { background: #7a6d5f; }

/* ── Tables ────────────────────────────────────────────────────────── */

.ws-table-wrap { overflow-x: auto; border: 1px solid var(--ws-line); border-radius: var(--radius); background: var(--surface); }
.ws-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ws-table caption { text-align: left; padding: .55rem .75rem; font-weight: 700; }
.ws-table th, .ws-table td { padding: .4rem .75rem; border-top: 1px solid var(--ws-line); text-align: left; vertical-align: middle; }
.ws-table thead th { font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--ws-soft); }
.ws-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ws-swatch { display: inline-block; width: .8rem; height: .8rem; margin-right: .45rem; border-radius: 2px; border: 1px solid var(--ws-line); vertical-align: -.05rem; }
.ws-link { color: var(--text); text-align: left; }

.ws-rules tr.is-off th, .ws-rules tr.is-off td { opacity: .5; }
.ws-rule-name { display: block; font-weight: 600; }
.ws-rule-range { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; }
.ws-rule-note { font-size: .82rem; color: var(--muted); max-width: 22rem; }
.ws-rule-actions { white-space: nowrap; }
.ws-rule-actions button + button { margin-left: .5rem; }
.ws-num { width: 4.4rem; }
.ws-combine { border: 1px solid var(--ws-line); border-radius: var(--radius); padding: .5rem .8rem .7rem; margin: 0; }
.ws-combine legend { font-weight: 700; padding: 0 .3rem; }
.ws-radio { display: flex; gap: .5rem; align-items: baseline; margin-top: .3rem; }
.ws-globals { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; }
.ws-credit { display: grid; gap: .3rem; padding: .7rem .85rem; border-left: 3px solid var(--accent); background: var(--ws-soft); font-size: .9rem; }
.ws-credit p { margin: 0; }

/* ── Review ────────────────────────────────────────────────────────── */

.ws-where { display: grid; gap: .15rem; min-width: 12rem; }
.ws-where button { justify-self: start; font-size: .85rem; }
.ws-review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15.5rem; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .ws-review-layout { grid-template-columns: minmax(0, 1fr); } }
.ws-list-col { display: grid; gap: .4rem; min-width: 0; }
.ws-keys { margin: 0; font-size: .82rem; color: var(--muted); }
.ws-keys kbd { font: 600 .74rem var(--ws-mono); padding: .05rem .3rem; border: 1px solid var(--ws-line); border-bottom-width: 2px; border-radius: 3px; background: var(--surface); color: var(--text); }

.ws-list-head, .ws-row {
  display: grid; grid-template-columns: 1.4rem minmax(6.5rem, 9rem) minmax(0, 1fr) 3.2rem 4.6rem 3.2rem minmax(7rem, 12rem);
  gap: .5rem; align-items: center;
}
.ws-list-head { padding: 0 .6rem; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.ws-list {
  position: relative; height: min(64vh, 34rem); overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--ws-line); border-radius: var(--radius); background: var(--surface);
  overscroll-behavior: contain;
}
.ws-list-spacer { width: 1px; }
.ws-list-empty { position: absolute; inset: 0; display: grid; place-content: center; padding: 2rem; color: var(--muted); text-align: center; }
.ws-row {
  position: absolute; left: 0; right: 0; height: 46px; padding: 0 .6rem; box-sizing: border-box;
  border-bottom: 1px solid var(--ws-line); cursor: grab; user-select: none; font-size: .88rem;
}
.ws-row:hover { background: var(--ws-soft); }
.ws-row:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.ws-row.is-picked { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.ws-row .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .82rem; }
.ws-check { width: 1rem; height: 1rem; border: 1.5px solid var(--ws-line); border-radius: 3px; display: grid; place-content: center; font-size: .75rem; color: var(--accent); }
.is-picked .ws-check { border-color: var(--accent); }
.ws-call { font: 600 .8rem var(--ws-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-title { display: grid; min-width: 0; line-height: 1.2; }
.ws-title-main, .ws-title-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-title-sub { font-size: .75rem; color: var(--muted); }
.ws-why { display: flex; gap: .25rem; flex-wrap: nowrap; overflow: hidden; }
.ws-chip { flex: none; font-size: .7rem; line-height: 1.5; padding: 0 .35rem; border-radius: 999px; border: 1px solid var(--ws-line); white-space: nowrap; }
.ws-chip-age, .ws-chip-idle { color: var(--ws-flag); border-color: color-mix(in srgb, var(--ws-flag) 45%, transparent); }
.ws-chip-worn { color: var(--ws-worn); border-color: color-mix(in srgb, var(--ws-worn) 45%, transparent); }
.ws-chip-missing, .ws-chip-damaged { color: var(--text); background: var(--ws-soft); }
.ws-decided { color: #fff; border: 0; font-weight: 700; }
.ws-decided.ws-d-weed { background: var(--ws-weed); }
.ws-decided.ws-d-replace { background: var(--ws-replace); }
.ws-decided.ws-d-mend { background: var(--ws-mend); }
.ws-decided.ws-d-move { background: var(--ws-move); }
.ws-decided.ws-d-keep { background: var(--ws-keep); }

@media (max-width: 720px) {
  .ws-list-head { display: none; }
  .ws-row { grid-template-columns: 1.2rem minmax(0, 1fr) 4.2rem; grid-template-rows: auto auto; height: 46px; gap: 0 .45rem; }
  .ws-row .ws-call { grid-column: 2; grid-row: 1; font-size: .74rem; }
  .ws-row .ws-title { grid-column: 2; grid-row: 2; }
  .ws-row .ws-title-sub { display: none; }
  .ws-row .ws-check { grid-row: 1 / 3; }
  .ws-row > .num { display: none; }
  .ws-row .ws-why { grid-column: 3; grid-row: 1 / 3; flex-direction: column; align-items: flex-end; }
}

.ws-bulk { display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: center; min-height: 2rem; font-size: .9rem; }
.ws-chip-btn { padding: .15rem .55rem; border-radius: 999px; border: 1px solid currentColor; text-decoration: none; font-weight: 600; }
.ws-chip-btn.ws-d-weed { color: var(--ws-weed); }
.ws-chip-btn.ws-d-replace { color: var(--ws-replace); }
.ws-chip-btn.ws-d-mend { color: var(--ws-mend); }
.ws-chip-btn.ws-d-move { color: var(--ws-move); }
.ws-chip-btn.ws-d-keep { color: var(--ws-keep); }

.ws-lanes { display: grid; gap: .5rem; position: sticky; top: 4rem; }
@media (max-width: 900px) { .ws-lanes { position: static; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); } }
.ws-lane {
  display: grid; gap: .1rem; padding: .55rem .7rem; border: 1px dashed var(--ws-line);
  border-left: 4px solid currentColor; border-radius: var(--radius); background: var(--surface);
  transition: background .1s, transform .1s;
}
.ws-lane-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--text); }
.ws-lane-count { font: 700 1.1rem var(--font-heading); font-variant-numeric: tabular-nums; }
.ws-lane-help { margin: 0; font-size: .78rem; color: var(--muted); }
.ws-lane button { justify-self: start; font-size: .8rem; }
.ws-lane.ws-d-weed { color: var(--ws-weed); }
.ws-lane.ws-d-replace { color: var(--ws-replace); }
.ws-lane.ws-d-mend { color: var(--ws-mend); }
.ws-lane.ws-d-move { color: var(--ws-move); }
.ws-lane.ws-d-keep { color: var(--ws-keep); }
.ws-dragging .ws-lane { border-style: solid; }
.ws-lane.is-over { background: color-mix(in srgb, currentColor 14%, var(--surface)); transform: scale(1.02); }
.ws-ghost {
  position: fixed; z-index: 1000; pointer-events: none; max-width: 18rem; padding: .35rem .6rem;
  border-radius: var(--radius); background: var(--text); color: var(--surface); font-size: .85rem;
  box-shadow: 0 .4rem 1.2rem rgba(0, 0, 0, .25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-dragging, .ws-dragging * { cursor: grabbing !important; }

.ws-exports { display: grid; gap: .35rem; padding: .7rem; border: 1px solid var(--ws-line); border-radius: var(--radius); background: var(--ws-soft); }
.ws-exports h3 { margin: 0 0 .2rem; font-size: 1rem; }
.ws-exports button { justify-self: start; text-align: left; }
.ws-exports .field-help { margin: 0 0 .3rem; }

/* ── Import ────────────────────────────────────────────────────────── */

.ws-drop {
  display: grid; gap: .3rem; justify-items: center; text-align: center; padding: 2rem 1.2rem;
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--ws-line)); border-radius: var(--radius);
  background: var(--ws-soft); cursor: pointer;
}
.ws-drop:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.ws-drop.is-dragover { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.ws-drop strong { font-size: 1.1rem; }
.ws-drop span { color: var(--muted); max-width: 36rem; }
.ws-progress:empty { display: none; }
.ws-import-msg { margin: 0; min-height: 1.2em; }
.ws-import-msg:empty { min-height: 0; }
.ws-import-msg.tone-bad { color: var(--ws-flag); font-weight: 600; }
.ws-guides h4 { margin: .6rem 0 .1rem; }
.ws-guides p { margin: 0; }
.ws-mapping { display: grid; gap: .6rem; }
.ws-mapping h3, .ws-mapping p { margin: 0; }
.ws-map-table select { min-width: 12rem; }
.ws-samples { display: flex; flex-wrap: wrap; gap: .25rem; }
.ws-sample { font: .76rem var(--ws-mono); padding: .05rem .35rem; border-radius: 3px; background: var(--ws-soft); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-collections h3 { margin: .6rem 0 .3rem; }
.ws-col-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.ws-col { padding: .6rem .8rem; border: 1px solid var(--ws-line); border-radius: var(--radius); background: var(--surface); }
.ws-col.is-open { border-left: 4px solid var(--accent); }
.ws-col .tool-actions { margin-top: .4rem; }

/* ── Print ─────────────────────────────────────────────────────────── */

.ws-print { display: none; }
@media print {
  body[data-printing-scope] .ws-print[data-printing] { display: block; }
  .ws-print { color: #000; font: 9.5pt/1.3 Georgia, serif; }
  .ws-print-head h1 { margin: 0; font-size: 16pt; }
  .ws-print-head p { margin: .1rem 0 .6rem; font-size: 9pt; }
  .ws-print h2 { font-size: 11pt; margin: .8rem 0 .3rem; break-after: avoid; }
  .ws-print-table { width: 100%; border-collapse: collapse; }
  .ws-print-table th, .ws-print-table td { border: .5pt solid #888; padding: 2pt 4pt; text-align: left; vertical-align: top; }
  .ws-print-table th { background: #eee; font-size: 8pt; }
  .ws-print-table tr { break-inside: avoid; }
  .ws-print-table .ws-box { text-align: center; width: 1.2em; font-size: 11pt; }
  .ws-print-key { font-size: 8pt; margin-top: .6rem; }
  .ws-print-facts { display: grid; grid-template-columns: auto 1fr; gap: 2pt 10pt; margin: 0 0 .6rem; }
  .ws-print-facts dd { margin: 0; }
  @page { margin: 12mm; }
}

/* A select is as wide as its longest option; on a phone that pushed the
   whole pane past the screen edge. */
@media (max-width: 640px) {
  .ws-bar > *, .ws-tools > *, .ws-filters > * { flex: 1 1 100%; max-width: 100%; }
  .ws-field select, .ws-field input { width: 100%; max-width: 100%; }
  .ws-bar-actions { margin-left: 0; }
}
