/**
 * Share Player Styles
 *
 * Styles for the share page player, controls, and layout.
 */

/* ============================================================================
   Share Page Layout
   ============================================================================ */

.share-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--gray-1);
  padding: var(--space-4);
  gap: var(--space-4);
}

.player-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
}

.player-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-1);
  border-radius: var(--radius-4);
  overflow: hidden;
}

#share-canvas {
  display: block;
  cursor: pointer;
  border-radius: var(--radius-3);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* ============================================================================
   Loading Overlay
   ============================================================================ */

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--gray-2);
  color: var(--gray-11);
  gap: var(--space-3);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-6);
  border-top-color: var(--accent-9);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-overlay p {
  font-size: var(--font-size-2);
}

/* ============================================================================
   Buffering Overlay
   ============================================================================ */

.buffering-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease-out;
}

.buffering-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

/* ============================================================================
   Player Controls
   ============================================================================ */

.player-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 1280px;
  padding: var(--space-3) var(--space-4);
  background: var(--gray-2);
  border-radius: var(--radius-3);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-2);
  background: var(--gray-4);
  color: var(--gray-12);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.control-btn:hover {
  background: var(--gray-5);
  transform: scale(1.05);
}

.control-btn:active {
  transform: scale(0.95);
}

.control-btn:focus-visible {
  outline: 2px solid var(--accent-9);
  outline-offset: 2px;
}

.control-btn .icon {
  font-size: 16px;
  line-height: 1;
}

.play-btn {
  background: var(--accent-9);
  color: white;
}

.play-btn:hover {
  background: var(--accent-10);
}

/* ============================================================================
   Seekbar
   ============================================================================ */

.seekbar-container {
  flex: 1;
  position: relative;
  height: 8px;
  display: flex;
  align-items: center;
}

.seekbar {
  width: 100%;
  height: 8px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: var(--gray-5);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.seekbar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.seekbar::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--accent-9) 0%,
    var(--accent-9) var(--progress, 0%),
    var(--gray-5) var(--progress, 0%),
    var(--gray-5) 100%
  );
}

.seekbar::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-9);
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  margin-top: -4px;
  transition: transform var(--duration-fast) var(--ease-bounce);
}

.seekbar::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.seekbar::-moz-range-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--gray-5);
}

.seekbar::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-9);
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-bounce);
}

.seekbar::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.seekbar::-moz-range-progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-9), var(--accent-11));
}

/* ============================================================================
   Time Display
   ============================================================================ */

.time-display {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-numeric);
  font-size: var(--font-size-2);
  color: var(--gray-11);
  min-width: 80px;
  white-space: nowrap;
}

.time-separator {
  color: var(--gray-8);
}

#current-time {
  color: var(--gray-12);
  font-weight: 500;
}

/* ============================================================================
   Share Footer
   ============================================================================ */

.share-footer {
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.expiration-notice {
  color: var(--gray-11);
  font-size: var(--font-size-2);
  background: var(--gray-3);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-2);
  border: 1px solid var(--gray-5);
}

.branding {
  color: var(--gray-10);
  font-size: var(--font-size-2);
}

.branding a {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  gap: var(--space-1);
  color: var(--accent-9);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--duration-fast) var(--ease-smooth);
}

.branding a img {
  flex-shrink: 0;
  border-radius: 50%;
}

.branding a:hover {
  color: var(--accent-10);
  text-decoration: underline;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 768px) {
  .share-page {
    padding: var(--space-2);
  }

  .player-wrapper {
    border-radius: var(--radius-3);
  }
}

@media (max-width: 640px) {
  .player-controls {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
  }

  .control-btn {
    width: 36px;
    height: 36px;
  }

  .time-display {
    font-size: var(--font-size-1);
    min-width: 70px;
  }
}

@media (max-width: 480px) {
  .time-display {
    display: none;
  }
}

/* ============================================================================
   Fullscreen Mode
   ============================================================================ */

/* Fullscreen player-wrapper styles */
.player-wrapper:fullscreen,
.player-wrapper:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: var(--gray-1);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-wrapper:fullscreen #share-canvas,
.player-wrapper:-webkit-full-screen #share-canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  box-shadow: none;
}

/* Fullscreen controls overlay */
.player-wrapper:fullscreen .player-controls,
.player-wrapper:-webkit-full-screen .player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: none;
  border-radius: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.8) 0%,
    rgba(0, 0, 0, 0.4) 50%,
    transparent 100%
  );
  padding: var(--space-4) var(--space-4) var(--space-3);
  box-shadow: none;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 300ms var(--ease-smooth),
    transform 300ms var(--ease-smooth);
  z-index: 10;
}

/* Hidden controls in fullscreen */
.player-wrapper:fullscreen .player-controls.controls-hidden,
.player-wrapper:-webkit-full-screen .player-controls.controls-hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

/* Cursor hidden state in fullscreen */
.player-wrapper:fullscreen.cursor-hidden,
.player-wrapper:-webkit-full-screen.cursor-hidden {
  cursor: none;
}

.player-wrapper:fullscreen.cursor-hidden #share-canvas,
.player-wrapper:-webkit-full-screen.cursor-hidden #share-canvas {
  cursor: none;
}

/* Ensure controls are visible when hovering over them */
.player-wrapper:fullscreen .player-controls:hover,
.player-wrapper:-webkit-full-screen .player-controls:hover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Non-fullscreen: controls below canvas */
.player-wrapper:not(:fullscreen):not(:-webkit-full-screen) {
  overflow: visible;
  margin-bottom: 60px; /* Space for controls */
}

.player-wrapper:not(:fullscreen):not(:-webkit-full-screen) .player-controls {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: var(--space-3);
  width: 100%;
  max-width: 1280px;
}
