/*
Theme Name: ViewTube
Theme URI: https://example.com/viewtube
Author: ViewTube Theme
Author URI: https://example.com
Description: A YouTube-inspired WordPress theme. SEO ready, mobile responsive, lightweight video portal theme with fake video player, random stats, and sidebar.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: viewtube
Tags: video, youtube, responsive, seo, custom-header, custom-logo, custom-menu, featured-images, threaded-comments, two-columns, right-sidebar
*/

/* =====================================================
   RESET & BASE
===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --yt-red: #ff0000;
  --yt-red-dark: #cc0000;
  --yt-black: #0f0f0f;
  --yt-dark: #181818;
  --yt-surface: #212121;
  --yt-border: #303030;
  --yt-text: #f1f1f1;
  --yt-muted: #aaaaaa;
  --yt-hover: #272727;
  --yt-white: #ffffff;
  --header-h: 56px;
  --sidebar-w: 300px;
  --radius: 12px;
  --radius-sm: 8px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--yt-black);
  color: var(--yt-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--yt-white); }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }

/* =====================================================
   SKIP LINK (Accessibility)
===================================================== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--yt-red);
  color: #fff;
  padding: 8px 16px;
  z-index: 9999;
  border-radius: 0 0 4px 0;
}
.skip-link:focus { top: 0; }

/* =====================================================
   HEADER
===================================================== */
#masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--yt-black);
  border-bottom: 1px solid var(--yt-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 1000;
}

.site-branding {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 130px;
}

.site-logo-icon {
  background: var(--yt-red);
  border-radius: 6px;
  width: 34px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.site-logo-icon svg { width: 20px; height: 14px; }

.site-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--yt-white);
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.site-title a { color: inherit; }

/* Search Bar */
.header-search {
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
}

.header-search form {
  display: flex;
  height: 36px;
}

.header-search input[type="search"] {
  flex: 1;
  background: var(--yt-black);
  border: 1px solid var(--yt-border);
  border-right: none;
  color: var(--yt-text);
  padding: 0 12px;
  font-size: 16px;
  outline: none;
  border-radius: 20px 0 0 20px;
}

.header-search input[type="search"]:focus {
  border-color: #1c62b9;
}

.header-search button[type="submit"] {
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-left: none;
  color: var(--yt-text);
  padding: 0 18px;
  cursor: pointer;
  border-radius: 0 20px 20px 0;
  font-size: 16px;
  transition: background 0.2s;
}

.header-search button[type="submit"]:hover { background: #3d3d3d; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-btn {
  background: none;
  border: none;
  color: var(--yt-text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.15s;
}

.header-btn:hover { background: var(--yt-hover); }

.sign-in-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #3ea6ff;
  color: #3ea6ff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.sign-in-btn:hover { background: rgba(62,166,255,0.1); }

/* =====================================================
   LAYOUT WRAPPER
===================================================== */
.site-body {
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* =====================================================
   SIDEBAR NAV (Left)
===================================================== */
#sidebar-nav {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: 240px;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--yt-black);
  padding: 12px 0;
  z-index: 900;
  scrollbar-width: thin;
  scrollbar-color: var(--yt-border) transparent;
}

#sidebar-nav::-webkit-scrollbar { width: 6px; }
#sidebar-nav::-webkit-scrollbar-thumb { background: var(--yt-border); border-radius: 3px; }

.nav-section { padding: 0 0 12px; border-bottom: 1px solid var(--yt-border); margin-bottom: 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  margin: 0 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  transition: background 0.15s;
  color: var(--yt-text);
}

.nav-item:hover { background: var(--yt-hover); }
.nav-item.active { background: var(--yt-hover); font-weight: 600; }
.nav-item svg, .nav-item .nav-icon { width: 22px; height: 22px; flex-shrink: 0; }

.nav-section-title {
  padding: 8px 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--yt-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* =====================================================
   MAIN CONTENT
===================================================== */
#primary {
  margin-left: 240px;
  padding: 24px 24px 40px;
  max-width: 1800px;
}

/* Home page has full width feed */
body.home #primary { padding: 24px 24px 40px; }

/* =====================================================
   VIDEO GRID (Home / Archive)
===================================================== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.video-card {
  cursor: pointer;
  transition: transform 0.1s;
}

.video-card:hover { transform: translateY(-2px); }

.video-thumb-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--yt-surface);
aspect-ratio: 16 / 9;
}

.video-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card:hover .video-thumb-wrap img { transform: scale(1.03); }

.video-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.85);
  color: var(--yt-white);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.video-card-meta {
  display: flex;
  gap: 12px;
  padding: 12px 0 4px;
}

.avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--yt-surface);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

.video-info { flex: 1; min-width: 0; }

.video-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--yt-white);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card-channel {
  font-size: 13px;
  color: var(--yt-muted);
  margin-top: 4px;
}

.video-card-stats {
  font-size: 13px;
  color: var(--yt-muted);
  margin-top: 2px;
}

/* =====================================================
   VIDEO SINGLE PAGE
===================================================== */
.single-video-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.video-main { flex: 1; min-width: 0; }

/* Fake Player */
.fake-player {
  position: relative;
  width: 100%;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  line-height: 0; /* collapse whitespace under img */
}

/* The featured image (from plugin or native WP) fills the player */
.fake-player-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

.fake-player:hover .fake-player-img { transform: scale(1.02); }

/* Fallback when no thumbnail is set */
.fake-player-no-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--yt-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  background: rgba(0,0,0,0.75);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  pointer-events: none;
}

.fake-player:hover .play-btn-overlay {
  background: var(--yt-red);
  transform: translate(-50%, -50%) scale(1.1);
}

.play-btn-overlay svg {
  width: 30px;
  height: 30px;
  fill: white;
  margin-left: 4px;
}

.player-controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 12px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 35%;
  background: var(--yt-red);
  border-radius: 2px;
  position: relative;
}

.progress-dot {
  position: absolute;
  right: -5px;
  top: -4px;
  width: 11px;
  height: 11px;
  background: var(--yt-red);
  border-radius: 50%;
}

.ctrl-time { color: #fff; font-size: 12px; white-space: nowrap; }

/* Video Title & Actions */
.video-title-wrap { margin-top: 12px; }

.video-single-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--yt-white);
}

.video-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.video-channel-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-md {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--yt-surface);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-md img { width: 100%; height: 100%; object-fit: cover; }

.channel-name {
  font-size: 14px;
  font-weight: 600;
}

.sub-count {
  font-size: 12px;
  color: var(--yt-muted);
}

.subscribe-btn {
  background: var(--yt-white);
  color: var(--yt-black);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.subscribe-btn:hover { background: #e5e5e5; }

.action-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

.action-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--yt-surface);
  border: none;
  color: var(--yt-text);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.action-pill:hover { background: #3d3d3d; }
.action-pill.like-pill { border-right: 1px solid var(--yt-border); border-radius: 20px 0 0 20px; }
.action-pill.dislike-pill { border-radius: 0 20px 20px 0; }
.like-dislike-group { display: flex; background: var(--yt-surface); border-radius: 20px; }

/* Video Description */
.video-description-box {
  background: var(--yt-surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.video-description-box .desc-meta {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

.video-description-box .desc-meta span { color: var(--yt-muted); font-weight: 400; margin-left: 8px; }

/* Comments */
.comments-section { margin-top: 24px; }
.comments-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

.comment-item {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.comment-body { flex: 1; }
.comment-author { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.comment-date { font-size: 12px; color: var(--yt-muted); margin-left: 8px; font-weight: 400; }
.comment-text { font-size: 14px; line-height: 1.5; }
.comment-actions { display: flex; gap: 12px; margin-top: 6px; }
.comment-like-btn {
  background: none;
  border: none;
  color: var(--yt-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}
.comment-like-btn:hover { color: var(--yt-text); }

/* =====================================================
   RIGHT SIDEBAR (Single Video)
===================================================== */
.video-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--yt-border);
}

.sidebar-video-card {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.sidebar-video-card:hover { background: var(--yt-hover); }

.sidebar-thumb {
  position: relative;
  width: 160px;
  flex-shrink: 0;
  aspect-ratio: 16/9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--yt-surface);
}

.sidebar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
}

.sidebar-info { flex: 1; min-width: 0; }

.sidebar-video-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--yt-white);
}

.sidebar-channel { font-size: 12px; color: var(--yt-muted); margin-top: 4px; }
.sidebar-stats { font-size: 12px; color: var(--yt-muted); }

/* =====================================================
   CATEGORY CHIPS
===================================================== */
.category-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: none;
}
.category-chips::-webkit-scrollbar { display: none; }

.cat-chip {
  background: var(--yt-surface);
  color: var(--yt-text);
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  text-decoration: none;
  display: inline-block;
}

.cat-chip:hover { background: var(--yt-text); color: var(--yt-black); }
.cat-chip.active { background: var(--yt-white); color: var(--yt-black); }

/* =====================================================
   PAGINATION
===================================================== */
.pagination {
  margin-top: 32px;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.page-numbers {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  color: var(--yt-text);
  font-weight: 500;
  transition: background 0.15s;
}

.page-numbers:hover { background: var(--yt-hover); }
.page-numbers.current { background: var(--yt-white); color: var(--yt-black); }

/* =====================================================
   FOOTER
===================================================== */
#colophon {
  margin-left: 240px;
  border-top: 1px solid var(--yt-border);
  padding: 24px;
  color: var(--yt-muted);
  font-size: 13px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 12px;
}

.footer-links a { color: var(--yt-muted); transition: color 0.15s; }
.footer-links a:hover { color: var(--yt-text); }

.footer-copy { color: var(--yt-muted); }

/* =====================================================
   WIDGETS (WP default widget areas)
===================================================== */
.widget { margin-bottom: 24px; }
.widget-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* =====================================================
   NO SIDEBAR PAGES
===================================================== */
body.page #primary,
body.search #primary {
  max-width: 960px;
  margin-left: 240px;
}

/* =====================================================
   SEARCH RESULTS
===================================================== */
.search-header { font-size: 18px; margin-bottom: 20px; color: var(--yt-muted); }
.search-header strong { color: var(--yt-white); }

/* =====================================================
   SCROLLBAR GLOBAL
===================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--yt-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* =====================================================
   MOBILE — Responsive
===================================================== */
@media (max-width: 1200px) {
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

@media (max-width: 1024px) {
  #sidebar-nav { display: none; }
  #primary { margin-left: 0; padding: 16px; }
  #colophon { margin-left: 0; }
  body.page #primary,
  body.search #primary { margin-left: 0; }
  .single-video-layout { flex-direction: column; }
  .video-sidebar { width: 100%; }
}

@media (max-width: 768px) {
  #masthead { padding: 0 12px; gap: 10px; }
  .site-branding { min-width: unset; }
  .header-search { max-width: 100%; }
  .sign-in-btn span { display: none; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .video-card-title { font-size: 13px; }
  .video-single-title { font-size: 17px; }
  .action-btns { flex-wrap: wrap; }
  .sidebar-thumb { width: 120px; }
}

@media (max-width: 480px) {
  .header-search { display: none; }
  #masthead { justify-content: space-between; }
  .video-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .video-card-meta { gap: 8px; }
  .avatar-sm { width: 28px; height: 28px; }
}

/* =====================================================
   PRINT
===================================================== */
@media print {
  #masthead, #sidebar-nav, .video-sidebar { display: none; }
  #primary { margin: 0; padding: 0; }
  body { background: #fff; color: #000; }
}

/* =====================================================
   REDUCED MOTION
===================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
