/* css/watch.css — pause strip + end overlay + iPad polish.
   Loaded after app.css so card/focus rules cascade through. */

/* ========== Pause strip — multi-row "down-recs" grid ==========
   Multiple horizontal rails stacked vertically. Each rail scrolls left/right
   independently; the rails container can scroll vertically if rows overflow.
   touch-action separates the gestures natively so swipes go to the right
   scroller (no JS arbitration needed). The strip sits ABOVE chrome-bottom
   so playback controls remain reachable while paused. */

.pause-strip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 88px;
  z-index: 115;
  padding: 8px 12px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(to top, rgba(0,0,0,0.92) 70%, rgba(0,0,0,0));
  transition: max-height var(--t-med) var(--ease);
}

/* PEEK — small teaser poking up from the bottom + bouncing up-arrow hint.
   DV presses UP (or taps it) to pull the full recs in. */
.pause-strip.is-peek {
  max-height: 200px;
  cursor: pointer;
  animation: peek-pop var(--t-med) var(--ease) both;
}
/* FULL — the whole "Up next" grid. Tall (82vh) so the rails feel like a real
   browse surface DV can scroll through, not a thin strip. */
.pause-strip.is-full {
  max-height: 82vh;
}

/* Close (✕) "keep watching" — exits the Up-next overlay and resumes the current
   video. Touch users had no obvious way back to the video after a peek-tap
   expanded the grid. Visible in FULL only. */
.strip-close {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 3;
  width: 48px;
  height: 48px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: var(--yt-text);
  cursor: pointer;
}
.pause-strip.is-full .strip-close { display: flex; }
.strip-close svg { width: 28px; height: 28px; }
.strip-close:focus,
.strip-close:focus-visible,
.strip-close.is-focused {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: 2px;
}

@keyframes peek-pop {
  0%   { transform: translateY(48px); opacity: 0; }
  72%  { transform: translateY(-6px); opacity: 1; }
  100% { transform: translateY(0);    opacity: 1; }
}

/* "Pull me up" hint — only in peek; gentle bounce. Stands in for the title. */
.peek-hint { display: none; }
.pause-strip.is-peek .peek-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--yt-text, #f1f1f1);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  margin-bottom: 4px;
  animation: peek-bounce 1.4s var(--ease) infinite;
}
.peek-hint svg { width: 22px; height: 22px; }
@keyframes peek-bounce {
  0%, 100% { transform: translateY(2px); }
  50%      { transform: translateY(-3px); }
}
.pause-strip.is-peek .strip-title { display: none; }
.pause-strip.is-full .peek-hint   { display: none; }

/* In peek, kill the inner vertical scroll so a drag-up EXPANDS (gesture handler)
   instead of scrolling inside the tiny teaser. Horizontal rail scroll stays. */
.pause-strip.is-peek .strip-rails { overflow-y: hidden; }

/* CLEAN paused frame — DV pauses to show us something: hide ALL overlays. JS
   removes the strip from the DOM; this guarantees the chrome is gone too. */
body.is-clean-paused .chrome {
  opacity: 0 !important;
  pointer-events: none;
}

.strip-title {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  color: var(--yt-text);
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  flex: 0 0 auto;
}

/* Outer container: vertical scroll when rails overflow. We rely on the
   browser's native gesture-axis detection rather than touch-action hints
   — iOS Safari's `touch-action: pan-x` on the inner rails was actively
   blocking vertical swipes (consuming them without bubbling). With no
   touch-action restriction, iOS picks the dominant swipe axis and routes
   it to whichever scroll container has overflow on that axis. */
.strip-rails {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;   /* iOS momentum scroll */
  overscroll-behavior: contain;        /* don't chain past strip into the page */
}
.strip-rails::-webkit-scrollbar { display: none; }

/* Each rail: horizontal scroll only (overflow-y: hidden so vertical swipes
   bubble up to the parent's overflow-y: auto). No touch-action override. */
.strip-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  align-items: flex-start;
  flex: 0 0 auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.strip-rail::-webkit-scrollbar { display: none; }

.strip-card {
  flex: 0 0 168px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-snap-align: start;
  text-decoration: none;
  color: inherit;
  outline: 0;
  border-radius: 4px;
  transition: transform var(--t-fast) var(--ease);
}
.strip-card:focus,
.strip-card:focus-visible,
.strip-card.is-focused {
  transform: scale(1.04);
}
.strip-card:focus .strip-thumb,
.strip-card:focus-visible .strip-thumb,
.strip-card.is-focused .strip-thumb {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: 2px;
}

.strip-thumb {
  position: relative;
  width: 168px;
  height: 94px;
  background: var(--yt-surface);
  border-radius: var(--thumb-radius);
  overflow: hidden;
  flex: 0 0 auto;
}
.strip-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 250ms ease;
}
.strip-thumb img.is-loaded { opacity: 1; }
.strip-duration {
  position: absolute;
  right: 4px;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--yt-text);
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 3px;
}
.strip-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 2px;
  flex: 0 0 auto;
}
.strip-card-title {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--yt-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 2px;
}
.strip-card-meta {
  font-size: 11px;
  color: var(--yt-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tablet: bigger cards, more breathing room. */
@media (min-width: 700px) {
  .pause-strip { padding: 10px 24px; }
  .strip-card  { flex: 0 0 260px; }
  .strip-thumb { width: 260px; height: 146px; }
  .strip-card-title { font-size: 15px; }
  .strip-card-meta  { font-size: 13px; }
}

/* Desktop / TV: even bigger cards, thicker rails.
   bottom: 120px reserves space for the taller desktop chrome-bottom
   (24px top pad + 48px button + 32px bottom pad ≈ 104 + safety margin). */
@media (min-width: 1100px) {
  .pause-strip {
    bottom: 120px;
    padding: 8px 32px 16px;
    max-height: 45vh;
  }
  .strip-title {
    font-size: var(--fs-card-title);
    margin-bottom: 12px;
  }
  .strip-rails { gap: 16px; }
  .strip-rail  { gap: 16px; }
  .strip-card  { flex: 0 0 280px; gap: 8px; }
  .strip-thumb { width: 280px; height: 158px; border-radius: var(--thumb-radius); }
  .strip-card-title { font-size: 16px; }
  .strip-card-meta  { font-size: 14px; }
}

/* ========== End-of-video overlay ========== */

.end-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--yt-bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: end-fade-in var(--t-med) var(--ease) both;
}

@keyframes end-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.end-inner {
  width: 100%;
  max-width: 1600px;
  padding: 0 64px;
}

.end-heading {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: var(--fs-h2);
  color: var(--yt-text);
  margin-bottom: 32px;
  letter-spacing: -0.5px;
}

.end-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.end-card {
  text-decoration: none;
  color: inherit;
  outline: 0;
  border-radius: var(--focus-radius);
  transition: transform var(--t-fast) var(--ease);
  display: flex;
  flex-direction: column;
}
.end-card-primary {
  grid-row: 1 / span 2;
}

.end-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--yt-surface);
  border-radius: var(--thumb-radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.end-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 250ms ease;
}
.end-thumb img.is-loaded { opacity: 1; }

.end-card:focus,
.end-card:focus-visible,
.end-card.is-focused { transform: scale(1.04); z-index: 2; }
.end-card:focus .end-thumb,
.end-card:focus-visible .end-thumb,
.end-card.is-focused .end-thumb {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: 2px;
}

.end-card-title {
  font-size: var(--fs-card-title);
  font-weight: 500;
  color: var(--yt-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.end-card-primary .end-card-title { font-size: 28px; }

.end-card-meta {
  font-size: var(--fs-card-meta);
  color: var(--yt-text-2);
}

/* Countdown ring on the primary card */
.countdown {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.countdown-track {
  fill: rgba(0, 0, 0, 0.4);
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 4;
}
.countdown-fill {
  fill: none;
  stroke: var(--yt-red);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 276.46;     /* 2π × 44 */
  stroke-dashoffset: 0;
  transform: rotate(-90deg);
  transform-origin: center;
  animation: countdown-spin var(--countdown-duration, 8s) linear forwards;
}
@keyframes countdown-spin {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: 276.46; }
}

.end-hint {
  text-align: center;
  font-size: var(--fs-card-meta);
  color: var(--yt-text-3);
}

/* ========== iPad / tablet polish ========== */

@media (max-width: 1100px) {
  .end-grid { grid-template-columns: 1.4fr 1fr; grid-template-rows: 1fr 1fr 1fr; }
  .end-card-primary { grid-row: 1 / span 3; }
}

/* Phone portrait: single-column end overlay so cards aren't squashed. */
@media (max-width: 480px) {
  .end-inner   { padding: 0 16px; }
  .end-heading { font-size: 22px; margin-bottom: 16px; }
  .end-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 16px;
  }
  .end-card-primary { grid-row: auto; }
  .end-card-primary .end-card-title { font-size: 20px; }
}

/* Touch devices: hide focus rings on tap, larger tap targets */
@media (hover: none) and (pointer: coarse) {
  .nav-item:focus:not(:focus-visible) { outline: 0; background: transparent; color: var(--yt-text-2); }
  .card:focus:not(:focus-visible) { transform: none; }
  .card:focus:not(:focus-visible) .card-thumb { outline: 0; }
  .chrome-btn { width: 56px; height: 56px; }
  .progress { height: 32px; }
}

/* ========== Double-tap seek ripple ==========
   Half-circle backdrop fades in + scales while three chevrons pulse.
   pointer-events: none so the ripple itself never intercepts the next tap. */

.seek-ripple {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 40%;
  z-index: 105;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}
.seek-ripple-left  { left: 0; }
.seek-ripple-right { right: 0; }

.seek-ripple-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--rip-cx, 50%) center,
              rgba(255,255,255,0.18) 0%,
              rgba(255,255,255,0.08) 35%,
              transparent 60%);
  border-radius: 50%;
  transform: scale(0.5);
  opacity: 0;
}
.seek-ripple-left  .seek-ripple-bg { --rip-cx: 0%;   border-radius: 0 50% 50% 0 / 0 50% 50% 0; }
.seek-ripple-right .seek-ripple-bg { --rip-cx: 100%; border-radius: 50% 0 0 50% / 50% 0 0 50%; }

.seek-ripple-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #fff;
}

.seek-ripple-arrows {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-bottom: 8px;
}
.seek-ripple-arrows svg {
  width: 28px;
  height: 28px;
  opacity: 0.4;
}

.seek-ripple-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Animation runs once per is-active toggle.
   JS removes/re-adds the class to retrigger. */
.seek-ripple.is-active {
  animation: ripple-fade 600ms ease-out forwards;
}
.seek-ripple.is-active .seek-ripple-bg {
  animation: ripple-bg 600ms ease-out forwards;
}
.seek-ripple.is-active .seek-ripple-arrows svg:nth-child(1) {
  animation: arrow-pulse 600ms ease-out 0ms forwards;
}
.seek-ripple.is-active .seek-ripple-arrows svg:nth-child(2) {
  animation: arrow-pulse 600ms ease-out 100ms forwards;
}
.seek-ripple.is-active .seek-ripple-arrows svg:nth-child(3) {
  animation: arrow-pulse 600ms ease-out 200ms forwards;
}

@keyframes ripple-fade {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes ripple-bg {
  0%   { transform: scale(0.6); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: scale(1.0); opacity: 0; }
}
@keyframes arrow-pulse {
  0%   { opacity: 0.2; transform: scale(0.85); }
  40%  { opacity: 1.0; transform: scale(1.1); }
  100% { opacity: 0.2; transform: scale(0.95); }
}

/* ========== End-overlay touch handlers ========== */

.end-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.end-close:hover { background: rgba(0,0,0,0.85); }

/* ========== Channel avatar on rec cards (pause strip + end overlay) ==========
   The audit flagged the dropped avatar as "THE biggest looks-like-real-YT tell."
   Rendered inline in the meta line so the layout stays compact on tiny cards. */
.strip-card-meta,
.end-card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}
.strip-card-meta .rec-channel,
.end-card-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rec-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--yt-surface);
}
.rec-avatar-ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: #555;
}
.end-card .rec-avatar         { width: 24px; height: 24px; }
.end-card-primary .rec-avatar { width: 30px; height: 30px; }
.end-card-primary .rec-avatar-ph { font-size: 15px; }
@media (min-width: 1100px) {
  .strip-card-meta .rec-avatar { width: 22px; height: 22px; }
}

/* ========== Transient volume indicator (arrow-key volume feedback) ========== */
.vol-indicator {
  position: fixed;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%) translateY(8px);
  z-index: 118;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.vol-indicator.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.vol-icon { width: 26px; height: 26px; color: #fff; flex: 0 0 auto; }
.vol-bar  { width: 140px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.vol-fill { display: block; height: 100%; background: #fff; border-radius: 3px; transition: width 120ms ease; }
