/* ==========================================================================
   Red Edge Turns 15 — styles
   Tokens from Figma file 1jSWolS2u3XWVkUAtuVGYs (see IMPLEMENTATION.md)
   ========================================================================== */

:root {
  --red: #ec1c24;
  --maroon: #7a1319;
  --brand-white: #eff4fe;
  --true-white: #ffffff;
  --ink: #000000;

  --font-display: "Poppins", sans-serif;
  --font-hand: "Schoolbell", cursive;
  --font-body: "Inter", sans-serif;
  --font-nav: "Noto Sans", sans-serif;

  --container: 1108px;
  --card-border: 4px;
  --grid-gap: 32px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
  margin: 0;
  background: var(--true-white);
  font-family: var(--font-body);
  color: var(--ink);
  overflow-x: hidden;
}

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

.container {
  width: min(var(--container), 100% - 48px);
  margin-inline: auto;
}

/* ---- Reveal animation (applied by JS) ------------------------------------ */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.reveal.in {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   1. HEADER
   ========================================================================== */
.site-header {
  position: relative;
  background: var(--maroon);
  padding: 65px 0 24px;
  margin-bottom: 57px;
}
.site-header__inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
}
.site-header__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.98;
  color: var(--true-white);
  text-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
}
.site-header__video {
  position: relative;
  flex: 0 0 auto;
  width: 236px;
  max-width: 100%;
  aspect-ratio: 788.55 / 713.42; /* match cake artwork so it scales cleanly */
  display: grid;
  place-items: center;
}
.site-header__video-el { width: 100%; height: 100%; object-fit: cover; }

/* ---- Animated cake (composited cake + candles + confetti) ---------------- */
.cake-anim {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
/* artwork fills — scoped per layer (each source SVG reused .cls-* names) */
.cake-anim__cake .ca-1 { fill: #fff; }
.cake-anim__cake .ca-3 { fill: var(--red); }
.cake-anim__cake .ca-2 {
  fill: #fff;
  stroke: var(--red);
  stroke-width: 3px;
  stroke-miterlimit: 10;
}
.cake-anim__confetti .cf-1 { fill: var(--red); }
.cake-anim__confetti .cf-2 {
  fill: #fff;
  stroke: var(--red);
  stroke-width: 3px;
  stroke-miterlimit: 10;
}
.cake-anim__candles .cd-1 {
  fill: #fff;
  stroke: var(--red);
  stroke-width: 3px;
  stroke-miterlimit: 10;
}

/* 1. Cake drops in from the top and settles */
.cake-anim__cake {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: cake-drop 0.6s var(--ease-out) 0.15s both;
}
@keyframes cake-drop {
  from { transform: translateY(-70%); opacity: 0; }
  40%  { opacity: 1; }
  80%  { transform: translateY(4%); }
  to   { transform: translateY(0); opacity: 1; }
}

/* 2. Candles grow upward from the cake top (staggered) */
.cake-anim__candle {
  transform-box: fill-box;
  transform-origin: center bottom;
  transform: scaleY(0);
  animation: candle-grow 0.45s var(--ease-out) both;
}
.cake-anim__candle:nth-child(1) { animation-delay: 0.62s; }
.cake-anim__candle:nth-child(2) { animation-delay: 0.70s; }
.cake-anim__candle:nth-child(3) { animation-delay: 0.66s; }
.cake-anim__candle:nth-child(4) { animation-delay: 0.74s; }
.cake-anim__candle:nth-child(5) { animation-delay: 0.68s; }
.cake-anim__candle:nth-child(6) { animation-delay: 0.72s; }
.cake-anim__candle:nth-child(7) { animation-delay: 0.64s; }
@keyframes candle-grow {
  from { transform: scaleY(0); }
  70%  { transform: scaleY(1.08); }
  to   { transform: scaleY(1); }
}

/* 3. Confetti / sprinkles pop onto the cake top
   (positioning lives on the outer group's transform attribute; the inner
   group carries the CSS animation so the two transforms don't collide) */
.cake-anim__confetti-pop {
  transform-box: fill-box;
  transform-origin: center center;
  animation: confetti-pop 0.5s var(--ease-out) 1.05s both;
}
@keyframes confetti-pop {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: scale(1); }
}
.site-header__badge {
  position: absolute;
  right: 70px;
  bottom: -96px;
  width: 150px;
  height: auto;
  transform: rotate(16.88deg);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25));
  z-index: 3;
}

/* ==========================================================================
   2. SECTION HEADING
   ========================================================================== */
.section-heading { margin: 16px 0 52px; }
.section-heading__text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 3.4vw, 48px);
  line-height: 1.05;
  color: var(--red);
  text-transform: uppercase;
}
.section-heading__circled {
  position: relative;
  font-weight: 400;
  white-space: nowrap;
}
.section-heading__scribble {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120%;
  height: auto;
  transform: translate(-50%, -50%) scale(1.15);
  pointer-events: none;
  color: #000;
  overflow: visible;
}
.section-heading__scribble path {
  /* path length ~770; dash it fully out, then draw in on reveal */
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
}
.reveal.in .section-heading__scribble path {
  animation: scribble-draw 0.8s var(--ease-out) 0.35s forwards;
}
@keyframes scribble-draw {
  to { stroke-dashoffset: 0; }
}

/* ==========================================================================
   3. STATS GRID
   ========================================================================== */
.stats {
  display: flex;
  flex-direction: column;
  gap: var(--grid-gap);
  margin-bottom: 52px;
}
.stat-row {
  display: flex;
  gap: var(--grid-gap);
  align-items: stretch;
}
.rail,
.region {
  display: flex;
  flex-direction: column;
  gap: var(--grid-gap);
  min-width: 0;
}
.stat-row--top .rail { flex: 348 1 0; }
.stat-row--top .region { flex: 728 1 0; }
.stat-row--mid .region { flex: 728 1 0; }
.stat-row--mid .card--founded { flex: 348 1 0; }
.stat-row--bottom .card--forks { flex: 348 1 0; }
.stat-row--bottom .card--map { flex: 728 1 0; }

.pair { display: flex; gap: var(--grid-gap); }
.pair > * { flex: 1 1 0; min-width: 0; }

/* ---- Card base ----------------------------------------------------------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 24px 16px;
  border: var(--card-border) solid var(--red);
  background: var(--true-white);
  color: var(--red);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(236, 28, 36, 0.15);
}
.stat-num {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}
.card__label {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(20px, 2.2vw, 32px);
  line-height: 1.03;
  text-transform: uppercase;
}
.card__label--sm { font-size: clamp(16px, 1.6vw, 24px); }
.card__art { width: auto; max-height: 180px; }

/* ---- Card 1: 150+ -------------------------------------------------------- */
.card--150 {
  min-height: 450px;
  justify-content: space-between;
  padding: 24px 16px;
}
.card--150 .stat-num { font-size: clamp(72px, 9vw, 119px); }
.card--150 .card__art { max-height: 180px; }

/* ---- Card 2: 400% -------------------------------------------------------- */
.card--400 {
  min-height: 412px;
  justify-content: flex-end;
  gap: 4px;
  padding-bottom: 23px;
  overflow: visible;
}
.card--400 .stat-num { font-size: clamp(64px, 8vw, 96px); letter-spacing: -0.03em; }
.card__art--400 { max-height: 150px; margin-bottom: auto; margin-top: 8px; }

/* ---- Card 3: EMAILS banner ---------------------------------------------- */
.card--banner { min-height: 132px; overflow: visible; }
.card--emails { padding: 24px 52px; }
.emails {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: nowrap;
}
/* Odometer — real carry-propagating counter (built by js/main.js) ---------- */
.odometer {
  display: inline-flex;
  align-items: stretch;
  height: var(--odo-h);
  --odo-h: clamp(40px, 5vw, 72px);
}
.odo-digit {
  width: clamp(20px, 2.7vw, 40px);
  height: var(--odo-h);
  overflow: hidden;
}
.odo-strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.odo-cell,
.odo-comma {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 4.6vw, 64px);
  line-height: var(--odo-h);
  height: var(--odo-h);
  color: var(--red);
  text-align: center;
}
.odo-comma { width: clamp(8px, 1vw, 18px); }

/* Smaller odometer (Lines of Code banner) */
.odometer--sm { --odo-h: clamp(26px, 3.6vw, 48px); }
.odometer--sm .odo-cell,
.odometer--sm .odo-comma { font-size: clamp(24px, 3.4vw, 44px); }
.odometer--sm .odo-digit { width: clamp(15px, 2.1vw, 30px); }
.odometer--sm .odo-comma { width: clamp(6px, 0.9vw, 14px); }

.emails .card__label--sm { margin-left: 16px; }

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

/* ---- Card 4: 309 --------------------------------------------------------- */
.card--309 { min-height: 450px; }
.card--309 .stat-num { font-size: clamp(72px, 9vw, 119px); }
.card--309 .card__art { max-height: 140px; }

/* ---- Card 5: 8% ---------------------------------------------------------- */
/* 8% card: wedge pinned near the top; number + label anchored to the bottom so
   they line up with "309 / WEBSITES MADE" in the neighbouring card (whose
   centred content sits its label ~72px from the card bottom). */
.card--8 {
  min-height: 450px;
  overflow: hidden;
  position: relative;
  justify-content: flex-end;
  padding-bottom: 67px;
}
.card--8 .stat-num { font-size: clamp(80px, 10vw, 128px); }
.card--8__arc {
  position: absolute;
  top: 36px;
  left: 50%;
  width: 66px;
  height: auto;
  transform: translateX(-50%) rotate(180deg);
  opacity: 0.9;
}

/* ---- Card 6: 216,531 (rocket) ------------------------------------------- */
.card--ads {
  min-height: 248px;
  flex-direction: row;
  gap: 24px;
  justify-content: center;
  padding: 14px 35px 14px 18px;
}
.card__art--rocket { width: clamp(120px, 16vw, 220px); height: auto; max-height: none; }
.card--ads__text { display: flex; flex-direction: column; align-items: center; }
.card--ads .stat-num { font-size: clamp(72px, 9vw, 128px); }
.card--ads:hover .card__art--rocket { transform: translateY(-6px) rotate(-4deg); transition: transform 0.3s var(--ease-out); }

/* ---- Card 7: LINES OF CODE banner --------------------------------------- */
.card--lines {
  min-height: 140px;
  flex-direction: row;
  gap: 16px;
  padding: 32px 44px;
}
.card--lines .card__label--sm { font-size: clamp(16px, 1.4vw, 20px); }

/* ---- Card 8: 1004 -------------------------------------------------------- */
.card--data {
  min-height: 258px;
  flex-direction: row;
  gap: 24px;
  justify-content: center;
  overflow: visible;
}
.card--data__text { display: flex; flex-direction: column; align-items: flex-start; text-align: left; }
.card--data .stat-num { font-size: clamp(96px, 14vw, 168px); }
.card--data .card__label { text-align: center; width: 100%; }
.card__art--chart { width: clamp(140px, 15vw, 210px); height: auto; max-height: none; }

/* ---- Card 9: FOUNDED 2011 ------------------------------------------------ */
.card--founded { min-height: 430px; gap: 8px; }
.card__art--mark { max-height: 204px; }
.card__label--founded { font-size: clamp(24px, 2.6vw, 36px); }
.card--founded .stat-num { font-size: clamp(72px, 9vw, 116px); }

/* ---- Card 10: 0 FORKS ---------------------------------------------------- */
.card--forks { min-height: 450px; gap: 8px; }
.stat-num--forks { font-size: clamp(120px, 16vw, 200px); }
.card__label--forks { font-size: clamp(28px, 3vw, 40px); line-height: 1.1; }
.card__art--fork { max-height: 130px; }

/* ---- Card 11: US MAP ----------------------------------------------------- */
.card--map { min-height: 450px; overflow: visible; gap: 4px; padding: 23px 40px 10px; }
.card--map__map { width: min(454px, 100%); height: auto; }
.card--map__stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.card--map__stat .stat-num { font-size: clamp(72px, 9vw, 116px); }
.card--map__stat .card__label { font-size: clamp(28px, 3.4vw, 48px); }
.annotation--territory {
  position: absolute;
  left: 4%;
  bottom: 8%;
  transform: rotate(-14.54deg);
}
.annotation--countries {
  position: absolute;
  right: 4%;
  top: 48%;
  transform: rotate(5.11deg);
}

/* ==========================================================================
   Handwritten annotations (Schoolbell + doodle arrows)
   ========================================================================== */
.annotation {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.4s var(--ease-out) 0.3s, transform 0.4s var(--ease-out) 0.3s;
}
.reveal.in .annotation { opacity: 1; transform: none; }
.annotation__note {
  font-family: var(--font-hand);
  font-size: clamp(20px, 2.4vw, 32px);
  line-height: 1;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
}
.annotation__arrow { width: 90px; height: auto; }

/* Per-annotation placement (sits in the gaps around its card) */
.annotation--real { top: -6px; right: -10px; flex-direction: column; transform: rotate(8.59deg) scale(0.8); }
.reveal.in .annotation--real { transform: rotate(8.59deg); }

.annotation--never { top: -78px; right: 24px; flex-direction: column; align-items: flex-end; gap: 2px; }
.annotation--never .annotation__note { transform: translateY(18px) rotate(8.59deg); }
.annotation--never .annotation__arrow { transform: rotate(-8deg); width: 95px; margin-right: 30px; }

.annotation--trust { top: -48px; left: 40%; }
.annotation--trust .annotation__note { transform: rotate(2.81deg); }
.annotation--trust .annotation__arrow { transform: scaleY(-1) rotate(120deg); width: 80px; }

.annotation--charts { top: -50px; left: 12%; }
.annotation--charts .annotation__note { transform: rotate(-1.8deg); }
.annotation--charts .annotation__arrow { transform: rotate(-50deg); width: 85px; }

/* ==========================================================================
   4. CTA FORM
   ========================================================================== */
.cta {
  border: var(--card-border) solid var(--maroon);
  padding: 46px 75px 40px;
  margin-bottom: 0;
}
.cta__title {
  margin: 0 0 28px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 3.4vw, 48px);
  color: var(--maroon);
  text-align: center;
}
.cta__form {
  display: flex;
  gap: 28px;
  align-items: flex-end;
}
.field {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.24px;
  color: var(--maroon);
}
.field__input {
  border: var(--card-border) solid var(--maroon);
  padding: 16px 24px;
  font-family: var(--font-body);
  font-size: 16px;
  letter-spacing: 0.32px;
  color: var(--maroon);
  background: var(--true-white);
}
.field__input::placeholder { color: var(--maroon); opacity: 0.7; }
.field__input:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.field__input.invalid { outline: 3px solid var(--red); }

.cta__button {
  flex: 1 1 0;
  min-width: 0;
  align-self: stretch;
  margin-top: auto;
  height: 57px;
  border: none;
  background: var(--maroon);
  color: var(--brand-white);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.32px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s var(--ease-out), transform 0.1s var(--ease-out);
}
.cta__button:hover { background: #5e0f14; }
.cta__button:active { transform: translateY(2px); }
.cta__button:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.cta__success {
  flex-basis: 100%;
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--maroon);
  text-align: center;
}

/* ==========================================================================
   5. FOOTER
   ========================================================================== */
.site-footer {
  position: relative;
  margin-top: 80px;
  padding-top: 60px; /* room for the overlapping card */
}
.footer-cta {
  position: absolute;
  top: -7px;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: min(802px, calc(100% - 32px));
  background: var(--true-white);
  border: var(--card-border) solid var(--red);
  padding: 24px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 2;
}
.footer-cta__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(24px, 3vw, 44px);
  line-height: 1.1;
  color: var(--red);
  text-align: center;
}
.footer-cta__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.4vw, 32px);
  color: var(--red);
}
.footer-cta__goto { font-weight: 400; }
.footer-cta__pill {
  position: relative;
  background: var(--red);
  color: var(--true-white);
  font-weight: 400;
  padding: 4px 18px;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
}
.footer-cta__pill strong { font-weight: 700; }
.footer-cta__scribble {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 122%;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: #000;
  overflow: visible;
}
.footer-cta__scribble path {
  /* path length ~770; dash it fully out, then draw in on reveal */
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
}
.reveal.in .footer-cta__scribble path {
  animation: scribble-draw 0.8s var(--ease-out) 0.35s forwards;
}

.site-footer__inner {
  background: var(--maroon);
  padding: 120px 0 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}
.site-footer__logo { width: 325px; height: auto; }
.site-footer__social-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 16px;
  align-items: center;
}
.site-footer__social a {
  display: block;
  width: 24px;
  height: 24px;
  transition: transform 0.2s var(--ease-out), opacity 0.2s var(--ease-out);
}
.site-footer__social a:hover { transform: scale(1.15); opacity: 0.85; }
.site-footer__social img { width: 24px; height: 24px; }
.site-footer__legal {
  display: flex;
  gap: 16px;
  align-items: center;
  font-family: var(--font-nav);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.32px;
  text-transform: uppercase;
  color: var(--true-white);
}
.site-footer__legal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 16px;
  align-items: center;
}
.site-footer__legal a { color: var(--true-white); text-decoration: none; }
.site-footer__legal a:hover { text-decoration: underline; }
.site-footer__copyright { margin: 0; color: var(--true-white); }

/* decorative "|" separators between the links and before the copyright */
.site-footer__legal-list li + li::before,
.site-footer__copyright::before {
  content: "|";
  margin-right: 16px;
}

/* ==========================================================================
   RESPONSIVE — collapse to single column
   ========================================================================== */
@media (max-width: 860px) {
  .site-header__inner { flex-direction: column; align-items: flex-start; gap: 24px; }
  .site-header__badge { right: 16px; bottom: -72px; width: 120px; }

  .stat-row,
  .rail,
  .region,
  .pair { flex-direction: column; }
  .stat-row > *,
  .pair > * { width: 100%; flex: 1 1 auto; }

  /* horizontal cards stack their parts */
  .card--ads,
  .card--lines,
  .card--data { flex-direction: column; text-align: center; }
  .card--data__text { align-items: center; text-align: center; }

  /* re-anchor annotations so they don't fly off narrow cards */
  .annotation--trust { left: auto; right: 8px; }
  .annotation--charts { left: 8px; }
  .annotation--never { right: 8px; }

  /* Full Scale Digital Campaigns: put the artwork above the number/label */
  .card--150 .card__art { order: -1; }

  /* 309 / 8% pair no longer needs to match each other's height once the
     pair stacks — trim the wasted vertical space */
  .card--309 { min-height: 300px; }
  .card--8 { min-height: 360px; padding-bottom: 48px; }
  .card--8__arc { top: 28px; }

  /* Social Reach Growth: drop the desktop alignment height so the art and
     number/label aren't separated by a big empty gap once stacked */
  .card--400 { min-height: 320px; padding-bottom: 32px; }
  .card__art--400 { margin-bottom: 0; }

  .emails { flex-wrap: wrap; }
  .card--emails { padding: 24px 16px; }

  .cta { padding: 32px 20px; }
  .cta__form { flex-direction: column; align-items: stretch; }
  .cta__button { align-self: stretch; }

  .footer-cta { padding: 20px 24px; }
  .site-footer__legal,
  .site-footer__legal-list { flex-direction: column; gap: 8px; }
  .site-footer__legal-list li + li::before,
  .site-footer__copyright::before { display: none; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
  .annotation { opacity: 1; transform: none; }
}
