/* =========================================================
   CV POPUP (.cv-popup)
   Centered panel with the CV (PDF in an iframe) and its actions.
   Same visual language as the drawers (experience-drawer.css,
   info-drawer.css); bottom sheet on narrow screens.
   The close button reuses .dialog-close (popup.css) and
   the actions reuse .link-btn (info-drawer.css).
========================================================= */

.cv-popup {
  /* reset dialog defaults (UA) */
  position: fixed;
  inset: 0;
  width: min(56rem, 92vw);
  height: min(90dvh, 60rem);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-color);
  border-radius: 1.25rem 0.75rem 1.25rem 0.75rem;
  overflow: hidden;

  color: var(--accent-color);
  font-family: var(--font-body);
  line-height: var(--lh-base);

  /* glass, same as the drawers */
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.1);

  &[open] {
    display: flex;
    flex-direction: column;
  }

  &::backdrop {
    background: var(--overlay-color);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
}

.dark .cv-popup {
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.35);
}

/* scoped: popup.css (.dialog-close) loads after this sheet */
.cv-popup .cv-popup__close {
  top: 1rem;
  right: 1rem;
  i {
    font-size: 1.5rem;
  }
}

.cv-popup__header {
  /* room for the close button, so the title never runs under it */
  padding: 1.25rem 4.5rem 1rem clamp(1.25rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line-color);

  h2 {
    margin: 0 0 0.25rem;
    font-size: var(--fs-3);
  }

  p {
    margin: 0;
    font-size: var(--fs-7);
    color: var(--text-muted);
    text-wrap: pretty;
  }
}

/* the iframe fills the space left between header and footer */
.cv-popup__body {
  flex: 1;
  min-height: 0;
  padding: 1rem clamp(1rem, 2.5vw, 1.5rem);

  iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 1px solid var(--line-color);
    border-radius: 0.75rem 0.5rem 0.75rem 0.5rem;
    /* visible frame while the PDF loads */
    background: var(--surface-light-color);
  }
}

.cv-popup__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem clamp(1.25rem, 3vw, 2rem);
  border-top: 1px solid var(--line-color);
}

/* "Abrir" is only needed on touch devices, where the iframe can't show the PDF;
   with a mouse the PDF viewer already offers open, print and download */
@media (hover: hover) and (pointer: fine) {
  /* footer scope: beats .link-btn's display (loaded later) */
  .cv-popup__footer .cv-popup__open {
    display: none;
  }
}

/* ---------- Narrow screens: bottom sheet ---------- */
@media (max-width: 600px) {
  .cv-popup {
    inset: auto 0 0 0;
    width: 100%;
    height: 92dvh;
    margin: 0;
    border: 0;
    border-top: 1px solid var(--line-color);
    border-radius: 1.25rem 1.25rem 0 0;
    box-shadow: 0 -1rem 3rem rgba(0, 0, 0, 0.12);
  }
  .cv-popup__footer {
    justify-content: stretch;
    > * {
      flex: 1;
      justify-content: center;
    }
  }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .cv-popup[open] {
    animation: cv-popup-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @media (max-width: 600px) {
    .cv-popup[open] {
      animation-name: cv-popup-up;
    }
  }
}

@keyframes cv-popup-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

@keyframes cv-popup-up {
  from {
    opacity: 0;
    transform: translateY(2rem);
  }
}
