/* =====================================================================
   MeguPlayer — custom HLS player, themed to MeguAnimes.
   Scoped under .megu-player so it can't leak into the rest of the site.
   ===================================================================== */
.megu-player {
  --mp-accent:  var(--accent);
  --mp-accent2: var(--accent2);
  --mp-gold:    #fbbf24;
  --mp-bg:      #000;
  --mp-text:    #e8e8e8;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--mp-bg);
  overflow: hidden;
  border-radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  color: var(--mp-text);
}
.megu-player.mp-fullscreen { border-radius: 0; }
.megu-player video {
  width: 100%; height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

/* Tap layer for play/pause toggle + double-tap seek */
.mp-tap { position: absolute; inset: 0; z-index: 2; cursor: pointer; }

/* ---- Center play / buffering ---- */
.mp-center {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.mp-bigplay {
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(var(--accent-rgb),.92);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  pointer-events: auto; cursor: pointer; border: none;
  transition: transform .15s, background .15s, opacity .2s;
}
.mp-bigplay:hover { transform: scale(1.07); background: var(--mp-accent2); }
.mp-bigplay svg { width: 26px; height: 26px; fill: #fff; }
.megu-player.mp-playing .mp-bigplay { opacity: 0; pointer-events: none; }

.mp-spinner {
  width: 46px; height: 46px;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: var(--mp-accent2);
  border-radius: 50%;
  animation: mp-spin .8s linear infinite;
  display: none;
}
.megu-player.mp-buffering .mp-spinner { display: block; }
.megu-player.mp-buffering .mp-bigplay { display: none; }
@keyframes mp-spin { to { transform: rotate(360deg); } }

/* ---- Error / message overlay ---- */
.mp-msg {
  position: absolute; inset: 0; z-index: 9;
  display: none; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center;
  background: rgba(7,4,15,.92); text-align: center; padding: 24px;
}
.megu-player.mp-error .mp-msg { display: flex; }
.mp-msg-icon { font-size: 40px; }
.mp-msg-text { font-size: 14px; color: var(--mp-text); max-width: 380px; line-height: 1.5; }
.mp-msg-btn {
  padding: 8px 20px; border-radius: 8px; border: 1px solid rgba(var(--accent-rgb),.4);
  background: rgba(var(--accent-rgb),.18); color: var(--mp-accent2);
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.mp-msg-btn:hover { background: rgba(var(--accent-rgb),.3); }

/* ---- Double-tap seek ripples ---- */
.mp-seekhint {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 4; display: none; align-items: center; gap: 4px;
  background: rgba(0,0,0,.45); color: #fff; padding: 14px 18px;
  border-radius: 50%; font-size: 12px; font-weight: 700;
}
.mp-seekhint.left  { left: 8%; }
.mp-seekhint.right { right: 8%; }
.mp-seekhint.show { display: flex; animation: mp-fade .6s ease forwards; }
@keyframes mp-fade { 0%{opacity:0;transform:translateY(-50%) scale(.8)} 30%{opacity:1} 100%{opacity:0} }

/* ---- Skip intro / outro ---- */
.mp-skip {
  position: absolute; right: 18px; bottom: 78px; z-index: 7;
  display: none; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px;
  background: rgba(20,20,20,.9); border: 1px solid var(--mp-accent);
  color: #fff; font-size: 13px; font-weight: 700; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .15s;
}
.mp-skip:hover { background: var(--mp-accent); }
.mp-skip.show { display: flex; }

/* ---- Up-next toast ---- */
.mp-nextcard {
  position: absolute; right: 18px; bottom: 78px; z-index: 7;
  display: none; flex-direction: column; gap: 8px;
  padding: 12px 14px; border-radius: 10px; min-width: 210px;
  background: rgba(20,20,20,.94); border: 1px solid var(--mp-accent);
  backdrop-filter: blur(6px);
}
.mp-nextcard.show { display: flex; }
.mp-nextcard .nx-label { font-size: 11px; color: var(--mp-text); opacity: .7; }
.mp-nextcard .nx-title { font-size: 13px; font-weight: 700; color: #fff; }
.mp-nextcard .nx-btns { display: flex; gap: 8px; }
.mp-nextcard button {
  flex: 1; padding: 7px; border-radius: 7px; border: none;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.mp-nextcard .nx-go { background: var(--mp-accent); color: #fff; }
.mp-nextcard .nx-go:hover { background: var(--mp-accent2); }
.mp-nextcard .nx-cancel { background: rgba(255,255,255,.1); color: var(--mp-text); }

/* ---- Controls bar ---- */
.mp-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 28px 14px 10px;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.4) 55%, transparent 100%);
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.megu-player.mp-show-ui .mp-controls { opacity: 1; pointer-events: auto; }
.megu-player.mp-show-ui { cursor: default; }
.megu-player:not(.mp-show-ui) { cursor: none; }

/* progress / scrubber */
.mp-progress { position: relative; height: 16px; display: flex; align-items: center; cursor: pointer; }
.mp-track { position: relative; width: 100%; height: 4px; border-radius: 4px; background: rgba(255,255,255,.25); transition: height .12s; }
.mp-progress:hover .mp-track { height: 6px; }
.mp-buffered { position: absolute; left: 0; top: 0; height: 100%; border-radius: 4px; background: rgba(255,255,255,.35); width: 0; }
.mp-played   { position: absolute; left: 0; top: 0; height: 100%; border-radius: 4px; background: var(--mp-accent2); width: 0; }
.mp-thumb {
  position: absolute; top: 50%; width: 13px; height: 13px; border-radius: 50%;
  background: var(--mp-gold); transform: translate(-50%, -50%) scale(0);
  transition: transform .12s; box-shadow: 0 0 6px rgba(0,0,0,.5);
}
.mp-progress:hover .mp-thumb { transform: translate(-50%, -50%) scale(1); }
/* intro/outro markers on the scrubber */
.mp-marker { position: absolute; top: 0; height: 100%; background: rgba(251,191,36,.55); }

.mp-hovertime {
  position: absolute; bottom: 18px; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; font-size: 11px; font-weight: 600;
  padding: 3px 7px; border-radius: 5px; pointer-events: none; display: none; white-space: nowrap;
}

/* button row */
.mp-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.mp-btn {
  background: none; border: none; cursor: pointer; padding: 6px;
  display: flex; align-items: center; justify-content: center; border-radius: 6px;
  transition: background .12s;
}
.mp-btn:hover { background: rgba(255,255,255,.12); }
.mp-btn svg { width: 21px; height: 21px; fill: #fff; }
/* cast/AirPlay button glows amber while connected to a TV */
.mp-cast.mp-active svg { fill: var(--mp-accent2); }
.mp-time { font-size: 12.5px; font-weight: 600; color: #fff; margin: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mp-time .sep { opacity: .55; margin: 0 3px; }
.mp-spacer { flex: 1; }

/* volume */
.mp-vol { display: flex; align-items: center; }
.mp-vol-slider {
  width: 0; opacity: 0; height: 4px; border-radius: 4px; margin-left: 2px;
  background: rgba(255,255,255,.3); cursor: pointer; transition: width .18s, opacity .18s;
  position: relative; overflow: hidden;
}
.mp-vol:hover .mp-vol-slider, .mp-vol-slider:focus-within { width: 64px; opacity: 1; }
.mp-vol-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--mp-accent2); width: 100%; }

/* badges (CC active, quality label) */
.mp-btn .mp-badge {
  position: absolute; transform: translate(14px, -10px);
  font-size: 8px; font-weight: 800; background: var(--mp-accent);
  color: #fff; padding: 1px 3px; border-radius: 3px;
}
.mp-btn { position: relative; }

/* ---- Popup menus (settings / captions) ---- */
.mp-menu {
  position: absolute; right: 12px; bottom: 60px; z-index: 8;
  min-width: 172px; max-width: calc(100% - 24px);
  max-height: calc(100% - 72px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: rgba(24,24,24,.97);
  border: 1px solid rgba(255,255,255,.1); border-radius: 10px;
  padding: 6px; display: none; box-shadow: 0 8px 28px rgba(0,0,0,.55);
}
.mp-menu.show { display: block; }
.mp-menu-title { font-size: 11px; color: var(--mp-text); opacity: .6; padding: 6px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }
.mp-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--mp-text);
  cursor: pointer; background: none; border: none; width: 100%; text-align: left;
}
.mp-menu-item:hover { background: rgba(255,255,255,.08); }
.mp-menu-item.active { color: var(--mp-accent2); font-weight: 700; }
.mp-menu-item .tick { width: 14px; }

/* captions render box */
.mp-cc {
  position: absolute; left: 0; right: 0; z-index: 3; bottom: 64px;
  text-align: center; pointer-events: none; padding: 0 8%;
  transition: bottom .2s;
}
.megu-player:not(.mp-show-ui) .mp-cc { bottom: 28px; }
.mp-cc span {
  display: inline;
  background: var(--mp-cc-bg, rgba(0,0,0,.72));
  color: var(--mp-cc-color, #fff);
  font-size: var(--mp-cc-size, clamp(14px, 2.4vw, 22px));
  text-shadow: var(--mp-cc-shadow, none);
  line-height: 1.4; padding: 2px 8px;
  border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.mp-cc:empty { display: none; }

/* subtitle-style options in the CC menu */
.mp-cc-row { display: flex; gap: 6px; padding: 4px 10px 8px; flex-wrap: wrap; }
.mp-cc-opt {
  flex: 1; min-width: 34px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 1px solid transparent;
  color: var(--mp-text); font-size: 12px; font-weight: 700; text-transform: capitalize;
}
.mp-cc-opt:hover { background: rgba(255,255,255,.16); }
.mp-cc-opt.active { border-color: var(--mp-accent2); color: var(--mp-accent2); }
.mp-cc-opt.sw { flex: 0 0 26px; min-width: 26px; height: 26px; padding: 0; border: 2px solid rgba(255,255,255,.25); }
.mp-cc-opt.sw.active { border-color: var(--mp-accent2); box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.4); }

@media (max-width: 600px) {
  .mp-time { font-size: 11px; margin: 0 3px; }
  .mp-btn svg { width: 19px; height: 19px; }
  .mp-skip, .mp-nextcard { right: 10px; bottom: 70px; }
  /* Keep the captions/settings popup within the player and scrollable, so the
     subtitle-language list is always reachable on small/portrait screens. */
  .mp-menu { right: 8px; bottom: 52px; max-height: min(60vh, calc(100% - 64px)); }
}
