/* --- GALLERY CONTAINER --- */
#gallery-container {
    min-height: calc(100vh - 150px);
    /* Add to raise cards, subtract to lower */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 60px;
    /* Space for the floating navbar on desktop (phones: see the max-width 768px rule below) */
    width: 100%;
}

/* --- GALLERY TITLE --- */
h1 {
    font-family: 'VT323', monospace;
    font-size: 5.5rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent), 0 0 40px var(--accent);
    margin-bottom: 1rem;
    text-align: center;
}

/* --- CARD (shared by the carousel and the collapsible list) --- */
/* Card background: 0.9 (was 0.8) so text and photos stay readable over the brighter green funnel */
.gallery-card {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--accent);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.4s ease, opacity 0.4s ease, filter 0.4s ease, background 0.3s ease;
}

.gallery-card:focus-visible {
    outline: 2px dashed var(--accent);
    outline-offset: 3px;
}

/* Scan line sweeping across the top edge */
.gallery-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: scan 3s linear infinite;
    z-index: 1;
}

@keyframes scan {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* Photo area: only the first link (the cover) shows; the rest are album-only */
.card-photos {
    position: relative;
    width: 100%;
    height: 240px;
    flex-shrink: 0;
    border: 1px dashed rgba(var(--accent-rgb), 0.3);
    background: #000;
    overflow: hidden;
}

/* A card whose photos haven't been added yet: placeholder label instead of an empty black box */
.card-photos:empty::after {
    content: '[ PHOTOS COMING SOON ]';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    letter-spacing: 0.1rem;
    color: rgba(var(--accent-rgb), 0.6);
}

.card-photos a {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

.card-photos a:not(:first-child) {
    display: none;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
    transition: opacity 0.3s ease, transform 0.4s ease;
}

/* "Enlarge" hint over the photo on hover / keyboard focus */
.card-photos a::after {
    content: '[ + ENLARGE ]';
    position: absolute;
    inset: auto 0 0 0;
    padding: 0.4rem;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    letter-spacing: 0.1rem;
    text-align: center;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    text-shadow: 0 0 8px var(--accent);
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.card-photos a:hover .card-image,
.card-photos a:focus-visible .card-image {
    opacity: 1;
    transform: scale(1.05);
}

.card-photos a:hover::after,
.card-photos a:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

/* Photo-count badge (added by gallery.js when a card has more than one photo) */
.photo-count {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.1rem 0.5rem;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--accent);
    pointer-events: none;
}

.card-title {
    color: var(--accent);
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 2.4px;
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.3);
    padding-bottom: 0.6rem;
}

/* Card body text: IBM Plex Mono (@font-face in base.css), like the home page's About Me and project text */
.card-description {
    font-family: 'IBM Plex Mono', 'Courier New', Courier, monospace;
    color: var(--text);
    font-size: 0.84rem;
    line-height: 1.5;
}

.card-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Tags: labels, not buttons — full accent-coloured text (amber: 11.5:1 contrast) on a faint chip with a clear border */
.card-tag {
    font-family: 'IBM Plex Mono', 'Courier New', Courier, monospace;
    background: rgba(var(--accent-rgb), 0.12);
    border: 1px solid rgba(var(--accent-rgb), 0.8);
    color: var(--accent);
    padding: 0.24rem 0.6rem;
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Same look as the home page hero buttons */
.album-btn {
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    letter-spacing: 0.05rem;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--accent);
    padding: 0.4rem 1rem;
    text-shadow: 0 0 10px var(--accent);
    cursor: pointer;
    transition: all 0.3s;
}

.album-btn:hover,
.album-btn:focus-visible {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 15px var(--accent);
}

/* --- HINT LINE UNDER THE GALLERY --- */
/* Plex Mono is much wider than the VT323 it replaced, so it's smaller to keep the line about the same length */
.gallery-hint {
    font-family: 'IBM Plex Mono', 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    letter-spacing: 0.1rem;
    /* Full accent colour (amber: 11.5:1 contrast) with a soft glow, like the carousel controls */
    color: var(--accent);
    text-shadow: 0 0 6px var(--accent);
    text-align: center;
    /* Same dark box and accent outline as the carousel controls, so it stays readable over the background */
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--accent);
    padding: 0.3rem 0.9rem;
    max-width: calc(100% - 2rem);
    margin-top: 0.75rem;
}

/* =====================================================================
   LAPTOP / DESKTOP (1024px+): SWIPER CAROUSEL
   Flat "focus" coverflow: the centre card is full size and glowing,
   the neighbours step back and dim. Clicking a side card brings it to the centre.
   ===================================================================== */
@media (min-width: 1024px) {
    .gallery-swiper {
        width: 100%;
        padding: 2.5rem 0 1.5rem;
        overflow: hidden;
    }

    /* .gallery-swiper prefix: Swiper's own stylesheet loads later and sets slides to 100% wide */
    .gallery-swiper .swiper-slide {
        width: 360px;
        height: auto;
        display: flex;
    }

    .gallery-card {
        width: 100%;
        height: 560px;
    }

    /* Card shows a 4-line excerpt; the album shows the full text */
    .card-description {
        flex-shrink: 0;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        line-clamp: 4;
        overflow: hidden;
    }

    /* Tags and button sit on the bottom edge of every card */
    .card-tags {
        margin-top: auto;
    }

    .album-btn {
        align-self: stretch;
    }

    /* Side cards: dimmed and desaturated until they come to the centre */
    .swiper-slide:not(.swiper-slide-active) .gallery-card {
        opacity: 0.45;
        filter: grayscale(0.7);
    }

    .swiper-slide:not(.swiper-slide-active) .gallery-card:hover {
        opacity: 0.75;
    }

    /* Only the centre card's photo enlarges; a side card's photo just brings it forward */
    .swiper-slide:not(.swiper-slide-active) .card-photos a {
        cursor: pointer;
    }

    .swiper-slide:not(.swiper-slide-active) .card-photos a::after {
        display: none;
    }

    .swiper-slide-active .gallery-card {
        box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.45);
    }

    .swiper-slide-active .gallery-card:hover {
        background: rgba(0, 0, 0, 0.92);
        background: rgb(from var(--accent) calc(r * 0.08) calc(g * 0.08) calc(b * 0.08) / 0.92);
    }

    /* Prev / counter / next bar */
    .gallery-controls {
        display: flex;
        align-items: stretch;
        /* stretch: the [ < ] [ > ] buttons and the counter box share one height */
        justify-content: center;
        gap: 1.5rem;
        margin-top: 0.5rem;
    }

    .gallery-nav {
        font-family: 'VT323', monospace;
        font-size: 1.6rem;
        color: var(--accent);
        background: rgba(0, 0, 0, 0.8);
        border: 1px solid var(--accent);
        padding: 0.2rem 0.9rem;
        white-space: nowrap;
        text-shadow: 0 0 10px var(--accent);
        cursor: pointer;
        transition: all 0.3s;
    }

    .gallery-nav:hover,
    .gallery-nav:focus-visible {
        background: var(--accent);
        color: #000;
        box-shadow: 0 0 15px var(--accent);
    }

    /* Same dark box and accent outline as the [ < ] [ > ] buttons, so it stays readable over the background */
    .gallery-counter {
        font-family: 'VT323', monospace;
        font-size: 1.8rem;
        letter-spacing: 0.2rem;
        color: var(--accent);
        text-shadow: 0 0 10px var(--accent);
        min-width: 7ch;
        text-align: center;
        background: rgba(0, 0, 0, 0.8);
        border: 1px solid var(--accent);
        padding: 0.2rem 0.9rem;
    }

    .gallery-hint-mobile {
        display: none;
    }
}

/* Shorter laptop screens (e.g. 1366x768): tighten everything so the controls stay on screen */
@media (min-width: 1024px) and (max-height: 850px) {
    #gallery-container {
        padding-top: 30px;
    }

    h1 {
        font-size: 4rem;
        margin-bottom: 0;
    }

    .gallery-swiper {
        padding: 1rem 0 0.75rem;
    }

    .gallery-card {
        height: 500px;
        padding: 1rem;
        gap: 0.5rem;
    }

    .card-photos {
        height: 190px;
    }
}

/* =====================================================================
   TABLETS & PHONES (under 1024px): COLLAPSIBLE "FILE CABINET" LIST
   Tap a title to open a card; tap its photo to enlarge it.
   ===================================================================== */
@media (max-width: 1023px) {
    .gallery-controls,
    .gallery-hint-desktop {
        display: none;
    }

    .gallery-swiper {
        width: 100%;
        max-width: 900px;
        /* Optimal reading width */
        padding: 0 1rem 1rem;
    }

    /* Stack the cards vertically (Swiper is not running at this size) */
    #gallery-wrapper {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        transform: none !important;
        width: 100% !important;
    }

    .swiper-slide {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        display: block;
    }

    /* Collapsed card: only the title bar shows (grows if a long title wraps onto more lines) */
    .gallery-card {
        width: 100%;
        height: auto;
        min-height: 60px;
        margin: 0;
        gap: 0;
        padding: 0.8rem 1rem;
        justify-content: flex-start;
        border-left: 5px solid #000;
        border-left: 5px solid rgb(from var(--accent) calc(r * 0.2) calc(g * 0.2) calc(b * 0.2));
        /* Dark accent-tinted status bar */
        transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
    }

    /* Expanded card (toggled by gallery.js) */
    .gallery-card.active {
        height: auto;
        border-left: 5px solid var(--accent);
        /* Bright active bar */
        background: rgba(0, 0, 0, 0.95);
        background: rgb(from var(--accent) calc(r * 0.04) calc(g * 0.04) calc(b * 0.04) / 0.95);
        box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.3);
    }

    /* Title bar with +/- indicator; shown first even though the photo comes first in the HTML */
    .card-title {
        order: -1;
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0.5rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        font-weight: bold;
        font-size: 1rem;
        min-height: calc(60px - 1.6rem - 0.5rem);
    }

    .card-title::after {
        content: '+';
        font-family: monospace;
        font-size: 1.2rem;
        color: var(--accent);
        transition: transform 0.3s;
    }

    .gallery-card.active .card-title::after {
        content: '-';
        transform: rotate(180deg);
    }

    /* Photo, text and button stay hidden until the card opens */
    .card-photos {
        height: 0;
        opacity: 0;
        border: none;
        transition: opacity 0.3s ease;
    }

    .gallery-card.active .card-photos {
        height: 250px;
        opacity: 1;
        margin: 0.5rem 0 1rem;
        border: 1px solid var(--accent);
    }

    /* Touch screens can't hover, so the enlarge hint is always visible on an open card */
    .gallery-card.active .card-photos a::after {
        opacity: 1;
        transform: translateY(0);
        content: '[ + TAP TO ENLARGE ]';
    }

    .card-description {
        height: 0;
        opacity: 0;
        overflow: hidden;
        font-size: 0.85rem;
        transition: opacity 0.3s ease 0.1s;
    }

    .gallery-card.active .card-description {
        height: auto;
        opacity: 1;
        margin-bottom: 1rem;
    }

    /* Tags sit small in the corner of a closed card */
    .card-tags {
        position: absolute;
        bottom: 10px;
        right: 2.5rem;
        opacity: 0.5;
        transform: scale(0.8);
        transform-origin: bottom right;
        pointer-events: none;
    }

    .gallery-card.active .card-tags {
        position: static;
        opacity: 1;
        transform: scale(1);
        pointer-events: auto;
    }

    .album-btn {
        display: none;
    }

    .gallery-card.active .album-btn {
        display: block;
        margin-top: 1rem;
        align-self: flex-start;
    }
}

@media (max-width: 768px) {
    /* No top navbar on phones (it's a bottom bar), so less space above the title */
    #gallery-container {
        padding-top: 1rem;
    }

    h1 {
        font-size: 2.5rem;
    }
}

@media (min-width: 769px) and (max-width: 1023px) {
    h1 {
        font-size: 3rem;
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 600px) {
    /* Very small phones: no room for tags on a closed card */
    .card-tags {
        display: none;
    }

    .gallery-card.active .card-tags {
        display: flex;
    }

    .card-tag {
        font-size: 0.7rem;
    }
}

/* =====================================================================
   ALBUM OVERLAY: every photo in one card
   ===================================================================== */
.album-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.album-overlay[hidden] {
    display: none;
}

.album-overlay.open {
    opacity: 1;
}

.album-panel {
    position: relative;
    width: 100%;
    max-width: 1000px;
    max-height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.92);
    border: 1px solid var(--accent);
    box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.35);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.3s ease;
}

.album-overlay.open .album-panel {
    transform: none;
}

.album-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px dashed var(--accent);
    padding-bottom: 0.75rem;
}

.album-title {
    font-family: 'VT323', monospace;
    font-size: 2.4rem;
    font-weight: 400;
    line-height: 1;
    text-transform: uppercase;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.album-title::before {
    content: '> ';
    opacity: 0.6;
}

.album-close {
    flex-shrink: 0;
    font-family: 'VT323', monospace;
    font-size: 1.6rem;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--accent);
    padding: 0.1rem 0.7rem;
    text-shadow: 0 0 10px var(--accent);
    cursor: pointer;
    transition: all 0.3s;
}

.album-close:hover,
.album-close:focus-visible {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 15px var(--accent);
}

.album-meta {
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    letter-spacing: 0.1rem;
    color: rgba(var(--accent-rgb), 0.6);
    margin: 0.5rem 0 1rem;
}

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

/* A single photo gets the full width instead of one small tile */
.album-grid.single {
    grid-template-columns: 1fr;
}

.album-thumb {
    display: block;
    padding: 0;
    aspect-ratio: 4 / 3;
    border: 1px solid rgba(var(--accent-rgb), 0.5);
    background: #000;
    overflow: hidden;
    cursor: zoom-in;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.album-grid.single .album-thumb {
    aspect-ratio: auto;
    max-height: 55vh;
}

.album-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: opacity 0.3s, transform 0.4s;
}

.album-grid.single .album-thumb img {
    max-height: 55vh;
    object-fit: contain;
}

.album-thumb:hover,
.album-thumb:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.5);
    outline: none;
}

.album-thumb:hover img,
.album-thumb:focus-visible img {
    opacity: 1;
    transform: scale(1.04);
}

.album-description {
    color: rgba(var(--accent-rgb), 0.8);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 1.25rem 0 1rem;
}

.album-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* No page scrolling behind an open album */
body.album-open {
    overflow: hidden;
}

@media (max-width: 600px) {
    .album-overlay {
        padding: 0.75rem;
    }

    .album-panel {
        padding: 1rem;
    }

    .album-title {
        font-size: 1.8rem;
    }
}

/* --- FOOTER (gallery only) ---
   This page is barely taller than the screen, so the shared footer (base.css) is made more compact here:
   less padding, a tighter gap under the links, and a little space so it doesn't touch the hint line above. */
footer {
    padding: 1rem;
    margin-top: 1rem;
}

.footer-links {
    margin-bottom: 0.5rem;
}

/* --- REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
    .gallery-card::before {
        animation: none;
    }

    .album-overlay,
    .album-panel,
    .card-image {
        transition: none;
    }
}
