/* ── Inline gallery section on main page ──────────────── */
#gallery {
    width: 100%;
}

/* ── Title row ────────────────────────────────────────── */
.title {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5em;
}

/* ── Back link ────────────────────────────────────────── */
.back-link {
    font-size: 0.85em;
    color: #666;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s;
}

.back-link:hover {
    color: #fff;
}

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
    display: flex;
    flex-direction: row;
    border: 2px solid #fff;
    margin-bottom: 1.5em;
}

.tab {
    flex: 1;
    padding: 14px 20px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1em;
    text-align: center;
    transition: color 0.2s, background 0.2s;
}

.tab + .tab {
    border-left: 2px solid #fff;
}

.tab:hover {
    color: #fff;
}

.tab.active {
    color: #fff;
    background: #111;
}

.tab-count {
    font-size: 0.75em;
    opacity: 0.5;
    margin-left: 4px;
}

/* ── Tab panels ───────────────────────────────────────── */
.tab-panel {
    display: none;
}

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

/* ── Grid ─────────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-items: start;
}

/* ── Cards ────────────────────────────────────────────── */
.card {
    background: #000;
    color: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.15s;
}

.card:hover,
.card:focus-visible {
    border-color: #fff;
    transform: translateY(-3px);
}

.card:focus-visible {
    outline: none;
}

.card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.meta {
    padding: 10px 8px;
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Modal ────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.panel {
    position: relative;
    background: #000;
    padding: 20px;
    max-width: min(1000px, calc(100% - 2em));
    width: calc(100% - 2em);
    border: 2px solid #fff;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

#panel-body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.panel img {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    margin-top: 12px;
}

.panel .meta {
    padding: 16px 8px 8px;
    white-space: normal;
}

.panel .meta h3 {
    margin: 0 0 8px;
}

.panel .meta p {
    margin: 4px 0;
    font-size: 13px;
    opacity: 0.7;
}

.panel .meta a {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.panel .meta a:hover {
    opacity: 0.7;
}

/* ── Pagination ───────────────────────────────────────── */
.pagination {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    flex-wrap: wrap;
}

.page-btn,
.page-num,
#close,
.btn {
    padding: 7px 12px;
    background: #000;
    border: 2px solid #fff;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
    min-width: 36px;
    text-align: center;
}

.page-btn:hover:not(:disabled),
.page-num:hover:not(.current) {
    background: #fff;
    color: #000;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.page-num.current {
    background: #fff;
    color: #000;
}

.page-ellipsis {
    color: #666;
    padding: 0 4px;
    font-size: 13px;
    user-select: none;
}

#close {
    position: absolute;
    top: 0;
    right: 0;
    border-top: none;
    border-right: none;
    font-size: 18px;
    line-height: 1;
    padding: 8px 14px;
    z-index: 1;
}

#close:hover {
    background: #fff;
    color: #000;
}

.page-info {
    color: #999;
    font-size: 12px;
    width: 100%;
    text-align: center;
    margin-top: 4px;
}

/* ── Responsive ───────────────────────────────────────── */

/* 3 columns on large tablets / small desktops */
@media (max-width: 1100px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 2 columns on tablets */
@media (max-width: 720px) {
    .tabs {
        flex-direction: column;
    }

    .tab + .tab {
        border-left: none;
        border-top: 2px solid #fff;
    }

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

    .tab {
        padding: 12px 10px;
        font-size: 0.85em;
    }

    .meta {
        padding: 8px 6px;
        font-size: 12px;
    }

    .panel {
        max-width: calc(100% - 1em);
        width: calc(100% - 1em);
        padding: 14px;
    }
}

/* still 2 columns on small phones — keeps density */
@media (max-width: 420px) {
    .grid {
        gap: 6px;
    }

    .card {
        border-width: 1px;
    }

    .card:hover {
        transform: none; /* no hover lift on touch devices */
    }

    .meta {
        padding: 6px 4px;
        font-size: 11px;
    }

    .page-btn,
    .page-num {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 30px;
    }
}