/* ============================================================
   PompomHub — Enhanced Mobile & Video Responsive Styles
   ============================================================ */

/* ---- Flexible Video Player (handles all aspect ratios) ---- */
.video-player-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* Standard landscape (16:9) */
.video-player-wrap.landscape-video,
.video-player-wrap:not([data-aspect-ratio]) {
  aspect-ratio: 16 / 9;
}

/* Portrait videos (9:16) */
.video-player-wrap.portrait-video {
  aspect-ratio: 9 / 16;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Square videos (1:1) */
.video-player-wrap.square-video {
  aspect-ratio: 1 / 1;
  max-width: 100%;
}

/* Cinema videos (21:9) */
.video-player-wrap.cinema-video {
  aspect-ratio: 21 / 9;
}

/* Responsive video player elements */
.video-player-wrap iframe,
.video-player-wrap video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  object-fit: contain;
}

.pompom-player-stage {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.pompom-player-stage iframe,
.pompom-player-stage video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  flex: 1;
  min-height: 0;
}

/* ---- Mobile Video Card Improvements ---- */
@media (max-width: 768px) {
  .video-card {
    display: flex;
    flex-direction: column;
    gap: 9px;
  }

  .video-card__thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: var(--bg3);
  }

  .video-card__title {
    font-size: 0.95rem;
    line-height: 1.3;
    -webkit-line-clamp: 2;
  }

  /* Better spacing on mobile */
  .video-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* ---- Mobile Header Optimization ---- */
@media (max-width: 640px) {
  .site-header {
    --header-h: 50px;
  }

  .site-header .container {
    gap: 8px;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    width: 40px;
    height: 40px;
    padding: 6px;
    justify-content: center;
    align-items: center;
  }

  .header-search {
    flex: 1;
    min-width: 100px;
  }

  .header-search input {
    font-size: 14px;
    padding: 8px 12px;
  }
}

/* ---- Mobile Sidebar ---- */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 100%;
    max-width: 320px;
    height: calc(100vh - var(--header-h));
    z-index: 1000;
    background: var(--bg2);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  #sidebar-overlay.visible {
    display: block;
  }
}

/* ---- Mobile Layout for Watch Page ---- */
@media (max-width: 1024px) {
  .watch-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .upnext-sidebar {
    max-width: 100%;
  }
}

/* ---- Improved Touch Targets ---- */
@media (max-width: 768px) {
  .action-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    min-height: 44px;
    min-width: 44px;
  }

  button, a.btn {
    min-height: 44px;
  }

  .category-chip {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 32px;
  }
}

/* ---- Form Elements Mobile ---- */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px;
    padding: 12px;
    border-radius: 8px;
  }

  textarea {
    min-height: 100px;
  }
}

/* ---- Video Info Mobile ---- */
@media (max-width: 640px) {
  .video-info h1 {
    font-size: 1.1rem;
    line-height: 1.3;
    margin-bottom: 12px;
  }

  .video-meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  .video-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .video-description {
    font-size: 0.85rem;
    padding: 12px;
    max-height: 100px;
  }
}

/* ---- Portrait Video Fullscreen Support ---- */
.video-player-wrap.portrait-video video {
  object-fit: contain;
}

.video-player-wrap.portrait-video video:fullscreen,
.video-player-wrap.portrait-video video:-webkit-full-screen,
.video-player-wrap.portrait-video video::-moz-full-screen {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- Comments Mobile ---- */
@media (max-width: 640px) {
  .comment-item {
    gap: 8px;
  }

  .comment-author {
    font-size: 0.8rem;
  }

  .comment-text {
    font-size: 0.8rem;
  }
}

/* ---- Up Next Mobile ---- */
@media (max-width: 768px) {
  .upnext-card {
    flex-direction: row;
    gap: 8px;
  }

  .upnext-card__thumb {
    width: 120px;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .upnext-card__title {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
  }
}

/* ---- Ad Blocker Modal Mobile ---- */
@media (max-width: 640px) {
  .pompom-adblock-notice__panel {
    width: 90vw;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    padding: 24px 16px !important;
  }

  .pompom-adblock-notice__panel h2 {
    font-size: 1.2rem;
  }

  .pompom-adblock-notice__actions {
    flex-direction: column;
    gap: 10px;
  }

  .pompom-adblock-notice__actions .btn {
    width: 100%;
  }
}

/* ---- Preroll Ad Mobile ---- */
@media (max-width: 640px) {
  .preroll-overlay {
    z-index: 1001;
  }

  .preroll-bar {
    padding: 8px 12px;
  }

  .preroll-skip {
    font-size: 0.85rem;
    padding: 6px 12px;
    min-height: 32px;
  }
}

/* ---- Horizontal Scrollable Lists ---- */
@media (max-width: 640px) {
  .video-tags {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    margin-bottom: 8px;
  }

  .video-tags::-webkit-scrollbar {
    height: 3px;
  }

  .video-tags::-webkit-scrollbar-track {
    background: var(--bg3);
    border-radius: 3px;
  }

  .video-tags::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
  }
}

/* ---- Container Padding Mobile ---- */
@media (max-width: 640px) {
  .container {
    padding: 0 12px;
  }

  main {
    padding: 12px 0;
  }
}

/* ---- Footer Mobile ---- */
@media (max-width: 768px) {
  .site-footer {
    padding: 24px 12px;
  }

  .footer-content {
    flex-direction: column;
    gap: 24px;
  }
}

/* ---- Landscape Orientation Improvements ---- */
@media (max-height: 500px) and (orientation: landscape) {
  .site-header {
    --header-h: 45px;
  }

  .video-info h1 {
    font-size: 1rem;
    margin-bottom: 8px;
  }

  .video-actions {
    gap: 4px;
    margin-top: 8px;
  }
}

/* ---- Loading States ---- */
.player-skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--border) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Improved Video Card Loading ---- */
.video-card__thumb--loading {
  background: var(--bg3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---- Better Text Rendering ---- */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ---- Smooth Scrolling ---- */
html {
  scroll-behavior: smooth;
}

/* ---- Reduced Motion Support ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Dark Mode Portrait Video ---- */
html.dark .video-player-wrap.portrait-video {
  background: #000;
  border: 1px solid var(--border);
}

/* ---- High DPI Screens ---- */
@media (min-resolution: 192dpi) {
  img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* ---- Landscape Tab Optimization ---- */
@media (max-width: 920px) and (max-height: 600px) {
  .watch-grid {
    grid-template-columns: 1fr 250px;
    gap: 12px;
  }

  .upnext-sidebar {
    max-width: 250px;
  }
}

/* ---- Very Small Phones ---- */
@media (max-width: 360px) {
  .container {
    padding: 0 8px;
  }

  .video-card__title {
    font-size: 0.85rem;
  }

  .action-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .video-info h1 {
    font-size: 0.95rem;
  }
}
