/* ═══════════════════════════════════════════════════
   Signvano phrases mirror — in-page translation widget
   Look & feel adapted from extension/content.css + player/player.css
   ═══════════════════════════════════════════════════ */

/* Clickable phrases */
section[aria-labelledby^="theme-"] li.sgv-phrase {
  cursor: pointer;
  position: relative;
  padding: 6px 10px 6px 30px;
  margin-left: -10px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
section[aria-labelledby^="theme-"] li.sgv-phrase::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0284c7;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 5v14l11-7z" fill="black"/></svg>') center / contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 5v14l11-7z" fill="black"/></svg>') center / contain no-repeat;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}
section[aria-labelledby^="theme-"] li.sgv-phrase:hover {
  background: rgba(2, 132, 199, 0.10);
}
section[aria-labelledby^="theme-"] li.sgv-phrase:hover::before {
  opacity: 1;
}
section[aria-labelledby^="theme-"] li.sgv-phrase.sgv-phrase--active {
  background: rgba(2, 132, 199, 0.16);
}

/* ───── Popup shell ─────
   Compact picture-in-picture size: fixed 340px was 68% width / 85% height
   of a phone viewport (and full-width under 420px). Must stay a small
   overlay, never dominate the page. */
.sgv-popup {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 264px;
  z-index: 2147483000;
  background: #CFE8FD;
  border-radius: 22px;
  box-shadow: 0 10px 32px rgba(11, 35, 56, 0.35);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0b2338;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sgv-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
}
.sgv-popup__title {
  font-size: 14px;
  font-weight: 600;
}
.sgv-popup__close {
  border: none;
  background: none;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b2338;
  font-size: 17px;
  line-height: 1;
  transition: background 0.15s;
}
.sgv-popup__close:hover { background: rgba(11, 35, 56, 0.1); }

.sgv-popup__text {
  padding: 0 14px 8px;
  font-size: 11.5px;
  line-height: 1.35;
  color: rgba(11, 35, 56, 0.75);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sgv-popup__stage {
  position: relative;
  margin: 0 10px;
  border-radius: 14px;
  overflow: hidden;
  background: #0b2338;
  /* Must equal the real clip aspect (all worker MP4s are 880×1024).
     A mismatched box letterboxes on iOS, which ignores object-fit: cover
     on <video> — the "video frame not reaching the edges" bug. */
  aspect-ratio: 880 / 1024;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sgv-popup__video {
  /* Absolute fill, not flex child: WebKit resolves height:100% inside a
     flex + aspect-ratio container against its own stretched size, leaving
     the stage taller than the video → dark bands (seen on iPhone).
     inset:0 makes bands geometrically impossible. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Custom minimal playback control: tap video = pause/play. Replaces native
   controls, whose iOS overlay (±10s, dark top bar) buried the tiny avatar. */
.sgv-popup__playbtn {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.sgv-popup__stage.sgv-stage--paused .sgv-popup__playbtn,
.sgv-popup__stage.sgv-stage--ended .sgv-popup__playbtn {
  opacity: 1;
  pointer-events: auto;
}

/* Spinner while generating */
.sgv-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sgv-spin 0.9s linear infinite;
}
@keyframes sgv-spin { to { transform: rotate(360deg); } }
.sgv-popup__status {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
}
.sgv-popup__error {
  padding: 16px;
  color: #b91c1c;
  font-size: 13px;
  text-align: center;
}

/* Captions: current word over the avatar video (from player.css) */
.sgv-captions {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-end;
  gap: 3px 8px;
  max-height: 44%;
  overflow: hidden;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 3;
}
.sgv-caption-word {
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  line-height: 1.3;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease;
}
.sgv-caption-word--active {
  color: #fff;
  font-weight: 700;
}

/* Stats bar under the video */
.sgv-popup__stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 8px 12px 12px;
  font-size: 11px;
  color: rgba(11, 35, 56, 0.75);
  min-height: 31px;
}
.sgv-popup__stats b { color: #0b2338; }

/* Phones: even smaller PiP in the corner — never full-width. */
@media (max-width: 480px) {
  .sgv-popup { right: 10px; bottom: 10px; width: min(60vw, 236px); }
  .sgv-popup__text { font-size: 11px; }
  .sgv-caption-word { font-size: 10px; }
}
/* Short landscape viewports: cap by height so the popup never overflows. */
@media (max-height: 560px) {
  .sgv-popup { width: 210px; }
}
