/* ==========================================================================
   Zype Video Embed - Dark Streaming Theme
   Vanilla CSS. Low specificity, custom properties, logical layout ownership.
   ========================================================================== */

:root {
  /* Color system */
  --color-bg: #080b12;
  --color-surface: #111722;
  --color-surface-raised: #171f2d;
  --color-text: #f7f9fc;
  --color-text-muted: #a8b2c1;
  --color-primary: #6f5cff;
  --color-primary-contrast: #ffffff;
  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-strong: rgba(255, 255, 255, 0.18);
  --color-error: #ff6b7a;
  --color-error-surface: rgba(255, 107, 122, 0.08);
  --color-focus: #9d90ff;

  /* Radii */
  --radius-large: 18px;
  --radius-medium: 12px;
  --radius-small: 8px;
  --radius-pill: 999px;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --line-body: 1.65;

  /* Player target sizing */
  --player-max-width: 800px;
  --player-max-height: 600px;

  /* Motion */
  --transition: 160ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--color-bg);
  background-image: radial-gradient(
    1200px 600px at 50% -10%,
    rgba(111, 92, 255, 0.12),
    transparent 70%
  );
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: var(--line-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  border-radius: var(--radius-small);
  text-decoration: none;
  transition: top var(--transition);
}

.skip-link:focus {
  top: var(--space-4);
}

/* --------------------------------------------------------------------------
   Focus visibility (keyboard-first)
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-small);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.video-page {
  display: flex;
  justify-content: center;
  padding: clamp(var(--space-4), 4vw, var(--space-7)) var(--space-4);
}

.video-card {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: clamp(var(--space-4), 3vw, var(--space-6));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

/* --------------------------------------------------------------------------
   Title
   -------------------------------------------------------------------------- */

.video-header {
  margin: 0;
}

.video-title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* --------------------------------------------------------------------------
   Thumbnail
   -------------------------------------------------------------------------- */

.video-thumbnail {
  width: 100%;
  border-radius: var(--radius-medium);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}

.video-thumbnail img {
  display: block;
  width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   Player shell (responsive up to 800 x 600, 4/3)
   -------------------------------------------------------------------------- */

.video-player-shell {
  position: relative;
  width: min(100%, var(--player-max-width));
  max-height: var(--player-max-height);
  margin-inline: auto;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  overflow: hidden;
}

/*
  Fallback for browsers without aspect-ratio support: padding-based ratio.
  A wrapper element receives the padding; browsers that support aspect-ratio
  ignore the min-height:0 supports block below.
*/
@supports not (aspect-ratio: 4 / 3) {
  .video-player-shell {
    height: 0;
    padding-bottom: 75%; /* 3/4 = 4:3 */
  }
}

/* Make the Zype-generated player fill the shell where possible. */
.video-player-shell > .zype-player,
.video-player-shell iframe,
.video-player-shell video,
.video-player-shell > div {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Loading placeholder inside the player shell. */
.player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-4);
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--color-border-strong);
  border-top-color: var(--color-primary);
  animation: spin 0.9s linear infinite;
}

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

.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5);
  text-align: center;
  color: var(--color-text);
  background: var(--color-surface-raised);
}

.player-error__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-error);
}

.player-error__text {
  margin: 0;
  color: var(--color-text-muted);
  max-width: 46ch;
}

/* --------------------------------------------------------------------------
   Description
   -------------------------------------------------------------------------- */

.video-description {
  margin: 0;
}

.video-description__body {
  margin: 0;
  max-width: 70ch;
  color: var(--color-text);
  white-space: pre-line; /* preserve reasonable line breaks from metadata */
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Meta (duration + keywords)
   -------------------------------------------------------------------------- */

.video-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.meta-block {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.meta-block__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.duration-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.keyword-chip {
  padding: var(--space-1) var(--space-3);
  font-size: 0.8125rem;
  color: var(--color-text);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Share controls
   -------------------------------------------------------------------------- */

.video-share {
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.video-share__heading {
  margin: 0 0 var(--space-3);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.share-hint {
  margin: var(--space-3) 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  max-width: 60ch;
}

/* Buttons / links shared styling */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    transform var(--transition);
}

.btn:hover {
  background: #1e2738;
  border-color: var(--color-primary);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-primary-contrast);
}

.btn--primary:hover {
  background: #5b49e6;
}

.btn__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Panels (validation / errors / notices)
   -------------------------------------------------------------------------- */

.panel {
  padding: clamp(var(--space-4), 3vw, var(--space-6));
  border-radius: var(--radius-medium);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}

.panel--error {
  border-color: rgba(255, 107, 122, 0.4);
  background: var(--color-error-surface);
}

.panel__title {
  margin: 0 0 var(--space-3);
  font-size: 1.5rem;
  color: var(--color-error);
}

.panel__text {
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}

.panel__text:last-child {
  margin-bottom: 0;
}

.panel__list {
  margin: 0 0 var(--space-3);
  padding-left: 1.25rem;
  color: var(--color-text);
}

.panel__example {
  display: block;
  margin-top: var(--space-2);
  padding: var(--space-3);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.metadata-notice {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  background: var(--color-surface-raised);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-small);
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .spinner {
    animation: none;
    border-top-color: var(--color-border-strong);
  }
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .share-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}
