/* ========== SINGLE ALBUM PAGE STYLES ========== */
/* Extracted from BonzaUI single-album.html */

/* ========== ALBUM CONTENT ========== */
.album-content {
  padding: 0 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 100%;
}

/* ========== ALBUM HEADER CARD ========== */
.album-header {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  padding: 8px;
  position: relative;
}

.album-header-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.album-header-bg img {
  width: 100%;
  filter: blur(9px);
  opacity: 1;
  position: absolute;
  bottom: 0;
}

.album-header-top {
  position: relative;
  z-index: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.album-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.album-title {
  flex: 1;
  font-size: 24px;
  font-weight: 500;
  line-height: 32px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

.album-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.album-actions img {
  width: 20px;
  height: 20px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
  filter: invert(1);
}

.album-actions img:hover {
  opacity: 1;
}

/* Delete-all: icon plus the word, because "all" is the part that matters.
   The label collapses on a phone, where the title has the width — the
   aria-label carries the full sentence either way. */
.album-delete-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--neutral-700);
  background: var(--neutral-800);
  color: var(--neutral-300);
  font-family: 'Heebo', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.album-delete-all img {
  /* Overrides `.album-actions img`, which is sized for a bare icon. */
  width: 15px;
  height: 15px;
  opacity: 1;
  filter: brightness(0) invert(1);
}

.album-delete-all:hover {
  color: #fff;
  border-color: var(--rose-58-solid, #E8508A);
  background: rgba(232, 80, 138, 0.12);
}

.album-delete-all:focus-visible {
  outline: 2px solid var(--purple-400);
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .album-delete-all span { display: none; }
  .album-delete-all { padding: 6px; }
}

.album-badges {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.album-badge-filled {
  background: var(--purple-400);
  color: var(--purple-900);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 16px;
  font-weight: 600;
}

/* ========== CHARACTER BAR INSIDE HEADER ========== */
.album-character-bar {
  position: relative;
  z-index: 1;
  background: #000;
  border-radius: 12px;
  padding: 8px 16px 8px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.album-char-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.album-char-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  object-position: top;
}

.album-char-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-char-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-char {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--neutral-700);
  border: none;
  border-radius: 8px;
  padding: 6px 16px 6px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Heebo', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-char:hover {
  background: var(--neutral-600);
}

.btn-char img {
  width: 20px;
  height: 20px;
  filter: invert(1);
}

/* ========== GENERATE BUTTON ========== */
.btn-generate-album {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 16px 6px 10px;
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 20px rgba(255,255,255,0.56);
  cursor: pointer;
  font-family: 'Heebo', sans-serif;
  transition: opacity 0.2s;
}

.btn-generate-album:hover {
  opacity: 0.9;
}

.btn-generate-album img {
  width: 20px;
  height: 20px;
}

/* ========== PHOTO GRID ========== */
.photo-grid {
  display: flex;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap;
}

.photo-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.photo-card {
  width: 100%;
  height: 300px;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.3);
  background: var(--neutral-800);
  cursor: pointer;
  transition: all 0.2s;
}

/* Albums contain videos too, shown as a <video> parked at their first frame.
   It has to fill the tile exactly as an <img> does — selecting img alone left
   video entries at their intrinsic size, blowing the grid apart. */
.photo-card img,
.photo-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The video tile's wrapper — the IntersectionObserver watches this, so it
   must fill the card. A zero-area element would never intersect and the
   frame would never load. */
.photo-video {
  display: block;
  position: absolute;
  inset: 0;
}

/* Play badge marking a tile as a clip rather than a still. */
.photo-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  /* Nudge the glyph: a triangle centred by its bounding box reads as
     left-of-centre inside a circle. */
  padding-left: 3px;
}

.photo-card.selected {
  border-color: var(--purple-400);
  box-shadow: 0 0 28px rgba(204,149,255,0.7);
}

.photo-card:hover {
  transform: translateY(-2px);
}

.photo-card-actions {
  position: absolute;
  bottom: 7px;
  right: 7px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.photo-card.selected .photo-card-actions {
  opacity: 1;
}

.photo-card-delete {
  position: absolute;
  bottom: 7px;
  left: 7px;
  opacity: 0;
  transition: opacity 0.2s;
}

.photo-card:hover .photo-card-delete,
.photo-card.selected .photo-card-delete {
  opacity: 1;
}

.photo-action-btn {
  background: var(--neutral-700);
  border: none;
  border-radius: 8px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.photo-action-btn:hover {
  background: var(--neutral-600);
}

.photo-action-btn img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
}

.btn-char-studio {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--neutral-700);
  border: 1px solid var(--neutral-600);
  border-radius: 8px;
  padding: 6px 12px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Heebo', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-char-studio:hover {
  background: var(--neutral-600);
}

.btn-char-studio img {
  width: 16px;
  height: 16px;
  filter: invert(1);
}

/* ========== EMPTY STATE ========== */
.album-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 40px 16px;
  width: 100%;
}

.album-empty.show {
  display: flex;
}

.album-empty-illustration {
  width: 329px;
  height: 224px;
  position: relative;
}

.album-empty-card {
  position: absolute;
  width: 145px;
  height: 145px;
  border-radius: 16px;
  overflow: hidden;
}

.album-empty-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.album-empty-card:nth-child(1) {
  background: var(--neutral-700);
  top: 50%;
  left: 50%;
  transform: translate(calc(-50% - 50px), calc(-50% + 16px)) rotate(9.3deg);
}

.album-empty-card:nth-child(2) {
  background: var(--neutral-800);
  top: 50%;
  left: 50%;
  transform: translate(calc(-50% + 42px), calc(-50% - 10px)) rotate(-16.67deg);
}

.album-empty-text {
  font-size: 12px;
  color: var(--neutral-500);
  text-align: center;
}

/* ========== LIGHTBOX ========== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.95);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lightbox.open {
  display: flex;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--neutral-700);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: var(--neutral-600);
}

.lightbox-close svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
}

.lightbox-download {
  position: absolute;
  top: 16px;
  right: 64px;
  background: var(--neutral-700);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s;
}

.lightbox-download:hover {
  background: var(--neutral-600);
}

.lightbox-download svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
}

.lightbox-counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--neutral-400);
  z-index: 2;
}

.lightbox-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.lightbox-track {
  display: flex;
  align-items: center;
  height: 100%;
  transition: transform 0.3s ease;
  will-change: transform;
}

.lightbox-slide {
  min-width: 100vw;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 80px;
}

.lightbox-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--neutral-700);
  border: 1px solid var(--neutral-600);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s, opacity 0.2s;
}

.lightbox-arrow:hover {
  background: var(--neutral-600);
}

.lightbox-arrow.hidden {
  opacity: 0;
  pointer-events: none;
}

.lightbox-arrow svg {
  width: 24px;
  height: 24px;
  stroke: #fff;
  fill: none;
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.lightbox-thumbs {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 2;
  padding: 8px;
  background: rgba(0,0,0,0.6);
  border-radius: 12px;
  max-width: 90%;
  overflow-x: auto;
}

.lightbox-thumbs::-webkit-scrollbar {
  height: 4px;
}

.lightbox-thumbs::-webkit-scrollbar-track {
  background: transparent;
}

.lightbox-thumbs::-webkit-scrollbar-thumb {
  background: var(--neutral-600);
  border-radius: 2px;
}

.lightbox-thumb {
  width: 48px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.lightbox-thumb.active {
  border-color: var(--purple-400);
  opacity: 1;
}

.lightbox-thumb:hover {
  opacity: 0.8;
}

.lightbox-thumb img,
.lightbox-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ========== LOADING & ERROR STATES ========== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--neutral-700);
  border-top-color: var(--purple-400);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  font-size: 14px;
  color: var(--neutral-400);
}

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  text-align: center;
}

.error-container p {
  font-size: 16px;
  color: var(--neutral-400);
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 1024px) {
  .photo-card-wrap {
    width: calc(33.33% - 11px);
  }
  
  .photo-card {
    height: 250px;
  }
}

@media (max-width: 768px) {
  .album-character-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .album-char-actions {
    width: 100%;
  }
  
  .btn-char {
    flex: 1;
    justify-content: center;
  }
  
  .photo-grid {
    gap: 8px;
  }
  
  .photo-card-wrap {
    width: calc(33.33% - 6px);
  }
  
  .photo-card {
    height: auto;
    aspect-ratio: 2/3;
  }
  
  .lightbox-slide {
    padding: 60px 16px;
  }
  
  .lightbox-arrow {
    width: 36px;
    height: 36px;
  }
  
  .lightbox-prev {
    left: 8px;
  }
  
  .lightbox-next {
    right: 8px;
  }
  
  .lightbox-thumbs {
    gap: 4px;
    padding: 6px;
  }
  
  .lightbox-thumb {
    width: 36px;
    height: 48px;
  }
}

@media (max-width: 480px) {
  .photo-card-wrap {
    width: calc(50% - 4px);
  }
  
  .album-title {
    font-size: 20px;
  }
  
  .album-empty-illustration {
    width: 260px;
    height: 180px;
  }
  
  .album-empty-card {
    width: 115px;
    height: 115px;
  }
}

/* Delete Modal */
.delete-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.delete-modal {
  background: var(--neutral-800);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.delete-modal h3 {
  margin: 0 0 16px 0;
  font-size: 24px;
  font-weight: 600;
  color: #fff;
}

.delete-modal p {
  margin: 0 0 24px 0;
  font-size: 16px;
  color: var(--neutral-300);
  line-height: 1.5;
}

.delete-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.delete-modal-actions button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel {
  background: var(--neutral-700);
  color: #fff;
}

.btn-cancel:hover {
  background: var(--neutral-600);
}

.btn-confirm {
  background: #e74c3c;
  color: #fff;
}

.btn-confirm:hover {
  background: #c0392b;
}

/* AI Modal */
.ai-modal {
  background: #131313;
  border: 1px solid #2e2e2e;
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.modal-close-btn svg {
  transition: transform 0.2s;
}

.modal-close-btn:hover svg {
  transform: rotate(90deg);
}

/* Photo Skeleton Loading */
.photo-card {
  position: relative;
}

.photo-skeleton {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--neutral-700) 0%,
    var(--neutral-600) 50%,
    var(--neutral-700) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 16px;
  z-index: 1;
  pointer-events: none;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ── Deleting state ─────────────────────────────────────────────────────── */
/* Applied while a DELETE for this image is in flight. The card is desaturated
   + blurred and locked from interaction so the user can't fire a second
   request for the same image. */
.photo-card.is-deleting {
  pointer-events: none;
  cursor: default;
}

.photo-card.is-deleting img {
  /* Ramp into grayscale+blur, then keep breathing until the request settles. */
  animation: deletingEnter 0.35s ease forwards,
             deletingPulse 1.6s ease-in-out 0.35s infinite;
  transform-origin: center;
}

@keyframes deletingEnter {
  from {
    filter: grayscale(0) blur(0) brightness(1);
    transform: scale(1);
  }
  to {
    filter: grayscale(1) blur(3px) brightness(0.5);
    transform: scale(0.97);
  }
}

@keyframes deletingPulse {
  0%, 100% {
    filter: grayscale(1) blur(3px) brightness(0.5);
    transform: scale(0.97);
  }
  50% {
    filter: grayscale(1) blur(6px) brightness(0.32);
    transform: scale(0.94);
  }
}

.photo-deleting-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 16px;
  z-index: 3;
  pointer-events: none;
  animation: deletingOverlayIn 0.3s ease forwards;
}

@keyframes deletingOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.photo-deleting-overlay span {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  animation: deletingLabelPulse 1.6s ease-in-out infinite;
}

@keyframes deletingLabelPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.btn-char-studio:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.delete-modal .btn-confirm:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ================================================================
   STATUS TOAST — replaces window.alert() on this page.
   Non-blocking: a failed delete must not stall the rest of the
   delete queue behind a modal dialog.
   ================================================================ */
.album-notice {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 12px;
  background: #2a1a1e;
  border: 1px solid #5c2b33;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-family: Heebo, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  color: #e7dcdf;
  animation: albumNoticeIn 0.25s ease forwards;
}

@keyframes albumNoticeIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.album-notice-close {
  flex: 0 0 auto;
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.album-notice-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

@media (prefers-reduced-motion: reduce) {
  .album-notice { animation: none; }
}

/* ================================================================
   FALLBACK SKELETON — server-rendered, shown before React hydrates.
   The page is client:only, so without this the album area is blank
   until the bundle boots AND the album fetch resolves. Reuses
   .photo-grid / .photo-card / .photo-skeleton so the placeholder
   grid has exactly the real geometry and nothing shifts when the
   photos land.
   ================================================================ */
.album-skeleton {
  padding: 0;
}

.album-skeleton-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.album-skeleton-title,
.album-skeleton-sub {
  display: block;
  border-radius: 8px;
  background: var(--neutral-700);
  animation: albumSkeletonPulse 1.6s ease-in-out infinite;
}

.album-skeleton-title {
  width: min(260px, 60%);
  height: 26px;
}

.album-skeleton-sub {
  width: min(160px, 40%);
  height: 16px;
}

@keyframes albumSkeletonPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .album-skeleton-title,
  .album-skeleton-sub {
    animation: none;
  }
}


/*
 * "No more media" under the album grid.
 *
 * grid-column: 1 / -1 so it spans every column and centres against the grid
 * rather than sitting in the first cell. Rendered when the server's cursor
 * is exhausted, so it marks the end of the album and not the end of what
 * happens to be loaded.
 */
/*
 * End of the album.
 *
 * `flex-basis: 100%`, NOT `grid-column: 1 / -1` — .photo-grid is a wrapping
 * flexbox, not a grid, so the grid property did nothing and this sat as one
 * more flex item beside the last photo, looking like stray text.
 *
 * A full-width rule rather than a card. The carousel's end marker is a card
 * because it is a tile among tiles of one height; these cards vary in height
 * and each carries its own button, so a card here would either misalign or
 * read as another tappable thing that does nothing.
 */
.photo-grid-end {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 30px 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--neutral-500);
  /* Not a control: nothing here should offer a cursor or a selection. */
  cursor: default;
  user-select: none;
}

/* Hairlines either side, fading out from the label, so the line reads as a
   boundary rather than an underlined heading. */
.photo-grid-end::before,
.photo-grid-end::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neutral-700));
}
.photo-grid-end::after {
  background: linear-gradient(90deg, var(--neutral-700), transparent);
}
