/* ============================================================
   madushka.com — photo gallery styles (/photos page only)
   Builds on the design tokens defined in css/style.css
   ============================================================ */

/* ---------- Albums ---------- */
.albums-block { margin-bottom: 28px; }
.albums-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.albums-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-soft);
  text-transform: uppercase;
}
.albums-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.active-album-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass-fill-soft);
  border: 1px solid var(--glass-border);
}
.clear-album-btn {
  font-family: var(--font-ui);
  cursor: pointer;
  color: var(--text);
}
.clear-album-btn:hover { color: var(--accent); }
.clear-album-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}
@media (max-width: 900px) { .album-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .album-grid { grid-template-columns: 1fr; } }

.album-card {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  color: inherit;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  overflow: hidden;
}
.album-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--glass-shadow-hover);
}
.album-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.album-card.active {
  box-shadow: 0 0 0 2px rgba(10, 132, 255, .55), var(--glass-shadow-hover);
}
html.dark .album-card.active {
  box-shadow: 0 0 0 2px rgba(191, 90, 242, .55), var(--glass-shadow-hover);
}
.album-cover {
  display: block;
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: calc(var(--radius-lg) - 6px);
  overflow: hidden;
  background: var(--glass-fill-soft);
}
.album-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.album-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 6px 4px;
}
.album-name { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.album-count { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }

/* ---------- Filter chips ---------- */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 34px;
}
.filter-chip {
  font-family: var(--font-ui);
  cursor: pointer;
  color: var(--text-soft);
}
.filter-chip:hover { color: var(--text); }
.filter-chip.active {
  color: #fff;
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(96, 111, 248, .35);
}

/* ---------- Masonry grid (CSS columns) ---------- */
.photo-grid {
  columns: 3;
  column-gap: 20px;
  transition: opacity .2s ease;
  /* Avoid collapsing to 0 height during filter re-render (CLS) */
  min-height: 40vh;
}
.photo-grid.grid-fading { opacity: 0.35; }
@media (max-width: 900px) { .photo-grid { columns: 2; } }
@media (max-width: 560px) { .photo-grid { columns: 1; } }

.photo-card {
  display: block;
  width: 100%;
  margin: 0 0 20px;
  padding: 10px;
  border-radius: var(--radius-lg);
  break-inside: avoid;
  cursor: zoom-in;
  position: relative;
  overflow: hidden;
  text-align: left;
  font-family: var(--font-ui);
}
.photo-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--glass-shadow-hover);
}
.photo-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.photo-card img {
  display: block;
  width: 100%;
  height: auto;
  /* Reserve space before decode — cuts masonry CLS while thumbs load */
  aspect-ratio: 900 / 599;
  object-fit: cover;
  border-radius: calc(var(--radius-lg) - 8px);
  transition: transform .5s cubic-bezier(.2, .7, .3, 1), opacity .35s ease;
  position: relative;
  z-index: 1;
  background: var(--glass-fill-soft);
}
.photo-card:hover img { transform: scale(1.045); }

/* shimmer skeleton while grid thumbs load — sits behind reserved img box */
.photo-card::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: calc(var(--radius-lg) - 8px);
  background: linear-gradient(
    110deg,
    var(--glass-fill-soft) 25%,
    rgba(255, 255, 255, .35) 45%,
    var(--glass-fill-soft) 65%
  );
  background-size: 200% 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity .25s ease;
}
html.dark .photo-card::before {
  background: linear-gradient(
    110deg,
    rgba(255, 255, 255, .06) 25%,
    rgba(255, 255, 255, .14) 45%,
    rgba(255, 255, 255, .06) 65%
  );
  background-size: 200% 100%;
}
.photo-card.is-loading::before {
  opacity: 1;
  animation: photoShimmer 1.2s ease-in-out infinite;
}
/* Keep img in layout (opacity only) so reserved aspect-ratio space stays */
.photo-card.is-loading img { opacity: 0.01; }
@keyframes photoShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* entry animation for freshly rendered cards */
.card-in {
  opacity: 0;
  transform: translateY(22px);
  animation: cardIn .55s cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }

/* caption overlay */
.photo-overlay {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 34px 16px 12px;
  border-radius: 0 0 calc(var(--radius-lg) - 8px) calc(var(--radius-lg) - 8px);
  background: linear-gradient(180deg, transparent, rgba(10, 12, 24, .72));
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.photo-card:hover .photo-overlay,
.photo-card:focus-visible .photo-overlay {
  opacity: 1;
  transform: translateY(0);
}
.photo-caption { font-size: 14px; font-weight: 700; line-height: 1.35; }
.photo-loc {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  opacity: .88;
}
.photo-loc svg { width: 13px; height: 13px; flex: none; }

/* ---------- Empty state ---------- */
.gallery-empty {
  padding: 48px 24px;
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--text-soft);
  font-size: 15.5px;
  font-weight: 600;
}
.gallery-empty svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
  margin-bottom: 10px;
}

/* ---------- Lightbox ---------- */
body.lb-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: rgba(14, 16, 28, .55);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  backdrop-filter: blur(26px) saturate(140%);
  opacity: 0;
  transition: opacity .25s ease;
}
.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }

.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
}
.lb-counter {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  letter-spacing: .04em;
  min-width: 52px;
  text-align: center;
}
.lb-actions { display: flex; gap: 10px; }

.lb-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .14);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  cursor: pointer;
  transition: transform .2s, background .2s;
}
.lb-btn:hover { transform: scale(1.08); background: rgba(255, 255, 255, .26); }
.lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-btn svg { width: 20px; height: 20px; }

/* play / pause icon swap */
.lb-play .icon-pause { display: none; }
.lightbox.playing .lb-play .icon-pause { display: block; }
.lightbox.playing .lb-play .icon-play { display: none; }
.lightbox.playing .lb-play {
  background: var(--accent-grad);
  border-color: transparent;
}

.lb-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 76px;
  position: relative;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 255, 255, .18);
}

.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
}
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-prev:hover, .lb-next:hover { transform: translateY(-50%) scale(1.08); }

.lb-meta {
  text-align: center;
  padding: 14px 20px 6px;
  color: #fff;
}
.lb-meta .lb-caption { font-size: 16.5px; font-weight: 700; }
.lb-meta .lb-location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: .8;
}
.lb-meta .lb-location svg { width: 14px; height: 14px; }

/* autoplay progress indicator */
.lb-progress-track {
  height: 3px;
  margin: 12px auto 18px;
  width: min(360px, 70%);
  border-radius: 3px;
  background: rgba(255, 255, 255, .18);
  overflow: hidden;
}
.lb-progress {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent-grad);
}
.lb-progress.running { animation: lbProgress 4s linear infinite; }
@keyframes lbProgress { from { width: 0; } to { width: 100%; } }

@media (max-width: 640px) {
  .lb-stage { padding: 8px 12px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lb-prev, .lb-next { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .photo-card.is-loading::before,
  .photo-card.is-loading img { animation: none; opacity: 1; }
  .photo-card.is-loading::before { opacity: 0; }
  .photo-card:hover img { transform: none; }
  .album-card:hover { transform: none; }
}
