/* ==========================================================================
   Baystead Care: prelaunch page
   One viewport: the film, an ivory logo tag, the message, a footer line.
   ========================================================================== */

/* --------------------------------------------------------------------------
   The film: poster first, video fades in over it once it is playing
   -------------------------------------------------------------------------- */

.film {
  position: fixed;
  inset: 0;
  z-index: var(--z-film);
  overflow: hidden;
  background-color: var(--charcoal);
  pointer-events: none;
}

/* Parallax target (JS moves it). Oversized so the edges never show. */
.film__frame {
  position: absolute;
  inset: -14px;
  will-change: transform;
}

/* A slow camera settle on load. */
.film__settle {
  position: absolute;
  inset: 0;
}

.film__poster,
.film__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  /* Landscape cut: keeps both faces in frame from 4:3 to 21:9. */
  object-position: 38% 42%;
}

/* Portrait screens get their own 4:5 cut, already centred on the two faces. */
@media (orientation: portrait) {
  .film__poster,
  .film__video {
    object-position: 38% 42%;
  }
}

.film__video {
  opacity: 0;
  transition: opacity var(--dur-film-fade) var(--ease-in-out);
}

.film.is-playing .film__video {
  opacity: 1;
}

/* The veranda shade: just enough eucalyptus for the type, never a black scrim.
   Portrait and narrow screens: shade rises from the bottom, where the type sits. */
.film__shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      to top,
      rgb(var(--shade-warm-rgb) / 0.76) 0%,
      rgb(var(--shade-warm-rgb) / 0.78) 30%,
      rgb(var(--shade-warm-rgb) / 0.82) 42%,
      rgb(var(--eucalyptus-rgb) / 0.66) 50%,
      rgb(var(--eucalyptus-rgb) / 0.34) 57%,
      rgb(var(--eucalyptus-rgb) / 0.12) 64%,
      rgb(var(--eucalyptus-rgb) / 0) 70%
    );
}

.film__grain {
  position: absolute;
  inset: 0;
  background-image: url("../assets/img/grain.png");
  background-size: 128px 128px;
  opacity: 0.22;
  mix-blend-mode: soft-light;
}

/* --------------------------------------------------------------------------
   Page frame
   -------------------------------------------------------------------------- */

.page {
  position: relative;
  z-index: var(--z-content);
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
  padding-inline: max(var(--edge), env(safe-area-inset-left)) max(var(--edge), env(safe-area-inset-right));
  padding-bottom: max(var(--space-m), env(safe-area-inset-bottom));
}

/* --------------------------------------------------------------------------
   The logo tag: hangs from the top edge, the one opaque surface
   -------------------------------------------------------------------------- */

.tag {
  justify-self: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 7.5rem;
  padding: calc(var(--space-s) + env(safe-area-inset-top)) var(--space-xs) var(--space-xs);
  background-color: var(--ivory);
  color: var(--text-on-ivory);
  border-radius: var(--radius-tag);
  box-shadow: 0 18px 40px -22px rgb(var(--deep-rgb) / 0.55);
}

.tag__logo {
  width: 100%;
  height: auto;
}

.tag__place {
  width: 100%;
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--rule-on-ivory);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
}

.tag__place > span {
  display: block;
}

/* --------------------------------------------------------------------------
   The message
   -------------------------------------------------------------------------- */

.message {
  align-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 36rem;
  padding-bottom: var(--space-xl);
}

.message__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-display);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
  color: var(--text-on-film);
  font-feature-settings: "kern", "liga", "onum";
  text-shadow: 0 1px 28px rgb(var(--deep-rgb) / 0.35);
}

.line {
  display: block;
}

.message__lead {
  margin-top: var(--space-m);
  font-size: var(--step-lead);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text-on-film);
}

/* --------------------------------------------------------------------------
   Get in touch
   -------------------------------------------------------------------------- */

.cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-s);
  min-height: 3.25rem;
  margin-top: var(--space-l);
  padding: 0.375rem 0.375rem 0.375rem 1.5rem;
  background-color: var(--ivory);
  color: var(--text-on-ivory);
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: var(--step-small);
  font-weight: 500;
  letter-spacing: var(--tracking-button);
  text-transform: uppercase;
  box-shadow: 0 14px 32px -18px rgb(var(--deep-rgb) / 0.6);
  transition:
    background-color var(--dur-hover) var(--ease-out-soft),
    transform var(--dur-press) var(--ease-out-soft);
  user-select: none;
}

.cta__well {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-round);
  background-color: var(--eucalyptus);
  color: var(--ivory);
  overflow: hidden;
}

.cta__arrow {
  grid-area: 1 / 1;
  transition: transform var(--dur-hover) var(--ease-out-soft);
}

.cta__arrow--next {
  transform: translateX(-2.5rem);
}

.cta:active {
  transform: scale(0.97);
}

.cta:focus-visible {
  outline-color: var(--focus-on-film);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .cta:hover {
    background-color: var(--sand);
  }

  .cta:hover .cta__arrow {
    transform: translateX(2.5rem);
  }

  .cta:hover .cta__arrow--next {
    transform: translateX(0);
  }
}

/* --------------------------------------------------------------------------
   Footer and the film control
   -------------------------------------------------------------------------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  padding-top: var(--space-s);
  border-top: 1px solid rgb(var(--ivory-rgb) / 0.22);
}

.foot__info {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  column-gap: 0;
  row-gap: 0.125rem;
  font-size: var(--step-small);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-on-film);
}

.foot__sep {
  margin-inline: 0.65em;
  color: var(--sage);
}

.foot__tel {
  position: relative;
  text-decoration-line: underline;
  text-decoration-color: rgb(var(--ivory-rgb) / 0.4);
  text-underline-offset: 0.3em;
  font-variant-numeric: lining-nums;
  transition: text-decoration-color var(--dur-hover) var(--ease-out-soft);
}

/* A 44px-tall tap area without moving the line */
.foot__tel::after {
  content: "";
  position: absolute;
  inset: -0.75rem -0.25rem;
}

@media (hover: hover) and (pointer: fine) {
  .foot__tel:hover {
    text-decoration-color: var(--ivory);
  }
}

.film-toggle {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-round);
  border: 1px solid rgb(var(--ivory-rgb) / 0.5);
  color: var(--ivory);
  transition:
    border-color var(--dur-hover) var(--ease-out-soft),
    background-color var(--dur-hover) var(--ease-out-soft),
    transform var(--dur-press) var(--ease-out-soft);
}

.film-toggle {
  visibility: hidden;
}

.film-toggle.is-ready {
  visibility: visible;
}

/* No glyph animation until the first state is set */
.film-toggle:not(.is-ready) .film-toggle__icon {
  transition: none;
}

.film-toggle__icon {
  grid-area: 1 / 1;
  transition:
    opacity var(--dur-toggle) var(--ease-out-soft),
    transform var(--dur-toggle) var(--ease-out-soft);
}

.film-toggle__icon--play,
.film-toggle[aria-pressed="true"] .film-toggle__icon--pause {
  opacity: 0;
  transform: scale(0.6);
}

.film-toggle[aria-pressed="true"] .film-toggle__icon--play {
  opacity: 1;
  transform: scale(1);
}

.film-toggle:active {
  transform: scale(0.94);
}

@media (hover: hover) and (pointer: fine) {
  .film-toggle:hover {
    border-color: var(--ivory);
    background-color: rgb(var(--ivory-rgb) / 0.1);
  }
}

/* --------------------------------------------------------------------------
   Narrow phones
   -------------------------------------------------------------------------- */

@media (max-width: 379px) {
  .tag {
    width: 6.75rem;
  }

  .message__lead {
    margin-top: var(--space-s);
  }

  .cta {
    margin-top: var(--space-m);
  }
}

/* --------------------------------------------------------------------------
   Wide screens: message moves right, away from the two faces
   -------------------------------------------------------------------------- */

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  /* A pool of shade behind the message only; the sky and the faces stay lit.
     The pool is masked off above the horizon so it never reads as a cloud. */
  .film__shade {
    background: linear-gradient(
      to top,
      rgb(var(--deep-rgb) / 0.9) 0%,
      rgb(var(--deep-rgb) / 0.82) 8%,
      rgb(var(--deep-rgb) / 0.4) 16%,
      rgb(var(--deep-rgb) / 0) 26%
    );
  }

  .film__shade::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
      ellipse 60% 74% at 85% 68%,
      rgb(var(--deep-rgb) / 0.84) 0%,
      rgb(var(--deep-rgb) / 0.8) 36%,
      rgb(var(--deep-rgb) / 0.7) 50%,
      rgb(var(--eucalyptus-rgb) / 0.54) 62%,
      rgb(var(--eucalyptus-rgb) / 0.34) 74%,
      rgb(var(--eucalyptus-rgb) / 0.16) 85%,
      rgb(var(--eucalyptus-rgb) / 0.05) 94%,
      rgb(var(--eucalyptus-rgb) / 0) 100%
    );
    -webkit-mask-image: linear-gradient(to bottom, transparent 28%, #000 44%);
    mask-image: linear-gradient(to bottom, transparent 28%, #000 44%);
  }

  .tag {
    width: 9.25rem;
    padding-inline: var(--space-s);
    padding-bottom: var(--space-s);
  }

  .tag__place {
    font-size: var(--step-label);
  }

  .message {
    justify-self: end;
    width: fit-content;
    max-width: min(37rem, 36vw);
    padding-bottom: clamp(var(--space-xl), 9vh, 6.5rem);
  }

  /* Sized to the column so "A more personal" holds one line, clear of the faces */
  .message__title {
    font-size: min(var(--step-display), 5.7vw);
  }

  .line {
    white-space: nowrap;
  }

  .message__lead {
    margin-top: var(--space-l);
  }

  .cta {
    margin-top: var(--space-xl);
  }
}

@media (min-width: 1600px) and (min-aspect-ratio: 1/1) {
  .tag {
    width: 10.5rem;
  }
}

/* Short landscape screens (phones on their side, small laptop windows) */
@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  .tag {
    width: 6.25rem;
    padding: var(--space-xs) var(--space-2xs) var(--space-2xs);
  }

  .tag__place {
    font-size: 0.625rem;
    margin-top: var(--space-2xs);
    padding-top: var(--space-2xs);
  }

  .message {
    padding-bottom: var(--space-m);
  }

  .message__title {
    font-size: clamp(2.25rem, 7.5vh + 1rem, 3.5rem);
  }

  .message__lead {
    margin-top: var(--space-xs);
  }

  .cta {
    margin-top: var(--space-m);
  }

  .foot {
    padding-top: var(--space-xs);
  }
}

/* --------------------------------------------------------------------------
   The entrance: logo, place, headline, line, button, footer (about 2.2s)
   Content is visible by default; the motion only runs when it is welcome.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .film__settle {
    animation: settle var(--dur-settle) var(--ease-out) backwards;
  }

  .tag {
    --from-y: -1.25rem;
    animation: rise var(--dur-enter-lead) var(--ease-out) 100ms backwards;
  }

  .tag__place {
    animation: fade var(--dur-enter-quiet) var(--ease-out) 480ms backwards;
  }

  .line--1 {
    --from-y: 0.32em;
    animation: rise var(--dur-enter-lead) var(--ease-out) 640ms backwards;
  }

  .line--2 {
    --from-y: 0.32em;
    animation: rise var(--dur-enter-lead) var(--ease-out) 780ms backwards;
  }

  .message__lead {
    --from-y: 0.75rem;
    animation: rise var(--dur-enter-support) var(--ease-out) 1060ms backwards;
  }

  .cta {
    --from-y: 0.625rem;
    animation: rise var(--dur-enter-support) var(--ease-out) 1220ms backwards;
  }

  .foot {
    animation: fade var(--dur-enter-quiet) var(--ease-out) 1440ms backwards;
  }
}

@keyframes rise {
  from {
    /* 0.01, not 0: invisible, but lets the browser record the first paint (LCP) */
    opacity: 0.01;
    transform: translate3d(0, var(--from-y, 0.5rem), 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0.01;
  }
  to {
    opacity: 1;
  }
}

@keyframes settle {
  from {
    transform: scale(1.02);
  }
  to {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion: everything rests; the film waits on its poster (see JS)
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .film__video,
  .cta,
  .cta__arrow,
  .film-toggle,
  .film-toggle__icon {
    transition-duration: 0.01ms;
  }

  .film__frame {
    transform: none !important;
  }
}

/* Windows High Contrast / forced colours: keep the controls outlined */
@media (forced-colors: active) {
  .cta,
  .film-toggle {
    border: 1px solid ButtonText;
  }
}

/* --------------------------------------------------------------------------
   404: the same tag and type on the veranda shade, without the film
   -------------------------------------------------------------------------- */

/* The 404 uses the poster still under the same shade, no video. */
.lost {
  background-color: var(--charcoal);
}

.lost .message__title {
  text-shadow: none;
}

/* Phones: the footer sets as two clean lines, no stray separator */
@media (max-width: 599px) {
  .foot__info > span:first-child {
    flex-basis: 100%;
  }

  .foot__info > .foot__sep:nth-child(2),
  .foot__info > .foot__sep--tel {
    display: none;
  }

  /* Phones: the number gets its own line, the easiest thing to tap */
  .foot__info > span:last-child {
    flex-basis: 100%;
  }

  /* Give back the footer's third line so the headline stays low in the shade */
  .message {
    padding-bottom: var(--space-l);
  }

  .foot {
    padding-top: var(--space-xs);
  }
}
