/* ============================================================
   Cumulus — Step-specific, Console + Results, Animations
   ============================================================ */

/* ---------- Groupings (step 4) ---------- */
.group-builder { display: flex; flex-direction: column; gap: 12px; }
.group-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
  box-shadow: var(--shadow-1);
}
.group-row__name { display: flex; align-items: center; gap: 11px; font-weight: 600; }
.group-row__swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.group-row__by { font-size: var(--t-xs); color: var(--muted); font-family: var(--font-mono); }
.group-row__count {
  font-family: var(--font-mono); font-size: var(--t-sm); font-weight: 600;
  background: var(--paper-2); padding: 4px 11px; border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}

/* ---------- Marginal impact (step 6) ---------- */
.mi-row {
  display: grid;
  grid-template-columns: 1fr 34px 1fr;
  gap: 12px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--shadow-1);
  margin-bottom: 11px;
}
.mi-cell__label { font-size: var(--t-2xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); margin-bottom: 6px; }
.mi-cell select, .mi-cell .mi-static {
  width: 100%;
  background: var(--surface-sunk);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: var(--t-sm); font-weight: 600;
  cursor: pointer;
}
.mi-arrow {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent-deep);
  justify-self: center;
}
.mi-arrow svg { width: 16px; height: 16px; }

/* ---------- Review (step 9) ---------- */
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.review-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.review-card__head {
  display: flex; align-items: center; gap: 9px;
  font-size: var(--t-2xs); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--faint); margin-bottom: 11px;
}
.review-card__head svg { width: 14px; height: 14px; color: var(--accent-deep); }
.review-card__head button {
  margin-left: auto; font-size: var(--t-2xs); color: var(--accent-deep);
  font-weight: 700; text-transform: none; letter-spacing: 0;
}
.review-card__head button:hover { text-decoration: underline; }
.review-card ul li {
  font-size: var(--t-sm);
  padding: 5px 0;
  display: flex; gap: 8px; align-items: flex-start;
}
.review-card ul li svg { width: 14px; height: 14px; color: var(--loss-low); flex: none; margin-top: 3px; }
.review-card__empty { font-size: var(--t-sm); color: var(--faint); font-style: italic; }

/* ---------- Name (step 10) ---------- */
.name-step { max-width: 560px; }
.name-input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 500;
  letter-spacing: -0.02em;
  padding: 18px 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.name-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow); }
.name-suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.name-suggest button {
  font-size: var(--t-xs); color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--r-pill);
  padding: 6px 13px; font-family: var(--font-mono);
}
.name-suggest button:hover { color: var(--ink); border-color: var(--ink-2); border-style: solid; }

/* ============================================================
   RUN CONSOLE (dark)
   ============================================================ */
.console {
  min-height: calc(100vh - var(--topbar-h));
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(15,178,194,0.12), transparent 55%),
    var(--navy);
  color: var(--navy-ink);
  display: grid;
  place-items: center;
  padding: 60px 24px;
}
.console__inner { width: 100%; max-width: 760px; }
.console__eyebrow {
  font-family: var(--font-mono); font-size: var(--t-xs);
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px; text-align: center;
}
.console h2 {
  font-family: var(--font-display); font-weight: 500;
  font-size: var(--t-h1); letter-spacing: -0.02em;
  text-align: center; margin-bottom: 6px;
}
.console__sub { text-align: center; color: var(--navy-muted); margin-bottom: 40px; }

.run-steps { display: flex; flex-direction: column; gap: 4px; }
.run-step {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 14px;
  align-items: center;
  padding: 15px 18px;
  border-radius: var(--r);
  border: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
.run-step.is-active { background: var(--navy-1); border-color: var(--navy-line); }
.run-step.is-done { opacity: 0.62; }
.run-step__icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--navy-line);
  color: var(--navy-muted);
}
.run-step.is-active .run-step__icon { border-color: var(--accent); color: var(--accent); }
.run-step.is-done .run-step__icon { background: var(--accent); border-color: var(--accent); color: var(--navy); }
.run-step__icon svg { width: 15px; height: 15px; }
.run-step__label { font-weight: 600; font-size: var(--t-body); }
.run-step__detail { font-size: var(--t-xs); color: var(--navy-muted); font-family: var(--font-mono); }
.run-step__stat { font-family: var(--font-mono); font-size: var(--t-sm); color: var(--accent); font-variant-numeric: tabular-nums; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--navy-line); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.run-bar {
  margin-top: 32px; height: 6px; border-radius: var(--r-pill);
  background: var(--navy-2); overflow: hidden;
}
.run-bar__fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 16px var(--accent-glow);
  transition: width 0.5s var(--ease-out);
}
.run-bar__label {
  margin-top: 12px; text-align: center;
  font-family: var(--font-mono); font-size: var(--t-xs); color: var(--navy-muted);
}

/* ============================================================
   RESULTS DASHBOARD (dark)
   ============================================================ */
.results { min-height: calc(100vh - var(--topbar-h)); background: var(--navy); color: var(--navy-ink); }
.results__hero {
  background:
    radial-gradient(100% 120% at 80% -20%, rgba(15,178,194,0.16), transparent 55%),
    var(--navy-1);
  border-bottom: 1px solid var(--navy-line);
  padding: 40px clamp(24px, 5vw, 64px) 34px;
}
.results__hero-inner { max-width: var(--content-max); margin: 0 auto; }
.results__badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: var(--t-xs);
  letter-spacing: 0.05em; color: var(--accent);
  background: rgba(15,178,194,0.12);
  border: 1px solid var(--navy-line);
  padding: 6px 13px; border-radius: var(--r-pill);
  margin-bottom: 18px;
}
.results__badge .pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow); animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  70% { box-shadow: 0 0 0 9px rgba(15,178,194,0); }
  100% { box-shadow: 0 0 0 0 rgba(15,178,194,0); }
}
.results h1 {
  font-family: var(--font-display); font-weight: 500;
  font-size: var(--t-h1); letter-spacing: -0.02em;
}
.results__hero p { color: var(--navy-muted); margin-top: 8px; max-width: 60ch; }
.results__hero-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.btn--onnavy { background: rgba(255,255,255,0.06); color: var(--navy-ink); border-color: var(--navy-line); }
.btn--onnavy:hover { background: rgba(255,255,255,0.12); border-color: var(--accent); }

.results__body {
  max-width: var(--content-max); margin: 0 auto;
  padding: 30px clamp(24px, 5vw, 64px) 70px;
  display: grid; gap: 18px;
}
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--navy-1);
  border: 1px solid var(--navy-line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.kpi__label {
  font-size: var(--t-2xs); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--navy-muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 7px;
}
.kpi__label svg { width: 14px; height: 14px; color: var(--accent); }
.kpi__value {
  font-family: var(--font-mono); font-size: 1.95rem; font-weight: 600;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
  line-height: 1;
}
.kpi__value .cur { color: var(--navy-muted); font-size: 1.1rem; margin-right: 2px; }
.kpi__delta { font-size: var(--t-xs); margin-top: 9px; font-family: var(--font-mono); display: flex; align-items: center; gap: 6px; }
.kpi__delta.up { color: var(--loss-high); }
.kpi__delta.down { color: var(--loss-low); }

.panel {
  background: var(--navy-1);
  border: 1px solid var(--navy-line);
  border-radius: var(--r-lg);
  padding: 22px;
}
.panel__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.panel__head h3 { font-size: var(--t-h3); font-weight: 700; letter-spacing: -0.01em; }
.panel__head .hint { font-size: var(--t-xs); color: var(--navy-muted); font-family: var(--font-mono); }
.results__split { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }

/* Exceedance chart */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--navy-line); stroke-width: 1; }
.chart .axis-label { fill: var(--navy-muted); font-family: var(--font-mono); font-size: 10px; }
.chart .curve {
  fill: none; stroke: var(--accent); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px var(--accent-glow));
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: draw 1.5s var(--ease-out) 0.25s forwards;
}
.chart .curve-area, .chart .marker, .chart .marker-ring { animation: fade 0.8s ease 1.1s both; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .curve-area { fill: url(#curveGrad); opacity: 0.5; }
.chart .marker { fill: var(--accent); }
.chart .marker-ring { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.5; }

/* Return period table */
.rp-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.rp-table th {
  text-align: right; font-size: var(--t-2xs); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--navy-muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--navy-line);
}
.rp-table th:first-child, .rp-table td:first-child { text-align: left; }
.rp-table td {
  padding: 11px 10px; border-bottom: 1px solid rgba(120,180,210,0.08);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.rp-table td.rp { color: var(--navy-ink); font-weight: 600; }
.rp-table .sev-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }

/* Peril contribution bars */
.contrib { display: flex; flex-direction: column; gap: 13px; }
.contrib__row { display: grid; grid-template-columns: 130px 1fr 60px; gap: 12px; align-items: center; }
.contrib__name { font-size: var(--t-sm); font-weight: 600; }
.contrib__track { height: 9px; border-radius: var(--r-pill); background: var(--navy-2); overflow: hidden; }
.contrib__fill { height: 100%; border-radius: var(--r-pill); width: 0; transition: width 1s var(--ease-out); }
.contrib__pct { font-family: var(--font-mono); font-size: var(--t-sm); text-align: right; color: var(--navy-muted); }

/* Reports produced list */
.report-list { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.report-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--navy-2); border: 1px solid var(--navy-line);
  border-radius: var(--r); padding: 13px 15px;
}
.report-item__icon { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: rgba(15,178,194,0.12); color: var(--accent); flex: none; }
.report-item__icon svg { width: 17px; height: 17px; }
.report-item__name { font-size: var(--t-sm); font-weight: 600; }
.report-item__meta { font-size: var(--t-2xs); color: var(--navy-muted); font-family: var(--font-mono); }
.report-item__dl { margin-left: auto; color: var(--navy-muted); }
.report-item__dl:hover { color: var(--accent); }

@media (max-width: 920px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .results__split { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .report-list { grid-template-columns: 1fr; }
}

/* ============================================================
   ANIMATIONS — staggered reveal
   ============================================================ */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.reveal { animation: rise 0.55s var(--ease-out) both; }
.stagger > * { animation: rise 0.5s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0.03s; }
.stagger > *:nth-child(2) { animation-delay: 0.08s; }
.stagger > *:nth-child(3) { animation-delay: 0.13s; }
.stagger > *:nth-child(4) { animation-delay: 0.18s; }
.stagger > *:nth-child(5) { animation-delay: 0.23s; }
.stagger > *:nth-child(6) { animation-delay: 0.28s; }
.stagger > *:nth-child(7) { animation-delay: 0.33s; }
.stagger > *:nth-child(8) { animation-delay: 0.38s; }
.stagger > *:nth-child(9) { animation-delay: 0.43s; }

/* step transition */
.step-enter { animation: rise 0.4s var(--ease-out) both; }
