/* Amergent Partners — PDF viewer: the full-screen document dialog shared by the pages that list
   documents (Información corporativa, Publicaciones). Markup: partials/pdf-viewer.html.
   Behaviour: js/pdf-viewer.js. Loaded after site.css. */

/* Full screen at every size. Phones: the title gets two lines and the two actions share a second
   row; the details become a strip above the document. From md the bar is one row; from lg the
   details sit in a side column (the original layout). Safe areas pad the edges. */
.pdfv {
  position: fixed; inset: 0; z-index: 30;
  display: grid; grid-template-rows: auto minmax(0,1fr);
  background: color-mix(in srgb, black 35%, var(--color-text)); color: var(--color-bg);
  font-family: var(--font-body);
  animation: pdfv-fade 280ms ease both;
}
.pdfv[hidden] { display: none; }
@keyframes pdfv-fade { from { opacity: 0; } to { opacity: 1; } }

.pdfv__bar {
  position: relative; display: grid; grid-template-columns: minmax(0,1fr); align-items: center; gap: 8px;
  padding: calc(6px + var(--safe-top)) max(12px, env(safe-area-inset-right, 0px)) 12px max(4px, env(safe-area-inset-left, 0px));
  background: var(--color-text); border-bottom: 1px solid var(--color-neutral-800);
}
.pdfv__id { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pdfv__close {
  display: flex; align-items: center; justify-content: center; flex: none; width: 48px; height: 48px; padding: 0;
  border: 0; background: transparent; color: var(--color-bg); cursor: pointer;
}
.pdfv__sep { flex: none; width: 1px; height: 32px; background: var(--color-neutral-800); }
.pdfv__names { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pdfv__cat { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-neutral-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdfv__title {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  font-size: 16px; line-height: 1.25; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis;
}

.pdfv__actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; padding-left: 8px; }
.pdfv__tab,
.pdfv__dl {
  display: flex; align-items: center; justify-content: space-between; height: 44px;
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.pdfv__tab { gap: 12px; padding: 0 14px; border: 1px solid var(--color-neutral-700); color: var(--color-bg); }
.pdfv__dl { gap: 24px; padding: 0 16px; background: var(--color-bg); color: var(--color-text); }
.pdfv__dl svg { flex: none; }

.pdfv__main { display: grid; grid-template-rows: auto minmax(0,1fr); min-height: 0; }
.pdfv__aside { display: flex; flex-direction: column; min-height: 0; background: var(--color-text); border-bottom: 1px solid var(--color-neutral-800); }
.pdfv__meta {
  display: grid; grid-template-columns: auto minmax(0,1fr); align-items: baseline; gap: 4px 16px; margin: 0;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  font-size: var(--fs-13);
}
.pdfv__meta dt { color: var(--color-neutral-500); }
.pdfv__meta dd { margin: 0; }

.pdfv__stage { position: relative; min-width: 0; min-height: 0; margin-bottom: env(safe-area-inset-bottom, 0px); }
.pdfv__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; }

.pdfv__loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 20px;
  padding-top: 32px; pointer-events: none;
}
.pdfv__loading[hidden] { display: none; }
.pdfv__skel {
  width: min(720px, calc(100% - 2 * var(--gutter))); aspect-ratio: 8.5 / 11;
  background: color-mix(in srgb, var(--color-bg) 8%, transparent);
  animation: pdfv-pulse 1600ms ease-in-out infinite;
}
@keyframes pdfv-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.pdfv__chip { position: absolute; top: 56px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--color-text); font-size: 13px; }

.pdfv__error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: var(--gutter); overflow-y: auto; }
.pdfv__error[hidden] { display: none; }
.pdfv__card {
  display: flex; flex-direction: column; gap: 16px; max-width: 420px; padding: 24px;
  border: 1px solid var(--color-neutral-700); background: var(--color-text);
}
.pdfv__card-t { font-size: clamp(19px, 0.282vw + 17.94px, 22px); letter-spacing: -0.01em; }
.pdfv__card-d { font-size: var(--fs-14); line-height: 1.55; color: var(--color-neutral-400); }
.pdfv__card-a {
  align-self: flex-start; display: flex; align-items: center; gap: 20px; height: 44px; padding: 0 16px;
  background: var(--color-bg); color: var(--color-text); font-size: 13px; font-weight: 600; text-decoration: none;
}

@media (min-width: 768px) {
  .pdfv__bar {
    grid-template-columns: minmax(0,1fr) auto; gap: 24px; height: calc(72px + var(--safe-top));
    padding: var(--safe-top) max(20px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  }
  .pdfv__id { gap: 16px; }
  .pdfv__cat { overflow: visible; }
  .pdfv__title { display: block; -webkit-line-clamp: none; line-clamp: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pdfv__actions { display: flex; justify-content: flex-end; align-items: center; padding-left: 0; }
  .pdfv__error { padding: 48px; }
  .pdfv__card { padding: 32px; }
}

@media (min-width: 1024px) {
  .pdfv__main { grid-template-columns: 240px minmax(0,1fr); grid-template-rows: none; }
  .pdfv__aside { border-bottom: 0; border-right: 1px solid var(--color-neutral-800); }
  .pdfv__meta { align-items: normal; gap: 10px 16px; padding: 20px; border-bottom: 1px solid var(--color-neutral-800); }
  .pdfv__meta dd { text-align: right; }
}

@media (hover: hover) {
  .pdfv__close:hover { background: color-mix(in srgb, var(--color-bg) 12%, transparent); }
  .pdfv__tab:hover { border-color: var(--color-bg); color: var(--color-bg); }
  .pdfv__dl:hover { background: var(--color-neutral-300); color: var(--color-text); }
  .pdfv__card-a:hover { background: var(--color-neutral-300); color: var(--color-text); }
}

/* ── Reduced motion ─────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .pdfv, .pdfv__skel { animation: none; }
}
