:root {
    /* Väripaletti Fotomin LUMIX-kamera + filmirulla -kuvasta:
       lämmin kermanvalkoinen tausta, kameran musta runko, hopeanharmaat
       metalliset korostukset ja filmin lämmin kupari/ruskea sävy. */
    --bg: #f3ead9;
    --surface: #fffdf9;
    --ink: #2a2521;
    --ink-soft: #756a5b;
    --border: #e4d7bf;
    --accent: #8a4b23;
    --accent-dark: #6e3a19;
    --accent-soft: #f1e0cb;
    --charcoal: #211d1a;
    --silver-1: #e2e5e9;
    --silver-2: #7d838c;
}

* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background-color: var(--bg);
    background-image: linear-gradient(rgba(243, 234, 217, 0.45), rgba(243, 234, 217, 0.45)), url('img/background.webp');
    background-repeat: no-repeat, repeat;
    background-size: cover, 320px 320px;
    background-attachment: fixed, fixed;
    color: var(--ink);
    margin: 0;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, #10321d 0%, #2e6b41 50%, #10321d 100%);
    color: #fff;
}

.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: linear-gradient(180deg, #f5f7f9 0%, #c2c8ce 42%, #82868d 55%, #dfe2e6 75%, #9aa0a7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Nappi ja teksti samalla elementillä: kaksi taustakerrosta, joista
   ensimmäinen (metallinen gradientti) rajataan tekstin muotoon ja toinen
   (vihreä, kuten topbar) täyttää koko napin taustan sen ympärillä. */
.topbar nav a {
    display: inline-flex;
    align-items: center;
    margin-left: 0.6rem;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    background-image:
        linear-gradient(180deg, #f5f7f9 0%, #c2c8ce 42%, #82868d 55%, #dfe2e6 75%, #9aa0a7 100%),
        linear-gradient(180deg, #10321d 0%, #2e6b41 50%, #10321d 100%);
    -webkit-background-clip: text, border-box;
    background-clip: text, border-box;
    color: transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -1px 0 rgba(0,0,0,0.25);
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.topbar nav a:hover {
    background-image:
        linear-gradient(180deg, #f5f7f9 0%, #c2c8ce 42%, #82868d 55%, #dfe2e6 75%, #9aa0a7 100%),
        linear-gradient(180deg, #184026 0%, #3a7d52 50%, #184026 100%);
}

.topbar nav a:active {
    background-image:
        linear-gradient(180deg, #f5f7f9 0%, #c2c8ce 42%, #82868d 55%, #dfe2e6 75%, #9aa0a7 100%),
        linear-gradient(180deg, #081a0e 0%, #1c4429 50%, #081a0e 100%);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.6);
    transform: scale(0.97);
}

.topbar nav span {
    margin-right: 1rem;
    background: linear-gradient(180deg, #f5f7f9 0%, #c2c8ce 42%, #82868d 55%, #dfe2e6 75%, #9aa0a7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: fixed;
    inset: -20px;
    background-size: cover;
    background-position: center;
    filter: blur(18px) brightness(0.8);
    transform: scale(1.1);
    z-index: -1;
}

.auth-box {
    max-width: 420px;
    width: 100%;
    margin: 3rem auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(40,25,10,0.22);
    position: relative;
}

.auth-box label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.auth-box label.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-box label.checkbox-label input { width: auto; margin-top: 0; }

.auth-box input,
.auth-box textarea,
.auth-box select {
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
}

.auth-box button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.auth-box button:hover { background: var(--accent-dark); }

.error { color: #b91c1c; }
.success { color: #15803d; }

.notice-bar {
    max-width: 1100px;
    margin: 1rem auto 0;
    padding: 0.75rem 1.5rem;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--ink);
}

.notice-bar p { margin: 0; }

.notice-bar form { margin: 0; }

.notice-bar button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}

.notice-info {
    background: var(--silver-1);
    border-color: #cdd2d8;
}

.button-link {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    text-decoration: none;
}

.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--charcoal);
    color: #fff;
    padding: 0.6rem 1.1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    max-width: 90vw;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.badge-private {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.7rem;
    padding: 0.05rem 0.4rem;
    border-radius: 8px;
}

.filter-bar {
    max-width: 1100px;
    margin: 1.5rem auto 0;
    padding: 0 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.filter-bar label {
    font-size: 0.9rem;
}

.filter-bar select {
    margin-left: 0.4rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
}

.gallery {
    max-width: 1100px;
    margin: 1.5rem auto 3rem;
    padding: 2rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 2.5rem 2rem;
}

/* Polaroid-tyylinen pikkukuva: valkoinen "filmi"-reunus, paksumpi alareuna,
   kevyt varjo ja satunnainen kallistus, teksti käsinkirjoitetulla fontilla. */
.card {
    background: var(--surface);
    border-radius: 2px;
    box-shadow: 0 3px 6px rgba(50,35,15,0.2), 0 1px 3px rgba(50,35,15,0.14);
    margin: 0;
    padding: 0.85rem 0.85rem 0;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    transform: rotate(var(--tilt, -1.5deg));
}

.card:nth-child(2n) { --tilt: 2deg; }
.card:nth-child(3n) { --tilt: -2.5deg; }
.card:nth-child(4n) { --tilt: 1.5deg; }
.card:nth-child(5n) { --tilt: -1deg; }
.card:nth-child(6n) { --tilt: 2.5deg; }

.card:hover,
.card:focus {
    transform: rotate(0deg) scale(1.04) translateY(-4px);
    box-shadow: 0 14px 24px rgba(50,35,15,0.28), 0 4px 8px rgba(50,35,15,0.18);
    z-index: 2;
    outline: none;
}

.card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    filter: contrast(1.05) saturate(1.05);
    background: #eee;
}

.card figcaption {
    padding: 0.9rem 0.25rem 1.4rem;
    text-align: center;
}

.card h2 {
    margin: 0;
    font-family: 'Caveat', 'Segoe Script', cursive;
    font-weight: 700;
    font-size: 1.7rem;
    line-height: 1.1;
    color: #3a2a1a;
}

/* Kaikki muu tieto (kuvaus, kategoria, laite, lisääjä, päivämäärä) piilotetaan
   pikkukuvasta - vain nimi ja kuva näkyvät. */
.card figcaption p { display: none; }

.hint {
    font-size: 0.8rem;
    color: var(--ink-soft);
    margin: -0.5rem 0 1rem;
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.15s ease;
}

.lightbox.hidden { display: none; }
.lightbox.closing { opacity: 0; }

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-content {
    max-width: 1100px;
    max-height: 90vh;
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    overflow: auto;
    display: flex;
    flex-wrap: wrap;
}

.lightbox-content img {
    flex: 1 1 500px;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    background: #111;
}

.lightbox-info {
    flex: 1 1 280px;
    padding: 1.5rem;
    overflow-y: auto;
}

.lightbox-info h2 { margin-top: 0; }

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #ddd;
    font-size: 0.85rem;
}

.admin-actions form { margin: 0; }

.admin-actions a {
    color: var(--accent);
    text-decoration: none;
}

.admin-actions button {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.edit-preview {
    display: block;
    max-width: 100%;
    max-height: 260px;
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 1.25rem;
    background: #eee;
}

.exif-table {
    margin-top: 1rem;
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
}

.exif-table th {
    text-align: left;
    color: var(--ink-soft);
    font-weight: 600;
    padding: 0.3rem 0.75rem 0.3rem 0;
    white-space: nowrap;
    vertical-align: top;
}

.exif-table td {
    padding: 0.3rem 0;
}

.reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 1.25rem;
}

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--silver-1);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    font-size: 1rem;
}

.reaction-btn .count {
    font-size: 0.75rem;
    color: var(--ink-soft);
}

.reaction-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.comments {
    margin-top: 1.5rem;
    border-top: 1px solid #eee;
    padding-top: 1rem;
}

.comments h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.comment-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.comment {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.comment-meta {
    font-size: 0.75rem;
    color: var(--ink-soft);
    margin-bottom: 0.2rem;
}

.comment-body {
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-empty {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.comment-form textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.comment-form button {
    margin-top: 0.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.45rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.hidden { display: none; }

.page {
    max-width: 1100px;
    margin: 1.5rem auto 3rem;
    padding: 0 1.5rem;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(40,25,10,0.12);
    font-size: 0.9rem;
}

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

.user-table th {
    background: var(--accent-soft);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

.badge-ok { background: #dcfce7; color: #166534; }
.badge-banned { background: #fee2e2; color: #991b1b; }

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.actions form { display: inline; }

.actions button {
    background: var(--silver-1);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.actions button.danger {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.user-detail {
    margin-top: 1.5rem;
    background: var(--surface);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(40,25,10,0.12);
}

.activity-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.activity-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.changelog {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.changelog-entry {
    background: var(--surface);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 4px rgba(40,25,10,0.12);
    border-left: 4px solid var(--accent);
}

.changelog-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.changelog-version {
    font-weight: 700;
    color: var(--accent);
    font-size: 1rem;
}

.changelog-title {
    font-weight: 600;
    color: var(--ink);
}

.changelog-date {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.changelog-items {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--ink);
}

.changelog-items li {
    margin-bottom: 0.3rem;
    font-size: 0.92rem;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.5rem;
}

.table-scroll .user-table {
    margin-bottom: 0;
}

.stats-bar {
    max-width: 1100px;
    margin: 1rem auto 0;
    padding: 0 1.5rem;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.stats-bar p { margin: 0; }
.stats-bar strong { color: var(--accent); }

.per-page-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
}

.per-page-label { color: var(--ink-soft); }

.per-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.85rem;
}

.per-page-btn:hover {
    border-color: var(--accent);
}

.per-page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pagination-nav {
    max-width: 1100px;
    margin: 0 auto 2.5rem;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
}

.page-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: linear-gradient(180deg, #10321d 0%, #2e6b41 50%, #10321d 100%);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(16,50,29,0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.page-arrow:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(16,50,29,0.4);
}

.page-arrow-disabled {
    opacity: 0.35;
    box-shadow: none;
    cursor: default;
}

.page-indicator {
    font-size: 0.9rem;
    color: var(--ink-soft);
    min-width: 6rem;
    text-align: center;
}

/* Taustakuvan päällä (laatikoiden ulkopuolella) olevat tekstit paksummiksi
   ja mustiksi, jotta ne erottuvat selkeästi kuvioidusta taustasta. */
.page > h1,
.page > h2,
.page > h3,
.page > p.hint,
.stats-bar p,
.filter-bar label,
.per-page-label,
.page-indicator,
.gallery > p {
    color: #000;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(243, 234, 217, 0.9), 0 0 1px rgba(243, 234, 217, 0.9);
}

.page > h1 { font-weight: 800; }

/* ------------------------------------------------------
   Mobiili (puhelimet, leveys enintään 640px)
   ------------------------------------------------------ */
@media (max-width: 640px) {
    body {
        background-attachment: scroll, scroll;
        background-size: cover, 220px 220px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
        padding: 0.85rem 1rem;
    }

    .topbar nav {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem 0.9rem;
        width: 100%;
    }

    .topbar nav a { margin-left: 0; }
    .topbar nav span { margin-right: 0; }

    .auth-box {
        margin: 1.25rem auto;
        padding: 1.25rem;
        max-width: 100%;
        border-radius: 0;
    }

    .notice-bar {
        margin: 0.75rem 0.75rem 0;
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .notice-bar button, .notice-bar .button-link { width: 100%; padding: 0.6rem; text-align: center; }

    .filter-bar {
        padding: 0 0.75rem;
        margin-top: 1rem;
        flex-direction: column;
        gap: 0.75rem;
    }

    .filter-bar label { display: block; width: 100%; }
    .filter-bar select { width: 100%; margin-left: 0; margin-top: 0.3rem; }

    .per-page-toggle { flex-wrap: wrap; }

    .stats-bar { padding: 0 0.75rem; }

    .pagination-nav { padding: 0 0.75rem; gap: 0.75rem; }
    .page-arrow { width: 2.4rem; height: 2.4rem; font-size: 1.4rem; }

    .gallery {
        padding: 0 0.75rem;
        margin: 1rem auto 2rem;
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card img { height: 220px; }
    .card { transform: none; margin: 0 0.4rem; }
    .card:hover, .card:focus { transform: scale(1.02); }

    .lightbox { padding: 0; }

    .lightbox-content {
        max-width: 100%;
        max-height: 100vh;
        height: 100%;
        width: 100%;
        border-radius: 0;
        flex-direction: column;
    }

    .lightbox-content img {
        flex: 0 0 auto;
        width: 100%;
        max-height: 42vh;
    }

    .lightbox-info { flex: 1 1 auto; padding: 1rem; }

    .lightbox-close {
        top: 0.5rem;
        right: 0.75rem;
        background: rgba(0,0,0,0.4);
        border-radius: 50%;
        width: 2.25rem;
        height: 2.25rem;
        color: #fff;
        z-index: 10;
    }

    .reaction-btn {
        padding: 0.4rem 0.7rem;
        font-size: 1.1rem;
    }

    .comment-form button {
        width: 100%;
        padding: 0.65rem;
    }

    .page { padding: 0 0.75rem; margin: 1rem auto 2rem; }

    .user-table { font-size: 0.82rem; }
    .user-table th, .user-table td { padding: 0.5rem; }

    .actions {
        flex-direction: column;
        align-items: stretch;
        min-width: 140px;
    }

    .actions form, .actions button { width: 100%; }
    .actions a { display: block; width: 100%; text-align: center; }
    .actions button { padding: 0.5rem; }

    .user-detail { padding: 1rem; margin-top: 1rem; }
}
