/**
 * Recipe Image Styles
 * Styling for recipe images with lazy loading and responsive design
 * Version: 1.0.0
 */

/* ========================================
   RECIPE IMAGE CONTAINERS
   ======================================== */

.recipe-image-container {
  position: relative;
  overflow: hidden;
  background: var(--gray-100, #f5f5f5);
  border-radius: 12px;
}

.recipe-image-container.recipe-image-thumbnail {
  width: 100%;
  height: 200px;
  aspect-ratio: 3/2;
}

.recipe-image-container.recipe-image-medium {
  width: 100%;
  height: 300px;
  aspect-ratio: 4/3;
}

.recipe-image-container.recipe-image-full {
  width: 100%;
  height: auto;
  max-height: 500px;
}

/* ========================================
   RECIPE IMAGES
   ======================================== */

.recipe-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.recipe-image.lazy {
  filter: blur(10px);
}

.recipe-image.image-loaded {
  opacity: 1;
  filter: none;
}

.recipe-image.image-error {
  opacity: 0.7;
  filter: grayscale(50%);
}

/* Hover effect */
.recipe-card:hover .recipe-image {
  transform: scale(1.05);
}

/* ========================================
   LOADING INDICATOR
   ======================================== */

.recipe-image-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.recipe-image-loader .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary-color, #4caf50);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Hide loader when image is loaded */
.image-loaded ~ .recipe-image-loader {
  display: none;
}

/* ========================================
   RECIPE CARDS WITH IMAGES
   ======================================== */

.recipe-card {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.recipe-card-content {
  padding: 1rem;
  flex: 1;
}

.recipe-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text-color, #333);
  line-height: 1.4;
}

.recipe-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--gray-600, #666);
  margin-bottom: 0.75rem;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--gray-100, #f5f5f5);
  color: var(--gray-700, #555);
}

.tag-difficulty {
  background: var(--accent-gold, #ffc107);
  color: #333;
}

.tag-protein {
  background: var(--primary-light, #c8e6c9);
  color: var(--primary-dark, #2d5016);
}

/* ========================================
   RECIPE DETAIL VIEW
   ======================================== */

.recipe-detail-image {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 15px;
  margin-bottom: 2rem;
}

.recipe-detail-hero {
  position: relative;
  margin-bottom: 2rem;
}

.recipe-detail-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  border-radius: 0 0 15px 15px;
}

.recipe-detail-title {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  right: 1.5rem;
  color: white;
  font-size: 2rem;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .recipe-image-container.recipe-image-thumbnail {
    height: 180px;
  }

  .recipe-image-container.recipe-image-medium {
    height: 250px;
  }

  .recipe-name {
    font-size: 1rem;
  }

  .recipe-meta {
    font-size: 0.85rem;
  }

  .recipe-detail-title {
    font-size: 1.5rem;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
  }
}

@media (max-width: 480px) {
  .recipe-image-container.recipe-image-thumbnail {
    height: 160px;
  }

  .recipe-card-content {
    padding: 0.75rem;
  }

  .tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .recipe-image-loader {
    display: none;
  }

  .recipe-image {
    opacity: 1 !important;
    page-break-inside: avoid;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.recipe-card:focus-visible {
  outline: 3px solid var(--primary-color, #4caf50);
  outline-offset: 2px;
}

.recipe-image[alt=''] {
  /* Hide decorative images from screen readers */
  alt: '';
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .recipe-card {
    border: 2px solid currentColor;
  }

  .recipe-image-loader .spinner {
    border-left-color: currentColor;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .recipe-image,
  .recipe-card,
  .recipe-image-loader .spinner {
    animation: none;
    transition: none;
  }
}

/* ========================================
   DARK MODE
   ======================================== */

@media (prefers-color-scheme: dark) {
  .recipe-card {
    background: #2c2c2c;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .recipe-name {
    color: #f5f5f5;
  }

  .recipe-meta {
    color: #b0b0b0;
  }

  .tag {
    background: #3a3a3a;
    color: #e0e0e0;
  }

  .recipe-image-container {
    background: #1a1a1a;
  }
}
