/* Documents (kit) — `DocThumb` + `DocViewer` (`ui/doc_viewer.rs`). */

/* ── DocThumb ─────────────────────────────────────────────────────────────── */

.doc-thumb {
  display: flex;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* Clipped page / image (can't break the layout around it). */
.doc-thumb__frame {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: calc(var(--u) * 28);
  height: calc(var(--u) * 34);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: #fff;
}

.doc-thumb:hover .doc-thumb__frame,
.doc-thumb:focus-visible .doc-thumb__frame {
  border-color: var(--accent);
}

.doc-thumb__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  pointer-events: none;
}

.doc-thumb__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-muted);
}

/* Compact tile: smaller thumb, name underneath. */
.doc-thumb--tile {
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  width: calc(var(--u) * 22);
}

.doc-thumb--tile .doc-thumb__frame {
  width: calc(var(--u) * 22);
  height: calc(var(--u) * 28);
}

.doc-thumb__name {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--ui-text-caption);
  line-height: var(--ui-leading-caption);
  color: var(--text-muted);
  text-align: center;
}

/* A wrapping row of tiles. */
.doc-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── DocViewer — windowed, expandable to a full-viewport overlay ──────────── */

.doc-viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: color-mix(in srgb, var(--bg) 60%, black 40%);
}

.doc-viewer:focus {
  outline: none;
}

.doc-viewer {
  display: flex;
  flex-direction: column;
  width: min(920px, 92vw);
  height: min(86vh, 1100px);
  background: var(--bg);
  border: 1px solid var(--border-outer);
  border-radius: var(--radius);
  box-shadow: 0 10px 48px rgb(0 0 0 / 0.35);
  overflow: hidden;
}

.doc-viewer--full {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border: none;
  border-radius: 0;
}

.doc-viewer__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

.doc-viewer__title {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-viewer__bar-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.doc-viewer__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--space-4);
  background: var(--bg-inset);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.doc-viewer__body:has(> .doc-viewer__pdf) {
  padding: 0;
}

.doc-viewer__pdf {
  flex: 1 1 auto;
  width: 100%;
  min-height: calc(var(--u) * 120);
  border: none;
  background: #fff;
}

.doc-viewer__img {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
}
