/* ==================================================================
   Who For — kwizzbit/who-for (whole-file segment)
   Faithful slice of /HTML/who-for.html. Globals (reset/body/font-face/:root)
   dropped; tokens canonical (theme.json). Full-bleed via the .kwb-segment wrapper.
   ================================================================== */

.who-for {
  background: #F0E3D9; /* subtle deeper backdrop (was #FCF0E6) */
  padding-block: 120px 180px;
  padding-inline: var(--wp--custom--layout--gutter);
}

/* ── Inner layout ───────────────────────────────────────────── */
.who-for__inner {
  /* Grid is 4×260px + 3×16px gaps = 1088px.
     Inner wraps exactly that width. Section carries the side padding. */
  max-width: 1068px;
  width: 100%;
  margin-inline: auto;
}

/* ── Header row ─────────────────────────────────────────────── */
.who-for__header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--wp--preset--spacing--60);
  margin-bottom: 36px;
  width: 100%;
}

.who-for__header-text { }

/* Eyebrow */
.who-for__eyebrow {
  display: block;
  font-family: var(--wp--preset--font-family--pixel);
  font-size: var(--wp--preset--font-size--h-8-eyebrow);
  font-weight: 400;
  color: var(--wp--preset--color--coral);
  letter-spacing: 0.06em;
  line-height: 1;
  margin-bottom: 0.5rem;
}

/* Heading — uses h2-preview per COMPONENTS §5 audience-split spec */
/* ⚠ PENDING: 3.25rem (52px) is master preview size. Sketch spec is 65px.
   Confirm with Kevin before WP handoff. Using 3.25rem to match audience-split. */
.who-for__title {
  font-family: var(--wp--preset--font-family--display);
  font-size: var(--wp--preset--font-size--h-2-preview); /* 3.25rem / 52px */
  font-weight: 400;
  line-height: 3rem;
  letter-spacing: -0.10764em;
  color: var(--wp--preset--color--ink);
}

/* Title accent — coral full stop matching global pattern */
.who-for__title-accent {
  color: var(--wp--preset--color--coral);
}

/* Headline word size variation — design detail */
.who-for__title--sm {
  font-size: 2.75rem; /* slightly smaller than 3.25rem base */
}
.who-for__title--lg {
  font-size: 3.75rem; /* slightly larger than 3.25rem base */
}

/* Lead */
.who-for__lead {
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--md);
  font-weight: 500;
  color: var(--wp--preset--color--ink-soft);
  line-height: 1.412;
  max-width: 380px;
  margin-top: 1.25rem;
}

/* CTA — sits at the end of header row, right-aligned */
.who-for__header-cta { align-self: end; }

/* ── Card grid ──────────────────────────────────────────────── */
/*
  Desktop: 4-column grid (4 per row × 2 rows = 8 cards)
  Tablet:  2-column
  Mobile:  1-column scrollable carousel
*/
.who-for__grid {
  display: grid;
  grid-template-columns: repeat(4, 255px);
  column-gap: 16px;
  row-gap: 10px;
  justify-content: start;
  padding-top: 28px; /* clearance for row-1 image bleed above cards */
}

/* Columns 2 and 4 offset down 12px on desktop */
.who-for__grid .audience-card:nth-child(4n+2),
.who-for__grid .audience-card:nth-child(4n+4) {
  margin-top: 12px;
}

/* ── Audience card ──────────────────────────────────────────── */
.audience-card {
  background: #FFFAF5; /* container fill (matches features-9) */
  border-radius: 0; /* WP convention: 0 radius throughout */
  box-shadow: 0px 20px 50px rgba(255, 54, 35, 0.10); /* coral-glow */
  width: 255px;
  height: 200px;
  padding: 0 16px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: visible; /* allows image to bleed above card top */
  transition:
    transform var(--wp--custom--motion--panel-hover-duration) var(--wp--custom--motion--ease-out);
}

/* Image wrap — zero size, acts only as anchor for absolute image */
.audience-card__image-wrap {
  display: contents;
}

/* Image absolutely placed: top:-24px bleeds above card border.
   Card has position:relative + overflow:visible so this works freely.
   The grid row gap (16px) + section padding-top (100px) gives plenty
   of room above row 1; row 2 cards bleed into the row 1 gap. */
.audience-card__image {
  position: absolute;
  top: -24px;
  left: 16px;
  width: 123px;
  height: 114px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  pointer-events: none;
  transition: transform var(--wp--custom--motion--panel-hover-duration) var(--wp--custom--motion--ease-out);
}

/* Card body — pushed to footer of card, lifted 3px */
.audience-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: auto;
  padding-bottom: 14px;
  transform: translateY(-3px);
}

/* Card title — Semimono SemiBold 20px, -1.82px letter-spacing */
.audience-card__title {
  font-family: var(--wp--preset--font-family--display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.091em; /* -1.82px at 20px */
  color: var(--wp--preset--color--ink);
}

/* Card sub */
.audience-card__sub {
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--sm); /* 14px */
  font-weight: 500;
  color: #5F504B;
  line-height: 1.4;
}

/* Arrow — blood-orange SVG, bottom-right, lifted 3px */
.audience-card__arrow {
  position: absolute;
  bottom: 19px;
  right: 16px;
  transition: transform var(--wp--custom--motion--dur-base) var(--wp--custom--motion--ease-out);
  pointer-events: none;
  line-height: 0;
}

/* Hover — lift card + subtle arrow nudge */
@media (hover: hover) {
  .audience-card:hover {
    transform: translateY(-3px);
  }
  .audience-card:hover .audience-card__arrow {
    transform: translateX(3px); /* reduced from 7px token — gentler nudge */
  }
}

.audience-card:focus-visible {
  outline: 2px solid var(--wp--preset--color--coral);
  outline-offset: 3px;
}

/* ── Scroll-reveal ──────────────────────────────────────────── */
.who-for .js-reveal {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity  0.65s var(--wp--custom--motion--ease-out),
    transform 0.65s var(--wp--custom--motion--ease-out);
}
.who-for .js-reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger grid cards */
.who-for__grid .audience-card {
  opacity: 0;
  transform: translateY(32px);
  transition:
    opacity   0.55s var(--wp--custom--motion--ease-out),
    transform 0.55s var(--wp--custom--motion--ease-out);
}
.who-for__grid .audience-card.is-visible {
  opacity: 1;
  transform: translateY(0);
  /* Once revealed, hand transform back to hover via shorter duration */
  transition:
    opacity   0.55s var(--wp--custom--motion--ease-out),
    transform var(--wp--custom--motion--panel-hover-duration) var(--wp--custom--motion--ease-out);
}

/* Hover at higher specificity to win over stagger rule */
@media (hover: hover) {
  .who-for__grid .audience-card.is-visible:hover {
    transform: translateY(-3px);
  }
  .who-for__grid .audience-card.is-visible:hover .audience-card__image {
    transform: rotate(-2deg);
  }
}

/* Touch tap feedback — JS adds .is-pressed on touchstart, removes on touchend.
   More reliable than :active on iOS Safari, especially after scroll-reveal
   has cleared transitionDelay and handed transform back to hover timing. */
.who-for__grid .audience-card.is-visible.is-pressed {
  transform: translateY(-3px);
  transition-duration: 0s; /* instant lift on tap */
}
.who-for__grid .audience-card.is-visible.is-pressed .audience-card__image {
  transform: rotate(-2deg);
  transition-duration: 0s;
}

/* ── Tablet (≤1023px) ───────────────────────────────────────── */
@media (max-width: 1023px) {
  .who-for {
    padding-block: 80px 120px;
  }

  /* Header: text stacks, button drops below lead */
  .who-for__header {
    grid-template-columns: 1fr;
    align-items: start;
    gap: var(--wp--preset--spacing--50);
    margin-bottom: 48px;
  }

  .who-for__header-cta {
    align-self: start;
    /* Button sits naturally below lead — no extra override needed */
  }

  .who-for__lead {
    max-width: 480px;
  }

  /* Grid: 2 columns, cards at fixed 260px — centred in viewport */
  .who-for__grid {
    grid-template-columns: repeat(2, 255px);
    column-gap: 16px;
    row-gap: 10px; /* matches desktop row-gap */
    padding-top: 28px;
    justify-content: center; /* centres the fixed-width grid */
  }

  .audience-card {
    width: 260px;
  }

  /* Col 2 offset — matches desktop treatment */
  .who-for__grid .audience-card:nth-child(2n) {
    margin-top: 12px;
  }

  /* Override the 4n reset — tablet uses 2n pattern */
  .who-for__grid .audience-card:nth-child(4n+2),
  .who-for__grid .audience-card:nth-child(4n+4) {
    margin-top: 12px;
  }

  /* Header centred too */
  .who-for__header {
    text-align: left; /* keep text left-aligned within centred container */
    max-width: 526px; /* 2×255px + 16px gap */
    margin-inline: auto;
  }
}

/* ── Mobile (≤640px) ────────────────────────────────────────── */
@media (max-width: 640px) {
  .who-for {
    padding-block: 80px 100px;
    /* overflow-x: clip per STYLEGUIDE §11 — iOS safe */
    overflow-x: clip;
  }

  .who-for__eyebrow {
    font-size: 18px;
  }

  .who-for__title {
    /* Global mobile H2 spec — STYLEGUIDE §2 */
    font-size: clamp(1.875rem, 10.13vw, 2.375rem);
    line-height: 0.8421;
    letter-spacing: -0.10763em;
  }

  /* Proportionate word sizes — same ratio as desktop */
  .who-for__title--sm {
    font-size: clamp(1.586rem, 8.57vw, 2.01rem);  /* shapes: ×0.846 of base */
  }

  .who-for__title--lg {
    font-size: clamp(2.164rem, 11.69vw, 2.74rem); /* sizes: ×1.154 of base */
  }

  .who-for__lead {
    font-size: 1rem; /* 16px — matches hero lead */
    max-width: min(320px, 90vw);
    margin-inline: auto;
  }

  .who-for__header {
    margin-bottom: 32px;
    text-align: center;
    justify-items: center;
  }

  .who-for__grid {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 8px;
    row-gap: 0;
    padding-top: 20px;
  }

  .audience-card {
    width: auto;
    height: 120px;
    padding: 0 12px 0;
    margin-bottom: 8px; /* row gap */
  }

  .audience-card__image {
    top: -18px;
    left: 12px;
    width: 80px;
    height: 72px;
  }

  .audience-card__title {
    font-size: 0.9375rem;
    letter-spacing: -0.07em;
    white-space: normal;
    line-height: 1.15;
    padding-right: 20px; /* clears arrow zone */
  }

  /* Tighten body for compact mobile card */
  .audience-card__body {
    padding-bottom: 6px;
    gap: 0;
  }

  .audience-card__sub {
    font-size: var(--wp--preset--font-size--xs); /* 12px */
    padding-right: 20px; /* clears the arrow zone — arrow is at right:12px, width:11px */
  }

  /* Reset ALL column offsets on mobile */
  .who-for__grid .audience-card:nth-child(n) {
    margin-top: 0;
  }

  /* Col 2 offset — all even cards shifted, row-gap:0 means no compounding */
  .who-for__grid .audience-card:nth-child(2n) {
    margin-top: 12px;
  }

  .audience-card__arrow {
    bottom: 10px;
    right: 12px;
  }

  .audience-card__arrow svg {
    width: 11px;
    height: 11px;
  }
}

/* ── Keyframes ──────────────────────────────────────────────── */

/* Cursor blink — matches global pattern from STYLEGUIDE §8 */
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Shapes wiggle — gentle, looping sway. Soft enough to feel ambient. */
@keyframes shapes-wiggle {
  0%   { transform: rotate(0deg)    skewX(0deg); }
  15%  { transform: rotate(-0.6deg) skewX(-0.4deg); }
  35%  { transform: rotate(0.5deg)  skewX(0.3deg); }
  55%  { transform: rotate(-0.4deg) skewX(-0.2deg); }
  75%  { transform: rotate(0.3deg)  skewX(0.1deg); }
  100% { transform: rotate(0deg)    skewX(0deg); }
}

/* Blink */
.who-for__title-cursor {
  animation: cursor-blink 1.1s step-end infinite;
  display: inline-block; /* required for step-end to register correctly */
}

/* Wiggle */
.who-for__title--wiggle {
  display: inline-block; /* transform requires block context */
  transform-origin: center bottom;
  animation: shapes-wiggle 4.8s ease-in-out infinite;
  animation-delay: 1.2s; /* slight delay so it doesn't fire on page load */
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .who-for .js-reveal,
  .who-for__grid .audience-card {
    transition: none;
    opacity: 1;
    transform: none;
  }
  .audience-card,
  .btn {
    transition: none;
  }
  .who-for__title-cursor {
    animation: none;
    opacity: 1;
  }
  .who-for__title--wiggle {
    animation: none;
  }
}

/* ── Desktop: hide the header 'Get started' (Kev, 2026-07-18) ─────────
   On desktop (≥1024px) the fixed floating Get-started CTA (nav.css) sits
   top-right at all times, so this header CTA duplicated it. Hidden ONLY
   at ≥1024px; below that the burger replaces the float and this CTA is
   the real conversion point (it already drops below the lead in the
   max-width:1023 block), so it stays. Collapse the header grid from
   `1fr auto` to a single column so the text reclaims the CTA's track and
   its spacing-60 gutter cleanly, leaving no phantom gap on the right. */
@media (min-width: 1024px) {
  .who-for__header-cta { display: none; }
  .who-for__header { grid-template-columns: 1fr; }
}
