:root {
  --bg: #faf8f4;
  --bg-elev: #ffffff;
  --ink: #0f1e3d;
  --ink-soft: #3a4561;
  --ink-muted: #6a7389;
  --rule: #e4ddcc;
  --accent: #c9423a;
  --score-1: #c9423a;
  --score-2: #e08b3a;
  --score-3: #d4b24c;
  --score-4: #4f8a5e;
  --disclaimer-bg: #ece7d8;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue",
    Arial, sans-serif;

  --maxw: 680px;
  --radius: 4px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.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;
}

/* ---------- Header ---------- */

.site-header {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand__lockup {
  display: block;
  width: 220px;
  height: auto;
  max-width: 100%;
}

.brand__partner {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.brand__partner strong {
  color: var(--ink);
  letter-spacing: 0.14em;
}

/* ---------- Layout ---------- */

.container {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 24px 80px;
}

.screen {
  display: none;
}

[data-state="landing"] .screen--landing,
[data-state="processing"] .screen--processing,
[data-state="results"] .screen--results,
[data-state="error"] .screen--error,
[data-state="rate-limited"] .screen--rate-limited {
  display: block;
}

/* ---------- Landing ---------- */

.hero-title {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 32px 0 28px;
}

.hero-title em {
  color: var(--accent);
  font-style: italic;
}

.analyze-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.analyze-form input[type="url"] {
  flex: 1 1 260px;
  min-width: 0;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.analyze-form input[type="url"]::placeholder {
  color: var(--ink-muted);
}

.analyze-form input[type="url"]:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 30, 61, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.btn--primary {
  background: var(--ink);
  color: var(--bg);
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--accent);
}

.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
  background: var(--ink);
  color: var(--bg);
}

.btn:focus-visible {
  outline: 3px solid rgba(201, 66, 58, 0.35);
  outline-offset: 2px;
}

.how-it-works {
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 58ch;
}

/* ---------- Processing ---------- */

.screen--processing {
  text-align: center;
  padding-top: 64px;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 24px;
  border-radius: 50%;
  border: 3px solid var(--rule);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.processing-title {
  font-family: var(--serif);
  font-size: 28px;
  margin: 0 0 6px;
}

.processing-hint {
  color: var(--ink-muted);
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

/* ---------- Results ---------- */

.results-title {
  font-family: var(--serif);
  font-size: 32px;
  margin: 24px 0 20px;
}

.score-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.score-badge {
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  color: #fff;
  background: var(--ink-muted);
  font-family: var(--serif);
  padding-bottom: 4px;
}

.score-badge[data-score="1"] {
  background: var(--score-1);
}
.score-badge[data-score="2"] {
  background: var(--score-2);
}
.score-badge[data-score="3"] {
  background: var(--score-3);
  color: #3a2a00;
}
.score-badge[data-score="4"] {
  background: var(--score-4);
}

.score-badge__number {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
}

.score-badge__scale {
  font-size: 16px;
  opacity: 0.85;
}

.score-label__title {
  margin: 0 0 2px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}

.score-label__caption {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.rationale {
  margin: 0 0 24px;
}

.rationale__title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.rationale__body {
  margin: 0;
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
}

.recommendations {
  margin: 0 0 28px;
}

.recommendations__title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.recommendations__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.rec-card__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.rec-card__link:hover,
.rec-card__link:focus-visible {
  border-color: var(--ink);
  background: #fff;
  outline: none;
}

.rec-card__handle {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}

.rec-card__cta {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.transcript {
  margin: 0 0 28px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
}

.transcript summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  padding: 4px 0;
  list-style: none;
}

.transcript summary::-webkit-details-marker {
  display: none;
}

.transcript summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  color: var(--ink-muted);
  transition: transform 0.15s ease;
}

.transcript[open] summary::before {
  transform: rotate(90deg);
}

.transcript__body {
  margin: 12px 0 4px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.transcript__caption {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
  font-style: italic;
}

.transcript__section + .transcript__section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.transcript__label {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.results-actions {
  margin: 8px 0 32px;
}

.disclaimer {
  background: var(--disclaimer-bg);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
  padding: 14px 16px;
  border-radius: var(--radius);
}

/* ---------- Error / Rate ---------- */

.screen--error,
.screen--rate-limited {
  text-align: center;
  padding-top: 56px;
}

.error-title {
  font-family: var(--serif);
  font-size: 30px;
  margin: 0 0 12px;
}

.error-message {
  color: var(--ink-soft);
  margin: 0 auto 24px;
  max-width: 48ch;
}

.rate-countdown {
  color: var(--ink-muted);
  font-size: 14px;
  margin: -12px auto 20px;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 32px;
  color: var(--ink-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--rule);
}

.site-footer p {
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .site-header {
    padding: 24px 20px 12px;
  }

  .brand__lockup {
    width: min(60vw, 200px);
  }

  .container {
    padding: 16px 20px 64px;
  }

  .hero-title {
    font-size: 30px;
    margin: 20px 0 22px;
  }

  .analyze-form {
    flex-direction: column;
  }

  .analyze-form input[type="url"],
  .btn {
    width: 100%;
  }

  .analyze-form input[type="url"] {
    flex: 0 0 auto;
    padding: 12px 14px;
    font-size: 15px;
  }

  .score-card {
    gap: 16px;
    padding: 16px;
  }

  .score-badge {
    width: 70px;
    height: 70px;
  }

  .score-badge__number {
    font-size: 34px;
  }

  .results-title {
    font-size: 26px;
  }

  .rationale__body {
    font-size: 16px;
  }
}
