/* =========================================================
   Level 5 Portfolio — page-specific CSS (scoped under .l5g)
   Wide desktop layout • Centered heading/chips • Auto-fit grid
   Cards: no gray bars • Lightbox: fit-to-screen (never crop)
   ========================================================= */

.l5g { --brand:#E8C67D; --ink:#111; --muted:#666; --gap:16px; --radius:14px;
       --shadow:0 6px 20px rgba(0,0,0,.08); isolation:isolate; }
.l5g * { box-sizing:border-box; }

/* Break out of narrow site panel */
:where(main,section,article,div):has(#portfolio-gallery){
  max-width:none !important; width:100% !important;
  margin-inline:0 !important;
  padding-inline:clamp(16px,4vw,48px) !important;
  overflow:visible !important;
}
:where(main,section,article,div):has(#portfolio-gallery)
  > :where(.container,.wrapper,.inner,.content,.panel){
  max-width:none !important; width:100% !important; margin-inline:0 !important;
}

/* Shell / Heading */
.l5g .wrap{ max-width:min(96vw,1440px); margin:0 auto; padding:8px 0; }
.l5g .title{ display:flex; align-items:center; justify-content:center; gap:12px; flex-wrap:wrap; margin-bottom:6px; text-align:center; }
.l5g .title h2{ font:700 clamp(1.2rem,2.6vw,1.6rem)/1.2 system-ui; margin:0; }
.l5g .subtitle{ color:var(--muted); font-size:.98rem; }

/* Filters */
.l5g .filters{ display:flex; justify-content:center; flex-wrap:wrap; gap:10px; margin:14px 0 14px; }
.l5g .chip{ border:1px solid #e7e7ea; background:#f6f6f8; padding:8px 12px; border-radius:999px; cursor:pointer; box-shadow:inset 0 -1px 0 #ececf0; }
.l5g .chip[aria-pressed="true"], .l5g .chip:focus-visible{ outline:2px solid var(--brand); background:#fff; }

/* Grid */
.l5g .grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: var(--gap);
  justify-content:center;
  align-content:start;
}
@media (max-width:1200px){ .l5g .grid{ grid-template-columns:repeat(auto-fit, minmax(320px,1fr)); } }
@media (max-width:760px){  .l5g .grid{ grid-template-columns:repeat(auto-fit, minmax(300px,1fr)); } }
@media (max-width:480px){  .l5g .grid{ grid-template-columns:repeat(auto-fit, minmax(280px,1fr)); } }

/* Cards */
.l5g figure{ margin:0; }
.l5g .card{ position:relative; overflow:hidden; border-radius:var(--radius); box-shadow:var(--shadow); background:transparent; }
.l5g .card[data-aspect="square"]    { aspect-ratio:1/1; }
.l5g .card[data-aspect="landscape"] { aspect-ratio:4/3; }
.l5g .card[data-aspect="portrait"]  { aspect-ratio:3/4; }
.l5g .card button{ all:unset; display:block; width:100%; height:100%; cursor:pointer; }
.l5g .card img{ display:block; width:100%; height:100%; object-fit:cover; object-position:50% 50%; max-height:none !important; }
.l5g .card[data-pos="top"] img    { object-position:50% 0%; }
.l5g .card[data-pos="bottom"] img { object-position:50% 100%; }
.l5g .card[data-pos="left"] img   { object-position:0% 50%; }
.l5g .card[data-pos="right"] img  { object-position:100% 50%; }
.l5g .card figcaption{ position:absolute; left:0; right:0; bottom:0; padding:12px 12px 10px; color:#fff;
  background:linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0)); font-size:.92rem; }
.l5g .badge{ position:absolute; top:10px; left:10px; background:rgba(255,255,255,.92); color:#000;
  padding:6px 9px; border-radius:999px; font-size:.8rem; border:1px solid #e8e8ea; }

/* ======================= LIGHTBOX — fit to screen ======================= */
.l5g-lb{
  position:fixed; inset:0; background:rgba(0,0,0,.92);
  display:none; align-items:center; justify-content:center; z-index:2147483647;
  padding:0; overflow:hidden;
}
.l5g-lb[open]{ display:flex; }

.l5g .lb-frame{
  position:relative;
  width:min(96vw,1440px);
  height:92vh;
  padding:0 56px;                 /* room for arrows */
  display:flex; align-items:center; justify-content:center;
  overflow:visible;
}

/* KEY: explicit 100% sizing + contain + important to beat globals */
.l5g .lb-img{
  width:100% !important;
  height:100% !important;
  max-width:100% !important;
  max-height:100% !important;
  object-fit:contain !important;  /* show the entire photo */
  border-radius:12px;
  box-shadow:0 10px 40px rgba(0,0,0,.35);
}

/* Controls */
.l5g .lb-close, .l5g .lb-prev, .l5g .lb-next{
  position:absolute; top:50%; transform:translateY(-50%);
  background:rgba(255,255,255,.96); border:none; border-radius:999px;
  width:44px; height:44px; display:grid; place-items:center; cursor:pointer;
}
.l5g .lb-close{ top:12px; right:12px; transform:none; }
.l5g .lb-prev{ left:16px; } .l5g .lb-next{ right:16px; }

.l5g .lb-meta{
  position:absolute; left:56px; right:56px; bottom:12px;
  color:#fff; display:flex; justify-content:space-between; gap:12px; align-items:center;
  text-shadow:0 2px 8px rgba(0,0,0,.7); pointer-events:none;
}
.l5g .lb-meta .text{ font-size:.95rem; opacity:.95; }
.l5g .is-disabled{ opacity:.35; pointer-events:none; cursor:default; }

@media (max-width:768px){
  .l5g .lb-frame{ width:100vw; height:94vh; padding:0 12px; }
  .l5g .lb-prev{ left:6px; } .l5g .lb-next{ right:6px; }
  .l5g .lb-meta{ left:12px; right:12px; bottom:10px; }
}

/* Before/After slider (unchanged) */
.l5g .ba{ position:relative; overflow:hidden; border-radius:var(--radius); box-shadow:var(--shadow); }
.l5g .ba img{ width:100%; display:block; user-select:none; pointer-events:none; }
.l5g .ba .after{ position:absolute; inset:0; clip-path:inset(0 0 0 50%); }
.l5g .ba .handle{ position:absolute; top:0; bottom:0; left:50%; width:3px; background:var(--brand); }
.l5g .ba .knob{ position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  width:36px; height:36px; border-radius:50%; background:#fff; border:2px solid var(--brand); box-shadow:var(--shadow); }

/* ===== SAFETY vs theme caps (fixed): DO NOT touch .lb-img ===== */
.service .l5g .card,
.service .l5g .card img{
  height:auto !important;           /* neutralize theme caps inside cards only */
  max-height:none !important;
}
/* (Intentionally NOT applying to .lb-img) */
