/**
 * Cover Gallery Extension Styles
 */

/* Gallery mode cover block */
.wp-block-cover.cover-gallery-enabled {
  position: relative;
}

/* Gallery backgrounds container */
.cover-gallery-backgrounds {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
}

.cover-gallery-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  z-index: 0;
  transition: opacity 1s ease-in-out;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  will-change: opacity, transform;
}

.cover-gallery-bg.active {
  opacity: 1;
  z-index: 1;
}

/* Transition Effects */

/* Fade Effect */
.transition-fade .cover-gallery-bg {
  transition: opacity var(--transition-speed, 1s) ease-in-out;
}

/* Slide Effect */
.transition-slide .cover-gallery-bg {
  transform: translateX(100%);
  transition: transform var(--transition-speed, 1s) ease-in-out,
    opacity var(--transition-speed, 1s) ease-in-out;
}

.transition-slide .cover-gallery-bg.active {
  transform: translateX(0);
}

/* Zoom Effect */
.transition-zoom .cover-gallery-bg {
  transform: scale(1.1);
  transition: transform var(--transition-speed, 1s) ease-in-out,
    opacity var(--transition-speed, 1s) ease-in-out;
}

.transition-zoom .cover-gallery-bg.active {
  transform: scale(1);
}

/* Blur Effect */
.transition-blur .cover-gallery-bg {
  filter: blur(10px);
  transition: filter var(--transition-speed, 1s) ease-in-out,
    opacity var(--transition-speed, 1s) ease-in-out;
}

.transition-blur .cover-gallery-bg.active {
  filter: blur(0);
}

/* Dissolve Effect - Removed due to performance issues */

/* Cover content should be above gallery backgrounds */
.wp-block-cover.cover-gallery-enabled .wp-block-cover__inner-container {
  position: relative;
  z-index: 2;
}

/* Navigation Indicators - now within control bar */
.cover-gallery-indicators {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cover-gallery-indicators .indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
  outline: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner dot indicator */
.cover-gallery-indicators .indicator::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: all 0.3s ease;
  z-index: 2;
}

.cover-gallery-indicators .indicator:hover {
  border-color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.3);
}

.cover-gallery-indicators .indicator:hover::after {
  background: rgba(255, 255, 255, 0.6);
}

.cover-gallery-indicators .indicator.active {
  border-color: white;
  background: transparent;
}

.cover-gallery-indicators .indicator.active::after {
  background: rgba(255, 255, 255, 0.95);
}

/* Progress ring states */
.cover-gallery-indicators .indicator.completed::after {
  background: white;
}

/* Progress ring - ONE ring that shows progress */
.cover-gallery-indicators .indicator::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    white calc(var(--progress, 0) * 1%),
    rgba(255, 255, 255, 0.3) calc(var(--progress, 0) * 1% + 0.1%)
  );
  mask: radial-gradient(circle at center, transparent 14px, black 16px);
  -webkit-mask: radial-gradient(circle at center, transparent 14px, black 16px);
  opacity: 1;
  z-index: 1;
}

/* Unified Control Bar */
.cover-gallery-controls {
  position: absolute;
  bottom: var(--control-margin-bottom, 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--control-gap, 10px);
  padding: var(--control-padding, 5px);
  background: var(--control-bg, rgba(0, 0, 0, 0.5));
  color: var(--control-text, white);
  border: var(--control-border, none);
  border-radius: var(--control-border-radius, 50px);
  backdrop-filter: var(--control-backdrop-filter, none);
  -webkit-backdrop-filter: var(--control-backdrop-filter, none);
  transition: all 0.3s ease;
}

/* Control positioning variants */
.cover-gallery-controls.position-left {
  left: var(--control-margin-left, 20px);
  transform: none;
}

.cover-gallery-controls.position-right {
  left: auto;
  right: var(--control-margin-right, 20px);
  transform: none;
}

.cover-gallery-controls.position-center {
  left: 50%;
  transform: translateX(-50%);
}

/* Individual control buttons */
.cover-gallery-control-btn {
  background: transparent;
  color: inherit;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  position: relative;
}

/* Ensure all SVG icons inherit color */
.cover-gallery-control-btn svg {
  color: inherit;
  fill: currentColor;
}

.cover-gallery-control-btn:hover {
  background: var(--control-hover-bg, rgba(255, 255, 255, 0.2));
  transform: scale(1.05);
}

.cover-gallery-control-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

/* Control button sizing - smaller visual size with accessible touch targets */
.cover-gallery-control-btn.play-pause {
  width: 36px;
  height: 36px;
  padding: 4px; /* Extends touch target to 44px total */
}

.cover-gallery-control-btn.arrow {
  width: 36px;
  height: 36px;
  padding: 6px; /* Extends touch target to 44px total */
  font-size: 14px;
}

.cover-gallery-control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cover-gallery-control-btn:disabled:hover {
  transform: none;
  background: transparent;
}

/* Pause on hover functionality */
.wp-block-cover[data-pause-on-hover='true']:hover .cover-gallery-bg {
  animation-play-state: paused;
}

/* Responsive Design */
@media (max-width: 768px) {
  .cover-gallery-controls {
    bottom: 15px;
    gap: 8px;
    padding: 4px;
  }

  .cover-gallery-indicators {
    gap: 6px;
  }

  .cover-gallery-indicators .indicator {
    width: 28px;
    height: 28px;
  }

  .cover-gallery-indicators .indicator::before {
    top: -2px;
    left: -2px;
    width: 32px;
    height: 32px;
    border-width: 2px;
    mask: radial-gradient(circle at center, transparent 12px, black 14px);
    -webkit-mask: radial-gradient(
      circle at center,
      transparent 12px,
      black 14px
    );
  }

  .cover-gallery-indicators .indicator::after {
    width: 12px;
    height: 12px;
  }

  .cover-gallery-control-btn.play-pause {
    width: 32px;
    height: 32px;
    padding: 6px;
    font-size: 14px;
  }

  .cover-gallery-control-btn.arrow {
    width: 32px;
    height: 32px;
    padding: 6px;
    font-size: 14px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .cover-gallery-bg {
    transition: none !important;
  }

  .cover-gallery-arrow {
    transition: background-color 0.2s ease;
  }

  .cover-gallery-indicators .indicator {
    transition: background-color 0.2s ease;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .cover-gallery-indicators .indicator {
    border-color: white;
    border-width: 3px;
  }

  .cover-gallery-arrow {
    background: black;
    border: 2px solid white;
  }
}

/* Editor Preview Styles */
.cover-gallery-editor-wrapper {
  position: relative;
}

.cover-gallery-editor-preview {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Editor: Show first gallery image as cover background */
.block-editor-block-list__block[data-type='core/cover']
  .cover-gallery-editor-wrapper
  .wp-block-cover {
  transition: background-image 0.3s ease;
}

/* Editor: Gallery mode indicator */
.block-editor-block-list__block[data-type='core/cover'].is-selected
  .cover-gallery-editor-preview {
  opacity: 1;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
