/* CannaDB Phase 2 stylesheet — hand-rolled, intentionally minimal.
 * Design language: information service, not storefront. */

:root {
    --bg: #fafaf7;
    --bg-elev: #ffffff;
    --fg: #1d1d1b;
    --fg-muted: #555;
    --fg-faint: #888;
    --accent: #2f6b3a;
    --accent-fg: #fff;
    --border: #e3e1d6;
    --border-strong: #c4c0b1;
    --community-bg: #fff7e0;
    --community-border: #d4b86a;
    --editorial-bg: #e8f1ea;
    --editorial-border: #6b9572;
    --max-width: 72rem;
    --radius: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--fg);
    background: var(--bg);
    line-height: 1.55;
    font-size: 16px;
}

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

h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 1.5em 0 0.6em; }
h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

code, kbd, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.92em; }
pre { background: var(--bg-elev); border: 1px solid var(--border); padding: 0.75rem 1rem; border-radius: var(--radius); overflow-x: auto; }

/* ─── Site chrome ───────────────────────────────────────────── */

.site-header {
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
    color: var(--fg);
}
.brand:hover { text-decoration: none; color: var(--accent); }

.search-form {
    flex: 1;
    min-width: 14rem;
    max-width: 28rem;
    position: relative;
    display: flex;
    gap: 0.4rem;
}
.search-form input[type="search"] {
    flex: 1;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--bg);
}
.search-form button {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-fg);
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
}
.search-form button:hover { background: #244e2c; border-color: #244e2c; }

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
    max-height: 22rem;
    overflow-y: auto;
}
.search-suggestions:empty { display: none; }
.search-suggestions a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--fg);
}
.search-suggestions a:last-child { border-bottom: none; }
.search-suggestions a:hover { background: var(--bg); text-decoration: none; }
.search-suggestions .suggest-meta { color: var(--fg-faint); font-size: 0.85em; }

.primary-nav { display: flex; gap: 1rem; }
.primary-nav a { color: var(--fg-muted); }
.primary-nav a:hover { color: var(--accent); }

.site-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 4rem;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-elev);
    margin-top: 3rem;
    color: var(--fg-muted);
    font-size: 0.9rem;
}
.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* ─── Hero & rails ──────────────────────────────────────────── */

.hero { padding: 1.5rem 0; }
.hero h1 { font-size: 2.4rem; }
.hero .lede { font-size: 1.1rem; max-width: 50rem; color: var(--fg-muted); }

.rail { margin: 2.5rem 0; }
.rail-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.6rem; }
.rail-header h2 { margin: 0; }
.rail-link { font-size: 0.9rem; color: var(--fg-muted); }

.empty { color: var(--fg-faint); font-style: italic; }

/* ─── Cards ─────────────────────────────────────────────────── */

.card-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: 0.85rem;
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
}
.card.community-card { background: var(--community-bg); }
.card-title { margin: 0 0 0.25rem; font-size: 1.05rem; }
.card-meta { display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.35rem; }
.card-byline { color: var(--fg-muted); font-size: 0.92rem; margin: 0.1rem 0; }
.card-excerpt { color: var(--fg-muted); margin: 0.3rem 0 0; font-size: 0.92rem; }

/* ─── Badges ────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 500;
}
.badge-editorial { background: var(--editorial-bg); border-color: var(--editorial-border); color: #2c4530; }
.badge-community { background: var(--community-bg); border-color: var(--community-border); color: #715216; }

.kind {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    color: var(--fg-muted);
}
.kind-cut { color: #6b3a2f; border-color: #c8a89c; background: #f6ebe6; }

/* ─── Strain page ───────────────────────────────────────────── */

.strain-page header h1 { margin-bottom: 0.2rem; }
.strain-page .subtitle { color: var(--fg-muted); margin: 0; }
.strain-page .publisher {
    margin-top: 0.5rem;
    color: var(--fg-faint);
    font-size: 0.9rem;
}
.strain-page .publisher code { background: var(--bg-elev); padding: 0.05em 0.3em; border-radius: var(--radius); border: 1px solid var(--border); }

.fact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.6rem 1.4rem;
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.fact dt { font-size: 0.75rem; color: var(--fg-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.fact dd { margin: 0.1rem 0 0; }

.chip-list { list-style: none; padding: 0; margin: 0.3rem 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.markdown { line-height: 1.65; }
.markdown p { margin: 0.7em 0; }
.markdown ul, .markdown ol { padding-left: 1.4em; }
.markdown a { word-break: break-word; }

.relation-list { list-style: none; padding: 0; }
.relation-list li { padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.relation-list li:last-child { border-bottom: none; }
.relation-list .name-fallback { color: var(--fg-muted); }

details.raw-record { margin-top: 2rem; }
details.raw-record summary { cursor: pointer; color: var(--fg-muted); font-size: 0.9rem; }
details.raw-record pre { margin-top: 0.5rem; }

/* ─── Lineage page ──────────────────────────────────────────── */

.lineage-page .lineage-cols {
    display: grid;
    grid-template-columns: 18rem 1fr;
    gap: 1.5rem;
}
@media (max-width: 60rem) {
    .lineage-page .lineage-cols { grid-template-columns: 1fr; }
}

.lineage-tree {
    list-style: none;
    padding-left: 0;
    border-left: 1px solid var(--border);
}
.lineage-tree ul { padding-left: 1.2rem; border-left: 1px solid var(--border); }
.lineage-tree li { padding: 0.15rem 0 0.15rem 0.6rem; position: relative; }
.lineage-tree li::before {
    content: "↳";
    color: var(--fg-faint);
    position: absolute;
    left: -0.7rem;
}
.lineage-tree .root-marker { font-weight: 600; }

#cyto {
    width: 100%;
    height: 32rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ─── Lists / tables ────────────────────────────────────────── */

.list-page .list-controls {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 0 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.list-page .list-controls form { display: flex; gap: 0.5rem; align-items: center; }
.list-page .pagination { margin-top: 1rem; display: flex; gap: 1rem; }

.search-results { list-style: none; padding: 0; margin: 0; }
.search-results > li { margin: 0 0 0.7rem; }
.search-results .similarity { color: var(--fg-faint); font-size: 0.8rem; }

.error-page { text-align: center; padding: 3rem 1rem; }
.error-page h1 { font-size: 1.6rem; }
