/* =========================================================================
   DECISION-CAPITAL INDEX — additions on top of brand-budget.css.
   The base instrument styling (device chassis, LED, panels, sliders, etc.)
   is inherited from .s9-bbc__*. Below is only what's unique to DCI:
     - Selected-choice state on radio cards
     - Balance-sheet ledger (two columns: equity / debt)
     - LCD score readout with ±100 range bar
     - "What to refinance first" priority list
   ========================================================================= */

/* Radio choice cards — show a clear selected state.
   brand-budget.css has the base .s9-bbc__choice styling; we layer the
   selected affordance on top. */
.s9-bbc__choice {
  cursor: pointer;
}
.s9-bbc__choice input[type="radio"]:checked + .s9-bbc__choice-key,
.s9-bbc__choice.is-selected .s9-bbc__choice-key {
  background: var(--bbc-accent-2);
  color: var(--bbc-ink);
  border-color: var(--bbc-accent-2);
}
.s9-bbc__choice.is-selected {
  background: rgba(212, 255, 63, 0.06);
  border-color: var(--bbc-rule-strong);
}

/* ===== BALANCE SHEET ===== */
.s9-dci__sheet {
  margin-top: clamp(1rem, 1.5vw, 1.25rem);
  border: 1px solid var(--bbc-rule-strong);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
}
.s9-dci__sheet-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-family: var(--bbc-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--bbc-rule-strong);
}
.s9-dci__sheet-col {
  padding: 0.65rem 0.9rem;
}
.s9-dci__sheet-col--equity {
  color: #0a6c1a;
  background: rgba(160, 220, 80, 0.12);
  border-right: 1px solid var(--bbc-rule);
}
.s9-dci__sheet-col--debt {
  color: #9a3000;
  background: rgba(255, 90, 31, 0.10);
}

/* Two ledger columns side-by-side, equal heights */
.s9-dci__sheet-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.s9-dci__ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 100px;
}
.s9-dci__ledger--equity {
  border-right: 1px solid var(--bbc-rule);
}
.s9-dci__ledger-empty {
  padding: 0.85rem 0.9rem;
  font-family: var(--bbc-mono);
  font-size: 11px;
  color: var(--bbc-mute);
  letter-spacing: 0.04em;
}
.s9-dci__ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border-top: 1px dashed var(--bbc-rule);
  font-family: var(--bbc-mono);
  font-size: 11.5px;
}
.s9-dci__ledger-row:first-child { border-top: 0; }
.s9-dci__ledger-label {
  color: var(--bbc-ink);
  letter-spacing: 0.02em;
}
.s9-dci__ledger-val {
  font-weight: 600;
  white-space: nowrap;
}
.s9-dci__ledger--equity .s9-dci__ledger-val { color: #0a6c1a; }
.s9-dci__ledger--debt   .s9-dci__ledger-val { color: #9a3000; }

.s9-dci__sheet-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--bbc-rule-strong);
  background: rgba(0, 0, 0, 0.025);
}
.s9-dci__sheet-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.65rem 0.9rem;
  font-family: var(--bbc-mono);
  font-size: 11.5px;
  font-weight: 600;
}
.s9-dci__sheet-total:first-child {
  border-right: 1px solid var(--bbc-rule);
}
.s9-dci__sheet-total-label {
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bbc-mute);
  font-size: 10.5px;
  font-weight: 500;
}
.s9-dci__sheet-total-val--equity { color: #0a6c1a; }
.s9-dci__sheet-total-val--debt   { color: #9a3000; }

/* ===== LCD SCORE ===== */
.s9-dci__lcd {
  margin-top: clamp(1.25rem, 2vw, 1.75rem);
  /* Override the default brand-budget LCD layout — DCI has its own readout */
  display: flex !important;
  flex-direction: column;
  gap: 0.85rem;
  padding: clamp(1.25rem, 1.8vw, 1.5rem) clamp(1.25rem, 2vw, 1.5rem);
}
.s9-dci__lcd-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.s9-dci__lcd-row--big {
  border-top: 1px solid rgba(212, 255, 63, 0.15);
  padding-top: 0.85rem;
}
.s9-dci__lcd-label {
  font-family: var(--bbc-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(212, 255, 63, 0.55);
}
.s9-dci__lcd-net {
  font-family: var(--bbc-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--bbc-screen-ink);
}
.s9-dci__lcd-net.is-positive { color: var(--bbc-screen-ink); }
.s9-dci__lcd-net.is-negative { color: #ff7a4a; }
.s9-dci__lcd-score {
  font-family: var(--bbc-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.5rem, 4.5vw, 3.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--bbc-screen-ink);
  text-shadow: 0 0 18px rgba(212, 255, 63, 0.35);
  margin-left: auto;
}
.s9-dci__lcd-score.is-negative {
  color: #ff7a4a;
  text-shadow: 0 0 18px rgba(255, 122, 74, 0.4);
}
.s9-dci__lcd-score-max {
  font-family: var(--bbc-mono);
  font-size: 12px;
  color: rgba(212, 255, 63, 0.45);
  align-self: flex-end;
  margin-bottom: 0.5rem;
}

/* ±100 range bar */
.s9-dci__bar {
  margin-top: 0.5rem;
}
.s9-dci__bar-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}
.s9-dci__bar-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
}
.s9-dci__bar-zone--debt {
  left: 0;
  background: linear-gradient(90deg, rgba(255, 90, 31, 0.55) 0%, rgba(255, 90, 31, 0.10) 100%);
}
.s9-dci__bar-zone--equity {
  right: 0;
  background: linear-gradient(270deg, rgba(212, 255, 63, 0.55) 0%, rgba(212, 255, 63, 0.10) 100%);
}
.s9-dci__bar-axis-zero {
  position: absolute;
  left: 50%;
  top: -2px; bottom: -2px;
  width: 1px;
  background: rgba(255, 255, 255, 0.4);
}
.s9-dci__bar-marker {
  position: absolute;
  top: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fafafa;
  border: 2px solid #0a0a0a;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
  transform: translateX(-50%);
  transition: left 380ms cubic-bezier(0.22, 1, 0.36, 1);
}
.s9-dci__bar-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-family: var(--bbc-mono);
  font-size: 10px;
  color: rgba(212, 255, 63, 0.4);
  letter-spacing: 0.1em;
}

/* ===== TOP FIXES ===== */
.s9-bbc__why#dci-fixes ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.s9-dci__fix-title {
  font-family: var(--bbc-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--bbc-ink);
  margin: 0 0 0.2rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.s9-dci__fix-cost {
  font-weight: 600;
  color: #9a3000;
  font-size: 11px;
  white-space: nowrap;
}
.s9-dci__fix-desc {
  font-size: 13px;
  line-height: 1.45;
  color: var(--bbc-mute);
  margin: 0;
}

/* ===== Verdict state tinting ===== */
.s9-bbc__verdict[data-dci-verdict-state="bankrupt"],
.s9-bbc__verdict[data-dci-verdict-state="underwater"] {
  border-left: 3px solid #ff5a1f;
}
.s9-bbc__verdict[data-dci-verdict-state="compounding"],
.s9-bbc__verdict[data-dci-verdict-state="surplus"] {
  border-left: 3px solid var(--bbc-accent-2);
}
.s9-bbc__verdict[data-dci-verdict-state="flat"] {
  border-left: 3px solid var(--bbc-mute);
}

/* Thesis section spacing — sits below the device, breathes a bit more */
.s9-dci__thesis { margin-top: clamp(3rem, 5vw, 4rem); }
.s9-dci__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-dci__thesis h3:first-child { margin-top: 0; }

/* =========================================================================
   STICKY / FIXED RESULT PANEL
   Desktop ≥ 901px: right panel sticks to the viewport (top, below the
   header) while the left form scrolls past it.
   Mobile ≤ 900px: panel pins to the bottom of the viewport at max-50vh,
   the form scrolls above it. The summary block (header + LCD + verdict)
   inside the panel stays pinned to the panel's top so the score is
   always visible even while the user scrolls through the balance sheet.
   ========================================================================= */

/* ----- DESKTOP STICKY ----- */
@media (min-width: 901px) {
  /* brand-budget.css has overflow:hidden on .s9-bbc__device — that creates
     a scrolling context and breaks sticky on anything nested inside.
     For the DCI variant we override to visible. The chassis pseudo-element
     textures use inset:0 / inset:14px so they stay inside their boundaries
     even without the clip. */
  .s9-dci .s9-bbc__device { overflow: visible; }

  /* The right panel becomes sticky inside its grid track. align-self:start
     stops it stretching to match the (much taller) form on the left. */
  .s9-dci .s9-bbc__panel--display {
    position: sticky;
    top: calc(var(--s9-header-h) + 1rem);
    align-self: start;
    max-height: calc(100vh - var(--s9-header-h) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--bbc-rule-strong) transparent;
    /* Pad the right panel internally so its own content doesn't kiss
       the chassis edge after we removed the device's overflow clip. */
    padding: clamp(1rem, 1.6vw, 1.4rem);
  }
  .s9-dci .s9-bbc__panel--display::-webkit-scrollbar { width: 6px; }
  .s9-dci .s9-bbc__panel--display::-webkit-scrollbar-thumb {
    background: var(--bbc-rule-strong);
    border-radius: 3px;
  }
}

/* ----- MOBILE BOTTOM-PINNED ----- */
@media (max-width: 900px) {
  /* Take the right panel out of the device grid flow and pin it to the
     bottom of the viewport. The form scrolls naturally above it. */
  .s9-dci .s9-bbc__panel--display {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    max-height: 50vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: clamp(1rem, 2vw, 1.25rem) clamp(1rem, 3vw, 1.5rem) clamp(1rem, 3vw, 1.5rem);
    background: rgba(239, 237, 234, 0.96);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid var(--bbc-rule-strong);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.18),
                0 -2px 6px rgba(0, 0, 0, 0.04);
  }
  /* Grab-handle visual cue — looks like a small chrome pill at the top
     of the bottom sheet so it reads as draggable / belonging to a panel. */
  .s9-dci .s9-bbc__panel--display::before {
    content: "";
    display: block;
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: var(--bbc-rule-strong);
    margin: -0.4rem auto 0.85rem;
    opacity: 0.55;
  }
  /* The internal summary block (header + LCD + verdict) sticks to the top
     of the panel's scroll so the SCORE is always visible while users
     scroll the balance sheet below. */
  .s9-dci__summary {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(239, 237, 234, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding-bottom: 0.75rem;
    margin: -0.4rem -0.6rem 0.75rem;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    padding-top: 0.4rem;
    border-bottom: 1px solid var(--bbc-rule);
  }
  /* Pad the form so the last question can scroll above the fixed panel. */
  .s9-dci .s9-bbc__panel--inputs {
    padding-bottom: calc(50vh + var(--s9-space-5));
  }
  /* The chassis divider rivets sat between left + right panels — on
     mobile there's no right panel above to divide from. Hide it. */
  .s9-dci .s9-bbc__divider { display: none; }
  /* Don't double-pad — the device-inner already has padding; the form
     is now the sole occupant of the grid. */
  .s9-dci .s9-bbc__device-inner { display: block; }
  /* Footer at the bottom of the device sits behind the fixed panel on
     mobile; give it a bit of space so it isn't cramped against the form. */
  .s9-dci .s9-bbc__device-foot { margin-bottom: 0; }
}

/* ----- VERY SHORT VIEWPORTS ----- */
@media (max-width: 900px) and (max-height: 620px) {
  /* On tiny phones the 50vh cap is brutal — let the summary stay visible
     but allow a touch more room for the balance sheet underneath. */
  .s9-dci .s9-bbc__panel--display { max-height: 60vh; }
  .s9-dci .s9-bbc__panel--inputs { padding-bottom: calc(60vh + var(--s9-space-4)); }
}

/* When reduced motion is preferred, drop the smooth marker animation */
@media (prefers-reduced-motion: reduce) {
  .s9-dci__bar-marker { transition: none; }
}
