/* Ornitopedie layout. Colours come only from the semantic tokens in tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.55;
    overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); margin: 0 0 .4rem; }
h2 { font-size: 1.45rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1.15rem; margin: 1.2rem 0 .4rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-deep); }
img { max-width: 100%; height: auto; display: block; }
.muted { color: var(--ink-soft); }
.latin { font-style: italic; color: var(--ink-soft); margin: 0; }
.lead { font-size: 1.15rem; color: var(--ink-soft); }
.page { max-width: var(--max); margin: 0 auto; padding: 1.5rem 16px 3rem; }
.prose { max-width: 820px; }

/* app bar */
.mud-appbar.app-bar { background: var(--appbar) !important; color: var(--on-dark) !important; }
.mud-appbar .mud-toolbar { gap: .5rem; max-width: var(--max); margin: 0 auto; width: 100%; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--on-dark); text-decoration: none; min-height: 44px; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; }
.brand-mark { display: inline-flex; color: var(--accent-2); }
.app-bar-links { display: flex; gap: .25rem; }
.app-bar-links a { color: var(--on-dark); text-decoration: none; padding: .55rem .8rem; border-radius: var(--radius); min-height: 44px; display: inline-flex; align-items: center; }
.app-bar-links a:hover, .app-bar-links a.active { background: rgba(255, 255, 255, .14); }
.app-bar-search { width: min(320px, 30vw); }
.app-bar-search .mud-input-outlined-border { border-color: rgba(255, 255, 255, .35); }
.app-bar-search input { color: var(--on-dark); }
.app-bar-burger, .app-bar-search-icon { display: none !important; }

@media (max-width: 899px) {
    .app-bar-links, .app-bar-search { display: none; }
    .app-bar-burger, .app-bar-search-icon { display: inline-flex !important; }
}

/* hero */
.hero { padding: 1rem 0 1.5rem; }
.search-box-hero { max-width: 560px; }
.search-item { display: flex; flex-direction: column; padding: .15rem 0; }
.search-item-cz { font-weight: 600; }
.search-item-la { font-style: italic; color: var(--ink-soft); font-size: .9rem; }

/* home layout */
.home-layout { display: grid; grid-template-columns: 300px 1fr; gap: 2rem; align-items: start; }
.home-filter { position: sticky; top: 76px; }
.filter-toggle { display: none; }
.filter-panel { background: var(--surface); border: 1px solid var(--paper-3); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow-sm); }
.filter-head { display: flex; justify-content: space-between; align-items: baseline; }
.filter-head h2 { margin: 0 0 .5rem; font-size: 1.2rem; }
.filter-group h3 { font-family: var(--sans); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin: .9rem 0 .4rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
    display: inline-flex; align-items: center; gap: .4rem;
    min-height: 40px; padding: .3rem .8rem;
    background: var(--paper); color: var(--ink);
    border: 1px solid var(--paper-3); border-radius: 999px;
    font: inherit; font-size: .92rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.chip-month { min-width: 48px; justify-content: center; padding: .3rem .5rem; }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--paper-3); flex: none; }
.link-btn { background: none; border: 0; padding: .5rem 0; min-height: 40px; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.btn { min-height: 40px; padding: .4rem 1rem; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent); color: var(--surface); font: inherit; cursor: pointer; }

@media (max-width: 899px) {
    .home-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
    .home-filter { position: static; }
    .filter-toggle {
        display: flex; width: 100%; min-height: 44px; align-items: center; padding: .5rem 1rem;
        background: var(--surface); color: var(--ink); border: 1px solid var(--paper-3); border-radius: var(--radius);
        font: inherit; font-weight: 600; cursor: pointer;
    }
    .filter-body { display: none; margin-top: .5rem; }
    .filter-body.open { display: block; }
}

/* species grid and card */
.result-count { color: var(--ink-soft); margin: 0 0 .75rem; }
.species-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.species-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--paper-3); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; }
.species-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); color: var(--ink); }
.species-card-photo { aspect-ratio: 4 / 3; background: var(--paper-2); overflow: hidden; }
.species-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.species-card-placeholder { height: 100%; display: grid; place-items: center; font-family: var(--serif); font-size: 3rem; color: var(--ink-soft); }
.species-card-body { padding: .75rem 1rem 1rem; }
.species-card-body h3 { margin: 0; font-size: 1.15rem; }
.species-card-body .tagline { margin: .35rem 0 0; font-size: .92rem; color: var(--ink-soft); }
.empty { padding: 2rem 0; color: var(--ink-soft); }

/* detail */
.crumbs { font-size: .9rem; color: var(--ink-soft); margin-bottom: .5rem; }
.species-top { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 2rem; margin-top: 1rem; align-items: start; }
.gallery, .facts-card { min-width: 0; }
.gallery-main { margin: 0; background: var(--paper-2); border-radius: var(--radius); overflow: hidden; min-height: 200px; }
.gallery-main.loading { display: grid; place-items: center; color: var(--ink-soft); min-height: 260px; }
.gallery-main img { width: 100%; max-height: 520px; object-fit: contain; background: var(--paper-2); }
.gallery-main figcaption { padding: .5rem .75rem; font-size: .82rem; color: var(--ink-soft); background: var(--surface); border-top: 1px solid var(--paper-3); }
.gallery-thumbs { display: flex; gap: .5rem; overflow-x: auto; padding: .6rem 0; }
.thumb { flex: none; width: 80px; height: 60px; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; background: var(--paper-2); cursor: pointer; }
.thumb[aria-pressed="true"] { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.facts-card, .fact-panel, .sounds, .nesting, .reel-facts, .lookalikes, .wiki {
    background: var(--surface); border: 1px solid var(--paper-3); border-radius: var(--radius);
    padding: 1rem 1.25rem; margin-top: 1.25rem; box-shadow: var(--shadow-sm);
}
.facts-card { margin-top: 0; }
.facts-card h2, .fact-panel h2, .sounds h2, .nesting h2, .reel-facts h2, .lookalikes h2, .wiki h2 { margin-top: 0; }
.attrs { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.attrs dt { color: var(--ink-soft); }
.attrs dd { margin: 0; }
.tag { display: inline-flex; align-items: center; gap: .35rem; margin: 0 .35rem .35rem 0; padding: .1rem .6rem; border-radius: 999px; background: var(--accent-tint); font-size: .9rem; text-decoration: none; }
.note { background: var(--accent-tint); border-left: 4px solid var(--accent-2); padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1rem 0; }
.recordings { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.recordings audio { width: 100%; margin: .4rem 0 .2rem; }
.rec-credit { font-size: .85rem; color: var(--ink-soft); }
.decisive { font-weight: 600; }
.credit { font-size: .85rem; color: var(--ink-soft); }
.reel-facts li { margin-bottom: .35rem; }

/* calendar */
.calendar { display: grid; gap: 4px; font-size: .75rem; }
.cal-row { display: grid; grid-template-columns: 4.5rem repeat(12, 1fr); gap: 3px; align-items: center; }
.cal-cell { height: 18px; border-radius: 3px; background: var(--paper-2); text-align: center; line-height: 18px; color: var(--ink-soft); }
.cal-months .cal-cell { background: none; height: auto; }
.cal-cell.seen { background: var(--accent); }
.cal-cell.song { background: var(--accent-2); }
.cal-cell.nest { background: var(--accent-3); }
.cal-label { color: var(--ink-soft); }

@media (max-width: 899px) {
    .species-top { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
}

/* tables: scroll inside the container on wide, one card per row on a phone */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.data-table th, .data-table td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--paper-3); vertical-align: top; }
.data-table th { background: var(--paper-2); font-size: .85rem; }
@media (max-width: 640px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { margin-bottom: .75rem; border: 1px solid var(--paper-3); border-radius: var(--radius); }
    .data-table td { border: 0; padding: .3rem .75rem; }
    .data-table td::before { content: attr(data-label) ": "; color: var(--ink-soft); font-size: .85rem; }
}

/* logs */
.log-filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.log-filters label { display: grid; gap: .2rem; font-size: .85rem; color: var(--ink-soft); }
.log-filters select, .log-filters input { min-height: 40px; padding: .3rem .6rem; background: var(--surface); color: var(--ink); border: 1px solid var(--paper-3); border-radius: var(--radius); font: inherit; }
.log-table pre, .log-tail { white-space: pre-wrap; word-break: break-word; font-size: .8rem; margin: .3rem 0 0; }
.log-tail { background: var(--surface); border: 1px solid var(--paper-3); padding: .75rem; max-height: 480px; overflow: auto; }
.lvl-error td, .lvl-fatal td { color: var(--bad); }
.lvl-warning td { color: var(--accent-2-ink); }

/* footer */
.site-footer { background: var(--paper-2); border-top: 1px solid var(--paper-3); margin-top: 2rem; padding: 1.5rem 16px; font-size: .88rem; color: var(--ink-soft); }
.site-footer-inner { max-width: var(--max); margin: 0 auto; display: grid; gap: .75rem; }
.site-footer ul { margin: 0; padding-left: 1.1rem; }
.site-footer-admin { display: inline; }
.site-footer-admin button { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; padding: .5rem 0; }

/* errors */
#blazor-error-ui { display: none; position: fixed; inset: auto 0 0 0; background: var(--bad); color: #fff; padding: .75rem 1rem; z-index: 2000; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
#blazor-error-ui a { color: #fff; }

/* --- fact panel and badges ------------------------------------------ */
.fact-panel { min-width: 0; }
.fact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: .75rem; margin: 0; }
.fact { min-width: 0; padding: .7rem .85rem; border: 1px solid var(--paper-3); border-radius: 10px; background: var(--paper); }
.fact dt { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .25rem; }
.fact dd { margin: 0; display: flex; flex-direction: column; gap: .2rem; overflow-wrap: anywhere; }
.fact strong { font-size: 1.05rem; }
.fact strong.risk { color: var(--bad-ink); }
.fact-sub { font-size: .9rem; color: var(--ink-soft); }
.fact-src { font-size: .8rem; color: var(--ink-soft); }
.fact-src a { color: inherit; }
.fact-missing { color: var(--ink-soft); font-style: italic; }
.badge-risk { display: inline-block; margin-top: .3rem; padding: .05rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bad); color: #fff; }
