/* Home's opening film, then Home's own words rising over its last frame.
   The head script sets .film-on whenever scripts run; where the video shouldn't play (reduced motion,
   Save-Data, 2G, small phones, back from another page) it opens on the last frame (.film-still).
   Without scripts, Home's own hero shows that same last frame (letter.css).
   Loaded last on Home; every rule waits for .film-on. */
.film { display: none; }

/* As tall as the screen gets once a phone's toolbars slide away, so they can leave during the film
   without showing a strip of page under it. --film-bars is how much of it they cover at first.
   The paper and wine of DESIGN.md as channels, for the see-through tints below; and its own curve. */
html.film-on { --film-h: 100vh; --film-bars: 0px; --film-paper: 250 247 245; --film-wine: 121 36 42; --film-ease: cubic-bezier(.16, 1, .3, 1); }
@supports (height: 100lvh) { html.film-on { --film-h: 100lvh; --film-bars: calc(100lvh - 100svh); } }

/* One screen of film, then a short way for Home's words to rise over it: they arrive after about a third
   of a screen. On the way the film's brand fades and lifts away first, then the words come up (film.js
   sets the --film-* amounts from the scroll). Without film.js the words follow .film-leaving (app.js). */
html.film-on .film { display: block; position: relative; z-index: 0; height: calc(var(--film-h) * 1.45); }
html.film-on .home-hero-words { opacity: var(--film-words, 0); transition: opacity .15s linear; }
html.film-on.film-leaving .home-hero-words { opacity: var(--film-words, 1); }
/* Until then the page lies over the film unseen, so the treatment areas under it take the clicks and taps. */
html.film-on:not(.film-leaving) main { pointer-events: none; }
/* The first frame stands where the video will: the same crop, so nothing moves when it starts. */
.film-stage {
  position: sticky; top: 0; height: var(--film-h); overflow: hidden;
  background: var(--surface) url(/assets/film-first-frame.webp) 68% 42% / cover no-repeat;
}
.film-video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: 68% 42%; transition: opacity .6s ease, visibility 0s linear .6s; }
/* The last frame: once the film has played (film.js: phones may drop a finished video's picture when it is
   scrolled away, which would bare the first frame's skin), for a window that changes shape after it, and from
   the first paint when a visitor comes back to Home later in the visit (.film-still, the head script), the same
   face. The still is a touch crisper than the video, so the video fades off it rather than snapping. */
.film-stage.is-still, html.film-still .film-stage { background-image: url(/assets/film-end.webp); }
.film-stage.is-still .film-video, html.film-still .film-video { opacity: 0; visibility: hidden; }

/* The letterhead floats over the film and becomes paper again when the letter reaches it. */
html.film-on .header {
  position: fixed; inset: 0 0 auto;
  transition: background-color var(--motion-ui) ease, box-shadow var(--motion-ui) ease;
}
html.film-on:not(.film-past) .header:not(.menu-open) { background: transparent; box-shadow: none; }

/* Keeps the navigation readable over hair and highlights. Eases out just past the header,
   so it never draws a line across the hair. */
.film-stage::before {
  content: ""; position: absolute; inset: 0 0 auto; z-index: 1;
  height: calc(var(--header-offset, 100px) * 1.3);
  background: linear-gradient(180deg, rgb(var(--film-paper) / .9), rgb(var(--film-paper) / .87) 42%, rgb(var(--film-paper) / .6) 62%, rgb(var(--film-paper) / .28) 78%, rgb(var(--film-paper) / .08) 91%, rgb(var(--film-paper) / 0));
}
/* A phone on its side: the eyes sit under the header, so the veil stays behind the logo. */
@media (max-height: 500px) {
  .film-stage::before {
    -webkit-mask-image: linear-gradient(90deg, #000 38%, transparent 58%);
    mask-image: linear-gradient(90deg, #000 38%, transparent 58%);
  }
}

/* When the pull-back lands, the brand takes over: the logo, large, with the tagline under it at the same width.
   A soft glow keeps the logo's gold clear of the water's highlights. Scrolling on, the whole lockup fades
   and lifts away. */
.film-lockup {
  --w: clamp(340px, 30vw, 580px);
  position: absolute; z-index: 2; left: var(--margin); top: calc(50% - var(--film-bars) / 2); width: var(--w);
  opacity: var(--film-brand, 1); transform: translateY(calc(-50% + var(--film-lift, 0px)));
  transition: opacity .15s linear, transform .15s linear;
}
.film-lockup::before {
  content: ""; position: absolute; z-index: -1; inset: -34% -18%; opacity: 0; transition: opacity .6s ease-out; pointer-events: none;
  background: radial-gradient(closest-side, rgb(var(--film-paper) / .92), rgb(var(--film-paper) / .78) 58%, rgb(var(--film-paper) / 0));
}
.film-mark { display: block; width: 100%; height: auto; opacity: 0; transform: translateY(20px); transition: opacity .5s ease-out, transform .9s var(--film-ease); }
.film-line {
  margin: .36em 0 0; white-space: nowrap;
  font-family: var(--font-display); font-size: calc(var(--w) * .12); line-height: 1.02; letter-spacing: -.01em;
  color: var(--wine); opacity: 0; transform: translateY(20px);
  transition: opacity .5s ease-out .14s, transform .9s var(--film-ease) .14s;
}
.film-cue { transition: opacity .4s ease-out; }
html.film-line-in .film-lockup::before, html.film-line-in .film-mark, html.film-line-in .film-line { opacity: 1; transform: none; }
/* Once in, the tagline leaves with the logo, not ahead of it (letter.css fades it on .film-leaving). */
html.film-on.film-line-in.film-leaving .film-lockup .film-line { opacity: 1; }
/* The letterhead's own logo steps back while the large one is up, and comes back as the large one fades,
   or as soon as the keyboard reaches it. */
html.film-on .header .brand img { transition: opacity .2s linear; }
html.film-line-in:not(.film-past) .header:not(.menu-open) .brand:not(:focus-visible) img { opacity: calc(1 - var(--film-brand, 1)); }

/* Treatment areas on the face, each a dot with a line to its name. film.js keeps every dot on its place
   in the picture at any window size, and leaves out one that would not fit. They can't be reached
   until they have arrived, nor once they have faded; one the keyboard is on shows in full. */
.film-spots { --dot: 20px; --delay: 0s; position: absolute; inset: 0; z-index: 3; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.film-spots:focus-within { --film-areas: 1; }
html.film-on:not(.film-spots-in) .film-spots, html.film-on.film-areas-gone .film-spots { visibility: hidden; }
.film-spots li:nth-child(2) { --delay: .13s; }
.film-spots li:nth-child(3) { --delay: .26s; }
.film-spots li:nth-child(4) { --delay: .39s; }
.film-spot {
  position: absolute; left: var(--x, 0); top: var(--y, 0); display: flex; align-items: center; min-height: 48px;
  color: var(--wine); text-decoration: none; pointer-events: auto; outline: none; -webkit-tap-highlight-color: transparent;
  transform: translate(calc(var(--dot) / -2), -50%);
}
/* A name on the left is anchored by its right edge, so a long one has the room on its own side to wrap into. */
.film-spot[data-side="left"] { left: auto; right: calc(100% - var(--x, 0px)); flex-direction: row-reverse; transform: translate(calc(var(--dot) / 2), -50%); }
.film-spot[hidden] { display: none; }
/* A white dot with a Clinic Red centre, a pale ring and the floating card's shadow, so it reads on light skin and dark hair. */
.film-dot {
  position: relative; flex: none; width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--white, #FFFFFF);
  box-shadow: 0 0 0 5px rgb(255 255 255 / .34), var(--card-shadow);
  transform: scale(0); transition: transform .6s var(--film-ease) var(--delay), opacity .15s linear;
}
.film-dot::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--accent); }
/* A ring spreads from a dot as its area lights, as the drop's did on the skin: motion that means "this one". */
.film-dot::before { content: ""; position: absolute; inset: -1px; border-radius: 50%; border: 1.5px solid rgb(255 255 255 / .9); opacity: 0; }
html.film-spots-in .film-dot { transform: none; opacity: var(--film-areas, 1); }
html.film-spots-in .film-spot.is-lit .film-dot::before { animation: film-ripple 2.4s cubic-bezier(.16, .6, .3, 1) 1; }
@keyframes film-ripple { 0% { transform: scale(1); opacity: .9; } 46%, 100% { transform: scale(3.6); opacity: 0; } }
/* The line is white with a faint wine glow, so it reads on light skin as well as dark hair. */
.film-rule {
  flex: none; width: clamp(22px, 2.6vw, 44px); height: 1.5px; background: var(--white, #FFFFFF); box-shadow: 0 0 6px rgb(var(--film-wine) / .4);
  transform: scaleX(0); transform-origin: left; transition: transform .5s var(--film-ease) calc(var(--delay) + .12s), opacity .15s linear;
}
.film-spot[data-side="left"] .film-rule { transform-origin: right; }
html.film-spots-in .film-rule { transform: none; opacity: var(--film-areas, 1); }
/* The names are things to press, so they are set in Jost (DESIGN.md, the Two Roles Rule) at the size of typed
   text. They arrive with an animation, so the stagger belongs to the arrival only: lighting, fading and leaving
   answer at once. A name too long for its place may take two lines (film.js sets data-wrap). */
.film-label {
  display: inline-flex; align-items: center; gap: 12px; max-width: none; padding: 10px 18px 11px 20px; border-radius: 999px;
  background: rgb(var(--film-paper) / .95); font-family: var(--font-ui); font-size: 18px; font-weight: 500; line-height: 1.2; letter-spacing: .01em;
  box-shadow: inset 0 0 0 1px var(--rule), var(--card-shadow);
  opacity: 0; transition: opacity .15s linear, background-color .45s var(--film-ease), color .45s var(--film-ease);
}
.film-name { white-space: nowrap; }
.film-spot[data-wrap] .film-name { white-space: normal; max-width: 7.5em; text-wrap: balance; }
.film-spot[data-side="left"][data-wrap] .film-name { text-align: right; }
.film-spot[data-side="left"] .film-label { --from: 10px; }
html.film-spots-in .film-label { opacity: var(--film-areas, 1); animation: film-label-in .7s var(--film-ease) calc(var(--delay) + .22s) backwards; }
@keyframes film-label-in { from { opacity: 0; transform: translateX(var(--from, -10px)); } }
/* The site's drawn arrow (letter.css), as on its buttons. */
.film-arrow {
  flex: none; width: 18px; height: 7px; background: currentColor; transition: transform .55s var(--film-ease);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 8'%3E%3Cpath d='M0 3.5h19.5L17 1l.7-.7L21.4 4l-3.7 3.7-.7-.7 2.5-2.5H0z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 8'%3E%3Cpath d='M0 3.5h19.5L17 1l.7-.7L21.4 4l-3.7 3.7-.7-.7 2.5-2.5H0z'/%3E%3C/svg%3E") no-repeat center / contain;
}
/* The lit area: one at a time in turn, or the one under the pointer or the keyboard (film.js). */
.film-spots .film-spot.is-lit .film-label { background: var(--wine); color: var(--paper, #FAF7F5); }
.film-spots .film-spot.is-lit .film-arrow { transform: translateX(4px); }
.film-spot:active .film-label { transform: scale(.97); }
/* The site's focus ring, also where :focus-visible isn't known. */
.film-spot:focus .film-label { outline: 3px solid var(--accent); outline-offset: 3px; }
.film-spot:focus:not(:focus-visible) .film-label { outline: none; }
html.film-cue-in .film-cue { opacity: 1; }
html.film-past .film-cue { opacity: 0; }
/* Very large screens step the scale up once, as DESIGN.md does above 2200px. */
@media (min-width: 2200px) { .film-label { font-size: 21px; } }

.film-cue { position: absolute; z-index: 2; margin: 0; font-size: var(--small); color: var(--wine); left: 50%; bottom: calc(28px + var(--film-bars)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0; }
.film-cue::after { content: ""; width: 1px; height: 32px; background: currentColor; transform-origin: top; animation: film-cue 2.4s cubic-bezier(.65, 0, .35, 1) infinite; }
@keyframes film-cue { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* The letter: a sheet of paper laid over the face. Its own top margin sits under the letterhead. */
html.film-on main {
  position: relative; z-index: 1; margin-top: calc(var(--film-h) * -1);
  padding-top: var(--header-offset, 100px);
  box-shadow: 0 -18px 48px rgb(51 48 51 / .14);
}
/* The skip link lands on the letter, not above it. */
html.film-on #main { scroll-margin-top: calc((var(--header-offset, 100px) + 24px) * -1); }

@media (max-width: 760px), (max-aspect-ratio: 5/4) {
  /* The phone film ends on a tall arrangement of the same picture: the person over the top seven
     tenths, the water's ripples under the shoulder, the logo on the water. */
  .film-stage { background-image: url(/assets/film-first-frame-phone.webp); background-position: 100% 12%; }
  .film-stage.is-still, html.film-still .film-stage { background-image: url(/assets/film-end-phone.webp); }
  .film-video { object-position: 100% 12%; }
  .film-lockup { --w: min(100vw - var(--margin) * 2, 280px); top: auto; bottom: calc(92px + var(--film-bars)); transform: translateY(var(--film-lift, 0px)); }
  .film-lockup::before {
    inset: -30px calc(var(--w) + var(--margin) - 100vw) calc(-92px - var(--film-bars)) calc(var(--margin) * -1);
    background: linear-gradient(0deg, rgb(var(--film-paper) / .9), rgb(var(--film-paper) / .8) 72%, rgb(var(--film-paper) / 0));
  }
  .film-spots { --dot: 18px; }
  .film-rule { width: 16px; }
  .film-label { padding: 8px 14px 9px 16px; gap: 10px; }
  /* Frosted glass on a phone: the face shows through, softened and lifted so the words stay clear,
     over dark hair too. */
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .film-label {
      background: rgb(var(--film-paper) / .5);
      -webkit-backdrop-filter: blur(14px) saturate(1.3) brightness(1.16);
      backdrop-filter: blur(14px) saturate(1.3) brightness(1.16);
      box-shadow: inset 0 0 0 1px rgb(255 255 255 / .6), var(--card-shadow);
      text-shadow: 0 0 8px rgb(var(--film-paper) / .95), 0 0 3px rgb(var(--film-paper) / .8);
    }
    /* An area that lies on dark hair (FILM_SPOTS marks it) has a little thicker glass. */
    .film-spot[data-ground="dark"] .film-label { background: rgb(var(--film-paper) / .64); }
    .film-spots .film-spot.is-lit .film-label { background: var(--wine); text-shadow: none; }
  }
  .film-cue { left: var(--margin); transform: none; flex-direction: row; }
  .film-cue::after { width: 32px; height: 1px; transform-origin: left; animation: none; }
}
@media (max-width: 379px) { .film-label { font-size: 16px; } }

@media print {
  .film { display: none !important; }
  html.film-on main { margin-top: 0; padding-top: 0; box-shadow: none; }
  html.film-on .header { position: static; }
}
