/* =========================================================
   LIQUID GLASS POP-UP
   Shared by the Drones and Events pages. Opened by a READ MORE
   button with data-specs="<dialog id>" (popup.js); closes with
   ×, Esc or a click outside.
   ========================================================= */

/* The glass sits on the inner box, not on the <dialog> itself:
   a filter or transform here would stop the shared cursor, which
   is positioned against the viewport, from working inside. */
.spec-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(82vh, 760px);
  margin: auto;
  padding: 0;

  overflow: auto;

  color: #ffffff;

  border: none;
  background: transparent;

  /* Rounds off the inner glass as it scrolls. A radius is safe
     here; a filter or transform would not be. */
  border-radius: 28px;

  scrollbar-width: none;  /* still scrolls; the bar is just hidden */
}

.spec-dialog-inner {
  border-radius: 28px;

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0.04) 48%,
      rgba(255, 255, 255, 0.07)
    ),
    rgba(10, 16, 42, 0.42);

  backdrop-filter: blur(22px) saturate(185%) brightness(1.08);
  -webkit-backdrop-filter: blur(22px) saturate(185%) brightness(1.08);

  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.18),
    inset 0 1.5px 1px rgba(255, 255, 255, 0.55),
    inset 0 -1.5px 1px rgba(255, 255, 255, 0.2),
    inset 0 10px 18px -8px rgba(255, 255, 255, 0.18),
    inset 0 -12px 20px -10px rgba(170, 190, 255, 0.16);
}

.spec-dialog::backdrop {
  background: rgba(2, 4, 14, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Pop in with a slight overshoot, like iOS. The animation runs on
   the inner box so the <dialog> never carries a transform. */
.spec-dialog[open] .spec-dialog-inner {
  animation: spec-pop-in 0.42s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.spec-dialog[open]::backdrop {
  animation: spec-fade-in 0.3s ease;
}

.spec-dialog.closing .spec-dialog-inner {
  animation: spec-pop-out 0.2s ease forwards;
}

.spec-dialog.closing::backdrop {
  animation: spec-fade-out 0.2s ease forwards;
}

@keyframes spec-pop-in {
  from { opacity: 0; transform: scale(0.88) translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes spec-pop-out {
  to { opacity: 0; transform: scale(0.94) translateY(8px); }
}

@keyframes spec-fade-in {
  from { opacity: 0; }
}

@keyframes spec-fade-out {
  to { opacity: 0; }
}

.spec-dialog-inner {
  position: relative;
  padding: 30px 32px 28px;
}

.spec-dialog-kicker {
  display: block;
  margin-bottom: 6px;

  color: rgba(225, 232, 255, 0.85);

  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.8px;
}

.spec-dialog h3 {
  margin-bottom: 18px;
  padding-right: 48px;  /* keep long titles clear of the × button */

  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.spec-table {
  display: grid;
}

.spec-table div {
  display: flex;
  justify-content: space-between;
  gap: 16px;

  padding: 11px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);

  font-size: 15px;
}

.spec-table dt {
  color: rgba(230, 236, 255, 0.78);
}

.spec-table dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.spec-close {
  position: absolute;
  top: 18px;
  right: 18px;

  width: 38px;
  height: 38px;

  display: grid;
  place-items: center;

  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;

  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;

  font-size: 22px;
  line-height: 1;

  cursor: pointer;

  transition: background 0.2s ease;
}

/* Drawn × icon: centres exactly, unlike a text character */
.spec-close svg {
  display: block;
  width: 18px;
  height: 18px;
}

.spec-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 700px) {
  .spec-dialog-inner {
    padding: 24px 20px 20px;
  }

  .spec-dialog h3 {
    font-size: 24px;
  }

  .spec-table div {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spec-dialog[open],
  .spec-dialog[open]::backdrop,
  .spec-dialog.closing,
  .spec-dialog.closing::backdrop {
    animation: none;
  }
}


/* =========================================================
   EVENT POP-UP
   The same layout as the event article pages (text in the
   middle, photos floating and tilted on both sides, a wide
   photo underneath), shown over the page. The text box is
   liquid glass; the photos float on the dimmed page.
   ========================================================= */

.event-popup {
  position: fixed;
  inset: 0;

  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;

  border: 0;
  background: transparent;
  color: #ffffff;

  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;  /* still scrolls; the bar is just hidden */
}

.event-popup::backdrop {
  background: rgba(2, 4, 14, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.event-popup[open]::backdrop {
  animation: spec-fade-in 0.3s ease;
}

.event-popup.closing::backdrop {
  animation: spec-fade-out 0.2s ease forwards;
}

.event-popup-stage {
  min-height: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 84px 40px 64px;
  box-sizing: border-box;
}

/* Same grid as .article-layout on the event pages */
.event-popup-layout {
  display: grid;

  grid-template-columns:
    minmax(0, 1fr)
    minmax(380px, 600px)
    minmax(0, 1fr);

  grid-template-areas:
    "p1 card p2"
    "p3 card p4";

  column-gap: clamp(32px, 4vw, 60px);
  row-gap: 64px;

  align-items: center;

  width: min(100%, 1400px);
}

.event-popup-layout.rows-3 {
  grid-template-areas:
    "p1 card p2"
    "p3 card p4"
    "p5 card p6";
}


/* Liquid glass text box */

.popup-card {
  grid-area: card;

  padding: 44px 46px;

  border-radius: 28px;

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.14),
      rgba(255, 255, 255, 0.04) 48%,
      rgba(255, 255, 255, 0.07)
    ),
    rgba(10, 16, 42, 0.42);

  backdrop-filter: blur(22px) saturate(185%) brightness(1.08);
  -webkit-backdrop-filter: blur(22px) saturate(185%) brightness(1.08);

  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.18),
    inset 0 1.5px 1px rgba(255, 255, 255, 0.55),
    inset 0 -1.5px 1px rgba(255, 255, 255, 0.2),
    inset 0 10px 18px -8px rgba(255, 255, 255, 0.18),
    inset 0 -12px 20px -10px rgba(170, 190, 255, 0.16);
}

.popup-card h3 {
  margin: 0 0 22px;

  font-size: clamp(26px, 2.4vw, 34px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.popup-card p {
  margin: 0 0 20px;

  color: rgba(232, 237, 255, 0.9);

  font-size: 17px;
  line-height: 1.8;
}

.popup-card p:last-child {
  margin-bottom: 0;
}

.popup-card strong {
  color: #ffffff;
}


/* Floating photos, tilted like the event pages */

.popup-photo {
  position: relative;

  width: 100%;
  max-width: 340px;
  justify-self: center;

  aspect-ratio: 4 / 3;
  overflow: hidden;

  border-radius: 16px;
  border: 1px solid rgba(170, 180, 220, 0.25);

  background: #080c20;

  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);

  transform: rotate(var(--tilt)) translateY(var(--lift));
}

.popup-photo img {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: cover;

  transition: transform 0.5s ease;
}

.popup-photo:hover img {
  transform: scale(1.04);
}

/* --i staggers the pop-in animation */
.popup-photo.p1 { grid-area: p1; --tilt: -10deg; --lift: 10px;  --i: 1; }
.popup-photo.p2 { grid-area: p2; --tilt: 10deg;  --lift: 10px;  --i: 2; }
.popup-photo.p3 { grid-area: p3; --tilt: 7deg;   --lift: -5px;  --i: 3; }
.popup-photo.p4 { grid-area: p4; --tilt: -8deg;  --lift: -5px;  --i: 4; }
.popup-photo.p5 { grid-area: p5; --tilt: -7deg;  --lift: -5px;  --i: 5; }
.popup-photo.p6 { grid-area: p6; --tilt: 8deg;   --lift: -5px;  --i: 6; }

.popup-photo-wide {
  width: min(900px, 100%);
  margin-top: 64px;

  overflow: hidden;

  border-radius: 18px;
  border: 1px solid rgba(170, 180, 220, 0.25);

  background: #080c20;

  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);

  --i: 7;
}

.popup-photo-wide img {
  display: block;
  width: 100%;
  height: auto;
}


/* Close button stays in the corner while the pop-up scrolls */

.event-popup .spec-close {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 5;

  width: 46px;
  height: 46px;

  font-size: 24px;

  background: rgba(255, 255, 255, 0.12);

  backdrop-filter: blur(12px) saturate(170%);
  -webkit-backdrop-filter: blur(12px) saturate(170%);

  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 1px rgba(255, 255, 255, 0.5);
}


/* Pop in: the glass box springs up, then the photos pop
   into their tilted places one after another */

.event-popup[open] .popup-card {
  animation: popup-card-in 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.event-popup[open] .popup-photo,
.event-popup[open] .popup-photo-wide {
  animation: popup-photo-in 0.6s cubic-bezier(0.34, 1.45, 0.64, 1) both;
  animation-delay: calc(var(--i) * 55ms + 40ms);
}

.event-popup.closing .popup-card,
.event-popup.closing .popup-photo,
.event-popup.closing .popup-photo-wide {
  animation: popup-item-out 0.2s ease forwards;
  animation-delay: 0s;
}

@keyframes popup-card-in {
  from { opacity: 0; transform: translateY(26px) scale(0.92); }
  to { opacity: 1; transform: none; }
}

@keyframes popup-photo-in {
  from {
    opacity: 0;
    transform: rotate(0deg) translateY(40px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: rotate(var(--tilt, 0deg)) translateY(var(--lift, 0px)) scale(1);
  }
}

@keyframes popup-item-out {
  to {
    opacity: 0;
    transform:
      rotate(var(--tilt, 0deg))
      translateY(calc(var(--lift, 0px) + 14px))
      scale(0.94);
  }
}


/* Small laptops: same proportions as the event pages */

@media (max-width: 1100px) {
  .event-popup-layout {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(0, 2.2fr)
      minmax(0, 1fr);

    column-gap: clamp(18px, 3vw, 28px);
  }

  .popup-card {
    padding: 36px 30px;
  }

  .popup-card p {
    font-size: 16px;
    line-height: 1.75;
  }
}


/* Phones: text first, then the photos two by two, tilted less */

@media (max-width: 760px) {
  .event-popup-stage {
    justify-content: flex-start;
    padding: 76px 16px 40px;
  }

  .event-popup-layout {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "card card"
      "p1 p2"
      "p3 p4";
    column-gap: 18px;
    row-gap: 22px;
  }

  .event-popup-layout.rows-3 {
    grid-template-areas:
      "card card"
      "p1 p2"
      "p3 p4"
      "p5 p6";
  }

  .popup-card {
    margin-bottom: 8px;
    padding: 26px 22px;
    border-radius: 22px;
  }

  .popup-card h3 {
    font-size: 24px;
  }

  .popup-card p {
    margin-bottom: 14px;
    font-size: 15px;
    line-height: 1.7;
  }

  .popup-photo.p1,
  .popup-photo.p3,
  .popup-photo.p5 { --tilt: -4deg; --lift: 0px; }

  .popup-photo.p2,
  .popup-photo.p4,
  .popup-photo.p6 { --tilt: 4deg; --lift: 0px; }

  .popup-photo-wide {
    margin-top: 28px;
  }

  .event-popup .spec-close {
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .event-popup[open]::backdrop,
  .event-popup.closing::backdrop,
  .event-popup[open] .popup-card,
  .event-popup[open] .popup-photo,
  .event-popup[open] .popup-photo-wide,
  .event-popup.closing .popup-card,
  .event-popup.closing .popup-photo,
  .event-popup.closing .popup-photo-wide {
    animation: none;
  }
}


/* Hide the scrollbar in Chrome, Edge and Safari too (Firefox uses
   scrollbar-width above). The pop-ups still scroll with the wheel,
   trackpad, touch and keyboard. */
.spec-dialog::-webkit-scrollbar,
.event-popup::-webkit-scrollbar {
  display: none;
}
