/* ==========================================================
   media-gallery.css  -  MEDIA PAGE: filter buttons + gallery cards
   Load order in media.html:  style.css, media.css, media-gallery.css, responsive.css
   One gallery for ALL screen sizes (replaces the separate desktop / mobile galleries).
   ========================================================== */

/* ---------------------------------------------------------
   FILTER BUTTONS  (styled like the contact card's Submit button)
   --------------------------------------------------------- */
.media-filter {
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 90%;
  max-width: 1100px;
  margin: 24px auto 6px;
  padding: 0 10px;
  box-sizing: border-box;
}
.filter-btn {
  border: none;
  background-color: #ffdde1;
  color: #9d8871;
  padding: 12px 26px;
  border-radius: 20px;
  font-family: "BDRegular", BDRegular;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}
.filter-btn.is-active {
  background-color: #ec5d70;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(236, 93, 112, 0.35);
}
.filter-btn:focus-visible { outline: 3px solid #742655; outline-offset: 2px; }
@media (hover: hover) {
  .filter-btn:hover { background-color: #ec5d70; color: #ffffff; }
}

/* shown when a filter has no matching work yet */
.media-empty {
  text-align: center;
  font-family: "BDRegular", BDRegular;
  font-size: 1.3rem;
  color: #742655;
  padding: 40px 20px;
  position: relative;
  z-index: 20;
}
.media-empty[hidden] { display: none; }

/* ---------------------------------------------------------
   GALLERY  (CSS columns: items re-flow by themselves when filtered)
   --------------------------------------------------------- */
.media-gallery {
  column-count: 3;                 /* desktop: same 3 columns as before */
  column-gap: 14px;
  width: 90%;
  margin: 14px auto 40px;
  padding: 20px;
  box-sizing: border-box;
  position: relative;
  z-index: 999;
}

.media-item {
  display: block;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 14px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.media-item.is-hidden { display: none; }
.media-item.is-showing { animation: media-pop 0.4s ease backwards; }
@keyframes media-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.media-item label { display: block; cursor: pointer; }
.media-item img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0;
  border-radius: 8px 8px 0 0;
}

/* description + hashtags under each image */
.media-caption { display: block; padding: 10px 14px 14px; }
.media-caption__title,
.media-caption__desc,
.media-caption__tags { display: block; font-family: "BDRegular", BDRegular; }
.media-caption__title { font-size: 1.1rem; color: #742655; line-height: 1.25; }
.media-caption__desc  { font-size: 0.92rem; color: #9d8871; line-height: 1.4; margin-top: 4px; }
.media-caption__tags  { font-size: 0.88rem; color: #ec5d70; line-height: 1.5; margin-top: 8px; word-spacing: 4px; }

/* ---------------------------------------------------------
   LIGHTBOX (click an image): image + its description centred on the blurred overlay.
   media.css already turns the checked label into the full-screen overlay.
   --------------------------------------------------------- */
.media-item input[type=checkbox]:checked + label {
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  box-sizing: border-box;
  overflow-y: auto;
}
.media-item input[type=checkbox]:checked + label > img {
  max-width: min(88vw, 1100px);
  max-height: 66vh;
  border-radius: 8px;
}
.media-item input[type=checkbox]:checked + label .media-caption {
  max-width: min(88vw, 640px);
  padding: 0;
  text-align: center;
}
.media-item input[type=checkbox]:checked + label .media-caption__title { font-size: 1.5rem; color: #ffffff; }
.media-item input[type=checkbox]:checked + label .media-caption__desc  { font-size: 1.05rem; color: #ffffff; }
.media-item input[type=checkbox]:checked + label .media-caption__tags  { font-size: 1rem; color: #ffdde1; }

@media (prefers-reduced-motion: reduce) {
  .media-item.is-showing { animation: none; }
}

/* ---------------------------------------------------------
   TABLETS + PHONES (<= 1280px)  (column counts / margins are fine-tuned in responsive.css)
   --------------------------------------------------------- */
@media (max-width: 1280px) {
  .media-filter { gap: 8px; margin: clamp(8px, 2.5vw, 20px) auto 4px; }
  .filter-btn {
    padding: 9px clamp(14px, 4vw, 24px);
    font-size: clamp(0.95rem, 3.4vw, 1.1rem);
  }
  .media-gallery { column-count: 2; column-gap: 12px; padding: 0; }
  .media-item { margin-bottom: 12px; }
  .media-caption { padding: 8px 10px 12px; }
  .media-caption__title { font-size: 1rem; }
  .media-caption__desc  { font-size: 0.82rem; }
  .media-caption__tags  { font-size: 0.78rem; }
}
/* ---------------------------------------------------------
   FILTER ICON + DROPDOWN  (tablets + phones only; desktop keeps the button row)
   --------------------------------------------------------- */
.filter-toggle { display: none; }

@media (max-width: 1280px) {
  .filter-wrap {
    position: relative;
    z-index: 1000;                        /* above .media-gallery (z-index 999) so the panel overlaps it */
    display: flex;
    justify-content: center;
    margin: clamp(8px, 2.5vw, 20px) auto 4px;
  }

  .filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;                     /* comfortable tap target */
    padding: 8px 18px;
    border: none;
    border-radius: 20px;
    background: #ffdde1;
    color: #9d8871;
    font-family: "BDRegular", BDRegular;
    font-size: clamp(1rem, 3.6vw, 1.2rem);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: background-color 0.25s ease, color 0.25s ease;
  }
  .filter-toggle svg { flex: none; }
  .filter-toggle:focus-visible { outline: 3px solid #742655; outline-offset: 2px; }
  .filter-toggle[aria-expanded="true"] { background: #ec5d70; color: #fff; }

  /* small pill showing the active filter, e.g. "Logos" */
  .filter-toggle__current {
    display: none;
    padding: 2px 10px;
    border-radius: 999px;
    background: #ec5d70;
    color: #fff;
    font-size: 0.85em;
  }
  .filter-toggle.has-filter .filter-toggle__current { display: inline-block; }
  .filter-toggle[aria-expanded="true"] .filter-toggle__current { background: #fff; color: #ec5d70; }

  /* the existing button row becomes a dropdown panel */
  .filter-wrap .media-filter {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    width: min(92vw, 380px);
    max-width: none;
    margin: 0;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, -6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }
  .filter-wrap .media-filter.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }
  .filter-wrap .filter-btn { width: 100%; padding: 10px 12px; }
  .filter-wrap .filter-btn[data-filter="all"] { grid-column: 1 / -1; }   /* "All" spans the full top row */

  /* hide the icon while an image lightbox is open */
  body:has(.media-item input[type=checkbox]:checked) .filter-wrap { visibility: hidden; }
}
@media (max-width: 1280px) {
  .filter-wrap .media-filter { min-height: 60px; }
  .filter-wrap .media-filter .filter-btn {
    display: block;
    visibility: visible;
    opacity: 1;
    background-color: #ffdde1;
    color: #9d8871;
    font-size: 1rem;
    line-height: 1.2;
  }
  .filter-wrap .media-filter .filter-btn.is-active {
    background-color: #ec5d70;
    color: #fff;
  }
}

/* ---------- 3D viewer card + pop-up ---------- */

/* card: matches the other .media-item cards */
.media-3d-open {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0 !important;
  outline: 0;
  border-radius: 8px;
  overflow: hidden;                     /* keeps the rounded corners clean */
  background: transparent;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  position: relative;
}
.media-3d-open img {
  width: 100%; height: auto; display: block; margin: 0;
  border-radius: 8px 8px 0 0;
}
.media-3d-open:focus-visible { outline: 3px solid #742655; outline-offset: 2px; }
.media-3d-badge {
  position: absolute; top: 10px; right: 10px;
  padding: 6px 14px; border-radius: 999px;
  background: #ec5d70; color: #fff;
  font-family: "BDRegular", BDRegular; font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(236, 93, 112, 0.4);
}

/* pop-up: same blurred brown overlay as the image lightbox */
.viewer-3d {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;                        /* matches the visible screen on phones (address bar) */
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border: 0;
  background: transparent;
  color: #fff;
  box-sizing: border-box;
  overflow: hidden;                      /* the pop-up itself never scrolls */
  overscroll-behavior: contain;
  
}

.viewer-3d[open] { display: flex; }
.viewer-3d::backdrop {
  background-color: rgba(157, 136, 113, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.viewer-3d__stage {
  margin: auto;
  width: min(96vw, 1300px);
  height: min(calc(100dvh - 32px), 900px);   /* always fits the screen */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.viewer-3d__bar { display: flex; align-items: center; justify-content: space-between; }
.viewer-3d__newtab { font-family: "BDRegular", BDRegular; color: #fff; font-size: 1.05rem; }
.viewer-3d__close {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: #ec5d70; color: #fff; font-size: 1.7rem; line-height: 1; cursor: pointer;
}
.viewer-3d iframe {
  flex: 1 1 auto;                        /* fills whatever space is left between bar and caption */
  min-height: 0;
  width: 100%;
  height: auto;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  
}


/* caption under the viewer: same look as the image lightbox */
.viewer-3d__caption { max-width: 640px; margin: 0 auto; padding: 0; text-align: center; }
.viewer-3d .media-caption__title { font-size: 1.5rem; color: #ffffff; }
.viewer-3d .media-caption__desc  { font-size: 1.05rem; color: #ffffff; }
.viewer-3d .media-caption__tags  { font-size: 1rem; color: #ffdde1; }

/* hide the menu links while an image lightbox or the 3D viewer is open */
html:has(.media-item input[type=checkbox]:checked) .links-container,
html:has(dialog.viewer-3d[open]) .links-container {
  visibility: hidden !important;
}