/* ==========================================================
   UnGovr Law — "Constitutional Broadsheet" identity
   Warm paper, ink-black type, constitutional crimson accent.
   Fraunces (display) / Newsreader (body) / IBM Plex Mono (data).

   Loaded from law_overrides/base.html as an external stylesheet
   so CSS-only edits republish a single file instead of every
   law-site page (issue #892).
   ========================================================== */
:root {
    /* Ink / paper palette */
    --paper:        #f5f1e8;
    --paper-warm:   #efe9da;
    --paper-deep:   #e6dfcc;
    --ink:          #15171a;
    --ink-soft:     #2d3138;
    --ink-muted:    #5a5e66;      /* AA safe: 7.1:1 on paper */
    --ink-faint:    #7a7e86;      /* AA safe: 4.54:1 on paper */
    --rule:         #1d1f22;      /* ruled lines */
    --rule-soft:    #c7bfab;      /* decorative rules */

    /* Spot colors */
    --crimson:      #8b1a1a;      /* constitutional crimson — 7.3:1 on paper */
    --crimson-deep: #6e1212;
    --indigo:       #2c3a5e;      /* indigo ink — 10.8:1 on paper */
    --indigo-deep:  #1a2544;
    --ochre:        #8a6a12;      /* AA safe on paper: 5.9:1 */
    --sage:         #3f6c3f;      /* AA safe on paper: 5.5:1 */

    /* Legacy token aliases (consumed by inherited pillar templates
       so we don't touch every file). New code should prefer the
       ink/paper names above. */
    --navy:         #2c3a5e;
    --navy-dark:    #1a2544;
    --navy-darker:  #15171a;
    --blue:         #2c3a5e;
    --blue-light:   #5a6ea0;
    --green:        #3f6c3f;
    --green-light:  #5a8a5a;
    --gray-dark:    #2d3138;
    --gray-medium:  #5a5e66;
    --gray-light:   #7a7e86;      /* darkened from #a9aeb1 for AA */
    --gray-bg:      #efe9da;
    --gray-border:  #c7bfab;
    --white:        #ffffff;
    --error:        #8b1a1a;

    /* Type stacks */
    --font-display: 'Fraunces', 'Source Serif 4', Georgia, serif;
    --font-body:    'Newsreader', Georgia, 'Times New Roman', serif;
    --font-sans:    'Newsreader', Georgia, 'Times New Roman', serif;
    --font-serif:   'Fraunces', Georgia, serif;
    --font-mono:    'IBM Plex Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4.5rem;
    --container-max: 1200px;
    --container-narrow: 760px;

    --focus-ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--crimson);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}
body {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--ink);
    background-color: var(--paper);
    /* subtle paper grain — keeps it feeling printed, not digital */
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.07 0 0 0 0 0.05 0 0 0 0.035 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    background-attachment: fixed;
    background-size: 160px 160px;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: 1.12;
    letter-spacing: -0.012em;
    font-weight: 600;
    margin-bottom: var(--space-md);
    text-wrap: balance;
}
h1 {
    font-size: clamp(2.25rem, 4.2vw, 3.5rem);
    font-weight: 800;
    letter-spacing: -0.022em;
    font-variation-settings: 'SOFT' 20, 'WONK' 0;
}
h2 { font-size: 1.875rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }

p { margin-bottom: var(--space-md); }
p, li { text-wrap: pretty; }

a {
    color: var(--crimson);
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: rgba(139, 26, 26, 0.4);
    transition: text-decoration-color 180ms ease, color 180ms ease;
}
a:hover { text-decoration-color: var(--crimson); }
a:visited { color: var(--crimson-deep); }

ul, ol { margin-left: var(--space-lg); margin-bottom: var(--space-md); }
li { margin-bottom: var(--space-sm); }

strong, b { font-weight: 600; color: var(--ink); }
em, i { font-style: italic; }

hr {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: var(--space-xl) 0;
}

.container { max-width: var(--container-max); margin: 0 auto; padding: 0 var(--space-lg); }
.container-narrow { max-width: var(--container-narrow); margin: 0 auto; padding: 0 var(--space-lg); }

/* ---- Global focus styles (WCAG 2.4.7) ---- */
*:focus { outline: none; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--crimson);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---- Skip-to-content link (WCAG 2.4.1) ---- */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 0;
    background: var(--ink);
    color: var(--paper);
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 10000;
    letter-spacing: 0.02em;
}
.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    outline: 3px solid var(--crimson);
    outline-offset: -3px;
}

/* ---- Visually hidden (for SR-only text) ---- */
.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;
}

/* ---- Main content wrapper ---- */
main { display: block; }
#main-content { outline: none; }

/* ==========================================================
   Header / Masthead override
   ========================================================== */
.site-header {
    background: var(--paper);
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: none;
    /* Double-rule masthead bottom edge */
    background-image:
        linear-gradient(to bottom,
            var(--paper) 0,
            var(--paper) calc(100% - 6px),
            var(--rule) calc(100% - 6px),
            var(--rule) calc(100% - 5px),
            var(--paper) calc(100% - 5px),
            var(--paper) calc(100% - 2px),
            var(--rule) calc(100% - 2px),
            var(--rule) 100%);
}
.header-inner {
    padding: 0.35rem var(--space-lg);
}
/* Inline SVG logo rendered as a two-tone engraving. The "U" glyph and
   small "Un" wordmark sit a shade lighter than the "G" glyph and
   "Gov.r" wordmark — mirroring the blue-vs-navy pairing in the color
   version. On hover, both shades collapse to crimson. */
.site-logo .site-logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}
.site-logo .logo-mark {
    display: block;
    height: 58px;
    width: auto;
}
.site-logo .logo-mark .logo-light path {
    fill: var(--ink-muted);
    transition: fill 180ms ease;
}
.site-logo .logo-mark .logo-dark path {
    fill: var(--ink);
    transition: fill 180ms ease;
}
.site-logo .site-logo-link:hover .logo-mark .logo-light path,
.site-logo .site-logo-link:hover .logo-mark .logo-dark path,
.site-logo .site-logo-link:focus-visible .logo-mark .logo-light path,
.site-logo .site-logo-link:focus-visible .logo-mark .logo-dark path {
    fill: var(--crimson);
}
@media (max-width: 768px) {
    .site-logo .logo-mark { height: 47px; }
}
/* Hide any legacy <img> that may leak in via inherited templates. */
.site-logo img { display: none; }
.site-logo-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    font-style: italic;
    color: var(--ink-muted);
    letter-spacing: 0;
}
.main-nav {
    gap: 0.1rem;
}
.nav-link {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.005em;
    color: var(--ink-soft);
    padding: 0.5rem 0.75rem;
    border-radius: 0;
    background: transparent;
    position: relative;
}
.nav-link::after {
    content: '';
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 4px;
    height: 1.5px;
    background: var(--crimson);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 220ms cubic-bezier(.2,.7,.2,1);
}
.nav-link:hover,
.nav-link:focus-visible {
    color: var(--crimson);
    background: transparent;
    text-decoration: none;
}
.nav-link:hover::after,
.nav-link:focus-visible::after,
.nav-link.active::after {
    transform: scaleX(1);
}
.nav-link.active {
    color: var(--ink);
    background: transparent;
}
.menu-toggle {
    color: var(--ink);
    font-size: 1.5rem;
    line-height: 1;
}
.menu-toggle:focus-visible {
    outline: 2px solid var(--crimson);
    outline-offset: 2px;
}

/* ==========================================================
   Footer override — keep shared markup, restyle surface
   ========================================================== */
.site-footer {
    background: var(--ink);
    color: var(--paper-warm);
    padding: var(--space-md) 0;
    margin-top: 0;
    border-top: 1px solid var(--rule);
}
.site-footer h4 {
    font-family: var(--font-display);
    color: var(--paper);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid rgba(245, 241, 232, 0.18);
}
.site-footer a {
    color: var(--paper-warm);
    text-decoration: none;
    font-size: 0.9375rem;
}
.site-footer a:hover,
.site-footer a:focus-visible {
    color: var(--paper);
    text-decoration: underline;
    text-decoration-color: var(--crimson);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}
.footer-section ul { list-style: none; margin: 0; padding: 0; }
.footer-bottom {
    color: #bfb8a6;   /* 4.6:1 on #15171a — AA pass */
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
}
/* Law-site footer — copyright centered, Galileo badge stacked below */
.footer-bottom-compact {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.9rem;
    padding: 0;
}
.footer-colophon {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin: 0;
    text-align: center;
}
.footer-galileo {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}
.footer-galileo img {
    height: 60px;
    width: auto;
    vertical-align: middle;
    opacity: 0.9;
    transition: opacity 180ms ease;
}
.footer-galileo:hover img,
.footer-galileo:focus-visible img { opacity: 1; }
@media (max-width: 540px) {
    .footer-colophon { flex-direction: column; gap: 0.4rem; }
}

/* ==========================================================
   Global a11y patches for inherited pillar pages
   (fiscal-law, open-records-law, meetings-law, oversight-law,
    accessibility-law share several low-contrast classes).
   These rules force AA-compliant colors without touching
   every pillar template.
   ========================================================== */
.null-val {
    color: var(--ink-faint) !important;       /* was #a9aeb1 — 2.56:1 fail */
    font-style: italic;
}
.null-val::before { content: ''; }
.null-val[aria-hidden="true"] + .null-val-text { clip: rect(0 0 0 0); }

.pillar .stat-label,
.score-text .out-of,
.score-of {
    color: var(--ink-faint) !important;       /* was #999 — 2.85:1 fail */
}
.pillar .desc {
    color: var(--ink-muted) !important;       /* was #666 at 0.72rem — size bump too */
    font-size: 0.8125rem !important;
    line-height: 1.55 !important;
}
.pillar .tagline { color: var(--crimson) !important; }
.breadcrumb, .breadcrumb a {
    color: var(--ink-muted) !important;
}
.jurisdiction { color: var(--ink-muted) !important; }

/* Table row headers (legacy templates use <th> for row labels) —
   announce them as row headers to assistive tech. */
.field-table th {
    font-family: var(--font-display);
    color: var(--ink);
    font-weight: 500;
}
.field-table th[scope="row"],
.field-table tbody th { font-weight: 500; }

/* Pillar-detail tables: improve zebra + focus */
.field-table tbody tr:hover { background: rgba(44, 58, 94, 0.04); }
.field-table tbody tr:focus-within { background: rgba(139, 26, 26, 0.06); }

/* Pillar score-hero override (inherited from fiscal-law etc.) */
.score-hero {
    background: var(--paper-warm) !important;
    border: 1px solid var(--rule-soft) !important;
    border-radius: 0 !important;
    position: relative;
}
.score-hero::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--crimson);
}
.score-hero .score-number {
    font-family: var(--font-display) !important;
    font-weight: 800 !important;
    color: var(--ink) !important;
    font-variation-settings: 'SOFT' 0, 'WONK' 1;
}

/* Band chips: use earthier, print-friendly tones */
.band-strong   { background: #dfe8d5 !important; color: #2b4318 !important; }
.band-moderate { background: #d8dce8 !important; color: #1e2b52 !important; }
.band-limited  { background: #ece0c1 !important; color: #5f4411 !important; }
.band-weak     { background: #ebd3b6 !important; color: #6b3b11 !important; }
.band-nominal  { background: #e8cfcf !important; color: #6e1212 !important; }
.badge-yes     { background: #dfe8d5 !important; color: #2b4318 !important; }
.badge-no      { background: #e8cfcf !important; color: #6e1212 !important; }
.badge-enum    { background: var(--paper-warm) !important; color: var(--ink) !important; }

/* Reduce motion (WCAG 2.3.3 AAA & user respect) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Selection — matches the red masthead rules */
::selection {
    background: var(--crimson);
    color: var(--paper);
}
