/* =====================================================================
   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; }
/* CSS fullscreen fallback (iOS while casting — see _enterFauxFs in player.js): fills the
   viewport WITHOUT the browser's real fullscreen, so the inline MSE video / AirPlay stream
   is never interrupted. object-fit:contain on the video letterboxes it correctly. */
.megu-player.mp-fauxfs {
  position: fixed; inset: 0; z-index: 2147483647;
  width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; aspect-ratio: auto;
}
.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; }
.mp-bigplay text { 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: flex; 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);
  opacity: 0; visibility: hidden; transform: translateY(8px); pointer-events: none;
  transition: opacity .45s ease, transform .45s ease, visibility .45s, background .15s;
}
.mp-skip:hover { background: var(--mp-accent); }
.mp-skip.show { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }

/* ---- 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: 30px 12px 8px;
  background: linear-gradient(to top, rgba(0,0,0,.9) 0%, rgba(0,0,0,.45) 50%, 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-accent2); 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 — flat icons, tightly spaced, subtle round hover (matches the reference bar) */
.mp-row { display: flex; align-items: center; gap: 1px; margin-top: 4px; }
.mp-btn {
  background: none; border: none; cursor: pointer; padding: 7px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  transition: background .12s, transform .1s;
}
.mp-btn:hover { background: rgba(255,255,255,.14); }
.mp-btn:active { transform: scale(.9); }
.mp-btn svg { width: 22px; height: 22px; 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; }

/* ---- Fullscreen: scale the control bar up a notch ----
   The bar is sized in fixed px for the inline player, so on a big fullscreen
   display it looks tiny. Bump icons / time / scrubber / padding for real
   fullscreen AND the iOS faux-fullscreen (mp-fauxfs). */
.megu-player.mp-fullscreen .mp-controls,
.megu-player.mp-fauxfs .mp-controls { padding: 40px 26px 16px; }
.megu-player.mp-fullscreen .mp-row,
.megu-player.mp-fauxfs .mp-row { gap: 3px; margin-top: 7px; }
.megu-player.mp-fullscreen .mp-btn,
.megu-player.mp-fauxfs .mp-btn { padding: 9px; }
.megu-player.mp-fullscreen .mp-btn svg,
.megu-player.mp-fauxfs .mp-btn svg { width: 29px; height: 29px; }
.megu-player.mp-fullscreen .mp-time,
.megu-player.mp-fauxfs .mp-time { font-size: 16px; margin: 0 9px; }
.megu-player.mp-fullscreen .mp-progress,
.megu-player.mp-fauxfs .mp-progress { height: 22px; }
.megu-player.mp-fullscreen .mp-track,
.megu-player.mp-fauxfs .mp-track { height: 5px; }
.megu-player.mp-fullscreen .mp-progress:hover .mp-track,
.megu-player.mp-fauxfs .mp-progress:hover .mp-track { height: 8px; }
.megu-player.mp-fullscreen .mp-thumb,
.megu-player.mp-fauxfs .mp-thumb { width: 17px; height: 17px; }
.megu-player.mp-fullscreen .mp-vol:hover .mp-vol-slider,
.megu-player.mp-fauxfs .mp-vol:hover .mp-vol-slider { width: 84px; height: 5px; }
.megu-player.mp-fullscreen .mp-badge,
.megu-player.mp-fauxfs .mp-badge { font-size: 9px; }
/* keep the settings/captions popups clear of the taller bar + match the scale */
.megu-player.mp-fullscreen .mp-menu,
.megu-player.mp-fauxfs .mp-menu { bottom: 74px; min-width: 200px; }
.megu-player.mp-fullscreen .mp-menu-item,
.megu-player.mp-fauxfs .mp-menu-item { font-size: 15px; padding: 9px 12px; }

/* ---- 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; }

/* ---- Nested settings menu (main list → boost/speed/quality/a11y sub-views) ---- */
.mp-menu-settings { min-width: 258px; padding: 6px; }
.mp-set-row, .mp-set-back {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 11px 12px; border-radius: 8px; background: none; border: none; cursor: pointer;
  color: var(--mp-text); font-size: 13.5px; font-weight: 600; text-align: left;
}
.mp-set-row:hover, .mp-set-back:hover { background: rgba(255,255,255,.08); }
.mp-set-lead { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.mp-set-ico { display: inline-flex; flex: none; }
.mp-set-ico svg { width: 18px; height: 18px; fill: #fff; }
.mp-set-trail { display: inline-flex; align-items: center; gap: 6px; }
.mp-set-val { opacity: .58; font-weight: 500; }
.mp-set-chev { display: inline-flex; opacity: .55; }
.mp-set-chev svg { width: 17px; height: 17px; fill: currentColor; }
.mp-set-back { border-bottom: 1px solid rgba(255,255,255,.09); border-radius: 0; margin-bottom: 4px; padding-bottom: 12px; font-weight: 700; }
.mp-set-backico svg { width: 20px; height: 20px; }
/* sliders (speed / volume boost) */
.mp-set-slider-wrap { padding: 8px 12px 14px; }
.mp-set-slabel { display: flex; justify-content: space-between; font-size: 12px; color: var(--mp-text); opacity: .68; margin-bottom: 12px; }
.mp-set-slider-row { display: flex; align-items: center; gap: 11px; }
.mp-set-sico { display: inline-flex; flex: none; }
.mp-set-sico svg { width: 18px; height: 18px; fill: #fff; opacity: .82; }
.mp-set-slider { -webkit-appearance: none; appearance: none; flex: 1; height: 4px; border-radius: 4px; background: rgba(255,255,255,.24); outline: none; cursor: pointer; margin: 0; }
.mp-set-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 15px; height: 15px; border-radius: 50%; background: #fff; cursor: pointer; }
.mp-set-slider::-moz-range-thumb { width: 15px; height: 15px; border: none; border-radius: 50%; background: #fff; cursor: pointer; }
/* Always-HD toggle */
.mp-set-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px; font-size: 13.5px; color: var(--mp-text); }
.mp-set-toggle { position: relative; width: 40px; height: 22px; border-radius: 999px; background: rgba(255,255,255,.24); border: none; cursor: pointer; padding: 0; transition: background .15s; flex: none; }
.mp-set-toggle.on { background: var(--mp-accent2); }
.mp-set-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.mp-set-toggle.on .mp-set-knob { transform: translateX(18px); }
/* quality list */
.mp-set-qitem { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border-radius: 8px; background: none; border: none; cursor: pointer; color: var(--mp-text); font-size: 13px; text-align: left; }
.mp-set-qitem:hover { background: rgba(255,255,255,.08); }
.mp-set-qitem.active { color: var(--mp-accent2); font-weight: 700; }
.mp-set-qtick { width: 16px; flex: none; display: inline-flex; }
.mp-set-qtick svg { width: 15px; height: 15px; fill: var(--mp-accent2); }
.mp-set-qname { flex: 1; }
.mp-set-qbr { opacity: .48; font-size: 11.5px; font-weight: 500; }

/* 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; }

/* ---- Captions (CC) popup ---- */
.mp-menu-cc { min-width: 244px; padding: 8px; }
.mp-cc-head { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 700; color: var(--mp-text); padding: 4px 8px 10px; }
.mp-cc-head .mp-set-ico svg { width: 17px; height: 17px; fill: #fff; }
.mp-cc-track { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border-radius: 8px; background: none; border: none; cursor: pointer; color: var(--mp-text); font-size: 13px; text-align: left; }
.mp-cc-track:hover { background: rgba(255,255,255,.08); }
.mp-cc-track.active { color: var(--mp-accent2); font-weight: 700; }
.mp-cc-tick { width: 15px; flex: none; display: inline-flex; }
.mp-cc-tick svg { width: 14px; height: 14px; fill: var(--mp-accent2); }
.mp-cc-div { height: 1px; background: rgba(255,255,255,.09); margin: 8px 4px; }
.mp-cc-lab { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--mp-text); opacity: .5; padding: 6px 10px 6px; }
.mp-cc-row { display: flex; gap: 6px; padding: 0 8px 8px; flex-wrap: wrap; }
.mp-cc-opt {
  flex: 1; min-width: 38px; padding: 7px 8px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 1.5px solid transparent;
  color: var(--mp-text); font-size: 12px; font-weight: 700; text-transform: capitalize;
  transition: background .12s, border-color .12s;
}
.mp-cc-opt:hover { background: rgba(255,255,255,.16); }
.mp-cc-opt.active { border-color: var(--mp-accent2); color: var(--mp-accent2); background: rgba(var(--accent-rgb),.14); }
.mp-cc-opt.sw { flex: 0 0 28px; min-width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.28); }
.mp-cc-opt.sw.active { border-color: var(--mp-accent2); box-shadow: 0 0 0 2px rgba(var(--accent-rgb),.5); }

/* ---- In-player server switcher (globe) — works in fullscreen ---- */
.mp-menu-srv { min-width: 224px; padding: 8px; }
.mp-srv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 11px; border-radius: 8px; background: none; border: none; cursor: pointer; color: var(--mp-text); font-size: 13px; font-weight: 600; text-align: left; }
.mp-srv-row:hover { background: rgba(255,255,255,.08); }
.mp-srv-row.active { color: var(--mp-accent2); }
.mp-srv-row.srv-megu .mp-srv-name { color: var(--mp-accent2); font-weight: 800; }
.mp-srv-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-srv-tags { display: inline-flex; align-items: center; gap: 7px; flex: none; }
.mp-srv-tags .mp-cc-tick svg { width: 14px; height: 14px; fill: var(--mp-accent2); }
.mp-srv-loading { display: flex; align-items: center; gap: 9px; padding: 10px 11px; color: var(--mp-text); opacity: .6; font-size: 12.5px; }
.mp-srv-spin { width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--mp-accent2); border-radius: 50%; animation: mp-spin .8s linear infinite; }

@media (max-width: 600px) {
  .mp-time { font-size: 11px; margin: 0 3px; }
  .mp-btn { padding: 6px; }
  .mp-btn svg { width: 20px; height: 20px; }
  .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)); }
}
@media (max-width: 480px) {
  /* Portrait phones: the control row has too many buttons for the width, so the
     rightmost one (Fullscreen) could clip off-screen. Tighten spacing and drop the
     redundant in-player volume (hardware buttons handle it) so Fullscreen always fits. */
  .mp-row { gap: 2px; }
  .mp-btn { padding: 5px; }
  .mp-vol { display: none; }
}
