/**
 * Report document layout, header, tabs, outline, and print styles.
 */

.report-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
}

.report-header {
  padding: var(--space-8);
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  flex-shrink: 0;
}

.report-title-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.report-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.report-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: var(--space-2) 0 0 0;
  line-height: 1.6;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
  min-width: 0;
}

.meta-kind,
.meta-owner,
.meta-period {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  text-nowrap: wrap;
  word-break: break-word;
}

.meta-status {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-transform: uppercase;
  font-size: var(--text-xs);
}

.meta-status--draft {
  background: var(--surface-2);
  color: var(--text-secondary);
}

.meta-status--in-review {
  background: rgba(168, 85, 247, 0.2);
  color: rgb(168, 85, 247);
}

.meta-status--shipped {
  background: rgba(34, 197, 94, 0.2);
  color: rgb(34, 197, 94);
}

.meta-status--blocked {
  background: rgba(239, 68, 68, 0.2);
  color: rgb(239, 68, 68);
}

.meta-status--rolled-back {
  background: rgba(239, 68, 68, 0.2);
  color: rgb(239, 68, 68);
}

.meta-source {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.meta-source:hover {
  text-decoration: underline;
}

.report-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0 var(--space-6);
  overflow-x: auto;
  flex-shrink: 0;
}

.report-tab {
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  font-weight: 500;
  font-size: var(--text-sm);
  transition: color var(--dur), border-color var(--dur);
  white-space: nowrap;
}

.report-tab:hover {
  color: var(--text-primary);
}

.report-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.report-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/*
 * Blocks flow full width. The page was a two column grid with an outline in
 * the first column, which left every block in a 290px gutter: a chart with
 * four bars, a sixty row table and a side by side diff all squeezed into a
 * quarter of a 1600px window.
 *
 * The rail already carries the outline while someone is editing, so the one
 * inside the page is redundant there. In read mode the rail is gone, so the
 * page takes the outline back. One outline on screen, either way.
 *
 * `width: half` on a block is honoured only inside a `grid` block, which is
 * what the registry says it means.
 */
.report-page {
  display: block;
  padding: var(--space-8);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.report-outline { display: none; }

html[data-dossier-mode="read"] .report-page {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: var(--space-6);
}

html[data-dossier-mode="read"] .report-outline { display: block; }

.report-outline {
  position: sticky;
  top: 76px;
  height: fit-content;
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
}

.outline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
}

.outline-item {
  margin: 0;
}

.outline-item a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--dur), border-color var(--dur);
}

.outline-item a:hover {
  color: var(--text-primary);
  border-left-color: var(--accent);
}

.outline-level-3 a {
  padding-left: var(--space-5);
}

.report-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

@media (max-width: 1024px) {
  .report-page {
    grid-template-columns: 1fr;
  }
  .report-outline {
    display: none;
  }
}

@media (max-width: 768px) {
  .report-header {
    padding: var(--space-4);
  }
  .report-title-row {
    flex-direction: column;
    gap: var(--space-4);
  }
  .report-page {
    padding: var(--space-4);
    gap: var(--space-4);
  }
  .report-tabs {
    padding: 0 var(--space-4);
  }
  .report-tab {
    padding: var(--space-2) var(--space-3);
  }
}

/* Print styles */
@media print {
  .report-shell {
    min-height: auto;
  }
  .report-header {
    border: none;
  }
  .report-tabs {
    display: none;
  }
  .report-outline {
    display: none;
  }
  .report-page {
    display: block;
    page-break-after: always;
    break-after: page;
    padding: 0;
    max-width: 100%;
  }
  .report-page:last-child {
    page-break-after: avoid;
    break-after: avoid;
  }
  .report-blocks {
    gap: var(--space-6);
  }
  .block {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .block--collapsed {
    display: none;
  }
  code {
    word-break: break-word;
    white-space: pre-wrap;
  }
  pre {
    background-color: var(--surface-1) !important;
    print-color-adjust: exact;
  }
  .table-wrapper {
    overflow: visible;
  }
}
