:root {
    --bg: #0f0f10;
    --bg-elev: #1a1a1c;
    --fg: #f4f4f5;
    --muted: #9ca3af;
    --accent: #e11d48;
    --accent-hover: #f43f5e;
    --coffee: #ffdd00;
    --coffee-hover: #ffe54d;
    --border: #2a2a2e;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

/* Skip-to-content link for keyboard accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}
.skip-link:focus {
    top: 0;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
                 Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    /* Prevent stray horizontal overflow (from 100vw children, long button text,
       or third-party widgets like Ko-fi) from producing a horizontal scrollbar
       that then visually "cuts off" fixed-positioned elements near the right edge. */
    overflow-x: hidden;
}

.site-header {
    text-align: center;
    padding: 3rem 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #18181b 0%, var(--bg) 100%);
}

.site-title {
    /* inline-block so the clipped background sizes to the text width,
       not the full-width header block. */
    display: inline-block;
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin: 0;
    letter-spacing: -0.03em;
    font-weight: 900;
    /* Unfurled American flag shown through the letters as "windows".
       Source: photograph "Arby's Flag - American Flag" by Tony Webster,
       via Wikimedia Commons / Flickr, licensed CC BY 2.0
       (https://creativecommons.org/licenses/by/2.0/). Cropped to the US flag
       (the adjacent Arby's pennant and most of the night sky removed).
       The flag-red background-color sits behind the photo so any black sky
       at the corners of the cover-fitted image still reads as flag, not as
       the page bg, through the letter cutouts. */
    background-color: #b22234;
    background-image: url('images/decor/us-flag.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.tagline {
    margin: 0.5rem 0 1.5rem;
    color: var(--muted);
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    box-shadow: var(--shadow);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--coffee);
    color: #111;
}
.btn-secondary:hover {
    background: var(--coffee-hover);
    transform: translateY(-2px);
}

/* Ko-fi floating-chat widget defaults to a 195px-wide iframe, which is too
   narrow for the custom "Buy me a coffee" label and causes an internal
   horizontal scrollbar that visually cuts off the button. Widen the iframe
   (and its wrap) enough to fit the longer text. */
.floatingchat-container-wrap,
.floatingchat-container-wrap-mobi {
    max-width: 240px !important;
}
.floatingchat-container,
.floatingchat-container-mobi {
    width: 240px !important;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

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

.tile {
    position: relative;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    /* Inherit text styling instead of <button> defaults. */
    font: inherit;
    color: inherit;
}

/* Subtle dark overlay on hover/focus reinforces "click to enlarge". */
.tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

/* Always-visible magnifying-glass badge in the top-right corner.
   The SVG is inlined as a data URI so the icon stays crisp at any size
   and doesn't depend on emoji-font availability. */
.tile::after {
    content: "";
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.55);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/><line x1='8' y1='11' x2='14' y2='11'/><line x1='11' y1='8' x2='11' y2='14'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    opacity: 0.85;
    transform: scale(1);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
    pointer-events: none;
}

.tile:hover,
.tile:focus-visible {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 10px 25px rgba(225, 29, 72, 0.25);
    outline: none;
}

.tile:hover::before,
.tile:focus-visible::before {
    opacity: 1;
}

.tile:hover::after,
.tile:focus-visible::after {
    opacity: 1;
    transform: scale(1.1);
    background-color: var(--accent);
}

/* Touch / no-hover devices never get the hover state, so promote the badge
   to its emphasized form by default. This keeps the "tap to enlarge"
   affordance obvious on phones and tablets. */
@media (hover: none) {
    .tile::after {
        opacity: 1;
        background-color: var(--accent);
        border-color: rgba(255, 255, 255, 0.4);
        box-shadow: 0 2px 8px rgba(225, 29, 72, 0.5),
                    0 2px 6px rgba(0, 0, 0, 0.45);
    }
}

.tile img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    /* Keep the image below the hover overlay/badge pseudo-elements. */
    position: relative;
    z-index: 0;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.lightbox.open {
    display: flex;
}

/* Holds the image + download button as a vertical stack so the button
   sits directly below the image rather than pinned to the viewport. */
.lightbox-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 95vw;
    max-height: 90vh;
}

.lightbox-image {
    /* Sizing is driven by the stage; leave room for the button below. */
    max-width: 100%;
    max-height: calc(90vh - 4rem);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    transition: opacity 0.15s ease;
}

.lightbox.loading .lightbox-image {
    opacity: 0;
    /* Hide instantly so the previously-loaded image doesn't flash
       while the newly-selected full-size file is still decoding. */
    transition: none;
}

.lightbox.loading::before {
    content: "";
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    text-decoration: none;
}

.lightbox-close:hover,
.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-close {
    top: 1rem;
    right: 1rem;
    font-size: 1.75rem;
    line-height: 1;
}

/* Row of action buttons (Download, Shop) shown directly below the image. */
.lightbox-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

/* Prominent download CTA: accent-colored pill directly below the image. */
.lightbox-download {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.4rem;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.01em;
    border: none;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.lightbox-download:hover,
.lightbox-download:focus-visible {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(225, 29, 72, 0.45);
    outline: none;
}

.lightbox-download-icon {
    font-size: 1.6rem;
    line-height: 1;
    /* The ⬇ glyph sits below its em-box center in most fonts;
       nudge it up so it visually aligns with the label baseline. */
    position: relative;
    top: -2px;
}

/* Shop CTA: sits next to the download button below each full-size image. */
.lightbox-shop {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.4rem;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.01em;
    border: none;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.lightbox-shop:hover,
.lightbox-shop:focus-visible {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(225, 29, 72, 0.45);
    outline: none;
}

.lightbox-shop-icon {
    font-size: 1.2rem;
    line-height: 1;
}

/* Share button (same style as Download/Shop) */
.lightbox-share {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.4rem;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.01em;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
}

.lightbox-share:hover,
.lightbox-share:focus-visible {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(225, 29, 72, 0.45);
    outline: none;
}

.lightbox-share-icon {
    font-size: 1.4rem;
    line-height: 1;
}

/* Share menu popup */
.share-menu {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.share-menu.open {
    display: flex;
}

.share-menu-content {
    position: relative;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.share-menu-title {
    margin: 0 0 1.5rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--fg);
}

.share-menu-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    line-height: 1;
}

.share-menu-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.share-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.share-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    text-decoration: none;
    color: var(--fg);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    width: 100%;
    text-align: left;
}

.share-option:hover,
.share-option:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    transform: translateX(4px);
    outline: none;
}

.share-option-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.share-option-label {
    flex: 1;
}

.lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }

.site-footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

@media (max-width: 600px) {
    main {
        padding: 1.25rem 0.75rem;
    }
    .site-header {
        padding: 2rem 1rem 1.5rem;
    }
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.6rem;
    }
    .tile::after {
        top: 0.4rem;
        right: 0.4rem;
    }
    .lightbox {
        padding: 0.75rem;
    }
    .lightbox-stage {
        /* 100% of the lightbox's content box rather than 100vw, so scrollbar
           width doesn't cause overflow. */
        max-width: 100%;
        gap: 0.75rem;
    }
    .lightbox-image {
        max-height: calc(90vh - 3.5rem);
    }
    .lightbox-close,
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    .lightbox-close {
        top: 0.5rem;
        right: 0.5rem;
    }
    .lightbox-prev { left: 0.25rem; }
    .lightbox-next { right: 0.25rem; }
    .lightbox-download,
    .lightbox-shop {
        padding: 0.65rem 1.2rem;
        font-size: 0.9rem;
    }
    .lightbox-download-icon {
        font-size: 1.4rem;
    }
    .lightbox-shop-icon {
        font-size: 1.1rem;
    }
    .lightbox-share {
        padding: 0.65rem 1.2rem;
        font-size: 0.9rem;
    }
    .lightbox-share-icon {
        font-size: 1.25rem;
    }
    .lightbox-actions {
        gap: 0.5rem;
    }
    .share-menu-content {
        padding: 1.5rem;
    }
    .share-menu-title {
        font-size: 1.2rem;
    }
}
