:root {
  --navy: #0f172a;
  --navy-light: #1e293b;
  --mint: #10b981;
  --mint-hover: #059669;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Nav */
header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-container img {
  height: 42px;
  width: auto;
}

.badge-gdpr {
  font-size: 0.8rem;
  font-weight: 600;
  background-color: #f1f5f9;
  /*
   * ACCESSIBILITY FIX: var(--text-muted) (#64748b) on this badge's
   * #f1f5f9 background is only a ~4.34:1 contrast ratio, below the 4.5:1
   * WCAG AA minimum for normal-size text — flagged by PageSpeed
   * Insights/Lighthouse as a real accessibility failure. #475569 against
   * the same background is ~6.9:1, comfortably passing, while staying the
   * same muted slate grey visually.
   */
  color: #475569;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Main Container */
main {
  max-width: 680px;
  margin: 3rem auto;
  padding: 0 1.5rem;
  width: 100%;
}

/*
 * HERO BACKGROUND PHOTO + OVERLAY
 * -----------------------------------------------------------------------
 * background-color is a solid, near-instant fallback (the same black the
 * overlay itself is built from) so the section never flashes white/unstyled
 * for the split second before the photo has loaded — the text stays
 * readable even on a slow connection or if the image file is ever missing.
 *
 * The two background-image layers are painted top-to-bottom: the
 * linear-gradient (dark overlay) sits ON TOP of the photo. Overlay is
 * deliberately light — rgba(0,0,0,0.3 -> 0.4), down from an earlier
 * rgba(0,0,0,0.6 -> 0.7) — dark enough to keep the text readable, but
 * light enough that the photo (and the train in it) actually reads as
 * bright and visible rather than a near-black silhouette. To compensate
 * for the lighter overlay, .hero h1/.hero p below carry a slightly
 * stronger, two-layer text-shadow (a tight dark contour plus a soft
 * glow) rather than relying on the overlay alone for contrast.
 *
 * SELF-HOSTED LOCALLY: the photo now loads from
 * public/images/hero-train.jpg (served at /images/hero-train.jpg) instead
 * of a third-party CDN URL — no external request/preconnect needed any
 * more. To swap in a different photo (e.g. a specific GWR-liveried one),
 * just replace that file with another image of the same name; for best
 * results keep it around 1600px wide, compressed (JPEG quality ~75-80) so
 * it stays fast to load, especially on mobile.
 */
.hero {
  position: relative;
  text-align: center;
  margin-bottom: 2.5rem;
  padding: 4.5rem 1.75rem 4rem;
  border-radius: 20px;
  overflow: hidden;
  background-color: #000000;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.4)),
    url('/images/hero-train.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Deliberately NOT background-attachment: fixed — that disables GPU
     scroll compositing on mobile Safari/Chrome and is a well-known cause
     of janky, laggy scrolling on exactly the devices this needs to stay
     fast on. */
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.55), 0 4px 22px rgba(0, 0, 0, 0.45);
  margin-bottom: 0.5rem;
}

.hero p {
  color: #ffffff;
  font-size: 1.05rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6), 0 2px 16px rgba(0, 0, 0, 0.4);
}

@media (max-width: 480px) {
  .hero {
    padding: 3rem 1.25rem 2.75rem;
    border-radius: 14px;
    margin-bottom: 1.75rem;
  }

  .hero h1 {
    font-size: 1.65rem;
  }

  .hero p {
    font-size: 0.95rem;
  }
}

/* Card Form */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--navy);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

input, select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Buttons */
.btn-primary {
  width: 100%;
  background-color: var(--navy);
  color: #ffffff;
  border: none;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--navy-light);
}

/* Result Box */
.result-box {
  display: none;
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.result-box.active {
  display: block;
}

.result-box h3 {
  color: #166534;
  margin-bottom: 0.5rem;
}

.refund-amount {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--mint-hover);
  margin: 0.5rem 0;
}

/* Legal Footer */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------- */
/* UX: Visual loaders / spinners (Step 1-3 buttons + AI scan button)      */
/* ---------------------------------------------------------------------- */
.btn-primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.btn-primary:disabled,
.btn-primary[aria-busy="true"] {
  opacity: 0.75;
  cursor: not-allowed;
}

/*
 * BUGFIX: this rule previously set `display: inline-block` unconditionally,
 * which — same class of issue as the cookie-consent modal bug — always won
 * over the `hidden` attribute's UA-stylesheet `[hidden] { display: none }`
 * default (author rules beat user-agent rules regardless of specificity or
 * source order). That made every spinner render, and its `infinite`
 * animation run, from the very first page load, with no request in flight
 * and no way for JS toggling `hidden` to ever stop it.
 *
 * Fix: the spinner is now display:none by default. It is shown ONLY when
 * its button carries the `.loading` class (added/removed by JS below,
 * exclusively for the duration of an actual in-flight request), via the
 * more specific `.loading .btn-spinner` rule further down.
 */
.btn-spinner {
  display: none;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: delayo-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Spinner is only ever visible while its button is actively busy. */
button.loading .btn-spinner {
  display: inline-block;
}

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

.scan-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: #047857;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.scan-status.is-error {
  color: #b91c1c;
}

.scan-status .btn-spinner {
  border-color: rgba(4, 120, 87, 0.3);
  border-top-color: #047857;
}

/* ---------------------------------------------------------------------- */
/* GDPR Cookie Consent Banner                                             */
/* ---------------------------------------------------------------------- */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background: var(--navy);
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
}

.cookie-banner__body {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

.cookie-banner__body p {
  flex: 1 1 380px;
  font-size: 0.825rem;
  color: #cbd5e1;
  margin: 0;
}

.cookie-banner__body a {
  color: #6ee7b7;
  text-decoration: underline;
}

.cookie-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cookie-btn {
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.825rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.cookie-btn--primary {
  background: var(--mint);
  color: #05261c;
  border-color: var(--mint);
}

.cookie-btn--primary:hover {
  background: var(--mint-hover);
}

.cookie-btn--ghost {
  background: transparent;
  color: #e2e8f0;
  border-color: rgba(226, 232, 240, 0.35);
}

.cookie-btn--ghost:hover {
  border-color: #e2e8f0;
}

.cookie-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cookie-modal__panel {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.cookie-modal__panel h3 {
  font-size: 1.1rem;
  color: var(--navy);
  margin-bottom: 1rem;
}

.cookie-modal__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.cookie-modal__row:first-of-type {
  border-top: none;
}

.cookie-modal__row strong {
  display: block;
  font-size: 0.9rem;
  color: var(--navy);
  margin-bottom: 0.2rem;
}

.cookie-modal__row p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cookie-modal__row input[type="checkbox"] {
  width: auto;
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.cookie-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

@media (max-width: 480px) {
  .cookie-banner__actions {
    width: 100%;
  }

  .cookie-btn {
    flex: 1 1 auto;
  }
}