@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #0b1220;
  --surface: #121b2e;
  --surface-raised: #182640;
  --border: #253453;
  --text: #e7ecf4;
  --text-muted: #8b98af;
  --accent: #4993ff;
  --warn: #f59e0b;
  --green: #22c55e;
  --red: #ef4444;
  --blue-dim: #4d6fa8;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(73, 147, 255, 0.08), transparent),
    var(--ink);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  height: 44px;
  width: auto;
  display: block;
}
.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 22px;
}
.brand-sub {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 400;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}
.topbar-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  display: none;
}
@media (min-width: 560px) { .topbar-tag { display: block; } }

/* ---------- Hero ---------- */
main { max-width: 880px; margin: 0 auto; padding: 0 24px; }

.hero { padding: 64px 0 32px; }
.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 14px;
  text-align: center;
}
.hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 42px);
  line-height: 1.15;
  margin: 0 auto 18px;
  max-width: 100%;
  text-wrap: balance;
  text-align: center;
}
.hero-copy {
  color: var(--text-muted);
  max-width: 56ch;
  font-size: 15.5px;
  margin: 0 auto 32px;
  text-align: center;
}

.scan-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
#domain-input {
  flex: 1;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
}
#domain-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#domain-input::placeholder { color: var(--text-muted); }

#scan-button {
  background: var(--accent);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 14px 22px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
#scan-button:hover { filter: brightness(1.08); }
#scan-button:disabled { opacity: 0.6; cursor: not-allowed; }
#scan-button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.consent-block {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.consent-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.consent-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
}
.consent-row input[type="text"]::placeholder { color: var(--text-muted); }
.consent-row input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.4;
}
.consent-checkbox input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.scan-note {
  min-height: 20px;
  margin: 12px 2px 0;
  font-size: 13.5px;
  color: var(--red);
  font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Loading ---------- */
.loading {
  padding: 48px 0;
  text-align: center;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
}
.scanline {
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 50% 100%;
  animation: sweep 1.3s linear infinite;
  margin-bottom: 18px;
}
@keyframes sweep {
  0% { background-position: -50% 0; }
  100% { background-position: 150% 0; }
}
.hidden { display: none !important; }

/* ---------- Report ---------- */
.report { padding: 8px 0 72px; }

.score-card {
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.score-ring {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  flex-shrink: 0;
  border: 6px solid var(--border);
  position: relative;
}
.score-ring .grade { font-size: 34px; line-height: 1; }
.score-ring .pct { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

.score-meta h2 {
  font-family: 'Space Grotesk', sans-serif;
  margin: 0 0 6px;
  font-size: 20px;
}
.score-meta .domain-value {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--accent);
}
.score-meta p { margin: 0; color: var(--text-muted); font-size: 14px; }
.benchmark-note { margin-top: 8px !important; font-size: 12.5px !important; opacity: 0.8; max-width: 52ch; }

.category-group { margin-bottom: 28px; }
.category-group h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.finding {
  display: flex;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid rgba(37, 52, 83, 0.5);
}
.finding:last-child { border-bottom: none; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.dot.pass { background: var(--green); }
.dot.warn { background: var(--warn); }
.dot.fail { background: var(--red); }
.dot.info, .dot.unknown { background: var(--blue-dim); }

.finding-body { flex: 1; }
.finding-title {
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.finding-detail {
  color: var(--text-muted);
  font-size: 13.5px;
}
.finding-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
  opacity: 0.85;
}
.finding-record {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.severity-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}
.severity-badge.critical { background: rgba(239, 68, 68, 0.22); color: var(--red); }
.severity-badge.high { background: rgba(239, 68, 68, 0.14); color: var(--red); }
.severity-badge.medium { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.severity-badge.low { background: rgba(77, 111, 168, 0.22); color: var(--blue-dim); }


.subdomain-list {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: var(--text-muted);
  columns: 2;
  column-gap: 20px;
  margin-top: 6px;
}
@media (max-width: 560px) { .subdomain-list { columns: 1; } }

.remediation-section {
  border-top: 1px solid var(--border);
  padding-top: 32px;
  margin-top: 8px;
}
.remediation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.remediation-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  margin: 0 0 6px;
}
.remediation-caveat {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 46ch;
  margin: 0;
}
#remediation-button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
#remediation-button:hover { background: rgba(73, 147, 255, 0.1); }
#remediation-button:disabled { opacity: 0.5; cursor: not-allowed; }

.remediation-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.remediation-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.remediation-item-title {
  font-weight: 600;
  font-size: 14.5px;
}
.risk-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
}
.risk-badge.high { background: rgba(239, 68, 68, 0.18); color: var(--red); }
.risk-badge.medium { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.risk-badge.low { background: rgba(34, 197, 94, 0.18); color: var(--green); }
.effort-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--text-muted);
}
.remediation-impact {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.remediation-fix {
  font-size: 13.5px;
  white-space: pre-wrap;
}
.remediation-fix strong { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 4px; }

footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  max-width: 880px;
  margin: 0 auto;
}

.download-bar {
  max-width: 880px;
  margin: 0 auto 40px;
  padding: 0 24px;
}
#download-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
#download-button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Print / PDF export ---------- */
@media print {
  /* Redefine the theme's CSS variables for print rather than patching individual text
     colors one at a time — every component already references these variables, so this
     single block converts the whole dark theme to a coherent light one consistently.
     (The bug this fixes: patching .finding-detail's color alone to dark gray while its
     container card kept its original near-black background left dark-on-near-black text —
     invisible. Redefining --surface etc. means container and text always match.) */
  :root {
    --ink: #ffffff;
    --surface: #f7f8fa;
    --surface-raised: #eef0f3;
    --border: #d8dbe0;
    --text: #16181d;
    --text-muted: #4b5563;
    --accent: #1d4ed8;
    --warn: #b45309;
    --green: #15803d;
    --red: #b91c1c;
    --blue-dim: #3a5a8c;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .topbar, .hero, .loading, .download-bar, #remediation-button, .remediation-caveat { display: none !important; }
  body { background: #ffffff; }
  .score-card, .finding-record, .remediation-item { border-color: var(--border); break-inside: avoid; }
  a[href]::after { content: none !important; }
  /* Force the AI remediation section onto its own page */
  .remediation-section {
    page-break-before: always;
    break-before: page;
  }
}
