/* Local Hero Gallery — frontend styles
   ---------------------------------------------------------------
   Uses host theme tokens when available (--color-*, --space-*,
   --radius-*) and falls back to sensible defaults.
   --------------------------------------------------------------- */

/* Force [hidden] to win over our explicit display values on chips/links/items. */
.lhg [hidden],
.lhg-lightbox [hidden] { display: none !important; }

.lhg {
  --lhg-pad:        var(--space-5, 1.25rem);
  --lhg-gap:        var(--space-3, .75rem);
  --lhg-radius:     var(--radius-xl, 16px);
  --lhg-radius-sm:  var(--radius-md, 8px);
  --lhg-pill-bg:    var(--color-purple-xlight, #f1ebf8);
  --lhg-pill-fg:    var(--color-primary, #4b1d80);
  --lhg-pill-fg-hover: var(--color-primary-hover, #5d2b9a);
  --lhg-text:       var(--color-text, #1a1025);
  --lhg-muted:      var(--color-text-muted, #5c4d6e);
  --lhg-border:     var(--color-border, rgba(0,0,0,.08));
  --lhg-shadow-sm:  var(--shadow-sm, 0 1px 2px rgba(0,0,0,.06));
  --lhg-shadow-md:  var(--shadow-md, 0 8px 24px rgba(0,0,0,.10));
  --lhg-shadow-lg:  var(--shadow-lg, 0 24px 60px rgba(0,0,0,.18));
  --lhg-accent:     var(--color-accent, #f2daaa);

  margin-block: var(--space-6, 1.5rem);
}

/* -- Intro (heading + description) --------------------------- */
.lhg__intro {
  text-align: center;
  max-width: 60ch;
  margin: 0 auto var(--space-6, 1.5rem);
}
.lhg__heading {
  margin: 0 0 var(--space-2, .5rem);
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  letter-spacing: -0.01em;
}
.lhg__description {
  margin: 0;
  color: var(--lhg-muted);
  font-size: 1rem;
  line-height: 1.55;
}

/* -- Filters ------------------------------------------------- */
.lhg__filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3, .75rem);
  align-items: center;
  margin-bottom: var(--space-5, 1.25rem);
  padding-bottom: var(--space-4, 1rem);
  border-bottom: 1px solid var(--lhg-border);
}

@media (min-width: 720px) {
  .lhg__filters {
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: wrap;
  }
}

.lhg__pills {
  list-style: none;
  padding: .375rem;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  justify-content: center;
  align-items: center;
  background: var(--color-purple-xlight, #f6f0fc);
  border-radius: 999px;
}
.lhg__pills li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lhg__pill {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--lhg-text);
  padding: .5rem 1.1rem;
  border-radius: 999px;
  font: inherit;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.lhg__pill:hover { color: var(--lhg-pill-fg); }
.lhg__pill:focus-visible { outline: 2px solid var(--lhg-pill-fg); outline-offset: 2px; }

.lhg__pill.is-active {
  background: var(--lhg-pill-fg);
  color: #fff;
  box-shadow: 0 4px 12px rgba(75,29,128,.28);
}
.lhg__pill.is-active .lhg__pill-count { background: rgba(255,255,255,.22); color: #fff; }

.lhg__pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 0 .4em;
  height: 1.2em;
  border-radius: 999px;
  background: rgba(0,0,0,.06);
  color: var(--lhg-muted);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.lhg__location-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2, .5rem);
  font-size: .8125rem;
  color: var(--lhg-muted);
}

.lhg__location {
  padding: .55rem 2rem .55rem .875rem;
  border-radius: 999px;
  border: 1px solid var(--lhg-border);
  background: transparent;
  font: inherit;
  font-size: .8125rem;
  color: var(--lhg-text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 256 256'%3E%3Cpath fill='%235c4d6e' d='M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80A8 8 0 0 1 53.66 90.34L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
}
.lhg__location:focus { outline: 2px solid var(--lhg-pill-fg); outline-offset: 2px; }

.lhg__count {
  text-align: center;
  font-size: .8125rem;
  color: var(--lhg-muted);
  margin-block: 0 var(--space-4, 1rem);
  letter-spacing: .01em;
}

/* -- Image grid — true masonry via grid-auto-rows + JS row-spans ---- */
.lhg__grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--lhg-gap);
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 8px;
  grid-auto-flow: dense;
  align-items: start;
}

@media (min-width: 640px) {
  .lhg[data-columns="2"] .lhg__grid,
  .lhg[data-columns="3"] .lhg__grid { grid-template-columns: repeat(2, 1fr); }
  .lhg[data-columns="4"] .lhg__grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .lhg[data-columns="2"] .lhg__grid { grid-template-columns: repeat(2, 1fr); }
  .lhg[data-columns="3"] .lhg__grid { grid-template-columns: repeat(3, 1fr); }
  .lhg[data-columns="4"] .lhg__grid { grid-template-columns: repeat(4, 1fr); }
}

.lhg__item {
  position: relative;
  border-radius: var(--lhg-radius);
  overflow: hidden;
  background: var(--lhg-pill-bg);
  isolation: isolate;
  transform: translateZ(0);
  transition: transform .25s ease, box-shadow .25s ease, opacity .2s ease;
  /* JS sets grid-row-end inline; this is a fallback span until JS runs. */
  grid-row-end: span 30;
}

.lhg__item:hover {
  transform: translateY(-3px);
  box-shadow: var(--lhg-shadow-md);
}

.lhg__btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}

.lhg__img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform .55s cubic-bezier(.2,.7,.2,1);
}
.lhg__item:hover .lhg__img { transform: scale(1.04); }

/* Tags overlay — fades in on hover for a cleaner default look */
.lhg__tags {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
  padding: var(--space-3, .75rem) var(--space-3, .75rem) calc(var(--space-3, .75rem) - .1rem);
  background: linear-gradient(to top, rgba(10,5,25,.80) 0%, rgba(10,5,25,.55) 50%, rgba(10,5,25,0) 100%);
  pointer-events: none;
  z-index: 2;
  opacity: .92;
  transition: opacity .25s ease;
}
.lhg__item:hover .lhg__tags { opacity: 1; }

.lhg__tag {
  display: inline-flex;
  align-items: center;
  padding: .3rem .65rem;
  background: rgba(255,255,255,.95);
  color: var(--lhg-text);
  border-radius: 999px;
  font-size: .625rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lhg__tag--service {
  background: var(--lhg-pill-fg);
  color: #fff;
}

.lhg__empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--lhg-muted);
  padding: var(--space-12, 3rem) var(--space-4, 1rem);
  background: var(--lhg-pill-bg);
  border-radius: var(--lhg-radius);
  font-style: italic;
}

/* -- Index grid (gallery cards) ------------------------------ */
.lhg--index .lhg__index-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-5, 1.25rem);
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .lhg--index .lhg__index-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .lhg--index[data-columns="3"] .lhg__index-grid { grid-template-columns: repeat(3, 1fr); }
  .lhg--index[data-columns="4"] .lhg__index-grid { grid-template-columns: repeat(4, 1fr); }
}

.lhg__card {
  background: #fff;
  border-radius: var(--lhg-radius);
  overflow: hidden;
  box-shadow: var(--lhg-shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}
.lhg__card:hover {
  transform: translateY(-4px);
  box-shadow: var(--lhg-shadow-md);
}

.lhg__card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.lhg__card-media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.lhg__card-img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2,.7,.2,1);
}
.lhg__card:hover .lhg__card-img { transform: scale(1.05); }

.lhg__card-media .lhg__tag {
  position: absolute;
  top: var(--space-3, .75rem);
  left: var(--space-3, .75rem);
}

.lhg__card-body {
  display: block;
  padding: var(--space-4, 1rem) var(--space-5, 1.25rem) var(--space-5, 1.25rem);
}
.lhg__card-title {
  display: block;
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: .25rem;
  color: var(--lhg-text);
  line-height: 1.3;
}
.lhg__card-meta {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8125rem;
  color: var(--lhg-muted);
}
.lhg__card-dot { opacity: .5; }

/* -- Lightbox ------------------------------------------------ */
.lhg-lightbox {
  /* Center via fixed + inset:0 + margin:auto — works around UA quirks. */
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(94vw, 1200px);
  max-width: 1200px;
  max-height: 92vh;
  height: max-content;

  padding: 0;
  border: 0;
  border-radius: var(--lhg-radius);
  background: linear-gradient(180deg, #0d0820 0%, #1a0c3a 100%);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 40px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06) inset;
}

.lhg-lightbox::backdrop {
  background: rgba(10,5,25,.85);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}

.lhg-lightbox[open] {
  animation: lhg-pop .22s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes lhg-pop {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.lhg-lightbox__figure {
  margin: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  max-height: 92vh;
}

.lhg-lightbox__img-wrap {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}
.lhg-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.lhg-lightbox__caption {
  padding: var(--lhg-pad);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  background: rgba(255,255,255,.02);
  border-top: 1px solid rgba(255,255,255,.06);
}

.lhg-lightbox__counter {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--lhg-accent);
  opacity: .85;
}

.lhg-lightbox__title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lhg-lightbox__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .2rem;
}

.lhg-lightbox__chip {
  display: inline-flex;
  align-items: center;
  padding: .25rem .625rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  border-radius: 999px;
  font-size: .625rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.lhg-lightbox__chip--service { background: rgba(242,218,170,.18); border-color: rgba(242,218,170,.35); color: var(--lhg-accent); }

.lhg-lightbox__project {
  color: var(--lhg-accent);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: .01em;
  margin-top: .2rem;
  transition: color .15s ease, transform .15s ease;
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: .25rem;
}
.lhg-lightbox__project:hover { color: #fff; transform: translateX(2px); }

.lhg-lightbox__close,
.lhg-lightbox__nav {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 0;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
  z-index: 3;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.lhg-lightbox__close:hover,
.lhg-lightbox__nav:hover { background: rgba(255,255,255,.22); }
.lhg-lightbox__close:active,
.lhg-lightbox__nav:active { transform: scale(.94); }
.lhg-lightbox__close:focus-visible,
.lhg-lightbox__nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.lhg-lightbox__close { top: .75rem; right: .75rem; }
.lhg-lightbox__nav   { top: 50%; transform: translateY(-50%); }
.lhg-lightbox__nav--prev { left: .75rem; }
.lhg-lightbox__nav--next { right: .75rem; }

@media (max-width: 720px) {
  .lhg-lightbox { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; height: 100vh; }
  .lhg-lightbox img { max-height: 65vh; }
}

/* -- Reduced motion / no-JS ---------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .lhg__item,
  .lhg__img,
  .lhg__card-img,
  .lhg-lightbox { transition: none !important; animation: none !important; }
  .lhg__item:hover,
  .lhg__card:hover { transform: none; }
}

.lhg-empty {
  text-align: center;
  padding: var(--space-8, 2rem);
  background: var(--color-purple-xlight, #f6f0fc);
  border-radius: var(--lhg-radius);
  color: var(--lhg-muted);
}
.lhg-empty a { color: var(--lhg-pill-fg); font-weight: 600; }
