/*
 * Alf Theme — Main Stylesheet
 *
 * Split into 4 concern layers — never mix them:
 *
 *  1. Reset & Base   — *, html, body, img, a, ul, button
 *  2. Typography     — h1–h4, paragraph utilities
 *  3. Buttons        — .btn variants
 *  4. Layout         — .container, .section, grid/flex utilities
 *
 * Adding a new component → create a dedicated file in assets/css/ and enqueue
 * it conditionally in inc/enqueue.php. Do NOT append components here.
 */


/* ── Skip link (accessibility) ───────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.skip-link:focus {
  top: 8px;
  left: 8px;
  width: auto;
  height: auto;
  clip: auto;
  overflow: visible;
  white-space: normal;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  z-index: 99999;
  text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════
   1. RESET & BASE
   ═══════════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Reserve scrollbar space to prevent viewport-width shift on navigation */
  scrollbar-gutter: stable;
  overflow-x: hidden;
  /* prevent horizontal overflow from fixed-positioned drawers */
}

body {
  overflow-x: hidden;
  font-family: var(--font-body);
  font-size: var(--font-size-body-md);
  font-weight: var(--font-weight-regular);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

input,
textarea,
select {
  font: inherit;
}


/* ═══════════════════════════════════════════════════════════════════
   2. TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════

   Heading hierarchy (one h1 per page — hero only):

   h1  48px Bold    --color-dark   — Hero page title (ONLY ONE PER PAGE)
   h2  36px Semi    --color-black  — Section titles
   h3  24px Semi    --color-dark   — Sub-section heads, stat numbers
   h4  20px Bold    --color-secondary — Card titles, feature names

   ═══════════════════════════════════════════════════════════════════ */

h1 {
  font-family: var(--font-body);
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  color: var(--color-dark);
}

h2 {
  font-family: var(--font-body);
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-semibold);
  line-height: 1.25;
  color: var(--color-black);
}

h3 {
  font-family: var(--font-body);
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
  color: var(--color-dark);
}

h4 {
  font-family: var(--font-body);
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-bold);
  line-height: 1.4;
  color: var(--color-secondary);
}

p {
  font-family: var(--font-body);
  font-size: var(--font-size-body-md);
  font-weight: var(--font-weight-regular);
  line-height: 1.6;
  color: var(--color-text);
}

/* Mobile heading overrides */
@media (max-width: 767px) {
  h1 {
    font-size: var(--font-size-h1-mobile);
  }

  h2 {
    font-size: var(--font-size-h2-mobile);
  }

  h3 {
    font-size: var(--font-size-h3-mobile);
  }
}

/* Typography utilities */
.text-body-lg {
  font-size: var(--font-size-body-lg);
}

.text-sm {
  font-size: var(--font-size-sm);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-white {
  color: var(--color-white);
}

.text-primary {
  color: var(--color-primary);
}

.text-secondary {
  color: var(--color-secondary);
}

.text-dark {
  color: var(--color-dark);
}

.text-center {
  text-align: center;
}

/* Section label / badge pill */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 8px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-body-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-secondary);
}


/* ═══════════════════════════════════════════════════════════════════
   3. BUTTONS
   ═══════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  height: var(--btn-height);
  padding: var(--btn-padding-y) var(--btn-padding-x);
  border-radius: var(--btn-radius);
  font-size: var(--btn-font-size);
  font-weight: var(--btn-font-weight);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

/* Primary */
.btn--primary {
  background-color: var(--color-primary);
  color: var(--color-white);
  border: 2px solid transparent;
}

.btn--primary:hover {
  opacity: 0.88;
}

/* Secondary */
.btn--secondary {
  background-color: var(--color-secondary);
  color: var(--color-white);
  border: 2px solid transparent;
}

.btn--secondary:hover {
  opacity: 0.88;
}

/* Accent */
.btn--accent {
  background-color: var(--color-accent);
  color: var(--color-dark);
  border: 2px solid transparent;
}

.btn--accent:hover {
  opacity: 0.88;
}

/* Outline */
.btn--outline {
  background-color: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn--outline:hover {
  background-color: var(--color-primary);
  color: var(--color-white);
}

/* Ghost (white border, for use on dark backgrounds) */
.btn--ghost {
  background-color: transparent;
  color: var(--color-white);
  border: 2px solid var(--color-white);
}

.btn--ghost:hover {
  background-color: var(--color-white);
  color: var(--color-dark);
}


/* ═══════════════════════════════════════════════════════════════════
   4. LAYOUT
   ═══════════════════════════════════════════════════════════════════

   Container system — uses CSS min() so padding never squeezes content:

     width = min(content-max-width, 100% − 2 × gutter)

   Crossover viewport (where padding starts governing width):
     --content-max-width + 2 × --section-pad-x = 1200px + 240px = 1440px

   vw ≥ 1440px → width = 1200px, outer space = auto margin (no squeeze)
   vw < 1440px → width = vw − 2×gutter  (gutters always maintained)

   Usage:
     <section class="alf-section">
       <div class="alf-container">
         ... content max 1200px wide, never squished by padding ...
       </div>
     </section>
   ═══════════════════════════════════════════════════════════════════ */

/* ── Inner content container ────────────────────────────────────── */
.alf-container,
.container {
  /* Local gutter token — override per-breakpoint without touching globals */
  --_pad: var(--section-pad-x);
  /* 120px desktop */
  width: min(var(--content-max-width), 100% - 2 * var(--_pad));
  margin-inline: auto;
}

/* Gutters step down as the viewport shrinks */
@media (max-width: 1280px) {

  .alf-container,
  .container {
    --_pad: 80px;
  }

  /* tablet landscape */
}

@media (max-width: 900px) {

  .alf-container,
  .container {
    --_pad: 60px;
  }

  /* tablet portrait  */
}

@media (max-width: 600px) {

  .alf-container,
  .container {
    --_pad: 32px;
  }

  /* mobile           */
}

@media (max-width: 375px) {

  .alf-container,
  .container {
    --_pad: 16px;
  }

  /* small mobile     */
}

/* Wide variant — full Figma canvas width (1440px), e.g. hero, footer */
.alf-container--wide {
  --_pad: var(--section-pad-x);
  width: min(var(--section-max-width), 100% - 2 * var(--_pad));
  margin-inline: auto;
}

@media (max-width: 1280px) {
  .alf-container--wide {
    --_pad: 80px;
  }
}

@media (max-width: 900px) {
  .alf-container--wide {
    --_pad: 60px;
  }
}

@media (max-width: 600px) {
  .alf-container--wide {
    --_pad: 32px;
  }
}

@media (max-width: 375px) {
  .alf-container--wide {
    --_pad: 16px;
  }
}

/* Narrow variant — section headers (Figma: 896px) */
.alf-container--narrow {
  max-width: var(--header-max-width);
  /* 896px */
}

/* ── Section — vertical rhythm ───────────────────────────────────── */
/* Sections are always 100% wide; only .alf-container is constrained */
.alf-section,
.section {
  padding-block: var(--spacing-between-sections);
  /* 160px */
}

@media (max-width: 900px) {

  .alf-section,
  .section {
    padding-block: var(--spacing-between-sections-mobile);
    /* 120px */
  }
}

@media (max-width: 600px) {

  .alf-section,
  .section {
    padding-block: 80px;
  }
}

@media (max-width: 375px) {

  .alf-section,
  .section {
    padding-block: 60px;
  }
}

/* ── Grid utilities ──────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: var(--spacing-lg);
}

.grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid--3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {

  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
  }
}

/* ── Flex utilities ──────────────────────────────────────────────── */
.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-md {
  gap: var(--spacing-md);
}

.gap-lg {
  gap: var(--spacing-lg);
}

/* ── Visibility ──────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   5. SCROLL REVEAL  (driven by animations.js + IntersectionObserver)
   ═══════════════════════════════════════════════════════════════════

   Add  data-animate="reveal"            → simple fade + slide up
        data-animate="reveal-stagger"    → children animate one by one
        data-animate="reveal-left"       → fade + slide from left (bullet dots)
        data-animate-delay="200"         → extra delay in ms

   CSS handles the animation; JS adds .alf-visible when element enters view.
   ═══════════════════════════════════════════════════════════════════ */

/* Base hidden state — apply only when JS is loaded so no-JS users see content */
.js [data-animate="reveal"],
.js [data-animate="reveal-left"] {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

.js [data-animate="reveal-left"] {
  transform: translateX(-32px);
}

/* Children of stagger containers */
.js [data-animate="reveal-stagger"]>* {
  opacity: 0;
  transform: translateY(32px);
  transition:
    opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Visible state — added by JS */
.js [data-animate].alf-visible,
.js [data-animate="reveal-stagger"]>*.alf-visible {
  opacity: 1;
  transform: none;
}

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {

  .js [data-animate],
  .js [data-animate="reveal-stagger"]>* {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   6. BUTTON HOVER — wave text scroll + arrow slide
   ═══════════════════════════════════════════════════════════════════

   DOM injected by buildBtnHover() in animations.js:

     <a class="btn"> (or .alf-btn)
       <span class="alf-btn-text-clip">          ← overflow:hidden, 1 line tall
         <span class="alf-btn-texts">            ← position:relative, full height
           <span>                                ← original: top:0  (visible)
             <span class="alf-char" style="transition-delay:Xms">C</span>
             … one span per character, right-to-left delay stagger …
           </span>
           <span aria-hidden="true">             ← clone: top:100% (hidden below)
             <span class="alf-char" …>C</span> …
           </span>
         </span>
       </span>
       <span class="alf-arrow-clip" aria-hidden="true">  ← inline-grid, overflow:hidden
         <span class="alf-arrows">               ← display:contents (no box)
           <span class="alf-arrow">→</span>      ← clone:    grid-area:1/1, translateX(-100%) hidden left
           <span class="alf-arrow">→</span>      ← original: grid-area:1/1, translateX(0)     visible
         </span>
       </span>
     </a>

   On hover: all .alf-char get translateY(-100%) with staggered delay →
   right edge animates first (wave). Arrow copies slide simultaneously:
   clone enters from left, original exits right.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Text clip ───────────────────────────────────────────────────── */

/* Clip auto-sizes to text width via grid; overflow hides out-of-view copy */
.alf-btn-text-clip {
  display: inline-grid;
  overflow: hidden;
  vertical-align: top;
}

/* When inside a flex-row button, text clip grows to push arrow to the right edge */
.btn .alf-btn-text-clip,
.alf-btn .alf-btn-text-clip {
  flex: 1 0 0;
}

/* No layout box — children become direct grid items of the clip */
.alf-btn-texts {
  display: contents;
}

/* Both text copies in the same 1×1 grid cell — sized to text content width */
.alf-btn-texts>span {
  grid-area: 1 / 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
}

.alf-btn-texts>span:first-child {
  transform: translateY(0);
}

/* original — visible    */
.alf-btn-texts>span:last-child {
  transform: translateY(100%);
}

/* clone    — below clip */

/* Each character transitions independently; delay is set inline by JS */
.alf-char {
  display: inline-block;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* On hover: chars move up one line height — clip hides what exits */
.btn:hover .alf-char,
.btn:focus-visible .alf-char,
.alf-btn:hover .alf-char,
.alf-btn:focus-visible .alf-char {
  transform: translateY(-100%);
}

/* ── Arrow clip ──────────────────────────────────────────────────── */

/* CSS-grid: both arrow copies share the same 1×1 cell, sized to one arrow.
   overflow:hidden clips whichever copy is currently translateX'd away.   */
.alf-arrow-clip {
  display: inline-grid;
  overflow: hidden;
  vertical-align: middle;
  flex-shrink: 0;
}

/* No layout box for .alf-arrows — children go straight into the grid */
.alf-arrows {
  display: contents;
}

.alf-arrow {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.alf-arrow:first-child {
  transform: translateX(-100%);
}

/* clone    — hidden left */
.alf-arrow:last-child {
  transform: translateX(0);
}

/* original — visible    */

/* On hover: clone enters from left, original exits right */
.btn:hover .alf-arrow:first-child,
.btn:focus-visible .alf-arrow:first-child,
.alf-btn:hover .alf-arrow:first-child,
.alf-btn:focus-visible .alf-arrow:first-child {
  transform: translateX(0);
}

.btn:hover .alf-arrow:last-child,
.btn:focus-visible .alf-arrow:last-child,
.alf-btn:hover .alf-arrow:last-child,
.alf-btn:focus-visible .alf-arrow:last-child {
  transform: translateX(100%);
}

/* Figma button variants */
/* btn--beige: bg #F8FAF0, text #252525, radius 8px — Figma 557:155 */
.btn--beige {
  background-color: var(--color-bg);
  color: var(--color-dark);
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-regular);
  padding: 14px 16px;
  height: auto;
  max-width: 343px;
}

.btn--beige:hover {
  opacity: 0.88;
}