/* ------------------------------------------
   ARTIST PAGE GALLERY — BASE STYLES
------------------------------------------- */

/* Prevent horizontal overflow on artist show pages (Chrome 100vw bug) */
body.artists.show {
  overflow-x: clip;
}

/* Override overflow for artist show page to show arrows outside gallery */
body.artists.show main.page {
  overflow: visible;
  grid-column: full-start / full-end;
  display: grid;
  grid-template-columns: subgrid;
  background-color: var(--shw);
  position: relative;
  z-index: 19;
  padding: 50px 16px 200px;
}

@media (max-width: 768px) {
  body.artists.show main.page {
    padding: 32px 16px 100px;
  }
}

@media (max-width: 480px) {
  body.artists.show main.page {
    padding: 24px 12px 80px;
  }
}

body.artists.show main.page>* {
  grid-column: content-start / content-end;
}

/* Gallery wrapper */
.artistpage-gallery-container {
  width: 100%;
  position: relative;
  overflow: visible;
}

/* Controls container (holds arrows + track) */
.artistpage-gallery-controls {
  position: relative;
  width: 100%;
  margin: 0 auto;
  overflow: visible;
  --gap: 90px;
  --visible: 3;
  box-sizing: border-box;
}

/* Track: horizontal carousel */
.artistpage-gallery {
  display: flex;
  gap: auto;
  overflow: hidden;
  scroll-behavior: smooth;
  align-items: center;
}

/* Artwork card */
.artwork-card {
  flex: 0 0 calc((100% - (var(--visible) - 1) * var(--gap)) / var(--visible));
  aspect-ratio: 4 / 5;
  box-sizing: border-box;
  display: block;
  overflow: hidden;
  background: var(--grey-100);
}

/* Image */
.artwork-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ------------------------------------------
   ARROWS (Switch to Image Icons)
------------------------------------------- */

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: none;
  /* remove background */
  border: 0;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.arrow-img {
  width: 30px;
  height: auto;
  object-fit: contain;
}

.gallery-arrow--left {
  left: -60px;
  transform: translateY(-50%);
}

.gallery-arrow--right {
  right: -60px;
  transform: translateY(-50%);
}

/* hide arrow when disabled */
.gallery-arrow[aria-hidden="true"] {
  display: none;
}

/* ------------------------------------------
   RESPONSIVE — MOBILE FIRST
------------------------------------------- */

@media (max-width: 640px) {
  .artistpage-gallery-controls {
    --visible: 1;
    --gap: 16px;
    padding-left: 0;
    padding-right: 0;
    overflow: visible;
  }

  .artistpage-gallery {
    padding: 8px 0;
  }

  .gallery-arrow {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .gallery-arrow--left {
    left: 8px;
  }

  .gallery-arrow--right {
    right: 8px;
  }

  .arrow-img {
    width: 20px;
  }
}

/* Tablet */
@media (min-width: 641px) and (max-width: 980px) {
  .artistpage-gallery-controls {
    --visible: 3;
    --gap: 60px;
  }

  .gallery-arrow {
    width: 36px;
    height: 36px;
  }
}

/* Desktop */
@media (min-width: 981px) {
  .artistpage-gallery-controls {
    --visible: 3;
    --gap: 90px;
  }
}

/* ------------------------------------------
   COVER HERO SECTION
------------------------------------------- */

.cover-hero {
  position: sticky;
  top: 0;
  grid-column: 1 / -1;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.cover-logo {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  height: 40px;
  width: auto;
  /* Subtle drop shadow for visibility on bright/saturated images */
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25));
}

.cover-title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--shw);
  text-align: center;
  font-family: Montserrat;
  font-size: 48px;
  font-weight: 600;
  line-height: 52px;
  letter-spacing: 2.56px;
  text-transform: uppercase;
  /* Subtle text shadow for readability on saturated images */
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 40px 60px;
  z-index: 2;
}

/* Gradient overlay behind title for better contrast on busy images */
.cover-title::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%;
  height: 150%;
  background: radial-gradient(ellipse at center,
      rgba(0, 0, 0, 0.15) 0%,
      rgba(0, 0, 0, 0.08) 40%,
      transparent 70%);
  z-index: -1;
  pointer-events: none;
}

/* Mobile hero optimization - hide cover section on mobile */
@media (max-width: 768px) {
  .cover-hero {
    display: none;
  }
}

/* Default cover background when no image is uploaded */
.cover-hero--default {
  background-color: var(--dc-greys-900);
}

/* Cover image change button styling */
.cover-image-actions {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 10;
}

/* Mobile sticky CTA button - hidden by default on desktop */
.mobile-sticky-cta {
  display: none;
}

@media (max-width: 768px) {
  .mobile-sticky-cta {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 16px 24px;
    background-color: var(--mb);
    color: var(--shw);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 540;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    justify-content: center;
    align-items: center;
    border: none;
    z-index: 100;
    cursor: pointer;
    transition:
      transform 0.3s ease,
      opacity 0.3s ease;
    /* Add safe area padding for notched phones */
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  /* Hidden state */
  .mobile-sticky-cta.hidden {
    transform: translateY(100%);
    opacity: 0;
  }

  /* Visible state */
  .mobile-sticky-cta.visible {
    transform: translateY(0);
    opacity: 1;
  }

  /* Add padding to main content so button doesn't overlap */
  body.artists.show main.page {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

.cover-image-form {
  display: flex;
  align-items: center;
}

.cover-image-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 600px) {
  .cover-image-actions {
    bottom: 12px;
    right: 12px;
  }

  .cover-image-button {
    padding: 8px 14px;
    font-size: 10px;
  }
}

/* ------------------------------------------
   DASHBOARD ARTWORK GALLERY
------------------------------------------- */

.gallery-hint {
  color: var(--dc-greys-900);
  font-size: 14px;
  margin-top: 20px !important;
  text-transform: none;
}

.artworks-dashboard-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--crotchet);
  margin-bottom: var(--minim);
}

@media only screen and (min-width: 640px) {
  .artworks-dashboard-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* Artwork gallery item */
.artwork-gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
  background: var(--grey-100);
}

.artwork-gallery-item:active {
  cursor: grabbing;
}

/* Position badge */
.artwork-gallery-item__position {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  z-index: 3;
  pointer-events: none;
}

/* Drag handle */
.artwork-gallery-item__drag-handle {
  position: absolute;
  top: 8px;
  right: 40px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 3;
  color: var(--dc-greys-700);
}

.artwork-gallery-item:hover .artwork-gallery-item__drag-handle {
  opacity: 1;
}

.artwork-gallery-item__drag-handle:active {
  cursor: grabbing;
}

/* Delete button */
.artwork-gallery-item__delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
  z-index: 3;
  color: var(--dc-greys-700);
}

.artwork-gallery-item:hover .artwork-gallery-item__delete {
  opacity: 1;
}

.artwork-gallery-item__delete:hover {
  background: #dc2626;
  color: white;
}

/* Link wrapper */
.artwork-gallery-item__link {
  display: block;
  width: 100%;
  height: 100%;
}

.artwork-in-grid {
  object-fit: cover;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
}

.artwork-gallery-item.dragging {
  opacity: 0.5;
  z-index: 100;
}

.artwork-gallery-item.drag-ghost {
  opacity: 0.3;
}

.artwork-gallery-item.drag-over {
  transform: scale(0.98);
  box-shadow: 0 0 0 3px var(--dc-greys-900);
}

.artwork-gallery-item.touch-dragging {
  opacity: 0.7;
  transform: scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

/* Removing animation */
.artwork-gallery-item.removing {
  animation: fadeOutScale 0.3s ease forwards;
}

@keyframes fadeOutScale {
  from {
    opacity: 1;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

/* ------------------------------------------
   TOAST NOTIFICATIONS
------------------------------------------- */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--dc-greys-900, #1f2937);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  /* animation moved to components/toast.css to avoid conflicts */
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* ------------------------------------------
   ARTWORK FORM
------------------------------------------- */

.artwork-form-preview {
  object-fit: contain;
  height: 100%;
  width: 100%;
}

/* artwork form */
.artwork-form-image-preview {
  display: block;
  width: 400px;
  object-fit: contain;

  &.placeholder {
    height: 200px;
    background-color: var(--grey-100);
  }
}

/* ------------------------------------------
   MOBILE RESPONSIVE — GALLERY MANAGEMENT
------------------------------------------- */

@media (max-width: 640px) {

  .artwork-gallery-item__drag-handle,
  .artwork-gallery-item__delete {
    opacity: 1;
  }

  .artwork-gallery-item__drag-handle {
    top: 6px;
    right: 34px;
    width: 24px;
    height: 24px;
  }

  .artwork-gallery-item__delete {
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
  }

  .artwork-gallery-item__position {
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    padding: 10px 16px;
    font-size: 13px;
  }
}