/* Hero media (ui.hero_media, docs/hero-media.md): a poster picture first, a loop or a 3D model laid over it once it
   plays or loads. The picture sets the height (width and height attributes), so nothing shifts. A site sets tokens only:
   --hm-radius, --hm-accent (default: the site's --accent), --hm-glass (the 3D button's fill). No url(): inlining stays possible.
   Reduced motion: the poster only, no loop, no model, no button. */
:where(.hm) {
  --hm-radius: 16px;
  --hm-accent: var(--accent, #9DAE51);
  --hm-glass: rgba(8, 11, 16, 0.86);
}

.hm {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: var(--hm-radius);
  background: var(--surface, #0E131B);
  box-shadow: inset 0 1px 0 color-mix(in oklab, var(--hm-accent) 55%, transparent), 0 24px 60px -32px color-mix(in oklab, var(--hm-accent) 50%, transparent);
}
.hm__poster, .hm__poster img { display: block; width: 100%; }
.hm__poster img { height: auto; }

.hm__video, .hm model-viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}
/* The loop stays a hair smaller than the poster: Chrome counts a playing video as an LCP candidate, and a frame even slightly larger than
   the poster becomes the LCP element, later than the poster (knullfix.de: 54 px2 larger, LCP +230 ms in Lighthouse). 1 px per side is invisible. */
.hm__video { object-fit: cover; inset: auto; top: 1px; left: 1px; width: calc(100% - 2px); height: calc(100% - 2px); }
.hm model-viewer { --poster-color: transparent; background: transparent; touch-action: pan-y; }
.hm.is-playing .hm__video, .hm.is-3d model-viewer { opacity: 1; }

.hm__3d {
  position: absolute;
  left: 50%;
  bottom: 16px;
  translate: -50% 0;
  min-height: 44px;
  padding: 0 20px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--hm-glass);
  border: 1px solid color-mix(in oklab, var(--hm-accent) 60%, transparent);
  border-radius: 999px;
  cursor: pointer;
}
.hm__3d:focus-visible, .hm model-viewer:focus-visible { outline: 2px solid var(--hm-accent); outline-offset: 3px; }
.hm.is-3d .hm__3d { display: none; }

.hm-icon { display: inline-block; flex: none; vertical-align: middle; }

@media (prefers-reduced-motion: no-preference) {
  .hm__video, .hm model-viewer { transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1); }
}
@media (prefers-reduced-motion: reduce) {
  .hm__video, .hm__3d, .hm model-viewer { display: none !important; }
}
