/* =================================================================
   REVEAL PRODUCTIONS - drape-selector tool chassis (tool.css)
   Page-local port of app/resources/_toolkit/tool.css, re-themed
   from TSA paper/ink to the Reveal "Backstage, lit" system:
   coal cards on stage black, hairlines var(--line), red accents,
   --beam-ui on the primary CTA pill, Barlow Condensed display type.
   Rides on css/site.css :root tokens - never redeclares a token.
   All classes .tool-* prefixed; page one-offs live in the page
   <style> under .dsel-.
   ================================================================= */

/* ─── Toolkit-local status palette ────────────────────────────── */
.tool-shell {
  --tool-ok:    #35b37e;
  --tool-warn:  #d9a441;
  --tool-err:   #e05252;
  --tool-info:  #5aa7bd;
  --tool-line:  var(--line);
  --tool-card:  var(--coal);
  --tool-radius: 8px;
}

/* ─── Layout: form + sticky summary rail ──────────────────────── */
.tool-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}
.tool-form { min-width: 0; }
.tool-rail { position: sticky; top: calc(var(--header-h, 76px) + 20px); }

@media (max-width: 980px) {
  .tool-shell { grid-template-columns: 1fr; }
  .tool-rail { position: static; }
}

/* ─── Numbered step (fieldset) ────────────────────────────────── */
.tool-step {
  border: 0;
  padding: 0 0 clamp(28px, 4vw, 40px);
  margin: 0;
  scroll-margin-top: calc(var(--header-h, 76px) + 16px);
}
.tool-step + .tool-step { border-top: 1px solid var(--tool-line); padding-top: clamp(28px, 4vw, 40px); }
.tool-step[hidden] { display: none; }

.tool-step__head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; }
.tool-step__idx {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--red);
  text-shadow: 0 0 14px rgba(209, 30, 59, .45);
  letter-spacing: .02em;
  flex: none;
  min-width: 30px;
}
.tool-step__titles { flex: 1; min-width: 0; }
.tool-step__title {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  letter-spacing: .03em;
  line-height: 1.1;
  color: var(--white);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.tool-step__hint {
  display: block;
  margin-top: 6px;
  font-family: var(--body);
  font-weight: 400;
  font-size: .85rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--grey);
  line-height: 1.5;
}

/* entrance animation (one-shot; tool.js drops the class after) */
@keyframes toolRevealIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tool-reveal-in { animation: toolRevealIn 560ms var(--ease) both; }
@media (prefers-reduced-motion: reduce) { .tool-reveal-in { animation: none; } }

/* ─── Generic field + grid ────────────────────────────────────── */
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px 22px; }
@media (max-width: 560px) { .tool-grid { grid-template-columns: 1fr; } }

.tool-field { display: flex; flex-direction: column; gap: 9px; }
.tool-label {
  font-family: var(--body);
  font-weight: 600;
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--white);
  display: flex; align-items: center; gap: 8px;
}
.tool-label__tag {
  font-size: .58rem; letter-spacing: .12em;
  background: rgba(209, 30, 59, .16); color: #f0aab8;
  padding: 3px 7px; border-radius: 999px;
}

/* ─── Text / number input ─────────────────────────────────────── */
.tool-control {
  width: 100%;
  font-family: var(--body);
  font-size: 16px; line-height: 1.4; color: var(--white);
  background: var(--coal);
  border: 1px solid var(--tool-line, var(--line));
  border-radius: var(--tool-radius, 8px);
  padding: 13px 15px;
  appearance: none; -webkit-appearance: none;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease);
}
.tool-control::placeholder { color: var(--grey-2); opacity: .8; }
.tool-control:hover { border-color: rgba(255, 255, 255, .22); }
.tool-control:focus,
.tool-control:focus-visible {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(209, 30, 59, .22);
}

/* ─── Image-choice cards ──────────────────────────────────────── */
/* wrapper bloom: a faint red wash behind the card glass */
.tool-choicewrap { position: relative; }
.tool-choicewrap::before {
  content: ''; position: absolute; inset: -24px -12px; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 46% 40% at 22% 8%, rgba(209, 30, 59, .07) 0%, transparent 60%);
}
.tool-choicewrap > * { position: relative; z-index: 1; }
.tool-choice { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }

/* ─── Phone: tighter option grids ─────────────────────────────── */
@media (max-width: 480px) {
  .tool-choice { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

  /* compact 3-up tiles for small media (diagram / swatch / chip) */
  .tool-choice--compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tool-choice--compact .tool-choice__card { padding: 8px 7px 9px; border-radius: 12px; }
  .tool-choice--compact .tool-choice__media { height: 84px; margin: 0 0 6px; }
  .tool-choice--compact .tool-choice__media--diagram,
  .tool-choice--compact .tool-choice__media--swatch { height: 88px; padding: 4px 2px; }
  .tool-choice--compact .tool-choice__media--swatch img { width: 64px; height: 64px; }
  .tool-choice--compact .tool-choice__media--chip { height: 84px; }
  .tool-choicewrap .tool-choice--compact .tool-choice__label { font-size: .92rem; line-height: 1.05; }
  .tool-choice--compact .tool-choice__sub { font-size: .64rem; margin-top: 3px; }
  .tool-choice--compact .tool-choice__check { width: 18px; height: 18px; top: 6px; right: 6px; }
  .tool-choice--compact .tool-choice__check svg { width: 10px; height: 10px; }
  .tool-choice--compact .tool-choice__ribbon { font-size: 8px; padding: 2px 5px; top: 6px; left: 6px; }
  .tool-choicewrap .tool-choice--colour.tool-choice--compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* Compact tiles are too small for the in-tile reveal - the "why" surfaces
     in a single note below the grid (.tool-touchwhy, fed by the tool JS). */
  .tool-choicewrap .tool-choice--compact .tool-choice__card[aria-checked="true"] .tool-choice__detail { max-height: 0; opacity: 0; margin-top: 0; }

  /* Phone: drop the greyed "not suited" groups - non-selectable context that
     only adds scroll. :has guard keeps them when no suited group exists. */
  .tool-choicewrap:has(.tool-choice__group:not(.is-muted)) .tool-choice__group.is-muted { display: none; }
}
@media (min-width: 481px) { .tool-touchwhy { display: none !important; } }

.tool-choice__group + .tool-choice__group { margin-top: 28px; }
.tool-choice__grouphead {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.tool-choice__grouptitle {
  font-family: var(--body); font-weight: 600;
  font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: var(--grey);
}

/* Coal glass card on the black stage */
.tool-choice__card {
  position: relative; isolation: isolate;
  display: flex; flex-direction: column;
  border: 1px solid var(--tool-line);
  border-radius: 14px;
  padding: 14px 14px 16px;
  cursor: pointer; text-align: left;
  color: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .07) 0%, rgba(255, 255, 255, .035) 55%, rgba(255, 255, 255, .02) 100%), var(--coal);
  background-origin: border-box; /* gradient + border: padding-box origin tiles
     opposite-colour slivers into the border ring at the corners */
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, .8);
  transition: transform 240ms var(--ease), box-shadow 240ms var(--ease), border-color 240ms var(--ease);
}
/* soft red spotlight behind the media */
.tool-choice__card::before {
  content: ''; position: absolute; z-index: -1; left: 50%; top: 6px; transform: translateX(-50%);
  width: 80%; height: 54%;
  background: radial-gradient(ellipse 60% 60% at 50% 35%, rgba(209, 30, 59, .16) 0%, transparent 70%);
  filter: blur(6px); opacity: .85; pointer-events: none;
  transition: opacity 240ms var(--ease);
}
@media (hover: hover) {
  .tool-choice__card:hover {
    transform: translateY(-4px); border-color: rgba(209, 30, 59, .45);
    box-shadow: 0 26px 56px -22px rgba(0, 0, 0, .9), 0 0 0 1px rgba(209, 30, 59, .15);
  }
  .tool-choice__card:hover::before { opacity: 1; }
}
.tool-choice__card:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.tool-choice__card[aria-checked="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red), 0 22px 50px -22px rgba(209, 30, 59, .5);
}
.tool-choice__card[aria-checked="true"]::before {
  opacity: 1; background: radial-gradient(ellipse 64% 64% at 50% 35%, rgba(209, 30, 59, .26) 0%, transparent 70%);
}

/* media well, bottom faded out */
.tool-choice__media {
  height: 184px; margin: 2px 0 10px;
  display: flex; align-items: flex-start; justify-content: center;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 92%);
  mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 92%);
}
.tool-choice__media img { height: 100%; width: auto; max-width: 100%; object-fit: contain; object-position: top center; }
.tool-choice__label {
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; font-size: 1.08rem; line-height: 1.08; color: var(--white);
}
.tool-choice__sub { margin-top: 6px; font-size: .72rem; color: var(--grey-2); line-height: 1.4; }

/* typical-uses detail - desktop preview is the cursor bubble; on touch
   reveal it inline once a card is selected. */
.tool-choice__detail {
  max-height: 0; opacity: 0; overflow: hidden; margin-top: 0;
  transition: max-height 320ms var(--ease), opacity 240ms var(--ease), margin-top 240ms var(--ease);
}
@media (hover: none), (pointer: coarse) {
  .tool-choice__card[aria-checked="true"] .tool-choice__detail { max-height: 240px; opacity: 1; margin-top: 12px; }
}
.tool-choice__detail-k { display: block; font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; color: var(--red); font-weight: 700; margin-bottom: 5px; }
.tool-choice__detail p { font-size: .74rem; color: var(--grey); line-height: 1.5; margin: 0 0 6px; }
.tool-choice__detail p.is-duty { color: var(--white); font-weight: 600; margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .tool-choice__detail { transition: none; } }

/* Cursor-following preview bubble (desktop hover over choice cards) */
.tool-cursortip {
  position: fixed; left: 0; top: 0; z-index: 90;
  max-width: 260px; pointer-events: none;
  background: #1c1c1f; color: #e9e9ee;
  border: 1px solid var(--line);
  font-size: .76rem; line-height: 1.5; letter-spacing: 0;
  padding: 11px 13px; border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease), visibility 140ms;
}
.tool-cursortip[data-open="true"] { opacity: 1; visibility: visible; transform: translateY(0); }
.tool-cursortip__k { display: block; font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; color: var(--red); font-weight: 700; margin-bottom: 5px; }
.tool-cursortip__duty { display: block; margin-top: 6px; color: var(--grey); }
@media (hover: none) { .tool-cursortip { display: none; } }
@media (prefers-reduced-motion: reduce) { .tool-cursortip { transition: none; } }

.tool-choice__card[aria-checked="true"] .tool-choice__check { opacity: 1; transform: scale(1); }
.tool-choice__check {
  position: absolute; top: 10px; right: 10px;
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(.6);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.tool-choice__check svg { width: 13px; height: 13px; }

/* suggested ribbon on a card */
.tool-choice__ribbon {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  font-family: var(--body);
  font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  background: var(--red); color: #fff; padding: 4px 8px; border-radius: 999px;
}

/* ─── Numeric stepper ─────────────────────────────────────────── */
.tool-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--tool-line); border-radius: var(--tool-radius); overflow: hidden; background: var(--coal); max-width: 220px; }
.tool-stepper__btn { width: 46px; min-height: 44px; font-size: 20px; color: var(--white); background: var(--coal-2); border: 0; transition: background 180ms; }
@media (hover: hover) { .tool-stepper__btn:hover { background: #2a2a2e; } }
.tool-stepper__wrap { position: relative; flex: 1; display: flex; align-items: center; }
.tool-stepper input {
  width: 100%; border: 0; text-align: center;
  font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--white);
  padding: 12px 8px; background: transparent; -moz-appearance: textfield;
}
.tool-stepper input:focus { outline: none; }
.tool-stepper input::-webkit-outer-spin-button,
.tool-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tool-stepper__unit { position: absolute; right: 12px; font-size: .78rem; font-weight: 700; color: var(--grey-2); pointer-events: none; }

/* ─── Contextual note ─────────────────────────────────────────── */
.tool-note {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: .8rem; line-height: 1.5; padding: 12px 14px;
  border-radius: var(--tool-radius); border: 1px solid var(--tool-line);
  background: var(--coal); color: var(--grey); margin-top: 16px;
}
.tool-note[hidden] { display: none; }
.tool-note svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.tool-note.is-info { border-color: rgba(90, 167, 189, .4); color: #a9d3e0; background: rgba(90, 167, 189, .08); }
.tool-note.is-ok   { border-color: rgba(53, 179, 126, .4); color: #93dcb9; background: rgba(53, 179, 126, .08); }
.tool-note.is-warn { border-color: rgba(217, 164, 65, .5); color: #ecd0a0; background: rgba(217, 164, 65, .1); }
.tool-note.is-err  { border-color: rgba(224, 82, 82, .5); color: #f0a6a6; background: rgba(224, 82, 82, .09); }
.tool-note a { color: var(--white); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ─── Tooltip ─────────────────────────────────────────────────── */
.tool-tip { position: relative; display: inline-flex; }
.tool-tip__btn {
  position: relative;
  width: 18px; height: 18px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: var(--grey);
  font-family: var(--body); font-size: 11px; font-weight: 700; line-height: 1;
  letter-spacing: 0; text-transform: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 180ms, color 180ms, background 180ms;
}
/* Touch: expand the hit area to 44px without changing the 18px visual */
@media (pointer: coarse) {
  .tool-tip__btn::after { content: ''; position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%); }
}
.tool-tip__btn:hover, .tool-tip__btn[aria-expanded="true"] { border-color: var(--red); color: var(--red); }
.tool-tip__bubble {
  position: absolute; z-index: 70; left: 0; top: calc(100% + 8px);
  width: max-content; max-width: 280px;
  background: #1c1c1f; color: #e9e9ee; border: 1px solid var(--line);
  font-family: var(--body); font-size: .76rem; font-weight: 400; line-height: 1.5; letter-spacing: 0;
  text-transform: none;
  padding: 11px 13px; border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease), visibility 180ms;
}
.tool-tip__bubble[data-open="true"] { opacity: 1; visibility: visible; transform: translateY(0); }
.tool-tip__bubble::before {
  content: ''; position: absolute; bottom: 100%; left: 12px;
  border: 6px solid transparent; border-bottom-color: #1c1c1f;
}
@media (max-width: 560px) { .tool-tip__bubble { left: auto; right: 0; } .tool-tip__bubble::before { left: auto; right: 12px; } }

/* ─── Live summary rail ───────────────────────────────────────── */
.tool-summary {
  background: var(--coal); color: var(--grey);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 26px 24px 24px;
  box-shadow: 0 24px 50px -24px rgba(0, 0, 0, .9);
}
.tool-summary__eyebrow { font-family: var(--body); font-size: .62rem; font-weight: 700; letter-spacing: .28em; text-transform: uppercase; color: var(--red); margin-bottom: 16px; }
.tool-summary__title { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; font-size: 1.6rem; line-height: 1; color: var(--white); margin-bottom: 4px; }
.tool-summary__placeholder { font-size: .84rem; color: var(--grey-2); line-height: 1.55; }
.tool-summary__rows { list-style: none; margin: 18px 0 0; padding: 0; }
.tool-summary__row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); font-size: .84rem; }
.tool-summary__row:first-child { border-top: 0; }
.tool-summary__k { color: var(--grey-2); }
.tool-summary__v { color: var(--white); font-weight: 700; text-align: right; }
.tool-summary__v.accent { color: var(--red); }
.tool-summary__flag {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 18px; padding: 12px 13px; border-radius: var(--tool-radius);
  background: rgba(217, 164, 65, .12); border: 1px solid rgba(217, 164, 65, .45);
  color: #ecd0a0; font-size: .76rem; line-height: 1.5;
}
.tool-summary__flag svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.tool-summary__flag[hidden] { display: none; }

/* ─── Action bar ──────────────────────────────────────────────── */
.tool-actionbar { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  font-size: .92rem; letter-spacing: .1em;
  padding: .95em 1.9em; border-radius: 999px; text-decoration: none;
  border: 1.5px solid transparent; background: transparent; color: var(--white);
  min-height: 44px;
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), background 220ms, opacity 220ms, border-color 220ms;
}
.tool-btn svg { width: 17px; height: 17px; }
.tool-btn--primary { background: var(--beam-ui); background-origin: border-box; color: var(--white); }
/* background-origin border-box: the pill has a 1.5px transparent border and
   the default padding-box origin TILES the gradient into the border zone -
   a sliver of the opposite end colour appears at each cap. */
@media (hover: hover) {
  .tool-btn--primary:hover { transform: translateY(-2px); box-shadow: 0 14px 44px -12px rgba(209, 30, 59, .65); }
}
.tool-btn--primary[disabled], .tool-btn--primary[aria-disabled="true"] {
  background: #232327; color: var(--grey-2); cursor: not-allowed; transform: none; box-shadow: none;
}
.tool-btn--ghost { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, .35); }
@media (hover: hover) {
  .tool-btn--ghost:hover { border-color: var(--white); background: rgba(255, 255, 255, .06); }
}
.tool-btn:active { transform: scale(.97); }

/* sticky action bar on mobile */
@media (max-width: 980px) {
  .tool-actionbar--sticky {
    position: sticky; bottom: 0; z-index: 50;
    margin: 24px -16px 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: rgba(10, 10, 11, .94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
}

/* ─── Result / handoff section ────────────────────────────────── */
.tool-result { display: none; }
.tool-result.is-open { display: block; }
.tool-result__inner { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 4vw, 48px); align-items: start; }
@media (max-width: 860px) { .tool-result__inner { grid-template-columns: 1fr; } }
.tool-spec-readout {
  background: var(--coal); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px; font-size: .84rem; line-height: 1.6;
}
.tool-spec-readout h4 {
  font-family: var(--body); font-weight: 700; font-size: .66rem;
  letter-spacing: .2em; text-transform: uppercase; color: var(--grey-2); margin-bottom: 12px;
}
.tool-spec-readout dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; margin: 0; }
.tool-spec-readout dt { color: var(--grey-2); }
.tool-spec-readout dd { margin: 0; font-weight: 700; color: var(--white); }
.tool-spec-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
