/* =============================================================================
   Lenape Search — site styles
   ============================================================================= */

:root {
    --bg: #f7f5f0;
    --bg-card: #ffffff;
    --fg: #1f1d1a;
    --fg-muted: #5d5a52;
    --fg-dim: #8b877d;
    --accent: #6a4a2a;        /* warm brown — colonial archive feel */
    --accent-hover: #4a3014;
    --accent-soft: #efe2cf;
    --border: #d8d2c4;
    --border-soft: #e8e3d6;
    --mark-bg: #fbe7a3;
    --mark-fg: #2a2210;
    --error-fg: #8b1f1f;
    --link: #2c5cba;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Top bar ---------------- */

.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}
.brand {
    font-weight: 600;
    font-size: 17px;
    color: var(--fg);
    letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.topnav {
    display: flex;
    gap: 18px;
}
.topnav a {
    color: var(--fg-muted);
    font-size: 14px;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}
.topnav a.active {
    color: var(--fg);
    border-bottom-color: var(--accent);
}
.topnav a:hover { color: var(--fg); text-decoration: none; }

/* ---------------- Search shell ---------------- */

.search-shell, .sources-shell {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.search-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.search-input-row {
    position: relative;
    display: flex;
    align-items: center;
}
.search-input {
    flex: 1;
    width: 100%;
    padding: 10px 36px 10px 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    outline: none;
}
.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(106, 74, 42, 0.15);
}
.search-clear {
    position: absolute;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: var(--fg-dim);
    font-size: 18px;
    cursor: pointer;
    display: none;
    line-height: 22px;
    text-align: center;
}
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--fg); }

.search-categories {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    background: var(--bg);
    color: var(--fg-muted);
    user-select: none;
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.cat-chip:hover { border-color: var(--accent); color: var(--fg); }
.cat-chip.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.cat-chip input { margin: 0; cursor: inherit; }
.cat-chip:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-hover);
}
.cat-chip .cat-label { font-weight: 500; }

.search-meta {
    margin-left: auto;
    color: var(--fg-dim);
    font-size: 12px;
}

/* ---------------- Search body ---------------- */

.search-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 900px) {
    .search-body { grid-template-columns: 1fr; }
    .search-toc-wrap { position: static; }
}
.search-toc-wrap {
    position: sticky;
    top: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}
.search-toc-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    color: var(--fg-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.search-toc-actions { display: flex; gap: 8px; }
.search-toc-action {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 11px;
    padding: 0;
}
.search-toc-action:hover { color: var(--accent-hover); text-decoration: underline; }
.search-toc {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.search-toc a {
    color: var(--fg);
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    gap: 6px;
}
.search-toc a:hover { background: var(--accent-soft); text-decoration: none; }
.search-toc a .toc-count { color: var(--fg-dim); font-variant-numeric: tabular-nums; }

.search-results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    min-height: 200px;
}
.empty-prompt {
    color: var(--fg-muted);
    font-style: italic;
    margin: 12px 0;
}

/* ---------------- Result groups ---------------- */

.cat-group {
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 18px;
    margin-bottom: 18px;
}
.cat-group:last-child { border-bottom: none; margin-bottom: 0; }
.cat-group-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}
.cat-group-head h2 {
    margin: 0;
    font-size: 16px;
    color: var(--accent-hover);
    letter-spacing: -0.01em;
}
.cat-group-head .cat-count {
    color: var(--fg-dim);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.cat-group-head .toggle {
    margin-left: auto;
    color: var(--fg-dim);
    font-size: 12px;
}
.cat-group.collapsed .cat-group-body { display: none; }
.cat-group .cat-desc {
    color: var(--fg-muted);
    font-size: 12px;
    margin: -2px 0 10px 0;
    font-style: italic;
}

/* ---------------- PDF subgroups within a category ---------------- */

.pdf-group {
    margin: 10px 0 14px 0;
    padding: 10px 12px;
    background: #fdfbf6;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
}
.pdf-group-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}
.pdf-group-title {
    font-weight: 600;
    color: var(--fg);
    font-size: 14px;
}
.pdf-group-meta {
    margin-left: auto;
    color: var(--fg-dim);
    font-size: 12px;
}
.pdf-hit {
    margin: 6px 0 6px 0;
    padding: 6px 8px;
    border-left: 2px solid var(--accent-soft);
}
.pdf-hit:hover { background: #fbf7ed; }
.pdf-hit .citation {
    font-size: 12px;
    color: var(--fg-muted);
    margin-bottom: 2px;
    display: flex;
    gap: 8px;
    align-items: baseline;
}
.pdf-hit .citation a { color: var(--accent); }
.pdf-hit .citation .open-btn {
    margin-left: auto;
    padding: 6px 16px;
    background: var(--accent);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
    border-radius: 8px;
    text-decoration: none;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(106, 74, 42, 0.18);
    transition: background 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}
.pdf-hit .citation .open-btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(106, 74, 42, 0.25);
    transform: translateY(-1px);
}
.pdf-hit .citation .open-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
}
.pdf-hit .snippet {
    font-size: 13.5px;
    color: var(--fg);
    line-height: 1.5;
}
.pdf-hit .snippet mark {
    background: var(--mark-bg);
    color: var(--mark-fg);
    padding: 0 2px;
    border-radius: 2px;
}
.show-more-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
}
.show-more-link:hover { text-decoration: underline; }

/* ---------------- Sources page ---------------- */

.sources-content h2 {
    font-size: 16px;
    color: var(--accent-hover);
    margin: 24px 0 4px 0;
}
.sources-content .desc {
    color: var(--fg-muted);
    font-size: 12px;
    font-style: italic;
    margin: 0 0 8px 0;
}
.sources-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 12px 0;
    columns: 2;
    column-gap: 24px;
}
.sources-content li {
    font-size: 13px;
    padding: 2px 0;
    break-inside: avoid;
}
.sources-content .meta {
    color: var(--fg-dim);
    font-size: 11px;
    margin-left: 4px;
    font-variant-numeric: tabular-nums;
}

/* ---------------- Login ---------------- */

.login-page {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-shell {
    max-width: 420px;
    background: var(--bg-card);
    padding: 32px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.login-shell h1 {
    margin: 0 0 8px 0;
    font-size: 22px;
    letter-spacing: -0.01em;
}
.login-shell .lead {
    color: var(--fg-muted);
    font-size: 14px;
    margin-bottom: 22px;
}
.login-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.login-form label {
    font-size: 13px;
    color: var(--fg-muted);
}
.login-form input[type=password] {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    background: var(--bg);
    color: var(--fg);
}
.login-form input[type=password]:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(106, 74, 42, 0.15);
}
.login-form button {
    margin-top: 6px;
    padding: 10px 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.login-form button:hover { background: var(--accent-hover); }
.login-form .error {
    margin: 6px 0 0 0;
    color: var(--error-fg);
    font-size: 13px;
}

.lead {
    color: var(--fg-muted);
    font-size: 14px;
    max-width: 720px;
}
