/* Keep the PDF viewer inside the current page. Native dialogs stay hidden until opened. */
.document-viewer-dialog {
  box-sizing: border-box;
  width: 1100px;
  max-width: min(1100px, calc(100vw - 2rem));
  height: 90dvh;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--global-divider-color);
  border-radius: 1rem;
  background: var(--global-bg-color);
  color: var(--global-text-color);
}

.document-viewer-dialog[open] {
  display: flex;
  flex-direction: column;
}

.document-viewer-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.document-viewer-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--global-divider-color);
}

.document-viewer-heading {
  flex: 1;
  min-width: 0;
}

.document-viewer-label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--global-theme-color);
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.document-viewer-header h2 {
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.document-viewer-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.75rem;
}

.document-viewer-external {
  color: var(--global-text-color-light);
  font-size: 0.8rem;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.document-viewer-external:hover {
  color: var(--global-theme-color);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.document-viewer-close {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--global-divider-color);
  color: var(--global-text-color);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.document-viewer-close:hover {
  background: var(--global-divider-color);
  color: var(--global-theme-color);
}

.document-viewer-close:focus-visible,
.document-viewer-external:focus-visible {
  outline: 2px solid var(--global-theme-color);
  outline-offset: 2px;
}

.document-viewer-frame {
  display: block;
  flex: 1;
  width: 100%;
  height: auto;
  min-height: 0;
  border: 0;
  background: white;
}

body.document-viewer-open {
  overflow: hidden;
}

@media (max-width: 650px) {
  .document-viewer-dialog {
    width: calc(100vw - 1rem);
    max-width: calc(100vw - 1rem);
    height: calc(100dvh - 1rem);
    max-height: calc(100dvh - 1rem);
    border-radius: 0.75rem;
  }

  .document-viewer-header {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
  }

  .document-viewer-heading {
    flex-basis: 12rem;
  }

  .document-viewer-actions {
    margin-left: auto;
  }
}
