/*
 * Player chrome. Loaded by both the app layout (/watch) and the embed iframe
 * layout, which has no Tailwind - so this is plain CSS on purpose and must
 * stay free of @apply. One file, one player, whichever surface renders it.
 *
 * --player-accent is set per tenant on .nx-stage.
 */

.nx-stage {
  position: relative;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.nx-stage * { box-sizing: border-box; }

/* Share gates use the same lightweight stylesheet as the player iframe. */
.ss-share-state, .ss-share-state * { box-sizing: border-box; }
.ss-share-state {
  height: 100%; overflow: auto; display: flex; align-items: safe center; justify-content: center;
  padding: 1.5rem; color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Helvetica, Arial, sans-serif;
}
.ss-share-panel { width: min(100%, 26rem); padding: 1.5rem; border: 1px solid rgba(255,255,255,.14); border-radius: 1rem; background: #141414; }
.ss-share-panel h1 { margin: 0; font-size: 1.25rem; line-height: 1.35; }
.ss-share-panel p { margin: .5rem 0 0; color: #c4c4c7; font-size: .875rem; line-height: 1.6; }
.ss-share-panel label { display: block; margin-top: 1.25rem; font-size: .875rem; font-weight: 600; }
.ss-share-panel input { display: block; width: 100%; min-height: 2.75rem; margin-top: .4rem; padding: .55rem .7rem; border: 1px solid rgba(255,255,255,.2); border-radius: .5rem; background: #0a0a0a; color: #fff; font: inherit; }
.ss-share-panel input:focus { outline: 2px solid #30cf5d; outline-offset: 2px; }
.ss-share-panel input[type="submit"] { margin-top: 1rem; border: 0; background: #fff; color: #0a0a0a; font-weight: 700; cursor: pointer; }
.ss-share-panel input[type="submit"]:hover { background: #d8f8df; }
.ss-share-panel .ss-share-error { color: #fda4af; }

.nx-video,
.nx-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

/* Never stretch. A 4:3 or vertical upload in a 16:9 frame gets letterboxed,
   not distorted. */
.nx-video { object-fit: contain; }

.nx-canvas { display: none; touch-action: none; }

/* The watch page frames the player; the embed iframe is the player. */
.ss-watch-stage { aspect-ratio: 16 / 9; border-radius: 18px; }
.ss-embed-stage { position: fixed; inset: 0; width: 100vw; height: 100vh; }

.nx-stage:fullscreen,
.nx-stage:-webkit-full-screen { aspect-ratio: auto; border-radius: 0; width: 100%; height: 100%; }
.nx-stage:fullscreen .nx-video { object-fit: contain; }

/* ---------- captions ---------- */

.ss-caption-video::cue {
  color: #fff;
  background: rgba(0, 0, 0, 0.78);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Helvetica, Arial, sans-serif;
  font-size: clamp(0.9rem, 2.2vw, 1.5rem);
  line-height: 1.45;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.ss-caption-video[data-caption-size="small"]::cue { font-size: clamp(0.75rem, 1.7vw, 1.15rem); }
.ss-caption-video[data-caption-size="large"]::cue { font-size: clamp(1.05rem, 2.8vw, 1.9rem); }
.ss-caption-video[data-caption-font="serif"]::cue { font-family: Georgia, "Noto Serif KR", serif; }
.ss-caption-video[data-caption-font="mono"]::cue { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ss-caption-video[data-caption-background="soft"]::cue { background: rgba(0, 0, 0, 0.48); }
.ss-caption-video[data-caption-background="none"]::cue { background: transparent; }

.nx-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Whole-picture tap target. Sits under the bar and the menus. */
.nx-surface {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

/* ---------- top: title + logo ---------- */

.nx-scrim-top {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 40px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.36) 46%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
  opacity: 1;
  transition: opacity 180ms ease;
}

.nx-scrim-top[aria-hidden="true"]:not(:has(.nx-logo)) { display: none; }

.nx-title {
  margin: 0;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nx-logo {
  flex: none;
  height: 30px;
  width: auto;
  max-width: 96px;
  object-fit: contain;
  opacity: 0.92;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.5));
}

.nx-nulx-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-right: 4px;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.nx-nulx-brand img { width: 18px; height: 18px; object-fit: contain; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.65)); }

/* ---------- center: big play + spinner ---------- */

.nx-center {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.nx-bigplay {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  /* A flat dark circle disappears on a dark frame; the hairline keeps the
     button findable on black as well as on white. */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22), 0 6px 24px rgba(0, 0, 0, 0.4);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  transition: transform 160ms ease, opacity 160ms ease, background-color 160ms ease;
}

.nx-bigplay:hover { background: var(--player-accent, #22c55e); transform: scale(1.06); }
.nx-bigplay .nx-icon-lg { margin-left: 3px; }
.nx-stage[data-nx-state="playing"] .nx-bigplay,
.nx-stage[data-nx-state="waiting"] .nx-bigplay { opacity: 0; transform: scale(0.85); pointer-events: none; }

.nx-spinner {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.24);
  border-top-color: var(--player-accent, #22c55e);
  opacity: 0;
  transition: opacity 140ms ease;
}

.nx-stage[data-nx-state="waiting"] .nx-spinner { opacity: 1; animation: nx-spin 800ms linear infinite; }

@keyframes nx-spin { to { transform: rotate(360deg); } }

/* ---------- bottom: scrubber + control bar ---------- */

.nx-chrome {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 4;
  padding: 44px 8px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.45) 52%, rgba(0, 0, 0, 0) 100%);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 200ms ease, transform 200ms ease;
}

.nx-stage[data-nx-idle="true"] .nx-chrome,
.nx-stage[data-nx-idle="true"] .nx-scrim-top {
  opacity: 0;
  pointer-events: none;
}

.nx-stage[data-nx-idle="true"] .nx-chrome { transform: translateY(8px); }
.nx-stage[data-nx-idle="true"] { cursor: none; }

/* Scrubber ------------------------------------------------ */

.nx-scrub {
  position: relative;
  display: flex;
  align-items: center;
  height: 18px;
  margin: 0 8px;
  cursor: pointer;
  touch-action: none;
}

.nx-scrub-track {
  position: relative;
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  transition: height 120ms ease;
}

.nx-scrub:hover .nx-scrub-track,
.nx-scrub:focus-visible .nx-scrub-track,
.nx-scrub[data-nx-dragging="true"] .nx-scrub-track { height: 5px; }

.nx-scrub-buffered,
.nx-scrub-played {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  width: 0;
}

.nx-scrub-buffered { background: rgba(255, 255, 255, 0.42); }
.nx-scrub-played { background: var(--player-accent, #22c55e); }

.nx-scrub-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 999px;
  background: var(--player-accent, #22c55e);
  transform: translateY(-50%) scale(0);
  transition: transform 120ms ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.nx-scrub:hover .nx-scrub-knob,
.nx-scrub:focus-visible .nx-scrub-knob,
.nx-scrub[data-nx-dragging="true"] .nx-scrub-knob { transform: translateY(-50%) scale(1); }

.nx-scrub-tip {
  position: absolute;
  bottom: 20px;
  transform: translateX(-50%);
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 120ms ease;
}

.nx-scrub:hover .nx-scrub-tip,
.nx-scrub[data-nx-dragging="true"] .nx-scrub-tip { opacity: 1; }

/* Button row ---------------------------------------------- */

.nx-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 2px;
}

.nx-bar-left,
.nx-bar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.nx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.92;
  transition: background-color 140ms ease, opacity 140ms ease, color 140ms ease;
}

.nx-btn:hover { background: rgba(255, 255, 255, 0.14); opacity: 1; }
.nx-btn:focus-visible { outline: 2px solid var(--player-accent, #22c55e); outline-offset: -2px; }
.nx-btn[aria-pressed="false"] { opacity: 0.5; }
.nx-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.18); }
.nx-btn-sm { width: 30px; height: 30px; }

.nx-icon { display: block; width: 22px; height: 22px; }
.nx-icon-lg { width: 30px; height: 30px; }
.nx-btn-sm .nx-icon { width: 16px; height: 16px; }

/* Both states of every toggle ship in the DOM; CSS picks one. Swapping
   innerHTML from JS would mean a second copy of each path in JavaScript. */
.nx-i-pause,
.nx-i-fs-exit,
.nx-i-vol-low,
.nx-i-vol-mute { display: none; }

.nx-stage[data-nx-state="playing"] .nx-i-play { display: none; }
.nx-stage[data-nx-state="playing"] .nx-i-pause { display: block; }
.nx-stage[data-nx-fullscreen="true"] .nx-i-fs-enter { display: none; }
.nx-stage[data-nx-fullscreen="true"] .nx-i-fs-exit { display: block; }
.nx-stage[data-nx-volume="low"] .nx-i-vol-high { display: none; }
.nx-stage[data-nx-volume="low"] .nx-i-vol-low { display: block; }
.nx-stage[data-nx-volume="mute"] .nx-i-vol-high { display: none; }
.nx-stage[data-nx-volume="mute"] .nx-i-vol-mute { display: block; }

/* The big centre button is a play affordance only; it is hidden while
   playing, so it never needs a pause face. */
.nx-bigplay .nx-i-pause { display: none; }

.nx-btn[data-nulx-player-target="settingsButton"] .nx-icon { transition: transform 220ms ease; }
.nx-btn[aria-expanded="true"][data-nulx-player-target="settingsButton"] .nx-icon { transform: rotate(35deg); }

/* Volume: the slider only takes room once you reach for it. */
.nx-volume { display: flex; align-items: center; }

.nx-volume-slider {
  width: 0;
  height: 3px;
  margin: 0;
  padding: 0;
  opacity: 0;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  cursor: pointer;
  transition: width 160ms ease, opacity 160ms ease, margin 160ms ease;
}

.nx-volume:hover .nx-volume-slider,
.nx-volume:focus-within .nx-volume-slider { width: 66px; opacity: 1; margin: 0 8px 0 2px; }

.nx-volume-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 999px;
  background: #fff;
}

.nx-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 999px;
  background: #fff;
}

.nx-time {
  margin: 0 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.nx-time-sep { margin: 0 3px; opacity: 0.5; }
.nx-time-total { opacity: 0.7; }

/* ---------- settings menu ---------- */

.nx-menu {
  position: absolute;
  right: 10px;
  bottom: 62px;
  z-index: 6;
  width: min(300px, calc(100% - 20px));
  max-height: min(62%, 340px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(20, 20, 22, 0.94);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  font-size: 13px;
}

.nx-menu-row,
.nx-menu-item,
.nx-menu-back {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #f4f4f5;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.nx-menu-row:hover,
.nx-menu-item:hover,
.nx-menu-back:hover { background: rgba(255, 255, 255, 0.1); }

.nx-menu-row-icon { display: flex; opacity: 0.75; }
.nx-menu-row-icon .nx-icon { width: 18px; height: 18px; }
.nx-menu-row-label { flex: 1 1 auto; min-width: 0; }
.nx-menu-row-value { color: rgba(255, 255, 255, 0.55); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-menu-row-more { display: flex; opacity: 0.5; }
.nx-menu-row-more .nx-icon { width: 16px; height: 16px; }

.nx-menu-back {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px 9px 0 0;
  margin-bottom: 4px;
  font-weight: 600;
}

.nx-menu-back .nx-icon { width: 18px; height: 18px; }

.nx-menu-heading { margin: 6px 10px 8px; font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, 0.55); }

.nx-menu-item-check { display: flex; width: 18px; flex: none; opacity: 0; }
.nx-menu-item-check .nx-icon { width: 16px; height: 16px; color: var(--player-accent, #22c55e); }
.nx-menu-item.is-on .nx-menu-item-check { opacity: 1; }

.nx-menu-field { display: flex; flex-direction: column; gap: 5px; padding: 8px 10px; color: rgba(255, 255, 255, 0.6); font-size: 12px; }

.nx-menu-field select {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: #16181d;
  color: #f4f4f5;
  font: inherit;
  font-size: 13px;
}

.nx-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nx-chapter { align-items: baseline; }
.nx-chapter-time { flex: none; font-variant-numeric: tabular-nums; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.nx-chapter-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- transcript ---------- */

.nx-transcript {
  position: absolute;
  right: 10px;
  top: 56px;
  bottom: 62px;
  z-index: 6;
  width: min(340px, calc(100% - 20px));
  overflow-y: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(20, 20, 22, 0.94);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  color: #e4e4e7;
}

.nx-transcript-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nx-transcript h2 { margin: 0; font-size: 13px; font-weight: 600; }
.nx-transcript p { margin: 10px 0 0; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.nx-transcript ol { margin: 8px 0 0; padding: 0; list-style: none; }

.ss-transcript-cue {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e4e4e7;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.ss-transcript-cue:hover { background: rgba(255, 255, 255, 0.08); }
.ss-transcript-time { font-variant-numeric: tabular-nums; font-size: 12px; color: rgba(255, 255, 255, 0.5); }

/* ---------- error ---------- */

.nx-error {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 62px;
  z-index: 5;
  margin: 0;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.78);
  color: #fda4af;
  font-size: 13px;
  font-weight: 500;
}

.nx-error:empty { display: none; }

/* ---------- narrow / touch ---------- */

@media (max-width: 560px) {
  .nx-hide-sm { display: none; }
  .nx-chrome { padding: 36px 4px 4px; }
  .nx-btn { width: 38px; height: 38px; }
  .nx-icon { width: 20px; height: 20px; }
  .nx-time { margin: 0 4px; font-size: 12px; }
  .nx-scrim-top { padding: 10px 12px 32px; }
  .nx-nulx-brand { margin-right: 2px; }
  .nx-title { font-size: 13px; }
  .nx-bigplay { width: 58px; height: 58px; }
  /* Touch has no hover, so a hidden volume slider is unreachable. The mute
     button stays; the slider does not pretend to exist. */
  .nx-volume-slider { display: none; }
  .nx-menu, .nx-transcript { right: 6px; left: 6px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .nx-chrome, .nx-scrim-top, .nx-bigplay, .nx-scrub-track, .nx-scrub-knob, .nx-volume-slider { transition: none; }
  .nx-stage[data-nx-state="waiting"] .nx-spinner { animation-duration: 1600ms; }
}
