/* KnowThePepper Scoville scale page (templates/tools/scoville-scale.php). Loaded after tools.css (frame).
   Page-only blocks: .sv-toggle, .sv-stat__art / .sv-tip__art / .sv-flow (icon tiles and the row-build flow), .sv-scale, .sv-axis pods (.sv-pin), .sv-filters, .sv-list rows, .sv-result/.sv-cmp, .sv-tray.
   Frame classes used as they are: .tool-head, .tool-stats, .tool-card, .heat-axis (bar, segments, ticks), .heat-range,
   .tool-chip, .tier-chip, .tool-input, .tool-select, .tool-btn, .tool-tray, .tool-prose/.tool-tips/.tool-note/.tool-links.
   Frame candidates (reusable by other tools): .sv-pin (pod art pinned on the heat axis with lane layout), .sv-check
   (square compare checkbox), .sv-toggle (segmented two-way switch). */

.sv-stack > * + * { margin-top: var(--ktp-space-6); }
.sv-band { padding-bottom: 0; }
.sv-band > .wrap-wide { padding-bottom: var(--ktp-section-y); }

/* ── Head: Log | Linear toggle ─────────────────────────────────────────── */
.sv-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1.5px solid var(--tool-input-line);
  border-radius: var(--ktp-radius-sm);
  background: var(--ktp-white);
}
.sv-toggle button {
  min-width: 76px;
  min-height: 40px;
  padding: 6px 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ktp-ink);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.sv-toggle button:hover { background: var(--ktp-smoke); }
.sv-toggle button.is-active { background: var(--ktp-chili); color: var(--ktp-white); }
.sv-toggle button:focus-visible { outline: 3px solid var(--ktp-habanero); outline-offset: 2px; }

/* ── Stat tiles ────────────────────────────────────────────────────────── */
.tool-stats .tool-stat { display: flex; flex-direction: column; justify-content: center; }
.sv-stat__art,
.sv-tip__art,
.sv-empty__art,
.sv-flow__art {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ktp-smoke);
  color: var(--ktp-ink);
}
.sv-stat__art { width: 44px; height: 44px; margin: 0 auto var(--ktp-space-3); }
.sv-stat__name { font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1.2; text-wrap: balance; }

/* ── Scale panel ───────────────────────────────────────────────────────── */
.sv-scale__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--ktp-space-3) var(--ktp-space-6);
  margin-bottom: var(--ktp-space-5);
}
.sv-scale__note { max-width: 46ch; color: var(--ktp-muted); font-size: 15px; line-height: 1.5; }

.sv-axis {
  --sv-art: 64px;
  --sv-label-h: 24px;
  --sv-tag-h: calc(var(--sv-art) + var(--sv-label-h) + 8px);
  --sv-step: calc(var(--sv-tag-h) + 6px);
}
.sv-axis .heat-axis__marks {
  height: calc(var(--sv-tag-h) + 18px + var(--sv-lanes, 0) * var(--sv-step));
  margin-bottom: 0;
}
.sv-pin {
  position: absolute;
  bottom: 0;
  left: var(--pos);
  z-index: calc(10 - var(--lane, 0)); /* lower lanes paint over the stems of higher ones */
  width: 0;
  height: calc(var(--sv-tag-h) + 18px + var(--lane, 0) * var(--sv-step));
}
.sv-pin::before { /* stem */
  content: "";
  position: absolute;
  bottom: 0;
  left: -.75px;
  width: 1.5px;
  height: calc(100% - var(--sv-tag-h));
  background: var(--ktp-ink);
  opacity: .7;
}
.sv-pin::after { /* dot on the bar edge */
  content: "";
  position: absolute;
  bottom: -5px;
  left: -5px;
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border: 2px solid var(--ktp-white);
  border-radius: 50%;
  background: var(--ktp-ink);
}
.sv-pin__tag {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 6px 4px;
  background: var(--ktp-white);
  transform: translateX(calc(-50% + var(--shift, 0px)));
}
.sv-pin__name { color: var(--ktp-ink); font-size: 14px; font-weight: 700; line-height: var(--sv-label-h); white-space: nowrap; }
.sv-pin .ktp-pepper-art,
.sv-pin .ktp-icon { width: var(--sv-art); height: var(--sv-art); }

.sv-axis .heat-axis__bar { height: 48px; border-radius: 10px; }
.sv-axis .heat-axis__seg { display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sv-seg__name {
  padding: 0 4px;
  color: var(--ktp-ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}
.sv-seg__name[hidden] { display: none; }
.sv-axis [data-tier="super-hot"] .sv-seg__name { color: var(--ktp-white); }

/* ── Filters ───────────────────────────────────────────────────────────── */
.sv-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ktp-space-3) var(--ktp-space-4); }
.sv-search { position: relative; flex: 0 1 280px; min-width: 200px; }
.sv-search .tool-input { padding-left: 44px; }
.sv-search .sv-search__icon { position: absolute; top: 50%; left: 14px; margin-top: -9px; color: var(--ktp-muted); pointer-events: none; }
.sv-chips { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: var(--ktp-space-2); }
.sv-chips .tool-chip.is-active[data-tier]::before { box-shadow: 0 0 0 2px var(--ktp-white); }
.sv-sort { flex: 0 0 220px; }

.sv-more { margin-top: var(--ktp-space-3); }
.sv-more summary {
  display: inline-flex;
  align-items: center;
  gap: var(--ktp-space-2);
  min-height: 44px;
  color: var(--ktp-muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.sv-more summary::-webkit-details-marker { display: none; }
.sv-more summary:hover { color: var(--ktp-ink); }
.sv-more summary:focus-visible { outline: 3px solid var(--ktp-habanero); outline-offset: 2px; }
.sv-more summary .ktp-icon { --icon-size: 16px; transition: transform .2s; }
.sv-more[open] summary .ktp-icon { transform: rotate(-90deg); }
.sv-more__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 280px)); gap: var(--ktp-space-4); padding-block: var(--ktp-space-2) var(--ktp-space-1); }

.sv-listbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ktp-space-3) var(--ktp-space-4);
  margin-top: var(--ktp-space-4);
  scroll-margin-top: calc(var(--ktp-header-h, 72px) + 16px);
}
#scovilleSummary { color: var(--ktp-muted); font-size: 15px; }
.sv-listbar__actions { display: flex; flex-wrap: wrap; gap: var(--ktp-space-2); }
.tool-btn:disabled { opacity: .45; cursor: not-allowed; }
.tool-btn:disabled:hover { background: transparent; }
.tool-btn--primary:disabled:hover { background: var(--ktp-chili); }

/* ── Results list ──────────────────────────────────────────────────────── */
.sv-colhead,
.sv-row { --sv-cols: 44px minmax(0, 1.15fr) 128px minmax(0, 1.5fr) 104px 72px; }
.sv-colhead {
  display: grid;
  grid-template-columns: var(--sv-cols);
  gap: 0 var(--ktp-space-4);
  margin-top: var(--ktp-space-3);
  padding-block: 10px;
  border-bottom: 1px solid var(--ktp-hairline);
  color: var(--ktp-muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.3;
  text-transform: uppercase;
}
.sv-colhead__mult,
.sv-colhead__cmp { text-align: center; }
.sv-list { margin: 0; padding: 0; list-style: none; }
.sv-row {
  display: grid;
  grid-template-columns: var(--sv-cols);
  align-items: center;
  gap: 0 var(--ktp-space-4);
  min-height: 76px;
  padding-block: 12px;
  border-bottom: 1px solid var(--ktp-hairline);
}
.sv-row__rank { color: var(--ktp-muted); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sv-row__pepper { display: flex; align-items: center; gap: var(--ktp-space-3); min-width: 0; }
.sv-row__art { display: flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; }
.sv-row__art .ktp-pepper-art { width: 44px; height: 44px; }
.sv-row__art .ktp-icon { width: 34px; height: 34px; }
.sv-row__id { display: block; min-width: 0; }
.sv-row__name {
  display: block;
  color: var(--ktp-ink);
  font-family: var(--ktp-font-display);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
}
.sv-row__name:hover { text-decoration: underline; text-decoration-color: var(--ktp-chili-40); text-underline-offset: 3px; }
.sv-row__name:focus-visible { outline: 3px solid var(--ktp-habanero); outline-offset: 2px; }
.sv-row__origin { display: block; color: var(--ktp-muted); font-size: 15px; line-height: 1.4; }
.sv-row .tier-chip,
.sv-cmp .tier-chip { font-size: 13px; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.sv-row__range { display: block; min-width: 0; }
.sv-row__range .heat-range { margin-bottom: 8px; }
.sv-row__shu { display: block; color: var(--ktp-ink); font-size: 15px; font-variant-numeric: tabular-nums; line-height: 1.3; white-space: nowrap; }
.sv-row__mult { color: var(--ktp-muted); font-family: var(--ktp-font-display); font-size: 1.15rem; font-weight: 800; text-align: center; white-space: nowrap; }
.sv-row__mult-note { display: none; }
.sv-list[data-scale="linear"] .heat-range { background: var(--ktp-clay); }
.sv-empty { display: flex; flex-direction: column; align-items: center; gap: var(--ktp-space-3); padding-block: var(--ktp-space-7); color: var(--ktp-muted); text-align: center; }
.sv-empty__art { width: 56px; height: 56px; }

.sv-check { position: relative; display: flex; align-items: center; justify-content: center; justify-self: center; width: 44px; height: 44px; cursor: pointer; }
.sv-check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.sv-check input:disabled { cursor: not-allowed; }
.sv-check__box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--tool-input-line);
  border-radius: 6px;
  background: var(--ktp-white);
  color: var(--ktp-white);
}
.sv-check__box .ktp-icon { opacity: 0; }
.sv-check input:checked + .sv-check__box { border-color: var(--ktp-chili); background: var(--ktp-chili); }
.sv-check input:checked + .sv-check__box .ktp-icon { opacity: 1; }
.sv-check input:focus-visible + .sv-check__box { outline: 3px solid var(--ktp-habanero); outline-offset: 2px; }
.sv-check input:disabled + .sv-check__box { opacity: .4; }

.sv-pager { display: flex; align-items: center; justify-content: center; gap: var(--ktp-space-4); margin-top: var(--ktp-space-5); }
.sv-pager__status { color: var(--ktp-muted); font-size: 15px; }

/* ── Comparison card ───────────────────────────────────────────────────── */
.sv-result { scroll-margin-top: calc(var(--ktp-header-h, 72px) + 16px); }
.sv-result:focus { outline: 0; }
.sv-result__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ktp-space-4); }
.sv-result__summary { max-width: 68ch; color: var(--ktp-ink); font-size: 18px; line-height: 1.5; }
.sv-cmp__rows { display: grid; gap: var(--ktp-space-5); margin-top: var(--ktp-space-5); }
.sv-cmp__row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--ktp-space-2) var(--ktp-space-4);
}
.sv-cmp__art { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; }
.sv-cmp__art .ktp-pepper-art { width: 48px; height: 48px; }
.sv-cmp__art .ktp-icon { width: 36px; height: 36px; }
.sv-cmp__id { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ktp-space-1) var(--ktp-space-3); min-width: 0; }
.sv-cmp__id .sv-row__name { display: inline; }
.sv-cmp__nums { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.sv-cmp__mult { color: var(--ktp-muted); font-size: 14px; }
.sv-cmp__bar { grid-column: 1 / -1; height: 14px; border-radius: 7px; }
.sv-cmp__bar .heat-range__bar { border-radius: 7px; }
.sv-cmp__scale { margin-top: var(--ktp-space-2); }
.sv-result__actions { display: flex; flex-wrap: wrap; gap: var(--ktp-space-3); margin-top: var(--ktp-space-5); }

/* ── Compare tray ──────────────────────────────────────────────────────── */
.sv-slot__name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-cta-short { display: none; }

.sv-links li:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* ── Read width: how to read (icon tiles) and how a row is built (three-step flow) ── */
.sv-tips > li { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: start; gap: var(--ktp-space-4); }
.sv-tip__art { width: 56px; height: 56px; }

.sv-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ktp-space-4); margin: 0; padding: 0; list-style: none; counter-reset: sv-step; }
.sv-flow__step { position: relative; padding: var(--ktp-space-4); border: var(--ktp-line); border-radius: var(--ktp-radius); background: var(--ktp-white); }
.sv-flow__step + .sv-flow__step::before { /* arrow stub joining the tiles */
  content: "";
  position: absolute;
  top: 40px;
  right: 100%;
  width: var(--ktp-space-4);
  height: 2px;
  background: var(--tool-input-line);
}
.sv-flow__art { width: 52px; height: 52px; margin-bottom: var(--ktp-space-3); }
.sv-flow__title { color: var(--ktp-ink); font-family: var(--ktp-font-display); font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
.sv-flow__text { margin-top: var(--ktp-space-1); color: var(--ktp-muted); font-size: 15px; line-height: 1.5; }

/* ── Tablet and phone ──────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .sv-colhead,
  .sv-row { --sv-cols: 36px minmax(0, 1fr) 116px minmax(0, 1.2fr) 80px 64px; }
}
@media (max-width: 860px) {
  .sv-sort { flex: 1 1 100%; }
  .sv-search { flex: 1 1 100%; }
}
@media (max-width: 760px) {
  .sv-colhead { display: none; }
  .sv-list { display: grid; gap: var(--ktp-space-3); margin-top: var(--ktp-space-4); }
  .sv-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    grid-template-areas: "rank pepper check" ". tier mult" ". range range";
    gap: var(--ktp-space-2) var(--ktp-space-3);
    min-height: 0;
    padding: 12px 14px 14px 12px;
    border: var(--ktp-line);
    border-radius: var(--ktp-radius);
    background: var(--ktp-white);
  }
  .sv-row__rank { grid-area: rank; align-self: start; padding-top: 4px; font-size: 15px; }
  .sv-row__pepper { grid-area: pepper; }
  .sv-row__tier { grid-area: tier; }
  .sv-row__mult { grid-area: mult; align-self: center; font-size: 1rem; text-align: right; }
  .sv-row__mult-note { display: inline; color: var(--ktp-muted); font-family: var(--ktp-font-body); font-size: 14px; font-weight: 400; }
  .sv-row__range { grid-area: range; }
  .sv-check { grid-area: check; align-self: start; justify-self: end; margin: -6px -8px 0 0; }
  .sv-row__art { width: 40px; height: 40px; }
  .sv-row__art .ktp-pepper-art { width: 40px; height: 40px; }
  .sv-row__name { font-size: 1.05rem; }
  .sv-more__grid { grid-template-columns: minmax(0, 1fr); }
  .sv-cmp__row { grid-template-columns: 44px minmax(0, 1fr); }
  .sv-cmp__art { width: 44px; height: 44px; }
  .sv-cmp__art .ktp-pepper-art { width: 40px; height: 40px; }
  .sv-cmp__nums { grid-column: 2; align-items: flex-start; text-align: left; }
}
@media (max-width: 560px) {
  .sv-tips > li { grid-template-columns: 44px minmax(0, 1fr); gap: var(--ktp-space-3); }
  .sv-tip__art { width: 44px; height: 44px; }
  .sv-flow { grid-template-columns: minmax(0, 1fr); gap: var(--ktp-space-5); }
  .sv-flow__step { display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: var(--ktp-space-3); }
  .sv-flow__art { grid-row: 1 / span 2; margin-bottom: 0; }
  .sv-flow__step + .sv-flow__step::before { top: auto; right: auto; bottom: 100%; left: 42px; width: 2px; height: var(--ktp-space-5); }
  .sv-axis { --sv-art: 40px; --sv-label-h: 20px; }
  .sv-pin__name { font-size: 13px; }
  .sv-pin__tag { padding-inline: 3px; }
  .sv-seg__name { padding-inline: 2px; font-size: 11px; letter-spacing: 0; }
  .sv-axis .heat-axis__bar { height: 40px; }
  .sv-scale__head { margin-bottom: var(--ktp-space-4); }
  .sv-links li:last-child:nth-child(odd) { grid-column: auto; }
}
@media (max-width: 640px) { /* the frame turns the tray into one row; the count goes on the CTA, the slot x clears one pepper */
  .sv-slot__name { max-width: 110px; font-size: 14px; }
  .sv-cta-long { display: none; }
  .sv-cta-short { display: inline; }
  #btnClearAll { display: none; }
}

/* pod fallback glyph when a pepper has no illustration (colour lives here, not in style="") */
.sv-art-fallback { --icon-size: 28px; color: var(--ktp-chili); }
