/* Shared design system for every client site.
   Brand-agnostic on purpose: this file only ever references the semantic
   variables in tokens.css (generated from client.json). Swapping a client's
   palette or type must never require touching this file.

   Tailwind (CDN) handles utilities; this holds components, states, depth and
   motion that utilities express poorly. */

html {
  scroll-behavior: smooth;
  /* The header is fixed at h-20 (80px), so an anchor target would otherwise land
     underneath it. This replaces the JS scroll offset that came with Lenis. */
  scroll-padding-top: 96px;
}

body {
  font-family: var(--font-body);
  color: var(--body);
  background: var(--surface);
  /* Keeps an absolutely-positioned element (open dropdown, glow) from ever
     spawning a horizontal scrollbar and oscillating the layout. */
  overflow-x: clip;
}

h1, h2, h3, .font-display {
  font-family: var(--font-display);
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* Focus visibility — every interactive element, no exceptions */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1.6rem;
  border-radius: var(--radius-btn);
  transition: transform 220ms var(--ease-spring), box-shadow 220ms var(--ease-spring),
    background-color 220ms var(--ease-spring), color 220ms var(--ease-spring),
    border-color 220ms var(--ease-spring);
  white-space: nowrap;
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 12px 24px -10px var(--accent-shadow);
}
.btn-primary:hover {
  filter: brightness(0.94);
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 16px 32px -10px var(--accent-shadow);
}
.btn-secondary {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}
.btn-secondary.on-light {
  color: var(--body);
  border-color: var(--line);
}
.btn-secondary.on-light:hover {
  border-color: var(--muted);
  background: var(--surface-2);
}
.btn-lg {
  padding: 1rem 1.9rem;
  font-size: 1rem;
}

/* -------------------------------------------------- surfaces / depth scale
   base surface -> elevated card -> floating panel. Nothing should sit on the
   same z-plane as everything else. */
.surface-elevated {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 28px -14px rgba(0, 0, 0, 0.16);
  transition: transform 260ms var(--ease-spring), box-shadow 260ms var(--ease-spring),
    border-color 260ms var(--ease-spring);
}
a.surface-elevated:hover,
.surface-elevated.is-interactive:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05), 0 24px 48px -20px rgba(0, 0, 0, 0.22);
  border-color: var(--muted);
}
.surface-floating {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-card);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 30px 60px -20px rgba(0, 0, 0, 0.55);
}

/* ------------------------------------------------------ accents & texture */
.accent-line {
  height: 2px;
  width: 48px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
  border-radius: 999px;
}
.accent-hairline {
  background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
}
.gradient-text {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.eyebrow {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.on-dark .eyebrow,
.eyebrow.on-dark {
  color: var(--accent-soft);
}
.on-dark-muted {
  color: rgba(255, 255, 255, 0.68);
}
.footer-links {
  color: rgba(255, 255, 255, 0.62);
}

/* Fine grain keeps large dark fields from looking flat */
.grain::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* Ambient glow for dark sections — one per viewport, never more */
.ambient-glow {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  opacity: 0.18;
  filter: blur(8px);
}

/* Media: images always get a tonal treatment, never raw stock */
.media-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--ink);
}
.media-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent 60%);
  pointer-events: none;
}

/* ---------------------------------------------------------------- header */
#site-header {
  --nav-fg: #fff;
  --nav-fg-muted: rgba(255, 255, 255, 0.72);
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color 300ms var(--ease-spring), border-color 300ms var(--ease-spring),
    box-shadow 300ms var(--ease-spring);
}
#site-header[data-scrolled="true"] {
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 30px -12px rgba(0, 0, 0, 0.6);
}
/* Light header variant: for clients whose hero is a light surface */
#site-header[data-theme="light"] {
  --nav-fg: var(--body);
  --nav-fg-muted: var(--muted);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
#site-header[data-theme="light"][data-scrolled="true"] {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px -18px rgba(0, 0, 0, 0.4);
}
#site-header .nav-link {
  color: var(--nav-fg-muted);
  transition: color 200ms var(--ease-spring);
}
#site-header .nav-link:hover,
#site-header .nav-group:hover .nav-link,
#site-header .nav-group:focus-within .nav-link {
  color: var(--nav-fg);
}
#site-header .menu-icon-bar {
  background: var(--nav-fg);
  transition: background-color 200ms var(--ease-spring);
}
/* Logo swaps with the header theme — one file per background, never a
   white logo sitting on a white bar. */
#site-header[data-theme="dark"] .logo-on-light,
#site-header[data-theme="light"] .logo-on-dark {
  display: none;
}

/* Dropdown: hover bridge prevents the flicker between trigger and panel */
.nav-group::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 1.25rem;
}
.nav-dropdown {
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 200ms var(--ease-spring), transform 200ms var(--ease-spring), visibility 200ms;
}
.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nav-panel {
  background: color-mix(in srgb, var(--ink-soft) 88%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 24px 50px -18px rgba(0, 0, 0, 0.7);
}
.nav-panel a {
  color: rgba(255, 255, 255, 0.82);
}
.nav-panel a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-panel .nav-panel-sub {
  color: rgba(255, 255, 255, 0.55);
}

#mobile-menu {
  transition: opacity 220ms var(--ease-spring), transform 220ms var(--ease-spring);
}
#mobile-menu[data-open="false"] {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
#mobile-menu[data-open="true"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ------------------------------------------------------------- accordion */
.accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 320ms var(--ease-spring);
}
.accordion-item[data-open="true"] .accordion-panel {
  grid-template-rows: 1fr;
}
.accordion-panel > div {
  overflow: hidden;
  min-height: 0;
}
.accordion-icon {
  transition: transform 260ms var(--ease-spring);
}
.accordion-item[data-open="true"] .accordion-icon {
  transform: rotate(45deg);
}

/* --------------------------------------------------------- scroll reveal
   Hidden state is gated behind the js marker (set in head partial): if JS
   never runs, nothing is ever invisible. The hidden rule targets
   :not(.is-visible) so its specificity can never outrank the revealed
   state (a plain `html.js .reveal` gate beats `.reveal.is-visible` and
   permanently hides everything — shipped broken for a morning, 20.08). */
.reveal {
  transition: opacity 700ms var(--ease-spring), transform 700ms var(--ease-spring);
}
html.js .reveal:not(.is-visible) {
  opacity: 0;
  transform: translateY(16px);
}

/* ----------------------------------------------------------------- forms */
.field-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--body);
}
.field-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  background: #fff;
  color: var(--body);
  transition: border-color 200ms var(--ease-spring), box-shadow 200ms var(--ease-spring);
}
.field-input:hover {
  border-color: var(--muted);
}
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field-error {
  color: #c0362c;
  font-size: 0.82rem;
  min-height: 1.1em;
}
.field-input[aria-invalid="true"] {
  border-color: #c0362c;
}
/* Honeypot: off-screen, never focusable by a human */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal, .accordion-panel, .btn, .surface-elevated, #mobile-menu, .nav-dropdown {
    animation: none !important;
    transition: none !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
  [data-parallax] {
    transform: none !important;
  }
}

/* --------------------------------------------------- motion layer (opt-in)
   [data-anim] elements start hidden so they are not painted in their final position and
   then visibly yanked back when GSAP initialises.

   Two escape hatches, because a hidden hero is far worse than a flash:
     - motion.js sets data-motion-ready on <html> as soon as it has handed the elements
       to GSAP (or revealed them itself), which switches this whole rule off.
     - the failsafe keyframe reveals everything after 2s if the JS never runs at all —
       blocked CDN, script error, JS disabled.
   Dropped entirely under prefers-reduced-motion.  */
@media (prefers-reduced-motion: no-preference) {
  html[data-motion]:not([data-motion-ready]) [data-anim],
  html[data-motion]:not([data-motion-ready]) [data-anim-stagger] > * {
    opacity: 0;
    animation: motion-failsafe 1ms linear 2s forwards;
  }
}
@keyframes motion-failsafe { to { opacity: 1; } }
