/*
 * LightMoney score modal — production port of the approved prototype
 * (public/mockups/climate-modal.html). All styles + keyframes are scoped under
 * .score-modal so nothing leaks into the surrounding page. Per-instance tier
 * colour is driven by two CSS custom properties set inline on the root:
 *   --tier-accent  (hex)   and   --tier-glow (rgba)
 * Accent shades (-lo/-hi) and the chip ink are derived from --tier-accent via
 * color-mix() so the markup only has to supply the two base values.
 *
 * Animation choreography (matches the prototype):
 *   builds top-to-bottom; the score count-up (JS, .45s delay / 1.4s dur) ends
 *   exactly when the spectrum marker stops; the spectrum sheen washes L->R AFTER
 *   the marker lands; rank pips illuminate one at a time (global then peer);
 *   the grade chip flips up; a threshold bar gets the same marker-slide + sheen.
 * The whole sequence fires when the modal OPENS (the JS sets data-on one frame
 * after the overlay is shown) and resets cleanly on close.
 */

.score-modal {
  --sm-surface-top: #17264f;
  --sm-surface-bot: #0f1a3b;
  --sm-r-md: 12px;
  --sm-r-lg: 18px;
  --tier-accent: #6B7280;
  --tier-glow: rgba(107, 114, 128, .16);
  /* derived accent shades + chip ink */
  --tier-accent-lo: color-mix(in srgb, var(--tier-accent) 70%, #ffffff 30%);
  --tier-accent-hi: color-mix(in srgb, var(--tier-accent) 80%, #000000 20%);
  --tier-ink: #15110a;

  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  /* Shared floor so every cause modal is the same height regardless of how many
     metrics it has; the footer is pushed to the bottom via margin-top:auto. */
  min-height: 760px;
  margin: 0 auto;
  border-radius: var(--sm-r-lg);
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(120% 70% at 50% -8%, var(--tier-glow), transparent 55%),
    linear-gradient(160deg, var(--sm-surface-top) 0%, var(--sm-surface-bot) 100%);
  border: .5px solid rgba(255, 255, 255, .08);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  font-family: "Inter", "Proxima Nova", "Gilroy", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-align: left;
  -webkit-text-size-adjust: 100%;
}

/* dark-ink chip for the lighter tiers; deep tiers take white via .is-dark-ink */
.score-modal.is-dark-ink { --tier-ink: #ffffff; }

.score-modal * { box-sizing: border-box; }

.score-modal .sm-accentline {
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--tier-accent), transparent);
}

.score-modal .sm-glass {
  background: rgba(255, 255, 255, .055);
  border: .5px solid rgba(255, 255, 255, .12);
  border-top-color: rgba(255, 255, 255, .22);
  border-radius: var(--sm-r-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}

.score-modal .sm-label { font-size: 13px; color: rgba(255, 255, 255, .72); margin: 0; }

/* Header */
.score-modal .sm-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 1.3rem 1.5rem .4rem;
}
.score-modal .sm-illus {
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px var(--tier-glow));
}
.score-modal .sm-headtext { flex: 1; min-width: 0; }
.score-modal .sm-title { font-size: 23px; font-weight: 600; margin: 0; line-height: 1.12; }
.score-modal .sm-company { font-size: 16px; font-weight: 600; margin: 5px 0 0; color: #fff; }
.score-modal .sm-gradeline {
  font-size: 13px;
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, .78);
}
.score-modal .sm-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tier-accent);
  display: inline-block;
  box-shadow: 0 0 8px var(--tier-glow);
}
.score-modal .sm-close {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 19px;
  z-index: 3;
}
.score-modal .sm-close:hover { background: rgba(255, 255, 255, .2); }

.score-modal .sm-pad { padding: 1rem 1.5rem 0; }

/* Summary strip */
.score-modal .sm-summary {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, .95);
}
.score-modal .sm-summary i { color: var(--tier-accent); margin-top: 2px; font-size: 19px; }
.score-modal .sm-summary p { margin: 0; }
.score-modal .sm-summary b { font-weight: 600; }

/* Score hero + grade chip */
.score-modal .sm-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 1.2rem;
}
.score-modal .sm-score {
  font-size: 48px;
  font-weight: 600;
  text-shadow: 0 0 26px var(--tier-glow);
  font-variant-numeric: tabular-nums;
}
.score-modal .sm-score small { font-size: 19px; color: rgba(255, 255, 255, .65); font-weight: 400; }
.score-modal .sm-scoreline { margin: 0; line-height: 1; }
.score-modal .sm-notscored { font-size: 30px; font-weight: 600; color: rgba(255, 255, 255, .75); }

.score-modal .sm-chip {
  width: 58px;
  height: 58px;
  border-radius: var(--sm-r-md);
  color: var(--tier-ink);
  background: linear-gradient(150deg, var(--tier-accent-lo) 0%, var(--tier-accent) 52%, var(--tier-accent-hi) 100%);
  box-shadow: 0 8px 20px var(--tier-glow), inset 0 1px 0 rgba(255, 255, 255, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  margin: 0 auto;
  transform-origin: center bottom;
  transform: perspective(500px) rotateX(-90deg) scale(.95);
  opacity: 0;
  transition: transform .65s cubic-bezier(.2, 1.35, .4, 1) .9s, opacity .4s ease .9s;
}
.score-modal[data-on] .sm-chip { transform: perspective(500px) rotateX(0deg) scale(1); opacity: 1; }
/* Unknown / not-yet-scored chip: gray, no letter */
.score-modal .sm-chip.is-unknown {
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
  font-size: 24px;
}

/* Spectrum (fixed red->amber->green) */
.score-modal .sm-spectrum { position: relative; margin-top: 24px; }
.score-modal .sm-track {
  position: relative;
  height: 15px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, #E24B4A 0%, #EF9F27 50%, #1D9E75 100%);
}
.score-modal .sm-track::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  z-index: 2;
  background: linear-gradient(180deg, rgba(255, 255, 255, .30), transparent);
}
.score-modal .sm-track::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent);
  transform: translateX(-130%);
}
.score-modal[data-on] .sm-track::after { animation: sm-sheen 1.1s ease 1.95s 1 forwards; }
@keyframes sm-sheen { to { transform: translateX(130%); } }

.score-modal .sm-marker {
  position: absolute;
  top: 7.5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--sm-surface-top);
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  left: 0%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tier-accent) 60%, transparent), 0 4px 12px rgba(0, 0, 0, .4);
  transition: left 1.4s cubic-bezier(.2, .7, .2, 1) .45s;
}
.score-modal[data-on] .sm-marker { left: var(--sm-marker-pct, 0%); }
.score-modal .sm-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-size: 12px;
  color: rgba(255, 255, 255, .62);
}

/* Rank block */
.score-modal .sm-ranks { display: flex; margin-top: 18px; }
.score-modal .sm-ranks > div { flex: 1; padding: 13px 16px; }
.score-modal .sm-ranks > div + div { border-left: .5px solid rgba(255, 255, 255, .12); }
.score-modal .sm-rankval { font-size: 19px; font-weight: 600; margin: 3px 0 9px; }
.score-modal .sm-rankval span { font-size: 12px; color: rgba(255, 255, 255, .7); font-weight: 400; }
.score-modal .sm-pips { display: flex; gap: 5px; }
.score-modal .sm-pip { flex: 1; height: 8px; border-radius: 3px; background: rgba(255, 255, 255, .13); }
.score-modal .sm-pip.on { transition: background .45s ease, box-shadow .45s ease; }
.score-modal[data-on] .sm-pip.on {
  background: var(--tier-accent);
  box-shadow: 0 0 12px var(--tier-accent);
}
/* illuminate one at a time, well spaced: global pips first, then peer pips */
.score-modal .sm-ranks > div:first-child .sm-pip.on:nth-child(1) { transition-delay: 2.30s; }
.score-modal .sm-ranks > div:first-child .sm-pip.on:nth-child(2) { transition-delay: 2.85s; }
.score-modal .sm-ranks > div:first-child .sm-pip.on:nth-child(3) { transition-delay: 3.40s; }
.score-modal .sm-ranks > div:first-child .sm-pip.on:nth-child(4) { transition-delay: 3.95s; }
.score-modal .sm-ranks > div:last-child  .sm-pip.on:nth-child(1) { transition-delay: 3.40s; }
.score-modal .sm-ranks > div:last-child  .sm-pip.on:nth-child(2) { transition-delay: 3.95s; }
.score-modal .sm-ranks > div:last-child  .sm-pip.on:nth-child(3) { transition-delay: 4.50s; }
.score-modal .sm-ranks > div:last-child  .sm-pip.on:nth-child(4) { transition-delay: 5.05s; }
.score-modal .sm-qlabel { font-size: 12px; color: rgba(255, 255, 255, .6); margin: 7px 0 0; }

/* Metrics */
.score-modal .sm-section {
  font-size: 13px;
  letter-spacing: .05em;
  color: rgba(255, 255, 255, .7);
  margin: 1.35rem 0 11px;
  text-transform: uppercase;
}
.score-modal .sm-metric { padding: 15px 16px; margin-bottom: 11px; }
.score-modal .sm-mrow { display: flex; align-items: center; gap: 14px; }
.score-modal .sm-micon {
  width: 42px;
  height: 42px;
  border-radius: var(--sm-r-md);
  background: rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
}
.score-modal .sm-mtext { flex: 1; min-width: 0; }
.score-modal .sm-mlabel { font-size: 16px; margin: 0; color: #fff; }
.score-modal .sm-msub { font-size: 13px; color: rgba(255, 255, 255, .65); margin: 3px 0 0; }
.score-modal .sm-mval { font-size: 23px; font-weight: 600; margin: 0; white-space: nowrap; text-align: right; }
.score-modal .sm-mval small { font-size: 14px; color: rgba(255, 255, 255, .65); font-weight: 400; }
.score-modal .sm-mval.is-na { font-size: 16px; color: rgba(255, 255, 255, .5); font-weight: 400; }

/* Optional thin mini score-bar (metric `bar`) — same marker/sheen treatment */
.score-modal .sm-minibar { position: relative; margin: 13px 2px 0; }
.score-modal .sm-minitrack {
  position: relative;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, #E24B4A 0%, #EF9F27 50%, #1D9E75 100%);
}
.score-modal .sm-minitrack::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent);
  transform: translateX(-130%);
}
.score-modal[data-on] .sm-minitrack::after { animation: sm-sheen 1.1s ease 4.6s 1 forwards; }
.score-modal .sm-minimk {
  position: absolute;
  top: 3.5px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--sm-surface-top);
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  left: 0%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tier-accent) 55%, transparent);
  transition: left 1.2s cubic-bezier(.2, .7, .2, 1) 3.6s;
}
.score-modal[data-on] .sm-minimk { left: var(--sm-bar-pct, 0%); }

/* Threshold bar (e.g. GWP vs Paris targets) — same treatment as the spectrum */
.score-modal .sm-thresh { position: relative; margin: 14px 2px 0; }
.score-modal .sm-thtrack {
  position: relative;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, #1D9E75 0%, #EF9F27 55%, #E24B4A 100%);
}
.score-modal .sm-thtrack::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent);
  transform: translateX(-130%);
}
.score-modal[data-on] .sm-thtrack::after { animation: sm-sheen 1.1s ease 5.4s 1 forwards; }
.score-modal .sm-thmk {
  position: absolute;
  top: 4.5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--sm-surface-top);
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  left: 0%;
  box-shadow: 0 0 0 3px rgba(226, 75, 74, .5);
  transition: left 1.2s cubic-bezier(.2, .7, .2, 1) 4.0s;
}
.score-modal[data-on] .sm-thmk { left: var(--sm-thresh-pct, 0%); }
.score-modal .sm-thticks {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, .6);
}

/* Footer */
.score-modal .sm-footer {
  padding: 1.2rem 1.5rem;
  margin-top: auto;
  border-top: .5px solid rgba(255, 255, 255, .12);
}
.score-modal .sm-footrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.score-modal .sm-src { font-size: 13px; color: rgba(255, 255, 255, .7); }
.score-modal .sm-src b { color: #fff; font-weight: 600; }
.score-modal .sm-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: .5px solid rgba(255, 255, 255, .22);
  border-radius: var(--sm-r-md);
  padding: 9px 15px;
  cursor: pointer;
  text-decoration: none;
}
.score-modal .sm-cta:hover { background: rgba(255, 255, 255, .2); }
.score-modal .sm-disc { font-size: 12px; color: rgba(255, 255, 255, .55); margin: 11px 0 0; line-height: 1.5; }

/* Reveal (fade + rise), sequenced via inline transition-delay */
.score-modal .sm-reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .6s ease, transform .6s ease;
}
.score-modal[data-on] .sm-reveal { opacity: 1; transform: none; }

/* Visually-hidden SR summary sentence */
.score-modal .sm-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;
}

/* While resetting between opens — kill all transitions/animations for one frame */
.score-modal.sm-no-anim,
.score-modal.sm-no-anim * { transition: none !important; animation: none !important; }

/* Narrow screens */
@media (max-width: 480px) {
  .score-modal .sm-header { padding: 1.15rem 1.15rem .4rem; gap: 13px; }
  .score-modal .sm-pad { padding: 1rem 1.15rem 0; }
  .score-modal .sm-section { margin-top: 1.1rem; }
  .score-modal .sm-footer { padding: 1.15rem; }
  .score-modal .sm-score { font-size: 42px; }
  .score-modal .sm-title { font-size: 21px; }
  .score-modal .sm-illus { width: 74px; height: 74px; }
  .score-modal .sm-metric { padding: 13px; }
  .score-modal .sm-ranks > div { padding: 13px; }
  .score-modal .sm-mval { font-size: 20px; }
}

/*
 * NB: there is intentionally no @media (prefers-reduced-motion: reduce) block.
 * The reveal animations are user-initiated (they fire only when a cause modal is
 * opened) and are the headline feature of this redesign, so per the client they
 * play regardless of the OS reduce-motion setting. The JS count-up matches.
 */
