:root {
  /* Sampled from the clip's backdrop so the plate dissolves into the page. */
  --bg: #020509;
  --ink: #efe7da;
  --ink-dim: rgba(239, 231, 218, 0.46);
  --ink-faint: rgba(239, 231, 218, 0.16);
  --gutter: clamp(16px, 3.2vw, 44px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body { font-family: var(--mono); }

.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg); /* opaque backdrop so the grain blends evenly */
  touch-action: pan-y;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Stage: the original 1920×1440 composition, scaled + positioned by JS ── */

.hero__stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  opacity: 0;
  transition: opacity 1.4s var(--ease-out);
  will-change: transform;
}

.hero.is-plate .hero__stage { opacity: 1; }

.hero__plate {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-mask-image: radial-gradient(ellipse 62% 64% at 48.6% 47%, #000 58%, transparent 100%);
          mask-image: radial-gradient(ellipse 62% 64% at 48.6% 47%, #000 58%, transparent 100%);
}

/* Sprite canvas covers only the region that moves. Its edges are feathered so
   it melts into the plate; the bottom fade size comes from the manifest. */
.hero__sprite {
  position: absolute;
  display: block;
  opacity: 0;
  transition: opacity 0.5s linear;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0, #000 2.5%, #000 calc(100% - var(--feather-bottom, 8.5%)), transparent 100%),
    linear-gradient(to right, transparent 0, #000 2.5%, #000 97.5%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to bottom, transparent 0, #000 2.5%, #000 calc(100% - var(--feather-bottom, 8.5%)), transparent 100%),
    linear-gradient(to right, transparent 0, #000 2.5%, #000 97.5%, transparent 100%);
          mask-composite: intersect;
}

.hero.is-ready .hero__sprite { opacity: 1; }

/* Reaction videos (hero-react.js): over the crop region, feathered like the sprite. */
.hero__react {
  position: absolute;
  pointer-events: none;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0, #000 2.5%, #000 calc(100% - var(--feather-bottom, 8.5%)), transparent 100%),
    linear-gradient(to right, transparent 0, #000 2.5%, #000 97.5%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to bottom, transparent 0, #000 2.5%, #000 calc(100% - var(--feather-bottom, 8.5%)), transparent 100%),
    linear-gradient(to right, transparent 0, #000 2.5%, #000 97.5%, transparent 100%);
          mask-composite: intersect;
}

.hero__react video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  pointer-events: none;
}

.hero__react video.is-on { opacity: 1; }

/* ── One-shot clip (e.g. a sip of coffee), matched to the idle frame ── */

.hero__clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s linear;
  -webkit-mask-image: radial-gradient(ellipse 62% 64% at 48.6% 47%, #000 58%, transparent 100%);
          mask-image: radial-gradient(ellipse 62% 64% at 48.6% 47%, #000 58%, transparent 100%);
}

.hero.is-clip-visible .hero__clip { opacity: 1; }

.hero__hotspot {
  position: absolute;
  z-index: 3;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hero__hotspot[hidden] { display: none; }

.hero__hotspot::before {
  content: "";
  position: absolute;
  inset: -4%;
  border-radius: 50%;
  border: 1px solid rgba(239, 231, 218, 0.6);
  box-shadow: 0 0 0 1px rgba(2, 5, 9, 0.25), 0 0 28px rgba(233, 162, 125, 0.35);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.35s var(--ease-out), transform 0.5s var(--ease-out);
}

.hero__hotspot-label {
  position: absolute;
  left: 100%;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin-left: 14px;
  padding: 7px 12px 7px 10px;
  border: 1px solid rgba(239, 231, 218, 0.22);
  border-radius: 999px;
  background: rgba(2, 5, 9, 0.62);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-6px, -50%);
  transition: opacity 0.3s var(--ease-out), transform 0.45s var(--ease-out);
  pointer-events: none;
}

.hero__hotspot-label svg { width: 8px; height: 8px; }

.hero__hotspot:hover::before,
.hero__hotspot:focus-visible::before { opacity: 1; transform: scale(1); }

.hero__hotspot:hover .hero__hotspot-label,
.hero__hotspot:focus-visible .hero__hotspot-label { opacity: 1; transform: translate(0, -50%); }

.hero__hotspot:focus-visible { outline: none; }

/* No hover on touch screens: keep a quiet pulse on the mug as the invitation. */
@media (hover: none) {
  .hero__hotspot::before { opacity: 0.55; transform: scale(1); animation: hotspot 2.4s var(--ease-out) infinite; }
}

@keyframes hotspot {
  0%   { box-shadow: 0 0 0 0 rgba(233, 162, 125, 0.4); }
  70%  { box-shadow: 0 0 0 14px rgba(233, 162, 125, 0); }
  100% { box-shadow: 0 0 0 0 rgba(233, 162, 125, 0); }
}

.hero.is-playing .hero__hotspot { opacity: 0; pointer-events: none; transition: opacity 0.2s linear; }

/* ── Atmosphere ── */

.hero__light {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background: radial-gradient(
    circle 34vmax at var(--lx, 50%) var(--ly, 40%),
    rgba(150, 170, 205, 0.075),
    rgba(150, 170, 205, 0.025) 45%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 1.2s var(--ease-out);
}

.hero.is-engaged .hero__light { opacity: 1; }

.hero__grain {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(6) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -4%); }
  60%  { transform: translate(-4%, -1%); }
  80%  { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* ── Chrome ── */

.hero__top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(var(--gutter), env(safe-area-inset-top)) var(--gutter) 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 1.2s var(--ease-out) 0.35s, transform 1.2s var(--ease-out) 0.35s;
}

.hero.is-plate .hero__top { opacity: 1; transform: none; }

.brand {
  margin: 0;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.links {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 24px);
  pointer-events: auto;
}

.links a {
  display: block;
  color: var(--ink);
  opacity: 0.78;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}

.links a:hover,
.links a:focus-visible { opacity: 1; transform: translateY(-1px); }

.links a:focus-visible { outline: 1px solid var(--ink-dim); outline-offset: 4px; border-radius: 4px; }

.links__logo img {
  display: block;
  height: 32px;
  width: auto;
  margin-right: clamp(4px, 1vw, 12px);
}

.links__icon svg {
  display: block;
  width: 22px;
  height: 22px;
}

.hero__loader {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 1px;
  margin-left: -36px;
  overflow: hidden;
  background: var(--ink-faint);
  transition: opacity 0.6s linear;
}

.hero__loader span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--ink);
  animation: load 1.1s var(--ease-out) infinite;
}

@keyframes load {
  from { transform: translateX(-100%); }
  to   { transform: translateX(260%); }
}

.hero.is-plate .hero__loader { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .hero__grain,
  .hero__loader span,
  .hero__hotspot::before { animation: none; }
}
