/* E2C Intelligence site layer. Uses the design tokens in design/styles.css; no raw
   colors except where a token does not exist. */

:root {
    --font-serif: 'Fraunces', Georgia, serif;
    --page-max: 1180px;
    --gutter: clamp(1rem, 4vw, 2.5rem);
}

html { scroll-behavior: smooth; scroll-padding-top: 7.5rem; }

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-cream);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-serif); color: var(--primary-dark); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 600; margin: 0 0 1rem; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; margin: 0; }
h3 { font-size: 1.15rem; font-weight: 600; margin: 0; }
p { margin: 0 0 0.75rem; }

a { color: var(--primary-light); text-underline-offset: 2px; }
a:hover { color: var(--teal-dark); }
:focus-visible { outline: 3px solid var(--accent-light); outline-offset: 2px; border-radius: 4px; }

.skip-link {
    position: absolute; left: 1rem; top: -3rem; z-index: 200;
    padding: 0.5rem 1rem; background: var(--primary); color: var(--text-inverse);
    border-radius: var(--radius-sm); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 0.5rem; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- header and footer ---- */

.site-header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(250, 248, 245, 0.92);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.site-header-inner {
    max-width: var(--page-max); margin: 0 auto; padding: 0.4rem var(--gutter);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo-area { display: inline-flex; align-items: center; }
.header-logo { height: 84px; width: auto; display: block; } /* about 176 px wide; BRAND.md minimum for the primary lockup is 120 px */
.nav-links { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav-link {
    padding: 0.45rem 0.9rem; border-radius: 999px; text-decoration: none;
    color: var(--text-secondary); font-weight: 500; font-size: 0.95rem;
}
.nav-link:hover, .nav-link.active { background: var(--white); color: var(--primary); box-shadow: var(--shadow-sm); }

.site-footer { background: var(--primary-dark); color: rgba(255, 255, 255, 0.78); margin-top: 4rem; }
.site-footer-inner {
    max-width: var(--page-max); margin: 0 auto; padding: 2rem var(--gutter);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.site-footer img { height: 40px; width: auto; }
.site-footer p { margin: 0; font-size: 0.9rem; }
.footer-link { color: rgba(255, 255, 255, 0.78); font-size: 0.85rem; }
.footer-link:hover { color: var(--white); }

.site-main { display: block; }
.site-main:focus { outline: none; }

/* ---- home hero and search ---- */

.home-hero {
    background:
        radial-gradient(1200px 400px at 85% -10%, rgba(46, 182, 125, 0.16), transparent 60%),
        radial-gradient(900px 380px at -10% 110%, rgba(42, 77, 122, 0.12), transparent 60%),
        var(--bg-warm);
    border-bottom: 1px solid var(--border);
}
.home-hero-inner { max-width: 880px; margin: 0 auto; padding: clamp(3rem, 9vw, 6.5rem) var(--gutter) clamp(2.5rem, 7vw, 5rem); text-align: center; }
.eyebrow {
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--teal-dark); margin-bottom: 1rem;
}
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.home-hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.6rem); }
.home-hero-lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--text-secondary); max-width: 680px; margin: 0 auto 2rem; }

.scan-form {
    display: flex; gap: 0.5rem; max-width: 640px; margin: 0 auto;
    background: var(--white); padding: 0.5rem; border-radius: 999px;
    box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.scan-form input {
    flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 1.05rem;
    padding: 0.75rem 1.1rem; color: var(--text-primary);
}
.scan-form input:focus { outline: none; }
.scan-form:focus-within { border-color: var(--teal); box-shadow: var(--shadow-lg), 0 0 0 4px rgba(46, 182, 125, 0.18); }
.btn-scan {
    border: 0; border-radius: 999px; padding: 0.75rem 1.5rem; font: inherit; font-weight: 700;
    background: var(--primary); color: var(--text-inverse); cursor: pointer; white-space: nowrap;
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.btn-scan:hover { background: var(--teal-dark); }
.btn-scan:active { transform: translateY(1px); }
.scan-result { max-width: 640px; margin: 1rem auto 0; text-align: left; }
.scan-message {
    background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--teal);
    border-radius: var(--radius-md); padding: 1rem 1.25rem; box-shadow: var(--shadow-sm);
}
.scan-message p { margin: 0.25rem 0; }
.scan-message-title { font-weight: 700; color: var(--primary-dark); }
.scan-links { margin: 0.5rem 0 0; padding-left: 1.2rem; }

/* ---- sections ---- */

.site-section { max-width: var(--page-max); margin: 0 auto; padding: clamp(2.5rem, 6vw, 4rem) var(--gutter) 0; }
.section-head { margin-bottom: 1.5rem; }
.section-sub { color: var(--text-muted); margin: 0.4rem 0 0; max-width: 62ch; }

.region-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.region-card { display: flex; }
.region-card-link {
    flex: 1; display: flex; flex-direction: column; gap: 0.6rem;
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.4rem; text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
    transition: transform var(--transition-medium), box-shadow var(--transition-medium), border-color var(--transition-medium);
    position: relative; overflow: hidden;
}
.region-card-link::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--primary-light);
}
.region-card[data-type="nonmetro"] .region-card-link::before { background: var(--teal); }
.region-card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-dark); color: inherit; }
.region-card-top { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.region-card-title { font-size: 1.3rem; }
.region-card-where { color: var(--text-muted); font-size: 0.9rem; margin: 0; }
.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; margin: 0.5rem 0 0; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.card-stat dt { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.card-stat dd { margin: 0; font-family: var(--font-serif); font-size: 1.45rem; font-weight: 600; color: var(--primary-dark); line-height: 1.2; }
.card-stat { display: flex; flex-direction: column-reverse; }
.region-card-cta { margin-top: auto; padding-top: 0.5rem; font-weight: 700; color: var(--teal-dark); font-size: 0.95rem; }

.tag {
    display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--bg-warm); color: var(--text-secondary);
}
.tag-metro { background: var(--tool-brief-tint); color: var(--primary); }
.tag-rural { background: var(--tool-package-tint); color: var(--tool-package-dark); }
.tag-quiet { background: var(--bg-warm); color: var(--text-muted); }
.tag-inline { margin-left: 0.5rem; vertical-align: middle; }

.featured-intro {
    max-width: 46rem; margin: 0 0 1.5rem; padding: 0.9rem 1.1rem;
    border-left: 3px solid var(--teal); background: var(--white); border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.featured-intro p { margin: 0; color: var(--text-secondary); font-size: 0.95rem; }
.featured-intro p + p { margin-top: 0.4rem; }
.featured-intro strong { color: var(--primary); }
.method { padding-bottom: 1rem; }
.method h2 { margin-bottom: 1.5rem; }
.method-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.method-item { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem; }
.method-item h3 { margin-bottom: 0.4rem; color: var(--teal-dark); }
.method-item p { color: var(--text-secondary); margin: 0; font-size: 0.95rem; }

/* ---- report ---- */

.report-hero {
    max-width: var(--page-max); margin: 0 auto; padding: clamp(2rem, 6vw, 3.5rem) var(--gutter) 2rem;
}
.report-hero .eyebrow { margin-bottom: 0.75rem; }
.report-lead { font-size: 1.15rem; color: var(--text-secondary); max-width: 70ch; }
.report-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 1.25rem; font-size: 0.95rem; color: var(--text-secondary); }

.stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px;
    background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; margin: 1.5rem 0 0; box-shadow: var(--shadow-sm);
}
.stat { background: var(--white); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; }
.stat dd { margin: 0; font-family: var(--font-serif); font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 600; color: var(--primary-dark); line-height: 1.1; }
.stat dt { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.3rem; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin: 0 0 1.25rem; }
.mini-stats .stat { background: var(--bg-cream); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.8rem 1rem; }
.mini-stats .stat dd { font-size: 1.5rem; }
.district-group-title { margin: 1.5rem 0 0.5rem; font-size: 1.1rem; }
.method-note { margin: 0.75rem 0 0; }

.report-layout {
    max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter);
    display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 2.5rem; align-items: start;
}
.report-toc { position: sticky; top: 7.5rem; font-size: 0.92rem; }
.report-toc-title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--text-muted); }
.report-toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.report-toc a { display: block; padding: 0.35rem 0 0.35rem 1rem; margin-left: -2px; border-left: 2px solid transparent; color: var(--text-secondary); text-decoration: none; }
.report-toc a:hover { color: var(--primary); border-left-color: var(--teal); }

.report-section {
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: clamp(1.25rem, 3vw, 2rem); margin-bottom: 1.5rem; box-shadow: var(--shadow-sm);
}
.section-num { font-family: var(--font-serif); color: var(--teal-dark); font-weight: 600; margin: 0 0 0.25rem; }

.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.item-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.1rem 1.25rem; background: var(--bg-cream); }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.item-sub { color: var(--text-secondary); font-size: 0.95rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0.75rem 0; font-size: 0.93rem; }
.kv dt { color: var(--text-muted); font-weight: 600; }
.kv dd { margin: 0; }

.badge {
    display: inline-flex; align-items: center; font-size: 0.75rem; font-weight: 700; white-space: nowrap;
    padding: 0.18rem 0.6rem; border-radius: 999px; background: var(--bg-warm); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.badge-ok { background: var(--tool-package-tint); color: var(--tool-package-dark); border-color: rgba(46, 182, 125, 0.3); }
.badge-mid { background: var(--tool-brief-tint); color: var(--primary); border-color: rgba(42, 77, 122, 0.2); }
.badge-warn { background: var(--tool-fly-tint); color: var(--tool-fly-dark); border-color: rgba(217, 119, 6, 0.3); }
.badge-type { background: var(--white); }

.fact-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.75rem; }
.fact { border-left: 3px solid var(--teal); padding: 0.1rem 0 0.1rem 0.9rem; }
.fact-text { margin: 0 0 0.35rem; font-weight: 500; }
.fact-quote { margin: 0 0 0.4rem; font-family: var(--font-serif); font-style: italic; color: var(--text-secondary); font-size: 0.95rem; }
.fact-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; font-size: 0.82rem; color: var(--text-muted); margin: 0; }
.fact-meta a { overflow-wrap: anywhere; }
.dot { color: var(--border-dark); }

.chip-list { list-style: none; margin: 0.5rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { background: var(--white); border: 1px solid var(--border); border-radius: 999px; padding: 0.3rem 0.8rem; font-size: 0.9rem; text-transform: capitalize; }

details.more { margin-top: 0.75rem; }
details.more > summary { cursor: pointer; font-weight: 600; color: var(--primary-light); font-size: 0.92rem; }
details.more[open] > summary { margin-bottom: 0.5rem; }
.plain-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.5rem; font-size: 0.93rem; }
.plain-list a { overflow-wrap: anywhere; }

.speaking-group { margin: 1.25rem 0 0.75rem; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-family: inherit; }
.mini-stats + .speaking-group { margin-top: 0.25rem; }
.speaking-card { border-left: 4px solid var(--border-dark); }
.speaking-card.speaking-confirmed { border-left-color: var(--teal); }
.speaking-card.speaking-likely { border-left-color: var(--primary-light); }
.speaking-when { margin: 0 0 0.3rem; font-weight: 600; color: var(--primary-dark); font-size: 0.95rem; }
.speaking-date { white-space: nowrap; }
.speaking-why { margin-top: 0.6rem; }
.speaking-why .fine { margin: 0; }
.speaking-reasons .chip { text-transform: none; font-size: 0.82rem; padding: 0.2rem 0.65rem; }

.plans { margin-top: 1.5rem; }
.plans h3 { margin-bottom: 0.75rem; }
.plan-card { border: 1px dashed var(--border-dark); border-radius: var(--radius-md); padding: 1rem 1.25rem; margin-bottom: 0.75rem; }
.plan-state { font-weight: 700; color: var(--primary-dark); margin: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.data-table th, .data-table td { padding: 0.65rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table thead th { background: var(--bg-warm); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); position: sticky; top: 0; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--bg-cream); }
.data-table tbody th { font-weight: 600; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .wrap { overflow-wrap: anywhere; max-width: 340px; }

.btn-more {
    margin-top: 1rem; border: 1px solid var(--border-dark); background: var(--white); color: var(--primary);
    font: inherit; font-weight: 600; font-size: 0.92rem; padding: 0.5rem 1.1rem; border-radius: 999px; cursor: pointer;
}
.btn-more:hover { border-color: var(--teal); color: var(--teal-dark); }

.fine { font-size: 0.85rem; color: var(--text-muted); }
.note { font-size: 0.93rem; color: var(--text-secondary); }
.warn { color: var(--tool-fly-dark); font-weight: 600; }

/* ---- states ---- */

.state { border-radius: var(--radius-md); padding: 1rem 1.25rem; border: 1px solid var(--border); background: var(--bg-cream); }
.state p { margin: 0.2rem 0; }
.state-title { font-weight: 700; color: var(--primary-dark); }
.state-error { border-left: 4px solid var(--accent); }
.state-loading .state-title { color: var(--text-muted); font-weight: 500; }
.state-loading .state-title::before {
    content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.6em; vertical-align: -0.1em;
    border: 2px solid var(--border-dark); border-top-color: var(--teal); border-radius: 50%; animation: e2c-spin 0.8s linear infinite;
}
@keyframes e2c-spin { to { transform: rotate(360deg); } }

.cos-attribution { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 0; }
.cos-attribution[hidden] { display: none; }
.cos-attribution p { margin: 0; font-size: 0.9rem; color: var(--text-secondary); }

/* ---- small screens ---- */

@media (max-width: 860px) {
    .report-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .stats { grid-template-columns: 1fr 1fr; }
    .stats .stat:last-child:nth-child(odd) { grid-column: span 2; }
    .report-section { min-width: 0; }
    .report-toc { position: static; margin-bottom: 1.25rem; }
    .report-toc ol { display: flex; gap: 0.4rem; overflow-x: auto; border-left: 0; padding-bottom: 0.25rem; }
    .report-toc li { flex: none; }
    .report-toc a { border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.85rem; margin: 0; background: var(--white); white-space: nowrap; }
}

@media (max-width: 560px) {
    .scan-form { flex-direction: column; border-radius: var(--radius-lg); }
    .btn-scan { width: 100%; }
    .header-logo { height: 64px; } /* about 134 px wide, above the 120 px minimum */
    .site-header-inner { padding-top: 0.35rem; padding-bottom: 0.35rem; }
    .nav-link { padding: 0.4rem 0.7rem; }
    .kv { grid-template-columns: 1fr; }
    .kv dd { margin-bottom: 0.4rem; }
    .data-table th, .data-table td { padding: 0.55rem 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .region-card-link, .btn-scan { transition: none; }
    .region-card-link:hover { transform: none; }
}
.report-body { min-width: 0; }
.report-toc { min-width: 0; }
.item-card, .fact, .plan-card, .state { overflow-wrap: anywhere; min-width: 0; }
.card-list > li { min-width: 0; }

.region-filter { display: flex; gap: 0.4rem; margin: 0 0 1.25rem; flex-wrap: wrap; }
.filter-btn {
    border: 1px solid var(--border-dark); background: var(--white); color: var(--text-secondary);
    font: inherit; font-weight: 600; font-size: 0.9rem; padding: 0.4rem 1rem; border-radius: 999px; cursor: pointer;
}
.filter-btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: var(--text-inverse); }
.region-card[hidden] { display: none; }

/* Header logo size. Scoped to .site-header so the brand stylesheet's own header
   breakpoints do not shrink it. BRAND.md: primary lockup at least 120 px wide on screen. */
.site-header .logo-area { flex: none; }
.site-header .header-logo { height: 84px; width: auto; max-width: none; max-height: none; flex-shrink: 0; }
.site-header .nav-links { flex-wrap: nowrap; flex-direction: row; flex: none; width: auto; }
.site-header .site-header-inner { flex-wrap: nowrap; }
@media (max-width: 560px) {
    .site-header .header-logo { height: 64px; }
    .site-header .nav-link { white-space: nowrap; }
}
@media (max-width: 360px) {
    .site-header .header-logo { height: 58px; } /* about 121 px wide */
    .site-header .nav-link { padding: 0.35rem 0.55rem; font-size: 0.88rem; }
}
.site-header .nav-links { display: flex; overflow: visible; }
.site-header .nav-links .nav-link { width: auto; min-width: 0; min-height: 0; flex: none; }
