/*
Theme Name: WPS Video Theme
Theme URI: https://example.com/wps-video-theme
Author: Your Name
Author URI: https://example.com
Description: 轻量级、响应式 WordPress 主题，专为 WP-Script 插件导入的视频内容设计，提供类似 TikTok 的竖屏滑动体验。
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wps-video-theme
Tags: custom-background, custom-logo, custom-menu, featured-images, full-width-template, theme-options, translation-ready, video, one-column, responsive-layout
*/

/* ==========================================================================
   CSS 变量 - 便于统一修改主题色与间距
   ========================================================================== */
:root {
  --wps-primary: #fe2c55;
  --wps-primary-dark: #d91a45;
  --wps-text: #161823;
  --wps-text-muted: #8a8a8a;
  --wps-bg: #0f0f0f;
  --wps-card-bg: #1a1a1a;
  --wps-overlay: rgba(0, 0, 0, 0.5);
  --wps-radius: 8px;
  --wps-spacing: 1rem;
  --wps-swipe-edge-width: 72px; /* 上下滑动切换区域宽度（左右边缘），越大越容易滑动切换 */
  --wps-player-controls-safe: 88px; /* 预留给播放器底部控件的安全距离，避免元信息遮挡进度条/按钮 */
}

/* ==========================================================================
   基础重置与排版
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
  color: var(--wps-text);
  background: var(--wps-bg);
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: var(--wps-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==========================================================================
   首页全屏竖屏 Swiper 容器
   ========================================================================== */
.wps-swiper-wrap {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 1;
  background: var(--wps-bg);
}

.wps-swiper {
  width: 100%;
  height: 100%;
  position: relative;
}

/* 右侧上下箭头与清屏按钮：用 bottom 定位在播放器控制区上方，不遮挡进度条/跳过广告 */
.wps-swiper-arrow {
  position: absolute;
  right: 12px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.wps-swiper-arrow:hover {
  background: var(--wps-primary);
}

.wps-swiper-arrow:active {
  transform: scale(0.95);
}

.wps-swiper-arrow {
  pointer-events: auto;
}

.wps-swiper-prev {
  bottom: calc(var(--wps-player-controls-safe) + 44px + 12px + 44px + 12px);
}

.wps-swiper-prev:hover {
  transform: scale(1.05);
}

.wps-swiper-next {
  bottom: calc(var(--wps-player-controls-safe) + 44px + 12px);
}

.wps-swiper-next:hover {
  transform: scale(1.05);
}

.wps-meta-toggle {
  position: absolute;
  bottom: calc(var(--wps-player-controls-safe) + 12px);
  right: 12px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: background 0.2s ease;
}

.wps-meta-toggle:hover {
  background: var(--wps-primary);
}

.wps-meta-toggle svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* 左右窄条：仅此区域响应上下滑动，底部留出空间避免挡住进度条和跳过广告按钮 */
.wps-swipe-edge {
  position: absolute;
  top: 0;
  bottom: var(--wps-player-controls-safe);
  width: var(--wps-swipe-edge-width);
  z-index: 15;
  pointer-events: auto;
}

.wps-swipe-edge-left {
  left: 0;
}

.wps-swipe-edge-right {
  right: 0;
}

@media (min-width: 600px) {
  :root {
    --wps-swipe-edge-width: 96px;
  }
}

@media (max-width: 420px) {
  :root {
    --wps-player-controls-safe: 96px;
  }
}

.wps-swiper .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

/* 每个视频 slide 内部结构 */
.wps-video-slide {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #000;
}

/* 缩略图占位 / 背景 */
.wps-video-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.wps-video-thumb.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.wps-video-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: var(--wps-card-bg);
  min-height: 100%;
}

/* iframe 播放器容器：显示时在缩略图之上、信息层之下 */
.wps-video-embed-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: none;
  background: #000;
  pointer-events: auto;
}

.wps-video-embed-wrap.is-visible {
  display: block;
}

/* 不设 pointer-events: none，中间区域可点按 iframe 内控件（播放/全屏/进度条/跳过广告）；滑动由左右窄条处理 */
.wps-video-embed-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  object-fit: cover;
}

/* 顶部 banner：高度受控，叠在页面上方，不挤占视频主视区 */
.wps-top-banner {
  position: fixed;
  top: 96px;
  left: 12px;
  right: 12px;
  z-index: 55;
  height: auto;
  aspect-ratio: 4 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.wps-top-banner a {
  display: block;
  width: 100%;
  height: 100%;
}

.wps-top-banner .wps-top-banner-swiper,
.wps-top-banner .swiper-wrapper,
.wps-top-banner .swiper-slide {
  width: 100%;
  height: 100%;
}

.wps-top-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wps-top-banner .wps-top-banner-pagination {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  z-index: 2;
  text-align: center;
}

.wps-top-banner .wps-top-banner-pagination .swiper-pagination-bullet {
  width: 6px;
  height: 6px;
  background: #000;
  opacity: 0.35;
  margin: 0 3px !important;
}

.wps-top-banner .wps-top-banner-pagination .swiper-pagination-bullet-active {
  opacity: 0.9;
}

@media (min-width: 768px) {
  .wps-top-banner {
    left: 16px;
    right: 16px;
    top: 100px;
  }
}

/* 播放按钮遮罩：置于最上层确保可点击，点击区域覆盖整屏 */
.wps-play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wps-overlay);
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.wps-play-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.wps-play-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--wps-primary);
  border: 4px solid rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  padding-left: 6px;
  box-shadow: 0 4px 20px rgba(254, 44, 85, 0.5);
  transition: transform 0.2s ease, background 0.2s ease;
}

.wps-play-overlay:hover .wps-play-btn {
  transform: scale(1.08);
  background: var(--wps-primary-dark);
}

/* 视频元信息：无蒙层，仅底部展示；右侧留空避免与滑动区重叠 */
.wps-video-meta {
  position: absolute;
  bottom: var(--wps-player-controls-safe);
  left: 0;
  right: 0;
  z-index: 5;
  padding: 24px 16px 12px;
  padding-right: calc(var(--wps-swipe-edge-width) + 12px);
  color: #fff;
  pointer-events: none;
}

.wps-video-meta .wps-meta-content {
  pointer-events: auto;
}

.wps-video-meta.is-clear-screen .wps-meta-content {
  display: none;
}


/* 标题：单行截断，超出显示 ... */
.wps-video-meta .wps-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wps-video-meta .wps-stats {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
}

.wps-video-meta .wps-stats span {
  margin-right: 12px;
}

/* 视频底部标签：最多 3 行，无省略号，末尾放 "+" 按钮 */
.wps-video-meta .wps-video-terms-wrap {
  margin-top: 8px;
  pointer-events: auto;
  position: relative;
  min-height: 2.25em;
}

.wps-video-meta .wps-video-terms {
  line-height: 1.5;
  max-height: 5em;
  overflow: hidden;
  padding-right: 40px;
}

.wps-video-meta .wps-video-terms.is-expanded {
  max-height: none;
  overflow: visible;
  padding-right: 40px;
}

.wps-video-meta .wps-video-term-tag {
  display: inline-block;
  margin-right: 8px;
  margin-bottom: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: 0.8rem;
  color: #fff;
}

.wps-video-meta .wps-video-term-tag:hover {
  background: var(--wps-primary);
  color: #fff;
  text-decoration: none;
}

.wps-video-terms-toggle {
  display: none;
  position: absolute;
  bottom: 0;
  right: 0;
  padding: 4px 10px;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  border: none;
  min-width: 32px;
}

.wps-video-terms-wrap {
  display: block;
}

.wps-video-terms-toggle.is-visible {
  display: inline-block;
}

/* 展开时 "+" 变 "-"，位置保持右下角不变 */

.wps-video-terms-toggle:hover {
  color: #fff;
  background: var(--wps-primary);
}

/* 首页顶部筛选条（All + 分类/标签） */
.wps-filter-bar {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(8px);
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.wps-filter-bar::-webkit-scrollbar {
  height: 4px;
}

.wps-filter-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--wps-card-bg);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.wps-filter-chip:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
}

.wps-filter-chip.is-active {
  background: var(--wps-primary);
  color: #fff;
}

/* ==========================================================================
   单篇视频模板 single-videos.php
   ========================================================================== */
.wps-single-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--wps-spacing);
  padding-top: 2rem;
}

.wps-single-player {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  background: #000;
  border-radius: var(--wps-radius);
  margin-bottom: 1.5rem;
}

.wps-single-player iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.wps-single-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: #fff;
}

.wps-single-meta {
  font-size: 0.9rem;
  color: var(--wps-text-muted);
  margin-bottom: 1rem;
}

.wps-single-content {
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
}

.wps-single-content p {
  margin: 0 0 1rem;
}

.wps-taxonomy-links {
  margin-top: 1rem;
}

.wps-taxonomy-links a {
  display: inline-block;
  margin-right: 8px;
  margin-bottom: 8px;
  padding: 4px 12px;
  background: var(--wps-card-bg);
  border-radius: 20px;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
}

.wps-taxonomy-links a:hover {
  background: var(--wps-primary);
  color: #fff;
  text-decoration: none;
}

/* ==========================================================================
   归档页网格 archive-videos.php / taxonomy.php
   ========================================================================== */
.wps-archive-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--wps-spacing);
  padding-top: 2rem;
}

.wps-archive-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  color: #fff;
}

.wps-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

@media (min-width: 600px) {
  .wps-video-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }
}

.wps-video-card {
  display: block;
  position: relative;
  border-radius: var(--wps-radius);
  overflow: hidden;
  aspect-ratio: 9 / 16;
  background: var(--wps-card-bg);
}

.wps-video-card:hover {
  text-decoration: none;
}

.wps-video-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wps-video-card .wps-card-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

.wps-video-card .wps-card-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 8px 8px;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   站点头部导航（若使用菜单）
   ========================================================================== */
.wps-site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 12px 16px;
  background: rgba(15, 15, 15, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.wps-site-header .wps-nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wps-site-header .wps-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.5rem;
}

.wps-site-header .wps-menu a {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.wps-site-header .wps-menu a:hover {
  color: var(--wps-primary);
  text-decoration: none;
}

.wps-site-header .wps-site-name {
  font-weight: 700;
  font-size: 1.125rem;
  color: #fff;
}

.wps-site-header .wps-site-name:hover {
  color: var(--wps-primary);
  text-decoration: none;
}

.wps-site-header .custom-logo-link {
  display: inline-flex;
  align-items: center;
}

.wps-site-header .custom-logo {
  display: block;
  max-height: 36px;
  width: auto;
}

/* 首页全屏时给导航留出空间（可选：首页可隐藏导航） */
body.wps-front-page .wps-swiper-wrap {
  top: 0;
}

/* ==========================================================================
   页脚
   ========================================================================== */
.wps-site-footer {
  padding: 2rem var(--wps-spacing);
  text-align: center;
  color: var(--wps-text-muted);
  font-size: 0.875rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.wps-site-footer a {
  color: rgba(255, 255, 255, 0.7);
}

/* 首页全屏时隐藏页脚 */
body.wps-front-page .wps-site-footer {
  display: none;
}

/* 分页导航 */
.wps-archive-wrap .nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 2rem;
  padding: 1rem 0;
}

.wps-archive-wrap .nav-links a,
.wps-archive-wrap .nav-links .current {
  padding: 8px 14px;
  background: var(--wps-card-bg);
  border-radius: var(--wps-radius);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.wps-archive-wrap .nav-links a:hover {
  background: var(--wps-primary);
  color: #fff;
  text-decoration: none;
}

.wps-archive-wrap .nav-links .current {
  background: var(--wps-primary);
  color: #fff;
}

/* ==========================================================================
   登录/注册表单（邮箱+密码）
   ========================================================================== */
.wps-page-auth .wps-auth-page-wrap {
  padding: 2rem 1rem 4rem;
}

.wps-auth-wrap {
  max-width: 400px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--wps-card-bg);
  border-radius: var(--wps-radius);
  color: #fff;
}

.wps-auth-tabs {
  display: flex !important;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

.wps-auth-tab {
  display: block !important;
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1rem;
  cursor: pointer;
}

.wps-auth-tab.is-active {
  color: var(--wps-primary);
  font-weight: 600;
  background: transparent;
  border-bottom: 2px solid var(--wps-primary);
  margin-bottom: -2px;
}

.wps-auth-panel label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
}

.wps-auth-panel input[type="email"],
.wps-auth-panel input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 1rem;
  background: var(--wps-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
}

.wps-auth-panel .wps-auth-btn {
  width: 100%;
  padding: 12px;
  background: var(--wps-primary);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.wps-auth-panel .wps-auth-btn:hover {
  background: var(--wps-primary-dark);
}

.wps-auth-error {
  color: #ff6b6b;
  margin-bottom: 1rem;
  padding: 8px;
  background: rgba(255, 107, 107, 0.15);
  border-radius: 6px;
}

.wps-auth-success {
  color: #51cf66;
  margin-bottom: 1rem;
}

.wps-auth-notice {
  color: var(--wps-text-muted);
  margin-bottom: 1rem;
}

.wps-auth-logged-in a {
  color: var(--wps-primary);
}

.wps-menu-item.wps-auth-link {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.9);
}

.wps-menu-item.wps-auth-link:hover {
  color: var(--wps-primary);
  text-decoration: none;
}
