/* BOEF'S BOX - MAIN CSS */

/* --- BASE SETUP --- */
:root {
    --primary-action: #28766f;
    --primary-hover: #1d5d57;
    --ink: #243e3b;
    --muted: #687a75;
    --paper: #fffefa;
    --background: #f7f7f0;
    --bg-color: var(--background);
    --text-color: var(--ink);
    --line: #e2e8df;
    --sand: #f5e7c9;
    --mint: #e6f0e9;
    --radius: 20px;
    --shadow: 0 5px 20px rgba(36, 62, 59, 0.035);

    font-family: ui-rounded, 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ink);
    background: var(--background);
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
}

button, input, select, textarea {
    font: inherit;
}

button, summary, label.file-upload {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--primary-action);
    text-underline-offset: 3px;
}

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

button, select, summary {
    cursor: pointer;
}

/* --- GLOBAL BUTTONS & FONTS --- */
button {
    border: 0;
    border-radius: 12px;
    background: var(--primary-action);
    color: white;
    padding: 0.8rem 1.15rem;
    font-weight: 650;
    line-height: 1.4;
    min-height: 44px;
    transition: background 150ms ease, transform 150ms ease;
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.55;
    cursor: wait;
    transform: none;
}

:focus-visible {
    outline: 3px solid #b68a3d;
    outline-offset: 4px;
}

h1, h2, h3 {
    line-height: 1.25;
    letter-spacing: -0.025em;
}

h2 {
    margin: 0 0 1rem;
    font-size: clamp(1.3rem, 3vw, 1.65rem);
    font-weight: 700;
}

h3 {
    margin-top: 0;
}

p {
    overflow-wrap: anywhere;
}

/* --- HEADER & MAIN LAYOUT STRUCTURE --- */
.hero {
    box-sizing: border-box;
    min-height: 420px;
    padding: 3rem 1.25rem;
    display: grid;
    place-items: center;
    text-align: center;
    background-color: #476951;
    background-image:
        linear-gradient(
            rgba(12, 36, 30, 0.55),
            rgba(12, 36, 30, 0.45)
        ),
        url("/images/boefGrassSniff.jpg");
    background-size: cover;
    background-position: center 30%;
    background-repeat: no-repeat;
    position: relative;
    border-bottom: 1px solid #d9e6e2;
    border-radius: 0 0 36px 36px;
}

.hero-content {
    width: 100%;
    max-width: 700px;
}

.hero h1 {
    margin: 0 0 1rem;
    color: #fff;
    font-size: clamp(1.7rem, 4.6vw, 2.8rem);
    font-weight: 750;
    line-height: 1.15;
    text-wrap: balance;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.65);
}

.hero p {
    color: #fff;
    line-height: 1.65;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

.hero > p {
    max-width: 740px;
    margin-left: auto !important;
    margin-right: auto !important;
}

.hero-intro {
    margin: 0 auto 1rem;
    max-width: 620px;
    font-size: 1.1rem;
}

.hero-note {
    margin: 0 auto;
    max-width: 520px;
    font-size: 0.95rem;
}

main {
    width: min(100% - 40px, 1040px);
    margin: 2rem auto 0;
}

.top-stats-row {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.65fr);
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

#visitor-stats-card, .counter-section, .upload-container, .chart-container {
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow);
    min-width: 0;
}

/* --- VISITOR STATS & BALL COUNTER --- */
#visitor-stats-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 1rem;
    cursor: pointer;
    background: var(--mint);
    border-color: #d7e5dc;
    user-select: none;
    transition: box-shadow 150ms ease;
}

#visitor-stats-card:hover {
    box-shadow: 0 6px 22px rgba(36, 62, 59, 0.09);
}

.stat-period-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #536f65;
}

#stat-count-number {
    margin: 0.25rem 0 0;
    font-size: clamp(3rem, 6vw, 4rem);
    color: var(--primary-action);
    font-weight: 750;
}

.stat-switch-hint {
    padding: 0.35rem 0.75rem;
    border-radius: 30px;
    background: #ffffff80;
    color: #536f65;
    font-size: 0.78rem;
}

.counter-section {
    text-align: center;
}

.ball-counts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.ball-counts > div + div {
    border-left: 1px solid var(--line);
    padding-left: 1rem;
}

.ball-counts h3 {
    margin: 0;
    font-size: 2.35rem;
    font-weight: 750;
}

#donated-count {
    color: var(--primary-action);
}

#borrowed-count {
    color: #a77834;
}

.ball-counts p {
    margin: 0.2rem 0 0.7rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.ball-counts button {
    width: 100%;
    font-size: 0.87rem;
    padding: 0.65rem 0.5rem;
}

.borrow-ball-button {
    background: var(--sand);
    color: #705522;
}

.borrow-ball-button:hover {
    background: #ebd7ac;
}

/* --- REPORT ISSUE COMPONENT --- */
.counter-section .issue-report {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8e8;
    text-align: left;
}

.counter-section .issue-report summary {
    cursor: pointer;
    color: #2c7a7b;
    border: 0;
    background: #f3f5ef;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.07em;
    padding: 0.75rem 0.85rem;
}

.counter-section .issue-report summary:hover {
    background: var(--mint);
    color: var(--primary-action);
}

.counter-section .issue-report summary:focus-visible {
    outline: 3px solid #f6ad55;
    outline-offset: 3px;
}

.counter-section .issue-report form {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.counter-section .issue-report label {
    display: grid;
    gap: 0.4rem;
    font-size: 0.88rem;
    font-weight: bold;
}

.counter-section .issue-report select,
.counter-section .issue-report textarea {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 10px;
    background: white;
    padding: 0.8rem;
    font: inherit;
}

.counter-section .issue-report textarea {
    resize: vertical;
}

.counter-section .issue-report p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.counter-section .issue-report button {
    padding: 0.8rem 1rem;
    background: var(--primary-action);
    color: white;
}

.counter-section .issue-report button:hover {
    background: var(--primary-hover);
}

#issue-report-status:empty {
    display: none;
}

/* --- DAILY SPOTLIGHT CARD --- */
#daily-spotlight {
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    background: linear-gradient(120deg, #e2eee8, #faf0d6);
    overflow: hidden;
}

#daily-spotlight img {
    max-width: 100%;
    object-fit: cover;
    border-radius: 16px;
}

/* --- MAIN MESSAGE SUBMISSION FORM --- */
.upload-container {
    margin-bottom: 2.75rem;
}

.upload-container h2 {
    margin-bottom: 1.5rem;
}

#visitor-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.entry-choice, #dog-visit-fields {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.entry-choice legend {
    margin-bottom: 0.6rem;
    font-weight: 650;
}

.entry-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.entry-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem;
    border: 1px solid #d7e5dc;
    border-radius: 12px;
    cursor: pointer;
    background: #fffefa;
}

.entry-options label:has(input:checked) {
    background: #e6f0e9;
    border-color: #28766f;
    color: #28766f;
}

.entry-options input {
    accent-color: #28766f;
    flex-shrink: 0;
}

.visitor-name-field {
    display: grid;
    gap: 0.4rem;
}

#dog-visit-fields {
    display: grid;
    gap: 1rem;
}

#dog-visit-fields[hidden],
#modal-img[hidden],
#modal-breed[hidden] {
    display: none;
}

#entry-mode-help {
    margin: 0;
    font-size: 0.85rem;
    color: #687a75;
}

input[type='text'], input[list], select, textarea {
    width: 100%;
    min-width: 0;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.5;
}

input::placeholder, textarea::placeholder {
    color: #7b8781;
    opacity: 1;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.breed-input-group {
    display: grid;
    gap: 0.5rem;
}

.crossbreed-label {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.82rem;
    color: var(--muted);
    cursor: pointer;
}

#dog-crossbreed {
    width: 17px;
    height: 17px;
    accent-color: var(--primary-action);
}

.file-upload {
    display: block;
    border: 1px dashed #b9cec1;
    border-radius: 12px;
    background: #f3f7f0;
    color: var(--primary-action);
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    cursor: pointer;
}

.file-upload:hover {
    background: var(--mint);
}

/* --- HIDDEN FILE INPUTS --- */
#dog-photo {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

#visitor-form:has(#dog-photo:focus-visible) #photo-label {
    outline: 3px solid #b68a3d;
    outline-offset: 4px;
}

#upload-status {
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
}

#upload-status:empty {
    display: none;
}

#visitor-form > button {
    justify-self: stretch;
    width: 100%;
    text-align: center;
}

/* --- MAIN GALLERY & ENTRIES --- */
.gallery-container {
    margin-bottom: 2.75rem;
}

.gallery-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.gallery-heading h2 {
    margin: 0;
}

#gallery-filter {
    width: auto;
    max-width: 100%;
    padding: 0.6rem 2rem 0.6rem 0.85rem;
    font-size: 0.85rem;
    border-radius: 30px;
    background-color: var(--paper);
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.15rem;
}

.visitor-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--paper);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.visitor-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(36, 62, 59, 0.1);
}

.visitor-card img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.visitor-card-content {
    padding: 1rem;
    font-size: 0.9rem;
}

.visitor-card-content h3 {
    margin: 0 0 0.4rem;
    font-size: 1.1rem;
}

.visitor-card-content p {
    margin: 0.5rem 0;
    color: var(--muted);
}

.visitor-card-content small {
    color: var(--muted);
}

.card-message {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#visitor-grid > p {
    grid-column: 1 / -1;
    color: var(--muted);
}

#visitor-grid .tag,
#visitor-grid .badge {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.2rem 0.6rem;
    border-radius: 30px;
    background: var(--mint);
    color: var(--primary-action);
}

.message-card-icon {
    display: grid;
    place-items: center;
    min-height: 110px;
    background: linear-gradient(135deg, #e6f0e9, #f5e7c9);
    font-size: 2rem;
}

/* --- BREEDS SCOREBOARD & FOOTER --- */
.chart-container {
    margin-bottom: 2rem;
}

#breed-scoreboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

#breed-scoreboard:empty::after {
    content: 'The scoreboard will appear as visits are logged.';
    color: var(--muted);
    font-size: 0.9rem;
}

.local-rescue {
    text-align: center;
    margin: 0 0 1.5rem;
    padding: 1rem 0;
}

.local-rescue a {
    display: inline-block;
    padding: 0.9rem 1.3rem;
    background: var(--sand);
    color: #705522;
    border: 1px solid #ebddbf;
    border-radius: 30px;
    font-size: 0.88rem;
    text-decoration: none;
    font-weight: 650;
}

.local-rescue a:hover {
    background: #ebd7ac;
}

.community-footer {
    padding: 0 1.25rem 2.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.83rem;
}

.community-footer p {
    margin: 0.35rem 0;
}

/* --- MODAL POPUPS --- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(25, 46, 42, 0.65);
    overflow-y: auto;
    padding: 1.5rem;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    margin: 3vh auto;
    width: min(100%, 600px);
    background: var(--paper);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 20px 80px #0003;
}

.close-modal {
    position: absolute;
    right: 0.7rem;
    top: 0.7rem;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--paper);
    color: var(--ink);
    font-size: 1.7rem;
    cursor: pointer;
    z-index: 1;
}

#modal-img {
    max-width: 100%;
    max-height: 60vh;
    display: block;
    margin: 0 auto 1rem;
    object-fit: contain;
    border-radius: 12px;
}

#modal-name {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

#modal-message {
    white-space: pre-wrap;
}

/* --- RESPONSIVE MEDIA STUFF --- */
@media (max-width: 740px) {
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .top-stats-row {
        grid-template-columns: minmax(0, 1fr);
    }
    #visitor-stats-card {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
    #stat-count-number {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    main {
        width: calc(100% - 28px);
        margin-top: 1.25rem;
    }
    .hero {
        border-radius: 0 0 24px 24px;
    }
    .entry-options {
        grid-template-columns: minmax(0, 1fr);
    }
    .grid {
        gap: 0.75rem;
    }
    .visitor-card-content {
        padding: 0.75rem;
        font-size: 0.82rem;
    }
    .visitor-card-content h3 {
        font-size: 1rem;
    }
    .stat-switch-hint {
        max-width: 135px;
        text-align: center;
    }
    .local-rescue a {
        border-radius: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    button, .visitor-card, #visitor-stats-card {
        transition: none;
    }
    button:hover, .visitor-card:hover {
        transform: none;
    }
    .visitor-card.fade-in {
        animation: none;
    }
}