/* ============================================================
   UnderstandSEO Design Tokens
   Three palette families. Pick one per site based on brand archetype.
   Override --accent HSL hue with the actual brand color extracted
   from logo/photography/signage during Phase 2 research.
   ============================================================ */

:root {
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 1rem;
  --space-4: 1.5rem; --space-5: 2rem; --space-6: 3rem;
  --space-7: 5rem; --space-8: 8rem;

  --radius-sm: 0.25rem; --radius: 0.5rem; --radius-lg: 1rem;
  --radius-pill: 9999px;

  --max-w: 1200px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 24px 48px -12px rgba(0,0,0,0.18);
}

/* PALETTE 1: WARM — restaurants, hospitality, family business
   Reference: Hudson Kitchen. Body: refined sans. Display: warm serif. */
.palette-warm {
  --bg: #FBF7F1; --surface: #FFFFFF; --surface-2: #F4EDE2;
  --ink: #1F1A14; --ink-2: #4A4238; --ink-3: #7A7166;
  --rule: #E5DCC8;
  --accent: hsl(22 78% 48%);
  --accent-soft: hsl(22 78% 92%);
  --accent-ink: hsl(22 78% 22%);
  --highlight: #F2C94C;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --hero-display-size: clamp(2.75rem, 7vw, 5.5rem);
  --h2-size: clamp(2rem, 4.5vw, 3.25rem);
  --body-size: 1.0625rem;
}

/* PALETTE 2: MODERN — professional services, B2B, agencies
   Reference: Futureform, Clear Street. */
.palette-modern {
  --bg: #FFFFFF; --surface: #FAFAF7; --surface-2: #0E0E0C;
  --ink: #0E0E0C; --ink-2: #3A3A36; --ink-3: #6E6E68;
  --rule: #E8E8E2;
  --accent: hsl(220 90% 52%);
  --accent-soft: hsl(220 60% 95%);
  --accent-ink: hsl(220 90% 18%);
  --highlight: #D6FF3D;
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Geist', 'Inter', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;
  --hero-display-size: clamp(3rem, 8vw, 6.5rem);
  --h2-size: clamp(2rem, 4.5vw, 3.5rem);
  --body-size: 1.0625rem;
}

/* PALETTE 3: CIVIC — government, churches, schools, healthcare
   AAA contrast targets, not just AA. */
.palette-civic {
  --bg: #FFFFFF; --surface: #F5F2EC; --surface-2: #14202E;
  --ink: #14202E; --ink-2: #34465B; --ink-3: #647488;
  --rule: #D8D3C7;
  --accent: hsl(200 65% 32%);
  --accent-soft: hsl(200 35% 92%);
  --accent-ink: hsl(200 65% 18%);
  --highlight: #B8860B;
  --font-display: 'Source Serif 4', 'Charter', Georgia, serif;
  --font-body: 'Source Sans 3', 'Atkinson Hyperlegible', system-ui, sans-serif;
  --font-mono: 'Source Code Pro', ui-monospace, monospace;
  --hero-display-size: clamp(2.5rem, 6vw, 4.75rem);
  --h2-size: clamp(1.875rem, 4vw, 2.75rem);
  --body-size: 1.125rem;
}

/* Base styles
   ─────────────────────────────────────────────────────────
   FONT LOADING: All Google Fonts links must include &display=swap
   so the browser uses --font-body / --font-display fallbacks
   (system-ui, Georgia, etc.) instantly while web fonts download.
   See font-loading.md for the full preconnect + display=swap pattern.
   ───────────────────────────────────────────────────────── */
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: var(--body-size);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}
h1, h2, h3, h4 {
  font-family: var(--font-display); color: var(--ink);
  line-height: 1.05; letter-spacing: -0.02em; margin: 0;
  font-weight: 500;
}
h1 { font-size: var(--hero-display-size); }
h2 { font-size: var(--h2-size); }
h3 { font-size: 1.5rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
::selection { background: var(--accent); color: var(--bg); }

.display-italic {
  font-style: italic; font-weight: 400; color: var(--accent-ink);
}

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.875rem 1.5rem; border-radius: var(--radius-pill);
  font-family: var(--font-body); font-weight: 500; font-size: 1rem;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
  white-space: nowrap; cursor: pointer; border: none;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: var(--bg); }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn-secondary:hover { background: var(--ink); color: var(--bg); }
.btn-accent { background: var(--accent); color: var(--bg); }
.btn-accent:hover { background: var(--accent-ink); color: var(--bg); }

.container-prose {
  max-width: var(--max-w); margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-mono); font-size: 0.8125rem;
  font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}
.eyebrow::before {
  content: ""; display: inline-block;
  width: 1.5rem; height: 1px; background: currentColor; opacity: 0.5;
}

/* ============================================================
   DARK MODE
   Automatic via prefers-color-scheme. No manual toggle.
   Each palette gets a proper dark treatment — not just swapped
   bg/ink. Accent colors are lightened for WCAG AA on dark
   surfaces, and civic targets AAA.
   ============================================================ */

@media (prefers-color-scheme: dark) {
  /* WARM DARK — rich, deep warm neutrals */
  .palette-warm {
    --bg: #1A1613;
    --surface: #231F1A;
    --surface-2: #2E2822;
    --ink: #F2EDE6;
    --ink-2: #C4BBB0;
    --ink-3: #9A8F83;
    --rule: #3D352C;
    --accent: hsl(22 78% 58%);        /* lightened for dark bg visibility */
    --accent-soft: hsl(22 40% 18%);   /* muted warm glow, not light-mode pastel */
    --accent-ink: hsl(22 78% 72%);    /* readable text on dark surfaces */
    --highlight: #F2C94C;
    /* Shadows shift to deeper darks, no visible haze */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.25);
    --shadow: 0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg: 0 24px 48px -12px rgba(0,0,0,0.55);
  }

  /* MODERN DARK — near-black with crisp accent */
  .palette-modern {
    --bg: #0E0E0C;
    --surface: #171714;
    --surface-2: #222220;
    --ink: #F5F5F0;
    --ink-2: #BBBBB5;
    --ink-3: #8A8A84;
    --rule: #2E2E2A;
    --accent: hsl(220 90% 62%);       /* brighter blue for dark surfaces */
    --accent-soft: hsl(220 40% 16%);
    --accent-ink: hsl(220 80% 76%);
    --highlight: #D6FF3D;             /* already high-contrast on dark */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 24px 48px -12px rgba(0,0,0,0.6);
  }

  /* CIVIC DARK — deep navy with AAA contrast targets */
  .palette-civic {
    --bg: #0F1720;
    --surface: #162232;
    --surface-2: #1E2D40;
    --ink: #F0EDE8;                   /* 14.8:1 on --bg — exceeds AAA */
    --ink-2: #C8C2B8;                 /* 9.2:1 on --bg — AAA */
    --ink-3: #96908A;                 /* 5.5:1 on --bg — exceeds AA */
    --rule: #2A3A50;
    --accent: hsl(200 65% 52%);      /* lightened for dark bg; 5.1:1 on --bg */
    --accent-soft: hsl(200 30% 16%);
    --accent-ink: hsl(200 55% 72%);  /* 8.3:1 on --bg — AAA for body text */
    --highlight: #D4A017;            /* goldrod, warmer for dark bg */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 24px 48px -12px rgba(0,0,0,0.6);
  }

  /* Dark mode base overrides */
  ::selection {
    background: var(--accent);
    color: var(--bg);
  }

  /* Inverted surface sections need tweaked colors in dark mode */
  .shape-band-ink {
    background: #000;
  }
  .shape-band-accent {
    /* Slight opacity reduction so accent band is not blinding on dark */
    filter: brightness(0.9);
  }

  /* Glassmorphism adjustments for dark mode */
  .mobile-cta-bar {
    background: rgba(14, 14, 12, 0.82) !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
  }

  /* Dialog backdrop gets darker */
  .useo-dialog-backdrop {
    background: rgba(0, 0, 0, 0.7);
  }

  /* Google reviews fade gradient matches dark bg */
  .google-reviews-fade {
    background: linear-gradient(to right, transparent, var(--bg));
  }

  /* Scrollbar styling for dark mode */
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb { background: var(--rule); }
}

/* ============================================================
   END DARK MODE
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0; transform: translateY(12px);
    animation: reveal 700ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }
  .reveal:nth-child(2) { animation-delay: 80ms; }
  .reveal:nth-child(3) { animation-delay: 160ms; }
  .reveal:nth-child(4) { animation-delay: 240ms; }
  .reveal:nth-child(5) { animation-delay: 320ms; }
  @keyframes reveal { to { opacity: 1; transform: translateY(0); } }

  /* Horizontal slide-in variants */
  .reveal-left {
    opacity: 0; transform: translateX(-24px);
    animation: reveal-left 700ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }
  .reveal-right {
    opacity: 0; transform: translateX(24px);
    animation: reveal-right 700ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }
  @keyframes reveal-left { to { opacity: 1; transform: translateX(0); } }
  @keyframes reveal-right { to { opacity: 1; transform: translateX(0); } }

  /* Staggered group container — children auto-stagger via nth-child */
  .reveal-group > .reveal:nth-child(1),
  .reveal-group > .reveal-left:nth-child(1),
  .reveal-group > .reveal-right:nth-child(1) { animation-delay: 0ms; }
  .reveal-group > .reveal:nth-child(2),
  .reveal-group > .reveal-left:nth-child(2),
  .reveal-group > .reveal-right:nth-child(2) { animation-delay: 80ms; }
  .reveal-group > .reveal:nth-child(3),
  .reveal-group > .reveal-left:nth-child(3),
  .reveal-group > .reveal-right:nth-child(3) { animation-delay: 160ms; }
  .reveal-group > .reveal:nth-child(4),
  .reveal-group > .reveal-left:nth-child(4),
  .reveal-group > .reveal-right:nth-child(4) { animation-delay: 240ms; }
  .reveal-group > .reveal:nth-child(5),
  .reveal-group > .reveal-left:nth-child(5),
  .reveal-group > .reveal-right:nth-child(5) { animation-delay: 320ms; }
  .reveal-group > .reveal:nth-child(6),
  .reveal-group > .reveal-left:nth-child(6),
  .reveal-group > .reveal-right:nth-child(6) { animation-delay: 400ms; }

  /* IntersectionObserver-enhanced reveals (see scroll-reveal.md).
     When the observer script runs, it adds .reveal--pending to hide elements
     until they enter the viewport, then .reveal--visible to transition in. */
  .reveal--pending {
    opacity: 0; transform: translateY(12px); animation: none !important;
  }
  .reveal-left.reveal--pending {
    opacity: 0; transform: translateX(-24px); animation: none !important;
  }
  .reveal-right.reveal--pending {
    opacity: 0; transform: translateX(24px); animation: none !important;
  }
  .reveal--visible {
    opacity: 1 !important; transform: none !important;
    transition: opacity 700ms cubic-bezier(0.2, 0.7, 0.2, 1),
                transform 700ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
}
