/* =============================================================
   Highland Cabinetry — Gallery page
   Loaded only on template-gallery.php (is_page_template check in
   functions.php). Reuses the homepage's .hc-inspo__filters/.hc-pill
   classes (styled in front-page.css, loaded there too — this file adds
   only what's unique to this page: hero, masonry grid, badges, hearts).
   ============================================================= */

/* ─── Hero ─────────────────────────────────────────────────── */
/* Same radial gradient + scrim opacity as the collection banner
   (.hc-shop-banner in shop.css) instead of a flat two-stop linear one — the
   lighter top-left glow reads as "somewhat transparent" rather than a solid
   block, with or without a photo behind it. */
.hc-gallery-hero {
  position: relative;
  min-height: 360px;
  display: flex;
  align-items: flex-end;
  background:
    radial-gradient(120% 130% at 12% 0%, color-mix(in srgb, var(--hc-dark) 80%, #fff) 0%, var(--hc-dark) 52%, var(--hc-dark2) 100%);
  overflow: hidden;
}
.hc-gallery-hero--has-img {
  background-image: var(--hc-gallery-hero-img);
  background-size: cover;
  background-position: center;
}
.hc-gallery-hero__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, color-mix(in srgb, var(--hc-dark2) 78%, transparent) 0%, color-mix(in srgb, var(--hc-dark2) 20%, transparent) 60%, transparent 100%);
}
.hc-gallery-hero__inner {
  position: relative;
  padding: 64px 0 40px;
}
.hc-gallery-hero__eyebrow {
  display: block;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: var(--hc-text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hc-accent);
  margin-bottom: 12px;
}
.hc-gallery-hero__title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2rem, 4.2vw, 2.9rem);
  font-weight: 500;
  color: var(--hc-white);
  line-height: 1.15;
  margin: 0 0 14px;
}
.hc-gallery-hero__title em {
  color: var(--hc-accent);
  font-style: italic;
}
.hc-gallery-hero__sub {
  max-width: 46ch;
  font-size: var(--hc-text-md);
  color: color-mix(in srgb, var(--hc-white) 80%, transparent);
  margin: 0;
}

/* ─── Toolbar: filters + meta ──────────────────────────────── */
.hc-gallery__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}
/* The pill row itself reuses .hc-inspo__filters as its class (same markup
   as the homepage's Kitchen Inspiration section), but that class's own
   flex/gap styling lives in front-page.css, which this page doesn't load
   — so it's redeclared here scoped to this page's toolbar instead of
   duplicating a whole separate stylesheet just for one rule. */
.hc-gallery__toolbar .hc-inspo__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}
.hc-gallery__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: var(--hc-text-sm);
  color: var(--hc-muted);
}
.hc-gallery__saved {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--hc-accent);
  font-weight: 600;
}
.hc-gallery__clear {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--hc-text-sm);
  color: var(--hc-muted);
  text-decoration: underline;
  cursor: pointer;
}
.hc-gallery__clear:hover {
  color: var(--hc-heading);
}

/* ─── Masonry grid — CSS columns, same technique as the design's
   staggered layout, no JS layout library needed. ─────────────── */
.hc-gallery__grid {
  columns: 3;
  column-gap: 20px;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}
.hc-gallery__item {
  position: relative;
  break-inside: avoid;
  margin-bottom: 20px;
  border-radius: var(--hc-r-lg);
  overflow: hidden;
  background: var(--hc-warm);
}
.hc-gallery__img {
  display: block;
  width: 100%;
  height: auto;
  transition: filter 0.2s;
}
.hc-gallery__item:hover .hc-gallery__img,
.hc-gallery__item:focus-within .hc-gallery__img {
  filter: brightness(0.82);
}
.hc-gallery__img--empty {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: linear-gradient(155deg, var(--hc-warm) 0%, var(--hc-border) 100%);
}
/* When a stale <img> src fails, the onerror handler adds this class —
   suppress the browser's broken-image glyph / alt text. */
img.hc-gallery__img--empty {
  color: transparent;
  font-size: 0;
}
/* Feature tile always keeps a tall crop so the detail-overlay text has
   room to sit over the image — !important since the ratio above can also
   arrive as an inline style per-item (see template-gallery.php).
   object-fit: cover crops the photo to the box instead of stretching it
   (an <img> with height:auto + aspect-ratio would otherwise squash the
   bitmap to fill a portrait frame). */
.hc-gallery__item.is-feature .hc-gallery__img,
.hc-gallery__item.is-feature .hc-gallery__img--empty {
  aspect-ratio: 4 / 5 !important;
}
.hc-gallery__item.is-feature .hc-gallery__img {
  object-fit: cover;
}

.hc-gallery__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hc-surface) 92%, transparent);
  color: var(--hc-heading);
  font-size: var(--hc-text-xs);
  font-weight: 600;
}

.hc-gallery__heart {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--hc-surface) 90%, transparent);
  color: var(--hc-heading);
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
}
.hc-gallery__heart:hover {
  transform: scale(1.06);
}
.hc-gallery__heart.is-saved {
  color: var(--hc-accent);
}
.hc-gallery__heart.is-saved svg {
  fill: currentColor;
}

.hc-gallery__detail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 16px 16px;
  background: linear-gradient(0deg, color-mix(in srgb, var(--hc-dark2) 92%, transparent) 0%, transparent 100%);
  /* Hidden until the tile is hovered or a control inside it is focused —
     applies to every tile, feature tiles included. */
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.hc-gallery__item:hover .hc-gallery__detail,
.hc-gallery__item:focus-within .hc-gallery__detail,
/* Touch: gallery.js adds .is-open on first tap, opens on second (no hover). */
.hc-gallery__item.is-open .hc-gallery__detail {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.hc-gallery__style {
  margin: 0 0 4px;
  font-size: var(--hc-text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hc-accent);
}
.hc-gallery__title {
  margin: 0 0 4px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--hc-white);
}
.hc-gallery__meta-line {
  margin: 0 0 12px;
  font-size: var(--hc-text-xs);
  color: color-mix(in srgb, var(--hc-white) 78%, transparent);
}
.hc-gallery__quick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hc-gallery__quick svg {
  flex: none;
  display: block;
}

.hc-gallery__empty {
  text-align: center;
  color: var(--hc-muted);
  padding: 40px 0;
}

.hc-gallery__load-more {
  display: flex;
  justify-content: center;
}

/* ─── Quick View modal ─────────────────────────────────────────
   Bootstrap modal shell (.modal / .modal-dialog / .modal-content);
   only what's specific to this modal is styled here. */
.hc-project-modal .modal-content {
  border: none;
  border-radius: var(--hc-r-lg);
  overflow: hidden;
  background: var(--hc-surface);
}
.hc-project-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  /* Solid dark disc with a white X — the default btn-close SVG is dark and
     vanishes against a dark photo. */
  background-color: color-mix(in srgb, var(--hc-dark2) 78%, transparent);
  background-size: 12px;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3E%3Cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3E%3C/svg%3E");
  opacity: 1;
}
.hc-project-modal__close:hover {
  background-color: var(--hc-dark2);
  opacity: 1;
}

/* Before/after comparison */
.hc-project-modal__compare {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--hc-warm);
  user-select: none;
  touch-action: pan-y;
  cursor: ew-resize;
}
.hc-project-modal__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hc-project-modal__before-wrap {
  position: absolute;
  inset: 0;
  width: 50%;
  overflow: hidden;
}
/* The clipped "before" image must match the full compare box, not shrink
   with its 50%-wide wrapper — JS keeps --hc-compare-w in sync with the
   box's rendered width. */
.hc-project-modal__img--before {
  width: var(--hc-compare-w, 100%);
  max-width: none;
}
.hc-project-modal__compare.is-single {
  cursor: default;
}
.hc-project-modal__compare.is-single .hc-project-modal__before-wrap,
.hc-project-modal__compare.is-single .hc-project-modal__handle,
.hc-project-modal__compare.is-single .hc-project-modal__tag--before {
  display: none;
}

/* No photo yet — warm gradient frame + label, same treatment as the
   grid tile's .hc-gallery__img--empty. */
.hc-project-modal__placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(155deg, var(--hc-warm) 0%, var(--hc-border) 100%);
  color: var(--hc-muted);
  font-size: var(--hc-text-sm);
}
.hc-project-modal__compare.is-empty {
  cursor: default;
}
.hc-project-modal__compare.is-empty .hc-project-modal__placeholder {
  display: flex;
}
.hc-project-modal__compare.is-empty .hc-project-modal__before-wrap,
.hc-project-modal__compare.is-empty .hc-project-modal__handle,
.hc-project-modal__compare.is-empty .hc-project-modal__tag {
  display: none;
}
.hc-project-modal__tag {
  position: absolute;
  top: 14px;
  z-index: 2;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hc-dark2) 60%, transparent);
  color: var(--hc-white);
  font-size: var(--hc-text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hc-project-modal__tag--before { left: 14px; }
/* Clear of the round close button (34px wide at right:14px). */
.hc-project-modal__tag--after { right: 58px; }
.hc-project-modal__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  margin-left: -20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--hc-dark);
  cursor: ew-resize;
}
/* The vertical divider line */
.hc-project-modal__handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--hc-white);
}
.hc-project-modal__handle svg {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 50%;
  background: var(--hc-white);
  box-shadow: var(--hc-sh);
}
.hc-project-modal__handle:focus-visible svg {
  outline: 2px solid var(--hc-accent);
  outline-offset: 2px;
}

/* Modal text column */
.hc-project-modal__body {
  padding: 28px;
}
.hc-project-modal__eyebrow {
  margin: 0 0 6px;
  font-size: var(--hc-text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hc-accent);
}
.hc-project-modal__title {
  margin: 0 0 12px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 500;
  color: var(--hc-heading);
}
.hc-project-modal__blurb {
  margin: 0;
  font-size: var(--hc-text-md);
  color: var(--hc-body);
}
.hc-project-modal__specs {
  margin: 0;
}
.hc-project-modal__spec {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hc-border);
  font-size: var(--hc-text-sm);
}
.hc-project-modal__spec:last-child {
  border-bottom: none;
}
.hc-project-modal__spec dt {
  margin: 0;
  color: var(--hc-muted);
  font-weight: 400;
}
.hc-project-modal__spec dd {
  margin: 0;
  color: var(--hc-heading);
  font-weight: 600;
  text-align: right;
}

@media (max-width: 575.98px) {
  .hc-project-modal__compare {
    aspect-ratio: 4 / 3;
  }
  .hc-project-modal__body {
    padding: 20px;
  }
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .hc-gallery__grid {
    columns: 2;
  }
}

@media (max-width: 575.98px) {
  .hc-gallery__grid {
    columns: 1;
  }
  .hc-gallery__toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
