/* SDG "PDF Embed" viewer (static/js/sdg_pdf_viewer.js) */

.sdg-pdf {
  --pdf-navy: #062969;
  --pdf-ink: #1f2a44;
  --pdf-muted: #6b7a99;
  --pdf-line: #d9e1ee;
  --pdf-tint: #eef3fb;
  --pdf-stage: #e9edf4;
  overflow: hidden;
  border: 1px solid var(--pdf-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(6, 41, 105, 0.08);
  font-family: 'Poppins', sans-serif;
  line-height: 1.4;
  text-align: left;
  /* Lets the toolbar compact itself by the viewer's width, not the screen's */
  container-type: inline-size;
  container-name: sdg-pdf;
}

.sdg-pdf__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--pdf-line);
  background: #fff;
}

.sdg-pdf__name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1 1 220px;
}

.sdg-pdf__badge {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 6px;
  background: var(--pdf-navy);
  color: #fff;
  font-size: 0.95rem;
}

.sdg-pdf__title {
  overflow: hidden;
  color: var(--pdf-navy);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sdg-pdf__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.sdg-pdf__group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--pdf-line);
  border-radius: 8px;
  background: #f7f9fc;
}

.sdg-pdf__btn,
.sdg-pdf__zoom {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.4rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--pdf-navy);
  font: inherit;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sdg-pdf__btn:hover:not(:disabled),
.sdg-pdf__zoom:hover:not(:disabled) {
  background: var(--pdf-navy);
  color: #fff;
}

.sdg-pdf__btn:focus-visible,
.sdg-pdf__zoom:focus-visible,
.sdg-pdf__stage:focus-visible {
  outline: 3px solid rgba(6, 41, 105, 0.25);
  outline-offset: 1px;
}

.sdg-pdf__btn:disabled,
.sdg-pdf__zoom:disabled {
  opacity: 0.35;
  cursor: default;
}

.sdg-pdf__zoom {
  min-width: 52px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sdg-pdf__page {
  min-width: 92px;
  padding: 0 0.35rem;
  color: var(--pdf-ink);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sdg-pdf__stage {
  position: relative;
  min-height: 320px;
  max-height: 82vh;
  padding: 1rem;
  overflow: auto;
  background: var(--pdf-stage);
  outline: none;
}

.sdg-pdf__sheet {
  display: flex;
  width: max-content;
  min-width: 100%;
  justify-content: center;
}

.sdg-pdf__canvas {
  display: block;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 6px rgba(6, 41, 105, 0.12), 0 12px 32px rgba(6, 41, 105, 0.12);
}

.sdg-pdf__status {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem;
  background: var(--pdf-stage);
  color: var(--pdf-muted);
  font-size: 0.9rem;
  text-align: center;
}

.sdg-pdf.is-loading .sdg-pdf__status,
.sdg-pdf.has-error .sdg-pdf__status {
  display: flex;
}

.sdg-pdf.has-error .sdg-pdf__status > i {
  color: #c5192d;
  font-size: 1.5rem;
}

.sdg-pdf__fallback {
  padding: 0.45rem 1rem;
  border-radius: 8px;
  background: var(--pdf-navy);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.sdg-pdf__fallback:hover {
  background: #041d4a;
  color: #fff;
}

.sdg-pdf__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(6, 41, 105, 0.15);
  border-top-color: var(--pdf-navy);
  border-radius: 50%;
  animation: sdg-pdf-spin 0.8s linear infinite;
}

@keyframes sdg-pdf-spin {
  to { transform: rotate(360deg); }
}

/* Full screen on the current page (native Fullscreen API or overlay fallback) */
.sdg-pdf.is-fullscreen {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  float: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.sdg-pdf.is-overlay-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
}

.sdg-pdf.is-fullscreen .sdg-pdf__bar {
  flex: none;
  padding-top: max(0.6rem, env(safe-area-inset-top));
}

.sdg-pdf.is-fullscreen .sdg-pdf__stage {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.sdg-pdf.is-fullscreen .sdg-pdf__full {
  background: var(--pdf-navy);
  color: #fff;
}

.sdg-pdf::backdrop {
  background: var(--pdf-stage, #e9edf4);
}

html.sdg-pdf-lock,
html.sdg-pdf-lock body {
  overflow: hidden;
}

.sdg-pdf__short {
  display: none;
}

@media (max-width: 576px) {
  .sdg-pdf__bar {
    padding: 0.5rem;
  }

  .sdg-pdf__tools {
    width: 100%;
    justify-content: space-between;
  }

  /* Phones pinch-zoom; keep the toolbar on one row */
  .sdg-pdf__zoom-group,
  .sdg-pdf__long {
    display: none;
  }

  .sdg-pdf__short {
    display: inline;
  }

  .sdg-pdf__page {
    min-width: 56px;
  }

  .sdg-pdf__stage {
    padding: 0.6rem;
  }
}

/* Narrow viewer (after the phone rules so it wins): title on its own row,
   page + actions below, zoom left to full screen */
@container sdg-pdf (max-width: 460px) {
  .sdg-pdf__bar {
    gap: 0.45rem;
    padding: 0.5rem;
  }

  .sdg-pdf__name {
    flex-basis: 100%;
    gap: 0.5rem;
  }

  .sdg-pdf__badge {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .sdg-pdf__title {
    font-size: 0.85rem;
  }

  .sdg-pdf__tools {
    width: 100%;
    justify-content: space-between;
    gap: 0.35rem;
  }

  .sdg-pdf__zoom-group,
  .sdg-pdf__long {
    display: none;
  }

  .sdg-pdf__short {
    display: inline;
  }

  .sdg-pdf__btn {
    min-width: 28px;
    height: 30px;
    padding: 0 0.3rem;
  }

  .sdg-pdf__page {
    min-width: 48px;
    padding: 0 0.2rem;
  }

  .sdg-pdf__stage {
    min-height: 260px;
    padding: 0.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sdg-pdf__spinner {
    animation-duration: 2.4s;
  }
}
