/* ==========================================================================
   Gallery: album cards (bento), album page, justified photo grid, lightbox
   ========================================================================== */

/* ---------- Shared: photos fade in over their own average colour ---------- */
.album-card__img,
.jtile img,
.album-hero__cover img,
.next-album img {
  opacity: 0;
  transition: opacity 0.9s var(--ease-out), transform 1.4s var(--ease-out), filter 0.9s var(--ease-out);
}
.album-card__img.is-loaded,
.jtile img.is-loaded,
.album-hero__cover img.is-loaded,
.next-album img.is-loaded { opacity: 1; }
.no-js .album-card__img, .no-js .jtile img { opacity: 1; }

/* ==========================================================================
   Album cards (home "Selected Projects" + projects.html)
   ========================================================================== */
.album-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 360px;
  gap: 1rem;
}
@media (min-width: 640px) {
  .album-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 320px; gap: 1.25rem; }
  .album-tile--feature, .album-tile--wide { grid-column: span 2; }
  .album-tile--tall { grid-row: span 2; }
}
@media (min-width: 1024px) {
  .album-grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 300px; gap: 1.5rem; grid-auto-flow: dense; }
  .album-tile--feature { grid-column: span 2; grid-row: span 2; }
}

.album-card {
  position: relative;
  display: block;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  color: var(--c-cream);
  background: var(--tint, var(--c-green));
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -40px rgba(20, 40, 32, 0.7);
}
.album-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}
/* Legibility gradient + a fine gold inner frame that draws in on hover */
.album-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top, rgba(14, 28, 22, 0.88) 0%, rgba(14, 28, 22, 0.35) 42%, rgba(14, 28, 22, 0) 68%),
    linear-gradient(to bottom, rgba(14, 28, 22, 0.35), transparent 22%);
  transition: opacity 0.8s var(--ease-out);
}
.album-card::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(232, 207, 156, 0.55);
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
  pointer-events: none;
}

.album-card__count {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--c-gold-light);
}
.album-card__body {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.5rem;
}
.album-tile--feature .album-card__body { padding: 2rem; }
.album-card__meta {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--c-gold-light);
}
.album-card__title {
  font-family: "Playfair Display", serif;
  font-size: 1.6rem;
  line-height: 1.15;
}
.album-tile--feature .album-card__title { font-size: clamp(1.9rem, 3vw, 2.75rem); }
.album-card__summary {
  max-width: 34rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(251, 247, 239, 0.82);
}
.album-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--c-cream);
}
.album-card__cta::after {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--c-gold);
  transition: width 0.6s var(--ease-out);
}

@media (hover: hover) {
  .album-card:hover .album-card__img { transform: scale(1.05); }
  .album-card:hover::after { opacity: 1; transform: none; }
  .album-card:hover .album-card__cta::after { width: 56px; }
}
.album-card:focus-visible { outline-offset: 4px; }

/* ==========================================================================
   Album page
   ========================================================================== */
.album-hero { padding-top: calc(var(--nav-h) + 2.5rem); }
@media (min-width: 768px) { .album-hero { padding-top: calc(var(--nav-h) + 4rem); } }

.album-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--c-green);
}
.album-hero__meta > * { display: inline-flex; align-items: center; gap: 0.5rem; }
.album-hero__meta svg { width: 15px; height: 15px; color: var(--c-gold-dark); }

/* While album data loads (rarely seen once cached), hide the empty labels and icons */
[data-album-root][aria-busy="true"] [data-album-category],
[data-album-root][aria-busy="true"] .album-hero__meta,
[data-album-root][aria-busy="true"] .album-hero .btn { visibility: hidden; }

/* Arched cover, echoing the About section */
.album-hero__frame { position: relative; }
.album-hero__frame::before {
  content: "";
  position: absolute;
  inset: -12px;
  transform: translate(14px, 14px);
  border: 1px solid rgba(196, 154, 90, 0.5);
  border-radius: 999px 999px 0 0;
  pointer-events: none;
}
.album-hero__cover {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 999px 999px 0 0;
  background: var(--tint, var(--c-tan));
  box-shadow: 0 40px 80px -40px rgba(20, 40, 32, 0.55);
}
.album-hero__cover img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 1023px) {
  .album-hero__cover { aspect-ratio: 5 / 4; border-radius: 999px 999px 0 0 / 60% 60% 0 0; }
  .album-hero__frame::before { border-radius: 999px 999px 0 0 / 60% 60% 0 0; inset: -8px; transform: translate(8px, 8px); }
}

.album-section { background: #eee3d1; }
.album-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(196, 154, 90, 0.4);
}
.album-section__head h2 { font-family: "Playfair Display", serif; font-size: clamp(1.5rem, 2.4vw, 2rem); color: var(--c-green); }
.album-section__head p { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--c-gold-dark); }

/* ---------- Justified bento grid ---------- */
.jgrid { --g: 8px; display: flex; flex-direction: column; gap: var(--g); }
@media (min-width: 640px) { .jgrid { --g: 12px; } }
@media (min-width: 1024px) { .jgrid { --g: 16px; } }

.jrow { display: flex; gap: var(--g); }
.jrow__fill { flex-basis: 0; }

.jtile {
  position: relative;
  flex-shrink: 1;
  flex-basis: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--tint, var(--c-tan));
  border-radius: var(--radius);
  /* Entrance: soft rise, staggered within each screenful */
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  transition: opacity 1s var(--ease-out) var(--d, 0ms), transform 1.1s var(--ease-out) var(--d, 0ms), box-shadow 0.6s var(--ease-out);
}
.jtile.is-in { opacity: 1; transform: none; }
.no-js .jtile { opacity: 1; transform: none; }
.jtile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-select: none;
  user-select: none;
}
.jtile::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(232, 207, 156, 0);
  background: linear-gradient(to top, rgba(14, 28, 22, 0.25), transparent 40%);
  opacity: 0;
  transition: opacity 0.6s var(--ease-out), box-shadow 0.6s var(--ease-out);
  pointer-events: none;
}
@media (hover: hover) {
  .jtile:hover img { transform: scale(1.035); }
  .jtile:hover::after { opacity: 1; box-shadow: inset 0 0 0 1px rgba(232, 207, 156, 0.7); }
  .jtile:hover { box-shadow: 0 24px 50px -30px rgba(20, 40, 32, 0.7); }
}
.jtile:focus-visible { outline-offset: 3px; }

/* "Before & During" photos sit quieter until you look at them */
.album-before .jtile img { filter: saturate(0.75) brightness(0.97); }
@media (hover: hover) { .album-before .jtile:hover img { filter: none; } }

/* ---------- Next project ---------- */
.next-album {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 300px;
  overflow: hidden;
  isolation: isolate;
  color: var(--c-cream);
  background: var(--tint, var(--c-green));
  border-radius: var(--radius);
}
@media (min-width: 768px) { .next-album { min-height: 380px; } }
.next-album img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.next-album::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(14, 28, 22, 0.9), rgba(14, 28, 22, 0.45) 55%, rgba(14, 28, 22, 0.15));
}
.next-album__body { display: flex; flex-direction: column; gap: 0.6rem; padding: 2rem; }
@media (min-width: 768px) { .next-album__body { padding: 3rem; } }
.next-album__title { font-family: "Playfair Display", serif; font-size: clamp(2rem, 4.4vw, 3.5rem); line-height: 1.05; }
.next-album__meta { font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--c-gold-light); }
.next-album__arrow {
  position: absolute;
  right: 2rem;
  bottom: 2rem;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(232, 207, 156, 0.6);
  border-radius: 50%;
  color: var(--c-gold-light);
  transition: background-color 0.5s var(--ease-out), color 0.5s var(--ease-out), transform 0.6s var(--ease-out);
}
.next-album__arrow svg { width: 22px; height: 22px; }
@media (hover: hover) {
  .next-album:hover img { transform: scale(1.04); }
  .next-album:hover .next-album__arrow { background: var(--c-gold); color: var(--c-green-deep); transform: translateX(6px); }
}
@media (max-width: 639px) { .next-album__arrow { display: none; } }

/* ==========================================================================
   Lightbox
   ========================================================================== */
.lb {
  --lb-fade: 1;
  position: fixed;
  inset: 0;
  z-index: 100;
  color: var(--c-cream);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.lb[hidden] { display: none; }
/* The viewer handles every touch itself: no page pinch-zoom, double-tap zoom or scroll behind it */
.lb { touch-action: none; overscroll-behavior: contain; }
.lb.is-zoomed .lb__zone { cursor: grab; }
.lb.is-zoomed.is-dragging .lb__zone { cursor: grabbing; }
.lb.is-zoomed .lb__tag { opacity: 0; }

.lb__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(31, 58, 48, 0.55), transparent 70%),
    #0c1612;
  opacity: 0;
  transition: opacity 0.55s var(--ease-out);
}
.lb.is-open .lb__backdrop { opacity: calc(0.985 * var(--lb-fade)); }
.lb.is-dragging .lb__backdrop { transition: none; }
.lb.is-closing .lb__backdrop { opacity: 0; transition-duration: 0.6s; }

.lb__stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}
.lb__track { position: absolute; inset: 0; will-change: transform; }
.lb__slide { position: absolute; inset: 0; margin: 0; }
.lb__frame {
  position: absolute;
  overflow: hidden;
  background: var(--tint, #1f3a30);
  box-shadow: 0 50px 100px -40px rgba(0, 0, 0, 0.8);
  will-change: transform;
  backface-visibility: hidden;
}
.lb__frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.lb__full { opacity: 0; transition: opacity 0.5s ease; }
.lb__full.is-loaded { opacity: 1; }

.lb.is-fading .lb__slide.is-current { opacity: 0; transition: opacity 0.16s ease; }

.lb__tag {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: none;
  padding: 0.35rem 0.9rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--c-gold-light);
  border: 1px solid rgba(196, 154, 90, 0.5);
  border-radius: 999px;
  background: rgba(12, 22, 18, 0.6);
}
.lb__slide.is-before .lb__tag { display: block; }

/* Invisible halves: the whole photo is the control. Arrow cursor hints the direction. */
.lb__zone {
  position: absolute;
  top: 64px;
  bottom: 0;
  width: 50%;
  padding: 0;
  background: transparent;
  border: 0;
  -webkit-tap-highlight-color: transparent;
}
.lb__zone--prev {
  left: 0;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Ccircle cx='24' cy='24' r='22' fill='rgba(12,22,18,0.55)' stroke='%23c49a5a' stroke-width='1.2'/%3E%3Cpath d='M27 16l-8 8 8 8' fill='none' stroke='%23e8cf9c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 24 24, w-resize;
}
.lb__zone--next {
  right: 0;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Ccircle cx='24' cy='24' r='22' fill='rgba(12,22,18,0.55)' stroke='%23c49a5a' stroke-width='1.2'/%3E%3Cpath d='M21 16l8 8-8 8' fill='none' stroke='%23e8cf9c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 24 24, e-resize;
}
.lb.is-single .lb__zone { cursor: default; }
.lb.is-dragging .lb__zone { cursor: grabbing; }
.lb__zone:focus-visible { outline: none; }
.lb__zone:focus-visible::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  border: 1.5px solid var(--c-gold);
  border-radius: 50%;
}
.lb__zone--prev:focus-visible::after { left: 16px; }
.lb__zone--next:focus-visible::after { right: 16px; }

/* Top bar: title · counter · close */
.lb__bar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  height: 64px;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1.25rem, env(safe-area-inset-left));
  padding-top: env(safe-area-inset-top);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}
@media (min-width: 640px) { .lb__bar { height: 76px; padding-inline: 2rem; } }
.lb.is-open .lb__bar { opacity: calc(var(--lb-fade)); transform: none; transition-delay: 0.2s; }
.lb.is-open.is-idle .lb__bar { opacity: 0; transition-delay: 0s; }
.lb.is-closing .lb__bar { opacity: 0; transition-delay: 0s; }

.lb__title {
  overflow: hidden;
  font-family: Cinzel, serif;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--c-gold-light);
}
.lb__count {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: "Playfair Display", serif;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}
.lb__count [data-total] { color: rgba(251, 247, 239, 0.5); }
.lb__sep { width: 26px; height: 1px; background: var(--c-gold); }
.lb__close {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(196, 154, 90, 0.45);
  border-radius: 50%;
  color: var(--c-gold-light);
  transition: background-color 0.4s var(--ease-out), color 0.4s var(--ease-out), transform 0.5s var(--ease-out);
}
.lb__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
@media (hover: hover) {
  .lb__close:hover { background: var(--c-gold); color: var(--c-green-deep); transform: rotate(90deg); }
}
@media (max-width: 639px) { .lb__title { font-size: 0.68rem; } }

/* Thin gold progress line along the bottom */
.lb__progress {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  height: 2px;
  background: rgba(196, 154, 90, 0.15);
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
}
.lb.is-open .lb__progress { opacity: var(--lb-fade); }
.lb.is-closing .lb__progress { opacity: 0; }
.lb__progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--c-gold-dark), var(--c-gold-light));
  transform-origin: left;
  transition: transform 0.6s var(--ease-out);
}

/* One-time gesture hint */
.lb__hint {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 2;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.lb__hint span {
  display: block;
  padding: 0.55rem 1.1rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--c-cream);
  background: rgba(12, 22, 18, 0.7);
  border: 1px solid rgba(196, 154, 90, 0.45);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.lb__hint.is-visible { opacity: 1; transform: translate(-50%, 0); transition-delay: 0.6s; }

@media (prefers-reduced-motion: reduce) {
  .jtile { transform: none; transition: opacity 0.4s ease; }
  .lb__frame { transition: none !important; }
}
