/* ==========================================================================
 * lulu 剧集专页（列表 /series + 详情 /series/:id）
 * 移植自 k5u-mirror SeriesPage / SeriesDetailPage / VideoList / Pagination /
 * SectionLayout；去掉 data-v hash。变量映射到 tokens.css 的 --k-*。
 * ========================================================================== */

.series-page,
.video-player-page,
.series-detail,
.site-header--compact {
  --site-accent: var(--k-primary);
  --site-border: var(--k-border);
  --site-surface: var(--k-surface);
  --site-page-max-width: var(--k-page-max, 1180px);
  --vv-color-text: var(--k-text);
  --vv-color-muted: var(--k-text-muted);
  --vv-color-border: var(--k-border);
  --vv-color-surface: var(--k-surface);
  --vv-color-primary: var(--k-primary);
  --vv-color-background: var(--k-bg);
  --vv-radius-small: var(--k-radius-sm, 8px);
  --vv-radius-medium: var(--k-radius, 12px);
  --vv-space-1: 4px;
  --vv-space-2: 8px;
  --vv-space-3: 12px;
  --vv-space-4: 16px;
  --vv-space-5: 20px;
}

/* ---- series list + detail: undo #app-main --k-page-edge(17px) without touching shell/chrome.
 * Source 06/30 sit at 16px gutter on a 390 viewport (32px on 2x shots). Shell pads
 * #app-main 17px and .vv-page-layout adds another 16px, stacking wider than source.
 * Cancel the shell edge only while .series-page or .video-player-page is on the page;
 * keep the 16px page gutter. Do not change --k-page-edge itself. */
/* 顶栏背景铺满视口；内层与下方专页同一 --k-page-max 对齐。不改 chrome/shell。 */
#app-main:has(> .site-header--compact):has(.series-page),
#app-main:has(> .site-header--compact):has(.video-player-page) {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  box-sizing: border-box !important;
}

/* ---- page layout ---- */
.vv-page-layout {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--vv-page-layout-max-width, var(--site-page-max-width, 1180px));
  margin-inline: auto;
  padding-inline: var(--vv-page-layout-gutter, clamp(16px, 4vw, 32px));
  padding-block: var(--vv-page-layout-block-start, 24px) var(--vv-page-layout-block-end, 48px);
}

.vv-page-layout.site-header__inner {
  --vv-page-layout-block-start: 0px;
  --vv-page-layout-block-end: 0px;
}

.vv-stack-layout {
  display: flex;
  flex-direction: column;
  gap: var(--vv-stack-layout-gap, clamp(28px, 5vw, 56px));
  min-width: 0;
}

/* ---- compact header（对照 site-header__compact-bar）---- */
.site-header--compact {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  background: var(--k-surface, #151823);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom: 0;
}
html.light .site-header--compact {
  background: #fff;
}

.site-header__compact-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.site-header__compact-title {
  margin: 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--k-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-header__compact-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.site-header__compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--k-text);
  text-decoration: none;
  cursor: pointer;
}

.site-header__compact-button:hover {
  background: var(--k-tint, rgb(255 255 255 / 4%));
}

.site-header__compact-button svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ---- section layout ---- */
.vv-section-layout {
  display: grid;
  min-width: 0;
  gap: var(--vv-section-layout-gap, 20px);
}

.vv-section-layout__header {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--vv-section-layout-gap, 20px);
}

.vv-section-layout__heading {
  display: grid;
  min-width: 0;
  gap: var(--vv-section-layout-header-gap, 8px);
}

.vv-section-layout__eyebrow,
.vv-section-layout__description {
  color: var(--vv-color-muted);
}

.vv-section-layout__eyebrow {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.vv-section-layout__title {
  margin: 0;
  color: var(--vv-color-text);
  font: inherit;
  font-size: var(--vv-section-layout-title-size, clamp(1.25rem, 2vw, 1.75rem));
  font-weight: 700;
}

.vv-section-layout__content,
.vv-section-layout__footer {
  min-width: 0;
}

@media (max-width: 640px) {
  .vv-section-layout__header {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ---- series page ---- */
.series-page {
  --vv-page-layout-max-width: var(--site-page-max-width);
}

.series-page__search {
  display: flex;
  gap: 8px;
  align-items: center;
}

.series-page__search label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.series-page__search input {
  min-width: 0;
  flex: 1;
  padding: 12px;
  border: 1px solid var(--site-border);
  border-radius: 12px;
  color: var(--vv-color-text);
  background: var(--site-surface);
  font: inherit;
}

.series-page__search button {
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--site-accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.series-page__summary {
  margin-block: 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.series-page__summary h2 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.series-page__summary span {
  white-space: nowrap;
  color: var(--vv-color-muted);
}

.series-page__empty {
  grid-column: 1 / -1;
  margin: 24px 0;
  color: var(--vv-color-muted);
  text-align: center;
}

.series-page .vv-video-card {
  --vv-video-card-background: var(--site-surface);
  height: 100%;
  text-decoration: none;
}

.series-page .vv-video-card__tags {
  white-space: normal;
}

.series-page__ad-slot {
  margin-top: 24px;
}

/* ---- video list / cards ---- */
.vv-video-list {
  display: grid;
  gap: var(--vv-space-4);
  width: 100%;
  min-width: 0;
}

.vv-collection-layout--grid {
  display: grid;
  gap: var(--vv-collection-layout-gap, 14px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.series-page .vv-collection-layout--grid {
  /* 写死 2/3/4/6 列，避开 auto-fill 的 5 列；与 per_page=24 整除 */
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 521px) {
  .series-page .vv-collection-layout--grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 700px) {
  .series-page .vv-collection-layout--grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .series-page .vv-collection-layout--grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.vv-collection-layout__item {
  min-width: 0;
}

.vv-video-card {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--vv-video-card-radius, var(--vv-radius-medium));
  background: var(--vv-video-card-background, var(--vv-color-surface));
  color: var(--vv-video-card-color, var(--vv-color-text));
  box-shadow: var(--vv-video-card-shadow, 0 1px 2px rgba(15, 23, 42, .08));
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
  appearance: none;
}

.vv-video-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--vv-color-primary) 45%, transparent);
  outline-offset: 3px;
}

.vv-video-card__cover {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--vv-video-card-aspect-ratio, var(--k-cover-ratio, 16 / 9));
  overflow: hidden;
  background: color-mix(in srgb, var(--vv-color-muted) 12%, transparent);
}

.vv-video-card__cover .vv-image {
  display: block;
  width: 100%;
  height: 100%;
}

.vv-image__element {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vv-video-card__category,
.vv-video-card__score {
  position: absolute;
  top: var(--vv-space-2);
  z-index: 1;
  max-width: calc(100% - var(--vv-space-5));
  padding: 3px 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #0f172ab8;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.vv-video-card__category {
  inset-inline-start: var(--vv-space-2);
}

.vv-video-card__body {
  display: grid;
  gap: var(--vv-space-2);
  min-width: 0;
  padding: var(--vv-video-card-padding, var(--vv-space-3));
}

.vv-video-card__title {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  font-size: var(--vv-video-card-title-size, .95rem);
  font-weight: 650;
  line-height: 1.45;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--vv-video-card-title-lines, 2);
}

.vv-video-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--vv-space-2);
  min-width: 0;
  color: var(--vv-video-card-muted, var(--vv-color-muted));
  font-size: 12px;
  line-height: 1.4;
}

.vv-video-card__tags {
  display: flex;
  gap: var(--vv-space-1);
  min-width: 0;
  overflow: hidden;
}

.vv-video-card__tag {
  padding: 2px 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--vv-color-primary) 8%, transparent);
  color: var(--vv-video-card-tag-color, var(--vv-color-primary));
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) {
  .vv-video-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--vv-video-card-hover-shadow, 0 10px 24px rgba(15, 23, 42, .12));
  }
}

@media (prefers-reduced-motion: reduce) {
  .vv-video-card {
    transition: none;
  }
}

/* ---- pagination ---- */
.vv-pagination {
  --vv-pagination-height: 38px;
  --vv-pagination-gap: var(--vv-space-3);
  --vv-pagination-button-padding: var(--vv-space-4);
  --vv-pagination-page-width: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--vv-pagination-gap);
  width: 100%;
  margin-top: 20px;
  font-variant-numeric: tabular-nums;
}

.vv-pagination__button,
.vv-pagination__page {
  height: var(--vv-pagination-height);
  border: 1px solid var(--vv-color-border);
  border-radius: var(--vv-radius-small);
  background: var(--vv-color-surface);
  color: var(--vv-color-text);
  font: inherit;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, color .16s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.vv-pagination__button {
  min-width: 76px;
  padding-inline: var(--vv-pagination-button-padding);
  font-weight: 650;
}

.vv-pagination__page {
  gap: 6px;
  width: var(--vv-pagination-page-width);
  padding-inline: var(--vv-space-2);
  color: var(--vv-color-primary);
  font-weight: 700;
}

.vv-pagination__page--static {
  cursor: default;
}

.vv-pagination__button:disabled,
.vv-pagination__page:disabled {
  cursor: not-allowed;
  opacity: .46;
}

.vv-pagination__button:hover:not(:disabled),
a.vv-pagination__button:hover {
  border-color: var(--vv-color-primary);
  background: color-mix(in srgb, var(--vv-color-primary) 7%, var(--vv-color-surface));
  color: var(--vv-color-primary);
}

@media (max-width: 520px) {
  .vv-pagination {
    --vv-pagination-height: 36px;
    --vv-pagination-gap: var(--vv-space-2);
    --vv-pagination-button-padding: var(--vv-space-3);
    --vv-pagination-page-width: 78px;
  }

  .vv-pagination__button {
    min-width: 66px;
  }
}

/* ---- detail / player ---- */
.video-player-page {
  --vv-page-layout-gutter: clamp(16px, 4vw, 32px);
  --vv-page-layout-block-start: clamp(20px, 4vw, 48px);
  --vv-page-layout-block-end: 72px;
  width: 100%;
  max-width: var(--site-page-max-width, 1180px);
  margin-inline: auto;
  padding-inline: var(--vv-page-layout-gutter, clamp(16px, 4vw, 32px));
  box-sizing: border-box;
}

.video-player-page__player-shell {
  width: 100%;
  min-width: 0;
}

.vv-video-player {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}

.vv-video-player .k-apt,
.vv-video-player__artplayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* player-art.css 窄屏给 .k-apt 的负 margin 会在 overflow:hidden 圆角壳里切掉左侧通知/播放钮 */
  margin: 0;
  margin-inline: 0;
}

.vv-video-player .k-apt__mount {
  width: 100%;
  height: 100%;
}

.vv-video-player__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.vv-video-player__poster {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #111;
}

.vv-video-player__poster--empty {
  background: linear-gradient(160deg, #1a1e2b, #0c0e15);
}

.vv-video-player__playhint {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: rgb(0 0 0 / 45%);
  color: #fff;
}

/* ---- horizontal ads ---- */
.series-detail__ads,
.vv-ad-horizontal {
  min-width: 0;
}

.vv-horizontal-scroller {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.vv-horizontal-scroller__track,
.vv-collection-layout--row {
  display: flex;
  gap: 12px;
  width: max-content;
  padding-block: 2px;
}

.vv-ad-horizontal__item {
  flex: 0 0 auto;
  width: 96px;
}

.vv-ad-card {
  display: grid;
  gap: 6px;
  margin: 0;
}

.vv-ad-card__action {
  display: grid;
  gap: 6px;
  color: inherit;
  text-decoration: none;
}

.vv-ad-card__media {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 12px;
  background: color-mix(in srgb, var(--vv-color-muted) 14%, transparent);
}

.vv-ad-card__badge {
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgb(15 23 42 / 72%);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
}

.vv-ad-card__title {
  display: block;
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--vv-color-text);
}

.vv-ad-card--placeholder .vv-ad-card__media {
  min-height: 96px;
}

/* ---- series detail ---- */
.series-detail {
  padding: 24px 0 40px;
  color: var(--vv-color-text);
}

.series-detail__back {
  display: inline-block;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--site-accent);
  text-decoration: none;
  padding-inline: 0;
  font: inherit;
  cursor: pointer;
}

.series-detail__heading {
  margin: 12px 0 24px;
}

.series-detail__heading h1 {
  margin: 0 0 12px;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.series-detail__heading p {
  color: var(--vv-color-muted);
  line-height: 1.7;
}

.series-detail__intro summary {
  cursor: pointer;
}

.series-detail__intro p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.series-detail__controls,
.series-detail__pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.series-detail button,
.series-detail select,
.series-detail__controls a,
.series-detail__episodes a {
  border: 1px solid var(--site-border);
  border-radius: 10px;
  padding: 12px 16px;
  color: inherit;
  background: var(--site-surface);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
}

.series-detail button:disabled,
.series-detail select:disabled {
  opacity: .4;
  cursor: default;
}

.series-detail__controls a,
.series-detail__controls button {
  min-width: 88px;
}

.series-detail__episode-title {
  color: var(--vv-color-muted);
  text-align: center;
}

.series-detail__episodes-title {
  font-size: 18px;
  margin: 24px 0 16px;
}

.series-detail__episodes-title span {
  font-size: 14px;
  color: var(--vv-color-muted);
}

.series-detail__episodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.series-detail__episodes a,
.series-detail__episodes button {
  padding: 12px 6px;
  overflow-wrap: anywhere;
}

.series-detail__episodes .is-selected {
  border-color: var(--site-accent);
  background: var(--site-accent);
  color: #fff;
}

.series-detail__episodes-empty {
  color: var(--vv-color-muted);
  grid-column: 1 / -1;
}

/* ---- leftover slot shell (empty companion config does not render a block) ---- */
.vv-ad-slot {
  min-height: 0;
}

.vv-ad-slot[data-size-preset="popup"] {
  /* 不再回落 banner1；空配置由模板省略整块 */
}

/* Review r2: private six-up icon carousel; no CMS or remote click-through dependency. */
[data-lulu-series-icons] { overflow: hidden; }
[data-lulu-series-icons] .vv-horizontal-scroller {
  width: 100%; container-type: inline-size;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  overscroll-behavior-x: contain; touch-action: pan-x pan-y;
}
[data-lulu-series-icons] .vv-horizontal-scroller::-webkit-scrollbar { display: none; }
[data-lulu-series-icons] .series-icon-loop {
  display: flex; width: max-content; gap: 8px;
  animation: series-icon-loop 90s linear infinite;
}
[data-lulu-series-icons] .series-icon-loop__group { display: flex; gap: 8px; width: max-content; }
[data-lulu-series-icons] .vv-ad-horizontal__item {
  /* Mirror: --vv-collection-layout-item-width: calc((100% - 40px) / 6). */
  width: calc((100cqw - 40px) / 6); flex: 0 0 auto;
  scroll-snap-align: start;
}
[data-lulu-series-icons] .vv-ad-card__media {
  aspect-ratio: 1; border: 1px solid var(--k-border);
  border-radius: 14px; background: var(--k-surface);
}
[data-lulu-series-icons] .vv-ad-card__image { display: block; width: 100%; height: 100%; }
[data-lulu-series-icons] .vv-ad-card__badge { display: none; } /* Mirror main CSS: body .vv-ad-card__badge */
[data-lulu-series-icons] .vv-ad-card__title { font-size: 10px; font-weight: 600; line-height: 1.4; text-align: center; }
[data-lulu-series-icons] .vv-ad-card__action { gap: 8px; cursor: grab; }
[data-lulu-series-icons]:hover .series-icon-loop,
[data-lulu-series-icons]:focus-within .series-icon-loop,
[data-lulu-series-icons]:active .series-icon-loop { animation-play-state: paused; }
@keyframes series-icon-loop { to { transform: translateX(calc(-50% - 4px)); } }
@media (prefers-reduced-motion: reduce) {
  [data-lulu-series-icons] .series-icon-loop { animation: none; }
  [data-lulu-series-icons] .series-icon-loop__group[aria-hidden] { display: none; }
}

[data-lulu-series-icons] .vv-ad-card {
  gap: 4px;
}
[data-lulu-series-icons] .vv-ad-card__media {
  width: 100%;
  /* keep square; with item calc((100cqw - 40px)/6) ≈ 53 → media ≈ 51 after borders */
  box-sizing: border-box;
}
[data-lulu-series-icons] .vv-ad-card__title {
  font-size: 10px;
  line-height: 1.4;
  max-height: 1.4em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ---- series detail: poster is the default visual; artplayer stays under until play ---- */
[data-lulu-series-player] {
  position: relative;
}
[data-lulu-series-player] .vv-video-player__artplayer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
[data-lulu-series-player].is-playing .vv-video-player__artplayer {
  position: relative;
  inset: auto;
  opacity: 1;
  pointer-events: auto;
  margin: 0;
  margin-inline: 0;
  width: 100%;
  max-width: 100%;
}
[data-lulu-series-player].is-playing [data-lulu-series-poster] {
  display: none;
}
[data-lulu-series-poster] {
  cursor: pointer;
}

/* list-page companion ads (empty config: block omitted in twig) */
.series-page__ads {
  margin-top: var(--vv-space-4, 16px);
  overflow: hidden;
}
.series-page__ads .vv-ad-horizontal {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.series-page__ads .vv-ad-horizontal__item {
  flex: 0 0 auto;
  width: calc((100% - 40px) / 6);
}
.series-page__ads .vv-ad-card__media {
  display: block;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--k-border);
}
.series-page__ads img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ads are real links now */
[data-lulu-series-icons] .vv-ad-card__action { cursor: pointer; }
