/* =============================================================================
   EMPIRICAL REGISTRY — GLOBAL CSS
   /public/styles/global.css
   
   CONTENTS:
     01. Design Tokens (:root)
     02. Reset & Base
     03. Site Header
     04. Site Footer
     05. Tier Badges (shared across audit layout + index)
     06. Utility Classes
     07. Responsive Overrides

   MIGRATION NOTE:
     Component-specific styles currently scoped in AuditLayout.astro,
     BaseLayout.astro, and audit index will migrate to components.css
     once this token set is confirmed stable.
     Do not add component styles here — this file is tokens and site chrome only.
============================================================================= */


/* =============================================================================
   01. DESIGN TOKENS
   All colour, typography, and spacing decisions live here.
   Every value used across the site references these variables.
   
   PALETTE RATIONALE:
     Off-white background (#faf9f7) — warmer than pure white, reduces eye strain
     on long-form reading. Signals print/editorial rather than SaaS product.
     
     Near-black ink (#1a1a18) — not pure black. Softens contrast slightly,
     consistent with quality print typography (FT, HBR, Economist).
     
     Accent (#8b1a1a) — deep institutional red. Authority signal without
     aggression. Used sparingly: kickers, active nav, verified fact border.
     
     Warn palette (#fdf6ec / #c8892a) — amber. Used exclusively for
     corrections notices and misleading verdict badges.
     
     Rule (#d4d0c8) — warm grey. Matches the off-white background tone.
     Pure #ccc reads cold against #faf9f7.
============================================================================= */

:root {

  /* ── TYPOGRAPHY ── */
  --font-serif:  'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans:   'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'IBM Plex Mono', 'Courier New', monospace;

  /* ── COLOUR: INK ── */
  --ink:         #1a1a18;   /* primary text — near-black, warm */
  --ink-mid:     #3d3d3a;   /* body copy, secondary text */
  --ink-light:   #7a7870;   /* labels, metadata, captions */

  /* ── COLOUR: BACKGROUND ── */
  --bg:          #faf9f7;   /* page background — warm off-white */
  --bg-inset:    #f2f0ec;   /* inset blocks, sidebar, code backgrounds */
  --bg-hover:    #eceae4;   /* hover state for interactive elements */

  /* ── COLOUR: RULES & BORDERS ── */
  --rule:        #d4d0c8;   /* standard dividers */
  --rule-light:  #e8e5de;   /* subtle dividers within components */

  /* ── COLOUR: ACCENT (institutional red) ── */
  --accent:      #8b1a1a;   /* kickers, active nav underline, CTAs */
  --accent-mid:  #a83232;   /* links, anchor labels */
  --accent-light:#c8a0a0;   /* decorative, disabled states */

  /* ── COLOUR: VERDICT — FALSE ── */
  --false-ink:   #6b2020;
  --false-bg:    #fdf0f0;
  --false-border:#e8c8c8;

  /* ── COLOUR: VERDICT — MISLEADING ── */
  --warn-ink:    #6b4a10;
  --warn-bg:     #fdf6ec;
  --warn-border: #c8892a;

  /* ── COLOUR: VERDICT — OUTDATED ── */
  --outdated-ink:    #1a3a5c;
  --outdated-bg:     #eef2f8;
  --outdated-border: #8aaad4;

  /* ── COLOUR: SOURCE TIERS ── */
  --tier1-ink:   #1a3a1a;
  --tier1-bg:    #eef6ee;
  --tier1-border:#7aaa7a;

  --tier2-ink:   #1a2a4a;
  --tier2-bg:    #eef2fa;
  --tier2-border:#7a9ac8;

  --tier3-ink:   #3a2a1a;
  --tier3-bg:    #f6f0e8;
  --tier3-border:#b89060;

  --tier4-ink:   #3a3a3a;
  --tier4-bg:    #f2f2f0;
  --tier4-border:#b0aea8;

  /* ── SPACING ── */
  --space-xs:    0.25rem;
  --space-sm:    0.5rem;
  --space-md:    1rem;
  --space-lg:    2rem;
  --space-xl:    3.5rem;

  /* ── LAYOUT ── */
  --max-width:   1080px;    /* primary content max-width */
  --prose-width: 680px;     /* long-form reading column */
  --header-h:    56px;      /* site header height — used for sticky offset calc */

  /* ── TRANSITIONS ── */
  --ease:        0.15s ease;
}


/* =============================================================================
   02. RESET & BASE
============================================================================= */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Offset anchor links so sticky header doesn't obscure the target */
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

body {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Remove list styles for nav lists — preserve for prose lists */
nav ul, nav ol {
  list-style: none;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Focus visible — keyboard navigation only, not mouse */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 1px;
}

/* Skip to main content — screen readers and keyboard users */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  z-index: 100;
  transition: top var(--ease);
}
.skip-link:focus { top: 0.5rem; }


/* =============================================================================
   03. SITE HEADER
   Identical markup rendered by both AuditLayout.astro and BaseLayout.astro.
   Height is fixed at --header-h (56px) for scroll-padding-top calculation.
============================================================================= */

.site-header {
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 20;
  /* Subtle backdrop blur — softens content scrolling beneath header */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* Semi-transparent to allow blur to show through */
  background: rgba(250, 249, 247, 0.92);
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Wordmark */
.site-wordmark {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
  text-transform: uppercase;
  /* Subtle tracking — institutional, not decorative */
}
.site-wordmark:hover { color: var(--accent); }

/* Primary nav */
.site-nav {
  display: flex;
  align-items: center;
  gap: 0;
}

.site-nav a {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-light);
  text-decoration: none;
  padding: 0 0.9rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color var(--ease), border-color var(--ease);
  /* Negative margin to align border-bottom flush with header border */
  margin-bottom: -1px;
}

.site-nav a:hover {
  color: var(--ink);
}

.site-nav a.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* Mobile nav — hamburger handled in responsive section */
.site-nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  color: var(--ink);
}


/* =============================================================================
   04. SITE FOOTER
   Identical markup rendered by both AuditLayout.astro and BaseLayout.astro.
============================================================================= */

.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--bg-inset);
  padding: 0 2rem;
}

.site-footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  list-style: none;
}

.footer-links a {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--ink-light);
  text-decoration: none;
  transition: color var(--ease);
}
.footer-links a:hover { color: var(--ink); }

.footer-copy {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--ink-light);
  white-space: nowrap;
}
.footer-copy a {
  color: var(--ink-light);
  text-decoration: none;
}
.footer-copy a:hover { color: var(--accent); }


/* =============================================================================
   05. TIER BADGES
   Shared component used in AuditLayout sidebar, anchor lists, and audit cards.
   Class names: .tier-badge.t1 / .t2 / .t3 / .t4
   Referenced in AuditLayout.astro tierConfig and components.css.
============================================================================= */

.tier-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border: 1px solid;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tier-badge.t1 {
  color: var(--tier1-ink);
  background: var(--tier1-bg);
  border-color: var(--tier1-border);
}
.tier-badge.t2 {
  color: var(--tier2-ink);
  background: var(--tier2-bg);
  border-color: var(--tier2-border);
}
.tier-badge.t3 {
  color: var(--tier3-ink);
  background: var(--tier3-bg);
  border-color: var(--tier3-border);
}
.tier-badge.t4 {
  color: var(--tier4-ink);
  background: var(--tier4-bg);
  border-color: var(--tier4-border);
}


/* =============================================================================
   06. UTILITY CLASSES
   Minimal set — only patterns used in 3+ places across the codebase.
   Not a utility framework. Add here only when duplication is confirmed.
============================================================================= */

/* Screen-reader only — visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Truncate to single line with ellipsis */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Visually hidden but takes up space (for layout stability) */
.invisible { visibility: hidden; }

/* Monospace number display — used for version strings, counts */
.mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
}


/* =============================================================================
   07. RESPONSIVE OVERRIDES
   Mobile-first breakpoints.
   768px — tablet: collapse footer, adjust header
   480px — phone: tighten spacing, single-column everything
============================================================================= */

@media (max-width: 768px) {

  /* Header: show hamburger, hide nav links */
  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 0;
    z-index: 19;
  }
  .site-nav.open { display: flex; }
  .site-nav a {
    height: auto;
    padding: 0.75rem 2rem;
    border-bottom: none;
    border-left: 3px solid transparent;
    margin-bottom: 0;
  }
  .site-nav a.active { border-left-color: var(--accent); }
  .site-nav-toggle { display: flex; }

  /* Footer: stack vertically */
  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .footer-copy { white-space: normal; }
}

@media (max-width: 480px) {
  html { font-size: 15px; }

  .site-header-inner { padding: 0 1.25rem; }
  .site-footer { padding: 0 1.25rem; }
}