/**
 * pdb-viewer — full-screen modal 3D viewer.
 *
 * One viewer is open at a time. The overlay covers the viewport at
 * z above the page-level rail/header (z-index sits above the shell's
 * modal layer). The panel is centered with safe-area-aware margins so
 * it works on notched mobile too.
 */

.pdb-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(var(--s-space-4), env(safe-area-inset-top))
           max(var(--s-space-4), env(safe-area-inset-right))
           max(var(--s-space-4), env(safe-area-inset-bottom))
           max(var(--s-space-4), env(safe-area-inset-left));
}

.pdb-viewer-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in oklch, var(--s-color-bg-app) 60%, transparent);
  backdrop-filter: blur(6px);
}

.pdb-viewer-overlay__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(96vw, 1280px);
  height: min(92vh, 880px);
  background: var(--s-color-bg-surface);
  border: 1px solid var(--s-color-border-subtle);
  border-radius: var(--s-radius-2);
  box-shadow: none;
  overflow: hidden;
}

.pdb-viewer-overlay__header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-space-3);
  padding: var(--s-space-3) var(--s-space-4);
  border-bottom: 1px solid var(--s-color-border-subtle);
  background: var(--s-color-bg-app);
}

.pdb-viewer-overlay__id-block {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-space-2);
  min-width: 0;
}

.pdb-viewer-overlay__id {
  font-family: var(--s-font-mono);
  font-size: var(--s-font-size-2);
  font-weight: var(--s-font-weight-semibold);
  letter-spacing: 0.04em;
  color: var(--s-color-fg-primary);
  padding: 2px 8px;
  background: color-mix(in oklch, var(--s-color-fg-primary) 8%, transparent);
  border-radius: var(--s-radius-1);
}

.pdb-viewer-overlay__label {
  font-family: var(--s-font-sans);
  font-size: var(--s-font-size-1);
  color: var(--s-color-fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdb-viewer-overlay__subtitle {
  font-family: var(--s-font-sans);
  font-size: var(--s-font-size-1);
  color: var(--s-color-fg-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdb-viewer-overlay__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--s-radius-1);
  color: var(--s-color-fg-secondary);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.pdb-viewer-overlay__close:hover,
.pdb-viewer-overlay__close:focus-visible {
  background: var(--s-color-bg-subtle);
  border-color: var(--s-color-border-subtle);
  color: var(--s-color-fg-primary);
  outline: none;
}

.pdb-viewer-overlay__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--s-color-bg-surface);
}

.pdb-viewer-overlay__stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pdb-viewer-overlay__footer {
  padding: var(--s-space-2) var(--s-space-4);
  font-family: var(--s-font-mono);
  font-size: var(--s-font-size-0);
  color: var(--s-color-fg-muted);
  border-top: 1px solid var(--s-color-border-subtle);
  background: var(--s-color-bg-app);
  letter-spacing: 0.02em;
}

.pdb-viewer-overlay__error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-space-4);
  font-family: var(--s-font-mono);
  font-size: var(--s-font-size-1);
  color: var(--s-color-fg-muted);
  text-align: center;
}
