/* ===========================================================================
 * FlixHub — Anime experience styles (SCOPED)
 * ---------------------------------------------------------------------------
 * Everything here is namespaced under `.anime-watch` (watch page fork) or
 * `.anime-experience` (anime.html) or the `.aw-*` / `.axp-*` component classes.
 * None of these selectors touch movies.html, webseries.html, or the standard
 * watch flow, so the rest of FlixHub is guaranteed unaffected.
 * ======================================================================== */

:root {
  --aw-accent: #e50914;
  --aw-accent-2: #ff3b30;
  --aw-cyan: #38bdf8;
  --aw-panel: #0e1420;
  --aw-panel-2: #131b2b;
  --aw-line: rgba(255, 255, 255, 0.08);
  --aw-muted: #93a1b8;
}

/* ───────────────────────── Watch page: takeover ───────────────────────── */
.anime-watch .watch-hero {
  background: radial-gradient(circle at 15% 0%, rgba(56, 189, 248, 0.10), transparent 40rem),
    radial-gradient(circle at 85% 0%, rgba(229, 9, 20, 0.14), transparent 42rem),
    #060912;
}

#animeWatchRoot.hidden { display: none; }

.aw-stage {
  position: relative;
  padding: 1.25rem clamp(0.75rem, 2vw, 2.5rem) 2rem;
  max-width: 120rem;
  margin: 0 auto;
}
.aw-stage::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 22rem;
  background-image: linear-gradient(180deg, rgba(6, 9, 18, 0.6), #060912 92%), var(--anime-banner, none);
  background-size: cover;
  background-position: center 20%;
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
}
.aw-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 1280px) {
  .aw-grid { grid-template-columns: 260px minmax(0, 1fr); }
  .aw-related { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .aw-grid { grid-template-columns: 1fr; }
  .aw-eplist { order: 2; }
  .aw-main { order: 1; }
  .aw-related { order: 3; }
}

/* ── Episode sidebar ── */
.aw-eplist {
  background: linear-gradient(180deg, var(--aw-panel-2), var(--aw-panel));
  border: 1px solid var(--aw-line);
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 78vh;
}
.aw-eplist__head {
  padding: 0.85rem 0.85rem 0.65rem;
  border-bottom: 1px solid var(--aw-line);
  background: rgba(255, 255, 255, 0.02);
}
.aw-eplist__controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}
.aw-audio-seg {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--aw-line);
  border-radius: 0.6rem;
  padding: 2px;
}
.aw-audio-seg button {
  border: 0;
  background: transparent;
  color: var(--aw-muted);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 0.32rem 0.7rem;
  border-radius: 0.45rem;
  cursor: pointer;
  transition: 0.18s;
}
.aw-audio-seg button.active {
  background: linear-gradient(135deg, var(--aw-accent), var(--aw-accent-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(229, 9, 20, 0.35);
}
.aw-range__sel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--aw-line);
  color: #dbe4f0;
  font-weight: 700;
  font-size: 0.72rem;
  border-radius: 0.55rem;
  padding: 0.34rem 0.5rem;
  cursor: pointer;
  outline: none;
}
.aw-range__sel option { background: #0e1420; }
.aw-eplist__title {
  margin-top: 0.7rem;
  font-weight: 800;
  font-size: 0.85rem;
  color: #eaf0f8;
}
.aw-eplist__title i { color: var(--aw-accent); margin-right: 0.35rem; }
.aw-eplist__scroll {
  overflow-y: auto;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.aw-eplist__scroll::-webkit-scrollbar { width: 8px; }
.aw-eplist__scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }

.aw-ep {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: #c7d2e0;
  border-radius: 0.6rem;
  padding: 0.55rem 0.6rem;
  cursor: pointer;
  transition: 0.16s;
}
.aw-ep:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.aw-ep__num {
  flex: 0 0 auto;
  min-width: 1.9rem;
  text-align: center;
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--aw-muted);
}
.aw-ep__name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aw-ep__play { opacity: 0; color: var(--aw-accent); font-size: 0.72rem; transition: 0.16s; }
.aw-ep:hover .aw-ep__play { opacity: 1; }
.aw-ep.active {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.9), rgba(255, 59, 48, 0.85));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 20px rgba(229, 9, 20, 0.3);
}
.aw-ep.active .aw-ep__num { color: #fff; }
.aw-ep.active .aw-ep__play { opacity: 1; color: #fff; }
/* Dub-not-out-yet episodes: dimmed, small amber badge (still clickable → sub). */
.aw-ep--pending { opacity: 0.62; }
.aw-ep--pending .aw-ep__name { color: #9aa7b6; }
.aw-ep.active.aw-ep--pending { opacity: 1; }
.aw-ep__badge {
  flex: 0 0 auto;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.16rem 0.4rem;
  border-radius: 0.35rem;
  color: #ffcf8a;
  background: rgba(255, 176, 32, 0.14);
  border: 1px solid rgba(255, 176, 32, 0.32);
}
.aw-ep.active .aw-ep__badge { color: #fff; background: rgba(0, 0, 0, 0.28); border-color: rgba(255, 255, 255, 0.3); }

/* ── Player ── */
.aw-main { min-width: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.aw-player-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid var(--aw-line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}
.aw-player, .aw-player .art-video-player { width: 100%; height: 100%; }
.aw-iframe { width: 100%; height: 100%; border: 0; display: block; }
.aw-player__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #0b1120, #000);
  pointer-events: none;
}
.aw-player__loading.hidden { display: none; }
.aw-spin {
  width: 3rem; height: 3rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--aw-accent);
  animation: aw-spin 0.8s linear infinite;
}
.aw-fail { color: #ffd0d0; font-weight: 700; font-size: 0.9rem; padding: 1rem; text-align: center; }
@keyframes aw-spin { to { transform: rotate(360deg); } }

/* ── Control bar under player ── */
.aw-controlbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--aw-panel-2), var(--aw-panel));
  border: 1px solid var(--aw-line);
  border-radius: 0.85rem;
  padding: 0.5rem 0.65rem;
}
.aw-controlbar__left, .aw-controlbar__right { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.aw-cbtn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--aw-line);
  background: rgba(255, 255, 255, 0.04);
  color: #d7e0ec;
  font-weight: 700;
  font-size: 0.78rem;
  border-radius: 0.6rem;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  transition: 0.16s;
}
.aw-cbtn:hover { background: rgba(255, 255, 255, 0.09); color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.aw-cbtn i { color: var(--aw-accent); }
.aw-cbtn.on { background: rgba(229, 9, 20, 0.16); border-color: rgba(229, 9, 20, 0.5); color: #fff; }
.aw-cbtn.on i { color: #ffd166; }

/* ── Now-playing block ── */
.aw-nowplaying {
  display: flex;
  gap: 0.9rem;
  background: linear-gradient(180deg, var(--aw-panel-2), var(--aw-panel));
  border: 1px solid var(--aw-line);
  border-radius: 0.85rem;
  padding: 0.85rem;
}
.aw-nowplaying__poster img {
  width: 82px;
  height: 116px;
  object-fit: cover;
  border-radius: 0.55rem;
  border: 1px solid var(--aw-line);
  background: #0b1120;
}
.aw-nowplaying__meta { min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.aw-badge-anime {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--aw-accent), var(--aw-accent-2));
  color: #fff;
}
.aw-title { font-size: clamp(1.1rem, 2.4vw, 1.6rem); font-weight: 900; line-height: 1.15; color: #fff; }
.aw-submeta { display: flex; gap: 0.6rem; align-items: center; font-size: 0.8rem; color: var(--aw-muted); font-weight: 700; }
.aw-score { color: #ffd166; }
.aw-hint { font-size: 0.78rem; color: var(--aw-muted); line-height: 1.5; }
.aw-hint strong { color: #fff; }

/* ── Server rows ── */
.aw-servers {
  background: linear-gradient(180deg, var(--aw-panel-2), var(--aw-panel));
  border: 1px solid var(--aw-line);
  border-radius: 0.85rem;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.aw-servers__note { font-size: 0.76rem; color: var(--aw-muted); line-height: 1.5; }
.aw-servers__warn {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.45;
  color: #ffcf8a;
  background: rgba(255, 176, 32, 0.1);
  border: 1px solid rgba(255, 176, 32, 0.28);
  border-radius: 0.55rem;
  padding: 0.5rem 0.65rem;
}
.aw-servers__warn i { margin-top: 0.1rem; color: #ffb020; }
.aw-servers__row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 0.6rem;
  align-items: center;
}
/* Keep the SUB/DUB tag inline beside its chips on phones (never full-width). */
@media (max-width: 560px) { .aw-servers__row { grid-template-columns: auto minmax(0, 1fr); } }
.aw-servers__label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  color: #06121e;
}
.aw-servers__label.is-sub { background: #9fe6ff; }
.aw-servers__label.is-dub { background: #ffd59f; }
.aw-servers__chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.aw-server {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--aw-line);
  background: rgba(255, 255, 255, 0.05);
  color: #cdd7e5;
  font-weight: 700;
  font-size: 0.76rem;
  border-radius: 0.55rem;
  padding: 0.42rem 0.7rem;
  cursor: pointer;
  transition: 0.16s;
}
.aw-server i { font-size: 0.62rem; color: var(--aw-accent); }
.aw-server:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.aw-server.active {
  background: linear-gradient(135deg, var(--aw-accent), var(--aw-accent-2));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 16px rgba(229, 9, 20, 0.35);
}
.aw-server.active i { color: #fff; }

/* ── Related rail ── */
.aw-related {
  background: linear-gradient(180deg, var(--aw-panel-2), var(--aw-panel));
  border: 1px solid var(--aw-line);
  border-radius: 1rem;
  padding: 0.85rem;
}
.aw-related__title { font-size: 1rem; font-weight: 900; color: #fff; margin-bottom: 0.7rem; }
.aw-related__list { display: flex; flex-direction: column; gap: 0.5rem; }
@media (max-width: 1280px) {
  .aw-related__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
.aw-related__card {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.4rem;
  border-radius: 0.6rem;
  border: 1px solid transparent;
  transition: 0.16s;
}
.aw-related__card:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--aw-line); }
.aw-related__thumb {
  position: relative;
  flex: 0 0 auto;
  width: 46px; height: 66px;
  border-radius: 0.4rem;
  overflow: hidden;
  background: #0b1120;
}
.aw-related__card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.aw-related__rating {
  position: absolute;
  left: 3px; bottom: 3px;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 0.3rem;
  color: #ffd166;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
}
.aw-related__rating i { font-size: 0.55rem; }
.aw-related__info { min-width: 0; display: flex; flex-direction: column; }
.aw-related__info strong {
  font-size: 0.82rem; color: #eaf0f8; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aw-related__info small { font-size: 0.72rem; color: var(--aw-muted); }
.aw-empty { color: var(--aw-muted); font-size: 0.82rem; }

/* ── Lights-off (dim page, spotlight the player) ── */
body.anime-lights-off .watch-detail-card,
body.anime-lights-off aside,
body.anime-lights-off .site-footer,
body.anime-lights-off header { filter: brightness(0.35); transition: filter 0.25s; }
body.anime-lights-off .aw-player-shell { box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.82); }

.aw-player-shell--theater {
  position: fixed; inset: 0; z-index: 60; border-radius: 0; aspect-ratio: auto;
}

/* ─────────────────────── anime.html: browse polish ─────────────────────── */
.anime-experience .top10-card,
.anime-experience .media-card { scroll-margin-top: 6rem; }

/* Genre / format filter bar (added to anime.html) */
.axp-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1.5rem auto 0;
  max-width: 112rem;
  padding: 0 clamp(1rem, 2vw, 2.5rem);
}
.axp-chip {
  border: 1px solid var(--aw-line);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.16s;
  text-decoration: none;
}
.axp-chip:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.axp-chip.active {
  background: linear-gradient(135deg, var(--aw-accent), var(--aw-accent-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(229, 9, 20, 0.3);
}

/* Give the anime hero a slightly more "streaming site" feel */
.anime-experience .anime-hero {
  border-bottom: 1px solid var(--aw-line);
}
.anime-experience .anime-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 8rem;
  background: linear-gradient(180deg, transparent, #070b13);
  pointer-events: none;
}

/* ─────────────────────── Mobile watch layout (≤ 860px) ───────────────────────
   Goal: player + controls + compact server chips all fit inside one mobile
   viewport (≈100vh) so Sub/Dub switching never needs a scroll hunt. The server
   strip sits directly under the control bar (see injectShell markup) and shrinks
   its chips to token-sized pills here. Desktop is untouched. */
@media (max-width: 860px) {
  .aw-stage { padding-left: 0.6rem; padding-right: 0.6rem; }
  .aw-main { gap: 0.55rem; }

  /* Control bar: keep it one tidy row, icons stay, verbose labels drop out. */
  .aw-controlbar { padding: 0.4rem 0.5rem; gap: 0.35rem; }
  .aw-controlbar__left, .aw-controlbar__right { gap: 0.3rem; }
  .aw-cbtn { padding: 0.42rem 0.55rem; font-size: 0.74rem; }

  /* Servers panel: tighter, chips become compact pills that wrap nicely. */
  .aw-servers { padding: 0.6rem 0.65rem; gap: 0.5rem; }
  .aw-servers__note { font-size: 0.7rem; }
  /* Inline label + chips (auto-width tag), so SUB/DUB stays compact, not stacked. */
  .aw-servers__row { grid-template-columns: auto minmax(0, 1fr); gap: 0.45rem; align-items: start; }
  .aw-servers__label {
    font-size: 0.6rem;
    padding: 0.28rem 0.42rem;
    white-space: nowrap;
  }
  .aw-servers__chips { gap: 0.3rem; }
  .aw-server {
    font-size: 0.68rem;
    padding: 0.32rem 0.55rem;
    border-radius: 0.45rem;
  }
  .aw-server i { font-size: 0.55rem; }

  /* Now-playing shrinks so it isn't the thing that overflows the fold. */
  .aw-nowplaying { padding: 0.65rem; gap: 0.65rem; }
  .aw-nowplaying__poster img { width: 62px; height: 88px; }
  .aw-hint { font-size: 0.72rem; }
}

/* Phones: hide the control-button word labels, keep the glyphs. This is what
   lets Expand / Light / Auto Next / Prev / Next stay on a single row. */
@media (max-width: 560px) {
  .aw-cbtn__txt { display: none; }
  .aw-cbtn { padding: 0.5rem 0.6rem; }
  .aw-cbtn i { color: var(--aw-accent); font-size: 0.9rem; }
  /* Auto Next is the one action worth spelling out — keep its label. */
  #awAutoNext .aw-cbtn__txt { display: inline; }
  #awAutoNext { font-size: 0.72rem; }

  .aw-controlbar { justify-content: space-between; }
  .aw-servers__note { font-size: 0.68rem; line-height: 1.4; }
  .aw-server { font-size: 0.66rem; padding: 0.3rem 0.5rem; }
  .aw-ep__badge { font-size: 0.54rem; padding: 0.14rem 0.34rem; }
}
