/* ==========================================================================
   Gallery Styles
   Illuminated manuscript-style image display for resources
   ========================================================================== */

/* --------------------------------------------------------------------------
   Single Image - Float Right (Illuminated Manuscript Style)
   -------------------------------------------------------------------------- */

.gallery-single {
  float: right;
  max-width: 300px;
  margin: 0 0 var(--space-md) var(--space-md);
  padding: 0;
}

.gallery-single img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center 35%;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.15s ease;
  box-shadow: 0 4px 12px var(--shadow-black-strong);
}

.gallery-single img:hover {
  transform: scale(1.02);
}

.gallery-single figcaption {
  font-size: 0.85rem;
  color: var(--warm-grey);
  text-align: center;
  margin-top: var(--space-xs);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Mood Board Row (Multiple Images)
   -------------------------------------------------------------------------- */

.gallery-mood-board {
  display: flex;
  gap: var(--space-xs);
  height: 120px;
  margin-bottom: var(--space-md);
  overflow: hidden;
}

.gallery-mood-board img {
  height: 100%;
  width: auto;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.15s ease;
  box-shadow: 0 2px 4px var(--shadow-black-medium);
}

.gallery-mood-board img:hover {
  transform: scale(1.05);
  z-index: 1;
}

/* --------------------------------------------------------------------------
   Primary Image Indicator (Edit Mode Only)
   -------------------------------------------------------------------------- */

/* Subtle border on first polaroid to indicate which image is used for card backgrounds */
.gallery-polaroid.primary-image {
  border: 3px solid var(--warm-grey-dark);
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Polaroid Thumbnails (Edit Mode)
   -------------------------------------------------------------------------- */

.gallery-upload-section {
  margin-bottom: var(--space-md);
}

.gallery-upload-section > label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.gallery-polaroids {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.gallery-polaroid {
  display: inline-block;
  background: #fff;
  padding: var(--space-xs);
  padding-bottom: calc(var(--space-xs) + 20px);
  box-shadow: 0 2px 4px var(--shadow-black-medium);
  position: relative;
  border-radius: 2px;
  transform: rotate(-1deg);
}

.gallery-polaroid:nth-child(2) {
  transform: rotate(1deg);
}

.gallery-polaroid:nth-child(3) {
  transform: rotate(-0.5deg);
}

.gallery-polaroid:nth-child(4) {
  transform: rotate(1.5deg);
}

.gallery-polaroid img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  display: block;
}

.gallery-polaroid-pdf-placeholder {
  width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--parchment-light);
  border: 1px dashed var(--parchment-dark);
}

.gallery-polaroid-pdf-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.gallery-polaroid-pdf-label {
  font-size: 0.6rem;
  color: var(--warm-grey);
  text-align: center;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: var(--space-xs);
}

.gallery-polaroid-delete {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  background: var(--warm-grey);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.gallery-polaroid-delete:hover {
  opacity: 1;
  background: var(--danger);
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Gallery Upload Dropzone
   -------------------------------------------------------------------------- */

.gallery-upload-dropzone {
  margin-top: var(--space-sm);
}

.gallery-dropzone {
  border: 2px dashed var(--parchment-dark);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.gallery-dropzone:hover,
.gallery-dropzone.file-upload-dragover {
  border-color: var(--warm-grey);
  background-color: var(--parchment-light);
}

.gallery-dropzone .file-upload-prompt {
  color: var(--warm-grey);
  margin: 0;
}

/* --------------------------------------------------------------------------
   Lightbox Overlay
   -------------------------------------------------------------------------- */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
  animation: lightbox-fade-in 0.2s ease;
}

@keyframes lightbox-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  cursor: default;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-sm);
  animation: lightbox-scale-in 0.2s ease;
}

@keyframes lightbox-scale-in {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   PDF Attachments (View Mode)
   -------------------------------------------------------------------------- */

.resource-pdf-attachments {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--parchment-dark);
}

.resource-pdf-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--parchment-light);
  border: 1px solid var(--parchment-dark);
  border-radius: var(--radius-sm);
  color: var(--warm-grey-dark);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.resource-pdf-link:hover {
  background: var(--parchment-base);
  border-color: var(--warm-grey-light);
}

.resource-pdf-icon {
  font-size: 1.25rem;
}

.resource-pdf-filename {
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Clear Float (for description text)
   -------------------------------------------------------------------------- */

.rich-text-display::after,
.trait-content::after {
  content: "";
  display: table;
  clear: both;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 768px) /* tablet */ {
  /* Remove float on mobile - center images instead */
  .gallery-single {
    float: none;
    max-width: 100%;
    margin: 0 auto var(--space-md);
  }

  /* Make mood board scrollable horizontally on mobile */
  .gallery-mood-board {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Make gallery grid responsive */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);  /* 2 columns instead of 3+ */
    gap: var(--space-xs);
  }
}

/* Extra small - single column gallery */
@media (max-width: 480px) /* mobile */ {
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}
