/* Borderbuddy · borderbuddy.eu
   Colours, type and motion follow brand/README.md. Monochrome only, no accent colour. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #111111;
  --canvas: #202020;
  --graphite: #2A2A2A;
  --slate: #5C5C5C;
  --ash: #9A9A9A;
  --mist: #E6E6E3;
  --paper: #FFFFFF;
  --paper-dim: #EDEDEA;

  --display: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* CSS stand-ins for BBMotion.spring / .snap / .bounce */
  --spring: cubic-bezier(.34, 1.36, .64, 1);
  --snap: cubic-bezier(.2, .9, .3, 1);
  --bounce: cubic-bezier(.34, 1.7, .5, 1);

  --gutter: 16px;
  --left: 100%;
  --radius: 22px;
}

/* Nested corners stay concentric: an inner radius is the outer radius minus everything between the two
   edges (padding plus border). Where the inner shape is a capsule, the outer radius follows from it. */

@media (min-width: 960px) {
  :root { --gutter: 24px; --left: clamp(400px, 40vw, 600px); --radius: 28px; }
}

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

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

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font: 17px/1.5 var(--text);
  background-color: var(--paper);
  background-image: radial-gradient(rgb(154 154 154 / .42) 1px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }

.wrap {
  position: relative;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header: a floating container over the left column ---------- */

.bar {
  /* The capsule on the right (36 px high, 40 px on desktop) sets the radius of the bar around it. */
  --inner-h: 36px;
  --pad: 8px;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: calc(var(--inner-h) + 2 * var(--pad) + 2px);
  margin-top: 12px;
  padding: var(--pad) var(--pad) var(--pad) 16px;
  background: var(--paper);
  border: 1px solid var(--mist);
  border-radius: calc(var(--inner-h) / 2 + var(--pad) + 1px);
}

.bar__logo { display: block; flex: none; border-radius: 4px; }
/* The lockup's box reserves room below the baseline for the descender of the "y" (viewBox 438.45 high,
   icon only 362.28). Moving it down by half of that centres icon and word optically in the bar. */
.bar__logo svg { height: 22px; width: auto; translate: 0 8.69%; }

@media (min-width: 960px) {
  .bar { --inner-h: 40px; --pad: 10px; position: absolute; top: 0; left: var(--gutter); width: var(--left); margin-top: var(--gutter); padding-left: 22px; }
  .bar__logo svg { height: 26px; }
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font: 600 15px/1 var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .22s var(--snap), color .22s var(--snap), transform .35s var(--spring);
}
.button:active { transform: scale(.97); }

.button--quiet { height: 36px; padding: 0 14px; font-size: 14px; background: var(--mist); color: var(--ink); }
/* Active and hover states invert, as everywhere in Borderbuddy. */
.button--quiet:hover { background: var(--ink); color: var(--paper); }

.button--primary { height: 48px; padding: 0 22px; font-size: 16px; background: var(--ink); color: var(--paper); }
.button--primary:hover { background: #000; transform: translateY(-1px); }
.button--primary:active { transform: scale(.97); }

/* Until the app is live, plain text in a quiet outlined capsule stands where the App Store buttons go.
   It is not a link and has no hover state. */
.soon {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 15px;
  border: 1px solid rgb(17 17 17 / .16);
  border-radius: 999px;
  color: var(--ink);
  font: 600 14px/1 var(--text);
  white-space: nowrap;
  cursor: default;
}
.soon--large { height: 44px; padding: 0 22px; border: 1.5px solid var(--ink); background: var(--paper); font-size: 16px; }
/* On narrow phones the header has no room next to the logo, and the hero says the same right below. */
@media (max-width: 519.98px) { .bar .soon { display: none; } }
@media (min-width: 960px) {
  .soon { height: 40px; padding: 0 17px; font-size: 15px; }
  .soon--large { height: 54px; padding: 0 28px; font-size: 17px; }
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  gap: 18px;
  padding: 22px 0 0;
}

.hero__copy { max-width: 34rem; }

h1, h2 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -.035em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.75rem);
  line-height: 1.02;
}

.hero__lead {
  margin-top: 12px;
  max-width: 32rem;
  color: var(--slate);
  font-size: clamp(.9375rem, .9rem + .3vw, 1.1875rem);
  line-height: 1.42;
  text-wrap: pretty;
}

.hero__action { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 16px; }
.hero__price { color: var(--slate); font-size: 14px; line-height: 1.45; }
/* The two halves of the price line only ever break at the dot between them. */
.hero__price span { white-space: nowrap; }

/* The stage stands for the editor. Behind the frame the photo itself glows through, blurred and dimmed,
   the way iOS lays a picture behind its own controls. It stays dark enough for the black frame to show. */
.stage {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  /* Fixed height on phones, so a format change in the demo never moves the page. */
  height: min(72vw, 520px);
  padding: 16px 16px 14px;
  overflow: hidden;
  border-radius: var(--radius);
  background-color: var(--canvas);
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}
.stage::before {
  inset: -20%;
  background: url("img/seascape.webp") center / cover;
  filter: blur(44px) brightness(.46) contrast(1.15);
  transform: scale(1.1);
  will-change: transform;
}
/* A soft vignette and the brand's dot grid on top keep it calm and tie it to the page. */
.stage::after {
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 42%, transparent 35%, rgb(17 17 17 / .6) 100%),
    radial-gradient(rgb(255 255 255 / .07) 1px, transparent 1.3px) 0 0 / 22px 22px;
}

@media (min-width: 960px) {
  .hero {
    grid-template-columns: var(--left) minmax(0, 1fr);
    gap: 48px;
    min-height: max(660px, 100svh);
    padding: var(--gutter) 0;
  }
  .hero__copy { align-self: end; padding: 140px 0 40px; }
  .hero__lead { margin-top: 22px; }
  .hero__action { gap: 14px; margin-top: 32px; }
  .hero__price { font-size: 15px; }
  .button--primary { height: 54px; padding: 0 28px; font-size: 17px; }
  .button--quiet { height: 40px; padding: 0 16px; font-size: 15px; }
  .stage { height: auto; gap: 40px; padding: 48px 24px 32px; }
}

.stage__piece {
  position: relative;
  width: min(40vw, 280px);
  /* A little depth: photo and buddy drift against the pointer at different rates. */
  translate: calc(var(--px, 0) * -8px) calc(var(--py, 0) * -8px);
  transition: translate .9s var(--spring);
}
@media (min-width: 960px) {
  .stage__piece { width: min(56%, 440px); }
  .chip { height: 32px; padding: 0 14px; font-size: 13px; }
}

/* Layer widths are in % of the frame width (cqw), the format is a ratio. Registered, so they can glide. */
@property --o { syntax: "<number>"; inherits: true; initial-value: 7.5; }
@property --i { syntax: "<number>"; inherits: true; initial-value: 1.9; }
@property --r { syntax: "<number>"; inherits: true; initial-value: .8; }

.frame {
  --o: 7.5;   /* outer layer, black */
  --i: 1.9;   /* inner layer, white */
  --r: .8;    /* format, 4:5 */
  /* Like in the app, a wider format does not crop the photo: the outer layer fills up the sides. */
  --b: calc(var(--o) + var(--i));
  --hx: max(var(--b), (100 - .8 * (100 / var(--r) - 2 * var(--b))) / 2);
  position: relative;
  aspect-ratio: var(--r);
  container-type: inline-size;
  background: var(--ink);
  transition: --o .7s var(--spring), --i .7s var(--spring), --r .8s var(--spring);
}
.frame__white, .frame__photo { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame__white { background: var(--paper); clip-path: inset(calc(var(--o) * 1cqw) calc((var(--hx) - var(--i)) * 1cqw)); }
.frame__photo { object-fit: cover; clip-path: inset(calc(var(--b) * 1cqw) calc(var(--hx) * 1cqw)); }

.buddy {
  position: absolute;
  right: -14%;
  bottom: -11%;
  width: 32%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  translate: calc(var(--px, 0) * 10px) calc(var(--py, 0) * 10px);
  transition: transform .45s var(--bounce), translate .9s var(--spring);
}
.buddy:hover { transform: translateY(-3px); }
.buddy:active { transform: scale(.94); }

.buddy .eye, [data-blink] .eye, .intro__wink {
  transform-box: fill-box;
  transform-origin: center;
}
.buddy .eye { transition: transform .3s var(--snap), opacity .2s; }
.smile {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scale(.5);
  transition: transform .45s var(--bounce), opacity .2s;
}
.buddy.is-happy .eye { opacity: 0; transform: scaleY(.2); }
.buddy.is-happy .smile { opacity: 1; transform: none; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgb(17 17 17 / .55);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .08);
  color: var(--paper-dim);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.chip__swatch { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--ash); }
.chip--white .chip__swatch { background: var(--paper); }
.chip { transition: background-color .25s var(--snap), color .25s var(--snap); }
/* The layer that is being changed shows inverted, as in the app. */
.chip.is-active { background: var(--paper-dim); color: var(--ink); }
.chip--black .chip__swatch { background: var(--ink); }

/* ---------- About ---------- */

.about {
  display: grid;
  gap: 32px;
  padding: 96px 0 0;
}

h2 {
  max-width: 18em;
  font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.5rem);
  line-height: 1.08;
}

.points li {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 6px 20px;
  align-items: start;
  padding: 22px 0;
}
.points h3, .points p { grid-column: 2; }
.points li::before, .points li:last-child::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--mist);
  transform-origin: left;
}
.points li:last-child::after { top: auto; bottom: 0; }
.points h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.points p { color: var(--slate); max-width: 38rem; text-wrap: pretty; }

@media (min-width: 960px) {
  .about { grid-template-columns: var(--left) minmax(0, 1fr); gap: 48px; padding-top: 120px; }
  .points li { grid-template-columns: 56px minmax(0, 13rem) minmax(0, 1fr); gap: 28px; padding: 28px 0; }
  .points h3 { grid-column: 2; padding-top: 2px; }
  .points p { grid-column: 3; }
}

/* Mini animations next to the three points. Static they show the finished state. */
.mini { grid-row: 1 / span 2; display: grid; place-items: center; width: 56px; height: 56px; }
.mini i { display: block; }
.mini__photo { background: linear-gradient(var(--ash) 50%, var(--slate) 50%); }

.mini--layers { position: relative; justify-self: center; width: 44px; height: 55px; background: var(--ink); }
.mini--layers .mini__white, .mini--layers .mini__photo { position: absolute; inset: 0; }
.mini--layers .mini__white { background: var(--paper); clip-path: inset(6px); }
.mini--layers .mini__photo { clip-path: inset(9px); }

.mini--format .mini__canvas { display: grid; place-items: center; width: 36px; height: 45px; background: var(--ink); }
.mini--format .mini__photo { width: 24px; height: 30px; box-shadow: 0 0 0 2px var(--paper); }

.mini--export .mini__eye, .mini--export .mini__bar, .mini--export .mini__smile { transform-box: fill-box; }
.mini--export .mini__eye { transform-origin: center; }
.mini--export .mini__bar { transform-origin: left center; }
.mini--export .mini__smile { opacity: 0; transform-origin: 50% 100%; }

/* ---------- Comparison ---------- */

.compare { display: grid; gap: 28px; padding: 96px 0 0; }
.compare__intro { margin-top: 14px; max-width: 34rem; color: var(--slate); text-wrap: pretty; }

/* A table on a white card at every width. The Borderbuddy column is the dark one, inverted like an
   active state in the app. */
.compare__table {
  --pad: 6px;
  padding: var(--pad) var(--pad) var(--pad) 16px;
  background: var(--paper);
  border: 1px solid var(--mist);
  border-radius: var(--radius);
  /* The dark column touches the card's right corners at the distance of the padding. */
  --inner-radius: calc(var(--radius) - var(--pad) - 1px);
}
.compare table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 1.42; text-align: left; }
.compare th, .compare td { vertical-align: top; }
.compare thead th { color: var(--slate); font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.compare tbody th { font-weight: 600; }
.compare td { color: var(--slate); }
.compare .compare__us { background: var(--ink); color: var(--paper-dim); }
.compare thead .compare__us { border-radius: var(--inner-radius) var(--inner-radius) 0 0; color: var(--paper); font: 800 16px/1.1 var(--display); letter-spacing: -.02em; }
.compare tbody tr:last-child .compare__us { border-radius: 0 0 var(--inner-radius) var(--inner-radius); }
.compare__us strong { color: var(--paper); font-weight: 700; }

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

/* Phones: still a table with two value columns side by side. The criterion moves into the left cell,
   above the other apps' answer, so the dark Borderbuddy column runs through without a break.
   The ARIA roles in the HTML keep the table semantics although rows become grids. */
@media (max-width: 719.98px) {
  .compare tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "k us" "o us"; }
  .compare th, .compare td { display: block; }
  .compare thead th:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .compare thead th { grid-area: o; padding: 12px 14px 12px 0; }
  .compare thead th:nth-child(2) { align-self: end; }
  .compare thead .compare__us { grid-area: us; padding: 14px 14px 12px; }
  .compare tbody th { grid-area: k; padding: 14px 14px 2px 0; border-top: 1px solid var(--mist); color: var(--ink); }
  .compare tbody td { grid-area: o; padding: 0 14px 14px 0; }
  .compare tbody .compare__us { grid-area: us; padding: 14px; border-top: 1px solid rgb(255 255 255 / .1); }
}

@media (min-width: 720px) {
  .compare__table { --pad: 8px; padding-left: 24px; }
  .compare table { font-size: 15px; line-height: 1.45; }
  .compare th, .compare td { padding: 18px 24px 18px 0; border-top: 1px solid var(--mist); }
  .compare thead th { padding-top: 16px; padding-bottom: 16px; border-top: 0; font-size: 13px; }
  .compare tbody th { width: 20%; }
  .compare td { width: 40%; }
  .compare .compare__us { padding-left: 24px; border-top-color: rgb(255 255 255 / .1); }
  .compare thead .compare__us { font-size: 18px; }
}

@media (min-width: 960px) {
  .compare { grid-template-columns: var(--left) minmax(0, 1fr); gap: 48px; padding-top: 120px; }
  .compare__intro { margin-top: 20px; font-size: 1.0625rem; }
}

/* ---------- Legal pages ---------- */

@media (min-width: 960px) {
  .bar--static { position: relative; top: auto; left: auto; }
}

.legal { max-width: 44rem; padding: 48px 0 0; }
.legal h1 { font-size: clamp(2rem, 1.2rem + 3vw, 3.25rem); line-height: 1.05; }
.legal h2 { margin-top: 36px; font: 600 18px/1.3 var(--text); letter-spacing: -.01em; }
.legal p, .legal li { margin-top: 10px; color: var(--slate); text-wrap: pretty; }
.legal ul { padding-left: 1.2em; list-style: disc; }
.legal a { color: var(--ink); text-underline-offset: 3px; }
.legal .legal__lead { margin-top: 16px; font-size: 19px; }
.legal .legal__date { margin-top: 48px; font-size: 14px; }

/* Facts page: a short definition list at the top, then plain sections. */
.facts__list { margin-top: 14px; border-top: 1px solid var(--mist); }
.facts__list > div { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--mist); }
.facts__list dt { color: var(--ink); font-weight: 600; }
.facts__list dd { margin: 0; color: var(--slate); }
@media (min-width: 960px) { .facts__list > div { grid-template-columns: 9rem minmax(0, 1fr); } }
/* The address is written backwards in the source and turned around for display, so simple scrapers miss it.
   main.js replaces it with a normal mailto link. */
.mail__rtl { unicode-bidi: bidi-override; direction: rtl; }
.mail__at::before { content: "@"; }
@media (min-width: 960px) { .legal { padding-top: 72px; } }

/* ---------- Footer ---------- */

/* The footer is the negative of the page: black ground, light type, and the buddy in white dots.
   An ASCII band leads into it, from a few marks on white to solid black. */
.footer {
  --footer-text: var(--ash);
  margin-top: 96px;
  color: var(--footer-text);
  font-size: 15px;
}
.footer__ascii { position: relative; height: 84px; }
.footer__ascii canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Without the canvas (no JavaScript) a hard edge stays, which is fine. */
.footer > .wrap { padding-top: 36px; }
.footer { background: linear-gradient(transparent 84px, var(--ink) 84px); }
.footer :focus-visible { outline-color: var(--paper); }

.footer__top { display: grid; gap: 32px; }
.footer__claim { max-width: 17em; color: var(--paper); font: 800 22px/1.15 var(--display); letter-spacing: -.025em; text-wrap: balance; }
.footer__by { margin-top: 12px; }
.footer__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 11rem)); gap: 24px; }
.footer__col h2 { max-width: none; margin-bottom: 10px; color: var(--paper); font: 600 14px/1.3 var(--text); letter-spacing: 0; }
.footer__col li + li { margin-top: 6px; }
.footer a { color: inherit; text-decoration: none; }
.footer a:hover, .footer a[aria-current] { color: var(--paper); }
.footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.footer__by a { color: var(--paper); text-decoration: underline; text-decoration-color: var(--slate); text-underline-offset: 3px; }

/* The buddy, drawn in white dots, peeks over the bottom line. main.js draws it. */
.footer__field { position: relative; height: 150px; margin-top: 40px; }
.footer__field canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.footer__base { display: flex; justify-content: space-between; gap: 16px; padding: 16px 0 28px; border-top: 1px solid var(--paper); font-size: 14px; }

@media (min-width: 960px) {
  .footer { margin-top: 120px; background: linear-gradient(transparent 128px, var(--ink) 128px); }
  .footer__ascii { height: 128px; }
  .footer > .wrap { padding-top: 56px; }
  .footer__top { grid-template-columns: var(--left) minmax(0, 1fr); gap: 48px; }
  .footer__cols { justify-self: end; gap: 48px; }
  .footer__claim { font-size: 26px; }
  .footer__field { height: 220px; margin-top: 56px; }
}

/* ---------- Background dot field ---------- */

/* With motion, main.js draws the page's dot grid on a fixed canvas instead, so dots near the pointer
   can light up and give way a little. Without JavaScript or with reduced motion the CSS grid stays. */
.mesh { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
.mesh-on body { background-image: none; }

/* ---------- Motion (only with html.motion, which reduced motion never gets) ---------- */

/* Frame build: the photo appears, then the white layer, then the black one, like in the editor. */
.motion .stage.is-building .frame__photo { animation: build-photo 1.6s both; }
.motion .stage.is-building .frame__white { animation: build-white 1.6s both; }
.motion .stage.is-building .chip { animation: chip-in .5s var(--spring) both; }
.motion .stage.is-building .chip--white { animation-delay: .5s; }
.motion .stage.is-building .chip--black { animation-delay: .95s; }
.motion .stage.is-building .chip--format { animation-delay: 1.3s; }

/* main.js arms the stage and starts the build once it is in view.
   If the script never runs, the finished frame simply shows up after 4 s. */
.motion .stage:not(.is-armed) .frame__photo,
.motion .stage:not(.is-armed) .chip { animation: wait 0s 4s both; }
.motion .stage.is-armed:not(.is-building):not(.is-built) .frame__photo,
.motion .stage.is-armed:not(.is-building):not(.is-built) .chip { opacity: 0; }

/* Scroll reveals, armed by main.js so nothing stays hidden without it. */
.motion.reveals .reveal {
  transition: opacity .7s ease, transform .9s var(--spring);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.motion.reveals .reveal:not(.is-in) { opacity: 0; transform: translateY(28px); }
.motion.reveals .points li::before, .motion.reveals .points li:last-child::after {
  transition: transform 1.1s cubic-bezier(.2, .8, .2, 1);
  transition-delay: calc(var(--i, 0) * 90ms + 120ms);
}
.motion.reveals .points li:not(.is-in)::before,
.motion.reveals .points li:not(.is-in)::after { transform: scaleX(0); }

@keyframes wait { from { opacity: 0; } to { opacity: 1; } }

/* The blurred light behind the frame drifts slowly, like clouds over the sea. */
.motion .stage::before { animation: drift 26s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: scale(1.12) translate(-4%, -3%); }
  to   { transform: scale(1.26) translate(4%, 3%); }
}

@keyframes build-photo {
  0%   { opacity: 0; transform: scale(1.03); clip-path: inset(0); animation-timing-function: ease-out; }
  22%  { opacity: 1; transform: none; clip-path: inset(0); animation-timing-function: var(--spring); }
  40%  { clip-path: inset(calc(var(--i) * 1cqw)); }
  56%  { clip-path: inset(calc(var(--i) * 1cqw)); animation-timing-function: var(--spring); }
  82%, 100% { opacity: 1; clip-path: inset(calc(var(--b) * 1cqw)); }
}
@keyframes build-white {
  0%, 56% { clip-path: inset(0); animation-timing-function: var(--spring); }
  82%, 100% { clip-path: inset(calc(var(--o) * 1cqw)); }
}
@keyframes chip-in { from { opacity: 0; transform: translateY(8px) scale(.9); } }

/* Intro: the buddy flies in, winks once and the page opens underneath. Everything is settled within 2 s. */
.intro { display: none; }
.has-intro .intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: inherit;
  background-color: var(--paper);
  animation: intro-out .35s ease 1.1s forwards;
}
.intro__buddy {
  width: clamp(104px, 20vw, 168px);
  animation: buddy-in .5s var(--bounce) .05s both, buddy-out .3s ease-in 1.05s forwards;
}
.intro__wink { animation: wink .28s ease-in-out .65s both; }
.has-intro.is-skipping .intro { animation: intro-out .25s ease forwards; }
.has-intro.is-skipping .intro__buddy { animation: buddy-out .2s ease-in forwards; }
.has-intro.is-skipping .bar, .has-intro.is-skipping .rise, .has-intro.is-skipping .stage { animation-delay: 0s; }

@keyframes buddy-in {
  from { transform: translateY(60vh) scale(.55); }
  to   { transform: none; }
}
@keyframes buddy-out { to { transform: scale(.82); opacity: 0; } }
@keyframes wink {
  0%, 100% { transform: scaleY(1); }
  35%, 62% { transform: scaleY(.1); }
}
@keyframes intro-out { to { opacity: 0; visibility: hidden; } }

/* While the intro lifts, the page settles into place. */
.has-intro .bar, .has-intro .rise, .has-intro .stage { animation: rise .6s var(--spring) both; }
.has-intro .bar { animation-delay: 1.1s; }
.has-intro .rise { animation-delay: calc(1.12s + var(--i) * 50ms); }
.has-intro .stage { animation-delay: 1.15s; }
@keyframes rise { from { transform: translateY(28px); } }

/* Mini animations loop only while their row is on screen. */
.motion .is-playing .mini--layers .mini__photo { animation: mini-layer-photo 4.4s infinite; }
.motion .is-playing .mini--layers .mini__white { animation: mini-layer-white 4.4s infinite; }
.motion .is-playing .mini--format .mini__canvas { animation: mini-format 4.8s infinite; }
.motion .is-playing .mini--export .mini__bar { animation: mini-bar 4s infinite; }
.motion .is-playing .mini--export .mini__eyes { animation: mini-glance 4s infinite; }
.motion .is-playing .mini--export .mini__eye { animation: mini-eye 4s infinite; }
.motion .is-playing .mini--export .mini__smile { animation: mini-smile 4s infinite; }

@keyframes mini-layer-photo {
  0%, 8% { clip-path: inset(0); animation-timing-function: var(--spring); }
  22%, 38% { clip-path: inset(3px); animation-timing-function: var(--spring); }
  52%, 82% { clip-path: inset(9px); animation-timing-function: ease-in-out; }
  94%, 100% { clip-path: inset(0); }
}
@keyframes mini-layer-white {
  0%, 38% { clip-path: inset(0); animation-timing-function: var(--spring); }
  52%, 82% { clip-path: inset(6px); animation-timing-function: ease-in-out; }
  94%, 100% { clip-path: inset(0); }
}
@keyframes mini-format {
  0%, 16% { width: 36px; height: 45px; animation-timing-function: var(--spring); }
  30%, 46% { width: 46px; height: 46px; animation-timing-function: var(--spring); }
  60%, 76% { width: 30px; height: 54px; animation-timing-function: var(--spring); }
  90%, 100% { width: 36px; height: 45px; }
}
@keyframes mini-bar {
  0% { transform: scaleX(0); opacity: 1; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
  58%, 88% { transform: scaleX(1); opacity: 1; }
  96%, 100% { transform: scaleX(1); opacity: 0; }
}
@keyframes mini-glance {
  0%, 6% { transform: none; }
  18% { transform: translateX(-3px); }
  32% { transform: translateX(3px); }
  46% { transform: translateX(-3px); }
  58%, 100% { transform: none; }
}
@keyframes mini-eye {
  0%, 60% { opacity: 1; transform: none; }
  66%, 86% { opacity: 0; transform: scaleY(.2); }
  92%, 100% { opacity: 1; transform: none; }
}
@keyframes mini-smile {
  0%, 61% { opacity: 0; transform: scale(.4); animation-timing-function: var(--bounce); }
  70%, 86% { opacity: 1; transform: none; }
  92%, 100% { opacity: 0; transform: none; }
}
