/* AEKE .sg — the two floating widgets: the need-help bubble and the video player.
 *
 * They share a file because they share the one thing that has to be decided jointly: the
 * corners they occupy. Two independently-placed fixed elements in the same corner is a
 * collision waiting to happen, and the fix belongs somewhere both can see.
 *
 * ## What is measured and what is not
 *
 * MEASURED on aeke.com's chat widget — its iframe frame:
 *
 *     position: fixed; inset: auto 20px 20px auto; z-index: 2147483647
 *
 * That is the whole of it. The widget's contents live in a cross-origin iframe on
 * `guest.herodash.ai`, so the bubble's colour, size and icon are not readable from the page.
 *
 * NOT MEASURED, and therefore a stated choice rather than a port: the floating player. The
 * Firework script loads but never renders here — `.cy-player` stays an empty 0-height div and
 * it is gated on consent/region. What is known is its *controls*, from the accessibility tree:
 * a region called "Picture in picture window" holding "Close picture in picture player",
 * a play/pause pair, and a slider called "Video progress". Those four are reproduced, with
 * those four names.
 *
 * The bubble takes the bottom-right corner, because that is where the live one measures itself
 * into. The player takes bottom-left, which is the conventional spot for this kind of UGC
 * widget and the only corner left. **Flagged as an inference, not a measurement.**
 */

.pip-player,
.chat-widget {
  position: fixed;
  bottom: 20px;
  z-index: 60;
}

/* ------------------------------------------------------------ floating video */

.pip-player {
  left: 20px;
  width: 200px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg-body-darken);
  box-shadow: 0 12px 34px rgba(var(--color-overlay-rgb), 0.45);
}

.pip-player[hidden] {
  display: none;
}

.pip-player__video {
  display: block;
  width: 100%;
  height: auto;
}

.pip-player__video[hidden] {
  display: none;
}

/* The controls sit over the foot of the clip: a scrim keeps them legible whatever the
   artwork behind them is doing. */
.pip-player__controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: linear-gradient(rgba(var(--color-overlay-rgb), 0), rgba(var(--color-overlay-rgb), 0.75));
}

.pip-player__frame {
  position: relative;
}

.pip-player__button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(var(--color-overlay-rgb), 0.45);
  color: var(--color-heading);
  cursor: pointer;
}

.pip-player__button svg {
  width: 13px;
  height: 13px;
}

/* The two glyphs ship and CSS picks one, so a toggle never rewrites markup. */
.pip-player__icon-pause,
.pip-player__icon-play {
  display: none;
}

[data-pip-play][aria-pressed="false"] .pip-player__icon-play,
[data-pip-play][aria-pressed="true"] .pip-player__icon-pause {
  display: block;
}

/* A native range input, so the slider is a slider for real: arrow keys, Home/End and
   assistive technology all work without a line of script. Upstream's has
   `role="slider"` on something hand-rolled. */
.pip-player__progress {
  flex: 1 1 auto;
  min-width: 0;
  height: 14px;
  margin: 0;
  appearance: none;
  background: none;
  cursor: pointer;
}

.pip-player__progress::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: rgba(var(--color-overlay-rgb), 0.5);
}

.pip-player__progress::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: rgba(var(--color-overlay-rgb), 0.5);
}

.pip-player__progress::-webkit-slider-thumb {
  width: 10px;
  height: 10px;
  margin-top: -3.5px;
  border: 0;
  border-radius: 50%;
  appearance: none;
  background: var(--color-heading);
}

.pip-player__progress::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 50%;
  background: var(--color-heading);
}

.pip-player__label {
  margin: 0;
  padding: 0 10px 10px;
  font-size: 0.75rem;
  color: var(--color-footer-link);
}

/* --------------------------------------------------------------- chat bubble */

.chat-widget {
  right: 20px;
}

.chat-widget__bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 10px 26px rgba(var(--color-overlay-rgb), 0.4);
  color: var(--color-heading);
  cursor: pointer;
}

.chat-widget__bubble svg {
  width: 24px;
  height: 24px;
}

.chat-widget__panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(320px, calc(100vw - 40px));
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-drawer-bg);
  box-shadow: 0 18px 44px rgba(var(--color-overlay-rgb), 0.5);
}

.chat-widget__panel[hidden] {
  display: none;
}

.chat-widget__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.chat-widget__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-heading);
}

.chat-widget__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--color-heading);
  cursor: pointer;
}

.chat-widget__close svg {
  width: 15px;
  height: 15px;
}

.chat-widget__routes {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.chat-widget__routes a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 8px;
  color: var(--color-footer-link);
  text-decoration: none;
}

.chat-widget__routes a:hover {
  background: var(--color-secondary-menu-bg);
}

.chat-widget__route-label {
  font-size: 0.6875rem;
  color: var(--color-footer-text);
}

.chat-widget__route-value {
  font-size: 0.875rem;
  color: var(--color-heading);
}

.chat-widget__bubble:focus-visible,
.chat-widget__close:focus-visible,
.pip-player__button:focus-visible,
.pip-player__progress:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Below 768 the player would cover most of a phone screen, so it goes — the same call the
   live page effectively makes by not showing it there. The bubble stays. */
@media (max-width: 47.99em) {
  .pip-player {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget__panel,
  .pip-player {
    transition: none;
  }
}
