/* ===========================
   Theme Variables
   =========================== */
:root {
    /* Background & surfaces */
    --bg-gradient: linear-gradient(to bottom, #d9fdd3, #a5d6a7, #81c784);
    --card: #ffffffcc; /* semi-transparent white */
    --border: #e2e8f0;
    --shadow: 0 6px 16px rgba(0,0,0,0.08);
    /* Text & accents */
    --text: #0f172a;
    --muted: #64748b;
    --link: #0ea5e9;
    --accent: #22c55e;
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(to bottom, #003300, #006400, #004d00);
    --card: #111827cc; /* semi-transparent dark */
    --border: #1f2937;
    --shadow: 0 8px 20px rgba(0,0,0,0.25);
    --text: #f8fafc;
    --muted: #94a3b8;
    --link: #38bdf8;
    --accent: #22c55e;
}

/* ===========================
   Base Layout
   =========================== */
html, body {
    height: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg-gradient);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* ===========================
   Header & Logo
   =========================== */
.logo {
    display: flex;
    justify-content: center;
    padding: 12px 0;
}

.crest-img {
    width: 25%;
    max-width: 220px; /* cap on wide screens */
    min-width: 100px; /* legible on small screens */
    height: auto;
    display: block;
}

.site-title {
    text-align: center;
    font-size: 1.8rem;
    margin: 0;
    padding: 6px 0;
}

.nav-links {
    text-align: center;
    margin-bottom: 16px;
}

    .nav-links a {
        color: var(--link);
        text-decoration: none;
        font-weight: 700;
        margin: 0 8px;
    }

        .nav-links a:hover {
            text-decoration: underline;
        }

/* Theme toggle */
.theme-toggle {
    text-align: center;
    margin-bottom: 16px;
}

.btn-theme {
    cursor: pointer;
    border: 1px solid var(--link);
    background: transparent;
    color: var(--text);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
}

    .btn-theme:hover {
        background: var(--link);
        color: #fff;
    }

/* ===========================
   Cards
   =========================== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin: 16px auto;
    box-shadow: var(--shadow);
}

    .card h2, .card h3 {
        margin-top: 0;
    }

/* Constrain category cards so tables don’t sprawl on desktop */
.category {
    max-width: 900px;
    width: 100%;
    margin: 20px auto;
    padding: 20px;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    transition: background .2s, color .2s, transform .05s;
}

    .btn:active {
        transform: translateY(1px);
    }

.btn-primary {
    background: var(--accent);
    color: #052e16;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-primary:hover {
    background: #16a34a;
    color: #fff;
}

.btn-outline:hover {
    background: var(--border);
}

/* ===========================
   Category Header & Search
   =========================== */
.cat-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 10px;
}

    .cat-head h2 {
        margin: 0;
    }

.row.right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.search-input {
    width: 280px;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    background: #fff;
    color: #0f172a;
}

[data-theme="dark"] .search-input {
    background: #0b1220;
    color: #e5e7eb;
}

/* ===========================
   Voting Table (Desktop/Tablet)
   =========================== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    margin: 0 auto;
    max-width: 850px; /* keep table content centered and narrower */
    box-shadow: var(--shadow);
}

.vote-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* keeps columns stable & prevents blowout */
    min-width: 560px; /* allows sideways scroll on narrow windows */
    border-radius: 14px;
    overflow: hidden;
}

    .vote-table thead th {
        text-align: left;
        font-weight: 800;
        padding: 14px;
        border-bottom: 2px solid var(--border);
        font-size: 1rem;
        position: sticky;
        top: 0;
        background: var(--card);
        z-index: 1;
    }

    .vote-table tbody td {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
    }

/* Columns */
.col-entry {
    width: 84%;
}

.col-action {
    width: 16%;
    text-align: center;
}

/* Long text handling */
.entry-name {
    display: block;
    white-space: normal; /* allow wrapping */
    overflow-wrap: anywhere; /* wrap long words/strings */
    hyphens: auto;
    line-height: 1.4;
}

/* Zebra & hover */
.vote-table tbody tr:nth-child(odd) {
    background: rgba(0,0,0,.02);
}

[data-theme="dark"] .vote-table tbody tr:nth-child(odd) {
    background: rgba(255,255,255,.03);
}

.vote-table tbody tr:hover {
    background: rgba(34,197,94,.12);
}

/* Radios */
.radio-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
}

.vote-table input[type=radio] {
    width: 20px;
    height: 20px;
}

/* Submit row */
.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* ===========================
   Mobile Adjustments
   =========================== */
@media (max-width: 700px) {
    .container {
        padding: 12px;
    }

    .category {
        margin: 12px auto;
        padding: 16px;
    }

    /* Center & size search input */
    .cat-head {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .search-input {
        width: 90%;
        max-width: 320px;
    }

    /* Make table narrower with no scroll bar */
    .table-wrap {
        width: 92%;
        max-width: 400px; /* cap width on mobile */
        margin: 0 auto;
        overflow-x: hidden; /* remove adjustment bar */
    }

    /* Compact stacked table */
    .vote-table thead {
        display: none;
    }

    .vote-table, .vote-table tbody, .vote-table tr, .vote-table td {
        display: block;
        width: 100%;
    }

        .vote-table tr {
            border-bottom: 1px solid var(--border);
            padding: 8px 10px;
            background: transparent !important;
        }

        /* Center entries + make white text */
        .vote-table td.col-entry {
            padding-bottom: 4px;
            text-align: center;
            color: #fff;
        }

            .vote-table td.col-entry .entry-name {
                color: #fff;
                font-weight: 600;
            }

        /* Center the radio button */
        .vote-table td.col-action {
            display: flex;
            justify-content: center;
            padding-top: 0;
        }

    /* Center the submit button */
    .form-actions {
        justify-content: center;
        margin-top: 12px;
    }
}

