@import "tailwindcss";

@theme {
  --color-background: #ffffff;
  --color-background-secondary: #f8fafc;
  --color-background-tertiary: #f1f5f9;
  --color-background-elevated: #e2e8f0;

  --color-foreground: #0f172a;
  --color-muted: #475569;
  --color-muted-dark: #94a3b8;

  --color-border: #e2e8f0;
  --color-border-subtle: #f1f5f9;
  --color-border-emphasis: #cbd5e1;

  --color-primary: #1d4ed8;
  --color-accent: #7c3aed;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-destructive: #dc2626;

  --color-section: #f8fafc;
  --color-callout: #eff6ff;

  --font-sans: var(--font-inter), system-ui, sans-serif;
  --font-heading: var(--font-inter), system-ui, sans-serif;
  --font-body: var(--font-inter), system-ui, sans-serif;
}

@source "./**/*.{ts,tsx}";
@source "../components/**/*.{ts,tsx}";

body {
  font-family: var(--font-body);
  background: var(--color-background);
  color: var(--color-foreground);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Restore default list markers (Tailwind's preflight strips them).
   Scoped to @layer base so Tailwind utilities (e.g., `list-none`, `m-0`)
   on individual components still win. */
@layer base {
  ol, ul {
    padding-left: 1.6rem;
    margin: 0.75rem 0;
  }
  ol { list-style: decimal outside; }
  ul { list-style: disc outside; }
  li { margin: 0.25rem 0; }
  li::marker {
    color: var(--color-muted);
    font-weight: 600;
  }
}

/* Page-level wrapper used by every report's app/page.tsx. */
.report-container {
  max-width: 850px;
  margin: 0 auto;
  padding: 2rem;
}

/* Compatibility hooks for raw <table className="comparison-table"> markup
   used directly in pages (not via the <ComparisonTable> component). Projects
   that author tables inline use these. */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  /* No page-break-inside:avoid here — long tables must be allowed to break.
     Short tables stay together naturally (browsers prefer not to break short
     content). */
}
.comparison-table th {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--color-primary);
  text-align: left;
}
.comparison-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: top;
}
.comparison-table .metric {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--color-foreground);
}
.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

/* Print rules — Playwright honors these when generating PDF. Atomic blocks
   carry their own break-inside-avoid via Tailwind utilities on the component;
   only page-level rules and cover-after live here. */
@media print {
  body {
    font-size: 11pt;
  }
  .report-container {
    max-width: none;
    padding: 0;
  }
  a {
    text-decoration: none;
    color: var(--color-foreground);
  }
  /* No orphaned headings — if there isn't room for at least one line of
     content after a heading, push the heading to the next page. */
  h1, h2, h3, h4, h5, h6 {
    break-after: avoid;
    page-break-after: avoid;
  }
  /* Label-as-heading: a paragraph that contains only a <strong> child is
     semantically a sub-heading (e.g., "Scoring guidance:"). Same orphan
     treatment as real headings. */
  p:has(> strong:only-child) {
    break-after: avoid;
    page-break-after: avoid;
  }
  /* Don't break paragraphs across pages.
     Chromium's PDF engine doesn't reliably honor `orphans`/`widows`, so we
     use the stronger `break-inside: avoid`. Most paragraphs are short
     enough to stay whole; very long ones (>1 page) will break anyway
     because the browser has no choice. */
  p {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Page setup for PDF (A4, narrow margins). */
@page {
  size: A4;
  margin: 18mm 16mm;
}
