/* Announcement popup (components/popup.js, site/snippets/popup.php).
   Styled like the place cards: white card, red Roboto Mono text, Mammane
   title. With a photo it's two columns (photo left, text right) on wider
   screens and stacked on phones; the card always fits the screen, the
   photo adapts instead of making the card scroll. */

/* ---------- Overlay + entrance ---------- */

.popup-overlay {
  --popup-duration: calc(var(--duration-panel) * 0.5);
  /* Space between the card and the screen edges. */
  --popup-gap: clamp(2rem, 6vw, 4rem);
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--popup-gap);
  background: rgba(0, 0, 0, 0.2); /* same as the menu's overlay */
  /* Closed: faded out, then hidden (also from the tab order). */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity calc(var(--popup-duration) * 0.5) ease,
    visibility 0s linear calc(var(--popup-duration) * 0.5);
}

.popup-overlay.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--popup-duration) ease, visibility 0s;
}

.popup-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 34rem;
  max-height: calc(100dvh - 2 * var(--popup-gap));
  overflow: hidden;
  background: #fff;
  color: var(--color-text-primary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  /* Slides up into place, like the intro's entrances. */
  transform: translateY(16px);
  transition: transform calc(var(--popup-duration) * 0.5) ease;
  padding: 20px;
}

.popup-overlay.is-open .popup-card {
  transform: none;
  transition: transform var(--popup-duration) var(--ease-enter);
}

/* The dialog itself gets focus when it opens; that needs no ring (the
   buttons inside show theirs when tabbed to). */
.popup-card:focus {
  outline: none;
}

/* ---------- Photo ---------- */

.popup-card__image {
  flex-shrink: 0;
  background: var(--color-bg-level-0);
}

.popup-card__image img {
  display: block;
  width: 100%;
  /* Phones: a band across the top, so the text stays visible. */
  height: 35dvh;
  object-fit: cover;
}

@media (min-width: 640px) {
  .popup-card.has-image {
    flex-direction: row;
    max-width: 56rem;
  }

  /* The photo column takes the photo's own shape; its height (and with
     it the card's) is capped so everything fits on screen. */
  .popup-card__image img {
    width: auto;
    max-width: 45vw;
    height: min(calc(100dvh - 2 * var(--popup-gap)), 36rem);
  }
}

/* ---------- Text ---------- */

.popup-card__body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem;
  /* Long texts scroll here, never the whole card. */
  min-height: 0;
  overflow-y: auto;
}

@media (min-width: 640px) {
  .popup-card__body {
    flex: 1;
    justify-content: center;
    padding: 3rem 2.5rem 2.5rem;
  }
}

.popup-card__title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  line-height: 1.1;
  padding-right: 2.5rem; /* room for the close button */
  text-transform: uppercase;
}

.popup-card__text {
  line-height: 1.6;
}

/* Download: a button in the style of the map/list toggle buttons. */
.popup-card__download {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-text-primary);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.popup-card__download:hover {
  background: var(--color-text-primary);
  color: #fff;
}

/* ---------- Close ---------- */

/* Top right of the card, on the white. */
.popup-card__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-primary);
  transition: color 0.2s ease;
}

/* Phones, with a photo: the photo is a band across the top of the card,
   so the card's white frame gets a strip above it for the button instead
   of the button sitting on the photo. */
@media (max-width: 639px) {
  .popup-card.has-image {
    padding-top: 3.5rem;
  }

  /* Centred in that strip, the cross lined up with the photo's edge. */
  .popup-card.has-image .popup-card__close {
    top: 0.375rem;
    right: 0.625rem;
  }

  .popup-card.has-image .popup-card__title {
    padding-right: 0;
  }
}

.popup-card__close:hover {
  color: var(--color-text-darkpurple);
}
