/* =========================================================
   PURSUE FILE REGISTER — design tokens
   Theme: matte black / glossy black industrial — brass + brushed chrome
   ========================================================= */

:root, [data-theme='light'] {
  /* brushed aluminum */
  --color-bg: #e6e6e8;
  --color-surface: #f1f1f2;
  --color-surface-2: #f8f8f9;
  --color-surface-offset: #dadadd;
  --color-surface-offset-2: #cbcbce;
  --color-divider: #c3c3c7;
  --color-border: #aeaeb3;

  --color-text: #17171a;
  --color-text-muted: #52525a;
  --color-text-faint: #86868d;
  --color-text-inverse: #f8f8f9;

  --color-primary: #8a6a24;
  --color-primary-hover: #6f5419;
  --color-primary-active: #574210;
  --color-primary-highlight: #e4d3a3;

  --color-accent: #a13d1f;
  --color-accent-highlight: #e8cec0;

  --color-green: #3f6b56;
  --color-green-highlight: #cfe0d8;
  --color-blue: #3f6b7a;
  --color-blue-highlight: #cfe0e6;
  --color-purple: #5a4f6e;
  --color-purple-highlight: #d9d3e2;

  --radius-sm: 0.3rem;
  --radius-md: 0.45rem;
  --radius-lg: 0.7rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 22, 0.1);
  --shadow-md: 0 6px 18px rgba(20, 20, 22, 0.12);

  --font-display: 'JetBrains Mono', 'Courier New', monospace;
  --font-body: 'General Sans', 'Inter', -apple-system, sans-serif;
}

[data-theme='dark'] {
  /* matte black / glossy black */
  --color-bg: #0a0a0b;
  --color-surface: #141416;
  --color-surface-2: #1b1b1e;
  --color-surface-offset: #202024;
  --color-surface-offset-2: #28282c;
  --color-divider: #2f2f34;
  --color-border: #3d3d43;

  --color-text: #ececee;
  --color-text-muted: #9b9ba1;
  --color-text-faint: #63636a;
  --color-text-inverse: #0a0a0b;

  --color-primary: #c9a24f;
  --color-primary-hover: #dab568;
  --color-primary-active: #e8c982;
  --color-primary-highlight: #3a2f18;

  --color-accent: #e0714a;
  --color-accent-highlight: #3a2018;

  --color-green: #8fc7ab;
  --color-green-highlight: #1c2b24;
  --color-blue: #8fb9c7;
  --color-blue-highlight: #1c2b30;
  --color-purple: #a9a0c2;
  --color-purple-highlight: #26232e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.55);
}

:root {
  --text-xs: clamp(0.7rem, 0.67rem + 0.15vw, 0.8rem);
  --text-sm: clamp(0.8rem, 0.77rem + 0.2vw, 0.9rem);
  --text-base: clamp(0.92rem, 0.88rem + 0.2vw, 1rem);
  --text-lg: clamp(1.05rem, 0.95rem + 0.5vw, 1.35rem);
  --text-xl: clamp(1.4rem, 1.1rem + 1.2vw, 2.1rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --transition-interactive: 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  line-height: 1.55;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-interactive), color var(--transition-interactive);
  position: relative;
}

img, svg { display: block; max-width: 100%; }

a { color: var(--color-primary); text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--color-primary) 40%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--color-primary-hover); }

button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }

::selection { background: color-mix(in oklab, var(--color-primary) 30%, transparent); }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* subtle scanline overlay for the "monitor readout" feel */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.012) 0px,
    rgba(255, 255, 255, 0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.5;
}
[data-theme='light'] .scanlines { display: none; }

/* =========================================================
   HEADER
   ========================================================= */

.site-header {
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in oklab, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-mark { color: var(--color-primary); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
}
.brand-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: var(--transition-interactive);
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* =========================================================
   MAIN LAYOUT
   ========================================================= */

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
}

.intro { max-width: 860px; margin-bottom: var(--space-10); }

.stamp-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stamp {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  transform: rotate(-1.5deg);
  margin-bottom: 0;
}

.updated-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--color-bg);
  background: var(--color-accent);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: 0;
}

.updated-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-bg);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.intro h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-4);
  text-wrap: balance;
}

.intro-copy { color: var(--color-text-muted); font-size: var(--text-base); margin-bottom: var(--space-3); }
.intro-copy strong { color: var(--color-text); }
.source-note { font-size: var(--text-xs); color: var(--color-text-faint); }

/* =========================================================
   STATS
   ========================================================= */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* =========================================================
   TRENDS
   ========================================================= */

.trends {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-10);
}

.trend-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.trend-card h3 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  font-weight: 600;
}

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

.bar-row { display: grid; grid-template-columns: 148px 1fr 34px; align-items: center; gap: var(--space-2); }

.bar-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track { height: 8px; background: var(--color-surface-offset); border-radius: var(--radius-full); overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(to right, var(--color-primary), color-mix(in oklab, var(--color-primary) 60%, var(--color-accent))); border-radius: var(--radius-full); transition: width 500ms cubic-bezier(0.16,1,0.3,1); }

.bar-count { font-family: var(--font-display); font-size: var(--text-xs); color: var(--color-text); text-align: right; }

/* =========================================================
   CONTROLS
   ========================================================= */

.controls {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}

.controls-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr auto;
  gap: var(--space-4);
  align-items: end;
}

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

.field label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.field input, .field select {
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-sm);
}

.field input:focus, .field select:focus {
  border-color: var(--color-primary);
}

.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8f' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: var(--space-8); }

.action-buttons { display: flex; gap: var(--space-2); }

.btn {
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition-interactive);
  border: 1px solid transparent;
}

.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-ghost { background: transparent; border-color: var(--color-border); color: var(--color-text-muted); }
.btn-ghost:hover { border-color: var(--color-primary); color: var(--color-primary); }

.result-count {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-family: var(--font-display);
}

/* =========================================================
   TABLE
   ========================================================= */

.table-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; max-height: 74vh; }

table { border-collapse: collapse; width: 100%; min-width: 1180px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--color-surface-offset);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th.col-summary, thead th.col-source, thead th.col-title { cursor: default; }

thead th:hover:not(.col-summary):not(.col-source):not(.col-title) { color: var(--color-primary); }

.sort-arrow { display: inline-block; margin-left: var(--space-1); opacity: 0.4; font-size: 10px; }
th.sorted-asc .sort-arrow::after { content: '▲'; opacity: 1; color: var(--color-primary); }
th.sorted-desc .sort-arrow::after { content: '▼'; opacity: 1; color: var(--color-primary); }
th:not(.sorted-asc):not(.sorted-desc) .sort-arrow::after { content: '⇕'; }

tbody tr {
  border-bottom: 1px solid var(--color-divider);
  transition: background var(--transition-interactive);
}
tbody tr:hover { background: var(--color-surface-offset); }

tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  vertical-align: top;
}

td.mono { font-family: var(--font-display); font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }

td.col-title { max-width: 260px; }
td.col-title .title-text { font-weight: 600; color: var(--color-text); }
td.col-title .doc-meta { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.badge-pdf { background: var(--color-primary-highlight); color: var(--color-primary); }
.badge-video { background: var(--color-accent-highlight); color: var(--color-accent); }
.badge-image { background: var(--color-blue-highlight); color: var(--color-blue); }
.badge-audio { background: var(--color-purple-highlight); color: var(--color-purple); }

.agency-tag { font-size: var(--text-xs); color: var(--color-text-muted); }

td.col-summary { max-width: 340px; color: var(--color-text-muted); font-size: var(--text-sm); cursor: pointer; }
td.col-summary .summary-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
td.col-summary.expanded .summary-text { -webkit-line-clamp: unset; overflow: visible; }
td.col-summary .expand-hint { font-size: var(--text-xs); color: var(--color-primary); margin-top: 4px; display: inline-block; }

td.col-source a {
  font-size: var(--text-xs);
  font-family: var(--font-display);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.empty-state {
  padding: var(--space-16) var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
}
.empty-state p { margin-bottom: var(--space-4); }

/* =========================================================
   LEGEND / FOOTER
   ========================================================= */

.legend {
  margin-top: var(--space-10);
  padding: var(--space-5) var(--space-6);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--color-surface) 60%, transparent);
}
.legend h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.legend ul { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.legend li { font-size: var(--text-sm); color: var(--color-text-muted); padding-left: var(--space-4); position: relative; }
.legend li::before { content: '▸'; position: absolute; left: 0; color: var(--color-primary); }

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) var(--space-6);
}
.site-footer p {
  max-width: 1320px;
  margin: 0 auto;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.7;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .trends { grid-template-columns: 1fr; }
  .controls-row { grid-template-columns: 1fr; }
  .field-actions .action-buttons { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .header-inner { padding: var(--space-3) var(--space-4); }
  main { padding: var(--space-6) var(--space-4) var(--space-12); }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* =========================================================
   GLOSSY SHEEN — matte black / glossy black industrial finish
   (dark mode only, layered after base rules so the attribute
   selector wins the cascade)
   ========================================================= */

[data-theme='dark'] .site-header {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 45%);
}

[data-theme='dark'] .stat-card,
[data-theme='dark'] .trend-card,
[data-theme='dark'] .controls,
[data-theme='dark'] .table-section {
  background-image: linear-gradient(165deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 55%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme='dark'] thead th {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 60%);
}

[data-theme='dark'] .btn-primary {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 60%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

[data-theme='dark'] .field input,
[data-theme='dark'] .field select {
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

[data-theme='dark'] .legend {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.intro-links{display:flex;flex-wrap:wrap;gap:.6rem;margin:1rem 0 .25rem}
.intro-links .btn{display:inline-flex;align-items:center;text-decoration:none}

td.col-title a.title-link { color: var(--color-text); text-decoration: none; display: block; }
td.col-title a.title-link:hover { color: var(--color-primary); text-decoration: underline; }
td.col-title a.open-file { display: inline-block; margin-top: 8px; padding: 6px 10px; min-height: 32px; line-height: 20px; border: 1px solid var(--color-primary); border-radius: 6px; color: var(--color-primary); font-size: var(--text-xs); font-weight: 600; text-decoration: none; white-space: nowrap; }
td.col-title a.open-file:hover { background: var(--color-primary); color: var(--color-bg, #0b0b0c); }
