/*
 * Challenge selector of the trader space (checkout, step 1) in grid v3: the choices are switches (../v3.css .v3-seg,
 * their thumbs placed by space/space-seg.js), the rules sit in a plate where the chosen challenge is drawn on "the line"
 * (space/space-line.js in [data-plot]), the summary is a plate that carries the one blue key. The host may set --sel-top
 * (sticky offset), --sel-bottom (room under the phone bar) and --sel-safe (bottom safe area). Without a script the
 * summary follows the choices; with one (.sel-live) it is a bottom bar and a drawer on a phone. Tokens only.
 */
.sel { position: relative; }
.sel *, .sel *::before, .sel *::after { box-sizing: border-box; }
.sel fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.sel .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sel-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 400px); gap: 24px; align-items: start; }
.sel-main { display: grid; gap: 28px; min-width: 0; }
.sel-step { display: grid; gap: 10px; }
.sel-legend { padding: 0; margin-bottom: 10px; font: 600 1rem var(--f-sans); font-stretch: 106%; color: var(--ink); }
.sel-k { display: block; padding: 0; margin-bottom: 8px; font: 600 var(--t-xs) var(--f-sans); color: var(--ink-2); }

/* the switches: program (four across, two by two on a phone), size, options, token */
.sel .v3-seg__opt input { width: 1px; height: 1px; margin: 0; }
.sel-progs { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sel-prog { align-items: flex-start; justify-content: flex-start; gap: 3px; min-height: 92px; padding: 12px 14px 14px; text-align: start; }
.sel-prog-name { font-size: 1rem; font-weight: 640; font-stretch: 106%; color: var(--ink); }
.sel-prog-price { font-size: var(--t-xs); font-weight: 500; color: var(--ink-2); }
.sel-prog-price .num { font-size: 0.8125rem; color: var(--ink); }
.sel-prog-tags { font-size: 11.5px; font-weight: 500; line-height: 1.4; color: var(--ink-3); }
.sel-prog-tags span { white-space: nowrap; }
.sel-prog:has(input:checked) .sel-prog-price .num { color: var(--pale); }
.sel-prog:has(input:checked) .sel-prog-tags { color: var(--ink-2); }
.sel-sizes { grid-auto-flow: column; }
.sel-size-v { font: 500 var(--t-sm) var(--f-mono); font-stretch: 87.5%; direction: ltr; unicode-bidi: isolate; }
.sel-opts { display: flex; flex-wrap: wrap; gap: 16px 24px; }
.sel-opts .sel-seg-wrap { flex: 1 1 220px; }
.sel-seg-wrap[hidden] { display: none; }
.sel-included { margin: 0; font-size: var(--t-sm); color: var(--ink-2); }

/* the rules of the chosen account: a plate with the drawing */
.sel-rules { padding: clamp(18px, 2.2vw, 26px); }
.sel-rules-head h3 { margin: 0; font-size: 1.15rem; font-weight: 640; font-stretch: 110%; letter-spacing: -0.01em; }
.sel-rules-head p { margin: 4px 0 0; font-size: var(--t-sm); color: var(--ink-2); }
.sel-plot { height: 250px; margin: 16px 0 6px; }
.sel-dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; margin: 8px 0 0; }
.sel-rule { padding: 14px 0 8px; border-top: 1px solid var(--hair); }
.sel-rule dt { font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); }
.sel-rule dd { margin: 6px 0 0; }
.sel-rule-v { display: block; font: 600 1.05rem var(--f-sans); color: var(--ink); text-align: start; }   /* words in Archivo, each figure a .num */
.sel-rule-v .num { font-weight: 500; letter-spacing: -0.015em; }
.sel-rule small { display: block; margin-top: 3px; font-size: var(--t-xs); line-height: 1.45; color: var(--ink-3); }
.sel-input {
  width: 100%; height: 46px; padding: 0 14px; border: 0; border-radius: 10px; color: var(--ink); font: 500 15px var(--f-mono); font-stretch: 87.5%;
  background: linear-gradient(180deg, var(--well-top), var(--well-bottom)); box-shadow: inset 0 0 0 1px var(--hair-2), inset 0 2px 6px rgba(0, 0, 0, 0.5);
}
.sel-input:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--ring), 0 0 0 3px var(--tint); }

/* comparison */
.sel-btn-quiet {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 15px; border: 0; border-radius: 9px; cursor: pointer; color: var(--ink);
  font: 640 var(--t-sm) var(--f-sans); font-stretch: 106%; background: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), inset 0 0 0 1px var(--hair-2), 0 3px 0 var(--ledge);
}
.sel-btn-quiet:disabled { cursor: default; color: var(--ink-3); background: transparent; box-shadow: inset 0 0 0 1px var(--hair); }
.sel-ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; flex: none; }

/* the summary: a plate with the price and the one blue key */
.sel-sum { position: sticky; top: var(--sel-top, 92px); border-radius: 4px; background: var(--plate-bg), var(--bg); box-shadow: var(--plate-shadow); }
.sel-bar { display: none; }
.sel-sum-body { display: grid; gap: 14px; padding: 22px 22px 24px; }
.sel-sum-title { margin: 0; font-size: 1.6rem; font-weight: 660; font-stretch: 116%; letter-spacing: -0.03em; line-height: 1.05; }
.sel-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 0; }
.sel-price-v { font: 500 clamp(2.2rem, 1.8rem + 1.2vw, 2.8rem)/1 var(--f-mono); font-stretch: 87.5%; letter-spacing: -0.03em; color: var(--white); direction: ltr; unicode-bidi: isolate; }
.sel-was { font: 450 1rem var(--f-mono); font-stretch: 87.5%; color: var(--ink-3); }
.sel-price small { flex-basis: 100%; font-size: var(--t-xs); font-weight: 560; color: var(--ink-3); }
.sel-sum-dl { display: grid; margin: 0; border-top: 1px solid var(--hair); }
.sel-sum-dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--hair); font-size: var(--t-sm); }
.sel-sum-dl dt { color: var(--ink-2); }
.sel-sum-dl dd { margin: 0; font: 500 var(--t-sm) var(--f-sans); text-align: end; color: var(--ink); }
.sel-code summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-size: var(--t-sm); font-weight: 600; color: var(--link); list-style: none; }
.sel-code summary::-webkit-details-marker { display: none; }
.sel-code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 4px; }
.sel-code-msg { margin: 6px 0 0; font-size: var(--t-xs); color: var(--ink-2); }
.sel-code-msg[data-tone="ok"] { color: var(--mood-ok); }
.sel-code-msg[data-tone="bad"], .sel-code-msg[data-tone="down"], .sel-code-msg[data-tone="held"] { color: var(--mood-watch); }
.sel-pay .sel-k { margin-bottom: 6px; }
.sel-note { margin: 6px 0 0; font-size: var(--t-xs); color: var(--ink-3); }
.sel-pay-one { margin: 0; font-size: var(--t-sm); }
.sel-terms { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; font-size: var(--t-sm); color: var(--ink-2); }
.sel-terms input { width: 20px; height: 20px; margin: 0; accent-color: var(--acc); cursor: pointer; }
.sel-terms input:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.sel-terms a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.sel-err { margin: -6px 0 0; font-size: var(--t-sm); color: var(--mood-watch); }
.sel-cta { width: 100%; margin-top: 4px; }
.sel-bar-cta.key--laser::before, .sel-bar-cta.key--laser::after { display: none; }   /* the phone bar carries the blue key without its laser */

@media (hover: hover) {
  .sel-btn-quiet:not(:disabled):hover { background: linear-gradient(180deg, var(--key-top-hi), var(--key-bottom-hi)); }
  .sel-code summary:hover, .sel-terms a:hover { color: var(--ink); }
}

@media (max-width: 1099px) {
  .sel-grid { grid-template-columns: minmax(0, 1fr); }
  .sel-sum { position: static; }
  .sel-live { padding-bottom: calc(84px + var(--sel-bottom, 0px)); }
  .sel-live .sel-sum {
    position: fixed; z-index: 70; top: auto; left: 0; right: 0; bottom: var(--sel-bottom, 0px); border-radius: 4px 4px 0 0;
    transform: translateY(110%); visibility: hidden; transition: transform 0.3s var(--ease-v3), visibility 0s 0.3s; background: var(--plate-bg), var(--bg);
  }
  .sel-live.sel-in .sel-sum, .sel-live .sel-sum.is-open { transform: none; visibility: visible; transition: transform 0.3s var(--ease-v3); }
  .sel-live .sel-bar { display: flex; align-items: center; gap: 10px; padding: 10px max(14px, env(safe-area-inset-right)) calc(10px + var(--sel-safe, env(safe-area-inset-bottom, 0px))) max(14px, env(safe-area-inset-left)); }
  .sel-live .sel-sum-body { display: none; max-height: min(72vh, 640px); overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--hair); padding: 16px 18px 22px; }
  .sel-live .sel-sum.is-open .sel-sum-body { display: grid; }
  .sel-live .sel-sum.is-open { box-shadow: 0 -30px 80px rgba(0, 0, 0, 0.7); }
  .sel-live .sel-sum.is-open .sel-bar-cta { display: none; }
  .sel-bar-toggle { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; min-height: 44px; padding: 4px; border: 0; background: transparent; color: var(--ink); text-align: start; cursor: pointer; }
  .sel-bar-name { font-weight: 640; font-stretch: 106%; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sel-bar-price { font: 500 15px var(--f-mono); font-stretch: 87.5%; direction: ltr; unicode-bidi: isolate; }
  .sel-bar-more { grid-column: 1 / -1; font-size: var(--t-xs); font-weight: 600; color: var(--link); }
  .sel-bar-cta { flex: none; }
}
@media (max-width: 899px) {
  .sel-dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 639px) {
  .sel-progs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sel-prog { min-height: 84px; padding: 10px 12px 12px; }
  .sel-sizes { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .sel-plot { height: 230px; }
}
@media (max-width: 599px) {
}
@media (max-width: 420px) {
  .sel-rule-v { font-size: 1rem; }
  .sel-bar-cta { padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .sel *, .sel *::before, .sel *::after { transition: none !important; animation: none !important; }
}
