/* 
 * Enhanced media handling for Devotly
 * This file contains improved styling for YouTube and Spotify embeds
 * to ensure proper responsive behavior across different devices
 */

/* Base styling for media section */
#mediaSection {
  background: rgba(18, 18, 20, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Common container styling */
.media-container {
  width: 100%;
  max-width: 85%;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
  margin: auto;
  background: rgba(0, 0, 0, 0.4);
  transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(4px);
}

/* YouTube-specific aspect ratio */
.media-container[data-media-type="youtube"] {
  aspect-ratio: 16/9;
  min-height: 300px;
}

/* Spotify album and track aspect ratio */
.media-container[data-media-type="spotify"] {
  aspect-ratio: 1/1;
  max-height: 380px;
}

/* Spotify playlist (taller interface) */
.media-container[data-media-type="spotify-playlist"] {
  aspect-ratio: 2/3;
  max-height: 450px;
}

/* Accent border at the top */
.media-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
  opacity: 0.6;
  z-index: 2;
}

/* Iframe styling */
.media-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.95;
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  will-change: opacity, transform;
  border: none;
}

/* Hover effects */
.media-container:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6), 0 0 20px rgba(244, 196, 64, 0.15);
  border-color: rgba(244, 196, 64, 0.15);
}

.media-container:hover iframe {
  opacity: 1;
  transform: scale(1.01);
}

/* Loading progress indicator */
.media-container.loaded::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-accent), transparent);
  animation: mediaProgress 3s cubic-bezier(0.19, 1, 0.22, 1) forwards;
  will-change: transform, opacity;
}

@keyframes mediaProgress {
  0% { width: 0; opacity: 1; }
  100% { width: 100%; opacity: 0.7; }
}

/* YouTube preview image */
.youtube-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.youtube-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  transition: background 0.3s ease;
}

.youtube-preview:hover::before {
  background: rgba(0, 0, 0, 0.2);
}

.youtube-play-button {
  width: 70px;
  height: 70px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.youtube-play-button i {
  color: var(--color-accent);
  font-size: 24px;
  margin-left: 4px; /* Small offset for play icon */
}

.youtube-play-button:hover {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.7);
  border-color: var(--color-accent);
}

/* No media placeholder */
.no-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 2rem;
}

.no-media i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.no-media p {
  font-size: 1.1rem;
  margin: 0;
}

/* Media queries for different screen sizes */
@media (max-width: 768px) {
  .media-container {
    max-width: 90%;
  }
  
  .youtube-play-button {
    width: 60px;
    height: 60px;
  }
  
  .youtube-play-button i {
    font-size: 20px;
  }
  
  .media-container[data-media-type="spotify"] {
    max-height: 360px;
  }
  
  .media-container[data-media-type="spotify-playlist"] {
    max-height: 400px;
  }
}

/* For mobile landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .media-container {
    max-width: 70%;
  }
  
  .media-container[data-media-type="youtube"] {
    aspect-ratio: 16/8;
  }
  
  .media-container[data-media-type="spotify"] {
    aspect-ratio: 3/2;
    max-height: 60vh;
  }
  
  .media-container[data-media-type="spotify-playlist"] {
    aspect-ratio: 3/2;
    max-height: 60vh;
  }
}

/* For small screens */
@media (max-width: 480px) {
  .media-container {
    max-width: 95%;
  }
  
  .youtube-play-button {
    width: 50px;
    height: 50px;
  }
  
  .youtube-play-button i {
    font-size: 18px;
  }
}

/* For iOS devices */
@supports (-webkit-touch-callout: none) {
  .media-container {
    transform: translateZ(0);
  }
}