/* The preview shares the capture-results layout instead of covering the page. */
.capture-results {
  --capture-preview-panel-width: clamp(580px, 46vw, 680px);
}

.capture-results.capture-preview-open {
  position: relative;
  box-sizing: border-box;
  padding-right: calc(var(--capture-preview-panel-width) + 12px);
  transition: padding-right 180ms cubic-bezier(.16, 1, .3, 1);
}

.capture-preview-drawer {
  position: absolute;
  inset: 0 0 auto auto;
  z-index: 20;
  width: var(--capture-preview-panel-width);
  height: 100%;
  max-height: none;
  border-right: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: -8px 0 24px color-mix(in srgb, var(--shadow-color) 68%, transparent);
}

.capture-preview-drawer > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  line-height: 1.5;
}

.capture-preview-drawer > header h3 {
  margin: 0;
}

/* The surrounding preview table row has line-height: 0. Keep status text in a real line box. */
.capture-preview-drawer > header .capture-preview-generation-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}

/* Hide the task facts in the preview so its template follows the header. */
.capture-preview-drawer .capture-preview-facts {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px 14px;
  margin: 0;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  line-height: 1.4;
}

.capture-preview-drawer .capture-preview-facts dt {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.capture-preview-drawer .capture-preview-facts dd {
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capture-preview-heading {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.capture-preview-title-line {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

.capture-preview-drawer .capture-preview-collapse {
  display: grid;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  place-items: center;
  border-radius: 5px;
}

.capture-preview-drawer .capture-preview-collapse svg {
  width: 16px;
  height: 16px;
}

.capture-preview-drawer .capture-preview-collapse:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.capture-preview-drawer .capture-preview-section-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
}

.capture-preview-drawer .capture-preview-section-heading span {
  min-width: 0;
}

.capture-preview-drawer .capture-preview-template-toggle {
  display: grid;
  width: 28px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  place-items: center;
  justify-self: end;
}

.capture-preview-drawer .capture-preview-template-toggle svg {
  width: 15px;
  height: 15px;
  transition: transform 160ms ease;
}

.capture-preview-drawer .capture-preview-template-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.capture-preview-drawer .capture-preview-template-toggle:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.capture-preview-drawer .capture-preview-template-content.is-expanded {
  display: block;
  max-height: 132px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.capture-preview-drawer .capture-preview-images {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-width: 0;
  gap: 7px;
}

.capture-preview-drawer .capture-preview-images > a {
  display: block;
  min-width: 0;
  overflow: hidden;
  border-radius: 7px;
}

.capture-preview-drawer .capture-preview-images img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
}

@media (max-width: 1200px) {
  .capture-results.capture-preview-open {
    padding-right: 0;
  }

  .capture-preview-drawer-row,
  .capture-preview-drawer-row > td {
    height: auto !important;
    line-height: normal;
  }

  .capture-preview-drawer {
    position: static;
    width: 100%;
    height: auto;
    max-height: 480px;
    border-right: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .capture-results.capture-preview-open {
    transition-duration: .01ms;
  }

  .capture-preview-drawer .capture-preview-template-toggle svg {
    transition-duration: .01ms;
  }
}
