/* HVO creator morph popup — carousel level-up Task 4 (2026-07-19).
   Spec: docs/specs/2026-07-19-carousel-levelup-design.md §4; plan Steps
   4.2–4.4b. A wheel card FLIP-morphs into this theme-aware squircle
   card: 16:9 mlplayer on top (video creators), identity row (48px
   avatar = the FLIP target, channel name, subs count-up), delivered-
   language flag chips, VIEW CHANNEL pill (GET STARTED fallback when a
   creator has no channelId). Backdrop = rgba dim +
   blur(8px) MAX (small-items ledger: 18px full-viewport over video
   janks the Studio Display; the hero is paused via HVOMediaBus anyway).
   Theme: light #fff / dark #232323 (dark surface hierarchy, README).
   z-order: layer 9990 · FLIP clone 9995 · mobile see-pill 9996 — all
   below the fx cursor dot (99999). */

/* ---- Layer (full viewport — blocks the wheel while open) ---- */
.hvo-popup-layer {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  /* safe-area padding (4.4b) — notched phones keep the card reachable */
  padding: max(24px, env(safe-area-inset-top))
           max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom))
           max(16px, env(safe-area-inset-left));
}

.hvo-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 16, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.hvo-popup-layer.is-opening .hvo-popup-backdrop,
.hvo-popup-layer.is-open .hvo-popup-backdrop { opacity: 1; }
.hvo-popup-layer.is-closing .hvo-popup-backdrop {
  opacity: 0;
  transition-duration: 0.32s;
}

/* ---- Card ---- */
.hvo-popup {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(920px, 92vw);
  max-height: 100%;
  overflow: hidden; /* body scrolls internally; X stays put */
  background: #fff;
  color: #131313;
  border-radius: 24px;
  corner-shape: squircle;
  box-shadow:
    0 24px 80px -24px rgba(9, 30, 60, 0.45),
    0 6px 24px -12px rgba(9, 30, 60, 0.3);
  opacity: 0;
  transition: opacity 0.42s cubic-bezier(0.2, 0.7, 0.15, 1);
}
.hvo-popup-layer.is-open .hvo-popup { opacity: 1; }
.hvo-popup-layer.is-closing .hvo-popup {
  opacity: 0;
  transition-duration: 0.32s;
}
html[data-theme="dark"] .hvo-popup {
  background: #232323; /* elevated-card level of the dark hierarchy */
  color: #fff;
  box-shadow:
    0 24px 80px -24px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset; /* hairline edge (README) */
}

/* ---- Close X (over the media in video popups — dark chip reads on
   both video frames and the identity-only card in either theme) ---- */
.hvo-popup_x {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10; /* above .mlp's z-index:5 (mlplayer.css) — 3 left the X unclickable under the player */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  transition: background 0.12s ease, transform 0.12s ease;
}
.hvo-popup_x:hover { background: rgba(0, 0, 0, 0.72); }
.hvo-popup_x:active { transform: scale(0.92); }
.hvo-popup_x:focus-visible {
  outline: 2px solid var(--base--green, #d6fd70);
  outline-offset: 2px;
}
.hvo-popup_x svg { width: 14px; height: 14px; }

/* ---- Media (16:9 mlplayer mounts here) ---- */
.hvo-popup_media {
  position: relative;
  flex-shrink: 0;
  background: #000;
}
.hvo-popup_media .mlp { width: 100%; margin: 0; }
.hvo-popup_media .mlp_frame { border-radius: 0; } /* popup owns corners */
/* the popup X occupies the frame's top-right — cap the top-left
   title+language stack (2026-07-20: label moved UNDER the title, so
   only the stack's width needs to clear the X now) */
.hvo-popup_media .mlp_topleft { max-width: calc(100% - 5rem); }

/* ---- Body: identity row + chips ---- */
.hvo-popup_body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 24px;
  overflow-y: auto; /* internal scroll at mobile sizes (4.4b) */
}

.hvo-popup_identity {
  display: flex;
  align-items: center;
  gap: 14px;
}
/* identity-only popups (video:null): no media band above, so the X
   shares the top edge with the identity row — reserve its corner */
.hvo-popup.is-plain .hvo-popup_identity {
  padding-right: 44px;
}
/* 48px avatar — the FLIP morph target (both directions). Same squircle
   language as the wheel cards so the clone lands seamlessly. */
.hvo-popup_avatar {
  display: block;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 18%;
  corner-shape: squircle;
  overflow: hidden;
  box-shadow:
    0 4px 10px -6px rgba(9, 30, 60, 0.2),
    0 14px 28px -14px rgba(9, 30, 60, 0.22);
}
.hvo-popup_avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hvo-popup_names { min-width: 0; }
.hvo-popup_channel {
  font-family: var(--_typography---font-family--headers, "Plus Jakarta Sans", sans-serif);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hvo-popup_subs {
  margin-top: 2px;
  font-family: var(--_typography---font-family--alternate, Geistmono, Arial, sans-serif);
  font-size: 0.8rem;
  color: rgba(19, 19, 19, 0.62);
}
.hvo-popup_subs .hvo-subs { font-weight: 600; color: #131313; }
html[data-theme="dark"] .hvo-popup_subs { color: rgba(255, 255, 255, 0.6); }
html[data-theme="dark"] .hvo-popup_subs .hvo-subs { color: #fff; }

/* CTA pill (VIEW CHANNEL → creator's YouTube; GET STARTED → pricing as
   the no-channelId fallback) — same treatment as the site's lime CTA
   pills; ↗ arrow per the reference */
.hvo-popup_cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
  padding: 0.6rem 1.2rem;
  border-radius: 5rem;
  background: var(--bg-color--bg-green, #d6fd70);
  color: var(--grey--grey-900, #191815) !important;
  font-family: var(--_typography---font-family--alternate, Geistmono, Arial, sans-serif);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hvo-popup_cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -8px rgba(160, 200, 40, 0.9);
}
.hvo-popup_cta:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ---- Flag chips: ALL delivered languages (creator.languages) ----
   grey-100/dark-soft surfaces; contrast-checked on #232323 (ledger). */
.hvo-popup_chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hvo-popup_chip {
  padding: 0.35rem 0.7rem;
  border-radius: 5rem;
  background: var(--grey--grey-100, #f2f2f2);
  color: var(--grey--grey-700, #2f2f2f);
  font-family: var(--_typography---font-family--alternate, Geistmono, Arial, sans-serif);
  font-size: 0.75rem;
  white-space: nowrap;
}
html[data-theme="dark"] .hvo-popup_chip {
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.88); /* ≥9:1 on #232323 */
}

/* ---- FLIP clone (card image morphing card-rect ⇄ 48px avatar) ----
   The site-wide dark rule `html[data-theme=dark] img` already applies
   brightness(.88) to this clone AND to the avatar target, so the seam
   matches in dark with no filter animation needed. */
.hvo-popup-flip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9995;
  object-fit: cover;
  border-radius: 18%;
  corner-shape: squircle;
  transform-origin: top left;
  pointer-events: none;
  will-change: transform;
  box-shadow:
    0 4px 10px -6px rgba(9, 30, 60, 0.2),
    0 14px 28px -14px rgba(9, 30, 60, 0.22);
}

/* ---- Source-card seam (60–90ms crossfade masks projection taper) ---- */
.img3d .hvo-card-fx.hvo-flip-fading {
  transition: opacity 80ms linear !important;
  opacity: 0;
}
.img3d .hvo-card-fx.hvo-flip-hidden {
  opacity: 0 !important;
  visibility: hidden;
  transition: none !important;
}

/* ---- Mobile "See {Name}" pill flash (~600ms, spec decision 4) ---- */
/* .hvo-see-flash removed 2026-08-28 with the touch "See {Name}" flash it
   styled. See the note in creator-popup.js. */

/* ---- Scroll lock (position:fixed pattern preserving scrollY — JS sets
   body.style.top = -scrollY) ---- */
body.hvo-scroll-lock {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

/* ---- Mobile layout ---- */
@media (max-width: 767px) {
  .hvo-popup { width: 100%; }
  /* the top-left stack + X share the top edge at 390px — keep the
     stack clear of the X (label lives under the title since
     2026-07-20, so there's no separate label rule anymore) */
  .hvo-popup_media .mlp_topleft { max-width: calc(100% - 4.2rem); }
  .hvo-popup_body { padding: 16px 16px 18px; gap: 12px; }
  .hvo-popup_identity { flex-wrap: wrap; }
  .hvo-popup_channel { font-size: 1.02rem; }
  .hvo-popup_cta {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
}

/* ---- Reduced motion: fades, not morphs (spec §5) ---- */
@media (prefers-reduced-motion: reduce) {
  .hvo-popup,
  .hvo-popup-backdrop {
    transition-duration: 0.2s !important;
  }
  .hvo-popup-flip { display: none; }
}
