/* NEBians Media Player — minimal M3, subject-tinted, performance-first */

.nmp {
  --nmp-accent: var(--subject-color, var(--md-primary));
  --nmp-fg: var(--md-on-surface);
  --nmp-muted: var(--md-on-surface-variant);
  --nmp-surface: var(--md-surface-container-lowest);
  --nmp-track: var(--md-surface-container-high);
  --nmp-radius: var(--md-radius-md, 12px);
  position: relative;
  background: var(--nmp-surface);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--nmp-radius);
  overflow: hidden;
  margin-bottom: 24px;
  outline: none;
  content-visibility: auto;
  contain: layout style;
}

.nmp:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--nmp-accent) 45%, transparent);
}

.nmp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  background: color-mix(in srgb, var(--nmp-accent) 4%, var(--nmp-surface));
}

.nmp-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nmp-kind-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--md-radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--nmp-accent) 10%, transparent);
  color: var(--nmp-accent);
  border: 1px solid color-mix(in srgb, var(--nmp-accent) 22%, transparent);
  flex-shrink: 0;
}

.nmp-kind-pill .material-symbols-outlined {
  font-size: 14px;
}

.nmp-header-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--nmp-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nmp-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nmp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--md-radius-full);
  background: transparent;
  color: var(--nmp-muted);
  cursor: pointer;
  transition: background var(--md-transition), color var(--md-transition);
  font-family: inherit;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.nmp-icon-btn:hover {
  background: color-mix(in srgb, var(--nmp-accent) 10%, transparent);
  color: var(--nmp-accent);
}

.nmp-icon-btn:active {
  background: color-mix(in srgb, var(--nmp-accent) 16%, transparent);
}

.nmp-icon-btn[aria-pressed="true"],
.nmp-icon-btn.is-active {
  color: var(--nmp-accent);
}

.nmp-icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.nmp-icon-btn .material-symbols-outlined {
  font-size: 20px;
}

.nmp-icon-btn-sm {
  width: 32px;
  height: 32px;
}

.nmp-icon-btn-sm .material-symbols-outlined {
  font-size: 18px;
}

.nmp-icon-btn-lg {
  width: 48px;
  height: 48px;
}

.nmp-icon-btn-lg .material-symbols-outlined {
  font-size: 28px;
}

/* ── Video stage ── */
.nmp-stage {
  position: relative;
  background: #0a0f18;
  aspect-ratio: 16 / 9;
  max-height: min(70vh, 560px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

.nmp-stage.is-theatre {
  max-height: min(86vh, 820px);
}

.nmp-el-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.nmp-poster {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 60% at 70% 20%, color-mix(in srgb, var(--nmp-accent) 28%, transparent), transparent 70%),
    radial-gradient(ellipse 50% 50% at 20% 80%, color-mix(in srgb, var(--nmp-accent) 14%, transparent), transparent 70%),
    #0a0f18;
  transition: opacity 220ms cubic-bezier(0.2, 0, 0, 1);
  z-index: 2;
}

.nmp-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

.nmp-poster-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}

.nmp.is-ready .nmp-poster,
.nmp.is-playing .nmp-poster {
  opacity: 0;
  pointer-events: none;
}

.nmp-big-play {
  position: relative;
  z-index: 3;
  width: 72px;
  height: 72px;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--nmp-accent) 92%, #fff);
  color: var(--md-on-primary, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  transition: transform 180ms cubic-bezier(0.2, 0, 0, 1), box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.nmp-big-play:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
}

.nmp-big-play:active {
  transform: scale(0.97);
}

.nmp-big-play .material-symbols-outlined {
  font-size: 40px;
  font-variation-settings: 'FILL' 1;
  margin-left: 3px;
}

.nmp-buffer {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: nmp-spin 0.7s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.nmp.is-loading .nmp-buffer {
  opacity: 1;
}

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

.nmp-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(10, 15, 24, 0.92);
  color: #e5eeff;
}

.nmp.has-error .nmp-error {
  display: flex;
}

.nmp-error .material-symbols-outlined {
  font-size: 36px;
  opacity: 0.7;
}

.nmp-error p {
  margin: 0;
  font-size: 0.875rem;
  max-width: 280px;
  color: rgba(229, 238, 255, 0.8);
}

.nmp-error a {
  color: var(--md-inverse-primary, #B4C5FF);
  font-weight: 600;
  font-size: 0.8125rem;
}

/* ── Controls bar ── */
.nmp-controls {
  padding: 10px 12px 12px;
  background: var(--nmp-surface);
}

.nmp-progress {
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  margin-bottom: 2px;
}

.nmp-progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--nmp-track);
  overflow: hidden;
  transition: height 120ms ease;
}

.nmp-progress:hover .nmp-progress-track,
.nmp-progress:focus-within .nmp-progress-track,
.nmp-progress.is-dragging .nmp-progress-track {
  height: 6px;
}

.nmp-progress-buf {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: color-mix(in srgb, var(--nmp-muted) 28%, transparent);
  border-radius: 2px;
  pointer-events: none;
}

.nmp-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--nmp-accent);
  border-radius: 2px;
  pointer-events: none;
  will-change: width;
}

.nmp-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--nmp-accent);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 120ms ease;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  will-change: left, transform;
}

.nmp-progress:hover .nmp-progress-thumb,
.nmp-progress:focus-within .nmp-progress-thumb,
.nmp-progress.is-dragging .nmp-progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.nmp-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.nmp-time {
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--nmp-muted);
  padding: 0 8px;
  white-space: nowrap;
  user-select: none;
}

.nmp-time b {
  color: var(--nmp-fg);
  font-weight: 600;
}

.nmp-spacer {
  flex: 1;
  min-width: 8px;
}

.nmp-speed {
  position: relative;
}

.nmp-speed-btn {
  min-width: 40px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-radius-full);
  background: transparent;
  color: var(--nmp-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--md-transition), color var(--md-transition), border-color var(--md-transition);
}

.nmp-speed-btn:hover,
.nmp-speed-btn[aria-expanded="true"] {
  background: color-mix(in srgb, var(--nmp-accent) 10%, transparent);
  color: var(--nmp-accent);
  border-color: color-mix(in srgb, var(--nmp-accent) 30%, transparent);
}

.nmp-speed-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 96px;
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  border-radius: 10px;
  box-shadow: var(--md-elevation-2);
  padding: 4px;
  z-index: 20;
  display: none;
}

.nmp-speed-menu.is-open {
  display: block;
}

.nmp-speed-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--nmp-fg);
  cursor: pointer;
}

.nmp-speed-option:hover {
  background: var(--md-surface-container-high);
}

.nmp-speed-option.is-active {
  color: var(--nmp-accent);
  background: color-mix(in srgb, var(--nmp-accent) 10%, transparent);
}

.nmp-volume {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nmp-volume-range {
  width: 0;
  opacity: 0;
  height: 4px;
  accent-color: var(--nmp-accent);
  cursor: pointer;
  transition: width 160ms ease, opacity 160ms ease;
  margin: 0;
}

.nmp-volume:hover .nmp-volume-range,
.nmp-volume:focus-within .nmp-volume-range {
  width: 72px;
  opacity: 1;
}

/* ── Audio layout ── */
.nmp-audio {
  display: grid;
  grid-template-columns: 148px 1fr;
  min-height: 168px;
}

.nmp-audio-art {
  position: relative;
  background:
    radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--nmp-accent) 40%, transparent), transparent 55%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--nmp-accent) 22%, transparent), transparent 50%),
    linear-gradient(160deg, color-mix(in srgb, var(--nmp-accent) 18%, #0a0f18), #0a0f18 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.nmp-audio-art::before {
  content: '';
  position: absolute;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, #fff 18%, transparent);
  opacity: 0.7;
}

.nmp-audio-art::after {
  content: '';
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, #fff 12%, transparent);
}

.nmp-audio-disc {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--nmp-accent) 85%, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-on-primary, #fff);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  transition: transform 400ms cubic-bezier(0.2, 0, 0, 1);
}

.nmp-audio-disc .material-symbols-outlined {
  font-size: 30px;
  font-variation-settings: 'FILL' 1;
}

.nmp-audio.is-playing .nmp-audio-disc {
  animation: nmp-disc-spin 8s linear infinite;
}

.nmp-bars {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
  z-index: 1;
  opacity: 0.55;
}

.nmp-bars span {
  width: 3px;
  border-radius: 2px;
  background: #fff;
  height: 6px;
  transform-origin: bottom;
}

.nmp-audio.is-playing .nmp-bars span {
  animation: nmp-bar 1s ease-in-out infinite;
}

.nmp-bars span:nth-child(1) { animation-delay: 0s; }
.nmp-bars span:nth-child(2) { animation-delay: 0.12s; height: 10px; }
.nmp-bars span:nth-child(3) { animation-delay: 0.24s; height: 16px; }
.nmp-bars span:nth-child(4) { animation-delay: 0.08s; height: 8px; }
.nmp-bars span:nth-child(5) { animation-delay: 0.2s; height: 12px; }

@keyframes nmp-bar {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1.2); }
}

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

.nmp-audio-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 18px 14px;
  min-width: 0;
}

.nmp-audio-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--nmp-fg);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nmp-audio-meta {
  font-size: 0.75rem;
  color: var(--nmp-muted);
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.nmp-audio-meta .dot-sep {
  opacity: 0.3;
}

.nmp-audio .nmp-controls {
  padding: 0;
  background: transparent;
}

.nmp-audio .nmp-bar {
  margin-top: 2px;
}

/* ── Embed (YouTube / Drive / Vimeo) ── */
.nmp-embed {
  position: relative;
  background: #0a0f18;
  aspect-ratio: 16 / 9;
  max-height: min(70vh, 560px);
}

.nmp-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.nmp-embed-poster {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 60% at 70% 20%, color-mix(in srgb, var(--nmp-accent) 28%, transparent), transparent 70%),
    #0a0f18;
  cursor: pointer;
  border: none;
  width: 100%;
  padding: 0;
  color: inherit;
}

.nmp-embed.is-loaded .nmp-embed-poster {
  display: none;
}

.nmp-embed-label {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  text-align: left;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  pointer-events: none;
}

/* ── Resume toast ── */
.nmp-resume {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border-radius: var(--md-radius-full);
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
}

.nmp-resume.is-visible {
  display: inline-flex;
}

.nmp-resume button {
  border: none;
  background: color-mix(in srgb, var(--nmp-accent) 90%, #fff);
  color: #fff;
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--md-radius-full);
  cursor: pointer;
}

.nmp-resume .nmp-resume-dismiss {
  background: transparent;
  color: rgba(255,255,255,0.7);
  padding: 4px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Image lightbox-ish preview ── */
.nmp-image {
  background: var(--md-surface-container-high);
}

.nmp-image img {
  width: 100%;
  max-height: min(70vh, 560px);
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* ── Keyboard hint (desktop only) ── */
.nmp-hint {
  display: none;
  font-size: 0.6875rem;
  color: var(--nmp-muted);
  padding: 0 16px 10px;
}

@media (hover: hover) and (min-width: 900px) {
  .nmp-video .nmp-hint {
    display: block;
  }
}

/* ── Fullscreen ── */
.nmp:fullscreen,
.nmp:-webkit-full-screen {
  border-radius: 0;
  border: none;
  background: #000;
  max-height: none;
}

.nmp:fullscreen .nmp-stage,
.nmp:-webkit-full-screen .nmp-stage {
  max-height: none;
  flex: 1;
  aspect-ratio: auto;
  height: calc(100vh - 96px);
}

.nmp:fullscreen .nmp-header,
.nmp:-webkit-full-screen .nmp-header {
  background: #0a0f18;
  border-color: rgba(255,255,255,0.08);
}

.nmp:fullscreen .nmp-header-title,
.nmp:-webkit-full-screen .nmp-header-title {
  color: #e5eeff;
}

.nmp:fullscreen .nmp-controls,
.nmp:-webkit-full-screen .nmp-controls {
  background: #0a0f18;
}

.nmp:fullscreen .nmp-time,
.nmp:-webkit-full-screen .nmp-time {
  color: rgba(229,238,255,0.7);
}

.nmp:fullscreen .nmp-time b,
.nmp:-webkit-full-screen .nmp-time b {
  color: #e5eeff;
}

.nmp:fullscreen .nmp-icon-btn,
.nmp:-webkit-full-screen .nmp-icon-btn {
  color: rgba(229,238,255,0.75);
}

.nmp:fullscreen .nmp-progress-track,
.nmp:-webkit-full-screen .nmp-progress-track {
  background: rgba(255,255,255,0.15);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .nmp-audio {
    grid-template-columns: 1fr;
  }

  .nmp-audio-art {
    height: 120px;
  }

  .nmp-audio-body {
    padding: 14px;
  }

  .nmp-volume-range {
    display: none;
  }

  .nmp-big-play {
    width: 64px;
    height: 64px;
  }

  .nmp-big-play .material-symbols-outlined {
    font-size: 34px;
  }

  .nmp-header {
    padding: 10px 12px;
  }

  .nmp-header-title {
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nmp-audio.is-playing .nmp-audio-disc,
  .nmp-audio.is-playing .nmp-bars span,
  .nmp-buffer {
    animation: none !important;
  }

  .nmp-big-play,
  .nmp-icon-btn,
  .nmp-progress-thumb,
  .nmp-progress-track {
    transition: none !important;
  }
}

/* Dark theme polish */
[data-theme="dark"] .nmp {
  background: var(--md-surface-container-low);
}

[data-theme="dark"] .nmp-header {
  background: color-mix(in srgb, var(--nmp-accent) 8%, var(--md-surface-container-low));
}

[data-theme="dark"] .nmp-controls {
  background: var(--md-surface-container-low);
}
