/* 
 * IMAGE DISPLAY STYLES
 * Responsive, lazy-loaded images with dark mode support
 */

/* ============================================================================
   FEATURED IMAGES (Hero/Lead images)
   ============================================================================ */

.featured-image {
  margin: 2.5rem 0;
  padding: 0;
  border: none;
}

.featured-image__img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: cover;
  border-radius: 0.25rem;
  
  /* Lazy loading fallback - fade in */
  opacity: 1;
  transition: opacity 300ms ease-out;
}

/* Loading state */
.featured-image__img[loading="lazy"]:not([src=""]) {
  background-color: var(--color-bg-alt, #f5f1e8);
}

.featured-image__caption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--color-text-secondary, #6b6b6b);
  font-style: italic;
  text-align: center;
}

/* ============================================================================
   CONTENT IMAGES (Inline in articles)
   ============================================================================ */

.content-image {
  margin: 1.5rem 0;
  padding: 0;
  border: none;
}

.content-image__img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0.25rem;
  transition: opacity 300ms ease-out;
}

.content-image__caption {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--color-text-secondary, #6b6b6b);
  font-style: italic;
  text-align: center;
}

/* Missing image fallback */
.content-image--missing {
  background-color: var(--color-bg-alt, #f5f1e8);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 0.25rem;
  padding: 1.5rem;
  text-align: center;
}

.image-placeholder {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-placeholder p {
  color: var(--color-text-secondary, #888);
  font-size: 0.875rem;
  margin: 0;
}

/* ============================================================================
   THUMBNAIL GRID (List pages)
   ============================================================================ */

.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

@media (max-width: 768px) {
  .thumbnail-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .thumbnail-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
  }
}

.thumbnail-grid__item {
  margin: 0;
  padding: 0;
}

.thumbnail-grid__link {
  display: block;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  border-radius: 0.25rem;
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}

.thumbnail-grid__link:hover,
.thumbnail-grid__link:focus {
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.thumbnail {
  margin: 0;
  padding: 0;
  border: none;
  overflow: hidden;
  background-color: var(--color-bg-alt, #f5f1e8);
}

.thumbnail__img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  transition: transform 200ms ease-out;
}

.thumbnail-grid__link:hover .thumbnail__img,
.thumbnail-grid__link:focus .thumbnail__img {
  transform: scale(1.03);
}

.thumbnail__caption {
  padding: 0.75rem;
  background-color: var(--color-bg, white);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-text, #333);
  text-align: center;
  transition: background-color 200ms ease-out;
}

.thumbnail-grid__link:hover .thumbnail__caption,
.thumbnail-grid__link:focus .thumbnail__caption {
  background-color: var(--color-bg-alt, #f5f1e8);
}

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

@media (prefers-color-scheme: dark) {
  .featured-image__img[loading="lazy"]:not([src=""]) {
    background-color: #2a2a2a;
  }

  .content-image--missing {
    background-color: #2a2a2a;
    border-color: #4a4a4a;
  }

  .image-placeholder p {
    color: #999;
  }

  .thumbnail {
    background-color: #2a2a2a;
  }

  .thumbnail__caption {
    background-color: #1a1a1a;
    color: #e8e8e8;
  }

  .thumbnail-grid__link:hover .thumbnail__caption,
  .thumbnail-grid__link:focus .thumbnail__caption {
    background-color: #2a2a2a;
  }
}

/* ============================================================================
   CLIPART PLACEMENTS — surreal inline illustrations
   ============================================================================ */

.clipart {
  margin: 2rem 0;
  overflow: visible;
  position: relative;
  line-height: 0;
}

.clipart img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Float right — ghosted into text flow */
.clipart--float-right {
  float: right;
  width: 35%;
  margin: 0 0 1.5rem 2rem;
  shape-outside: margin-box;
}

/* Float left — ghosted into text flow */
.clipart--float-left {
  float: left;
  width: 40%;
  margin: 0 2rem 1.5rem 0;
  shape-outside: margin-box;
}

/* Full-width break between paragraphs */
.clipart--break {
  width: 100%;
  max-width: 100%;
  margin: 3rem 0;
}

.clipart--break img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  object-position: center;
}

/* Effect: multiply blend — sinks into cream background */
.clipart--multiply img {
  mix-blend-mode: multiply;
  opacity: 0.85;
}

/* Effect: screen blend — ghostly overlay */
.clipart--screen img {
  mix-blend-mode: screen;
  opacity: 0.6;
}

/* Effect: darken blend — heavy presence */
.clipart--darken img {
  mix-blend-mode: darken;
  opacity: 0.75;
}

/* Effect: subliminal — barely there */
.clipart--subliminal img {
  mix-blend-mode: screen;
  opacity: 0.45;
  filter: grayscale(100%);
}

/* Effect: washed — dreamy, desaturated */
.clipart--washed img {
  opacity: 0.7;
  filter: grayscale(30%);
}

/* Effect: tilted — slightly unhinged */
.clipart--tilted img {
  transform: rotate(-2deg);
}

/* Clear floats after clipart sections */
.article-content::after {
  content: "";
  display: table;
  clear: both;
}

/* Mobile: no floats, stack full width */
@media (max-width: 768px) {
  .clipart--float-right,
  .clipart--float-left {
    float: none;
    width: 80%;
    margin: 2rem auto;
  }

  .clipart--break img {
    max-height: 250px;
  }
}

/* ============================================================================
   ACCESSIBILITY & RESPONSIVE
   ============================================================================ */

/* High DPI / Retina support */
@media (min-resolution: 2dppx) {
  .featured-image__img,
  .content-image__img,
  .thumbnail__img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Print styles */
@media print {
  .featured-image,
  .content-image,
  .thumbnail-grid {
    page-break-inside: avoid;
  }

  .thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
}

/* Focus outline for keyboard navigation */
.thumbnail-grid__link:focus-visible {
  outline: 2px solid var(--color-text, #333);
  outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
  .thumbnail-grid__link:focus-visible {
    outline-color: #e8e8e8;
  }
}
