/* BreederMate web client. Mobile-first: single column by default, form
   fields flow into columns as width allows. Wide content (the pedigree
   grid) scrolls inside its own box rather than the page. */

:root {
    --bg: #fbfaf8;
    --surface: #ffffff;
    --text: #1f2328;
    --muted: #656d76;
    --border: #d8dee4;
    --accent: #2f6f5e;
    --accent-text: #ffffff;
    --danger: #b42318;
    --notice-bg: #e7f4ee;
    --error-bg: #fdecea;
    --sire: #eaf2fb;
    --dam: #fbeef3;
    --radius: 6px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181b;
        --surface: #1e2125;
        --text: #e6e8eb;
        --muted: #9aa3ad;
        --border: #363b42;
        --accent: #5fb39b;
        --accent-text: #0e1513;
        --danger: #f2877d;
        --notice-bg: #1d3a30;
        --error-bg: #42201d;
        --sire: #1d2a38;
        --dam: #382331;
    }
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
    max-width: 72rem;
    margin: 0 auto;
    padding: 1rem;
}

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

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.site-header .brand { margin-right: auto; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; order: 3; width: 100%; }
.site-header .logout { display: inline; }
@media (min-width: 48rem) {
    .site-header nav { order: 0; width: auto; }
}

section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
section section { border: none; padding: 0; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; margin-top: 0; }

.muted { color: var(--muted); }
.error, .notice {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
}
.error { background: var(--error-bg); color: var(--danger); }
.notice { background: var(--notice-bg); }
.examples-offer { margin-bottom: 1rem; }
.access-notice { margin-bottom: 1rem; }
.access-notice p { margin: 0; }
.access-line { margin: 0 0 1rem; font-size: 0.9rem; }
.subscription-state { margin-bottom: 1.5rem; }
.subscription-state p { margin: 0; }
.plans { padding-left: 1.25rem; }
.plans li { margin-bottom: 0.5rem; }
.examples-offer p { margin-top: 0; }

input, select, textarea, button {
    font: inherit;
    color: inherit;
}
input, select, textarea {
    width: 100%;
    min-width: 0;
    padding: 0.4rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
button {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-text);
    cursor: pointer;
}
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.danger-link { color: var(--danger); }
.delete-subscription { margin: 1rem 0; }
.delete-subscription h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.delete-subscription p + p { margin-top: 0.5rem; }
.delete-account { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1.5rem; }

.record-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.record-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.record-list li:last-child { border-bottom: none; }

.quick-add {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
@media (min-width: 40rem) {
    .quick-add { grid-template-columns: 2fr 1fr 1fr auto; }
}

.record-form fieldset {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0 0 1rem;
    padding: 0.75rem;
    /* fieldsets default to min-width: min-content, which stops the grid
       shrinking and pushes the page wider than a phone screen. */
    min-width: 0;
}
.record-form legend { font-weight: 600; padding: 0 0.25rem; }
.record-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.record-form label.wide { grid-column: 1 / -1; }
.record-form .actions { margin-bottom: 1rem; }

/* Wraps a record form's fields so sample mode can disable them all at once
   (a record of the user's own, view only); it adds no box of its own. */
fieldset.form-lock, .record-form fieldset.form-lock { display: contents; }
.form-lock:disabled :is(input, select, textarea) {
    color: inherit;
    -webkit-text-fill-color: currentColor; /* Safari greys disabled text */
    opacity: 1;
    background: transparent;
    border-style: dashed;
}
.form-lock:disabled ::placeholder { color: transparent; }
.form-lock:disabled button { display: none; }
.sample-note { margin: 0.5rem 0 1rem; }

.kitten-rows { grid-template-columns: 1fr !important; }
.kitten-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
@media (min-width: 40rem) {
    .kitten-row { grid-template-columns: 2fr 1fr 2fr; }
}

details > summary { cursor: pointer; font-weight: 600; margin-bottom: 0.75rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Ancestor entry: the traditional pedigree table, one column per
   generation. Sire lines are tinted blue and dam lines pink, as Pedigree
   Assistant's gender-based ancestor colours are. */
.pedigree-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pedigree-grid {
    border-collapse: collapse;
    min-width: 44rem;
    width: 100%;
}
.pedigree-grid th {
    text-align: left;
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0.25rem 0.5rem;
}
.pedigree-grid td {
    border: 1px solid var(--border);
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
}
.pedigree-grid td.sire { background: var(--sire); }
.pedigree-grid td.dam { background: var(--dam); }
.pedigree-grid input { background: var(--surface); }
.pedigree-grid .open-link { font-size: 0.8rem; }

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

.button-link {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    text-decoration: none;
}

button.secondary { background: transparent; color: var(--accent); }
button.small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
input[type="checkbox"], input[type="radio"] { width: auto; }
.record-form label.inline { flex-direction: row; align-items: center; gap: 0.4rem; }
.record-form .wide { grid-column: 1 / -1; }
.record-form p.wide { margin: 0; font-size: 0.85rem; }

/* --- photos --- */

.photo-grid {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 0.75rem;
}
.photo-grid li { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.photo-grid li.primary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.photo-grid img { display: block; width: 100%; height: 9rem; object-fit: cover; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; justify-content: space-between; padding: 0.4rem; }
.badge { font-size: 0.8rem; font-weight: 600; color: var(--accent); }
.upload-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.upload-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; flex: 1 1 14rem; }

/* --- share links --- */

.copy-row { display: flex; gap: 0.4rem; align-items: center; }
.copy-row input { flex: 1 1 auto; font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
.copy-row button { flex: none; }
.share-list li { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.6rem 0; }
.share-list .muted { font-size: 0.85rem; }
.notice p { margin: 0 0 0.5rem; }

/* --- certificate style: font samples (stacks match certificate.css) --- */

.font-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.6rem; }
.record-form label.font-choice {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.1rem 0.5rem;
    align-items: center;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}
.font-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.font-choice input { grid-row: span 2; }
.font-choice .sample-heading { font-size: 1.35rem; line-height: 1.2; }
.font-choice .sample-text { font-size: 0.85rem; color: var(--muted); }
.font-classic { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
.font-classic .sample-heading { font-family: "Snell Roundhand", "Apple Chancery", "Monotype Corsiva", "URW Chancery L", cursive; }
.font-traditional { font-family: Baskerville, "Baskerville Old Face", "Libre Baskerville", Georgia, serif; }
.font-traditional .sample-heading { font-family: "Savoye LET", "Apple Chancery", "Monotype Corsiva", "URW Chancery L", cursive; }
.font-elegant { font-family: Didot, "Bodoni 72", "Bodoni MT", "Didot LT STD", "Times New Roman", serif; }
.font-elegant .sample-heading { font-style: italic; }
.font-modern { font-family: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
.font-modern .sample-heading { font-size: 1rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; }
.logo-preview { display: block; max-width: 14rem; max-height: 6rem; margin-bottom: 0.5rem; background: #fff; padding: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius); }

/* Inbreeding: the animal page's section and the inbreeding table. */
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.inline-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1rem; }
.data-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table thead th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.data-table tbody th { font-weight: normal; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table .loop { color: var(--danger); }
/* The names and figures have to fit a phone without scrolling sideways. */
#mate-table thead .num { white-space: normal; }

.export-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Record list: search, view, filters, saved searches and results. On a
   phone the results table becomes one block per animal, each value
   labelled with its column. */
.search-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; margin-bottom: 0.5rem; }
.search-bar input[type="search"] { flex: 1 1 16rem; }
.search-bar .view-select { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; flex: 1 1 12rem; max-width: 18rem; }
.filters { margin-bottom: 0.25rem; }
.filters summary { margin-bottom: 0.5rem; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.6rem; }
.filter-grid label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
.filter-help { font-size: 0.85rem; margin: 0.5rem 0 0; }
.search-actions { margin: 0.25rem 0 0.75rem; font-size: 0.9rem; }
.saved-searches { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; margin-bottom: 0.75rem; }
.saved-searches label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; flex: 1 1 12rem; max-width: 20rem; }
.save-search { display: flex; gap: 0.4rem; flex: 1 1 16rem; max-width: 26rem; }
.save-search input { flex: 1 1 auto; }
.save-search button { flex: none; }
.related-heading { margin-top: 0; }
.result-count { margin: 0 0 0.25rem; font-size: 0.9rem; }
.results-table th a { color: inherit; text-decoration: none; white-space: nowrap; }
.results-table th a:hover { text-decoration: underline; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.related-links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
.list-search { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.list-search input { flex: 1 1 12rem; }
.list-search select { flex: 0 1 10rem; width: auto; }
@media (max-width: 40rem) {
    .results-table thead { display: none; }
    .results-table, .results-table tbody, .results-table tr, .results-table td { display: block; width: 100%; }
    .results-table tr { padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
    .results-table td { border: none; padding: 0.05rem 0; }
    .results-table td:not(.name-cell):empty { display: none; }
    .results-table td:not(.name-cell)::before { content: attr(data-label) ": "; color: var(--muted); }
    .results-table td.name-cell { font-weight: 600; }
}

/* Checks, similar names and record history. */
.check-group h3 { margin-bottom: 0.25rem; }
.check-group .record-list li { display: flex; flex-wrap: wrap; gap: 0.15rem 0.5rem; }
.similar-search { margin-top: 1.5rem; }
.similar-search .search-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.similar-search .search-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.similar-search input[type="search"] { min-width: 14rem; }
.similar-search input[type="number"] { width: 5rem; }
#breeder-owner .wide { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.history { margin: 1rem 0; }
.history summary { cursor: pointer; font-weight: 600; }
.history-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.history-list > li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.history-list > li:last-child { border-bottom: none; }
.history-list ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.history-list li li { overflow-wrap: anywhere; }
.history-list del { color: var(--muted); }
.history-list ins { text-decoration: none; }
