/* ── Shared overlay backdrop ────────────────────────────────────────────── */
.mm-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(27, 31, 46, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.mm-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ── Close button ───────────────────────────────────────────────────────── */
.mm-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-3);
  padding: 4px 6px;
  z-index: 1;
  transition: color var(--t-fast);
}

.mm-close:hover {
  color: var(--ink);
}
.mm-close:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }

/* ── Video modal ────────────────────────────────────────────────────────── */
.mm-overlay--video {
  padding: 40px 24px;
  /* backdrop-filter on a parent blacks out iframes on iOS Safari (WebKit bug) */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.mm-overlay--video .mm-panel {
  position: relative;
  background: #000;
  width: 100%;
  max-width: min(1100px, calc((100vh - 80px) * 16 / 9));
}

.mm-overlay--video .mm-close {
  color: rgba(255, 255, 255, 0.7);
}

.mm-overlay--video .mm-close:hover {
  color: #fff;
}
.mm-overlay--video .mm-close:focus-visible { outline-color: rgba(255,255,255,0.6); }

.mm-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

/* Fallback for browsers without aspect-ratio support */
@supports not (aspect-ratio: 1) {
  .mm-video-wrap {
    padding-top: 56.25%;
    height: 0;
  }
  .mm-video-iframe {
    position: absolute;
    inset: 0;
  }
}

.mm-video-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── PDF modal ──────────────────────────────────────────────────────────── */
.mm-overlay--pdf {
  padding: 48px 24px 24px;
}

.mm-overlay--pdf .mm-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  height: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  padding-top: 38px; /* clear the absolute close button */
  box-shadow: 0 24px 80px rgba(27, 31, 46, 0.25);
}

.mm-overlay--pdf .mm-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mm-pdf-iframe {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: block;
  border: none;
}

/* ── Article preview card ───────────────────────────────────────────────── */
.mm-overlay--card .mm-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 440px;
  margin: 0 24px;
  padding: 32px 32px 28px;
  box-shadow: 0 20px 60px rgba(27, 31, 46, 0.22);
  animation: mm-rise 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mm-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mm-card-publisher {
  display: block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 8px;
}

.mm-card-title {
  font-family: var(--fd);
  font-size: 20px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.35;
  margin: 0 0 18px;
}

.mm-card-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  font-weight: 300;
  color: var(--ink-3);
  line-height: 1.6;
  margin-bottom: 24px;
  padding: 11px 14px;
  background: rgba(27, 31, 46, 0.04);
  border-left: 2px solid var(--border);
}

.mm-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  transition: color var(--t-fast);
  white-space: nowrap;
}

.mm-card-cta:hover {
  color: var(--brass-dk);
  text-decoration: none;
}

/* ── Dark mode ──────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  .mm-overlay {
    background: rgba(0, 0, 0, 0.75);
  }

  .mm-overlay--pdf .mm-panel,
  .mm-overlay--card .mm-panel {
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  }
}

/* ── SVG diagram modal ──────────────────────────────────────────────────── */
.mm-overlay--svg {
  padding: 40px 24px;
}

.mm-overlay--svg .mm-panel {
  position: relative;
  background: var(--warm);
  border: 1px solid var(--border-warm);
  padding: 40px;
  box-shadow: 0 24px 80px rgba(27, 31, 46, 0.18);
  animation: mm-rise 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.mm-overlay--svg .mm-body svg {
  display: block;
  height: min(75vh, 650px);
  width: auto;
}

.mm-overlay--svg .mm-body svg .sans {
  font-family: var(--fs, 'DM Sans', sans-serif);
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .mm-overlay--svg {
    padding: 48px 16px 16px;
  }

  .mm-overlay--svg .mm-panel {
    padding: 28px 20px;
    width: 100%;
  }

  .mm-overlay--svg .mm-body svg {
    height: auto;
    width: 100%;
  }

  .mm-overlay--video {
    padding: 40px 0;
  }

  .mm-overlay--pdf {
    padding: 48px 0 0;
  }

  .mm-overlay--pdf .mm-panel {
    border-left: none;
    border-right: none;
    max-width: 100%;
  }

  .mm-overlay--card .mm-panel {
    margin: 0 16px;
    padding: 28px 20px 24px;
  }

  .mm-card-title {
    font-size: 17px;
  }
}
