/* Siteinator — Default Theme Variables
   Customer overrides via site/theme Firestore doc + loadTheme() in page-renderer.js. */

:root {
  /* Brand */
  --brand-primary: #0A95D7;    /* Electric Blue — buttons, links */
  --brand-accent: #56F9F3;     /* Luminous Cyan — high-energy accents */
  --brand-anchor: #0059B3;     /* Slipwai Navy — hover states, structure */

  /* Backgrounds */
  --bg-base: #020817;          /* Void Blue — page background */
  --bg-surface: #0F172A;       /* Slate Hull — cards, sections */
  --bg-elevated: #1E293B;      /* Steel Wave — elevated elements */

  /* Text */
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Borders — derived from --text-primary so they invert with the theme:
     a white-translucent line on dark backgrounds, a dark-translucent line on
     light. CSS variables nesting is supported and re-evaluates at use-site,
     so swapping --text-primary via loadTheme automatically repaints. */
  --border: color-mix(in srgb, var(--text-primary) 10%, transparent);
  --border-hover: color-mix(in srgb, var(--text-primary) 20%, transparent);

  /* Shadows stay black-translucent — matches universal real-world shadow
     direction (sun/lights cast dark shadows regardless of background). */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);

  /* Status */
  --success: #00E676;
  --warning: #FFD600;
  --danger: #FF5252;

  /* Layout — overridable per-customer via site/theme + loadTheme() */
  --section-padding: 2rem;

  /* Typography — theme overrides set these from site/theme via loadTheme(). */
  --font-heading: 'Barlow Semi Condensed', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', monospace;
}

/* Base reset and defaults */
/* The previous `*, *::before, *::after { box-sizing; margin: 0; padding: 0 }`
   reset lived here when the page loaded Tailwind via CDN (Tailwind v3 +
   runtime injection — no strict @layer separation). With Tailwind v4 built
   to `public/css/tailwind.css`, Preflight already applies the same reset
   inside `@layer base`, which is the cascade-correct position: utilities
   like `mx-auto` and `px-6` (in `@layer utilities`) properly override it.
   Re-introducing the same reset here as unlayered CSS would beat every
   Tailwind utility regardless of specificity (unlayered > layered in CSS
   cascade) and collapse every `mx-auto` / `px-*` / `py-*` in the templates. */

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Below the body (overscroll bounce, short content) the html element's
     background is what shows through. Track the footer's theme — when the
     header / body / footer use different themes, "the rest of the page"
     past the footer matches the footer rather than reverting to the body
     background. Falls back to the body bg when the footer isn't themed
     independently. */
  background-color: var(--footer-bg-base, var(--bg-base));
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--heading-colour, var(--text-primary));
}

code, pre {
  font-family: var(--font-code);
}

/* Form inputs — theme-aware focus ring + placeholder colour, replacing the
   hardcoded Tailwind focus:ring-blue-brand / placeholder-gray-500 utilities
   that templates used to apply per-input. */
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
::placeholder { color: var(--text-muted); opacity: 1; }

/* Header / footer theme scoping. The body's active theme writes to the
   unprefixed --bg-base, --text-primary etc. variables. The header and footer
   active themes write to --header-* / --footer-* variants. These rules
   redefine the unprefixed names inside <nav> and <footer> tags so the
   existing utility classes (.bg-base, .text-primary, …) and template inline
   styles automatically resolve to the section-specific values. If the
   activeHeader / activeFooter theme isn't overridden, the var() second arg
   chains back to the body value — so a single-theme deployment behaves
   exactly as before. */
nav {
  --bg-base: var(--header-bg-base, var(--bg-base, #020817));
  --bg-surface: var(--header-bg-surface, var(--bg-surface));
  --bg-elevated: var(--header-bg-elevated, var(--bg-elevated));
  --text-primary: var(--header-text-primary, var(--text-primary));
  --text-secondary: var(--header-text-secondary, var(--text-secondary));
  --text-muted: var(--header-text-muted, var(--text-muted));
  --brand-primary: var(--header-brand-primary, var(--brand-primary));
  --brand-accent: var(--header-brand-accent, var(--brand-accent));
  --brand-anchor: var(--header-brand-anchor, var(--brand-anchor));
  --success: var(--header-success, var(--success));
  --warning: var(--header-warning, var(--warning));
  --danger: var(--header-danger, var(--danger));
  --heading-colour: var(--header-heading-colour, var(--heading-colour));
  --body-colour: var(--header-body-colour, var(--body-colour));
  --link-colour: var(--header-link-colour, var(--link-colour));
  --link-hover-colour: var(--header-link-hover-colour, var(--link-hover-colour));
  --btn-bg: var(--header-btn-bg, var(--btn-bg));
  --btn-text: var(--header-btn-text, var(--btn-text));
  --btn-hover-bg: var(--header-btn-hover-bg, var(--btn-hover-bg));
  --btn-hover-text: var(--header-btn-hover-text, var(--btn-hover-text));
  --font-heading: var(--header-font-heading, var(--font-heading));
  --font-body: var(--header-font-body, var(--font-body));
  --font-code: var(--header-font-code, var(--font-code));
  background-color: var(--bg-base);
  color: var(--text-primary);
}
footer {
  --bg-base: var(--footer-bg-base, var(--bg-base));
  --bg-surface: var(--footer-bg-surface, var(--bg-surface));
  --bg-elevated: var(--footer-bg-elevated, var(--bg-elevated));
  --text-primary: var(--footer-text-primary, var(--text-primary));
  --text-secondary: var(--footer-text-secondary, var(--text-secondary));
  --text-muted: var(--footer-text-muted, var(--text-muted));
  --brand-primary: var(--footer-brand-primary, var(--brand-primary));
  --brand-accent: var(--footer-brand-accent, var(--brand-accent));
  --brand-anchor: var(--footer-brand-anchor, var(--brand-anchor));
  --success: var(--footer-success, var(--success));
  --warning: var(--footer-warning, var(--warning));
  --danger: var(--footer-danger, var(--danger));
  --heading-colour: var(--footer-heading-colour, var(--heading-colour));
  --body-colour: var(--footer-body-colour, var(--body-colour));
  --link-colour: var(--footer-link-colour, var(--link-colour));
  --link-hover-colour: var(--footer-link-hover-colour, var(--link-hover-colour));
  --btn-bg: var(--footer-btn-bg, var(--btn-bg));
  --btn-text: var(--footer-btn-text, var(--btn-text));
  --btn-hover-bg: var(--footer-btn-hover-bg, var(--btn-hover-bg));
  --btn-hover-text: var(--footer-btn-hover-text, var(--btn-hover-text));
  --font-heading: var(--footer-font-heading, var(--font-heading));
  --font-body: var(--footer-font-body, var(--font-body));
  --font-code: var(--footer-font-code, var(--font-code));
  background-color: var(--bg-base);
  color: var(--text-primary);
}

/* Theme-driven utility classes used by the public renderer.
   Every text/background/border colour the templates emit must come through
   these classes (or inline var(--…)) — so a customer's site/theme switch is
   reflected everywhere, not just in places we remembered to make
   theme-aware. */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-brand { color: var(--brand-accent); }
.text-primary-brand { color: var(--brand-primary); }

.bg-base { background-color: var(--bg-base); }
.bg-surface { background-color: var(--bg-surface); }
.bg-elevated { background-color: var(--bg-elevated); }

/* Display font (for headings / numerals etc.) — wired through the theme so a
   customer's headingFont applies. Templates use `font-display` as a class. */
.font-display { font-family: var(--font-heading); }

.border-brand { border-color: var(--border); }
.border-themed-accent { border-color: var(--brand-accent); }

/* Hover variants — Tailwind's hover:text-* classes resolve to fixed colours
   at compile time, so they don't track the active theme. Use these instead.
*/
.hover-text-primary { transition: color 0.2s ease; }
.hover-text-primary:hover { color: var(--text-primary); }
.hover-text-secondary { transition: color 0.2s ease; }
.hover-text-secondary:hover { color: var(--text-secondary); }

/* Themed link styling for markdown output — used by md() and any anchor that
   needs theme-aware colour + hover. */
.link-themed { color: var(--brand-accent); transition: color 0.2s ease; }
.link-themed:hover { color: var(--text-primary); }

/* CTA button */
.btn-cta {
  display: inline-block;
  background-color: var(--btn-bg, var(--brand-accent));
  color: var(--btn-text, var(--bg-base));
  font-family: var(--font-heading, 'Barlow Semi Condensed', system-ui, sans-serif);
  font-weight: 700;
  font-size: 1.125rem;
  padding: 0.875rem 2.5rem;
  border: none;
  border-radius: var(--border-radius, 0);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  text-decoration: none;
}

.btn-cta:hover {
  background-color: var(--btn-hover-bg, var(--brand-primary));
  color: var(--btn-hover-text, var(--text-primary));
}

/* Links */
a[target="_blank"], [data-content] a {
  color: var(--link-colour, var(--brand-accent));
  transition: color 0.2s ease;
}

a[target="_blank"]:hover, [data-content] a:hover {
  color: var(--link-hover-colour, var(--text-primary));
}

/* Section spacing */
.section {
  padding: var(--section-padding) 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Beacon pulse animation for footer */
@keyframes beacon-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.beacon-pulse {
  animation: beacon-pulse 3s ease-in-out infinite;
}

/* Theme-driven utility overrides */
.text-brand-accent { color: var(--brand-accent); }
.text-brand-primary { color: var(--brand-primary); }
.bg-theme-base { background-color: var(--bg-base); }
.bg-theme-surface { background-color: var(--bg-surface); }
.border-theme { border-color: var(--border); }

/* Markdown content styling — applied to md() output (wrapped in [data-content]).
   Tailwind's preflight reset removes default browser styling for headings and
   lists, so we restore differentiated sizing and bullet/number markers here. */
[data-content] p,
section p {
  margin-bottom: 1rem;
}

[data-content] p:last-child,
section p:last-child {
  margin-bottom: 0;
}

/* Heading font / weight / line-height / colour are already set globally
   on h1..h6 in brand.css; only re-set what Tailwind's preflight strips
   (margins) and add per-level sizing. */
[data-content] h1,
[data-content] h2,
[data-content] h3,
[data-content] h4,
[data-content] h5,
[data-content] h6 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
[data-content] h1 { font-size: 2rem; }
[data-content] h2 { font-size: 1.5rem; }
[data-content] h3 { font-size: 1.25rem; color: var(--brand-accent); }
[data-content] h4 { font-size: 1.125rem; }
[data-content] h5 { font-size: 1rem; }
[data-content] h6 { font-size: 0.875rem; }
[data-content] > :first-child { margin-top: 0; }

[data-content] ul,
[data-content] ol {
  margin: 0.75rem 0 1rem 1.5rem;
  padding-left: 0;
}
[data-content] ul { list-style: disc outside; }
[data-content] ol { list-style: decimal outside; }
[data-content] li { margin-bottom: 0.25rem; }
[data-content] li > ul,
[data-content] li > ol { margin: 0.25rem 0 0.25rem 1.5rem; }

[data-content] blockquote {
  border-left: 3px solid var(--brand-accent);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
}

/* font-family for code/pre is already set globally; just add the inline
   chip styling that Tailwind's preflight removes. */
[data-content] code {
  background: color-mix(in srgb, var(--text-primary) 10%, transparent);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.875em;
}
[data-content] pre {
  background: color-mix(in srgb, var(--text-primary) 5%, transparent);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
}
[data-content] pre code {
  background: transparent;
  padding: 0;
}

/* Carousel scrollbar hide */
[id^="carousel-"]::-webkit-scrollbar { display: none; }

/* Mobile adjustments */
@media (max-width: 768px) {
  .section {
    padding: 3rem 1rem;
  }

  h1 { font-size: 2rem !important; }
  h2 { font-size: 1.75rem !important; }

  .btn-cta {
    font-size: 1rem;
    padding: 0.75rem 2rem;
    width: 100%;
    text-align: center;
  }

  footer .flex.items-center.gap-8 {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* Nav links flagged hideTab / hideFromMenu / hideInFooter are hidden from
   the rendered page entirely. Admins reach un-navigable pages via the
   admin user menu, so there's no need to surface them on the public site. */
.nav-link-hidden, .footer-link-hidden { display: none; }

/* Pricing grid — every tile is 1/3 of the row regardless of count. With 1
   or 2 tiles total the row is centred; with 3+ the grid left-aligns so
   columns stay vertically aligned and any trailing row sits left rather
   than centring its remainder. Mobile collapses to a single column. */
.pricing-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
}
.pricing-grid:has(> :nth-child(3)) {
  justify-content: flex-start;
}
.pricing-grid > * {
  flex: 0 0 calc((100% - 3rem) / 3);
  max-width: calc((100% - 3rem) / 3);
}
@media (max-width: 768px) {
  .pricing-grid > * {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

/* Scroll reveal base state */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Per-page opt-out: when the page has animations disabled the renderer adds
   .no-animation to <body>, which short-circuits the reveal entrance. */
.no-animation .reveal {
  opacity: 1;
  transform: none;
  transition: none;
}

@media (min-width: 768px) {
  .split-grid { grid-template-columns: var(--cols, 1fr 1fr) !important; }
}
