/* === PV:LAYOUT (flex two-column) === */
/* Left: console (brand, timer, game). Right: topbar, ad bars, main grid. Only grid scrolls. */

html, body {
  height: 100%;
  overflow: hidden;
}

#pv-page {
  min-height: 100vh;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #111;
}

#pv-layout {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  gap: 0;
}

#pv-console {
  flex: 0 0 260px;
  min-width: 260px;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0 16px 12px;
  border-right: 1px solid #1f1f1f;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Logo vertical position is controlled by #pv-console-brand in index.php (margin-top: 20px).
   Do not override it here or the logo moves up (layout_flex loads after inline styles). */

#pv-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#pv-topbar,
#pv-subbar,
.pv-adbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #0b0b0b;
  margin: 0;
  padding: 0;
}

/* DIAGNOSTIC: Previous fix wrongly set max-width:60% on #pv-topbar, which reduced WIDTH
   and compressed the 5-column grid (bunching, "All Videos" wrap, search stealing space).
   Correct fix: restore full width; reduce HEIGHT via smaller vertical padding. */
#pv-topbar {
  flex: 0 0 auto;
  border-bottom: 1px solid #1f1f1f;
  padding: 5px 16px;
  min-height: 0;
}

#pv-topbar-inner {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 3fr 1fr;
  align-items: center;
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  gap: 8px;
}

.pv-nav-item {
  display: flex;
  justify-content: center;
  align-items: center;
}

.pv-nav-item form {
  margin: 0;
}

.pv-search input {
  width: 100%;
  max-width: 640px;
  min-width: 200px;
  height: 30px;
  font-size: 15px;
  padding: 4px 10px;
  box-sizing: border-box;
  border-color: #e53935;
}

.pv-adbar {
  width: 100%;
  text-align: center;
  color: #777;
  font-size: 1.2em;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
  padding: 4px 0;
  margin: 0;
  flex: 0 0 auto;
}

#pv-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  margin-top: 0;
  padding-top: 0;
  padding: 0 16px 16px 16px;
  position: relative;
}

/* When overlay is open, hide feed header so it does not appear above the player. */
.pv-overlay-open #pv-feed-header {
  display: none;
}

/* Video overlay: starts exactly at top of content area (no gap above "← Back" bar). */
#pv-video-overlay {
  position: fixed;
  top: 100px;
  left: 260px;
  right: 0;
  bottom: 0;
  z-index: 99999;
  display: none;
}

/* Explicit backdrop: receives clicks outside the viewer window; closing is reliable. */
#pv-overlay-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

#pv-overlay-window {
  position: absolute;
  left: 1.5%;
  top: 0;
  width: 97%;
  height: 97%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: default;
  pointer-events: auto;
  background: #000;
}

#pv-overlay-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 0;
  flex-shrink: 0;
  background: #000;
}

#pv-overlay-back {
  color: #1da1ff;
  background: none;
  border: none;
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  line-height: 1.2;
}

#pv-overlay-meta {
  display: none;
}

#pv-overlay-title,
#pv-overlay-duration {
  display: none;
}

#pv-overlay-player {
  position: relative;
  width: 100%;
  flex: 0 0 79%;
  min-height: 0;
  overflow: hidden;
}

#pv-overlay-player::before {
  content: "";
  display: block;
  padding-top: 56.25%;
}

#pv-overlay-player iframe,
#pv-overlay-player video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

#pv-overlay-related {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#pv-overlay-related .video-card,
.video-card {
  flex: 0 0 150px;
  cursor: pointer;
}

/* Related card title: show full title, wrap as needed, no clipping */
#pv-overlay-related .video-card > div:last-child {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.25;
  display: block;
  max-height: none;
}

/* Netflix/YouTube-style fade mask at edges (visual only, no interaction blocking) */
#pv-overlay-related::before,
#pv-overlay-related::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  z-index: 2;
}

#pv-overlay-related::before {
  left: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0));
}

#pv-overlay-related::after {
  right: 0;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0));
}

#pv-main-inner {
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  #pv-layout {
    flex-direction: column;
  }

  #pv-console {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid #1f1f1f;
    padding: 16px;
  }
}
