/* ==========================================================================
   VIDPULSE - CLEAN & FULLY RESPONSIVE VIDEO SHARING PLATFORM
   Mobile: 1 Video Card Per Row (Full-width, highly visible, YouTube-style)
   Desktop: Clean Multi-column Grid
   Includes Display Ad Placements
   ========================================================================== */

:root {
  /* Brand Theme */
  --color-primary: #ff0000;
  --color-primary-hover: #cc0000;
  --color-accent: #38bdf8;
  
  /* Dark Mode Default */
  --bg-app: #0f0f12;
  --bg-surface: #18181f;
  --bg-surface-elevated: #23232d;
  --bg-surface-hover: #2b2b38;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;
  
  --border-subtle: #272733;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Light Theme */
[data-theme="light"] {
  --bg-app: #f9fafb;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f3f4f6;
  --bg-surface-hover: #e5e7eb;
  
  --text-main: #111827;
  --text-muted: #4b5563;
  --text-subtle: #9ca3af;
  
  --border-subtle: #e5e7eb;
  --border-focus: #2563eb;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Fluid Container */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

@media (max-width: 640px) {
  .container {
    padding: 0 0.85rem;
  }
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
  .app-header {
    padding: 0.6rem 0.85rem;
  }
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.brand-name span {
  color: var(--color-primary);
}

/* Desktop Search Box */
.header-search {
  flex: 1;
  max-width: 520px;
}

.search-form {
  display: flex;
  align-items: center;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.search-form:focus-within {
  border-color: var(--color-primary);
}

.search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.92rem;
  outline: none;
}

.search-btn {
  padding: 0.6rem 1.15rem;
  background-color: var(--bg-surface-hover);
  border-left: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background-color: var(--bg-surface-elevated);
  transition: background-color 0.2s ease;
}

.btn-icon:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .header-search {
    display: none;
  }
}

/* Mobile Search Bar below Header */
.mobile-search-bar {
  display: none;
  padding: 0.65rem 0.85rem 0.25rem;
}

@media (max-width: 640px) {
  .mobile-search-bar {
    display: block;
  }
}

/* ==========================================================================
   DISPLAY AD SLOTS
   ========================================================================== */
.ad-slot-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0.85rem auto;
  text-align: center;
  width: 100%;
}

.ad-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 0.25rem;
}

.ad-unit-container {
  min-width: 320px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  overflow: hidden;
}

/* ==========================================================================
   HOMEPAGE MAIN SECTION
   ========================================================================== */
.main-wrapper {
  flex: 1;
  padding: 0.75rem 0 3rem;
}

@media (max-width: 640px) {
  .main-wrapper {
    padding: 0.5rem 0 2rem;
  }
}

/* ==========================================================================
   VIDEO GRID LAYOUT
   Mobile (<640px): EXACTLY 1 VIDEO CARD PER ROW! Full visibility!
   Tablet (640px - 1000px): 2 or 3 columns
   Desktop (>1000px): 4 or 5 columns
   ========================================================================== */
.video-grid {
  display: grid;
  grid-template-columns: 1fr; /* 1 video card per row on mobile */
  gap: 1.35rem;
}

@media (min-width: 640px) {
  .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }
}

@media (min-width: 960px) {
  .video-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.35rem;
  }
}

@media (min-width: 1200px) {
  .video-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
  }
}

/* Video Card */
.video-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.video-card:hover,
.video-card:active {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: var(--shadow-md);
}

/* Thumbnail Area - Exact 16:9 Cinema Aspect Ratio */
.thumbnail-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #0b0b0e;
  overflow: hidden;
}

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

/* Center Play Button Overlay */
.play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.video-card:hover .play-overlay,
.video-card:active .play-overlay {
  background: rgba(0, 0, 0, 0.42);
}

.play-btn-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: background 0.15s ease;
}

@media (max-width: 640px) {
  .play-btn-circle {
    width: 48px;
    height: 48px;
  }
  .play-btn-circle svg {
    width: 24px !important;
    height: 24px !important;
  }
}

.video-card:hover .play-btn-circle {
  background: #ff0000;
}

.play-btn-circle svg {
  width: 24px;
  height: 24px;
  margin-left: 3px;
  fill: currentColor;
}

/* Duration Pill */
.duration-pill {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
  line-height: 1.1;
}

/* Video Details Below Thumbnail */
.video-content {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

@media (max-width: 640px) {
  .video-content {
    padding: 0.75rem 0.85rem;
  }
}

.video-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s ease;
}

@media (max-width: 640px) {
  .video-title {
    font-size: 0.95rem;
    line-height: 1.35;
    margin-bottom: 0.35rem;
  }
}

.video-card:hover .video-title {
  color: var(--color-primary);
}

.video-stats {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .video-stats {
    font-size: 0.78rem;
  }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.app-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 0 1.5rem;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 0.85rem;
  }
}

.footer-nav {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  font-size: 0.825rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}

.footer-nav a:hover {
  color: var(--color-primary);
}

.footer-copy {
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
  font-size: 0.78rem;
  color: var(--text-subtle);
  text-align: center;
}
