/* YouTube View — no Shorts, resizable + flippable player */

.yv-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px max(20px, 6%) 60px;
}

.yv-head { margin-bottom: 28px; }

.yv-head h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  margin: 10px 0 8px;
}

.yv-sub {
  color: var(--muted);
  font-size: 15px;
  max-width: 620px;
  line-height: 1.6;
}

.yv-body {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
  align-items: start;
}

/* ---------- Browse ---------- */
.yv-browse { display: flex; flex-direction: column; gap: 16px; }

.yv-filter { font-size: 13px; color: var(--muted); margin-top: 4px; }
.yv-filter input { margin-right: 6px; accent-color: var(--accent); }

.yv-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 4px;
}

.yv-video {
  display: flex;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.yv-video:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.yv-video .yv-thumb {
  flex: 0 0 120px;
  width: 120px;
  height: 68px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

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

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

.yv-video .yv-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yv-video .yv-channel { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.yv-video .yv-meta { font-size: 11px; color: #6f6f6f; }

.yv-empty { text-align: center; color: var(--muted); padding: 20px; font-size: 14px; }

/* ---------- Player ---------- */
.yv-player-wrap { display: flex; flex-direction: column; gap: 16px; }

.yv-player-container {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* a fixed-position player must not be clipped by the rounded container */
.yv-player-container.fs-open { overflow: visible; border-color: transparent; }
.yv-player-container.resizing { user-select: none; }

#yv-player-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  color: var(--muted);
  text-align: center;
  padding: 40px;
}

.yv-placeholder-icon { font-size: 44px; margin-bottom: 12px; }
.yv-hint { font-size: 12px; color: #6f6f6f; margin-top: 6px; }

.yv-video-box {
  position: relative;
  width: 640px;
  max-width: 100%;
  height: 360px;
  min-width: 200px;
  min-height: 120px;
  margin: 0 auto;
  background: #000;
}

.yv-video-inner { width: 100%; height: 100%; }

.yv-video-inner iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
  display: block;
}

.yv-resize-handle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  background: var(--ink);
  color: #fff;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 20;
  opacity: 0.85;
}
.yv-resize-handle:hover { opacity: 1; }

.yv-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.yv-foot {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.hidden { display: none !important; }

/* =========================================================
   Mobile flip-fullscreen
   ========================================================= */
body.yv-fs-lock {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.yv-video-box.yv-fs {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 100000;
  margin: 0;
  border: 0;
  border-radius: 0;
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  transform: translate(-50%, -50%)
             translate(var(--fsx, 0px), var(--fsy, 0px))
             rotate(var(--fsr, 0deg));
  transition: none;
  touch-action: none;
  background: #000;
}

/* Portrait phone: flip 90° so the video is wide-side-up, filling the screen */
.yv-video-box.yv-fs.portrait {
  --fsr: 90deg;
  width: 100vh;
  height: 100vw;
  width: 100dvh;
  height: 100dvw;
}

.yv-video-box.yv-fs .yv-resize-handle { display: none; }

/* Drag handle — lives inside the rotated video, so it rides along */
.yv-fs-drag {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 30px;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  cursor: grab;
  touch-action: none;
  z-index: 30;
}
.yv-video-box.yv-fs .yv-fs-drag { display: flex; }
.yv-fs-drag:active { cursor: grabbing; }

/* Overlay controls, deliberately NOT rotated so they stay readable */
.yv-fs-ui {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 100001;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  pointer-events: none;
}
.yv-fs-ui.open { display: flex; }

.yv-fs-btn {
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 20, 20, 0.82);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s, transform 0.15s;
}
.yv-fs-btn:hover { background: rgba(40, 40, 40, 0.9); }
.yv-fs-btn:active { transform: scale(0.94); }

.yv-fs-close {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.5);
  color: #111;
}
.yv-fs-close:hover { background: #fff; }

.yv-fs-hint {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100001;
  pointer-events: none;
  display: none;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.yv-fs-hint.open { display: block; animation: yv-hint-fade 3.5s forwards; }

@keyframes yv-hint-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .yv-body { grid-template-columns: 1fr; }
  .yv-player-container { min-height: 220px; }
  .yv-video-box {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    min-height: 0;
  }
  .yv-results { max-height: 40vh; }
}
