:root {
  /* Sizing */
  --music-album-art-size: 300px;
  --music-album-art-radius: 4px;
  --music-album-art-shadow: 0 1px 4px rgba(0,0,0,0.08);

  /* Vinyl size and position are calculated from album art size */
  --music-vinyl-size: calc(var(--music-album-art-size) * 0.85); /* 85% of album art */
  --music-vinyl-top: calc(var(--music-album-art-size) * 0.10);  /* 10% from top */
  --music-vinyl-left-initial: 0;
  --music-vinyl-left-hover: calc(var(--music-album-art-size) * 0.25); /* 30% of art width */
  --music-vinyl-shadow: 0 2px 8px rgba(0,0,0,0.10);

  /* Spacing */
  --music-album-gap: 3rem;
  --music-album-padding: 1.25rem;
  --music-album-margin-right: 2.5rem;

  /* Card style (inherits from theme if available) */
  --music-card-bg: var(--mm-background, #fff);
  --music-card-border: 1px solid var(--mm-border-color, #eaeaea);
  --music-card-radius: 6px;
  --music-card-shadow: var(--mm-box-shadow, 0 1px 2px rgba(0,0,0,0.03));

  /* Colors */
  --music-muted-color: var(--mm-muted-color, #555);
  --music-text-color: var(--mm-text-color, #222);
}

/* Cover Flow Styles */
.cover-flow-container {
  position: relative;
  width: 100%;
  height: 400px;
  perspective: 1000px;
  -webkit-perspective: 1000px;
  overflow: visible;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.cover-flow {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.5s ease-in-out;
  touch-action: pan-y;
}

.cover-flow-item {
  position: absolute;
  width: 200px;
  height: 200px;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  -webkit-transform-origin: center center;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
  -webkit-transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
  will-change: transform;
  cursor: pointer;
  box-shadow: var(--music-album-art-shadow);
  border-radius: var(--music-album-art-radius);
  margin-left: -100px;
  margin-top: -100px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Placeholder SVG for loading state - defined once as data URI */
:root {
  --album-placeholder-svg: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100' height='100' fill='%231a1a1a'/%3E%3Ccircle cx='50' cy='50' r='38' fill='%232a2a2a' stroke='%23333' stroke-width='1'/%3E%3Ccircle cx='50' cy='50' r='28' fill='none' stroke='%233a3a3a' stroke-width='0.5'/%3E%3Ccircle cx='50' cy='50' r='20' fill='none' stroke='%233a3a3a' stroke-width='0.5'/%3E%3Ccircle cx='50' cy='50' r='8' fill='%231a1a1a' stroke='%23444' stroke-width='1'/%3E%3Ccircle cx='50' cy='50' r='3' fill='%23555'/%3E%3C/svg%3E");
}

.cover-flow-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--music-album-art-radius);
  background: var(--album-placeholder-svg);
  background-size: cover;
  z-index: 0;
}

.cover-flow-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--music-album-art-radius);
  pointer-events: none;
  transition: transform 0.2s ease-in-out, opacity 0.4s ease-in-out;
  position: relative;
  z-index: 1;
  opacity: 0;
}

.cover-flow-item img.loaded {
  opacity: 1;
}

.cover-flow-item.centered {
  z-index: 10;
  opacity: 1 !important;
}

.cover-flow-item.centered:hover img {
  transform: scale(1.07) translateZ(1px);
}

.cover-flow-item:focus-visible {
  box-shadow: 0 0 0 3px rgba(0, 140, 255, 0.35), var(--music-album-art-shadow);
}

.cover-flow-info {
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1000;
  margin-top: -23px;
}

.cover-flow-album-artist,
.cover-flow-album-name {
  align-self: center !important;
  border-bottom: none !important;
  margin-bottom: 0.2em !important;
  margin-top: 0 !important;
  line-height: 1.2 !important;
  padding-bottom: 0 !important;
}


.cover-flow-info h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--music-text-color);
}

.cover-flow-info p {
  color: var(--music-muted-color);
  margin-bottom: 0.2em;
  margin-top: 0;
  font-weight: 400;
  font-style: italic;
  line-height: 1.2;
}

.cover-flow-info.visible {
  opacity: 1;
}

.cover-flow-item.centered .cover-flow-info {
  opacity: 1;
}

.cover-flow-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 100;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  user-select: none;
  -webkit-user-select: none;
}

.cover-flow-nav:hover {
  background: rgba(0,0,0,0.7);
}

.cover-flow-nav.prev {
  left: 20px;
}

.cover-flow-nav.next {
  right: 20px;
}

/* Existing Gallery Styles */
.music-gallery {
  display: flex;
  flex-direction: column;
  gap: var(--music-album-gap);
  margin-top: var(--music-album-gap);
}

/* Use theme-like card style */
.album-card {
  display: flex;
  align-items: flex-start;
  background: var(--music-card-bg);
  border: var(--music-card-border);
  border-radius: var(--music-card-radius);
  box-shadow: var(--music-card-shadow);
  padding: var(--music-album-padding);
  transition: box-shadow 0.2s, border-color 0.2s;
  position: relative;
  overflow: visible;
  margin-bottom: 0;
}

.album-art-container {
  position: relative;
  width: var(--music-album-art-size);
  height: var(--music-album-art-size);
  margin-right: var(--music-album-margin-right);
  flex-shrink: 0;
  z-index: 2;
}

.album-art-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--music-album-art-radius);
  background: var(--album-placeholder-svg);
  background-size: cover;
  z-index: 3; /* Higher than vinyl (z-index: 1) */
}

.album-art {
  width: 100%;
  height: 100%;
  border-radius: var(--music-album-art-radius);
  box-shadow: var(--music-album-art-shadow);
  z-index: 4; /* Higher than placeholder */
  position: relative;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}

.album-art.loaded {
  opacity: 1;
}

/* Define a rotation animation */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Vinyl starts hidden until image loads */
.vinyl {
  position: absolute;
  left: var(--music-vinyl-left-initial);
  top: var(--music-vinyl-top);
  width: var(--music-vinyl-size);
  height: var(--music-vinyl-size);
  background: radial-gradient(circle at 40% 40%, #222 60%, #444 100%);
  border-radius: 50%;
  z-index: 1;
  transition: left 0.5s cubic-bezier(.4,0,.2,1), opacity 0.4s ease-in-out;
  box-shadow: var(--music-vinyl-shadow);
  pointer-events: none;
  /* 33⅓ rpm = 1.8 seconds per rotation (60 seconds ÷ 33.33) */
  animation: spin 1.8s linear infinite;
  animation-play-state: paused;
  opacity: 0; /* Hidden until image loads */
}

/* Show and animate vinyl only after album art loads */
.album-art.loaded ~ .vinyl {
  animation-play-state: running;
  opacity: 1;
}

/* Add dotted pattern around the edge of the vinyl */
.vinyl::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px dotted #afafaf;
  box-sizing: border-box;
  pointer-events: none;
}

/* On hover, vinyl slides out but stays partially behind the cover */
.album-card:hover .vinyl,
.album-art-container:hover .vinyl {
  transition-timing-function: cubic-bezier(.4,2,.6,1);
  left: var(--music-vinyl-left-hover);
}

.album-info {
  flex: 1;
  min-width: 0;
}

.album-info h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.1;
}

.album-info p {
  margin-bottom: 0.75rem;
}

.album-artist {
  color: var(--music-muted-color, #555);
  margin-bottom: 0.2em;
  margin-top: 0;
  font-weight: 400;
  font-style: italic;
  line-height: 1.2;
  flex: 1;
}

.favorite-songs {
  margin: 0;
  padding-left: 1.2rem;
}

.favorite-songs li {
  margin-bottom: 0.2em;
}

@media (max-width: 600px) {
  .album-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
  }
  .album-art-container {
    margin-right: 0;
    margin-bottom: 1rem;
    align-self: center;
    width: 100%;
    height: auto;
  }
  .album-art {
    width: 100%;
    height: auto;
  }
  
  .cover-flow-container {
    display: none;
    height: 300px;
  }
  
  .cover-flow-item {
    width: 150px;
    height: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cover-flow,
  .cover-flow-item,
  .cover-flow-item img {
    transition: none !important;
  }
}
