/* ==========================================================================
   Photo Detail Page — photo_detail.css
   ========================================================================== */

/* ── Action Bar ─────────────────────────────────────────────────────────── */
.photo-actions-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  /* dark mode default */
  background: rgba(18, 18, 26, 0.80);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.18);
}

/* light mode override */
[data-theme="light"] .photo-actions-bar {
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 10px rgba(0, 0, 0, 0.08);
}

/* ── Action bar buttons — violet accent in both modes ────────────────────── */
.photo-actions-bar .btn-ghost {
  color: var(--color-primary, #8b5cf6);
  border: 1px solid rgba(139, 92, 246, 0.30);
  background: rgba(139, 92, 246, 0.07);
}

.photo-actions-bar .btn-ghost:hover,
.photo-actions-bar .btn-ghost:focus-visible {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.55);
  color: var(--color-primary, #8b5cf6);
}

[data-theme="light"] .photo-actions-bar .btn-ghost {
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.06);
}

[data-theme="light"] .photo-actions-bar .btn-ghost:hover,
[data-theme="light"] .photo-actions-bar .btn-ghost:focus-visible {
  background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.5);
}

.photo-actions-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
  flex-wrap: wrap;
}

/* Centered variant — used on photo detail full page (no back button) */
.photo-actions-bar__inner--centered {
  justify-content: center;
}

.photo-actions-bar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* nowrap: the action bar is sticky, so if its buttons re-wrap to a 2nd line
     (e.g. when the Inter web-font swaps in and text metrics change) the bar's
     height changes and the whole page content below jumps vertically (CLS).
     Keeping a single row makes the bar height font-independent. */
  flex-wrap: nowrap;
  position: relative;
}

/* The Edit button's wrapper (its menu: collections.css) — here, in the blocking CSS, so the
   bar has its final height before the deferred CSS arrives (no CLS). */
.photo-edit-dd {
  position: relative;
  display: inline-flex;
}

/* Narrow screens: allow wrapping (buttons can't fit one row) — the resulting
   font-swap shift is small on mobile and acceptable vs. horizontal overflow. */
@media (max-width: 640px) {
  .photo-actions-bar__right {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Back button arrow icon */
.photo-back svg {
  flex-shrink: 0;
  transform: translateY(1px);
}

/* ── Main image area ─────────────────────────────────────────────────────── */
.photo-detail-wrap {
  padding-top: 2.5rem;
  padding-bottom: 4rem;
  max-width: 1120px;
  margin-inline: auto;
}

/* ── Detail row: image left, info right ──────────────────────────────────── */
.photo-detail-row {
  display: flex;
  flex-direction: row;
  gap: 1.25rem;
  align-items: flex-start;
  margin-bottom: 3rem;
  justify-content: center;
}
.photo-detail-row__image {
  flex: 1 1 auto;
  min-width: 0;
  order: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Portrait: image is narrow — don't let the container expand; center the pair */
.photo-detail-row[data-orientation="portrait"] .photo-detail-row__image {
  flex: 0 1 auto;
}
.photo-detail-row__info {
  flex: 1 1 300px;
  min-width: 280px;
  max-width: 520px;
  order: 1;
}
.photo-detail-row[data-orientation="landscape"] .photo-detail-row__info,
.photo-detail-row[data-orientation="square"] .photo-detail-row__info {
  flex: 1 1 420px;
  min-width: 340px;
  max-width: 560px;
}
.photo-detail-row__info .meta-card__title {
  text-align: center;
}

@media (max-width: 768px) {
  .photo-detail-row {
    flex-direction: column;
    align-items: center;
  }
  .photo-detail-row__image {
    order: 0;
    width: 100%;
  }
  .photo-detail-row__info {
    flex: 1 1 auto;
    max-width: 100%;
    order: 1;
  }
}

.photo-main {
  text-align: center;
  margin-bottom: 0;
  /* Fill the flex image column so the trigger/img get a definite width. Without
     this the chain collapses to the unloaded img's 0px width and the reserved
     aspect-ratio box (plus its blur-hash placeholder) has nothing to size to. */
  width: 100%;
}

.photo-main__trigger {
  display: block;
  border: none;
  background: none;
  padding: 0;
  cursor: zoom-in;
  border-radius: 0.75rem;
  overflow: hidden;
  outline: none;
  width: 100%;
  max-width: 100%;
  transition: opacity 0.2s;
}

.photo-main__trigger:focus-visible {
  box-shadow: 0 0 0 3px var(--color-primary, #8b5cf6);
}

.photo-main__trigger:hover {
  opacity: 0.93;
}

/* Hide the image (and its broken-image/alt glyph) while the blur-hash
   placeholder is showing, so a cold proxy fetch shows only the blur. */
.photo-main__img.bh-pending {
  opacity: 0;
  transition: opacity 0.4s ease-out;
}

.photo-main__img {
  display: block;
  /* Definite width + inline aspect-ratio reserves the box height before the
     image loads, so the blur-hash placeholder is visible instead of a blank
     0-height box (which collapsed the column on a cold image-proxy miss). */
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 0.75rem;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
}

.photo-main__credit {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted, #71717a);
}

.photo-main__credit a {
  color: var(--color-text-muted, #71717a);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.photo-main__credit a:hover {
  color: var(--color-text, #e4e4e7);
}

/* ── Metadata grid ───────────────────────────────────────────────────────── */
.photo-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 3rem;
}

@media (max-width: 700px) {
  .photo-meta-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Meta card ────────────────────────────────────────────────────────────── */
.meta-card {
  background: var(--color-surface, #12121a);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.06));
  border-radius: 0.875rem;
  padding: 1.25rem 1.5rem;
}

.meta-card__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-text-muted, #71717a);
  margin: 0 0 1rem 0;
}

.meta-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.06));
}

.meta-row:last-child {
  border-bottom: none;
}

.meta-row--full {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.meta-row dt {
  font-size: 0.8125rem;
  color: var(--color-text-muted, #71717a);
  white-space: nowrap;
  flex-shrink: 0;
}

.meta-row dd {
  font-size: 0.875rem;
  color: var(--color-text, #e4e4e7);
  text-align: end;
  line-height: 1.5;
}

.meta-row--full dd {
  text-align: start;
}

/* alt_description rendered as <h1> for SEO — reset browser h1 defaults to match <dd> */
.meta-row--full h1 {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text, #e4e4e7);
  margin: 0;
  padding: 0;
}

[data-theme="light"] .meta-row--full h1 {
  color: var(--color-text, #18181b);
}

/* Color swatch */
.meta-color {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.meta-color__link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.meta-color__link--hex {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.meta-color__dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

/* Source badge */
.badge--source {
  display: inline-block;
  padding: 0.15em 0.55em;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 0.35em;
  background: rgba(139, 92, 246, 0.18);
  color: var(--color-primary, #8b5cf6);
  border: 1px solid rgba(139, 92, 246, 0.3);
  text-transform: capitalize;
}

/* ── Keyword tags ─────────────────────────────────────────────────────────── */
.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}
.keyword-tag {
  display: inline-block;
  padding: 0.2em 0.6em;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 0.35em;
  background: rgba(139, 92, 246, 0.12);
  color: var(--color-primary, #8b5cf6);
  border: 1px solid rgba(139, 92, 246, 0.2);
  text-transform: capitalize;
}
.keyword-tag--link {
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.keyword-tag--link:hover {
  background: rgba(139, 92, 246, 0.22);
  border-color: rgba(139, 92, 246, 0.4);
}
.keyword-tag--hidden {
  display: none;
}
.keyword-tags__more {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.7em;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 0.35em;
  background: rgba(255,255,255,0.06);
  color: var(--color-text-muted, #a1a1aa);
  border: 1px solid rgba(255,255,255,0.10);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.keyword-tags__more:hover {
  background: rgba(255,255,255,0.10);
  color: var(--color-text, #e4e4e7);
}
[data-theme="light"] .keyword-tag {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.18);
}
[data-theme="light"] .keyword-tag--link:hover {
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.3);
}
[data-theme="light"] .keyword-tags__more {
  background: #f4f4f5;
  color: #52525b;
  border-color: #d4d4d8;
}

/* ── Download dropdown ────────────────────────────────────────────────────── */
.download-dropdown {
  position: relative;
  display: inline-block;
}

.btn-success {
  background: var(--color-primary, #8b5cf6);
  color: #fff;
  border: 1px solid transparent;
  gap: 0.375rem;
}

.btn-success:hover,
.btn-success:focus-visible {
  background: #7c3aed;
}

.download-trigger__chevron {
  transition: transform 0.18s ease;
  flex-shrink: 0;
  margin-inline-start: 0.125rem;
}

.download-trigger[aria-expanded="true"] .download-trigger__chevron {
  transform: rotate(180deg);
}

.download-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 14rem;
  background: #12121a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.625rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  list-style: none;
  margin: 0;
  padding: 0.375rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}

.download-menu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.download-menu li {
  list-style: none;
}

.download-menu li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #e4e4e7;
  text-decoration: none;
  gap: 0.75rem;
  cursor: pointer;
  transition: background 0.12s;
}

.download-menu li a:hover,
.download-menu li a:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.download-menu__size {
  color: #71717a;
  font-size: 0.75rem;
  white-space: nowrap;
}

.download-menu__divider {
  border: none;
  padding: 0 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  margin: 0.25rem 0;
  cursor: default !important;
}

/* ── Like button ──────────────────────────────────────────────────────────── */
.photo-like {
  color: var(--color-text-muted, #71717a);
}

.photo-like.is-liked {
  color: #f43f5e;
}

.photo-like.is-liked svg {
  fill: #f43f5e;
}

/* ── Similar photos ───────────────────────────────────────────────────────── */
.similar-section {
  margin-top: 2rem;
}

.similar-section__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text, #e4e4e7);
  margin: 0 0 1.25rem 0;
}

.similar-masonry {
  display: flex;
  gap: 0.75rem;
}

.similar-masonry .masonry-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.similar-masonry .photo-card {
  width: 100%;
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  position: relative;
  background: var(--color-surface, #12121a);
  cursor: pointer;
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.similar-masonry .photo-card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.similar-masonry .photo-card__link {
  display: block;
  position: relative;
}

.similar-masonry .photo-card__img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.similar-masonry .photo-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 200ms ease;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.5rem;
}

.similar-masonry .photo-card:hover .photo-card__overlay {
  opacity: 1;
}

.similar-masonry .photo-card__photographer {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
}

.similar-masonry .photo-card__source {
  font-size: 0.65rem;
  text-transform: capitalize;
  background: rgba(0,0,0,0.5);
  color: rgba(255,255,255,0.8);
  padding: 2px 6px;
  border-radius: 99px;
}

.similar-masonry .photo-card__relevance-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-color, #888);
  box-shadow: 0 0 6px 2px var(--dot-color, #888);
  cursor: help;
  transition: transform 180ms ease;
}

.similar-masonry .photo-card__relevance-dot:hover {
  transform: scale(1.5);
}

/* ── Similar photos — blur gate ───────────────────────────────────────────── */
.photo-card--blurred {
  pointer-events: none;
  user-select: none;
  position: relative;
}

.photo-card--blurred .photo-card__img {
  filter: blur(10px);
  transform: scale(1.06); /* hide blur edge artifacts */
}

.similar-blur-gate {
  margin-top: 1.5rem;
  padding: 2rem 1.5rem;
  border-radius: var(--radius-lg, 12px);
  background: var(--color-surface-raised, rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.similar-blur-gate__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text, #e4e4e7);
  margin: 0 0 0.5rem;
}

.similar-blur-gate__text {
  color: var(--color-text-muted, #a1a1aa);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

.similar-blur-gate__actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.similar-blur-gate__secondary {
  color: var(--color-text-muted, #a1a1aa);
  font-size: 0.875rem;
  text-decoration: none;
}

.similar-blur-gate__secondary:hover {
  color: var(--color-text, #e4e4e7);
  text-decoration: underline;
}

[data-theme="light"] .similar-blur-gate {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .similar-blur-gate__title {
  color: var(--color-text, #18181b);
}

[data-theme="light"] .similar-blur-gate__text {
  color: var(--color-text-muted, #52525b);
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  /* Hidden state */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 8, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: zoom-out;
}

.lightbox__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
}

.lightbox__close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(18, 18, 26, 0.85);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
  z-index: 2;
}

.lightbox__close:hover,
.lightbox__close:focus-visible {
  background: rgba(139, 92, 246, 0.5);
  outline: none;
}

.lightbox__img {
  display: block;
  max-width: 90vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  cursor: zoom-in;
  transition: max-width 0.25s ease, max-height 0.25s ease, cursor 0.1s;
}

.lightbox__img.is-zoomed {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  cursor: zoom-out;
}

.lightbox__hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.04em;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  background: var(--color-surface, #12121a);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
  color: var(--color-text, #e4e4e7);
  padding: 0.5rem 1.25rem;
  border-radius: 2rem;
  font-size: 0.875rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.photographer-link {
  color: var(--accent, #8b5cf6);
  text-decoration: none;
  transition: color .15s, background .15s;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 6px;
}
.photographer-link:hover {
  color: #fff;
  background: var(--accent, #8b5cf6);
}
[data-theme="light"] .photographer-link:hover {
  color: #fff;
  background: var(--accent, #8b5cf6);
}

/* ── Photographer profiles (pills row inside meta-row dd) ────────────────── */
.meta-photographer-profiles__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-photographer-profile-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem 0.3rem 0.5rem;
  border-radius: 2rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text, #e4e4e7);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: nowrap;
}

.meta-photographer-profile-link svg {
  flex-shrink: 0;
  height: 20px;
  width: auto;
  max-width: 90px;
}
.meta-photographer-profile-link svg *[fill]:not([fill="none"]) {
  fill: currentColor;
}
.meta-photographer-profile-link svg *[stroke]:not([stroke="none"]) {
  stroke: currentColor;
}

.meta-photographer-profile-link__name {
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
}

/* Per-source logo size calibration */
.meta-photographer-profile-link--pixabay svg { height: 16px; }
.meta-photographer-profile-link--unsplash { gap: 0.2rem; }

.meta-photographer-profile-link:hover {
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.45);
  color: var(--color-primary, #8b5cf6);
}

.meta-photographer-profile-link--no-url {
  cursor: default;
  opacity: 0.65;
}

[data-theme="light"] .meta-photographer-profile-link {
  border-color: rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.03);
  color: var(--color-text, #18181b);
}

[data-theme="light"] .meta-photographer-profile-link:hover {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.35);
  color: #7c3aed;
}
