/* The intro film (app-intro.js, app-intro-stage.js): Marcus narrating the analysis on the analysing screen. Flat, in
   the BenchMarcus logo's colours whichever theme the page is in, as "Your briefing" is (app-briefing.css, whose
   Marcus, .br-marcus, it reuses): ink #1B2B40 for the night, the tile blue #2F588C for cards, the light bars
   #9BC0E8 / #CFE0F3 for your competitors and quiet words, Marcus's yellow #FFF55B for you; where you trail, the soft
   red. Solid fills, no blur, no glow. A 16:9 picture on a wide screen and a tall one on a phone; sizes follow the
   picture (container units). Places come from the script as custom properties (stageLayout: --pad, --top, --foot,
   --hero-*, --end-*). The scenes come and go by the stage's data-beat (and the reveal's data-step). */

.if {
  --night: #1B2B40; --deep: #14223A; --tile: #2F588C; --tile-2: #284D7C; --bar: #9BC0E8; --bar-lit: #CFE0F3;
  --you: #FFF55B; --behind: #FF9C9C; --dim: #CFE0F3; --quiet: #9BC0E8;
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 22px; background: var(--night); color: #fff;
  container-type: size; font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.if :where(p, ul, ol) { margin: 0; }
.if :where(button) { font: inherit; color: inherit; cursor: pointer; }
.if :focus-visible { outline: 2px solid var(--you); outline-offset: 3px; }
.if-k { font-size: clamp(10px, 2.2cqmin, 13px); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }

.if-stage { position: absolute; inset: 0; }
/* A quiet dotted grid, the film's floor. */
.if-bg { position: absolute; inset: 0; background-image: radial-gradient(rgba(155, 192, 232, .13) 1px, transparent 1.6px); background-size: 22px 22px; }

/* ---------------------------------------------------------------- hello: the title under Marcus */
.if-title { position: absolute; z-index: 3; left: var(--pad); right: var(--pad); top: calc(var(--hero-y) + var(--hero-s) * .6); display: grid; justify-items: center; gap: 1cqmin; text-align: center;
  opacity: 0; transform: translateY(10px); transition: opacity .35s ease, transform .45s cubic-bezier(.2, 1.2, .3, 1); pointer-events: none; }
.if-title-n { font-family: 'Bricolage Grotesque', Inter, sans-serif; font-size: clamp(1.4rem, 7cqmin, 3.2rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.05; }
.if-stage[data-beat="hello"] .if-title { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- the scenes between the corner and the captions */
.if-scene { position: absolute; z-index: 2; left: var(--pad); right: var(--pad); top: var(--top); bottom: var(--foot); display: grid; place-items: center;
  opacity: 0; visibility: hidden; transform: translateY(12px); transition: opacity .35s ease, transform .45s ease, visibility 0s linear .45s; pointer-events: none; }
.if-stage:is([data-beat="read"], [data-beat="filed"]) .if-house,
.if-stage[data-beat="rivals"] .if-cast,
.if-stage[data-beat="reveal"] .if-app { opacity: 1; visibility: visible; transform: none; transition: opacity .35s ease .1s, transform .45s ease .1s; }

/* ---- read, filed: Companies House */
.if-house-in { display: grid; justify-items: center; gap: 3cqmin; max-width: 100%; }
.if-house-k { display: inline-flex; align-items: center; gap: 8px; padding: .4em .9em; border-radius: 999px; background: var(--tile-2); font-size: clamp(11px, 2.4cqmin, 14px); font-weight: 600; color: var(--dim); }
.if-house-i { width: 1.3em; height: 1.3em; fill: var(--bar-lit); }
.if-file { position: relative; display: flex; align-items: center; gap: 3cqmin; padding: 2.6cqmin 3.4cqmin; border-radius: 18px; background: var(--tile); max-width: 100%; box-sizing: border-box; }
.if-stage.is-portrait .if-file { flex-direction: column; text-align: center; }
.if-sheets { position: relative; flex: none; width: 12cqmin; height: 15cqmin; transition: width .55s cubic-bezier(.2, .9, .2, 1); }
.if-sheet { position: absolute; left: 0; top: 0; width: 12cqmin; height: 15cqmin; transform: translate(calc(var(--i) * 4px), calc(var(--i) * -4px)); transition: transform .55s cubic-bezier(.2, .9, .2, 1) calc(var(--i) * 60ms); }
.if-sheet-p { position: absolute; inset: 0; display: grid; align-content: start; gap: 9%; padding: 16% 14%; border-radius: 8%; background: #fff; box-shadow: 0 0 0 2px var(--tile); }
.if-sheet-l { display: block; height: 7%; min-height: 3px; border-radius: 3px; background: rgba(27, 43, 64, .22); }
.if-sheet-l:nth-child(2n) { width: 70%; }
.if-sheet-l.is-head { width: 55%; background: var(--tile); }
.if-sheet-y { position: absolute; left: 0; right: 0; top: calc(100% + .5em); text-align: center; font-size: clamp(10px, 2.3cqmin, 13px); font-weight: 700; color: var(--you); opacity: 0; transition: opacity .3s ease calc(var(--i) * 90ms + 300ms); }
.if-sheet.is-off { opacity: 0; }
/* The band reading the top page, while it is read. */
.if-scan { position: absolute; left: 8px; top: -8px; width: 12cqmin; height: 2.6cqmin; border-radius: 3px; background: rgba(255, 245, 91, .55); opacity: 0; }
.if-stage[data-beat="read"] .if-scan { animation: if-scan 1.5s ease-in-out infinite; }
@keyframes if-scan { 0% { opacity: 0; transform: translateY(0); } 15%, 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(13cqmin); } }
/* Filed: the accounts fanned out, year by year. */
.if-stage[data-beat="filed"] .if-sheets { width: 40cqmin; }
.if-stage[data-beat="filed"] .if-sheet { transform: translateX(calc(var(--i) * 14cqmin)); }
.if-stage[data-beat="filed"] .if-sheet-y { opacity: 1; }
/* Room for the years under the pages: under the card beside the name (landscape), above the name (portrait). */
.if-stage.is-landscape[data-beat="filed"] .if-file { padding-bottom: calc(2.6cqmin + 1.6em); }
.if-stage.is-portrait[data-beat="filed"] .if-sheets { margin-bottom: 1.7em; }
.if-file-t { display: grid; gap: 4px; min-width: 0; }
.if-file-n { font-family: 'Bricolage Grotesque', Inter, sans-serif; font-size: clamp(1rem, 4.2cqmin, 1.6rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; overflow-wrap: anywhere; }
.if-file-m { font-size: clamp(11px, 2.4cqmin, 14px); color: var(--dim); }
/* Read: a tick at the file's corner once your accounts are in. */
.if-tick { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%; background: var(--you); box-shadow: 0 0 0 3px var(--night); opacity: 0; transform: scale(.4); transition: opacity .25s ease, transform .4s cubic-bezier(.2, 1.6, .4, 1); }
.if-tick::before { content: ''; position: absolute; left: 9px; top: 7px; width: 6px; height: 11px; border: solid var(--night); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.if-stage.is-read .if-tick { opacity: 1; transform: none; }
/* What comes off the accounts: your revenue and staff where they are read, the rest by name. */
.if-facts { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 1.4cqmin; }
.if-fact { display: inline-flex; align-items: baseline; gap: .5em; padding: .45em .85em; border-radius: 999px; background: var(--tile-2); font-size: clamp(11px, 2.5cqmin, 15px);
  opacity: 0; transform: translateY(8px) scale(.9); transition: opacity .25s ease calc(var(--i) * 110ms + 350ms), transform .4s cubic-bezier(.2, 1.4, .4, 1) calc(var(--i) * 110ms + 350ms); }
.if-fact-k { color: var(--dim); font-weight: 600; }
.if-fact-v { color: var(--you); font-weight: 700; }
.if-fact-v:empty { display: none; }
.if-stage[data-beat="filed"] .if-fact { opacity: 1; transform: none; }

/* ---- rivals: you, and your competitors gathering under you */
.if-cast-in { display: grid; justify-items: center; gap: 2.6cqmin; width: 100%; }
.if-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.4cqmin 1.2cqmin; max-width: min(100%, 760px); }
.if-pill { max-width: 34cqw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .45em .95em; border-radius: 999px; background: var(--tile); color: var(--bar-lit);
  font-size: clamp(11px, 2.6cqmin, 15px); font-weight: 600;
  opacity: 0; transform: translate(var(--fx, 0px), var(--fy, 0px)) scale(.8); transition: opacity .3s ease calc(var(--i) * 85ms + 150ms), transform .55s cubic-bezier(.2, 1.15, .3, 1) calc(var(--i) * 85ms + 150ms); }
.if-pill.is-you { max-width: 80cqw; padding: .5em 1.2em; background: var(--you); color: var(--night); font-size: clamp(13px, 3.4cqmin, 19px); font-weight: 700; opacity: 1; transform: none; }
.if-pill.is-you::after { content: ' · you'; font-weight: 600; opacity: .7; }
.if-stage[data-beat="rivals"] .if-pill { opacity: 1; transform: none; }
.if-count { font-size: clamp(11px, 2.4cqmin, 14px); font-weight: 600; color: var(--quiet); opacity: 0; transition: opacity .3s ease 1s; }
.if-stage[data-beat="rivals"] .if-count { opacity: 1; }

/* ---- reveal: the app's window, its competitors' figures locked */
.if-win { display: grid; width: min(100%, 640px); max-height: 100%; overflow: hidden; border-radius: 14px; background: var(--deep); box-shadow: 0 0 0 2px var(--tile); }
.if-win-bar { display: flex; align-items: center; gap: 2cqmin; padding: 1.4cqmin 2cqmin; background: var(--tile-2); }
.if-dots { display: inline-flex; gap: 5px; flex: none; }
.if-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(207, 224, 243, .35); }
.if-tabs { display: flex; gap: 2px; min-width: 0; overflow: hidden; }
.if-tab { flex: none; padding: .3em .75em; border-radius: 999px; font-size: clamp(10px, 2.3cqmin, 13px); font-weight: 600; color: var(--quiet); transition: color .25s ease, background-color .25s ease; }
.if-stage[data-step="0"] [data-tab="dashboard"],
.if-stage:is([data-step="1"], [data-step="2"]) [data-tab="benchmark"],
.if-stage[data-step="3"] [data-tab="improve"],
.if-stage[data-step="4"] [data-tab="forecast"] { color: var(--night); background: var(--you); }
.if-rows { list-style: none; padding: 1.6cqmin 2cqmin 1cqmin; display: grid; gap: 1.1cqmin; }
.if-row { display: grid; grid-template-columns: 3.4em minmax(0, 10em) minmax(2em, 1fr) 4.6em; align-items: center; gap: 1.6cqmin; font-size: clamp(11px, 2.4cqmin, 14px);
  opacity: 0; transform: translateY(6px); transition: opacity .3s ease calc(var(--i, 0) * 70ms + 150ms), transform .4s ease calc(var(--i, 0) * 70ms + 150ms); }
.if-stage[data-beat="reveal"] .if-row { opacity: 1; transform: none; }
.if-row-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--bar-lit); }
.if-row-b { display: block; height: max(8px, 1.5cqmin); border-radius: 99px; background: rgba(155, 192, 232, .12); overflow: hidden; }
/* Their bars wait behind the unlock: a shimmer where the figure would be. Yours is drawn in your yellow. */
.if-row-b i { display: block; height: 100%; background: linear-gradient(90deg, rgba(155, 192, 232, .18), rgba(155, 192, 232, .42), rgba(155, 192, 232, .18)); background-size: 200% 100%; animation: if-shimmer 1.8s linear infinite; }
@keyframes if-shimmer { to { background-position: -200% 0; } }
.if-row.is-you .if-row-n, .if-row.is-you .if-row-v { color: var(--you); }
.if-row.is-you .if-row-b i { background: var(--you); animation: none; transform-origin: 0 50%; transform: scaleX(0); transition: transform .7s cubic-bezier(.2, .9, .2, 1) .35s; }
.if-stage[data-beat="reveal"] .if-row.is-you .if-row-b i { transform: none; }
.if-row-v { text-align: right; font-weight: 700; white-space: nowrap; }
.if-lock { display: inline-flex; align-items: center; gap: 4px; color: var(--quiet); font-weight: 700; letter-spacing: .04em; }
.if-lock-i { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; }
.if-notes { list-style: none; padding: .4cqmin 2cqmin 2cqmin; display: flex; flex-wrap: wrap; justify-content: center; gap: 1.2cqmin; }
.if-note { display: inline-flex; align-items: center; gap: .55em; padding: .45em .8em; border-radius: 10px; font-size: clamp(11px, 2.4cqmin, 14px); font-weight: 700; color: var(--night);
  opacity: 0; transform: translateY(8px) scale(.94); transition: opacity .25s ease, transform .4s cubic-bezier(.2, 1.4, .4, 1); }
.if-note .if-lock { color: rgba(27, 43, 64, .65); }
.if-note.is-lead { background: var(--you); }
.if-note.is-trail { background: var(--behind); }
.if-note.is-fix { background: var(--bar-lit); }
.if-stage[data-step="1"] .if-note[data-n="1"],
.if-stage[data-step="2"] .if-note:is([data-n="1"], [data-n="2"]),
.if-stage:is([data-step="3"], [data-step="4"]) .if-note { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- next: the end card, under Marcus */
.if-end { position: absolute; z-index: 4; left: var(--pad); right: var(--pad); top: calc(var(--end-y) + var(--end-s) * .62); display: grid; justify-items: center; gap: 1.8cqmin; text-align: center;
  opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity .4s ease, transform .5s cubic-bezier(.2, .9, .2, 1), visibility 0s linear .5s; }
.if-stage[data-beat="next"] .if-end { opacity: 1; visibility: visible; transform: none; transition: opacity .4s ease .15s, transform .5s cubic-bezier(.2, .9, .2, 1) .15s; }
.if-end-t { font-family: 'Bricolage Grotesque', Inter, sans-serif; font-size: clamp(1.5rem, 7cqmin, 3rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.05; }
.if-stage.is-ready .if-end-t { color: var(--you); }
.if-end-bar { display: block; width: min(260px, 60cqw); height: 6px; border-radius: 3px; background: var(--tile-2); overflow: hidden; }
.if-end-bar i { display: block; height: 100%; width: 100%; border-radius: 3px; background: var(--bar-lit); transform-origin: 0 50%; transform: scaleX(var(--p, .05)); transition: transform .6s ease; }
.if-stage:is(.is-ready, .is-failed) .if-end-bar { display: none; }
.if-end-b { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 14px; }
.if-go { min-height: 48px; padding: 12px 26px; border: 0; border-radius: 999px; font-size: 1rem; font-weight: 700; color: var(--night); background: var(--you); }
.if-go:hover:not(:disabled) { filter: brightness(1.06); }
.if-go:disabled { cursor: default; color: var(--dim); background: var(--tile); }
.if-again { min-height: 44px; padding: 8px 12px; border: 0; background: none; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.if-end-s { font-size: clamp(12px, 2.5cqmin, 14px); color: var(--quiet); }
.if-end-s:empty, .if-stage.is-failed .if-go { display: none; }
/* The end card's way on is only a way on at the end. */
.if-stage:not([data-beat="next"]) .if-end button { pointer-events: none; }

/* ---------------------------------------------------------------- Marcus (app-briefing.css .br-marcus) */
.if .br-marcus { z-index: 5; }

/* ---------------------------------------------------------------- captions and the sound button */
.if-cc { position: absolute; z-index: 6; left: 50%; bottom: max(10px, calc(var(--pad) * .8)); transform: translateX(-50%); width: max-content; max-width: calc(100% - var(--pad) * 2);
  box-sizing: border-box; padding: 8px 14px; border-radius: 12px; background: var(--deep); opacity: 0; transition: opacity .25s ease; pointer-events: none; }
.if-cc.is-on { opacity: 1; }
.if-cc-t { font-size: clamp(14px, 3.3cqmin, 21px); font-weight: 500; line-height: 1.4; text-align: center; color: rgba(155, 192, 232, .8); }
.if-w { transition: color .12s linear; }
.if-w.is-said { color: #fff; }
.if-sound { position: absolute; z-index: 7; top: var(--pad); right: var(--pad); display: inline-flex; align-items: center; gap: 6px; height: 40px; min-width: 40px; justify-content: center; padding: 0 9px;
  border: 0; border-radius: 999px; background: var(--tile); color: #fff; font-size: .85rem; font-weight: 700; }
.if-sound:hover { background: var(--tile-2); }
.if-sound[hidden] { display: none; }
.if-ic { width: 22px; height: 22px; }
.if-sound-l:empty { display: none; }
/* The browser kept the film quiet (no tap before it): a clear, yellow "Tap for sound". */
.if-sound.is-locked { padding: 0 14px 0 10px; color: var(--night); background: var(--you); animation: if-nudge 2.4s ease-in-out infinite; }
@keyframes if-nudge { 0%, 70%, 100% { transform: none; } 80% { transform: scale(1.06); } 90% { transform: scale(.98); } }

/* ---------------------------------------------------------------- a phone: a taller picture */
@media (max-width: 640px) {
  /* Tall, but leaving the heading above and the progress and its button below in view on most phones. */
  .if { aspect-ratio: auto; height: clamp(380px, calc(100svh - 320px), 540px); border-radius: 18px; }
  .if-row { grid-template-columns: 2.8em minmax(0, 1fr) minmax(1.5em, .7fr) 4.2em; }
}

/* A phone on its side: the whole picture on the screen once scrolled to, as wide as that height allows. */
@media (pointer: coarse) and (max-height: 500px) and (min-width: 641px) {
  .if { aspect-ratio: auto; width: min(100%, calc((100svh - 24px) * 16 / 9)); height: calc(100svh - 24px); margin: 0 auto; }
}

/* ---------------------------------------------------------------- still: the scenes change without moving */
.if.is-reduced *, html.pf-reduce-motion .if * { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { .if * { transition: none !important; animation: none !important; } }
