/* BookAChange gallery — masonry grid, lightbox, year filter.
   Styling mirrors the reference event page (option 3). */

html#sharepopup { overflow-y: hidden !important; }
#sharepopup header { position: static; }

/* ========== YEAR FILTER DROPDOWN ========== */
.gallery-filter-wrap {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 20px;
}
.gallery-year-dropdown { position: relative; display: inline-block; }
.gallery-year-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: transparent;
    border: none;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #19191F;
    cursor: pointer;
    transition: color 0.2s ease;
}
.gallery-year-trigger:hover { color: #E7364D; }
.gallery-year-trigger:hover svg path { fill: #E7364D; }
.gallery-year-trigger svg { width: 12px; height: 8px; transition: transform 0.2s ease; }
.gallery-year-trigger.is-open svg { transform: rotate(180deg); }
.gallery-year-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 140px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    list-style: none;
    margin: 0;
    padding: 6px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    max-height: 320px;
    overflow-y: auto;
}
.gallery-year-menu.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
.gallery-year-menu li {
    padding: 10px 16px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: 14px;
    color: #565D6D;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
}
.gallery-year-menu li:hover { background: #FEF2F4; color: #E7364D; }
.gallery-year-menu li.is-active { background: #E7364D; color: #fff; font-weight: 600; }

/* ========== MASONRY GRID (reference: 5-cell collage, video centered) ==========
   The gallery JS chunks items into groups of 5. Each .masonry block is a
   magazine-style collage with a wide centre cell (item4) where a video sits.
   Partial trailing groups (1-4 items) use the count-N fallbacks below. */
.bac-gallery-stack { display: flex; flex-direction: column; gap: 15px; }

.masonry {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  /* Exact reference row heights: top image 800x400, centre iframe 350px,
     bottom strip 800x300. Container is width-capped at 1290px so these stay
     in proportion. object-fit:cover makes every event's images fill the cells. */
  grid-template-rows: 400px 350px 300px;
  grid-template-areas:
    "top top right"
    "left center right"
    "left bottom bottom";
  gap: 15px;
}
.masonry .item1 { grid-area: top; }
.masonry .item2 { grid-area: right; }
.masonry .item3 { grid-area: left; }
.masonry .item4 { grid-area: center; }
.masonry .item5 { grid-area: bottom; }

/* Fallback layouts for trailing groups that aren't a full set of 5. */
.masonry.count-1 { grid-template-columns: 1fr; grid-template-rows: 480px; grid-template-areas: "a"; }
.masonry.count-1 .item1 { grid-area: a; }
.masonry.count-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 380px; grid-template-areas: "a b"; }
.masonry.count-2 .item1 { grid-area: a; } .masonry.count-2 .item2 { grid-area: b; }
.masonry.count-3 { grid-template-columns: 1fr 1.5fr 1fr; grid-template-rows: 380px; grid-template-areas: "a b c"; }
.masonry.count-3 .item1 { grid-area: a; } .masonry.count-3 .item2 { grid-area: b; } .masonry.count-3 .item3 { grid-area: c; }
.masonry.count-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 320px 320px; grid-template-areas: "a b" "c d"; }
.masonry.count-4 .item1 { grid-area: a; } .masonry.count-4 .item2 { grid-area: b; }
.masonry.count-4 .item3 { grid-area: c; } .masonry.count-4 .item4 { grid-area: d; }

.masonry .item {
  overflow: hidden;
  border-radius: 10px;
  position: relative;
}
.masonry .item img,
.masonry .item video,
.masonry .item iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: 0;
  transition: transform 0.4s ease;
}
.masonry .item iframe { position: absolute; inset: 0; }
.masonry .item:hover img,
.masonry .item:hover video,
.masonry .item:hover iframe { transform: scale(1.05); }

.masonry .item.video-item { cursor: pointer; }
.masonry .item video { pointer-events: none; }
.masonry .item video::-webkit-media-controls,
.masonry .item video::-webkit-media-controls-enclosure,
.masonry .item video::-webkit-media-controls-panel,
.masonry .item video::-webkit-media-controls-play-button,
.masonry .item video::-webkit-media-controls-start-playback-button {
  display: none !important;
  -webkit-appearance: none !important;
}
.masonry .item .mejs-controls,
.masonry .item .plyr__controls,
.masonry .item .wp-video,
.masonry .item .mejs-overlay-play { display: none !important; }
.masonry .item .mejs-mediaelement,
.masonry .item .mejs-layer { pointer-events: none !important; }

/* Play icon overlay on hover */
.masonry .video-item::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 70px; height: 70px;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(255,255,255,0.95);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 2;
}
.masonry .video-item::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  border-left: 18px solid #1a1a1a;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  transform: translate(-40%, -50%) scale(0.8);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 3;
}
.masonry .video-item:hover::after,
.masonry .video-item:hover::before { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.masonry .video-item:hover::before { transform: translate(-40%, -50%) scale(1); }

/* Lightbox */
.bac-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.bac-lightbox.active { display: flex; opacity: 1; }
.bac-lightbox-content {
  position: relative;
  width: 90%;
  max-width: 1000px;
  aspect-ratio: 16 / 9;
  top: 50%;
  transform: translate(0, -50%);
}
.bac-lightbox-content iframe,
.bac-lightbox-content img {
  width: 100%;
  height: 450px;
  border-radius: 10px;
  background: #000;
  border: 0;
  object-fit: contain;
}
.bac-lightbox-close {
  position: absolute;
  top: -45px;
  right: 0;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 2;
}
.bac-lightbox-close:hover { background: #fff; color: #000; transform: rotate(90deg); }
body.bac-lightbox-open { overflow: hidden; }

/* Empty state */
.gallery-empty-state {
    text-align: center;
    padding: 60px 20px;
    font-family: 'DM Sans', sans-serif;
    color: #565D6D;
    font-size: 16px;
}

/* ========== SINGLE EVENT LAYOUT (reference: yellow hero + purple gallery) ========== */

/* The theme adds ~7.1rem top padding to .page_content_wrap on every page to
   clear the header. On single events the hero is a full-width colour band, so
   that padding shows as a white gap above it — remove it here only. */
.single-bac_event .page_content_wrap { padding-top: 0; }

/* Full-width bands break out of the theme's centred content container so the
   background colours span the whole viewport, like the reference page. */
.bac-event-band {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}
.bac-event-band .bac-event-inner {
    max-width: 1290px; /* matches the site's Elementor content width */
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* Hero: soft yellow glow fading to white (top-left), title + intro, left-aligned. */
.bac-event-hero {
    background: radial-gradient(1200px 620px at 0% 0%, #FFF4B8 0%, #FFFDEB 40%, #FFFFFF 74%);
}
.bac-event-hero .bac-event-inner {
    padding-top: 80px;
    padding-bottom: 16px;
    text-align: left;
}
/* "Back to <category>" link above the heading. */
.bac-event-backtop {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: #565D6D;
    text-decoration: none;
    transition: color .2s ease, gap .2s ease;
}
.bac-event-backtop:hover { color: #E7364D; gap: 12px; }
.bac-event-backtop-arrow { font-size: 18px; line-height: 1; }

.bac-event-hero .sc_title { margin: 0; text-align: left; }
.bac-event-hero .sc_title .sc_item_title,
.bac-event-hero .sc_title .sc_item_title a {
    color: #19191F;
    font-size: 48px;
    line-height: 1.15;
}
.bac-event-intro {
    max-width: none; /* span the full content width, like the reference page */
    margin: 22px 0 0;
    font-family: 'DM Sans', sans-serif;
    font-size: 20px;
    line-height: 1.65;
    color: #4B5563;
}
.bac-event-intro p:last-child { margin-bottom: 0; }

/* Event gallery: the event's own images/videos as a masonry collage, white bg. */
/* Break out of the theme's narrow single-post content column (like the hero
   band), then cap the gallery at 1290px so it lines up with the heading/text. */
.bac-event-gallery-section {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: 8px 0 64px;
}
.bac-event-gallery-section .bac-event-gallery {
    display: block;
    max-width: 1290px;
    margin: 0 auto;
    padding: 0 20px;
}

/* "More galleries" band: a copy of the press-and-media In Action / Gallery
   section — purple background, centred white title, 3 redirect tiles. */
.bac-event-gallery-band {
    background: #5C358D;
}
.bac-event-gallery-band .bac-event-inner {
    padding-top: 56px;
    padding-bottom: 64px;
}
.bac-event-gallery-band .bac-event-gallery-title {
    text-align: center;
    margin: 0 0 30px;
}
.bac-event-gallery-band .sc_title .sc_item_title,
.bac-event-gallery-band .sc_title .sc_item_subtitle { color: #fff; }
.bac-event-back { margin-top: 40px; text-align: center; }

@media (max-width: 768px) {
    .bac-event-hero .bac-event-inner { padding-top: 52px; padding-bottom: 14px; }
    .bac-event-hero .sc_title .sc_item_title { font-size: 32px; }
    .bac-event-intro { font-size: 17px; }
    .bac-event-gallery-section { padding: 8px 0 48px; }
}

/* ========== GALLERY HUB (3 tiles) ========== */
.bac-gallery-hub {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 10px;
}
/* Reference layout: landscape image with the label below it (image-box style). */
.bac-gallery-tile {
    display: block;
    text-decoration: none;
}
.bac-gallery-tile-img {
    width: 100%;
    aspect-ratio: 370 / 267;
    border-radius: 12px;
    overflow: hidden;
    background-color: #2a2540;
    background-size: cover;
    background-position: center;
    transition: transform .5s ease;
}
.bac-gallery-tile:hover .bac-gallery-tile-img { transform: scale(1.02); }
.bac-gallery-tile-label {
    display: block;
    margin-top: 16px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 20px;
    line-height: 1.25;
    color: #fff;
    text-align: left;
}
@media (max-width: 768px) {
    .bac-gallery-hub { grid-template-columns: 1fr; gap: 24px; }
}

/* ========== LISTING PAGE ========== */
/* Trim the theme's ~7.1rem header gap on the gallery template pages (hub +
   category/list listings) so the title sits a comfortable distance under the
   menu, consistent with the single event pages. */
.page-template-template-gallery-category .page_content_wrap,
.page-template-template-gallery-list .page_content_wrap,
.page-template-template-gallery-hub .page_content_wrap { padding-top: 0; }

.bac-gallery-list-wrap {
    max-width: 1140px;
    margin: 0 auto;
    padding: 64px 20px 60px;
}
.bac-gallery-list-wrap .sc_title { margin-bottom: 24px; }
.bac-event-list { margin-top: 10px; }
.bac-event-year-group { margin-bottom: 48px; }
.bac-event-year-group h2 {
    font-family: 'DM Sans', sans-serif;
    color: #19191F;
    margin-bottom: 20px;
}
.bac-event-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}
.bac-event-card {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transition: transform .25s ease, box-shadow .25s ease;
    text-decoration: none;
    color: inherit;
}
.bac-event-card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,0.12); }
.bac-event-card-thumb { aspect-ratio: 4/3; overflow: hidden; background: #f1f1f4; }
.bac-event-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bac-event-card-body { padding: 16px 18px 20px; }
.bac-event-card-body h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #19191F;
    margin: 0 0 6px;
    line-height: 1.3;
}
.bac-event-card-body .bac-card-date { font-size: 13px; color: #E7364D; font-weight: 600; }
.bac-event-card-body .bac-card-venue { font-size: 13px; color: #565D6D; margin-top: 4px; }

/* Tablet: scale the fixed row heights down a touch as the collage narrows. */
@media (max-width: 1100px) {
  .masonry { grid-template-rows: 340px 300px 250px; }
  .masonry.count-1 { grid-template-rows: 400px; }
  .masonry.count-2, .masonry.count-3 { grid-template-rows: 320px; }
  .masonry.count-4 { grid-template-rows: 260px 260px; }
}
/* Phones & small tablets: keep the desktop hierarchy without the cramped
   magazine grid — the first image becomes a full-width "feature", the rest fall
   into a tidy 2-up grid of square tiles. Cells use aspect-ratio so they scale
   with the screen and stay aligned to the text width above. */
@media (max-width: 768px) {
  /* !important is required: the desktop count-N rules (e.g.
     .masonry.count-3 .item1{grid-area:a}) are more specific than these, so
     without it the collage placement leaks through and images overlap/hide. */
  .masonry,
  .masonry.count-1,
  .masonry.count-2,
  .masonry.count-3,
  .masonry.count-4 {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto !important;
    grid-auto-rows: auto !important;
    grid-template-areas: none !important;
    gap: 12px;
  }
  .masonry .item,
  .masonry .item1, .masonry .item2, .masonry .item3,
  .masonry .item4, .masonry .item5 {
    grid-area: auto !important;
    grid-column: auto !important;
    grid-row: auto !important;
    aspect-ratio: 1 / 1 !important;
    min-height: 0 !important;
  }
  /* Feature the first image full-width (editorial hero + supporting grid). */
  .masonry .item1 { grid-column: 1 / -1 !important; aspect-ratio: 16 / 10 !important; }
  /* 1-2 image groups don't need the feature split. */
  .masonry.count-1 { grid-template-columns: 1fr !important; }
  .masonry.count-2 .item1 { grid-column: auto !important; aspect-ratio: 1 / 1 !important; }
  .masonry .item iframe { height: 100% !important; }

  .bac-lightbox-content { width: 95%; }
  .bac-lightbox-close { top: -42px; right: 5px; }
  .bac-lightbox-content iframe,
  .bac-lightbox-content img { width: 100%; height: 280px; }
}

@media (max-width: 460px) {
  .bac-lightbox-content { top: 25%; }
}
