/* Dog Atlas: tool page (index.html) and the server-rendered breed pages
   (app/views/dog_atlas_pages/). Mobile first. Photos are never cropped: they are shown
   whole (object-fit: contain) over a blurred copy of themselves that fills the frame. */
:root {
    /* Shared navbar v2 height: seed; tt-navbar.js publishes the exact value */
    --tt-topnav-h: 64px;

    --bg: #0a0a0f;
    --bg-2: #121218;
    --card: #17171f;
    --card-hover: #1d1d27;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);

    --accent: #f59e0b;
    --accent-2: #ea580c;
    --accent-soft: rgba(245, 158, 11, 0.14);

    --text: #ffffff;
    --text-2: rgba(255, 255, 255, 0.74);
    --text-3: rgba(255, 255, 255, 0.52);

    --radius: 14px;
    --radius-sm: 8px;
    --gap: 1rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    overflow-x: clip;
}

a { color: var(--accent); }
a:hover { color: #fbbf24; }

.atlas-main {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

/* ---------- Hero ---------- */
.hero { padding: 0.75rem 0 1.25rem; }
.hero h1 {
    font-size: clamp(1.8rem, 6vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.hero h1 i { color: var(--accent); font-size: 0.85em; }
.hero-lede { color: var(--text-2); max-width: 760px; margin-top: 0.5rem; font-size: 1.02rem; }
.hero-facts { color: var(--text-3); margin-top: 0.6rem; font-size: 0.92rem; }
.hero-facts strong { color: var(--text); }
.hero-facts:empty { display: none; }

/* ---------- Filters ---------- */
.filters {
    background: rgba(10, 10, 15, 0.94);
    padding: 0.75rem 0 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.search-box { position: relative; }
.search-box i {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}
.search-box input {
    width: 100%;
    min-height: 46px;
    padding: 0.65rem 0.9rem 0.65rem 2.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-2);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}
.search-box input:focus, .filter-row select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: transparent;
}
/* Phones: two columns, nothing hidden off-screen. Wider: one wrapping row, sticky bar. */
.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.filter-row select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a1a1aa' d='M6 8 0 0h12z'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
/* Native options do not inherit the dark theme: literal colours (Rule 9) */
select option { background-color: #1a1a24; color: #ffffff; }
.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.5rem;
    min-height: 28px;
    color: var(--text-3);
    font-size: 0.88rem;
}
.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
    min-height: 44px;
    padding: 0 0.25rem;
}

/* ---------- Breed cards ---------- */
.breed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: var(--gap);
}
.breed-card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.breed-card[hidden] { display: none; }
.breed-card:hover { color: inherit; border-color: rgba(245, 158, 11, 0.45); background: var(--card-hover); }
.breed-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) {
    .breed-card:hover { transform: translateY(-2px); }
}

.card-media {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #101016;
    display: flex;
    align-items: center;
    justify-content: center;
    isolation: isolate;
}
.card-media::before,
.breed-photo-frame::before {
    content: "";
    position: absolute;
    inset: -30px;
    background-image: var(--photo, none);
    background-size: cover;
    background-position: center;
    filter: blur(22px) brightness(0.5) saturate(1.1);
    z-index: -1;
}
.card-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.card-media.no-photo i, .breed-photo.no-photo i { font-size: 2.6rem; color: rgba(255, 255, 255, 0.18); }
.card-flag {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.7);
    color: #fca5a5;
    border: 1px solid rgba(252, 165, 165, 0.35);
}
.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.85rem 0.95rem 1rem;
    flex: 1;
}
.card-name { font-size: 1.08rem; font-weight: 700; line-height: 1.25; }
.card-group, .badge {
    align-self: flex-start;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #fcd34d;
}
.card-summary {
    color: var(--text-2);
    font-size: 0.88rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.85rem;
    margin-top: auto;
    padding-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-3);
}
.card-meta i { color: var(--accent); opacity: 0.8; margin-right: 0.15rem; }

/* Group colours */
.g-herding { background: rgba(34, 197, 94, 0.14); color: #86efac; }
.g-molosser { background: rgba(239, 68, 68, 0.14); color: #fca5a5; }
.g-terrier { background: rgba(249, 115, 22, 0.15); color: #fdba74; }
.g-dachshund { background: rgba(234, 179, 8, 0.15); color: #fde047; }
.g-spitz { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.g-scenthound { background: rgba(168, 85, 247, 0.15); color: #d8b4fe; }
.g-pointer { background: rgba(20, 184, 166, 0.15); color: #5eead4; }
.g-retriever { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.g-companion { background: rgba(236, 72, 153, 0.14); color: #f9a8d4; }
.g-sighthound { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }

/* ---------- States ---------- */
.atlas-status { color: var(--text-3); text-align: center; padding: 2rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-2); }
.empty-state i { font-size: 2.5rem; color: var(--text-3); margin-bottom: 0.75rem; }
.empty-state h2 { font-size: 1.2rem; color: var(--text); margin-bottom: 0.3rem; }
.empty-state .btn-primary { margin-top: 1rem; }
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #111;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary:hover { color: #111; filter: brightness(1.08); }

.atlas-about {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.92rem;
    max-width: 860px;
}
.atlas-about h2 { font-size: 1.1rem; color: var(--text); margin-bottom: 0.6rem; }
.atlas-about p + p { margin-top: 0.6rem; }

/* ---------- Breed page ---------- */
.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    color: var(--text-3);
    margin-bottom: 1rem;
}
.crumbs a { color: var(--text-2); text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; gap: 0.35rem; }
.crumbs a:hover { color: var(--accent); }
.crumbs [aria-current] { color: var(--text); }

.breed-hero {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
    align-items: start;
}
.breed-photo { margin: 0; }
.breed-photo-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    isolation: isolate;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #101016;
    min-height: 220px;
    max-height: 72vh;
    cursor: zoom-in;
}
.breed-photo-frame img {
    display: block;
    max-width: 100%;
    max-height: 72vh;
    width: auto;
    height: auto;
    object-fit: contain;
}
.breed-photo.no-photo .breed-photo-frame { aspect-ratio: 4 / 3; cursor: default; }
.breed-photo figcaption {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-3);
    overflow-wrap: anywhere;
}
.breed-photo figcaption a { color: var(--text-2); }

.breed-intro h1 {
    font-size: clamp(1.9rem, 6vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.12;
}
.breed-aka { color: var(--text-3); margin-top: 0.35rem; font-size: 0.95rem; }
.breed-badges { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; }
.breed-badges .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
    text-decoration: none;
}
.breed-badges span.badge:not([class*="g-"]) { background: rgba(255, 255, 255, 0.07); color: var(--text-2); }
.badge-extinct { color: #fca5a5 !important; background: rgba(239, 68, 68, 0.14) !important; }
.breed-summary { font-size: 1.08rem; color: var(--text-2); margin-top: 1rem; }

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
    gap: 0.6rem;
    margin-top: 1.2rem;
}
.fact {
    display: grid;
    grid-template-columns: 1.6rem 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.4rem;
    padding: 0.7rem 0.8rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.fact i { grid-row: 1 / 3; color: var(--accent); align-self: center; font-size: 1rem; }
.fact dt { font-size: 0.74rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.fact dd { font-weight: 600; font-size: 0.95rem; }

.traits { list-style: none; display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 1rem; }
.traits li {
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fcd34d;
    font-size: 0.85rem;
}

.breed-card-block {
    margin-top: 2rem;
    padding: 1.2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.breed-card-block h2, .breed-text h2, .similar h2, .side-box h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
}
.rating-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
    gap: 0.75rem 1.5rem;
}
.rating { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.6rem; }
.rating-label { color: var(--text-2); font-size: 0.92rem; }
.rating-dots { display: inline-flex; gap: 4px; }
.rating-dots .dot { width: 18px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); }
.rating-dots .dot.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.rating-value { font-size: 0.8rem; color: var(--text-3); min-width: 2.2em; text-align: right; }

.breed-columns { display: grid; gap: 2rem; margin-top: 2rem; grid-template-columns: 1fr; }
.breed-text section + section { margin-top: 1.8rem; }
.breed-text p { color: var(--text-2); font-size: 1.02rem; line-height: 1.7; }
.breed-text p + p { margin-top: 0.8rem; }
.breed-side { display: flex; flex-direction: column; gap: 1rem; }
.side-box {
    padding: 1.1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.side-box h2 { font-size: 1rem; }
.side-box p { color: var(--text-2); font-size: 0.95rem; }
.fun-fact { border-color: rgba(245, 158, 11, 0.35); background: linear-gradient(160deg, rgba(245, 158, 11, 0.1), var(--card) 60%); }
.fun-fact h2 i { color: var(--accent); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips li {
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-2);
    font-size: 0.85rem;
}
.links { list-style: none; display: flex; flex-direction: column; }
.links a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}
.links a i { color: var(--accent); width: 1.1rem; text-align: center; }
.links a:hover { color: var(--accent); }

.similar { margin-top: 2.5rem; }
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.pager a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.92rem;
    max-width: 40%;
}
.pager a:hover { color: var(--accent); }
.pager .pager-all { color: var(--accent); font-weight: 600; max-width: none; }
.breed-foot { margin-top: 1.5rem; font-size: 0.82rem; color: var(--text-3); max-width: 860px; }
.breed-foot a { color: var(--text-2); }

.missing { text-align: center; padding-top: 4rem; }
.missing-icon { font-size: 3rem; color: var(--accent); margin-bottom: 1rem; }
.missing h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.missing p { color: var(--text-2); margin-bottom: 1.25rem; }

/* ---------- Larger screens ---------- */
@media (min-width: 700px) {
    .atlas-main { padding: 1.75rem 1.5rem 4rem; }
    .filters {
        position: sticky;
        top: var(--tt-topnav-h, 64px);
        z-index: 50;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
    .filter-row { display: flex; flex-wrap: wrap; }
    .filter-row select { width: auto; max-width: 240px; }
    .breed-grid { gap: 1.15rem; }
}
@media (min-width: 900px) {
    .breed-hero { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 2.25rem; }
    .breed-columns { grid-template-columns: minmax(0, 1fr) 320px; gap: 2.5rem; }
    .breed-side { position: sticky; top: calc(var(--tt-topnav-h, 64px) + 1rem); }
}
@media (max-width: 420px) {
    .atlas-main { padding-left: 0.75rem; padding-right: 0.75rem; }
    .pager a:not(.pager-all) { font-size: 0.84rem; }
}
@media (prefers-reduced-motion: reduce) {
    .breed-card { transition: none; }
    .breed-card:hover { transform: none; }
}
