/* Figures and highlights for the homepage.
   Loaded on top of the page's own styles. Everything here is scoped to
   .hl (hero highlight tiles) and .figs (results figures), or uses the
   c- chart classes, so it cannot change the rest of the design.
   Charts draw when their [data-chart] parent gets .is-in (set in index.html). */

.hl, .figs {
  --paper: #ffffff;
  --ink: #121212;
  --red: #ff0000;
  --red-t: #eb0000;
  --mute: #8a8a8a;
  --mute-d: #5c5c5c;
  --rule: #121212;
  --grey: #b8b8b8;
  --wash: #f2f2f2;
  --tint: #ffecec;
  --ui: var(--grotesque);
  --data: var(--mono);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
[data-count] { font-variant-numeric: tabular-nums; }

/* Hand-drawn grease-pencil mark. Put .grease on an <svg> whose <path> has
   pathLength="1"; it draws when the nearest [data-chart] gets .is-in. */
.grease {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}
.grease path {
  fill: none;
  stroke: var(--red);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 900ms var(--ease) var(--d, 300ms);
}
.grease path { stroke-width: calc(var(--u, 1.5) * 3); }
.js [data-chart]:not(.is-in) .grease path { stroke-dashoffset: 1; }


/* Unit glyphs: the little device under each number. */
.c-glyph {
  display: flex;
  align-items: flex-end;
  height: 22px;
  margin-top: 12px;
}
.c-glyph i { display: block; }
/* nine squares = nine audited accounts */
.c-glyph--nine { gap: 3px; width: 100%; max-width: 132px; }
.c-glyph--nine i { flex: 1 1 0; max-width: 12px; aspect-ratio: 1; background: var(--ink); }
/* three segments = 425 / 400+ / 485 */
.c-glyph--three { gap: 3px; max-width: 220px; }
.c-glyph--three i {
  flex: var(--w) 1 0;
  height: 12px;
  background: var(--ink);
  transform-origin: left center;
  transition: transform 500ms var(--ease) calc(700ms + var(--i) * 160ms);
}
.c-glyph--three i:nth-child(2) { background: var(--mute-d); }
.c-glyph--three i:nth-child(3) { background: var(--grey); }
.js [data-chart]:not(.is-in) .c-glyph--three i { transform: scaleX(0); }
/* bar pair = client-made video, then mine at twice the length */
.c-glyph--pair {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  max-width: 160px;
}
.c-glyph--pair i {
  width: 50%;
  height: 8px;
  background: #990000;
  transform-origin: left center;
  transition: transform 600ms var(--ease) 700ms;
}
.c-glyph--pair i + i {
  width: 100%;
  background: var(--ink);
  transition-delay: 900ms;
}
.js [data-chart]:not(.is-in) .c-glyph--pair i { transform: scaleX(0); }
/* baseline with -11 hanging under it and +18 standing on it */
.c-glyph--lift {
  position: relative;
  align-items: stretch;
  gap: 6px;
  width: 120px;
  max-width: 100%;
  height: 31px;
  margin-top: 3px;
}
.c-glyph--lift::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 18px;
  border-top: 1px solid var(--ink);
}
.c-glyph--lift i {
  width: 34px;
  height: 11px;
  margin-top: 19px;
  background: var(--grey);
  transform-origin: center top;
  transition: transform 500ms var(--ease) 700ms;
}
.c-glyph--lift i + i {
  height: 18px;
  margin-top: 0;
  background: var(--red);
  transform-origin: center bottom;
  transition-delay: 1000ms;
}
.js [data-chart]:not(.is-in) .c-glyph--lift i { transform: scaleY(0); }


/* Chart kit. Flat, black / red / grey, mono axis text, hard edges. The
   finished state is the base CSS; ".js [data-chart]:not(.is-in)" holds the
   start state, so no-JS and reduced motion both show the final chart. */
.c-chart {
  font-family: var(--data);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.c-chart b {
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
.c-chart .k { color: var(--mute-d); }
.c-chart .red { color: var(--red-t); }
.c-chart i { display: block; font-style: normal; }
.c-chart svg { width: 100%; height: auto; overflow: visible; }
.c-chart text {
  font-family: var(--data);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: none;
  fill: var(--mute-d);
}
@media (min-width: 768px) and (max-width: 899px) {
  .c-chart text { font-size: 13.5px; }
  .c-chart text.v { font-size: 15.5px; }
}
@media (max-width: 767px) {
  .c-chart text { font-size: clamp(12px, 30px - 4.43vw, 16px); }
  .c-chart text.v { font-size: clamp(14px, 33px - 5vw, 18px); }
}
.c-chart text.v {
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  fill: var(--ink);
}
.c-chart text.red { fill: var(--red-t); }

.c-cap {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.c-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}
.c-big {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 18px;
}
.c-chart .c-big b { font-size: 30px; line-height: 1; }

/* Horizontal bar: width from --w, grows from the left. */
.c-bar {
  width: var(--w, 100%);
  height: 14px;
  background: var(--ink);
  transform-origin: left center;
  transition: transform 900ms var(--ease) calc(var(--i, 0) * 140ms);
}
.c-bar--red { background: var(--red); }
.c-bar--end { margin-left: auto; transform-origin: right center; }
.js [data-chart]:not(.is-in) .c-bar { transform: scaleX(0); }

/* Stepped wipe: children appear one at a time, left to right. --n = count. */
.c-wipe {
  clip-path: inset(0 0 0 0);
  transition: clip-path calc(var(--n) * var(--step, 60ms)) steps(var(--n)) calc(var(--i, 0) * var(--row, 140ms));
}
.js [data-chart]:not(.is-in) .c-wipe { clip-path: inset(0 100% 0 0); }

/* Benchmark: -11 hangs under the baseline, +18 stands on it. */
.c-bench__plot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 100px auto;
  column-gap: 0;
}
.c-bench__plot span { letter-spacing: 0.06em; }
.c-bench__plot .c-vbar { width: calc(100% - 10px); }
.c-bench__plot > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.c-bench__up {
  justify-content: flex-end;
  border-bottom: 2px solid var(--ink);
}
.c-bench__down { gap: 5px; }
.c-chart .c-bench__plot b { font-size: 20px; line-height: 1.3; }
.c-vbar {
  width: 100%;
  height: var(--h);
  background: var(--grey);
  transform-origin: center top;
  transition: transform 700ms var(--ease);
}
.c-vbar--red {
  background: var(--red);
  transform-origin: center bottom;
  transition-delay: 500ms;
}
.js [data-chart]:not(.is-in) .c-vbar { transform: scaleY(0); }

/* 110 judged videos, 11 per row. Colour comes from position. */
.c-dots {
  position: relative;
  width: max-content;
  max-width: 100%;
}
.c-dots__row {
  --n: 11;
  --step: 22ms;
  --row: 242ms;
  display: flex;
  gap: 6px;
  width: max-content;
}
.c-dots__row + .c-dots__row { margin-top: 6px; }
.c-dots__row i { width: 11px; height: 11px; background: var(--ink); }
.c-dots__row .r { background: var(--red); }
.c-dots__row .g { background: var(--grey); }
/* Homepage grid: 6 red, 51 black, 53 grey, coloured by position. */
.figs .c-dots__row:first-child i:nth-child(-n+6) { background: var(--red); }
.figs .c-dots__row:nth-child(6) i:nth-child(n+3),
.figs .c-dots__row:nth-child(n+7) i { background: var(--grey); }
.figs .c-dots .grease {
  left: -8px;
  top: -7px;
  width: 112px;
  height: 25px;
  max-width: none;
}
.figs .c-dots .grease path { stroke-width: 2; }
.c-legend {
  margin-top: 12px;
  list-style: none;
}
.c-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.c-legend li + li { margin-top: 3px; }
.c-legend i { flex: none; width: 9px; height: 9px; background: var(--ink); }
.c-legend .r { background: var(--red); }
.c-legend .g { background: var(--grey); }

/* Three numbers in a row. */
.c-trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.c-trio p { border-top: 3px solid var(--ink); padding-top: 8px; }
.c-chart .c-trio b {
  display: block;
  font-size: clamp(20px, 6vw, 26px);
  line-height: 1.1;
}

/* The 15-second spot. */
.c-strip {
  position: relative;
  height: 20px;
  margin-top: 44px;
  margin-bottom: 40px;
  background: var(--wash);
}
.c-strip .c-bar {
  height: 100%;
  background: var(--grey);
  transition-duration: 1500ms;
  transition-timing-function: linear;
}
.c-strip__m {
  position: absolute;
  top: -20px;
  bottom: 0;
  left: var(--x);
  border-left: 2px solid var(--ink);
  white-space: nowrap;
  transition: opacity 300ms var(--ease) var(--d);
}
.c-strip__m span {
  position: absolute;
  right: 6px;
  top: -2px;
}
.c-strip__m--red {
  top: 0;
  bottom: -20px;
  border-color: var(--red);
  color: var(--red-t);
}
.c-strip__m--red span { top: auto; bottom: -2px; }
.js [data-chart]:not(.is-in) .c-strip__m { opacity: 0; }

/* SVG line charts. */
.c-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1600ms var(--ease);
}
.js [data-chart]:not(.is-in) .c-line { stroke-dashoffset: 1; }
.c-pt { transition: opacity 300ms var(--ease) calc(var(--i, 0) * 300ms); }
.js [data-chart]:not(.is-in) .c-pt { opacity: 0; }
.c-rule { stroke: var(--ink); stroke-width: 1; }
.c-rule--grid { stroke: #dedede; }
.c-mark {
  stroke: var(--red);
  stroke-width: 2;
  stroke-dasharray: 3 4;
}

/* Head to head: black left for lower CPA, red right for higher ROAS. */
.c-h2h {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 100px minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #dedede;
}
.c-h2h:first-child {
  padding-top: 0;
  border-top: 0;
}
.c-h2h > :nth-child(3) { text-align: center; letter-spacing: 0.06em; }
@media (max-width: 480px) {
  .c-h2h { grid-template-columns: 38px minmax(0, 1fr) 76px minmax(0, 1fr) 50px; gap: 4px; }
  .c-h2h > :nth-child(3) { letter-spacing: 0.02em; }
}
.c-h2h > :first-child,
.c-h2h > :last-child { text-align: right; }

/* Hero highlights: four red tiles, each with a small figure in ink and white. */
.hl__n { position: relative; display: inline-block; }
.hl .count-up { min-width: 0; }
.hl .c-glyph { height: 31px; margin-top: 14px; padding-bottom: 13px; align-items: flex-end; }
.hl .c-glyph--pair { align-items: flex-start; justify-content: flex-end; gap: 2px; }
.hl .c-glyph--lift { padding-bottom: 0; align-items: stretch; margin-top: 14px; }
.hl .c-glyph--lift::after { border-top-width: 2px; }
.hl .c-glyph--three i:nth-child(2) { background: rgba(255, 255, 255, 0.55); }
.hl .c-glyph--three i:nth-child(3) { background: #ffffff; }
.hl .c-glyph--lift i { background: rgba(255, 255, 255, 0.55); }
.hl .c-glyph--lift i + i { background: #ffffff; }
.hl .c-glyph--pair i { background: rgba(255, 255, 255, 0.55); }
.hl .c-glyph--pair i + i { background: var(--ink); }
/* The ring around the standout number, drawn like a grease-pencil select. */
.hl .grease {
  left: -24%;
  top: -10%;
  width: 148%;
  height: 120%;
}
.hl .grease path {
  stroke: var(--ink);
  stroke-width: 3.5;
  transition-delay: 1100ms;
}

/* Results figures: one figure per result, light on words. */
.figs__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 56px;
}
.fig {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: 20px;
  border-top: 2px solid var(--ink);
}
.fig__label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red-t);
}
.fig__title {
  max-width: 24em;
  margin: 12px 0 28px;
  font-family: var(--grotesque);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.18;
}

.fig .c-bench__plot { max-width: 250px; }
@media (min-width: 768px) {
  .fig__title { min-height: 3.54em; }
  .figs__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 72px 56px;
  }
}
@media (min-width: 1100px) {
  .c-chart { font-size: 11px; }
  .c-h2h { grid-template-columns: 46px minmax(0, 1fr) 110px minmax(0, 1fr) 58px; }
  .figs__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 88px 64px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .hl *, .figs * { transition: none !important; }
}
