/* ---------- Reset ---------- */

/* Make every element use border-box sizing and drop default margins */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Design tokens ---------- */

:root {
  /* Page background: deep near-black navy */
  --bg: #080d1a;
  /* Card background, slightly lighter than the page */
  --bg-elevated: #0e1424;
  /* Nested surfaces inside cards (inputs, pills) */
  --bg-elevated-2: #131b31;
  /* Subtle and stronger border colors for dark surfaces */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  /* Text colors from brightest to dimmest */
  --text: #f5f6fa;
  --text-muted: #9aa3b8;
  --text-faint: #6b7385;
  /* Brand gradient endpoints (indigo to purple) */
  --accent-start: #6366f1;
  --accent-end: #a855f7;
  --accent-gradient: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  /* Status green used for the "AI-powered" live dot */
  --green: #22c55e;
  /* Status red used for error messages (e.g. failed letter generation) */
  --red: #ef4444;
  /* Shared corner radii */
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  /* Shared content max width */
  --max-width: 1180px;
}

/* ---------- Base ---------- */

/* Prevent the fixed decorative glow blobs from causing horizontal scroll */
html {
  overflow-x: hidden;
}

/* Base page styles: font, color, background */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Reusable centered content wrapper */
.navbar-inner,
.hero-inner,
.main-grid,
.steps-grid,
.disclaimer p {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ---------- Decorative background glow ---------- */

/* Large blurred radial gradients placed behind the hero for depth */
.bg-glow {
  position: fixed;
  z-index: 0;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.25;
  pointer-events: none;
}

/* First blob: indigo, upper left */
.bg-glow--one {
  top: -220px;
  left: -160px;
  background: var(--accent-start);
}

/* Second blob: purple, upper right */
.bg-glow--two {
  top: -160px;
  right: -220px;
  background: var(--accent-end);
}

/* ---------- Shared badge / pill styles ---------- */

/* Generic pill badge used in the nav, hero, and example card */
.badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated-2);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Small pulsing dot that signals "live AI" */
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 2s infinite;
}

/* Pulse animation: dot grows a fading ring outward */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Respect users who don't want motion */
@media (prefers-reduced-motion: reduce) {
  .pulse-dot {
    animation: none;
  }
}

/* Text rendered with the brand gradient instead of a solid color */
.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Muted "·" separators used in the hero subtext */
.dot-sep {
  color: var(--text-faint);
  margin: 0 0.15rem;
}

/* ---------- Navbar ---------- */

/* Sticky top bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(8, 13, 26, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

/* Navbar content row: logo left, badges right */
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
}

/* Logo link: icon + wordmark, no underline */
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}

/* Small gradient square behind the logo glyph */
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.9rem;
}

/* Logo wordmark text */
.logo-text {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

/* Dim the ".ai" portion of the wordmark for contrast */
.logo-text-accent {
  color: var(--text-muted);
  font-weight: 500;
}

/* Right side of the navbar: badge + price text */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

/* "$2 per letter" label next to the AI badge */
.navbar-price {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Hero ---------- */

/* Hero section padding and centering */
.hero {
  position: relative;
  z-index: 1;
  padding: 4.5rem 1.5rem 3rem;
  text-align: center;
}

/* Stack hero children centered with spacing between them */
.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* "AI-powered" badge in the navbar, slightly brighter than the default pill */
.badge-ai {
  color: var(--text);
}

/* Eyebrow badge above the headline */
.badge-hero {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
  color: #c7c9ff;
}

/* Big bold headline */
.hero-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  max-width: 780px;
}

/* Supporting line explaining the three-step flow */
.hero-subtext {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--text-muted);
  max-width: 600px;
}

/* ---------- Stats row ---------- */

/* Four-column stat grid, using <dl> for semantic number/label pairs */
.stats {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 2.5rem;
  margin-top: 1.5rem;
}

/* Each individual stat, number stacked above label */
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

/* Large gradient stat number */
.stat-number {
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Small muted stat label under the number */
.stat-label {
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ---------- Main two-column section ---------- */

/* Section padding around the grid */
.main-section {
  position: relative;
  z-index: 1;
  padding: 1.5rem 1.5rem 4rem;
}

/* Two equal columns on desktop: form and example letter */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  align-items: start;
}

/* Shared card look for the form and example panels */
.form-card,
.example-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

/* Heading inside the form card */
.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* ---------- Form ---------- */

/* Stack form fields vertically */
#complaint-form {
  display: flex;
  flex-direction: column;
}

/* Field labels */
#complaint-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 1.1rem;
  margin-bottom: 0.4rem;
}

/* First label doesn't need extra top spacing */
#complaint-form label:first-of-type {
  margin-top: 0;
}

/* Shared field chrome for text inputs, textarea, and select */
#complaint-form input,
#complaint-form textarea,
#complaint-form select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  width: 100%;
}

/* Placeholder text color */
#complaint-form input::placeholder,
#complaint-form textarea::placeholder {
  color: var(--text-faint);
}

/* Let the textarea grow vertically but not horizontally */
#complaint-form textarea {
  resize: vertical;
}

/* Style the select like the other fields, with a custom caret */
#complaint-form select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) center, calc(100% - 15px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Focus state: glowing purple ring, matches the brand gradient */
#complaint-form input:focus,
#complaint-form textarea:focus,
#complaint-form select:focus {
  outline: none;
  border-color: var(--accent-start);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* Submit button: gradient fill, price pill on the right */
.generate-btn {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.25rem;
  background: var(--accent-gradient);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

/* Subtle lift on hover */
.generate-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* Small pill showing the price inside the submit button */
.price-pill {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.85rem;
}

/* Status message shown under the form after submission (added by script.js) */
.form-status {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Error variant of the status message, used when generation fails */
.form-status--error {
  color: var(--red);
}

/* ---------- Example letter card ---------- */

/* Header row above the letter preview: badge + caption */
.example-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* Badge styled to stand out slightly greener/brighter than the AI badge */
.badge-example {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.35);
  color: #e6c8ff;
}

/* Caption next to the badge */
.example-caption {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* The "paper" mockup: light surface with dark serif text, like a real letter */
.letter-paper {
  background: #f8f7f4;
  color: #22242c;
  border-radius: var(--radius-md);
  padding: 1.75rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.88rem;
  line-height: 1.6;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

/* Date line at the top of the letter */
.letter-date {
  color: #55586a;
  margin-bottom: 1rem;
}

/* Recipient block */
.letter-recipient {
  margin-bottom: 1rem;
}

/* Bold subject / "Re:" line */
.letter-subject {
  font-weight: 700;
  margin-bottom: 1rem;
}

/* Space paragraphs of the letter body apart */
.letter-body p {
  margin-bottom: 0.9rem;
}

/* Sign-off block at the end of the letter */
.letter-signoff {
  margin-top: 1rem;
}

/* Signature line placeholder */
.letter-signature {
  font-weight: 700;
}

/* ---------- Generated letter result ---------- */

/* Full-width wrapper section, matching the horizontal padding used elsewhere */
.result-section {
  position: relative;
  z-index: 1;
  padding: 0 1.5rem 2.5rem;
}

/* Card holding the generated letter, centered and capped at the shared max width */
.result-card {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

/* The generated letter's text: inherit the letter-paper's serif styling, but wrap like normal text */
.generated-letter-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* "Copy letter" button: same shape as the submit button, but sized to its content */
.copy-btn {
  margin-top: 1.25rem;
  width: auto;
  padding: 0.7rem 1.5rem;
}

/* ---------- Steps section ---------- */

/* Section padding, separated from the section above by a top border */
.steps-section {
  position: relative;
  z-index: 1;
  padding: 3rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* Three-column grid of steps */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

/* Each step: number badge, title, description */
.step {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Circular gradient number badge */
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

/* Step heading */
.step-title {
  font-size: 1rem;
  font-weight: 700;
}

/* Step description text */
.step-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------- Disclaimer footer ---------- */

/* Footer wrapper, separated from the steps section */
.disclaimer {
  position: relative;
  z-index: 1;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* Small muted disclaimer text */
.disclaimer p {
  font-size: 0.78rem;
  color: var(--text-faint);
  max-width: 640px;
}

/* ---------- Responsive: tablet ---------- */

@media (max-width: 900px) {
  /* Stack the form and example letter instead of two columns */
  .main-grid {
    grid-template-columns: 1fr;
  }

  /* Let stats wrap into two rows of two on medium screens */
  .stats {
    grid-template-columns: repeat(2, auto);
    row-gap: 1.5rem;
  }

  /* Stack the three steps into a single column */
  .steps-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}

/* ---------- Responsive: mobile ---------- */

@media (max-width: 480px) {
  /* Hide the redundant "$2 per letter" label, already shown in the hero stats */
  .navbar-price {
    display: none;
  }

  /* Reduce hero vertical padding on small screens */
  .hero {
    padding: 3rem 1.25rem 2rem;
  }

  /* Reduce card padding on small screens */
  .form-card,
  .example-card {
    padding: 1.25rem;
  }
}
