/* Yap Health site styles. Colours, spacing and type come from tokens.css (var(--…)). */

/* Site-level values not in the design tokens. */
:root {
  /* White text on colour fills: buttons (orange-title, 3.24:1), the current-page nav pill and
     the Funding band (brand blue, 3.03:1). Cream falls short on both, so this text is white
     and kept large (19px bold or 24px+), where 3:1 is the minimum. */
  --on-fill: #ffffff;
  --type-button-size: 19px;
  --type-button-line: 24px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line);
  font-weight: var(--type-body-weight);
  overflow-x: hidden;
}

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

h1, h2, h3, p, ul, ol { margin: 0; }

a { color: var(--blue-deep); text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--blue-deep);
  color: var(--on-deep);
  font: var(--type-label-weight) var(--type-label-size)/var(--type-label-line) var(--font-sans);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-4); }

.container {
  width: 100%;
  max-width: calc(var(--content-max) + 2 * var(--space-6));
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.section { padding: var(--space-16) 0; }

/* ---------- Type styles ---------- */
.display, h1, h2, h3 { font-family: var(--font-sans); }

.display {
  font-size: var(--type-display-size);
  line-height: var(--type-display-line);
  font-weight: var(--type-display-weight);
}
h1, .h1 {
  font-size: var(--type-h1-size);
  line-height: var(--type-h1-line);
  font-weight: var(--type-h1-weight);
}
h2, .h2 {
  font-size: var(--type-h2-size);
  line-height: var(--type-h2-line);
  font-weight: var(--type-h2-weight);
}
h3, .h3 {
  font-size: var(--type-h3-size);
  line-height: var(--type-h3-line);
  font-weight: var(--type-h3-weight);
}
.subheading {
  font-size: var(--type-subheading-size);
  line-height: var(--type-subheading-line);
  font-weight: 700;
}
/* Orange subheadings run at 24px, the smallest size the -title shades are allowed. */
.subheading-lg { font-size: 24px; line-height: 30px; }
/* The brand book sets body copy at Medium (500) from 16px up, so body-lg uses 500 too. */
.body-lg {
  font-size: var(--type-body-lg-size);
  line-height: var(--type-body-lg-line);
  font-weight: 500;
}
/* Intro text on brand blue: white needs 24px (large text) to pass contrast there. */
.lede-lg {
  font-size: 24px;
  line-height: 34px;
  font-weight: 500;
}
.small {
  font-size: var(--type-small-size);
  line-height: var(--type-small-line);
  font-weight: var(--type-small-weight);
}
.label {
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  font-weight: var(--type-label-weight);
}

.prose > * + * { margin-top: var(--space-4); }
.measure { max-width: var(--text-max); }
.center { text-align: center; }

/* Text colours. -title shades and pink are for 24px and up only. */
.c-ink { color: var(--ink); }
.c-ink-muted { color: var(--ink-muted); }
.c-blue-title { color: var(--blue-title); }
.c-orange-title { color: var(--orange-title); }
.c-green-title { color: var(--green-title); }
.c-pink { color: var(--pink); }
.c-blue-deep { color: var(--blue-deep); }
.c-pink-deep { color: var(--pink-deep); }
.c-on-blue { color: var(--on-fill); }

@media (max-width: 640px) {
  .display { font-size: 38px; line-height: 46px; }
  h1, .h1 { font-size: 34px; line-height: 42px; }
  h2, .h2 { font-size: 30px; line-height: 38px; }
  h3, .h3 { font-size: 24px; line-height: 30px; }
  .section { padding: var(--space-12) 0; }
  .container { padding: 0 var(--space-4); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 28px;
  border: 0;
  border-radius: var(--radius-pill);
  font: var(--type-label-weight) var(--type-button-size)/var(--type-button-line) var(--font-sans);
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); filter: none; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; }
.btn-primary { background: var(--orange-title); color: var(--on-fill); }
/* Brightening the fill would drop the white label below 3:1, so buttons only lift on hover. */
.btn-primary:hover { filter: none; }

/* ---------- Header and nav ---------- */
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
}
.brand { display: inline-flex; border-radius: var(--radius-block); }
.brand img { height: 28px; width: auto; }

.nav-list {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
}
.nav-list a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 40px;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  background: var(--yellow);
  color: var(--blue-deep);
  font: var(--type-label-weight) var(--type-button-size)/var(--type-button-line) var(--font-sans);
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.nav-list a:hover { transform: translateY(-1px); filter: brightness(1.04); }
.nav-list a[aria-current="page"] { background: var(--blue); color: var(--on-fill); }
.nav-list a[aria-current="page"]:hover { filter: none; }

.nav-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 8px 20px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--yellow);
  color: var(--blue-deep);
  font: var(--type-label-weight) var(--type-label-size)/var(--type-label-line) var(--font-sans);
  cursor: pointer;
}
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before,
.nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after { top: 6px; }

@media (max-width: 820px) {
  .site-header .container { padding-top: var(--space-4); padding-bottom: var(--space-4); gap: var(--space-2); }
  .nav-toggle { padding: 8px 14px; }
  .nav-list { flex-wrap: wrap; }
  .nav-list a { min-width: 0; }

  /* nav.js adds .nav-ready; without JS the pills simply wrap. */
  .nav-ready .nav-toggle { display: inline-flex; }
  .nav-ready .site-nav { flex-basis: 100%; }
  .nav-ready .nav-list { display: none; flex-direction: column; padding-top: var(--space-2); }
  .nav-ready .nav-list.is-open { display: flex; }
  .nav-ready .nav-list a { width: 100%; }
}

/* Below 360px the 28px logo and a labelled button don't fit on one row, so the label is
   kept for screen readers only. */
@media (max-width: 359px) {
  .nav-toggle { padding: 8px 12px; }
  .nav-toggle-text {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
  }
}

/* ---------- Block strip ---------- */
.blocks {
  display: grid;
  gap: var(--space-3);
  overflow: hidden;
}
/* Rows hold more blocks than the widest screen needs; min-width: 0 keeps each row at the
   container's width so the extra blocks are cropped evenly at both edges. */
.blocks-row {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  min-width: 0;
}
.block {
  flex: none;
  height: var(--block-height);
  border-radius: var(--radius-block);
}
.block-w { width: 80px; }
.block-n { width: 34px; }
.block-xl { width: 128px; }
.blocks-hero .block { height: 56px; }

.fill-blue { background: var(--blue); }
.fill-pink { background: var(--pink); }
.fill-orange { background: var(--orange); }
.fill-green { background: var(--green); }
.fill-yellow { background: var(--yellow); }

/* Padding (not margin) above the footer blocks leaves room inside the clipped strip for
   the wave animation to lift the top row without cutting it off. Same total spacing. */
.footer-blocks { margin-top: var(--space-4); padding-top: var(--space-4); }

@media (max-width: 640px) {
  .block { height: 48px; }
  .block-w { width: 56px; }
  .block-n { width: 24px; }
  .block-xl { width: 88px; }
  .blocks-hero .block { height: 40px; }
}

/* ---------- Footer ---------- */
.site-footer { padding: var(--space-12) 0 var(--space-8); }
.footer-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: var(--space-6);
  max-width: 900px;
  margin: 0 auto;
}
.footer-meta { color: var(--ink-muted); }
.footer-meta:last-child { text-align: right; }
.footer-center {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  text-align: center;
}
.footer-center img { height: 26px; width: auto; }
.footer-tag { font-weight: 700; color: var(--ink); }

@media (max-width: 900px) {
  .footer-row { grid-template-columns: 1fr; text-align: center; gap: var(--space-4); }
  .footer-meta:last-child { text-align: center; }
  .footer-center { order: -1; }
}

/* ---------- Bands ---------- */
.band { position: relative; }
.band-arc {
  display: block;
  width: 100%;
  height: 64px;
  margin-bottom: -1px;
}
.band-yellow { --band: var(--surface-band); color: var(--ink); }
.band-blue { --band: var(--blue); color: var(--on-fill); }
.band-arc path { fill: var(--band); }
.band-inner {
  background: var(--band);
  padding: var(--space-8) 0 var(--space-16);
}
.band-head { margin: 0 auto var(--space-12); text-align: center; }
.band-head > * + * { margin-top: var(--space-4); }
.band-head .body-lg, .band-head .lede-lg { max-width: var(--text-max); margin-left: auto; margin-right: auto; }

@media (max-width: 640px) {
  .band-arc { height: 32px; }
  .band-inner { padding-bottom: var(--space-12); }
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  gap: var(--space-8);
  list-style: none;
  padding: 0;
}
/* 920px is the narrowest width where no home card paragraph ends on a single word. */
.card-grid-2 { grid-template-columns: repeat(2, 1fr); max-width: 920px; margin: 0 auto; }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); max-width: 960px; margin: 0 auto; }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  border-radius: var(--radius-card);
  background: var(--surface-card);
  color: var(--ink);
  text-align: center;
}
/* Speech bubbles sit in a fixed-height box. Each shape has its own height, matching the
   draft; the SVGs scale cleanly, so these can be changed freely. */
.card-icon-box {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 64px;
  margin-bottom: var(--space-1);
}
.card-icon { width: auto; }
/* Home and Services cards: two drawings of each bubble stacked in the same spot. Hovering the card swaps
   them. Visibility (not opacity) does the swap so it doesn't clash with the scroll-in
   animation, which fades .card-icon in with opacity. */
/* Bubbles show at a little under twice their Figma size, each scaled so all four look equally big
   (the olive and orange drawings are smaller shapes, so they're scaled up a little more;
   blue and pink sit about 10% under double). Each bubble is centred top to bottom in a box
   as tall as the tallest one (blue), so bubbles side by side line up through their middles
   and every card's heading still lines up. */
.bubble-swap { position: relative; height: 108px; align-items: center; }
.bubble-swap img { width: var(--bubble-w); height: auto; }
.bubble-olive { --bubble-w: 170px; }
.bubble-orange { --bubble-w: 137px; }
.bubble-blue { --bubble-w: 110px; }
.bubble-pink { --bubble-w: 130px; }
.bubble-swap .bubble-hover {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  visibility: hidden;
}
.card:hover .bubble-swap .card-icon { visibility: hidden; }
.card:hover .bubble-swap .bubble-hover { visibility: visible; }

/* On narrower screens, browsers that support it rebalance lines to avoid a lone last word. */
.card p { text-wrap: pretty; }

.card ul {
  align-self: stretch;
  margin-top: var(--space-2);
  padding-left: 20px;
  text-align: left;
}
.card li + li { margin-top: var(--space-2); }

@media (max-width: 1024px) {
  .card-grid-4 { grid-template-columns: repeat(2, 1fr); max-width: 720px; margin: 0 auto; }
}
@media (max-width: 860px) {
  .card-grid-3 { grid-template-columns: 1fr; max-width: 480px; }
}
@media (max-width: 640px) {
  .card-grid-2, .card-grid-4 { grid-template-columns: 1fr; max-width: 480px; }
  .card-grid { gap: var(--space-6); }
}

/* ---------- Two-column split (text and blob photo) ---------- */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: var(--space-16);
}
.split > * { min-width: 0; }
.split-media { justify-self: center; width: 100%; max-width: 440px; }
.split-text > * + * { margin-top: var(--space-6); }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; gap: var(--space-12); }
  .split-media { max-width: 360px; }
  /* Photo goes under the text on phones, whichever side it sits on desktop. */
  .split-media { order: 2; }
  /* Once stacked, the text centres above the photo. */
  .split-text { text-align: center; }
  .split-text .measure { margin-left: auto; margin-right: auto; }
}

/* ---------- Blob photos ---------- */
/* Photos supplied already cut to a blob shape (transparent surround), so no clipping here. */
.photo-shaped { margin: 0; }
.photo-shaped img { width: 100%; }

/* For a rectangular photo: wrap it in <figure class="split-media blob blob-1"> (or -2, -3)
   to clip it to one of the brand's three blob outlines. */
.blob {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1 / 1.1;
  margin: 0;
  background: var(--yellow);
}
.blob img { width: 100%; height: 100%; object-fit: cover; }
.blob-1 { border-radius: 58% 42% 46% 54% / 46% 52% 48% 54%; }
.blob-2 { border-radius: 42% 58% 62% 38% / 38% 46% 54% 62%; }
.blob-3 { border-radius: 50% 50% 38% 62% / 60% 40% 60% 40%; }

/* ---------- Decorative squiggle ---------- */
.squiggle { width: 104px; height: auto; margin: var(--space-3) auto 0; }

/* ---------- Home ---------- */
.logo-hero { padding: var(--space-8) 0 var(--space-12); }
.logo-hero-mark {
  display: flex;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
}
.logo-hero-mark img { width: 644px; }

.join {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-12);
  align-items: start;
  max-width: 880px;
  margin: 0 auto;
}
.join-head { text-align: center; }
.join-head .btn { margin-top: var(--space-6); }
.join-body > * + * { margin-top: var(--space-4); }

@media (max-width: 760px) {
  .logo-hero-mark { padding: var(--space-12) var(--space-4); }
  .join { grid-template-columns: 1fr; gap: var(--space-8); }
  .join-body { text-align: center; }
}

/* ---------- About ---------- */
.about-text { text-align: center; }
.about-text .prose { margin: var(--space-6) auto 0; }

/* ---------- Services ---------- */
.steps {
  display: grid;
  gap: var(--space-8);
  max-width: 440px;
  margin: var(--space-12) auto 0;
  padding: 0;
  list-style: none;
  text-align: left;
}
.step {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: var(--space-4);
  align-items: start;
}
.step-num {
  font-size: 52px;
  line-height: 1;
  font-weight: 700;
  color: var(--orange-title);
  text-align: center;
}
.step-body { padding-top: 4px; }
.step-body p { margin-top: var(--space-1); }

.cta > * + * { margin-top: var(--space-6); }
.cta .body-lg { max-width: var(--text-max); margin-left: auto; margin-right: auto; }

/* ---------- 404 ---------- */
.notfound { padding: var(--space-24) 0; }
.notfound .card-icon-box { margin: 0 auto; height: auto; }
/* The confused bubble shows at twice its Figma size. */
.notfound .card-icon { width: 158px; }

@media (max-width: 640px) {
  .notfound { padding: var(--space-16) 0; }
}

/* ---------- Contact ---------- */
.contact-intro { text-align: center; }
.contact-title-row,
.contact-emails-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-4);
}
.contact-flower { justify-self: end; align-self: start; width: 104px; }
.contact-star { justify-self: start; width: 150px; }
.contact-flower, .contact-star { max-width: 100%; }
.contact-intro .body-lg { max-width: var(--text-max); margin: var(--space-6) auto var(--space-8); }
.contact-emails { display: grid; gap: var(--space-6); }
.contact-emails a { font-weight: 600; overflow-wrap: anywhere; }
.contact-emails .label { margin-bottom: var(--space-1); }

@media (max-width: 640px) {
  .contact-flower { width: 52px; }
  .contact-star { width: 64px; }
  .contact-title-row, .contact-emails-row { gap: var(--space-2); }
}

/* ---------- Motion ---------- */
/* Subtle, one-off movement only: nothing loops. Everything here sits inside
   prefers-reduced-motion: no-preference, so it never runs for visitors who ask for less motion. */
@media (prefers-reduced-motion: no-preference) {
  :root {
    --ease-out: cubic-bezier(0.2, 0.7, 0.3, 1);
    --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes yh-fade-up { from { opacity: 0; transform: translateY(16px); } }
  @keyframes yh-settle { from { opacity: 0; transform: scale(0.96); } }
  @keyframes yh-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes yh-spin-in { from { opacity: 0; transform: rotate(-40deg) scale(0.7); } }
  @keyframes yh-twinkle {
    0% { opacity: 0; transform: scale(0.5) rotate(-15deg); }
    60% { opacity: 1; transform: scale(1.06) rotate(4deg); }
  }

  /* Page load: each page's first section.
     Home hero, "falling blocks": each block drops from above and bounces as it lands, in a
     mixed-up order, top row first. js/motion.js gives each block on screen its turn
     (--block-i). The hero clips them so they fall from its top edge rather than over the
     menu; the rows themselves don't clip, so bottom-row blocks can fall past the logo. */
  @keyframes yh-fall {
    0% { opacity: 0; transform: translateY(-140px); }
    60% { opacity: 1; transform: translateY(0); }
    75% { transform: translateY(-12px); }
    90% { transform: translateY(0); }
    95% { transform: translateY(-3px); }
    100% { transform: translateY(0); }
  }
  .logo-hero { overflow: hidden; }
  .logo-hero .blocks-hero { overflow: visible; }
  .logo-hero .blocks-hero .block {
    animation: yh-fall 0.8s calc(100ms + var(--block-i, 0) * 80ms) cubic-bezier(0.5, 0, 0.2, 1) both;
  }
  .logo-hero-mark img { animation: yh-settle 0.8s 0.2s var(--ease-out) both; }

  /* About and Services: heading, intro and photo fade up in sequence. */
  main > section:first-child .split-text > * { animation: yh-fade-up 0.7s var(--ease-out) both; }
  main > section:first-child .split-text > :nth-child(2) { animation-delay: 0.1s; }
  main > section:first-child .split-text > :nth-child(3) { animation-delay: 0.2s; }
  main > section:first-child .split-text > :nth-child(4) { animation-delay: 0.3s; }
  main > section:first-child .split-media { animation: yh-settle 0.9s 0.15s var(--ease-out) both; }
  main > section:first-child .squiggle { animation: yh-wipe 0.9s 0.35s var(--ease-out) both; }

  /* Contact: the flower spins in, the star twinkles once. */
  .contact-title-row h1,
  .contact-intro .container > .body-lg,
  .contact-emails { animation: yh-fade-up 0.7s var(--ease-out) both; }
  .contact-intro .container > .body-lg { animation-delay: 0.1s; }
  .contact-emails { animation-delay: 0.2s; }
  .contact-flower { animation: yh-spin-in 0.9s 0.1s var(--ease-pop) both; }
  .contact-star { animation: yh-twinkle 0.9s 0.45s var(--ease-out) both; }

  /* Scroll: js/motion.js adds .reveal to content below the fold and .is-visible as it arrives. */
  .reveal {
    opacity: 0;
    transform: var(--reveal-from, translateY(16px));
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
    transition-delay: calc(var(--reveal-i, 0) * 90ms);
  }
  .reveal.is-visible { opacity: 1; transform: none; }

  .split-media.reveal { --reveal-from: scale(0.96); }
  /* Footer blocks, every page: when the strip scrolls into view, one wave ripples across
     it, left to right, top row just ahead of the bottom. Nothing is hidden first.
     js/motion.js adds .is-waving and numbers the blocks on screen (--wave-i). */
  @keyframes yh-wave { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }
  .footer-blocks.is-waving .block {
    animation: yh-wave 0.6s calc(var(--wave-i, 0) * 50ms) ease-in-out;
  }
  .footer-blocks.is-waving .blocks-row:last-child .block {
    animation-delay: calc(150ms + var(--wave-i, 0) * 50ms);
  }

  /* Squiggles draw themselves left to right. */
  .squiggle.reveal {
    opacity: 1;
    transform: none;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.9s 0.3s var(--ease-out);
  }
  .squiggle.reveal.is-visible { clip-path: inset(0 0 0 0); }

  /* Speech bubbles pop in just after their card. */
  .card.reveal .card-icon {
    opacity: 0;
    transform: scale(0.7) rotate(-8deg);
    transition: opacity 0.4s var(--ease-out), transform 0.5s var(--ease-pop);
    transition-delay: calc(var(--reveal-i, 0) * 90ms + 250ms);
  }
  .card.reveal.is-visible .card-icon { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }
  .btn:hover, .nav-list a:hover { transform: none; }
}
