/* ============================================================
   Inline Media Text — photo pills set inline in a display headline.
   Every selector is scoped to .byq-gem--inline-media-text-01.

   Layout sizes are custom properties in em, so the pills scale
   with the type. script.js only flips classes and animates the
   in-between (FLIP); the resting geometry lives here.
   ============================================================ */

.byq-gem--inline-media-text-01 {
  /* pill geometry (em = headline size) */
  --imt-rest-w: 1.55em;
  --imt-rest-h: 0.72em;
  --imt-dim-w: 1.12em;
  --imt-dim-h: 0.58em;
  --imt-open-w: 4.1em;
  --imt-open-h: 1.02em;
  --imt-gap: 0.2em;
  /* colour the active pill spills into nearby words ("r g b") */
  --imt-tint: 246 243 236;

  position: relative;
  width: min(100%, 76rem);
  color: var(--byq-fg);
  font-family: var(--byq-font-sans);
}

.byq-gem--inline-media-text-01__line {
  margin: 0;
  max-width: 12.5em;
  font-family: var(--byq-font-display);
  font-weight: 400;
  font-size: clamp(2.35rem, 8.4vw, 7.6rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--byq-fg);
}

/* ---- words (script.js wraps each one) ---- */
.byq-gem--inline-media-text-01__w {
  display: inline-block;
  color: var(--byq-fg);
  color: color-mix(
    in oklab,
    rgb(var(--imt-tint)) calc(var(--imt-k, 0) * 100%),
    var(--byq-fg)
  );
  transition: color 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---- pills ---- */
.byq-gem--inline-media-text-01__pill {
  position: relative;
  display: inline-block;
  width: var(--imt-rest-w);
  height: var(--imt-rest-h);
  margin: 0 var(--imt-gap);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  vertical-align: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.byq-gem--inline-media-text-01__shell {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: var(--imt-rest-h);
  transform: translateY(-50%);
  overflow: hidden;
  border-radius: 0.4em; /* ≥ half the pill height → a capsule */
  background: var(--byq-depth);
  /* keeps the rounded clip crisp while children transform (Safari) */
  isolation: isolate;
  transition: border-radius 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.byq-gem--inline-media-text-01__shell img {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: calc(var(--imt-open-w) + 0.5em);
  height: calc(var(--imt-open-h) + 0.3em);
  max-width: none;
  margin: calc((var(--imt-open-h) + 0.3em) / -2) 0 0
    calc((var(--imt-open-w) + 0.5em) / -2);
  object-fit: cover;
  object-position: var(--pos, 50% 50%);
  /* two independent motions: `scale` settles as the window opens,
     `translate` = a slow drift on open + pointer parallax */
  /* at rest the whole strip is shrunk into the capsule (a miniature),
     opening zooms it up to full size */
  scale: 0.6;
  translate: calc(var(--imt-mx, 0) * -4%) 0;
  filter: saturate(1) brightness(1);
  transition:
    scale 0.76s cubic-bezier(0.22, 0.8, 0.18, 1), /* = the FLIP timing, so the photo always covers the growing window */
    translate 0.9s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.6s ease;
  pointer-events: none;
}

/* open: the wide media window */
.byq-gem--inline-media-text-01__pill.is-active {
  width: var(--imt-open-w);
  cursor: default;
}
.byq-gem--inline-media-text-01__pill.is-active .byq-gem--inline-media-text-01__shell {
  height: var(--imt-open-h);
  border-radius: 0.22em;
}
.byq-gem--inline-media-text-01__pill.is-active img {
  scale: 1.04;
  translate: calc(var(--imt-mx, 0) * -4%) 0;
}

/* the others step back: smaller + drained of colour */
.byq-gem--inline-media-text-01__pill.is-dim {
  width: var(--imt-dim-w);
}
.byq-gem--inline-media-text-01__pill.is-dim .byq-gem--inline-media-text-01__shell {
  height: var(--imt-dim-h);
}
.byq-gem--inline-media-text-01__pill.is-dim img {
  scale: 0.48;
  filter: saturate(0) brightness(0.62);
}
.byq-gem--inline-media-text-01__pill.is-dim:hover img {
  filter: saturate(0.5) brightness(0.8);
}

/* not yet popped in (scroll-in intro) */
.byq-gem--inline-media-text-01__pill.is-out {
  width: 0;
  margin: 0 0.12em; /* the two margins ≈ one word space */
}
.byq-gem--inline-media-text-01__pill.is-out .byq-gem--inline-media-text-01__shell {
  height: 0;
}

.byq-gem--inline-media-text-01__pill:focus-visible .byq-gem--inline-media-text-01__shell {
  outline: 2px solid var(--byq-accent-solar);
  outline-offset: 0.06em;
}

@media (max-width: 640px) {
  .byq-gem--inline-media-text-01 {
    --imt-rest-w: 1.4em;
    --imt-dim-w: 1.02em;
    --imt-open-w: 3.5em;
    --imt-gap: 0.17em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .byq-gem--inline-media-text-01__w,
  .byq-gem--inline-media-text-01__shell,
  .byq-gem--inline-media-text-01__shell img {
    transition-duration: 0.001ms;
  }
}
