/* As featured on. Two horizontal rows, each an infinite CSS marquee
   (Magic UI: overflow hidden, duplicated track, translateX by -100% - gap).
   Row 1 moves left, row 2 moves right, 40s linear. Edge fades are a mask,
   so they follow the page color in either theme. Gray at rest, the badge's
   own color on hover, keyboard focus, or tap. The marquee transform sits
   on the track; the hover lift sits on the badge, so they don't fight.
   Named properties only. fc- tokens are local so they don't collide
   with the page theme.

   Preview (absolute /assets paths need the server root to be web/landing):
     cd web/landing && python3 -m http.server 4173
     http://127.0.0.1:4173/#featured
     http://127.0.0.1:4173/badges.html
   prefers-reduced-motion freezes both marquees.
*/

:root {
  --fc-ring: var(--accent-ink);
  --fc-ease-out: var(--ease-out);
  --fc-lift: 240ms;
  --fc-color: 280ms;
  --fc-duration: 40s;
  --fc-gap: 22px;
  --fc-h: 26px;
}

@media (min-width: 600px) {
  :root {
    --fc-h: 36px;
    --fc-gap: 36px;
  }
}

/* The badges page is a .doc, widened so the rows can run at the
   homepage's width without leaving the shared header or footer. */
.doc.doc-badges {
  max-width: 1080px;
}

.doc .fc-section {
  padding-block: 0;
}

.doc .featured-lede {
  max-width: 52ch;
  margin-bottom: 0;
}

/* Two rows, enforced by markup: one .fc-marquee per direction.
   The homepage band breaks out of .wrap so the fades sit on the
   viewport edges. 100vw is clipped by the page's overflow-x. */
.fc-marquee-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 24px;
}

.fc-home .fc-marquee-stack {
  width: 100vw;
  margin-left: calc(50% - 50vw);
}

@media (min-width: 600px) {
  .fc-marquee-stack {
    margin-top: 32px;
  }
}

.fc-marquee {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--fc-gap);
  overflow: hidden;
  padding-block: 18px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}

/* Each track is one copy of the row. Translating by its own width
   plus the parent gap parks the duplicate exactly where this copy started. */
.fc-track {
  display: flex;
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--fc-gap);
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
  animation: fc-marquee var(--fc-duration) linear infinite;
}

.fc-marquee--rtl .fc-track {
  animation-direction: reverse;
}

@keyframes fc-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100% - var(--fc-gap))); }
}

/* Pause the whole row. Pausing one badge would desync the duplicate. */
.fc-marquee:focus-within .fc-track {
  animation-play-state: paused;
}

@media (hover: hover) {
  .fc-marquee:hover .fc-track {
    animation-play-state: paused;
  }
}

.fc-item {
  display: flex;
  flex: none;
  align-items: center;
}

.fc-badge {
  position: relative;
  display: block;
  border-radius: 10px;
  outline: none;
  text-decoration: none;
  transform: translate3d(0, 0, 0) scale(1);
  transition: transform var(--fc-lift) var(--fc-ease-out);
  -webkit-tap-highlight-color: transparent;
}

.fc-mark {
  display: block;
  width: auto;
  max-width: none;
  height: calc(var(--fc-h) * var(--fc-k, 1));
  /* Rest: one gray, slightly muted, for every brand. */
  position: relative;
  filter: grayscale(1) contrast(0.92) brightness(1.04);
  opacity: 0.6;
  transition:
    filter var(--fc-color) var(--fc-ease-out),
    opacity var(--fc-color) var(--fc-ease-out);
}

/* A dark-ground badge is lifted at rest so a black pill doesn't outweigh the light ones. */
.fc-badge[data-tone="dark"] .fc-mark {
  filter: grayscale(1) contrast(0.7) brightness(1.45);
}

/* The badge's own pixels, blurred, as a bloom under it. The pseudo paints the
   same cached file. No invented tint. */
.fc-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--fc-img) center / contain no-repeat;
  filter: blur(12px) saturate(1.6);
  opacity: 0;
  transform: translate3d(0, 4px, 0) scale(0.92);
  transition:
    opacity var(--fc-color) var(--fc-ease-out),
    transform var(--fc-color) var(--fc-ease-out);
  pointer-events: none;
}

/* The rest of the row steps back while one badge is up. */
.fc-marquee[data-active] .fc-badge:not([data-hot]) .fc-mark,
.fc-marquee:has(.fc-badge:focus-visible) .fc-badge:not(:focus-visible) .fc-mark {
  opacity: 0.42;
}

.fc-badge[data-hot],
.fc-badge:focus-visible {
  transform: translate3d(0, -3px, 0) scale(1.04);
}

.fc-badge[data-hot] .fc-mark,
.fc-badge:focus-visible .fc-mark {
  filter: grayscale(0) contrast(1) brightness(1);
  opacity: 1;
}

.fc-badge[data-hot]::before,
.fc-badge:focus-visible::before {
  opacity: 0.5;
  transform: translate3d(0, 8px, 0) scale(1);
}

@media (hover: hover) {
  .fc-marquee:has(.fc-badge:hover) .fc-badge:not(:hover) .fc-mark {
    opacity: 0.42;
  }

  .fc-badge:hover {
    transform: translate3d(0, -3px, 0) scale(1.04);
  }

  .fc-badge:hover .fc-mark {
    filter: grayscale(0) contrast(1) brightness(1);
    opacity: 1;
  }

  .fc-badge:hover::before {
    opacity: 0.5;
    transform: translate3d(0, 8px, 0) scale(1);
  }
}

/* Touch: a tap flashes the color while the finger is down. Hover rules stay
   inside (hover: hover), so a tap does not leave the badge colored. */
.fc-badge:active {
  transform: translate3d(0, -1px, 0) scale(0.98);
}

.fc-badge:active .fc-mark {
  filter: grayscale(0) contrast(1) brightness(1);
  opacity: 1;
}

/* Keyboard: the ring appears at once, no transition. */
.fc-badge:focus-visible {
  outline: 2px solid var(--fc-ring);
  outline-offset: 4px;
}

/* Homepage heading. The badges page keeps its own h1 inside .doc.
   The band is a lead-in to #trio, so it does not take a full section pad. */
section.fc-section {
  padding-block: clamp(28px, 4vw, 48px) clamp(12px, 2vw, 24px);
}
#featured {
  scroll-margin-top: 96px;
}
.fc-home {
  text-align: center;
}
.fc-home > h2 {
  margin: 0;
}

/* The page's .reveal fade would hide the whole band until scroll.
   The marquees run on their own; the band stays visible. */
.fc-section.reveal,
.fc-section.reveal.in {
  opacity: 1;
  translate: none;
  filter: none;
  transition: none;
}

/* No marquee and no lift. Color still answers, immediately.
   base.css also sets animation/transition to none under this query. */
@media (prefers-reduced-motion: reduce) {
  .fc-track {
    animation: none;
  }

  .fc-badge,
  .fc-mark,
  .fc-badge::before {
    transition-duration: 0.01ms;
  }

  .fc-badge,
  .fc-badge[data-hot],
  .fc-badge:focus-visible,
  .fc-badge:active {
    opacity: 1;
    translate: none;
    filter: none;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) {
  .fc-badge:hover {
    transform: none;
  }
}
