/* =========================================================================
   STRATEGY STACK X-RAY — additions on top of brand-budget.css.
   The killer moment is the deforming stack: six horizontal blocks that
   scale their width to the score (0–10). Pinches and bulges read
   instantly as the diagnosis. Everything else is quiet to let the shape
   carry the work.
   ========================================================================= */

/* ----- INPUT FIELDS ----- */
.s9-ssx__field {
  /* Slightly tighter than the brand-budget version because each fieldset
     is one slider + one hint — no choices block underneath. */
  gap: 0.5rem;
}
.s9-ssx__slider-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 1rem;
  align-items: center;
  margin-top: 0.25rem;
}
.s9-ssx__slider {
  /* Reuse brand-budget slider styling — that lives on .s9-bbc__slider.
     Apply matching look here without duplicating all the rules. */
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bbc-rule-strong);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.s9-ssx__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bbc-ink);
  border: 3px solid var(--bbc-accent-2);
  box-shadow: 0 0 0 2px rgba(212, 255, 63, 0.25);
  cursor: pointer;
  transition: transform 120ms var(--s9-ease);
}
.s9-ssx__slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bbc-ink);
  border: 3px solid var(--bbc-accent-2);
  box-shadow: 0 0 0 2px rgba(212, 255, 63, 0.25);
  cursor: pointer;
}
.s9-ssx__slider:active::-webkit-slider-thumb { transform: scale(1.08); }
.s9-ssx__slider:focus-visible {
  outline: 2px solid var(--bbc-accent-2);
  outline-offset: 4px;
  border-radius: 999px;
}
.s9-ssx__readout {
  font-family: var(--bbc-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  font-weight: 600;
  text-align: right;
  color: var(--bbc-ink);
  letter-spacing: -0.02em;
}

/* ----- THE STACK X-RAY ----- */
/* Dark instrument-panel container so the lime blocks pop. The blocks are
   centre-aligned horizontally and stack vertically; each block's width is
   driven by its --score variable (0–10 → 10–100%). */
.s9-ssx__stack {
  position: relative;
  background: #0A0A0A;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: clamp(0.85rem, 1.4vw, 1.15rem) clamp(0.6rem, 1vw, 0.85rem);
  margin-top: clamp(1rem, 1.5vw, 1.25rem);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  /* Faint grid texture so it reads as instrument, not just a black box */
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Centre spine — a 1px vertical line down the middle of the stack so the
   eye has a reference axis when blocks are narrow. */
.s9-ssx__spine {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.10);
  transform: translateX(-0.5px);
  pointer-events: none;
  z-index: 0;
}

/* Each layer block — width is the entire visual story.
   --score is set on the inline style (0–10). Translate to a width % via
   a clamp so the block stays clickable even at 0 (min 8% width). */
.s9-ssx__layer {
  position: relative;
  z-index: 1;
  /* The maths: width = max(8%, score/10 * 100%) */
  width: max(8%, calc(var(--score, 5) * 10%));
  height: clamp(32px, 4vh, 44px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(0.6rem, 1vw, 0.85rem);
  border-radius: 3px;
  background: var(--bbc-accent-2);
  color: #0a0a0a;
  font-family: var(--bbc-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  transition: width 380ms cubic-bezier(0.22, 1, 0.36, 1),
              background 280ms var(--s9-ease),
              color 280ms var(--s9-ease);
  /* Soft glow signals which layer is the strongest */
  box-shadow: 0 0 12px rgba(212, 255, 63, 0.18);
}

/* Tier colouring — set via data-tier on the JS side.
   weak (0–3) = orange/red — clearly the problem.
   mid  (4–6) = neutral/muted — functional but not compounding.
   strong (7–10) = full lime — already an asset. */
.s9-ssx__layer[data-tier="weak"] {
  background: #FF5A1F;
  color: #FAFAFA;
  box-shadow: 0 0 16px rgba(255, 90, 31, 0.35);
}
.s9-ssx__layer[data-tier="mid"] {
  background: rgba(250, 250, 250, 0.55);
  color: #0a0a0a;
  box-shadow: none;
}
.s9-ssx__layer[data-tier="strong"] {
  background: var(--bbc-accent-2);
  color: #0a0a0a;
  box-shadow: 0 0 18px rgba(212, 255, 63, 0.35);
}

.s9-ssx__layer-name {
  font-weight: 600;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  overflow: hidden;
}
.s9-ssx__layer-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-left: 0.5rem;
  flex-shrink: 0;
}
.s9-ssx__layer-score-max {
  opacity: 0.45;
  font-weight: 500;
  margin-left: 0.05em;
}

/* When a block is very narrow, the name + score don't fit. Hide the name
   so the score still reads. */
.s9-ssx__layer[style*="--score: 0"] .s9-ssx__layer-name,
.s9-ssx__layer[style*="--score: 1"] .s9-ssx__layer-name,
.s9-ssx__layer[style*="--score: 2"] .s9-ssx__layer-name {
  display: none;
}
.s9-ssx__layer[style*="--score: 0"],
.s9-ssx__layer[style*="--score: 1"] {
  justify-content: center;
}

/* ----- METRICS STRIP ----- */
.s9-ssx__metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: clamp(1rem, 1.5vw, 1.25rem);
  padding-top: clamp(0.85rem, 1.4vw, 1.1rem);
  border-top: 1px solid var(--bbc-rule);
}
.s9-ssx__metrics > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.s9-ssx__metric-label {
  font-family: var(--bbc-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bbc-mute);
}
.s9-ssx__metric-val {
  font-family: var(--bbc-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--bbc-ink);
}
@media (max-width: 540px) {
  .s9-ssx__metrics { grid-template-columns: 1fr 1fr; }
  .s9-ssx__metrics > div:last-child { grid-column: 1 / -1; }
}

/* ----- VERDICT — tinted border by shape state ----- */
.s9-ssx__verdict { margin-top: clamp(0.85rem, 1.4vw, 1.1rem); }
.s9-bbc__verdict[data-ssx-verdict-state="coherent-high"],
.s9-bbc__verdict[data-ssx-verdict-state="coherent-mid"]  { border-left: 3px solid var(--bbc-accent-2); }
.s9-bbc__verdict[data-ssx-verdict-state="coherent-low"]   { border-left: 3px solid var(--bbc-mute); }
.s9-bbc__verdict[data-ssx-verdict-state="top-heavy"],
.s9-bbc__verdict[data-ssx-verdict-state="bottom-heavy"],
.s9-bbc__verdict[data-ssx-verdict-state="hourglass"],
.s9-bbc__verdict[data-ssx-verdict-state="lopsided"],
.s9-bbc__verdict[data-ssx-verdict-state="mixed"]         { border-left: 3px solid #FF5A1F; }

/* ----- PRESCRIPTION PANEL ----- */
.s9-ssx__rx-target {
  font-family: var(--bbc-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bbc-mute);
  margin: 0 0 0.65rem;
}
.s9-ssx__rx-target strong {
  color: var(--bbc-ink);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.s9-ssx__rx-score {
  font-weight: 500;
  color: var(--bbc-mute);
  margin-left: 0.4em;
  font-size: 0.95em;
}
.s9-ssx__rx-title {
  font-family: var(--s9-font-display);
  font-weight: 600;
  font-size: clamp(1.05rem, 1.4vw, 1.2rem);
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  color: var(--bbc-ink);
}
.s9-ssx__rx p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--bbc-mute);
  margin: 0 0 0.5rem;
}

/* Thesis spacing */
.s9-ssx__thesis { margin-top: clamp(3rem, 5vw, 4rem); }
.s9-ssx__thesis h3 {
  font-family: var(--s9-font-display);
  font-weight: 600;
  font-size: clamp(1.1rem, 1.4vw, 1.25rem);
  letter-spacing: -0.01em;
  margin: 1.5rem 0 0.5rem;
}
.s9-ssx__thesis h3:first-child { margin-top: 0; }

/* =========================================================================
   LAYOUT — sliders TOP (3-col grid on desktop, 1-col on mobile),
   dashboard BELOW (stack viz | diagnosis side-by-side on desktop,
   stacked on mobile). No sticky / fixed panel. Single linear read.
   ========================================================================= */

/* Override the brand-budget grid (1fr 8px 1fr) — SSX is a vertical flow. */
.s9-ssx .s9-bbc__device-inner {
  display: block;
  padding: clamp(1.5rem, 2.5vw, 2.25rem);
}
/* Divider rivets aren't needed — there's no vertical divider in the new layout. */
.s9-ssx .s9-bbc__divider { display: none; }

/* SLIDER GRID — 3 cols × 2 rows on desktop, 2-col tablet, 1-col mobile. */
.s9-ssx__form {
  /* override brand-budget's flex-column on .s9-bbc__panel--inputs */
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.5rem, 2.2vw, 2rem) clamp(1rem, 1.8vw, 1.5rem);
  padding: 0;
}
@media (max-width: 1100px) { .s9-ssx__form { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .s9-ssx__form { grid-template-columns: 1fr; } }

/* Each fieldset becomes a labelled card-ish box. Hint shrinks a touch so
   the cards don't grow too tall in a 3-col grid. */
.s9-ssx .s9-ssx__field {
  gap: 0.45rem;
}
.s9-ssx .s9-ssx__field .s9-bbc__field-hint {
  font-size: 11.5px;
  line-height: 1.45;
}

/* Visual separator between the form and the dashboard underneath. */
.s9-ssx__display {
  margin-top: clamp(2rem, 3.5vw, 3rem);
  padding-top: clamp(2rem, 3vw, 2.5rem);
  border-top: 1px solid var(--bbc-rule-strong);
  /* Wipe any inherited sticky/fixed leftovers and float-in styles. */
  position: static;
  max-height: none;
  overflow: visible;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  border-radius: 0;
}
.s9-ssx__display-head {
  margin-bottom: clamp(1rem, 1.5vw, 1.25rem);
}

/* DASHBOARD — 2-col on desktop: stack viz (a bit wider) | diagnosis. */
.s9-ssx__dashboard {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: clamp(1.5rem, 2.5vw, 2.5rem);
  align-items: start;
}
@media (max-width: 900px) {
  .s9-ssx__dashboard {
    grid-template-columns: 1fr;
    gap: clamp(1.25rem, 2.5vw, 1.75rem);
  }
}

/* Left column: stack visualization + metrics */
.s9-ssx__viz-col { display: flex; flex-direction: column; }

/* Stack gets a bit more vertical breathing room in the new full-width layout. */
.s9-ssx .s9-ssx__stack {
  padding: clamp(1rem, 1.6vw, 1.35rem) clamp(0.65rem, 1vw, 0.95rem);
  gap: 5px;
}
.s9-ssx .s9-ssx__layer {
  height: clamp(38px, 4.5vh, 52px);
  font-size: 11.5px;
}
.s9-ssx .s9-ssx__layer-score { font-size: 13px; }

/* Right column: diagnosis stack */
.s9-ssx__diag-col {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 1.5vw, 1.25rem);
}
.s9-ssx__diag-col .s9-bbc__verdict {
  margin: 0;
}
.s9-ssx__diag-col .s9-bbc__why {
  margin: 0;
}

/* Actions row sits full-width below the dashboard, with a hairline rule
   to separate from the diagnosis. */
.s9-ssx__actions {
  margin-top: clamp(1.75rem, 3vw, 2.5rem);
  padding-top: clamp(1.25rem, 2vw, 1.5rem);
  border-top: 1px solid var(--bbc-rule);
}
.s9-ssx__save {
  margin-top: clamp(1.25rem, 2vw, 1.5rem);
}

@media (prefers-reduced-motion: reduce) {
  .s9-ssx__layer { transition: none; }
}
