:root {
    /* dark defaults */
    --bg: #0b0b0b;
    --bg-dark: #0b0b0b;
    --boarder: #ffffff16;
    --text-color: var(--fg);
    --muted: #a8a8a8;
    --fg: #e9e9e9;
    --primary: #e9e9e9;
    --primary2: #a8a8a8;
    --info: #2a5bff;
    --hover: #ffb703;
    --accent: #ffb703;

    --lightbox: #cfcfcf;
    --lightbox-muted: #cfcfcfb4;

    --header-color: hsl(0, 0%, 95%);

    --gallery-bg: color-mix(in oklab, var(--bg) 92%, var(--fg) 8%);

    --gap: 12px;
    --radius: 14px;
    --maxw: 1400px;
    --lb-pad: clamp(12px, 4vw, 24px);

    --font-sans: "Roboto", system-ui, -apple-system, "Segoe UI", Ubuntu, Cantarell, "Noto Sans", sans-serif;
}


/* System fallback if no data-theme (safety) */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f7f7f7;
        --fg: #0b0b0b;
        --text-color: var(--fg);
        --muted: #454545;
        --accent: #2a5bff;
    }
}

/* Explicit overrides */
html[data-theme="light"] {
    --bg: hsl(0, 0%, 85%);
    --fg: hsl(0, 0%, 4%);
    --text-color: hsl(0, 0%, 10%);
    --header-color: hsl(0, 0%, 1%);
    --muted: hsl(0, 0%, 40%);
    --accent: #e63946;
    --hover: #ffb703;
}

html[data-theme="dark"] {
    --bg: hsl(0, 0%, 10%);
    --bg2: #0b0b0b;
    --bg3: #0b0b0b;
    --boarder: #ffffff16;
    --fg: hsl(0, 0%, 91%);
    --text-color: hsl(0, 0%, 90%);
    --header-color: hsl(0, 0%, 99%);
    --muted: hsl(0, 0%, 60%);
    --primary: #e9e9e9;
    --primary2: #a8a8a8;
    --info: #2a5bff;
    --hover: #ffb703;
    --accent: #ffb703;
}



/* Base uses the tokens */
html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--header-color);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
}

/* Full-bleed section that spans the viewport width while content stays centered */
.gallery-section {
    background: var(--gallery-bg);

    /* Full-bleed “edge to edge” while inside a centered container */
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);

    /* Vertical rhythm; horizontal padding handled by .gallery-inner */
    padding: 24px 0;
}

/* Inner shell keeps content constrained to your design width */
.gallery-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--gap);
}

/* Actions + theme button */
.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.theme-btn {
    border: 1px solid currentColor;
    background: transparent;
    color: var(--fg);
    border-radius: 999px;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
}

.theme-btn .icon {
    width: 22px;
    height: 22px;
    display: block;
}


/* icon swap */
.theme-btn .icon-moon {
    display: none;
}

html[data-theme="light"] .theme-btn .icon-sun {
    display: none;
}

html[data-theme="light"] .theme-btn .icon-moon {
    display: block;
}

/* Centered theme toggle below bio */
.theme-toggle-wrap {
    display: flex;
    justify-content: center;
    margin: 24px 0;
}

/* Button inherits variables */
.theme-toggle-wrap .theme-btn {
    border: 1px solid var(--fg);
    /* instead of currentColor */
    background: var(--bg);
    color: var(--fg);
    border-radius: 999px;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle-wrap .theme-btn:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--bg) 85%, var(--accent) 15%);
    transform: scale(1.05);
}

/* Light/dark icon swap remains unchanged */
.theme-btn .icon-moon {
    display: none;
}

html[data-theme="light"] .theme-btn .icon-sun {
    display: none;
}

html[data-theme="light"] .theme-btn .icon-moon {
    display: block;
}



/* Bio block */
.bio {
    max-width: var(--maxw);
    margin: auto;
    padding: 16px;
    display: grid;
    gap: 16px;
    align-items: center;

}

@media (min-width:800px) {
    .bio {
        grid-template-columns: auto 1fr;
    }
}

.portrait {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
}

.bio .text p {
    margin: 0;
    color: var(--text-color);
}


* {
    box-sizing: border-box;
}


img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Utility */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(0, 0, 0, .7);
    border-bottom: 1px solid #ffffff16;
}

.bar {
    max-width: var(--maxw);
    margin: auto;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    letter-spacing: .18em;
    font-weight: 700;
}

/* Main gallery */
main {
    max-width: var(--maxw);
    margin: auto;
    padding: 16px;

}

.sub {
    color: var(--muted);
    margin: 8px 0 18px;
}

.grid {
    /* masonry via CSS columns */
    column-width: 320px;
    column-gap: var(--gap);
}

@media (max-width:600px) {
    .grid {
        column-width: 280px;
    }
}


/* skip paint offscreen */
.card {
    display: block;
    background: #00000020;
    border-radius: var(--radius);
    overflow: hidden;
    break-inside: avoid;
    margin: 0 0 var(--gap);
    position: relative;
}

.card-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 10px;
    color: #fff;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.9) 0%,
            rgba(0, 0, 0, 0.6) 70%,
            rgba(0, 0, 0, 0.0) 100%);
    /*background: rgba(0, 0, 0, 0.8);*/
    transform: translateY(8px);
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
    font-size: 13px;
    line-height: 1.35;
    pointer-events: none;
    /* let clicks pass through to the card */
}

.card:hover .card-meta,
.card:focus-within .card-meta {
    opacity: 1;
    transform: translateY(0);
}

.card-meta .cap {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta .cats {
    margin-top: 2px;
    font-size: 12px;
    color: #e6e6e6;
    opacity: .95;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .card-meta {
        transition: none;
        transform: none;
    }
}

/* Show overlay by default on devices without hover */
@media (hover: none),
(pointer: coarse) {
    .card .card-meta {
        opacity: 1;
        transform: none;
        pointer-events: none;
        /* keep taps going to the card */
    }
}


.card img {
    width: 100%;
    height: auto;
    /* preserve aspect ratio */
    display: block;
}

/* Lightbox */
.lightbox[hidden] {
    display: none;
}

body.lb-open {
    overflow: hidden;
    touch-action: none;
}

/* Center the media block inside the lightbox */
.lb-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* centers the image horizontally */
    max-width: 96vw;
    color: var(--lightbox-muted);
}

.lb-content {
    /* keep your existing rules, then add/override: */
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    /* pos | image | cap | cats */
    justify-items: center;
    align-self: stretch;
    height: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;

    overflow: hidden;
}

.lb-content {
    grid-area: content;
    justify-self: center;
}

.lb-pos {
    font-size: 13px;
    color: var(--lightbox-muted);
    margin-bottom: 6px;
}

/* Ensure the image itself can center and never overflow */
.lightbox img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    display: block;
    border-radius: 10px;
}

@supports (height: 100dvh) {
    .lightbox img {
        max-height: 80dvh;
    }
}


/* If the image is portrait and very tall, give it priority height on narrow screens */
@media (max-width: 480px) {
    .lightbox img {
        max-height: 78svh;
    }

    @supports (height: 100dvh) {
        .lightbox img {
            max-height: 78dvh;
        }
    }
}

.lightbox {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: clamp(12px, 4vw, 24px);
    background: rgba(0, 0, 0, .92);
    z-index: 100;
    min-height: 100svh;
    touch-action: none;
    /* required for PointerEvents preventDefault */
    overscroll-behavior: contain;
    /* avoid bounce/scroll chaining on mobile */

    /* padding with safe areas */
    padding-top: calc(env(safe-area-inset-top) + var(--lb-pad));
    padding-bottom: calc(env(safe-area-inset-bottom) + var(--lb-pad));
    padding-left: calc(env(safe-area-inset-left) + var(--lb-pad));
    padding-right: calc(env(safe-area-inset-right) + var(--lb-pad));

    min-height: 100svh;
    /* small viewport height for mobile */

}

@supports (height: 100dvh) {
    .lightbox {
        min-height: 100dvh;
    }
}

/* Stage: arrows | media | arrows */
/* Stage: arrows | media | arrows */
.lb-stage {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "prev content next";
    align-items: center;
    justify-items: center;
    /* centers content horizontally */
    gap: clamp(8px, 2vw, 16px);
    max-width: 96vw;
    width: 100%;

}

#lb-prev {
    grid-area: prev;
}


#lb-next {
    grid-area: next;
}

/* keep column space but make the button non-interactive and invisible */
.lb-btn.is-hidden {
    visibility: hidden;
    pointer-events: none;
}

/* optional: style for disabled (SR + fallback) */
.lb-btn[aria-disabled="true"] {
    cursor: default;
}


/* Respect iOS safe areas so controls aren't clipped */
.lightbox {
    padding-top: calc(env(safe-area-inset-top) + clamp(12px, 4vw, 24px));
    padding-bottom: calc(env(safe-area-inset-bottom) + clamp(12px, 4vw, 24px));
    padding-left: calc(env(safe-area-inset-left) + clamp(12px, 4vw, 24px));
    padding-right: calc(env(safe-area-inset-right) + clamp(12px, 4vw, 24px));
}

.lightbox img {
    max-width: 96vw;
    max-height: 80svh;
    /* leave room for caption and nav */
    height: auto;
    width: auto;
    border-radius: 10px;
}

/* If dynamic vh is available, prefer it */
@supports (height: 100dvh) {
    .lightbox img {
        max-height: 80dvh;
    }
}

.lb-close {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 8px);
    right: calc(env(safe-area-inset-right) + 8px);
    width: 44px;
    height: 44px;
    /* 44px minimum touch size */
    display: grid;
    place-items: center;
    font-size: 28px;
    line-height: 1;
    background: transparent;
    color: #fff;
    border: 0;
    cursor: pointer;
}

.lb-cap {
    color: var(--lightbox);
    margin-top: 10px;
    text-align: center;
    max-width: 90ch;
    max-height: 20svh;
    overflow: auto;
    word-break: break-word;
}

.lb-cats {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@supports (height: 100dvh) {
    .lb-cap {
        max-height: 20dvh;
    }
}

/*Hide Arrows on mobile*/
@media (hover: none),
(pointer: coarse) {
    .lb-btn {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .lb-stage {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "content content"
            "prev    next";
        justify-items: center;
    }

    .lb-btn {
        position: static !important;
        transform: none !important;
        width: 48px;
        height: 48px;
    }

    #lb-prev {
        grid-area: prev;
    }

    #lb-next {
        grid-area: next;
    }
}


.lb-nav {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.lb-btn {
    background: var(--bg);
    border: 1px solid color-mix(in oklab, var(--accent) 18%, transparent);
    color: var(--accent);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    cursor: pointer;
    touch-action: manipulation;
}

.lb-btn:hover {
    background: color-mix(in oklab, var(--accent) 16%, transparent);
}

.lb-hint {
    position: absolute;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 12px);
    transform: translateX(-50%) translateY(8px);
    background: color-mix(in srgb, var(--bg) 75%, transparent);
    color: var(--fg);
    border: 1px solid color-mix(in oklab, var(--fg) 20%, transparent);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}

.lightbox.show-hint .lb-hint {
    opacity: .95;
    transform: translateX(-50%) translateY(0);
}

/* Touch shows "Swipe to navigate"; desktop shows "Use ← / →" (if you kept both spans) */
@media (hover: none),
(pointer: coarse) {
    .hint-keys {
        display: none;
    }
}

@media (hover: hover) and (pointer: fine) {
    .hint-touch {
        display: none;
    }
}




/* Footer */
footer {
    border-top: 1px solid #ffffff16;
    margin-top: 18px;
}

.foot {
    max-width: var(--maxw);
    margin: auto;
    padding: 18px 16px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}


.scroll-cta button {
    all: unset;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 5px 0 30px 0;
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--muted);
    transition: color 0.3s ease, transform 0.3s ease;
}

.scroll-cta button:hover {
    color: var(--accent);
    transform: translateY(4px);
}

.scroll-cta .arrow {
    font-size: 2rem;
    margin-top: 8px;
    line-height: 1;
    transition: transform 0.3s ease;
}

.scroll-cta button:hover .arrow {
    transform: translateY(6px);
}


.divider {
    border: none;
    border-top: 1px solid var(--muted);
    width: 75%;
    margin: 2cm auto;
    opacity: 0.5;
}

.gallery-head {
    max-width: var(--maxw);
    margin: 0 auto var(--gap);
    padding: 0 var(--gap);
    display: grid;
    grid-template-columns: 1fr auto;
    /* title left, filter right */
    align-items: center;
    gap: var(--gap);
}

@media (max-width: 720px) {
    .gallery-head {
        grid-template-columns: 1fr;
    }
}

/* Controls */
.gallery-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gallery-controls label {
    font-size: 0.95rem;
    color: var(--muted);
}

/* Native select, styled consistently */
#cat-filter {
    appearance: none;
    /* remove native arrow (Chrome/Safari) */
    -moz-appearance: none;
    /* Firefox */
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: var(--bg);
    color: var(--fg);
    padding: 8px 36px 8px 12px;
    border-radius: 10px;
    font: inherit;
    line-height: 1.15;
    position: relative;
}

/* Custom caret */
#cat-filter {
    background-image:
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="%23a8a8a8" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
}

/* Focus and hover states */
#cat-filter:hover {
    border-color: var(--accent);
}

#cat-filter:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Light theme border contrast */
html[data-theme="light"] #cat-filter {
    border-color: rgba(0, 0, 0, 0.25);
}

#cat-filter {
    min-width: 220px;
    height: 40px;
}


#cat-filter {
    transition: border-color .2s ease, box-shadow .2s ease;
}

#cat-filter:focus {
    box-shadow: 0 0 0 4px rgba(255, 183, 3, 0.2);
}

/* match --accent */

#cat-filter {
    border-radius: 999px;
}


/* Mobile-only back-to-top button */
.mobile-top-btn {
    position: fixed;
    left: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 12px);
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid color-mix(in oklab, var(--fg) 25%, transparent);
    background: color-mix(in oklab, var(--bg) 85%, transparent);
    color: var(--fg);
    display: grid;
    place-items: center;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease, border-color .2s ease;
    backdrop-filter: saturate(120%) blur(6px);
}

.mobile-top-btn.is-visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.mobile-top-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Hide while lightbox is open */
body.lb-open .mobile-top-btn {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Desktop hides by default */
@media (hover: hover) and (pointer: fine) {
    .mobile-top-btn {
        display: none;
    }
}

/* Layout container for portrait + socials */
.bio-aside {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 10px;
}

/* Social strip */
.social {
    display: flex;
    gap: 14px;
}

.social-link {
    color: var(--text-color);
}

.social-link:hover {
    color: var(--accent);
}

.si {
    inline-size: 24px;
    block-size: 24px;
    display: inline-block;
    background-color: currentColor;
}

/* Brand masks via Simple Icons CDN */
.si-instagram {
    -webkit-mask: url("https://cdn.simpleicons.org/instagram") no-repeat center / contain;
    mask: url("https://cdn.simpleicons.org/instagram") no-repeat center / contain;
}

.si-github {
    -webkit-mask: url("https://cdn.simpleicons.org/github") no-repeat center / contain;
    mask: url("https://cdn.simpleicons.org/github") no-repeat center / contain;
}