/* ── Google Fonts ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* ── Pico CSS Custom Property Overrides ──────────────────────────────────── */
[data-theme="light"],
:root:not([data-theme="dark"]) {
  --pico-font-family-sans-serif: "Montserrat", system-ui, -apple-system, sans-serif;
  --pico-font-family: var(--pico-font-family-sans-serif);
  --pico-font-size: 16px;
  --pico-line-height: 1.6;

  /* Brand palette */
  --sd-primary:       rgba(0, 171, 237, 1);
  --sd-primary-dark:  rgba(0, 149, 204, 1);
  --sd-navy:          rgba(33, 34, 39, 1.0);
  --sd-charcoal:      rgba(73, 74, 82, 1);
  --sd-light-bg:      rgba(245, 249, 251, 1);
  --sd-medium-gray:   rgba(124, 126, 133, 1);
  --sd-accent:        rgba(67, 83, 255, 1);
  --sd-white:         rgba(255, 255, 255, 1);

  /* Pico overrides */
  --pico-primary:             var(--sd-primary);
  --pico-primary-hover:       var(--sd-primary-dark);
  --pico-primary-focus:       rgba(0, 174, 239, 0.25);
  --pico-background-color:    var(--sd-white);
  --pico-color:               var(--sd-charcoal);
  --pico-h1-color:            var(--sd-navy);
  --pico-h2-color:            var(--sd-navy);
  --pico-h3-color:            var(--sd-navy);
  --pico-card-background-color: var(--sd-white);
  --pico-card-border-color:   rgba(224, 237, 243, 1);
  --pico-card-box-shadow:     0 4px 16px rgba(7, 32, 45, 0.08);
  --pico-border-radius:       8px;
  --pico-form-element-border-color: rgba(205, 216, 224, 1);
}

[data-theme="light"],
:root:not([data-theme="dark"]) input,
:root:not([data-theme="dark"]) select,
:root:not([data-theme="dark"]) textarea {
    --pico-background-color: var(--sd-light-bg);
    --pico-color: var(--sd-charcoal);
}

/* ── Base ────────────────────────────────────────────────────────────────── */
body {
  color: var(--sd-charcoal);
  background: var(--sd-white);
}

a { color: var(--sd-primary); }
a:hover { color: var(--sd-primary-dark); }

/* ── Site header ─────────────────────────────────────────────────────────── */
.site-header {
  background: var(--sd-light-bg);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--sd-white);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.site-logo svg { width: 180px; height: auto; }

.header-cta {
  font-size: 0.875rem;
  padding: 0.5rem 1.25rem;
  background: var(--sd-primary);
  color: var(--sd-white);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
}
.header-cta:hover {
  background: var(--sd-primary-dark);
  color: var(--sd-white);
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  background: var(--sd-primary);
  color: var(--sd-white);
  text-align: center;
  padding: 4rem 1.5rem 3rem;
}

.hero h1 {
  color: var(--sd-white);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  margin-bottom: 1rem;
  line-height: 1.25;
}

.hero p {
  color: var(--sd-white);
  font-size: 1.125rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 0.5rem;
}

/* ── Calculator container ────────────────────────────────────────────────── */
#calculator {
  max-width: 820px;
  margin: 2.5rem auto 4rem;
  padding: 0 1.5rem;
}

/* ── Progress indicator ──────────────────────────────────────────────────── */
.progress-bar {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin-bottom: 2.5rem;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.progress-step + .progress-step::before {
  content: '';
  position: absolute;
  left: -50%;
  top: 16px;
  width: 100%;
  height: 2px;
  background: #dde8ef;
  z-index: 0;
}

.progress-step.completed + .progress-step::before,
.progress-step.active + .progress-step::before {
  background: var(--sd-primary);
}

.progress-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dde8ef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--sd-medium-gray);
  position: relative;
  z-index: 1;
  transition: all 0.2s;
}

.progress-step.active .progress-dot {
  background: var(--sd-primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(0, 174, 239, 0.2);
}

.progress-step.completed .progress-dot {
  background: var(--sd-primary);
  color: white;
}
.progress-step.completed .progress-dot::after {
  content: '✓';
  position: absolute;
}
.progress-step.completed .progress-dot span { display: none; }

.progress-label {
  font-size: 0.75rem;
  color: var(--sd-medium-gray);
  margin-top: 0.4rem;
  text-align: center;
  font-weight: 500;
}
.progress-step.active .progress-label { color: var(--sd-primary); font-weight: 600; }
.progress-step.completed .progress-label { color: var(--sd-charcoal); }

/* ── Calc step cards ─────────────────────────────────────────────────────── */
.calc-step {
  background: var(--sd-white);
  border: 1px solid var(--pico-card-border-color);
  border-radius: 12px;
  box-shadow: var(--pico-card-box-shadow);
  padding: 2rem 2.5rem;
}

.calc-step h2 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.calc-step .step-description {
  color: var(--sd-medium-gray);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ── Form layout ─────────────────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .calc-step { padding: 1.5rem 1.25rem; }
}

.field-hint {
  font-size: 0.8rem;
  color: var(--sd-medium-gray);
  margin-top: 0.25rem;
}

.field-error {
  font-size: 0.8rem;
  color: #c0392b;
  margin-top: 0.25rem;
  display: block;
}

/* ── Radio source toggle ─────────────────────────────────────────────────── */
.source-toggle {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.source-toggle label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
}

.source-toggle input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

/* ── Domain selection ────────────────────────────────────────────────────── */
#domain-radios {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.domain-radio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 1.5rem;
  border: 2px solid var(--pico-card-border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  min-width: 120px;
  text-align: center;
  user-select: none;
}

.domain-radio:hover { border-color: var(--sd-primary); }

.domain-radio input[type="radio"] {
  display: none;
}

.domain-radio:has(input:checked) {
  border-color: var(--sd-primary);
  background: rgba(0, 174, 239, 0.06);
}

.domain-icon { font-size: 2rem; }
.domain-name { font-weight: 600; font-size: 0.95rem; color: var(--sd-navy); }

/* ── Intervention dropdowns ──────────────────────────────────────────────── */
.intervention-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

@media (max-width: 600px) {
  .intervention-row { grid-template-columns: 1fr; gap: 0.25rem; }
}

.intervention-row label {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0;
}

.high-risk-badge {
  display: inline-block;
  font-size: 0.68rem;
  background: rgba(255, 140, 0, 0.12);
  color: #d07000;
  border: 1px solid rgba(255,140,0,0.3);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.intervention-row select { margin-bottom: 0; }

#intervention-hint {
  color: #c0392b;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* ── Navigation buttons ──────────────────────────────────────────────────── */
.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--pico-card-border-color);
}

.btn-primary {
  background: var(--sd-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.btn-primary:hover { background: var(--sd-primary-dark); }

.btn-secondary {
  background: transparent;
  color: var(--sd-charcoal);
  border: 1px solid #cdd8e0;
  border-radius: 6px;
  padding: 0.7rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-secondary:hover { border-color: var(--sd-primary); color: var(--sd-primary); }

/* ── Contact gate (dialog) ───────────────────────────────────────────────── */
dialog#contact-gate {
  border: none;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(7, 32, 45, 0.25);
  padding: 2.5rem 2.5rem 2rem;
  max-width: 520px;
  width: 95vw;
}

dialog#contact-gate::backdrop {
  background: rgba(7, 32, 45, 0.55);
  backdrop-filter: blur(3px);
}

.gate-header {
  padding-right: 50px;
}
.gate-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--sd-white);
}
.gate-header p {
  color: var(--sd-white);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.gate-privacy {
  font-size: 0.8rem;
  color: var(--sd-medium-gray);
  margin-top: 1rem;
  text-align: center;
}

.gate-privacy a { color: var(--sd-primary); }

/* ── Results section ─────────────────────────────────────────────────────── */
#results {
  max-width: 1100px;
  margin: 2rem auto 4rem;
  padding: 0 1.5rem;
}

.results-header {
  text-align: center;
  margin-bottom: 2rem;
}

.results-header h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  margin-bottom: 0.4rem;
}

.results-range-line {
  font-size: 1rem;
  color: var(--sd-medium-gray);
  font-weight: 500;
}

/* Summary cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 800px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .summary-cards { grid-template-columns: 1fr; }
}

.summary-card {
  background: var(--sd-white);
  border: 1px solid var(--pico-card-border-color);
  border-radius: 10px;
  box-shadow: var(--pico-card-box-shadow);
  padding: 1.25rem 1.25rem 1rem;
  text-align: center;
}

.summary-card .card-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.3rem;
}

.summary-card .card-label {
  font-size: 0.78rem;
  color: var(--sd-medium-gray);
  font-weight: 500;
  line-height: 1.3;
}

.net-positive { color: #1a8a4a; }
.net-negative { color: #c0392b; }

/* Results meta */
.results-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--sd-charcoal);
  background: var(--sd-light-bg);
  border-radius: 8px;
  padding: 0.875rem 1.25rem;
  margin-bottom: 1.75rem;
}

.results-meta span { white-space: nowrap; }

/* Detail table */
.results-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  box-shadow: var(--pico-card-box-shadow);
  border: 1px solid var(--pico-card-border-color);
  margin-bottom: 2rem;
}

table.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0;
}

table.results-table th {
  background: var(--sd-navy);
  color: white;
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

table.results-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #edf2f5;
  vertical-align: middle;
}

table.results-table .intervention-cell {
  font-size: 0.78rem;
  max-width: 200px;
}

table.results-table tr:last-child td { border-bottom: none; }
table.results-table .high-risk-row { background: rgba(255, 140, 0, 0.04); }
table.results-table .totals-row {
  background: var(--sd-light-bg);
  font-weight: 600;
  border-top: 2px solid var(--pico-card-border-color);
}

/* Results CTA */
.results-cta {
  background: linear-gradient(135deg, var(--sd-navy) 0%, #0a3347 100%);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  text-align: center;
  color: white;
  margin-top: 2rem;
}

.results-cta p {
  color: white;
}

.results-cta h3 {
  color: white;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}
.results-cta p {
  opacity: 0.85;
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

.results-cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.results-cta-buttons .btn-cta-primary {
  background: var(--sd-primary);
  color: white;
  padding: 0.75rem 2rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 0.2s;
  display: inline-block;
}
.results-cta-buttons .btn-cta-primary:hover {
  background: var(--sd-primary-dark);
  color: white;
}

.results-cta-buttons .btn-cta-secondary {
  background: transparent;
  color: white;
  border: 2px solid rgba(255,255,255,0.6);
  padding: 0.75rem 2rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
  display: inline-block;
  cursor: pointer;
  font-family: inherit;
}
.results-cta-buttons .btn-cta-secondary:hover {
  border-color: white;
  background: rgba(255,255,255,0.1);
}

/* Results action bar */
.results-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.results-actions h2 { margin: 0; }

.results-actions-right {
  display: flex;
  gap: 0.75rem;
}

/* ── Cookie banner ───────────────────────────────────────────────────────── */
#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--sd-light-bg);
  color: inherit;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 999;
  font-size: 0.875rem;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
  flex-wrap: wrap;
}

#cookie-banner a { color: var(--sd-primary); }

.cookie-buttons {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

#cookie-accept {
  background: var(--sd-primary);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 0.4rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
#cookie-accept:hover { background: var(--sd-primary-dark); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--sd-navy);
  color: rgba(255,255,255,0.9);
  text-align: center;
  padding: 1.75rem 1.5rem;
  font-size: 0.85rem;
}

.site-footer p {
  color: rgba(255,255,255,0.9);
}

.site-footer a { color: rgba(255,255,255,0.9); }
.site-footer a:hover { color: white; }

/* ── Print styles ────────────────────────────────────────────────────────── */
@media print {
  .site-header,
  .hero,
  #calculator,
  #cookie-banner,
  .site-footer,
  .results-actions-right,
  .results-cta,
  #start-over-btn,
  #print-btn {
    display: none !important;
  }

  #results {
    display: block !important;
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .summary-cards {
    grid-template-columns: repeat(4, 1fr);
    break-inside: avoid;
  }

  table.results-table {
    font-size: 0.75rem;
  }

  table.results-table th {
    background: #333 !important;
    color: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .net-positive { color: #1a5c34 !important; }
  .net-negative { color: #8b1c1c !important; }
}
