/* =============================================
   ixiun Collections — front-end styles
   ---------------------------------------------
   Colors and fonts come from the active theme's CSS custom properties
   (--color-*, --font-*), so the gallery and seasonal output track whatever
   palette the theme defines. On ixiun-onyx these variables exist already; on a
   different theme, define the same variables (or override these rules) to match.
   ============================================= */


/* ---------------------------------------------
   GALLERY — filterable portfolio grid ([cc_gallery])
   A row of pill filters (built from the gallery_cat taxonomy) sits above a
   responsive grid of Gallery Item cards. gallery-filter.js toggles .is-hidden /
   .is-leaving; the active pill carries .is-active. --cc-gallery-cols is inline.
   --------------------------------------------- */

/* The highlight colour shared by the selected filter pill and the lightbox
   controls. Tracks the theme's primary-button gold so the gallery speaks the same
   language as every other button on the site; themes that don't define the button
   variables fall back to their plain accent. Declared on both roots because the
   lightbox is appended to <body>, outside .cc-gallery. */
.cc-gallery,
.cc-lightbox {
  --cc-accent:      var(--color-btn-primary-bg, var(--color-accent));
  --cc-accent-text: var(--color-btn-primary-text, var(--color-primary));
}

.cc-gallery__filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 0 auto 3rem;
}

/* Pills: quiet-but-legible by default (a visible border, not a hairline); hover
   washes in the active colour; the selected one fills with it outright and lifts
   on a soft ring, so which category you're on is readable at a glance. */
.cc-gallery__filter {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.7em 1.4em;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease, transform 0.18s ease;
}

.cc-gallery__filter:hover {
  background: color-mix(in srgb, var(--cc-accent) 18%, var(--color-surface));
  border-color: var(--cc-accent);
}

.cc-gallery__filter.is-active {
  background: var(--cc-accent);
  color: var(--cc-accent-text);
  border-color: var(--cc-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cc-accent) 22%, transparent);
  transform: translateY(-1px);
}

.cc-gallery__filter:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .cc-gallery__filter { transition: none; transform: none; }
  .cc-gallery__filter.is-active { transform: none; }
}

/* Responsive grid: --cc-gallery-cols columns on desktop, degrading to 2 then 1. */
.cc-gallery__grid {
  display: grid;
  grid-template-columns: repeat(var(--cc-gallery-cols, 3), 1fr);
  gap: 1.75rem;
}

@media (max-width: 900px) {
  .cc-gallery__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .cc-gallery__grid { grid-template-columns: 1fr; }
}

.cc-gallery__item {
  margin: 0;
  /* Filter transition: the fade/rise is driven by .is-leaving (added/removed in
     gallery-filter.js). Keep this 350ms in sync with FADE_MS there. */
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* Animatable "out" (or not-yet-in) state — 0 opacity + a slight scale/drop. */
.cc-gallery__item.is-leaving {
  opacity: 0;
  transform: scale(0.96) translateY(8px);
}

/* Final resting state for filtered-out items: removed from the grid so the
   remaining items reflow to fill the gaps. Applied after the fade completes. */
.cc-gallery__item.is-hidden {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .cc-gallery__item { transition: none; }
}

/* The media is a <button> (see gallery.php) so the lightbox is reachable by
   keyboard and announced to screen readers — these rules strip the UA button
   chrome and leave it looking like the plain image tile it did before. */
.cc-gallery__media {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  overflow: hidden;
  border-radius: 12px;
  aspect-ratio: 4 / 5;
  background: color-mix(in srgb, var(--color-accent) 22%, var(--color-secondary));
  cursor: zoom-in;
}

.cc-gallery__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.cc-gallery__item:hover .cc-gallery__media img {
  transform: scale(1.04);
}

.cc-gallery__media:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .cc-gallery__media img { transition: none; }
  .cc-gallery__item:hover .cc-gallery__media img { transform: none; }
}


/* ---------------------------------------------
   LIGHTBOX — full-size view of a gallery item
   One dialog is created lazily by gallery-lightbox.js and reused for every item;
   it lives at the end of <body>, outside the gallery, hence the .cc-lightbox
   (not .cc-gallery__*) naming. Visibility is driven by the .is-open class.
   --------------------------------------------- */

.cc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--color-primary) 88%, transparent);
  backdrop-filter: blur(6px);

  /* Closed state. Kept in the DOM (not display:none) so opening/closing can
     animate; visibility + pointer-events keep it untabbable and inert while shut.
     Keep this 0.25s in sync with CLOSE_MS in gallery-lightbox.js. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.cc-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.25s ease, visibility 0s;
}

/* Scroll lock: set on <html> while the lightbox is open so the page behind it
   doesn't scroll away under the overlay. */
.cc-lightbox-open {
  overflow: hidden;
}

.cc-lightbox__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 100%;
  transform: scale(0.94);
  transition: transform 0.25s ease;
}

.cc-lightbox.is-open .cc-lightbox__figure {
  transform: scale(1);
}

/* The zoomed image: as big as the viewport allows, never cropped, never upscaled
   past its natural size. The height cap leaves room for the caption. */
.cc-lightbox__image {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-accent) 22%, var(--color-secondary));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s ease;
}

/* Set by gallery-lightbox.js while the full-size file is still downloading, so a
   slow image shows an empty frame rather than the previous item's picture. */
.cc-lightbox.is-loading .cc-lightbox__image {
  opacity: 0;
}

.cc-lightbox__caption {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--color-text-inverse);
  text-align: center;
  margin: 0;
}

/* Controls: close, previous, next. Circular glass buttons over the backdrop. */
.cc-lightbox__btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-text-inverse) 30%, transparent);
  background: color-mix(in srgb, var(--color-text-inverse) 12%, transparent);
  color: var(--color-text-inverse);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.cc-lightbox__btn:hover {
  background: var(--cc-accent);
  border-color: var(--cc-accent);
  color: var(--color-primary);
  transform: scale(1.06);
}

.cc-lightbox__btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.cc-lightbox__close { top: 1.25rem; right: 1.25rem; }
.cc-lightbox__prev  { left: 1.25rem;  top: 50%; transform: translateY(-50%); }
.cc-lightbox__next  { right: 1.25rem; top: 50%; transform: translateY(-50%); }

.cc-lightbox__prev:hover,
.cc-lightbox__next:hover { transform: translateY(-50%) scale(1.06); }

/* Hidden by the script when the filtered set holds a single item — nothing to
   page through, so the arrows would be dead controls. */
.cc-lightbox__btn[hidden] { display: none; }

/* On narrow screens the arrows would sit on top of the image; drop them to the
   bottom corners instead, clear of the artwork. */
@media (max-width: 640px) {
  .cc-lightbox__prev,
  .cc-lightbox__next {
    top: auto;
    bottom: 1.25rem;
    transform: none;
  }
  .cc-lightbox__prev:hover,
  .cc-lightbox__next:hover { transform: scale(1.06); }
  .cc-lightbox__image { max-height: 66vh; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-lightbox,
  .cc-lightbox__figure,
  .cc-lightbox__btn { transition: none; }
  .cc-lightbox__figure,
  .cc-lightbox.is-open .cc-lightbox__figure { transform: none; }
}

.cc-gallery__title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: var(--color-text);
  margin-top: 0.9rem;
}

.cc-gallery__empty {
  text-align: center;
  color: var(--color-muted);
  font-style: italic;
}


/* ---------------------------------------------
   SEASONAL — the date-driven collection wrapper ([ixiun_seasonal])
   Deliberately minimal: the collection's own block content carries the real
   layout (headers, text, images). These rules only frame the optional title /
   featured image and keep nested output flowing naturally.
   --------------------------------------------- */

.ixiun-seasonal__image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

.ixiun-seasonal__title {
  font-family: var(--font-heading);
  color: var(--color-text);
  margin: 1.25rem 0 0.75rem;
}

/* Editor-only nudge shown when no collections exist yet (never seen by visitors). */
.ixiun-seasonal__empty {
  text-align: center;
  color: var(--color-muted);
  font-style: italic;
}
