/* ============================================================================
   Acquired Documents Ledger — Dedicated Stylesheet
   Governs the public filings provenance ledger (/documents).
   All tokens are consumed from tokens.css.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. Filter & Controls Toolbar
   --------------------------------------------------------------------------- */

.controls {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.control-row {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(130px, 1fr);
  gap: var(--space-4);
  align-items: end;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.control-label {
  font-family: var(--font-mono);
  font-size: var(--size-3xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-muted);
}

.control-input {
  height: 2.375rem;
  padding: 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--size-sm);
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  transition: border-color var(--motion-fast) var(--ease-standard),
              box-shadow var(--motion-fast) var(--ease-standard);
  width: 100%;
}

.control-input:hover {
  border-color: var(--text-muted);
}

.control-input:focus-visible {
  border-color: var(--border-focus);
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------------------
   2. Section Heading
   --------------------------------------------------------------------------- */

.ledger-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-heading {
  font-family: var(--font-sans);
  font-size: var(--size-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

/* ---------------------------------------------------------------------------
   3. Table Wrapper & Data Table
   --------------------------------------------------------------------------- */

.table-wrapper {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  max-width: 100%;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--size-xs);
  line-height: var(--leading-normal);
  text-align: left;
}

/* Table Head */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--size-3xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
}

/* Alignment rules for headers */
.data-table th.th-numeric {
  text-align: right;
}

.data-table th.th-action {
  text-align: right;
}

/* Table Body Cells */
.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background-color var(--motion-fast) var(--ease-standard);
}

.data-table tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.015);
}

.data-table tbody tr:hover {
  background-color: var(--bg-selected);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---------------------------------------------------------------------------
   4. Cell Specific Styling & Alignment
   --------------------------------------------------------------------------- */

/* Column 1: Source Tag */
.cell-source {
  width: 140px;
}

.source-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--size-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  color: var(--text-secondary);
  background-color: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 0.125rem var(--space-2);
  line-height: var(--leading-none);
}

/* Column 2: Identifier (Accession) */
.cell-identifier {
  font-family: var(--font-mono);
  font-size: var(--size-xs);
  color: var(--text-primary);
}

.cell-identifier code {
  font-family: var(--font-mono);
  font-size: var(--size-xs);
  color: var(--text-highlight);
  background-color: transparent;
  padding: 0;
  letter-spacing: -0.01em;
}

/* Column 3 & 4: Date & Timestamp */
.cell-date,
.cell-timestamp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--size-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Column 5: Numeric (Content Length) - Precision Right Alignment */
.cell-numeric {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  white-space: nowrap;
}

/* Column 6: Digest */
.cell-digest {
  font-family: var(--font-mono);
}

.cell-digest code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--size-2xs);
  color: var(--text-muted);
  background-color: var(--bg-soft);
  padding: 0.125rem var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  letter-spacing: -0.02em;
}

/* Column 7: Action Link */
.cell-action {
  text-align: right;
  width: 100px;
}

.doc-source-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-sans);
  font-size: var(--size-2xs);
  font-weight: var(--weight-medium);
  color: var(--primary);
  text-decoration: none;
  padding: 0.25rem var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-ground);
  transition: all var(--motion-fast) var(--ease-standard);
  white-space: nowrap;
}

.doc-source-link:hover {
  background-color: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
}

.doc-source-link:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Explicitly Absent Cell */
.cell-absent {
  font-family: var(--font-sans);
  font-size: var(--size-2xs);
  font-style: italic;
  color: var(--text-muted);
  border-bottom: 1px dotted var(--border-medium);
  cursor: help;
}

/* ---------------------------------------------------------------------------
   5. State Notices (Loading, Empty, Error)
   --------------------------------------------------------------------------- */

.state-notice {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--size-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.state-notice strong {
  display: block;
  font-size: var(--size-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.state-notice-error {
  background-color: rgba(var(--error-rgb), 0.05);
  border-color: var(--error);
  color: var(--error);
}

/* ---------------------------------------------------------------------------
   6. Pagination Bar
   --------------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: var(--space-4);
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
}

.pagination-label {
  font-family: var(--font-mono);
  font-size: var(--size-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--size-xs);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--motion-fast) var(--ease-standard);
  min-width: 5rem;
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  border-color: var(--text-secondary);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.btn-secondary:disabled {
  background-color: var(--disabled-bg);
  color: var(--disabled-fg);
  border-color: var(--disabled-border);
  cursor: not-allowed;
  opacity: 0.6;
}

/* ---------------------------------------------------------------------------
   7. Provenance Verification Guide Panel
   --------------------------------------------------------------------------- */

.provenance-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin-top: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.provenance-panel .section-heading {
  margin-bottom: var(--space-4);
}

.provenance-steps {
  list-style: none;
  counter-reset: step-counter;
  padding: 0;
  margin: 0 0 var(--space-5) 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.provenance-steps li {
  counter-increment: step-counter;
  position: relative;
  background-color: var(--bg-ground);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  font-size: var(--size-xs);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.provenance-steps li::before {
  content: counter(step-counter);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-circle);
  background-color: var(--primary);
  color: var(--text-on-primary);
  font-family: var(--font-mono);
  font-size: var(--size-2xs);
  font-weight: var(--weight-bold);
  line-height: var(--leading-none);
}

.provenance-steps strong {
  color: var(--text-primary);
}

.provenance-note {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-subtle);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--size-xs);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.provenance-note code {
  font-family: var(--font-mono);
  font-size: var(--size-3xs);
  color: var(--text-primary);
  background-color: var(--bg-ground);
  padding: 0.125rem var(--space-1);
  border-radius: var(--radius-xs);
}

/* ---------------------------------------------------------------------------
   8. Responsive Adaptations
   --------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .control-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 580px) {
  .control-row {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-direction: column;
    text-align: center;
    gap: var(--space-3);
  }

  .provenance-steps {
    grid-template-columns: 1fr;
  }
}
