/**
 * Debian Reproducibility Dashboard Styles
 * Design philosophy: Edward Tufte - minimal chartjunk, high data-ink ratio
 * Typography-first, static pre-rendering, progressive enhancement
 */

/* ============================================================================
   Base & Reset
   ========================================================================= */

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

:root {
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;

  /* Colors - Minimal palette */
  --color-text: #000000;
  --color-text-muted: #666666;
  --color-bg: #ffffff;
  --color-accent: #d70a53;  /* Debian pink */
  --color-pass: #228b22;     /* Forest green */
  --color-fail: #8b0000;     /* Dark red */

  /* Spacing - 8px base grid */
  --space-xs: 0.25rem;  /* 4px */
  --space-sm: 0.5rem;   /* 8px */
  --space-md: 1rem;     /* 16px */
  --space-lg: 1.5rem;   /* 24px */
  --space-xl: 2rem;     /* 32px */
  --space-xxl: 3rem;    /* 48px */

  /* Type scale */
  --text-xs: 0.75rem;   /* 12px */
  --text-sm: 0.875rem;  /* 14px */
  --text-base: 1rem;    /* 16px */
  --text-lg: 1.125rem;  /* 18px */
  --text-xl: 1.5rem;    /* 24px */
  --text-xxl: 2rem;     /* 32px */
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-lg);
}

/* ============================================================================
   Typography
   ========================================================================= */

h1 {
  font-size: var(--text-xxl);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-xs);
}

h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--space-md);
}

p {
  margin-bottom: var(--space-md);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ============================================================================
   Layout
   ========================================================================= */

header {
  margin-bottom: var(--space-xxl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-text);
}

.subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-lg);
}

main {
  margin-bottom: var(--space-xxl);
}

section {
  margin-bottom: var(--space-xxl);
}

footer {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-text-muted);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

/* ============================================================================
   Summary Bar - Single line of key metrics
   ========================================================================= */

.summary-bar {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  padding: var(--space-md) 0;
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-text);
}

#loading {
  color: var(--color-text-muted);
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  align-items: baseline;
}

.stat {
  white-space: nowrap;
}

.stat-value {
  font-weight: 700;
}

.stat-label {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Consensus indicators */
.stat.consensus-pass .stat-value {
  color: var(--color-pass);
}

.stat.consensus-fail .stat-value {
  color: var(--color-fail);
}

/* ============================================================================
   Status Matrix - Primary data display
   ========================================================================= */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.data-exports {
  font-size: var(--text-sm);
  display: flex;
  gap: var(--space-sm);
  align-items: baseline;
  flex-wrap: wrap;
}

.export-link {
  font-family: var(--font-mono);
  font-weight: 600;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-text);
}

.export-link:hover {
  background-color: var(--color-text);
  color: var(--color-bg);
  text-decoration: none;
}

.export-note {
  color: var(--color-text-muted);
}

/* Matrix Table */
.matrix {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.matrix th,
.matrix td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border: none;
}

.matrix thead th {
  font-weight: 600;
  border-bottom: 2px solid var(--color-text);
  padding-bottom: var(--space-sm);
}

.matrix tbody th {
  font-weight: 600;
  text-align: left;
}

.matrix tbody tr {
  border-top: 1px solid var(--color-text-muted);
}

.matrix tbody tr:first-child {
  border-top: none;
}

/* Status cells */
.cell-pass {
  color: var(--color-pass);
}

.cell-fail {
  color: var(--color-fail);
}

.cell-na {
  color: var(--color-text-muted);
}

/* Cell content with inline metrics */
.cell-content {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.cell-status {
  font-weight: 600;
}

.cell-time {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* Sparkline inline SVG */
.sparkline {
  display: inline-block;
  vertical-align: middle;
  width: 40px;
  height: 16px;
}

/* Summary row */
.matrix tfoot td {
  border-top: 2px solid var(--color-text);
  padding-top: var(--space-sm);
  font-weight: 600;
}

/* ============================================================================
   Details Table - Architecture build details
   ========================================================================= */

.details-table table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.details-table th,
.details-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border: none;
}

.details-table thead th {
  font-weight: 600;
  border-bottom: 2px solid var(--color-text);
  padding-bottom: var(--space-sm);
}

.details-table tbody tr {
  border-top: 1px solid var(--color-text-muted);
}

.details-table tbody tr:first-child {
  border-top: none;
}

/* SHA256 display with hover */
.sha256 {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  cursor: help;
}

.sha256:hover::after {
  content: attr(data-full);
  position: absolute;
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-xs) var(--space-sm);
  margin-top: var(--space-xs);
  font-size: var(--text-xs);
  white-space: nowrap;
  z-index: 10;
}

/* Build time with inline bar chart */
.build-time {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.time-value {
  min-width: 3em;
}

.time-bar {
  height: 8px;
  background-color: var(--color-text-muted);
  min-width: 0;
}

/* ============================================================================
   Historical Context - 7-day sparklines
   ========================================================================= */

.history-sparklines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.sparkline-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sparkline-label {
  font-weight: 600;
  min-width: 5em;
}

.sparkline-svg {
  flex: 1;
  height: 24px;
}

.sparkline-value {
  color: var(--color-text-muted);
  min-width: 3em;
  text-align: right;
}

/* ============================================================================
   About & Links
   ========================================================================= */

.about {
  max-width: 60ch;
}

.links {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-top: var(--space-lg);
}

.links a {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* ============================================================================
   Responsive Design
   ========================================================================= */

@media (max-width: 768px) {
  body {
    padding: var(--space-md);
  }

  h1 {
    font-size: var(--text-xl);
  }

  h2 {
    font-size: var(--text-lg);
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-stats {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .matrix,
  .details-table table {
    font-size: var(--text-xs);
  }

  .matrix th,
  .matrix td,
  .details-table th,
  .details-table td {
    padding: var(--space-xs) var(--space-sm);
  }

  .sparkline {
    width: 30px;
    height: 12px;
  }
}

@media (max-width: 480px) {
  /* Stack matrix on very small screens */
  .matrix {
    display: block;
    overflow-x: auto;
  }

  .matrix thead {
    display: none;
  }

  .matrix tbody tr {
    display: block;
    margin-bottom: var(--space-md);
    border: 1px solid var(--color-text-muted);
    padding: var(--space-sm);
  }

  .matrix tbody th,
  .matrix tbody td {
    display: block;
    text-align: left;
    padding: var(--space-xs) 0;
  }

  .matrix tbody th::before,
  .matrix tbody td::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    display: inline;
  }
}

/* ============================================================================
   Print Styles
   ========================================================================= */

@media print {
  body {
    max-width: none;
    padding: 0;
  }

  header,
  footer {
    border-color: #000;
  }

  .data-exports,
  .links {
    display: none;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}

/* ============================================================================
   Accessibility
   ========================================================================= */

/* Visually hidden but available to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-text: #000;
    --color-bg: #fff;
    --color-text-muted: #333;
  }

  .matrix thead th,
  .details-table thead th,
  .summary-bar,
  header,
  footer {
    border-color: #000;
  }
}
