/* SPF IP Checker — hand-written CSS (no build step / no Tailwind; this is a
   Python-only stack). Mirrors the original design system: brand colors,
   glass panels, dark mode, grid background, verdict badges, trace tree. */

:root {
  color-scheme: light dark;

  --brand-50: #eef4ff;
  --brand-100: #d9e6ff;
  --brand-400: #5885ff;
  --brand-500: #3660fa;
  --brand-600: #233ddc;
  --brand-700: #1c2eb0;

  --surface-bg: #f7f8fa;
  --surface-fg: #12141c;
  --surface-muted: #6b7280;
  --surface-muted-2: #9aa1b0;
  --surface-border: rgba(0, 0, 0, 0.10);
  --surface-border-soft: rgba(0, 0, 0, 0.05);
  --panel-bg: rgba(255, 255, 255, 0.70);
  --input-bg: #ffffff;
  --code-bg: #12141c;
  --grid-line: rgba(0, 0, 0, 0.035);

  --emerald: #059669;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.30);
  --red: #dc2626;
  --red-bg: rgba(239, 68, 68, 0.12);
  --red-border: rgba(239, 68, 68, 0.30);
  --orange: #c2410c;
  --orange-bg: rgba(249, 115, 22, 0.12);
  --orange-border: rgba(249, 115, 22, 0.30);
  --sky: #0369a1;
  --sky-bg: rgba(14, 165, 233, 0.12);
  --sky-border: rgba(14, 165, 233, 0.30);
  --amber: #b45309;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.30);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-bg: #06070b;
    --surface-fg: #f7f8fa;
    --surface-muted: #aab1c5;
    --surface-muted-2: #7d84a0;
    --surface-border: rgba(255, 255, 255, 0.10);
    --surface-border-soft: rgba(255, 255, 255, 0.05);
    --panel-bg: rgba(255, 255, 255, 0.03);
    --input-bg: #0b0d13;
    --code-bg: #000000;
    --grid-line: rgba(255, 255, 255, 0.04);
  }
}

html.dark {
  --surface-bg: #06070b;
  --surface-fg: #f7f8fa;
  --surface-muted: #aab1c5;
  --surface-muted-2: #7d84a0;
  --surface-border: rgba(255, 255, 255, 0.10);
  --surface-border-soft: rgba(255, 255, 255, 0.05);
  --panel-bg: rgba(255, 255, 255, 0.03);
  --input-bg: #0b0d13;
  --code-bg: #000000;
  --grid-line: rgba(255, 255, 255, 0.04);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--surface-bg);
  color: var(--surface-fg);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

a { color: inherit; }

.bg-grid {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
}

.bg-glow {
  position: absolute;
  inset: -160px 0 auto 0;
  height: 500px;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(60% 60% at 50% 0%, rgba(88, 133, 255, 0.22), rgba(52, 211, 153, 0.10) 60%, transparent 100%);
  filter: blur(60px);
}
html.dark .bg-glow { opacity: 0.7; }

.site-header {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--surface-fg);
}
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: var(--brand-600);
  color: #fff;
}
.site-nav { display: flex; align-items: center; gap: 1rem; }
.nav-link {
  display: none;
  font-size: 0.875rem;
  color: var(--surface-muted);
  text-decoration: none;
}
.nav-link:hover { color: var(--surface-fg); }
@media (min-width: 640px) { .nav-link { display: inline; } }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  border: 1px solid var(--surface-border);
  background: var(--panel-bg);
  color: var(--surface-fg);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--brand-50); }
html.dark .theme-toggle:hover { background: rgba(255,255,255,0.08); }

main { max-width: 64rem; margin: 0 auto; padding: 0 1.25rem; }
@media (min-width: 640px) { main { padding: 0 2rem; } }

.hero { padding: 1.5rem 0 1rem; }
@media (min-width: 640px) { .hero { padding-top: 2.5rem; } }
.hero-inner { max-width: 42rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--surface-border);
  background: var(--panel-bg);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--surface-muted);
}
.pill-dot { width: 0.375rem; height: 0.375rem; border-radius: 9999px; background: #10b981; }

h1 {
  margin: 1rem 0 0;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
@media (min-width: 640px) { h1 { font-size: 2.25rem; } }

.hero p {
  margin-top: 0.75rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--surface-muted);
}
.hero code {
  font-size: 0.8125rem;
  background: var(--surface-border-soft);
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
}

.glass-panel {
  border: 1px solid var(--surface-border-soft);
  background: var(--panel-bg);
  border-radius: 1rem;
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.checker-section { padding-bottom: 4rem; }
.checker-form { padding: 1.25rem; margin-top: 1rem; }
@media (min-width: 640px) { .checker-form { padding: 1.75rem; } }

.form-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }

.field label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--surface-fg);
}
.field input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--surface-fg);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.875rem;
  outline: none;
}
.field input::placeholder { color: var(--surface-muted-2); }
.field input:focus { box-shadow: 0 0 0 2px rgba(54, 96, 250, 0.4); }

.form-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--brand-600);
  color: #fff;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(35, 61, 220, 0.2);
}
.btn-primary:hover { background: var(--brand-700); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.try-label { font-size: 0.75rem; color: var(--surface-muted-2); }
.example-btn {
  border: 1px solid var(--surface-border);
  background: transparent;
  color: var(--surface-muted);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  cursor: pointer;
}
.example-btn:hover { border-color: var(--brand-400); color: var(--brand-600); }

.error-banner {
  margin-top: 1.25rem;
  border: 1px solid var(--red-border);
  background: var(--red-bg);
  color: var(--red);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.icon-xs { width: 1rem; height: 1rem; }
.icon-sm { width: 1.125rem; height: 1.125rem; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.opacity-25 { opacity: 0.25; }
.opacity-75 { opacity: 0.75; }

/* ---- Result card ---- */
.result-wrap { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

.verdict-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: 1rem;
  box-shadow: 0 0 0 1px var(--ring-color, transparent);
}
.verdict-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 1px solid;
}
.verdict-body { min-width: 0; flex: 1; }
.verdict-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.verdict-title { margin: 0; font-size: 1.125rem; font-weight: 600; }
.verdict-chip {
  border-radius: 9999px;
  border: 1px solid;
  padding: 0.1rem 0.6rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.verdict-explanation { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--surface-muted); }

.verdict-meta {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 1.5rem;
  font-size: 0.75rem;
  color: var(--surface-muted);
}
@media (min-width: 640px) { .verdict-meta { grid-template-columns: repeat(4, 1fr); } }
.verdict-meta dt { font-weight: 500; color: var(--surface-muted-2); }
.verdict-meta dd { margin: 0; font-family: "JetBrains Mono", ui-monospace, monospace; }

.verdict-pass { --ring-color: rgba(16,185,129,0.4); }
.verdict-fail { --ring-color: rgba(239,68,68,0.4); }
.verdict-softfail { --ring-color: rgba(249,115,22,0.4); }
.verdict-neutral, .verdict-none { --ring-color: rgba(14,165,233,0.4); }
.verdict-permerror, .verdict-temperror { --ring-color: rgba(245,158,11,0.4); }

.badge-pass { background: var(--emerald-bg); color: var(--emerald); border-color: var(--emerald-border); }
.badge-fail { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.badge-softfail { background: var(--orange-bg); color: var(--orange); border-color: var(--orange-border); }
.badge-neutral, .badge-none { background: var(--sky-bg); color: var(--sky); border-color: var(--sky-border); }
.badge-permerror, .badge-temperror { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-border); }

/* ---- Trace tree ---- */
.trace-heading { margin: 0 0 0.5rem; font-size: 0.875rem; font-weight: 600; }

.trace-node {
  border: 1px solid var(--surface-border-soft);
  background: rgba(0,0,0,0.015);
  border-radius: 0.75rem;
  padding: 0.75rem;
}
html.dark .trace-node { background: rgba(255,255,255,0.015); }

.trace-node-head { margin-bottom: 0.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.trace-domain { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.75rem; font-weight: 600; }
.trace-status-ok {
  border-radius: 9999px; background: rgba(54,96,250,0.10); color: var(--brand-600);
  padding: 0.1rem 0.5rem; font-size: 0.625rem; font-weight: 600;
}
html.dark .trace-status-ok { color: var(--brand-400); }
.trace-status-err {
  border-radius: 9999px; background: var(--red-bg); color: var(--red);
  padding: 0.1rem 0.5rem; font-size: 0.625rem; font-weight: 600;
}

.trace-record {
  margin: 0 0 0.75rem;
  overflow-x: auto;
  border-radius: 0.5rem;
  background: var(--code-bg);
  color: #6ee7b7;
  padding: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.6;
}

.trace-terms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.trace-term { border-left: 1px dashed var(--surface-border); padding-left: 1rem; }

.term-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  border: 1px solid; border-radius: 0.5rem; padding: 0.5rem 0.75rem; font-size: 0.875rem;
}
.term-raw { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.8125rem; font-weight: 500; }
.term-outcome-badge {
  border-radius: 9999px; background: rgba(0,0,0,0.05); padding: 0.1rem 0.5rem;
  font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
html.dark .term-outcome-badge { background: rgba(255,255,255,0.10); }

.term-match { border-color: var(--emerald-border); background: var(--emerald-bg); color: var(--emerald); }
.term-no-match { border-color: var(--surface-border); background: rgba(0,0,0,0.02); color: var(--surface-muted); }
html.dark .term-no-match { background: rgba(255,255,255,0.02); }
.term-error { border-color: var(--red-border); background: var(--red-bg); color: var(--red); }
.term-skipped { border-color: var(--amber-border); background: var(--amber-bg); color: var(--amber); }

.term-expand-btn {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 0.6875rem; font-weight: 500; text-decoration: underline dotted; text-underline-offset: 2px;
  color: inherit; opacity: 0.8;
}
.term-expand-btn:hover { opacity: 1; }

.term-detail { margin: 0.25rem 0 0; padding-left: 0.25rem; font-size: 0.8125rem; line-height: 1.4; color: var(--surface-muted); }
.term-addresses { margin: 0.25rem 0 0; padding-left: 0.25rem; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.75rem; color: var(--surface-muted-2); }
.term-children { margin-top: 0.5rem; }

/* ---- Content sections ---- */
.content-section { padding-bottom: 4rem; scroll-margin-top: 5rem; }
.content-section h2 { font-size: 1.25rem; font-weight: 600; margin: 0 0 1.25rem; }

.step-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .step-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { padding: 1.25rem; }
.step-num {
  display: flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border-radius: 9999px;
  background: var(--brand-600); color: #fff; font-size: 0.75rem; font-weight: 700;
}
.step-card h3 { margin: 0.75rem 0 0; font-size: 0.875rem; font-weight: 600; }
.step-card p { margin: 0.375rem 0 0; font-size: 0.8125rem; line-height: 1.5; color: var(--surface-muted); }

.faq-list { margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.faq-item { padding: 1.25rem; }
.faq-item dt { font-size: 0.875rem; font-weight: 600; }
.faq-item dd { margin: 0.375rem 0 0; font-size: 0.8125rem; line-height: 1.5; color: var(--surface-muted); }

.site-footer {
  border-top: 1px solid var(--surface-border-soft);
  padding: 2rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
  text-align: center; font-size: 0.75rem; color: var(--surface-muted-2);
}
@media (min-width: 640px) { .site-footer { flex-direction: row; justify-content: space-between; text-align: left; } }

.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
