/* The long-form watch page (/watch/{publicId}). */

.watch-page {
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--space-5);
  align-items: start;
}

@media (max-width: 860px) {
  .watch-page {
    grid-template-columns: minmax(0, 1fr);
  }
}

.watch-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.watch-player-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.watch-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

/* Mini player: same-page only (see watch.js) — shrinks the whole wrapper
   (video + controls-extra bar + up-next overlay) into a small fixed corner
   widget once scrolled out of view while playing. */
.watch-player-wrap.is-mini {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  width: min(320px, calc(100vw - 2 * var(--space-4)));
  z-index: 40;
  box-shadow: var(--shadow-glow-signal);
}

.watch-mini-close {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 41;
  width: 24px;
  height: 24px;
  line-height: 22px;
  text-align: center;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
}

.watch-player-wrap.is-mini .watch-mini-close {
  display: block;
}

/* Autoplay "up next" overlay — hidden until the video's 'ended' event
   fires with a recommended video queued up (see watch.js). */
.watch-up-next-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(4px);
}

/* The overlay's `hidden` attribute (set/cleared by watch.js) would
   otherwise be overridden by the `display: flex` above — an author
   stylesheet rule always wins over the UA stylesheet's own
   `[hidden] { display: none }`, regardless of specificity, so without this
   override the overlay renders permanently visible (showing whatever
   blank/default markup it started with — no title, no thumbnail, "5"
   never updated) no matter what watch.js sets `overlay.hidden` to. Same
   class of bug as the CC/PiP/Cancel buttons needing an explicit color
   modifier — pairing a `display` declaration with a hideable element needs
   an explicit [hidden] override or the CSS wins over the attribute. */
.watch-up-next-overlay[hidden] {
  display: none;
}

/* Phase 7 slice 3 — pre-roll ad badge (see watch.js's wirePreRollAd()).
   Same [hidden]-override footgun as .watch-up-next-overlay just above —
   pairing a `display` declaration with a hideable element needs an
   explicit [hidden] rule, or the author stylesheet's `display` always
   wins over the UA stylesheet's `[hidden] { display: none }`. */
.watch-ad-badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: rgba(0, 0, 0, 0.75);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: var(--text-xs);
}

.watch-ad-badge[hidden] {
  display: none;
}

.watch-ad-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-faint);
}

.watch-ad-countdown {
  font-family: var(--font-mono);
}

.watch-ad-skip-btn {
  margin-left: var(--space-2);
}

/* Advertiser Platform Completion — Checkpoint C — the CTA <a> inside
   .watch-ad-badge (see watch.php). Same margin-left spacing as
   .watch-ad-skip-btn just above so the two sit consistently in the same
   flex row regardless of which combination is visible (CTA-only,
   skip-only, both, or neither) — .watch-ad-badge's own `gap` already
   handles most of the spacing; this only matters when the skip button is
   still hidden (before AD_SKIP_AFTER_SECONDS elapses) and the CTA is the
   first interactive element after the countdown text. `.btn` already
   provides the visible/tappable sizing this needs to work on mobile —
   nothing ad-CTA-specific to add there. */
.watch-ad-cta {
  margin-left: var(--space-2);
}

.watch-ad-cta[hidden] {
  display: none;
}

.watch-up-next-card {
  text-align: center;
  padding: var(--space-5);
  max-width: 320px;
}

.watch-up-next-card img {
  width: 160px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.watch-controls-extra {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-void-raised);
  flex-wrap: wrap;
}

.watch-controls-extra select {
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* CC / picture-in-picture toggles — both start `hidden` in the markup and
   are revealed by watch.js only once actually usable (a subtitle track
   exists / the browser supports the PiP API — see watch.js). */
.watch-icon-btn {
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
}

.watch-icon-btn.is-active {
  background: var(--gradient-signal);
  color: #fff;
  border-color: transparent;
}

.watch-autoplay-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.watch-owner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
  width: fit-content;
}

/* Recommended-videos sidebar. */
.watch-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.watch-sidebar-title {
  font-size: var(--text-sm);
  color: var(--color-faint);
  margin-bottom: var(--space-1);
}

.watch-rec-card {
  display: flex;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  transition: background var(--duration-fast) var(--ease-out);
}

.watch-rec-card:hover {
  background: var(--color-surface);
}

.watch-rec-thumb {
  position: relative;
  flex: 0 0 160px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: linear-gradient(135deg, rgba(124, 92, 252, 0.25), rgba(33, 209, 159, 0.15));
}

.watch-rec-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.watch-rec-meta {
  min-width: 0;
}

.watch-rec-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 640px) {
  .watch-rec-thumb {
    flex-basis: 120px;
  }
}

/* ---------------------------------------------------------------------
   Phase 4c frontend: like/dislike/subscribe (see engagement.js)
--------------------------------------------------------------------- */
.watch-actions {
  display: flex;
  gap: var(--space-2);
}

.watch-action-btn {
  gap: var(--space-2);
}

.watch-action-btn.is-active {
  border-color: var(--color-signal);
  color: var(--color-signal-strong);
}

#watch-dislike-btn.is-active {
  border-color: var(--color-edge);
  color: var(--color-edge);
}

.watch-owner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Toggled to look "already subscribed" (outline, not filled) by
   engagement.js's setSubscribeButton() — see that file. */
.watch-subscribe-btn.btn-ghost {
  color: var(--color-payout-strong);
  border-color: rgba(33, 209, 159, 0.35);
}

/* ---------------------------------------------------------------------
   Phase 4b frontend: comment thread (see comments.js)
--------------------------------------------------------------------- */
.watch-comments-heading {
  font-size: var(--text-md);
  margin-bottom: var(--space-4);
}

.watch-comment-composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.watch-comment-textarea {
  resize: vertical;
  min-height: 44px;
  font-family: var(--font-body);
}

.watch-comment-composer-actions {
  display: flex;
  justify-content: flex-end;
}

.comment-item {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
  transition: background var(--duration-med) var(--ease-out);
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-item.is-highlighted {
  background: rgba(124, 92, 252, 0.09);
  border-radius: var(--radius-sm);
}

.comment-item.is-pinned {
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: none;
}

.comment-pinned-label {
  font-size: var(--text-xs);
  color: var(--color-faint);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.comment-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.comment-author-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: inherit;
}

.comment-author-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.comment-author-handle {
  color: var(--color-faint);
  font-size: var(--text-xs);
}

.comment-item-time {
  color: var(--color-faint);
  font-size: var(--text-xs);
  flex-shrink: 0;
}

.comment-body {
  font-size: var(--text-sm);
  line-height: 1.5;
  margin-left: calc(32px + var(--space-2));
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-edit-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: calc(32px + var(--space-2));
  margin-top: var(--space-2);
}

.comment-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--color-faint);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease-out);
}

.comment-action-btn:hover {
  color: var(--color-ink);
}

.comment-action-btn.is-active {
  color: var(--color-edge);
}

.comment-replies {
  margin-left: calc(32px + var(--space-2));
  margin-top: var(--space-3);
  padding-left: var(--space-4);
  border-left: 1px solid var(--color-border);
}

.comment-reply-composer {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  margin-top: var(--space-3);
}

.comment-reply-composer textarea {
  flex: 1;
  min-height: 36px;
}

@media (max-width: 640px) {
  .comment-body,
  .comment-actions,
  .comment-replies {
    margin-left: 0;
  }
}
