/*
  Loop Studio launch title (kinetic type header)
  - Colours: edit the three custom properties on .lt.
  - Copy: edit the text in index.html (each word or sentence sits in its own span).
  - Timing: --d on each .lt__rise is its entry delay; --lt-loop is the length of one graphic loop.
  - Only transform and opacity are animated.
  - Needs CSS container queries (Chrome/Edge 105+, Safari 16+, Firefox 110+).
*/

.lt {
  --lt-ink: #1B1B1F;
  --lt-paper: #F4F1EA;
  --lt-signal: #FF5A36;
  --lt-ease: cubic-bezier(.16, 1, .3, 1);
  --lt-loop: 4s;

  container-type: inline-size;
  background: var(--lt-ink);
  color: var(--lt-paper);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.lt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout: 16:9 composition (1600 x 900 at full width), 4% safe margins ---------- */

.lt__stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "brand ring"
    "copy  ring";
  column-gap: 3cqi;
  /* 16:9 of the header's width, but never taller than the screen. */
  min-height: min(56.25cqi, 100svh);
  padding: 2.25cqi 4cqi;
}

.lt__brand {
  grid-area: brand;
  margin: 0;
  font-size: max(15px, 1.45cqi);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.lt__copy {
  grid-area: copy;
  align-self: center;
  min-width: 0;
}

.lt__headline {
  margin: 0 0 .32em;
  font-size: min(9cqi, 17svh);
  font-weight: 800;
  letter-spacing: -.045em;
  word-spacing: .06em;
  line-height: .95;
}

.lt__sub {
  margin: 0;
  font-size: min(4.2cqi, 8svh);
  font-weight: 700;
  letter-spacing: -.03em;
  word-spacing: .03em;
  line-height: 1.12;
}

.lt__ring {
  grid-area: ring;
  align-self: center;
  width: min(34cqi, 64svh);
  aspect-ratio: 1;
}

.lt__ring-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.lt__toggle {
  position: absolute;
  right: 4cqi;
  bottom: 2.25cqi;
}

/* Phone and narrow containers: graphic top right, copy underneath, control in the flow. */
@container (max-width: 699px) {
  .lt__stage {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "brand ring"
      "copy  copy"
      "foot  foot";
    row-gap: 5cqi;
    min-height: 0;
    padding: 6cqi 6cqi 7cqi;
  }
  .lt__brand { align-self: start; font-size: max(15px, 4.2cqi); }
  .lt__ring { width: min(56cqi, 360px); align-self: start; }
  .lt__headline { font-size: 13.4cqi; }
  .lt__sub { font-size: 6.6cqi; }
  .lt__toggle {
    position: static;
    grid-area: foot;
    justify-self: start;
  }
}

/* ---------- Type pieces ---------- */

/* The mask reveals each word from below; padding keeps ascenders and descenders unclipped. */
.lt__mask {
  display: inline-block;
  padding: .14em .1em .22em;
  margin: -.14em -.1em -.22em;
  clip-path: inset(0);
}

.lt__nowrap { white-space: nowrap; }

.lt__rise {
  display: inline-block;
  animation: lt-in-rise .9s var(--lt-ease) var(--d, 0s) both;
}

.lt__fade {
  display: inline-block;
  animation: lt-in-fade .8s var(--lt-ease) 0s both;
}

/* The full stop of the headline is drawn as a signal-orange dot that beats once per loop.
   The real "." stays in the text at zero size so the heading still reads "Make it move." */
.lt__ghost { font-size: 0; }

.lt__dot-pop {
  display: inline-block;
  width: .19em;
  height: .19em;
  margin-left: .04em;
  animation: lt-in-pop .6s cubic-bezier(.34, 1.56, .64, 1) .72s both;
}

.lt__dot {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--lt-signal);
}

/* ---------- Supporting graphic ---------- */

.lt__ring { animation: lt-in-ring 1.3s var(--lt-ease) .2s both; }

.lt__orbit {
  fill: none;
  stroke: var(--lt-paper);
  stroke-opacity: .14;
  stroke-width: 2;
}

.lt__frame-in { animation: lt-in-fade-only .5s ease-out calc(.3s + var(--i) * 25ms) both; }

.lt__frame {
  fill: var(--lt-paper);
  /* Still state = the trail the playhead leaves behind it while at the top of the ring. */
  opacity: max(.2, 1 - (1 - var(--i) / 24) / .3 * .8);
}
.lt__frame-in:first-of-type .lt__frame { opacity: 1; }

.lt__playhead-in { animation: lt-in-fade-only .6s ease-out 1s both; }

.lt__playhead line {
  stroke: var(--lt-signal);
  stroke-width: 7;
  stroke-linecap: round;
}

.lt__playhead circle { fill: var(--lt-signal); }

/* ---------- Loop: only runs once launch-title.js has added .is-ready (so a pause control exists) ---------- */

.lt.is-ready .lt__playhead {
  animation: lt-loop-spin var(--lt-loop) linear infinite;
}

/* Each frame flashes when the playhead passes it: frame i is offset by i/24 of a loop. */
.lt.is-ready .lt__frame {
  animation: lt-loop-flash var(--lt-loop) linear calc(var(--lt-loop) * (var(--i) / 24 - 1)) infinite;
}

.lt.is-ready .lt__dot {
  animation: lt-loop-beat var(--lt-loop) ease-out infinite;
}

.lt.is-paused .lt__playhead,
.lt.is-paused .lt__frame,
.lt.is-paused .lt__dot { animation-play-state: paused; }

/* ---------- Play / pause control ---------- */

.lt__toggle {
  display: inline-flex;
  align-items: center;
  gap: .6em;
  min-width: 44px;
  min-height: 44px;
  padding: 0 1.15em 0 1em;
  font: inherit;
  font-size: max(15px, 1.05cqi);
  font-weight: 650;
  line-height: 1;
  color: var(--lt-paper);
  background: transparent;
  border: 1.5px solid rgba(244, 241, 234, .55);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  /* Mouse only, so the button does not look stuck after a tap on a phone. */
  .lt__toggle:hover { background: rgba(244, 241, 234, .1); border-color: var(--lt-paper); }
}
.lt__toggle:focus-visible { outline: 3px solid var(--lt-signal); outline-offset: 3px; }
.lt__toggle[hidden] { display: none; }

.lt__icon {
  position: relative;
  flex: none;
  width: .78em;
  height: .9em;
}

/* Pause icon: two bars. */
.lt__icon::before,
.lt__icon::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: .26em;
  border-radius: 1px;
  background: currentColor;
}
.lt__icon::before { left: .06em; }
.lt__icon::after { right: .06em; }

/* Play icon: a triangle. */
.lt.is-paused .lt__icon::before {
  left: .1em;
  width: 0;
  border-radius: 0;
  background: none;
  border-style: solid;
  border-width: .45em 0 .45em .72em;
  border-color: transparent transparent transparent currentColor;
}
.lt.is-paused .lt__icon::after { display: none; }

/* ---------- Keyframes ---------- */

@keyframes lt-in-rise {
  from { opacity: 0; transform: translateY(130%); }
  to   { opacity: 1; transform: none; }
}

@keyframes lt-in-fade {
  from { opacity: 0; transform: translateY(.5em); }
  to   { opacity: 1; transform: none; }
}

@keyframes lt-in-fade-only {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes lt-in-pop {
  from { opacity: 0; transform: scale(0); }
  to   { opacity: 1; transform: none; }
}

@keyframes lt-in-ring {
  from { opacity: 0; transform: rotate(-60deg) scale(.86); }
  to   { opacity: 1; transform: none; }
}

@keyframes lt-loop-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes lt-loop-flash {
  0%        { opacity: 1; }
  30%, 100% { opacity: .2; }
}

/* Starts and ends at rest so a paused or reduced-motion dot is never caught enlarged. */
@keyframes lt-loop-beat {
  0%        { transform: scale(1); }
  4%        { transform: scale(1.5); }
  26%, 100% { transform: scale(1); }
}

/* ---------- Reduced motion: no entrance, everything starts still (the JS starts paused). ---------- */

@media (prefers-reduced-motion: reduce) {
  .lt__rise,
  .lt__fade,
  .lt__dot-pop,
  .lt__ring,
  .lt__frame-in,
  .lt__playhead-in { animation: none; }
}
