/* roi-estimator block deltas (plan §5.4) — web-only layout on top of the SDS
 * stat-block and cream card. @layer web. Matches V2: pitch + sliders on the
 * left, the result card on the right; single column on mobile. */
@layer web {
  .roi__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: center;
  }

  .roi__title {
    font-family: var(--sph-font-display);
    font-weight: var(--sph-weight-extrabold);
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    line-height: 1.08;
    letter-spacing: var(--sph-tracking-tight);
    color: var(--sph-text);
    margin: 0.75rem 0 0;
    max-width: 16ch;
  }
  .roi__title .sph-accent { color: var(--sph-primary); }
  .roi__lead {
    margin: clamp(1rem, 2.5vw, 1.5rem) 0 0;
    max-width: 34rem;
  }

  .roi__control {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 0.35rem 1rem;
    margin-top: clamp(1.25rem, 3vw, 1.9rem);
  }
  .roi__labelrow { display: flex; align-items: center; gap: 8px; }
  /* Volume: number input + magnitude select instead of a slider — the span
     K…B is far too wide for a track to feel precise. */
  .roi__control--volume { grid-template-columns: 1fr; }
  .roi__volume { display: flex; gap: 0.5rem; }
  .roi__volume-input { flex: 1; min-width: 0; }
  .roi__volume-unit { flex: none; width: auto; }
  /* Why-we-ask hint — same recipe as the CTA form's .cta__hint. */
  .roi__hint {
    position: relative;
    width: 16px;
    height: 16px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--sph-border-strong, var(--sph-border));
    border-radius: 999px;
    font: var(--sph-weight-bold) 10px/1 var(--sph-font-display);
    color: var(--sph-text-muted);
    cursor: help;
  }
  .roi__hint::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 260px;
    padding: 8px 10px;
    background: var(--sph-text);
    color: var(--sph-bg);
    font: var(--sph-weight-regular) var(--sph-fs-xs)/1.4 var(--sph-font-body);
    letter-spacing: normal;
    text-transform: none;
    border-radius: var(--sph-radius-sm, 4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--sph-dur-fast, 120ms) ease;
    pointer-events: none;
    z-index: 2;
  }
  /* :focus (not only :focus-visible) so a tap on touch devices — which has no
     hover and no visible focus ring — still opens the hint. */
  .roi__hint:hover::after,
  .roi__hint:focus::after,
  .roi__hint:focus-visible::after { opacity: 1; visibility: visible; }
  .roi__hint:focus-visible {
    outline: 2px solid var(--sph-focus, var(--sph-primary-deep));
    outline-offset: 1px;
  }
  .roi__reading {
    font-family: var(--sph-font-display);
    font-weight: var(--sph-weight-bold);
    font-variant-numeric: tabular-nums;
    color: var(--sph-text);
  }
  /* Custom slider (design review §P3, July 2026): hairline track, filled to
     the thumb via --roi-fill (kept in sync by roi-estimator.js; the CSS-only
     fallback is an unfilled track, still fully usable). Fill/focus colours are
     the theme-keyed --sph-text-accent / --sph-focus, thumb is page ink — all
     flip under the dark trigger. WebKit and Gecko need separate pseudo-element
     rules; Gecko draws the fill natively via ::-moz-range-progress. */
  .roi__slider {
    grid-column: 1 / -1;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    height: 24px;                 /* comfortable hit target around a thin track */
    background: transparent;
    cursor: pointer;
    margin: 0;
    --roi-fill: 50%;
  }
  .roi__slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: var(--sph-radius-pill, 999px);
    background: linear-gradient(
      to right,
      var(--sph-text-accent) var(--roi-fill),
      var(--sph-border) var(--roi-fill)
    );
  }
  .roi__slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;             /* centres the thumb on the 4px track */
    border-radius: 50%;
    background: var(--sph-ink);
    border: 2px solid var(--sph-bg);
  }
  .roi__slider::-moz-range-track {
    height: 4px;
    border-radius: var(--sph-radius-pill, 999px);
    background: var(--sph-border);
  }
  .roi__slider::-moz-range-progress {
    height: 4px;
    border-radius: var(--sph-radius-pill, 999px);
    background: var(--sph-text-accent);
  }
  .roi__slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--sph-ink);
    border: 2px solid var(--sph-bg);
  }
  .roi__slider:focus-visible {
    outline: none;
  }
  .roi__slider:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--sph-focus) 35%, transparent);
  }
  .roi__slider:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--sph-focus) 35%, transparent);
  }

  .roi__card {
    border-top: 3px solid var(--sph-primary);
    gap: 1.25rem;
  }
  /* The SDS stat-block brings its own top border; the card already draws one. */
  .roi__stat { border-top: 0; padding-top: 0; }
  /* Deck-scale 88px is too large for a web card; keep the stat voice, web size. */
  .roi__value { font-size: clamp(2.75rem, 6vw, 4.25rem); }

  .roi__rows {
    margin: 0;
    border-top: 1px solid var(--sph-border);
  }
  .roi__row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 0.6rem;
    border-bottom: 1px solid var(--sph-border);
    font-size: var(--sph-fs-sm);
  }
  .roi__row dt { color: var(--sph-text-muted); }
  .roi__row dd {
    margin: 0;
    font-family: var(--sph-font-display);
    font-weight: var(--sph-weight-bold);
    font-variant-numeric: tabular-nums;
  }

  /* The composed summary sentence — prose with tabular numbers. */
  .roi__sentence {
    margin: 0;
    font-size: var(--sph-fs-sm);
    line-height: var(--sph-lh-normal, 1.55);
    color: var(--sph-text-soft);
  }
  .roi__sentence strong {
    color: var(--sph-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .roi__cta { justify-content: center; }

  @media (max-width: 52rem) {
    .roi__grid { grid-template-columns: 1fr; }
  }

  @media (max-width: 44rem) {
    /* Keep the hidden tooltip out of the document scroll area on phones, and
       use the same in-viewport placement when keyboard focus reveals it. */
    .roi__hint::after {
      left: auto;
      right: 0;
      transform: none;
      width: min(12.5rem, calc(100vw - 2rem));
    }
  }
}
