/* ==========================================================================
   Yaseen Construction — Project Gallery
   Before / After collage. Inherits the site tokens declared in index.html.
   ========================================================================== */

:root {
  --ba-before: #2a2f37;
  --ba-before-line: rgba(255, 255, 255, .55);
  --g-gap: 24px;
}

/* ---------- page shell ---------------------------------------------------- */

.gallery-page { padding-top: var(--nav-h, 66px); }

.gallery-head {
  padding: 64px 0 34px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(201, 162, 39, .16), transparent 62%),
    linear-gradient(180deg, #090b0f, var(--bg));
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  text-align: center;
}
.gallery-head h1 {
  font-size: clamp(28px, 4.6vw, 46px);
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff;
}
.gallery-head h1 span { color: var(--gold); }
.gallery-head .lede {
  max-width: 640px;
  margin: 16px auto 0;
  color: var(--mut);
  font-size: 16px;
}

/* how-to-read strip: teaches the slider before the visitor meets one */
.ba-legend {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 26px auto 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
}
.ba-legend .lg { display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px; border-radius: 999px; }
.ba-legend .lg-before { background: var(--ba-before); color: #dfe3e8; border: 1px solid rgba(255, 255, 255, .16); }
.ba-legend .lg-after { background: linear-gradient(135deg, var(--gold), #d4af37); color: #0a0a0a; }
.ba-legend .lg-drag { color: var(--mut); border: 1px solid var(--line); background: rgba(201, 162, 39, .06); font-weight: 600; }
.ba-legend svg { flex: none; }

/* ---------- auto-hiding top chrome ---------------------------------------
   The nav and the filter bar travel together: they slide out of the way the
   moment the visitor scrolls down and drop back in as soon as they scroll up,
   so a phone screen is never half filled with chrome. Driven by
   body.chrome-hidden, set in gallery.js.
   -------------------------------------------------------------------------- */

.nav {
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  will-change: transform;
}
body.chrome-hidden .nav { transform: translateY(-100%); }

/* zero-height probe that tells JS when the filter bar has become stuck */
.toolbar-sentinel { height: 0; margin: 0; padding: 0; }

/* ---------- filter bar ---------------------------------------------------- */

.gallery-toolbar {
  position: sticky;
  top: var(--nav-h, 66px);
  z-index: 60;
  background: rgba(11, 13, 16, .93);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  padding: 14px 0;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
/* only a *stuck* bar is allowed to slide away — while it is still sitting in
   the flow under the header it must stay exactly where the layout put it */
body.chrome-hidden .gallery-toolbar.is-stuck {
  transform: translateY(calc(-100% - var(--nav-h, 66px)));
  will-change: transform;
}
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #cfd3d8;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s, transform .2s;
}
.filter:hover { color: var(--gold2); border-color: var(--gold); transform: translateY(-1px); }
.filter .n {
  font-size: 10px;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: var(--mut);
}
.filter[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--gold), #d4af37);
  border-color: var(--gold);
  color: #0a0a0a;
  box-shadow: 0 8px 22px rgba(201, 162, 39, .22);
}
.filter[aria-pressed="true"] .n { background: rgba(0, 0, 0, .18); color: #0a0a0a; }
.filter[disabled] { opacity: .38; cursor: not-allowed; transform: none; }
.filter[disabled]:hover { color: #cfd3d8; border-color: var(--line); }

/* Phones get ONE compact row that swipes sideways — never four stacked rows
   eating half the screen. */
@media (max-width: 760px) {
  .gallery-toolbar { padding: 5px 0; }
  .gallery-toolbar .wrap { padding: 0; }
  .filters {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;                       /* Firefox */
    -ms-overflow-style: none;                    /* old Edge */
    /* 6px of vertical room so the chips' 44px tap targets are not clipped */
    padding: 6px max(22px, env(safe-area-inset-left)) 6px max(22px, env(safe-area-inset-right));
    scroll-padding-inline: 22px;
  }
  .filters::-webkit-scrollbar { display: none; } /* Safari / Chrome */
  .filter {
    position: relative;
    flex: 0 0 auto;
    height: 32px;
    /* style.css sets a blanket min-height:44px on every button at this width;
       the chip stays 32px tall and gets its 44px touch target back below */
    min-height: 32px;
    padding: 0 13px;
    gap: 6px;
    font-size: 10.5px;
    letter-spacing: 1px;
    white-space: nowrap;
    transform: none;
  }
  .filter::after {                                /* invisible 44px tap target */
    content: '';
    position: absolute;
    left: 0; right: 0; top: 50%;
    height: 44px;
    transform: translateY(-50%);
  }
  .filter:hover { transform: none; }
  .filter .n { font-size: 9px; min-width: 15px; padding: 0 4px; line-height: 1.7; }
  .filter[aria-pressed="true"] { box-shadow: 0 4px 14px rgba(201, 162, 39, .22); }
}

/* ---------- masonry grid -------------------------------------------------- */

.gallery-main { padding: 40px 0 90px; }

/* Grid + JS-computed row spans = true masonry that always fills left to right,
   keeps DOM order (so tab order and screen readers stay sane), and never
   strands an empty column the way CSS multi-column balancing does. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  column-gap: var(--g-gap);
  row-gap: 0;
  grid-auto-rows: 8px;
  align-items: start;
}
/* before JS measures, cards flow as ordinary equal grid items */
.grid:not(.is-masonry) { grid-auto-rows: auto; row-gap: var(--g-gap); }
@media (max-width: 640px) { .grid { --g-gap: 18px; grid-template-columns: 1fr; } }

.card {
  width: 100%;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  transition: border-color .3s, box-shadow .3s, transform .3s;
}
.card:hover, .card:focus-within {
  border-color: var(--gold);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
  transform: translateY(-4px);
}
.card[hidden] { display: none; }

.card-body { padding: 18px 20px 20px; }
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.chip {
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold2);
  background: rgba(201, 162, 39, .1);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}
.card-date { font-size: 11.5px; letter-spacing: 1px; color: var(--mut); text-transform: uppercase; }
.card h2 { font-size: 17px; letter-spacing: .6px; color: #fff; margin-bottom: 6px; }
.card .loc {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 13px;
  color: var(--mut);
}
.card .loc svg { flex: none; margin-top: 2px; }
.card .blurb { font-size: 13.5px; color: #b3b9c1; margin-top: 10px; }

.card-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.card-open {
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold2);
  background: transparent;
  border: 1.5px solid var(--gold);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.card-open:hover { background: var(--gold); color: #0a0a0a; }
.card-count { font-size: 11.5px; color: var(--mut); letter-spacing: .6px; }

/* extra photos strip under the cover */
.thumbs { display: flex; gap: 8px; padding: 16px 20px 0; flex-wrap: wrap; }
.thumb {
  width: 74px; height: 56px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0d1015;
  cursor: pointer;
  position: relative;
  transition: border-color .2s, transform .2s;
}
.thumb:hover { border-color: var(--gold); transform: translateY(-2px); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .pl {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .42);
}
.thumb .pl svg { fill: #fff; width: 16px; height: 16px; }

/* ---------- the before / after slider ------------------------------------- */

.ba {
  position: relative;
  --ba-pos: 50%;
  background: #0d1015;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.ba-frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ba-ar, 16 / 9);
  touch-action: pan-y;          /* horizontal drag is ours, vertical scroll is the page's */
  cursor: ew-resize;
}
.ba-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.ba-img.is-before {
  z-index: 2;
  clip-path: inset(0 calc(100% - var(--ba-pos)) 0 0);
}
/* The ONLY animated state is the one-shot intro wipe when a card scrolls into
   view. A finger on the glass must never be chasing a transition. */
.ba.is-animating .ba-img.is-before { transition: clip-path .85s cubic-bezier(.4, 0, .2, 1); }
.ba.is-dragging .ba-img.is-before,
.ba.is-dragging .ba-handle { transition: none !important; }
.ba.is-dragging .ba-img.is-before { will-change: clip-path; }
.ba.is-dragging .ba-handle { will-change: transform; }

/* corner badges — always visible, each pinned to its own side */
.ba-badge {
  position: absolute;
  top: 12px;
  z-index: 5;
  font-family: 'Montserrat', sans-serif;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 7px 14px;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
}
.ba-badge.b {
  left: 12px;
  background: var(--ba-before);
  color: #e4e8ed;
  border: 1px solid rgba(255, 255, 255, .2);
}
.ba-badge.a {
  right: 12px;
  background: linear-gradient(135deg, var(--gold), #d4af37);
  color: #0a0a0a;
}

/* The divider + knob. Positioned with a transform rather than `left` so that
   dragging never triggers layout — the handle box is the full width of the
   frame, so translateX(50%) resolves against the frame, not the knob. */
.ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  transform: translate3d(var(--ba-pos), 0, 0);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  cursor: ew-resize;
  background: none;
  border: 0;
  padding: 0;
  touch-action: pan-y;
  pointer-events: none;             /* the knob takes the hits, not the strip */
}
.ba.is-animating .ba-handle { transition: transform .85s cubic-bezier(.4, 0, .2, 1); }
.ba-handle::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--ba-before-line);
  box-shadow: 0 0 12px rgba(0, 0, 0, .55);
}
.ba-knob {
  position: relative;
  margin-left: -21px;               /* centre the 42px knob on the divider */
  flex: none;
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: pan-y;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #d4af37);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .55), 0 0 0 3px rgba(11, 13, 16, .5);
  transition: transform .2s;
}
.ba-knob svg { fill: #0a0a0a; width: 20px; height: 20px; }
.ba-knob:hover { transform: scale(1.08); }
.ba-handle:focus-visible { outline: none; }
.ba-handle:focus-visible .ba-knob { outline: 3px solid var(--gold2); outline-offset: 4px; }
.ba.is-dragging .ba-knob { transform: scale(.94); transition: none; }

/* "drag me" nudge, fades out after the first interaction */
.ba-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Montserrat', sans-serif;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: #e9edf2;
  background: rgba(10, 12, 16, .72);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 6px 13px;
  white-space: nowrap;              /* never let it break onto two lines */
  pointer-events: none;
  backdrop-filter: blur(6px);
  transition: opacity .35s;
}
.ba-hint svg { fill: currentColor; width: 12px; height: 12px; }
.ba.is-touched .ba-hint { opacity: 0; }

/* no-JS / pre-hydration fallback: the pair sits side by side, still labelled */
.ba:not(.is-ready) .ba-frame { display: flex; aspect-ratio: auto; cursor: default; }
.ba:not(.is-ready) .ba-img {
  position: relative;
  inset: auto;
  width: 50%;
  height: auto;
  clip-path: none;
}
.ba:not(.is-ready) .ba-handle,
.ba:not(.is-ready) .ba-hint { display: none; }
.ba:not(.is-ready) .ba-badge.b { left: 12px; }
.ba:not(.is-ready) .ba-badge.a { right: 12px; }

/* ---------- single photo + video cover ------------------------------------ */

.shot {
  position: relative;
  display: block;
  width: 100%;
  background: #0d1015;
  border: 0;
  padding: 0;
  cursor: zoom-in;
  overflow: hidden;
  aspect-ratio: var(--shot-ar, 4 / 3);
}
.shot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s;
}
.card:hover .shot img { transform: scale(1.03); }
.tagline {
  position: absolute;
  left: 12px;
  top: 12px;
  font-family: 'Montserrat', sans-serif;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), #d4af37);
  color: #0a0a0a;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
}
.play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.play span {
  width: 66px; height: 66px;
  border-radius: 50%;
  background: rgba(201, 162, 39, .92);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transition: transform .25s;
}
.play svg { fill: #0a0a0a; width: 26px; height: 26px; margin-left: 4px; }
.shot:hover .play span { transform: scale(1.09); }

/* ---------- empty state --------------------------------------------------- */

.empty {
  text-align: center;
  padding: 70px 20px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .02);
}
.empty h3 { color: var(--gold2); font-size: 16px; letter-spacing: 1.4px; margin-bottom: 10px; }
.empty p { color: var(--mut); font-size: 14px; max-width: 460px; margin: 0 auto; }
.empty .btn { margin-top: 22px; }

/* ---------- lightbox ------------------------------------------------------ */

.lb {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(6, 8, 11, .96);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  padding: 18px;
}
.lb[hidden] { display: none; }
.lb-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto 14px;
}
.lb-title h2 { font-size: 17px; color: #fff; letter-spacing: .6px; }
.lb-title p { font-size: 13px; color: var(--mut); margin-top: 4px; }
.lb-x, .lb-nav {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  color: var(--gold2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
}
.lb-x:hover, .lb-nav:hover { background: var(--gold); color: #0a0a0a; }
.lb-x svg, .lb-nav svg { fill: currentColor; width: 18px; height: 18px; }

.lb-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}
.lb-media {
  flex: 1;
  min-width: 0;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* size the comparison by height so it always fits the viewport uncropped */
.lb-media .ba { width: auto; max-width: 100%; border-radius: 14px; }
.lb-media .ba-frame { height: 72vh; width: auto; max-width: 100%; }
@media (max-width: 700px) { .lb-media .ba-frame { height: auto; width: 100%; } }
.lb-media img.solo, .lb-media video {
  max-width: 100%;
  max-height: 76vh;
  width: auto;
  border-radius: 14px;
  display: block;
}
.lb-foot {
  max-width: 1180px;
  width: 100%;
  margin: 14px auto 0;
  text-align: center;
}
.lb-cap { font-size: 13.5px; color: #b6bcc4; max-width: 720px; margin: 0 auto; }
.lb-idx {
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  letter-spacing: 1.6px;
  color: var(--mut);
  margin-top: 8px;
}

@media (max-width: 700px) {
  .lb { padding: 12px; }
  .lb-stage { gap: 6px; }
  .lb-nav { width: 38px; height: 38px; }
  .lb-title h2 { font-size: 15px; }
}

/* ---------- no-JS notice -------------------------------------------------- */

.ns-note {
  max-width: 760px;
  margin: 0 auto 28px;
  text-align: center;
  color: var(--mut);
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 20px;
  background: rgba(201, 162, 39, .05);
}
.ns-card { max-width: 900px; margin: 0 auto; }
.ns-card .ba { border: 1px solid var(--line); border-radius: 18px; }

/* ---------- motion preferences -------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
  .card, .card:hover, .shot img, .card:hover .shot img,
  .filter, .filter:hover { transition: none !important; transform: none !important; }
  .ba-knob, .ba-knob:hover { transition: none !important; transform: none !important; }
  .ba.is-animating .ba-img.is-before,
  .ba.is-animating .ba-handle { transition: none; }
  .nav, .gallery-toolbar { transition: none !important; }
}
