.av-project-gallery .popup-modal.active {
  display:grid !important;
  grid-template-rows:auto minmax(0,1fr);
  max-height:85vh;
  max-height:min(85dvh,calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 8px));
  /* The imported mobile cards force 20px here. The scrollable body owns that inset. */
  padding:0 !important;
  overflow:hidden;
}
.av-project-gallery .popup-modal .popup-close-btn {
  position:static;
  display:grid;
  place-items:center;
  justify-self:end;
  width:44px;
  height:44px;
  margin:4px 10px 0;
}
.av-project-gallery .av-project-body {
  min-height:0;
  overscroll-behavior-y:contain;
  overflow-y:auto;
  padding:0 clamp(20px,4vw,30px) clamp(20px,4vw,30px);
}
.av-project-gallery .av-project-body a.elementor-button { display:inline-flex; align-items:center; min-height:44px; }
.av-project-gallery .popup-modal.active:has(> .av-project-enquiry) {
  grid-template-rows:auto minmax(0,1fr) auto;
}
.av-project-gallery .popup-modal > .av-project-enquiry {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:46px;
  padding:8px 16px;
  border-top:1px solid #e1dfea;
  background:#f8f7fc;
  color:#292077;
  font:650 16px/1.4 Urbanist,sans-serif;
  text-decoration:underline;
  text-underline-offset:3px;
}
.av-project-gallery .av-project-enquiry:is(:hover,:focus-visible) { background:#efecf7; }
.av-project-gallery .av-project-enquiry:focus-visible { outline:2px solid #54399d; outline-offset:-3px; }
.av-project-gallery [data-project-slug="myd-media"] .popup-modal { max-width: 720px; }
.av-film-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px clamp(20px, 4vw, 30px) 15px;
  color: #141333;
}
.av-film-header h2 { margin: 0 0 2px; font: 700 clamp(23px, 3vw, 30px)/1.15 Oxanium, sans-serif; }
.av-film-credit { color: #57566a; font-size: 14px; line-height: 1.45; }
.av-film-credit span { white-space: nowrap; }
.av-project-gallery .av-film-header .popup-close-btn { flex: 0 0 44px; margin: 0 -7px 0 0; }
.av-film-viewer {
  display: grid;
  grid-template: "frame choices" auto "frame copy" 1fr / minmax(0, 35%) minmax(0, 1fr);
  align-items: start;
  gap: 18px clamp(18px, 3vw, 28px);
  text-align: start;
}
.av-film-choices {
  grid-area: choices;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 3px;
  min-width: 0;
  border: 1px solid #dfdce9;
  border-radius: 8px;
  background: #f6f5fa;
}
.av-film-choices label { position: relative; margin: 0; }
.av-film-choices input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.av-film-choices span {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 4px 7px;
  border-radius: 5px;
  color: #37364b;
  font: 650 15px/1.25 Urbanist, sans-serif;
  text-align: center;
}
.av-film-choices input:checked + span { background: #292077; color: #fff; }
.av-film-choices input:focus-visible + span { outline: 2px solid #54399d; outline-offset: 2px; }
.av-film-frame {
  grid-area: frame;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e1dfea;
  border-radius: 8px;
  background: #f6f5fa;
}
.av-project-gallery .av-film-frame img { display: block; width: 100%; height: auto; max-width: 100%; border-radius: 0; object-fit: contain; }
.av-film-copy { grid-area: copy; min-width: 0; }
.av-film-caption h3 { margin: 0 0 9px; font: 700 clamp(20px, 2.5vw, 25px)/1.2 Oxanium, sans-serif; color: #161438; }
#portfolio-projects .av-film-caption p, #portfolio-projects .av-film-notes p { margin: 0; color: #464558; font-size: 16px; line-height: 1.55; }
.av-film-notes { margin: 18px 0; border-block: 1px solid #e1dfea; }
.av-film-notes summary { padding: 12px 0; min-height: 44px; color: #292077; cursor: pointer; font-weight: 650; }
.av-film-notes summary:focus-visible { outline: 2px solid #54399d; outline-offset: 2px; }
.av-film-viewer:not(:has(input[value="1"]:checked)) [data-film="1"],
.av-film-viewer:has(input[value="1"]:checked) [data-film="0"] { display: none; }
@media (max-width: 650px) {
  .av-film-viewer { grid-template: "choices" auto "frame" auto "copy" auto / minmax(0, 1fr); gap: 12px; }
  .av-film-frame { height: clamp(198px, 35vh, 320px); height: clamp(198px, 35dvh, 320px); }
  .av-project-gallery .av-film-frame img { width: auto; height: 100%; max-height: 100%; min-height: 0; }
  .av-film-header { padding-block: 13px 11px; }
  .av-film-notes { margin: 12px 0; }
}
html:has(body.popup-open) { overflow:hidden; }
@media (prefers-reduced-motion:reduce) {
  .av-project-gallery .popup-modal, .custom-popup-overlay { transition:none; }
}

@media (max-width:767px) {
  .av-project-gallery .elementor-pagination {
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    gap:4px;
    padding-block-start:16px;
  }
  .av-project-gallery .elementor-pagination .page-numbers {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:44px;
    min-height:44px;
    /* The imported per-widget selectors add another 5px on both sides of each number. */
    margin-inline:0 !important;
    border-radius:5px;
  }
  .av-project-gallery .elementor-pagination .current { background:#f0edf8; color:#302375; }
  .av-project-gallery .elementor-pagination a:focus-visible { outline:2px solid #392375; outline-offset:-2px; }
}
@media (max-width:479px) {
  .av-project-gallery .elementor-pagination { column-gap:2px; }
  .av-project-gallery .elementor-pagination :is(.prev,.next) { font-size:0; }
  .av-project-gallery .elementor-pagination :is(.prev,.next)::after {
    content:"";
    width:9px;
    height:9px;
    border:solid currentColor;
    border-width:2px 2px 0 0;
    transform:rotate(45deg);
  }
  .av-project-gallery .elementor-pagination .prev::after { transform:rotate(-135deg); }
  .av-project-gallery .elementor-pagination span:is(.prev,.next) { visibility:hidden; }
}
