/* RIPA Explorer - Minimal, clean styling */

:root {
    --bg: #fafafa;
    --surface: #fff;
    --text: #1a1a1a;
    --text-muted: #666;
    --border: #e0e0e0;
    --accent: #4a7c9b;
    --accent-light: #e8f0f5;
    --mod-disp: #f0ad4e;
    --high-disp: #d9534f;
    --bar-color: #4a7c9b;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
}

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

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

/* Layout */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}

nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    margin-left: auto;
    font-size: 0.9rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
}

.nav-links a:hover {
    color: var(--accent);
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

footer {
    max-width: 1100px;
    margin: 2rem auto 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

footer a { color: var(--accent); }

/* Typography */
h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; color: var(--text); }

.intro { color: var(--text-muted); margin-bottom: 1.5rem; }
.note { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.mono { font-family: var(--mono); font-size: 0.85em; }
.num { text-align: center; font-variant-numeric: tabular-nums; }

/* Search */
.search-box {
    margin-bottom: 1rem;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-family: var(--font);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.htmx-indicator {
    display: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

th, td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

.clickable { cursor: pointer; }
.clickable:hover { background: var(--accent-light); }
.clickable a { color: var(--accent); text-decoration: none; }
.clickable a:hover { text-decoration: underline; }

.no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Agency detail */
.breadcrumb {
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.agency-header { margin-bottom: 1.5rem; }

.agency-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: first baseline;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.agency-jurisdiction {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}

.tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-panel { margin-top: 0.5rem; }

/* Year filter */
.year-filter {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.year-filter label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.year-filter select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font);
    font-size: 0.9rem;
    background: var(--surface);
}

/* Chart */
.chart-container {
    max-width: 700px;
    margin-bottom: 0.5rem;
}

.footnote {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-style: italic;
}

/* Bar visualization in tables */
.bar-cell { min-width: 120px; }

.bar {
    height: 10px;
    background: var(--bar-color);
    border-radius: 2px;
    min-width: 2px;
    opacity: 0.7;
    margin-bottom: 2px;
}

.pop-bar {
    background: #999;
    opacity: 0.4;
}

.stop-bar-bg { background: var(--bar-color); opacity: 0.7; }
.pop-bar-bg { background: #999; opacity: 0.4; }

/* Disparities */
.table-scroll {
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.disparities th { font-size: 0.75rem; }
.disparities td { font-size: 0.85rem; }

.ref-group { background: #f8f8f8; }

.mod-disp { color: #8a6d3b; font-weight: 600; }
.high-disp { color: #a94442; font-weight: 700; }

.legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-item { display: flex; align-items: center; gap: 0.35rem; }

.swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

.mod-disp-bg { background: var(--mod-disp); opacity: 0.5; }
.high-disp-bg { background: var(--high-disp); opacity: 0.5; }

/* Article list */
.article-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.article-item {
    display: block;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.article-item:hover {
    border-color: var(--accent);
}

.article-item h2 {
    font-size: 1.1rem;
    margin: 0 0 0.25rem;
    color: var(--accent);
}

.article-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.article-summary {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

/* Article content (rendered markdown) */
.article-content {
    max-width: 780px;
    line-height: 1.7;
}

.article-content h1 {
    font-size: 1.6rem;
    margin: 0 0 0.75rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.article-content h2 {
    font-size: 1.25rem;
    margin: 2rem 0 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.35rem;
}

.article-content h3 {
    font-size: 1.05rem;
    margin: 1.5rem 0 0.4rem;
}

.article-content h4 {
    font-size: 0.95rem;
    margin: 1.25rem 0 0.35rem;
}

.article-content p {
    margin: 0.75rem 0;
}

.article-content ul, .article-content ol {
    /*margin: 0.75rem 0;*/
    padding-left: 1.5rem;
}

.article-content li {
    margin: 0.3rem 0;
}

.article-content blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--accent);
    background: var(--accent-light);
    color: var(--text);
    font-size: 0.9rem;
}

.article-content blockquote p {
    margin: 0.4rem 0;
}

.article-content code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: #f0f0f0;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
}

.article-content pre {
    margin: 1rem 0;
    padding: 1rem;
    background: #f5f5f5;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow-x: auto;
}

.article-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
}

.article-content table {
    margin: 1rem 0;
    font-size: 0.9rem;
}

.article-content a {
    color: var(--accent);
}

.article-content a:hover {
    text-decoration: underline;
}

.article-content strong {
    font-weight: 600;
}

.article-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.article-content .toc {
    background: var(--accent-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0 1.5rem;
    font-size: 0.85rem;
    line-height: 1.2;
    overflow-x: auto;
}

.article-content .toc ul { padding-left: 0; list-style: none; }
.article-content .toc ul ul { padding-left: 1.25rem; }
.article-content .toc a { text-decoration: none; }
.article-content .toc a:hover { text-decoration: underline; }

/* Article sidebar TOC layout */
.article-layout {
    position: relative;
}

.article-sidebar {
    display: none;
}

@media (min-width: 1200px) {
    .article-layout {
        display: grid;
        grid-template-columns: 230px minmax(0, 780px);
        gap: 0;
        margin-left: -0.5rem;
    }

    .article-sidebar {
        display: block;
        position: sticky;
        top: 1rem;
        align-self: start;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        font-size: 0.82rem;
        line-height: 1.5;
        padding-right: 1.25rem;
        border-right: 1px solid var(--border);
        margin-right: 1.75rem;
        scrollbar-width: thin;
        scrollbar-color: var(--border) transparent;
    }

    .article-sidebar ul {
        list-style: none;
        padding-left: 0;
        margin: 0;
    }

    .article-sidebar ul ul {
        padding-left: 0.9rem;
    }

    .article-sidebar li {
        margin: 0;
    }

    .article-sidebar a {
        display: block;
        padding: 0.2rem 0 0.2rem 0.6rem;
        color: var(--text-muted);
        text-decoration: none;
        border-left: 2px solid transparent;
        transition: color 0.15s, border-color 0.15s;
    }

    .article-sidebar a:hover {
        color: var(--text);
    }

    .article-sidebar a.active {
        color: var(--accent);
        border-left-color: var(--accent);
        font-weight: 600;
    }

    /* Hide inline TOC when sidebar is visible */
    .article-content .toc {
        display: none;
    }

    .article-content {
        max-width: none;
    }
}

/* Responsive */
@media (max-width: 1199px) {
    .article-sidebar { display: none !important; }
}

@media (max-width: 768px) {
    main { padding: 1rem; }
    .agency-meta { flex-direction: column; gap: 0.25rem; }
    th, td { padding: 0.4rem 0.5rem; font-size: 0.8rem; }

    .article-content .toc ul ul { padding-left: 1rem; }
}
