/* ============================================
   PIECE PAGES STYLES
   Styles for individual artwork detail pages
   ============================================ */

/* =============================================================
   1. HERO SECTION
   Gallery wall presentation with fade-in animations
   ============================================================= */

.piece-hero {
  position: relative;
  background: transparent; /* Preserves transparent PNG/WebP backgrounds */
  padding: 80px var(--space-3) 40px;
  min-height: auto;
  text-align: center;
}

/* INTENTIONAL: mobile centering for piece hero.
   .piece-hero-inner is inline-block on desktop to
   anchor image and label left together as a unit.
   On mobile this collapses to full-width centered block.
   Do not remove display: block or text-align: center.
   Desktop layout is restored at min-width: 768px below. */
@media (max-width: 767px) {
  .piece-hero {
    padding-top: calc(var(--section-padding-y) * 2);
  }

  .piece-hero-inner {
    display: block;
    width: 100%;
    text-align: center;
  }

  .piece-hero-image {
    margin: 0 auto;
  }

  .piece-hero-content {
    text-align: center;
    margin-inline: auto;
  }

  .details-grid {
    text-align: center;
  }

  .details-specs {
    justify-items: center;
    margin: 0 auto;
  }

  .piece-description p,
  .commission-note-text {
    font-size: var(--text-sm);
  }
}

.piece-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.02) 100%);
  pointer-events: none;
  z-index: 1;
}

.piece-hero-inner {
  display: inline-block;
  max-width: 100%;
  text-align: left;
}

.piece-hero-image-container {
  position: relative;
  z-index: 2;
  max-width: 1400px;
  display: inline-block;
  margin: 0;
  padding: 0 var(--space-3);
}

.piece-hero-image {
  max-width: 100%;
  max-height: 600px;
  width: auto;
  height: auto;
  display: block;
  margin: 0;
  /* Box-shadow removed - interferes with transparent PNG/WebP backgrounds */
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 1.8s ease 0.2s forwards;
}

.piece-hero-content {
  position: relative;
  z-index: 2;
  max-width: 1400px;
  margin: calc(var(--space-6) * 0.525) 0 0;
  padding: 0 var(--space-3);
  text-align: center;
}

.piece-hero-title {
  font-family: var(--font-primary);
  font-size: 1.4rem;
  font-weight: var(--weight-regular);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin: 0 0 calc(var(--space-2) * 0.7);
  opacity: 0;
  animation: fadeInUp 1.8s ease 0.5s forwards;
}

.piece-hero-location {
  font-family: var(--font-secondary);
  font-size: 0.75rem;
  font-weight: var(--weight-regular);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-brass);
  margin: 0;
  opacity: 0;
  animation: fadeInUp 1.8s ease 0.7s forwards;
}

/* =============================================================
   2. DETAILS SECTION
   Specs grid and piece description
   ============================================================= */

.piece-details {
  background: var(--color-bg-primary);
}

.piece-details.section-padded {
  padding-top: calc(var(--section-padding-y) * 0.7);
  padding-bottom: var(--section-padding-y);
}

.details-grid {
  display: block;
  max-width: 900px;
  margin: 0 auto;
}

.details-specs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-3) 0;
  font-family: var(--font-secondary);
  /* INTENTIONAL: increased from 0.7rem to var(--text-sm)
     for mobile legibility. Do not revert to 0.7rem. */
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
  opacity: 0;
  animation: fadeInUp 1.8s ease 0.9s forwards;
}

.detail-item {
  display: contents;
}

.detail-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: var(--weight-semibold);
  margin-right: var(--space-1);
}

.detail-value {
  font-weight: var(--weight-regular);
}

.piece-description {
  padding: var(--space-5) 0 var(--space-5);
  border-bottom: 2px solid var(--color-brass);
  margin-top: var(--space-5);
}

.piece-description p {
  font-family: var(--font-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-3);
}

.piece-commission-note {
  background: var(--color-bg-primary);
  padding: var(--space-5) 0;
  border-top: 1px solid var(--color-border);
}

.commission-note-content {
  max-width: 800px;
  margin: 0 auto;
}

.commission-note-text {
  font-family: var(--font-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin: 0;
  text-align: left;
  font-style: italic;
}

/* =============================================================
   3. GALLERY SECTION
   Image gallery with scroll-triggered fade-in
   ============================================================= */

.piece-gallery {
  background: transparent;
}

.piece-gallery.section-padded {
  padding-top: var(--section-padding-y);
  padding-bottom: calc(var(--section-padding-y) + var(--space-4));
}

.gallery-images {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

/* CRITICAL: padding: 0 is correct and intentional.
   The parent .piece-gallery.section-padded already provides
   horizontal spacing. Adding padding here double-stacks it
   and makes detail images narrower than the hero on mobile.
   Do not restore padding: 0 var(--space-4) or any other
   horizontal padding value. */

.gallery-image-wrapper {
  position: relative;
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.8s ease, transform 1.8s ease;
}

.gallery-image-wrapper.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gallery-image-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  /* Box-shadow removed - interferes with transparent PNG/WebP backgrounds */
}

.gallery-image-wrapper--narrow {
  max-width: 600px;
  margin: 0 auto;
}

/* Mobile: hero gallery image bleeds edge-to-edge —
   the "step closer to the wall" moment.
   Detail images keep their padding and feel narrower
   by contrast, signalling a shift from presence to study.
   CRITICAL: margin: 0 calc(-1 * var(--section-padding-x))
   is intentional negative margin to escape parent padding.
   Do not remove or change to margin: 0 auto. */
@media (max-width: 767px) {
  .gallery-image-wrapper--hero {
    margin-inline: calc(-1 * var(--section-padding-x));
    width: calc(100% + (2 * var(--section-padding-x)));
  }

  .gallery-image-wrapper--hero img {
    width: 100%;
  }
}

.gallery-image-wrapper--narrow img {
  width: 100%;
  height: auto;
}

.gallery-image-wrapper--narrow .gallery-caption {
  padding: 0;
}

.gallery-caption {
  font-family: var(--font-secondary);
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--color-text-secondary);
  text-align: left;
  margin: var(--space-2) 0 0;
  padding: 0 var(--space-2);
  opacity: 0.7;
}

.piece-lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 18, 18, 0.94);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s ease;
  z-index: 3000;
}

.piece-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.piece-lightbox__image {
  width: auto;
  max-width: calc(100vw - (var(--space-4) * 2));
  max-height: calc(100vh - (var(--space-8) * 1.15));
  object-fit: contain;
  transform: scale(0.98);
  transition: transform 0.24s ease;
}

.piece-lightbox.is-open .piece-lightbox__image {
  transform: scale(1);
}

.piece-lightbox__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(247, 246, 243, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--color-gallery-white);
  font-family: var(--font-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.piece-lightbox__close:hover,
.piece-lightbox__close:focus-visible {
  border-color: var(--color-brass);
  color: var(--color-brass);
  outline: none;
}

@media (max-width: 768px) {
  .piece-gallery .gallery-image-wrapper img {
    cursor: zoom-in;
  }
}

/* =============================================================
   4. ARTIST'S NOTE SECTION
   Dark background with drop cap styling
   ============================================================= */

.piece-artists-note {
  background: var(--color-bg-dark);
  padding: var(--section-padding-y) 0;
}

.artists-note-content {
  max-width: 800px;
  margin: 0 auto;
}

.artists-note-text p {
  font-family: var(--font-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-inverse);
  margin: 0 0 var(--space-4);
  opacity: 0.9;
  text-align: left;
}

.artists-note-text p:first-of-type::first-letter {
  font-family: var(--font-primary);
  font-size: 3.5em;
  line-height: 0.9;
  float: left;
  margin: 0.05em 0.1em 0 0;
  color: var(--color-brass);
}

.artists-note-text em {
  color: var(--color-brass);
  font-style: italic;
}

.artists-note-attribution {
  font-family: var(--font-secondary);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--color-brass);
  text-align: right;
  margin-top: var(--space-5);
  opacity: 0.8;
  letter-spacing: 0.05em;
}

/* =============================================================
   5. BACK TO GALLERY BUTTON
   Fixed position, hidden by default; scripts.js toggles .is-visible
   ============================================================= */

.back-to-gallery {
  position: fixed;
  top: 70px;
  left: var(--space-3);
  display: none; /* Hidden on mobile — piece-bottom-nav handles this */
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-primary);
  text-decoration: none;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: color 0.3s ease, opacity 1.2s ease;
}

.back-to-gallery.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-gallery:hover {
  color: var(--color-brass);
}

.back-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
}

.back-to-gallery:hover .back-arrow {
  transform: translateX(-4px);
}

/* =============================================================
   6. ANIMATIONS
   ============================================================= */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================================
   7. RESPONSIVE STYLES (mobile-first)
   ============================================================= */

/* Tablet enhancements */
@media (min-width: 768px) {
  .piece-hero {
    padding: 100px var(--space-4) 50px;
  }

  .piece-hero-image-container {
    padding: 0 var(--space-4);
  }

  /* iPad Mini portrait fit pass:
     keeps hero restrained so specs/details are visible
     without cropping on first view across all 10 pieces. */
  .piece-hero-image {
    max-height: 490px;
  }

  .back-to-gallery {
    display: inline-flex;
    left: var(--space-4);
  }

  .details-specs {
    /* INTENTIONAL: var(--text-sm) not var(--text-xs) —
       keeps spec text legible at tablet. Do not revert
       to var(--text-xs) at this breakpoint. */
    font-size: var(--text-sm);
  }
}

/* INTENTIONAL: tablet keeps centered layout.
   Base .piece-hero-inner is text-align: left; this
   overrides it at tablet. Left-aligned layout
   restores at 1024px below. */
@media (min-width: 768px) and (max-width: 1023px) {
  .piece-hero-inner {
    display: block;
    text-align: center;
  }

  .piece-hero-image {
    margin-left: auto;
    margin-right: auto;
  }

  .piece-hero-content {
    text-align: center;
  }

  /* Tablet conditional size-down:
     when max-height would allow a full-width hero, apply a
     proportional 15% reduction so hero reads smaller than
     the first gallery close-up image. */
  .piece-hero-image.piece-hero-image--tablet-reduced {
    max-width: 85%;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Desktop enhancements */
@media (min-width: 1024px) {
  .piece-hero {
    padding: 120px var(--space-4) 60px;
  }

  .piece-hero-image-container {
    padding: 0 64px;
  }

  .piece-hero-inner {
    display: inline-block;
    text-align: left;
  }

  .piece-hero-content {
    text-align: left;
  }

  .piece-hero-image {
    max-height: 650px;
  }

  .piece-hero-content {
    padding: 0 var(--space-6);
  }

  .piece-hero-title {
    font-size: 2rem;
    letter-spacing: -0.025em;
  }

  .piece-hero-location {
    font-size: 0.8125rem;
    letter-spacing: 0.25em;
  }

  /* INTENTIONAL: reduced from var(--space-10) to
     var(--space-6) — images read as a sequential
     study rather than disconnected elements.
     Do not increase back to var(--space-10). */
  .gallery-images {
    gap: var(--space-6);
  }

  .back-to-gallery {
    top: 100px;
    left: var(--space-6);
    font-size: var(--text-sm);
  }
}

.artists-note-collection-link {
  font-family: var(--font-secondary);
  /* INTENTIONAL: increased from 0.65rem to var(--text-xs)
     for legibility. Do not revert to 0.65rem. */
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-align: right;
  margin-top: var(--space-3);
}

.collection-thread-link {
  color: var(--color-text-inverse);
  text-decoration: none;
  opacity: 0.45;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.collection-thread-link:hover {
  opacity: 1;
  color: var(--color-brass);
}

/* =============================================================
   8. PIECE BOTTOM NAV
   Sits inside the dark artist's note section.
   Section padding handles all spacing above —
   no margin-top needed. Gallery White at low opacity
   reads cleanly on dark background; brass on hover.
   Appears across all breakpoints.
   ============================================================= */

.piece-bottom-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(247, 246, 243, 0.1);
  margin: var(--space-4) auto 0;
  max-width: 800px;
  min-height: 3.5rem;
}

.piece-bottom-nav-link {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: var(--space-2);
  font-family: var(--font-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  /* CRITICAL: color is Gallery White, not brass —
     nav sits on dark background. Do not change to
     var(--color-brass) or var(--color-text-primary). */
  color: var(--color-gallery-white);
  text-decoration: none;
  opacity: 0.45;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.piece-bottom-nav-link:hover {
  opacity: 1;
  color: var(--color-brass);
}

.piece-bottom-nav-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
}

/* CRITICAL: arrow directions are intentionally asymmetric.
   Do not swap or normalize them. */
.piece-bottom-nav-link--back:hover .piece-bottom-nav-arrow {
  transform: translateX(-3px);
}

.piece-bottom-nav-link--forward:hover .piece-bottom-nav-arrow {
  transform: translateX(3px);
}

.piece-bottom-nav-link--forward {
  text-align: right;
}
