:root {
    --primary: #b5654a;
    --primary-dark: #8f4d37;
    --bg: #fdf8f4;
    --card-bg: #ffffff;
    --text: #33261f;
    --muted: #7a6a60;
    --border: #e7dcd3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Random per-page background image (see BackgroundImageService), dimmed with
   a dark overlay so text stays readable regardless of the photo, and scaled
   to always cover the full viewport. */
body.has-page-background {
    background-image:
        linear-gradient(rgba(20, 14, 10, 0.62), rgba(20, 14, 10, 0.62)),
        var(--page-background-image);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 30;
}

body.has-page-background .site-header {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(6px);
    border-bottom-color: rgba(255, 255, 255, 0.4);
}

body.has-page-background .site-footer {
    color: rgba(255, 255, 255, 0.85);
    border-top-color: rgba(255, 255, 255, 0.25);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}

.logo {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-dark);
    text-decoration: none;
}

.main-nav a {
    margin-left: 1.25rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.main-nav a:hover {
    color: var(--primary);
}

.main-nav {
    display: inline-flex;
    align-items: center;
}

.nav-item {
    position: relative;
    display: inline-block;
}

.nav-item .submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 1.25rem;
    min-width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(51, 38, 31, 0.15);
    padding: 0.4rem 0;
    z-index: 20;
}

.nav-item:hover .submenu,
.nav-item:focus-within .submenu {
    display: block;
}

.nav-item .submenu a {
    display: block;
    margin: 0;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    font-weight: 500;
}

.nav-item .submenu a:hover {
    background: var(--bg);
}

.submenu-divider {
    display: block;
    padding: 0.5rem 1rem 0.15rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    border-top: 1px solid var(--border);
    margin-top: 0.3rem;
}

.submenu-divider:first-child {
    border-top: none;
    margin-top: 0;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 5px;
    width: 2.2rem;
    height: 2.2rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

.submenu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
}

.page-content {
    padding: 2rem 1.25rem 4rem;
    min-height: 60vh;
}

/* Keeps text readable over any photo, while still letting the dimmed image
   tint through - the panel is translucent, not solid. */
body.has-page-background .page-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    border-radius: 14px;
    margin: 1.5rem auto 2.5rem;
    padding: 2rem 1.75rem 3rem;
    box-shadow: 0 14px 45px rgba(0, 0, 0, 0.3);
}

.frontpage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.frontpage-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.frontpage-box h2 {
    margin-top: 0;
}

@media (max-width: 900px) {
    .frontpage-grid {
        grid-template-columns: 1fr;
    }
}

.hero {
    text-align: center;
    padding: 3rem 1rem;
}

.hero.frontpage-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero h1 {
    font-size: 2.4rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.section {
    margin: 3rem 0;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.cat-group-heading {
    margin-top: 2.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--primary);
    color: var(--primary-dark);
}

.cat-group-heading:first-of-type {
    margin-top: 1.5rem;
}

.cat-group-heading .muted {
    font-weight: 400;
    font-size: 0.85em;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.card .img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    border: 1px dashed var(--border);
    background: #f6f0ec;
    color: var(--muted);
    font-size: 0.85rem;
}

.card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.status-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: #efe4dc;
    color: var(--primary-dark);
    margin-top: 0.4rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: var(--card-bg);
}

.results-table th, .results-table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.results-table th {
    background: #f3e9e2;
    color: var(--primary-dark);
}

/* Highlights a result that includes a Best in Show style placement (BIS/BOX/BOB). */
.result-gold {
    color: #b8860b;
    font-weight: 600;
}

.career-stats-table {
    margin-bottom: 1.5rem;
}

.career-stats-table caption {
    text-align: left;
    font-weight: 600;
    color: var(--primary-dark);
    padding-bottom: 0.4rem;
}

.career-stats-table th, .career-stats-table td {
    text-align: center;
}

.career-stats-table th:first-child, .career-stats-table td:first-child {
    text-align: left;
}

.tabs {
    margin-top: 1.5rem;
}

.tab-list {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    font: inherit;
    font-weight: 600;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.6rem 1rem;
    cursor: pointer;
}

.tab-btn:hover { color: var(--primary-dark); }

.tab-btn.is-active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

.tab-panels {
    height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-top: none;
    background: var(--card-bg);
    padding: 0 0.75rem;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.tab-panel .results-table { margin-top: 0.75rem; }
.tab-panel > p.muted { padding: 1rem 0; }

.offspring-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
}

.offspring-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.offspring-list li:last-child { border-bottom: none; }

.offspring-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.offspring-meta {
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.results-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0 0.5rem;
}

.grouping-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.year-filter-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.year-filter-form select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--text);
}

.grouping-toggle-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.toggle-link {
    display: inline-block;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: #f3e9e2;
    color: var(--primary-dark);
    text-decoration: none;
    font-size: 0.9rem;
}

.toggle-link:hover {
    background: #ecdccf;
}

.toggle-link.active {
    background: var(--primary);
    color: white;
}

.results-group {
    margin-top: 2rem;
}

.results-group h2 {
    color: var(--primary-dark);
    font-size: 1.15rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.5rem;
}

.cat-detail {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 2rem;
}

.cat-detail-media img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 10px;
}

.cat-detail-media-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--muted);
    background: #f6f0ec;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.gallery img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
}

.fact-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    margin: 1rem 0;
}

.fact-list dt { color: var(--muted); }
.fact-list dd { margin: 0; }

.pedigree-name { font-style: italic; color: var(--muted); }
.titles { font-weight: 600; color: var(--primary-dark); }

.mating-heart { color: #c65a5a; }

.neutered-badge {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.8rem;
}

.litter-block {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.contact-form {
    max-width: 560px;
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.form-group input, .form-group textarea {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
}

.field-error {
    color: #b3261e;
    font-size: 0.85rem;
}

.honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.btn-primary:hover { background: var(--primary-dark); }

.alert {
    padding: 0.9rem 1.1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #e5f4e8;
    color: #1e6b34;
    border: 1px solid #b9e0c3;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; justify-content: space-between; }
    .nav-toggle { display: flex; }

    .main-nav {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        margin-top: 0.75rem;
    }
    .main-nav.is-open { display: flex; }
    .main-nav a { margin: 0; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }

    .nav-item {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }
    .nav-item > a { flex: 1; border-bottom: none; }
    .submenu-toggle { display: inline-flex; }

    .nav-item .submenu {
        display: none;
        position: static;
        box-shadow: none;
        border: none;
        padding: 0 0 0 1rem;
        margin: 0;
        min-width: 0;
        width: 100%;
        border-bottom: 1px solid var(--border);
    }
    .nav-item.is-open .submenu { display: block; }
    .nav-item .submenu a { border-bottom: 1px solid var(--border); }
    .nav-item .submenu a:last-child { border-bottom: none; }

    .cat-detail { grid-template-columns: 1fr; }

    .cat-detail-media img,
    .cat-detail-media-placeholder {
        width: 25%;
        display: block;
        margin: 0;
    }

    .results-table, .career-stats-table, .admin-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .gallery { grid-template-columns: repeat(2, 1fr); }

    .tab-list { flex-wrap: wrap; }
}

.litter-photo {
    width: 100%;
    max-width: 480px;
    border-radius: 10px;
    margin: 0.5rem 0 1rem;
    display: block;
}

.litter-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    margin: 0.5rem 0 1rem;
    border: 1px dashed var(--border);
    background: #f6f0ec;
    color: var(--muted);
}

/* Stand-in litter photo, stitched together from the kittens' own pictures when the litter has no main image of its own. */
.litter-collage {
    position: relative;
    display: grid;
    gap: 3px;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--border);
}

.litter-collage .collage-cell { overflow: hidden; }

.litter-collage img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 0;
}

.litter-collage-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }

.litter-collage-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.litter-collage-3 .collage-cell:first-child { grid-row: 1 / 3; }

.litter-collage-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.collage-more-badge {
    position: absolute;
    right: 10px;
    bottom: 10px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Slideshow for a cat's attached photos (see slideshow.js). */
.slideshow {
    position: relative;
    margin-top: 0.75rem;
}

.slideshow-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    background: var(--card-bg);
}

.slideshow-slide {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease;
}

.slideshow-slide.is-active {
    opacity: 1;
    visibility: visible;
}

.slideshow-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.slideshow-slide figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.5rem 0.75rem;
    background: rgba(20, 14, 10, 0.55);
    color: #fff;
    font-size: 0.85rem;
}

.slideshow-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 14, 10, 0.45);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.slideshow-btn:hover {
    background: rgba(20, 14, 10, 0.7);
}

.slideshow-prev { left: 0.5rem; }
.slideshow-next { right: 0.5rem; }

.slideshow-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.slideshow-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    border: none;
    background: var(--border);
    cursor: pointer;
    padding: 0;
}

.slideshow-dot.is-active {
    background: var(--primary);
}
