/* gallery.css - Main styles, mobile-first grid */
/* Modern, sharp-edged photography portfolio aesthetic */

/* CSS Reset and Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --target-height: 180px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1,
h2,
h3 {
    line-height: 1.1;
    font-weight: 500;
    letter-spacing: -0.02em;
}

/* Hero/Cover Section */
.hero {
    position: relative;
    width: 100vw;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    height: 50vh;
    min-height: 320px;
    max-height: 450px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 0;
    /* Initial state for lazy-loaded hero */
    background-image: none;
    opacity: 0.9;
    filter: blur(3px);
    transition: opacity 0.6s ease-out, filter 0.6s ease-out;
}

/* Hero loaded state - smooth fade-in */
.hero.hero-loaded {
    opacity: 1;
    filter: blur(0);
    background-size: cover;
    background-position: center;
}

/* Hero error fallback */
.hero.hero-error {
    opacity: 1;
    filter: blur(0);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.1) 50%, transparent 100%);
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 24px;
    color: #ffffff;
}

.hero-title {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hero-subheader {
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.85;
}

/* Gallery Header (no cover) */
.gallery-header {
    text-align: center;
    padding: 60px 24px 48px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

.gallery-title {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.gallery-subheader {
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Gallery Links Section */
.gallery-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
}

.gallery-links-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    flex: 1;
}

.gallery-link-pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 12px;
    background-color: transparent;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid var(--border-color);
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.gallery-link-pill:hover {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-link-pill:focus {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--text-primary-rgb, 0, 0, 0), 0.15);
}

.gallery-link-pill:active {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}

.gallery-link-pill.active {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-primary);
}

/* Gallery Metadata */
.gallery-meta {
    display: flex;
    gap: 24px;
    padding: 16px 0;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
}

/* Download Actions */
.download-actions {
    display: flex;
    gap: 12px;
    padding: 24px 0;
    margin-bottom: 0;
}

/* Modern Button Base Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    min-width: 48px;
    padding: 14px 28px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--accent-color-rgb, 0, 0, 0), 0.2);
}

.btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-download-all {
    background-color: var(--accent-color);
    color: var(--bg-primary);
}

.btn-download-all:hover {
    background-color: var(--accent-hover);
}

.btn-download-all:focus {
    box-shadow: 0 0 0 3px rgba(var(--accent-color-rgb, 100, 100, 100), 0.3);
}

.btn-icon {
    font-size: 1rem;
}

/* Gallery Grid - Mobile First */
.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 16px;
    padding-bottom: 60px;
    background-color: var(--bg-primary);
    /* Changed from border-color to bg-primary for cleaner look */
}

.gallery-grid::after {
    content: '';
    flex-grow: 999999999;
}

.gallery-item {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    transition: opacity 0.2s ease;
    /* Height is now controlled by content + flex scaling */
    width: auto;
    max-width: 100%;
    /* Prevent overflow on small screens */
    position: relative;
}

.gallery-item-image-container {
    height: var(--target-height);
    /* Keep the image part fixed height base */
    overflow: hidden;
    border-radius: 8px;
    /* Rounded corners */
    width: 100%;
    position: relative;
}

.gallery-item:hover .gallery-item-image-container {
    opacity: 0.9;
}

.gallery-item-button {
    width: 100%;
    height: 100%;
    /* Fill the container */
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    touch-action: manipulation;
    display: block;
}

.gallery-item-button:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 8px;
}

.gallery-thumbnail {
    width: 100%;
    height: 100%;
    /* Fill height */
    display: block;
    object-fit: cover;
    /* Fill container completely */
    transition: transform 0.3s ease;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
}

.gallery-thumbnail[loading="lazy"] {
    opacity: 0;
}

.gallery-thumbnail.loaded {
    opacity: 1;
    animation: fadeIn 0.4s ease-out;
}

.gallery-item:hover .gallery-thumbnail {
    transform: scale(1.02);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.gallery-item-info {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    color: var(--text-primary);
}

.image-filename {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-dimensions {
    font-size: 0.6875rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    background-color: var(--lightbox-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: var(--lightbox-text);
    border: 1px solid var(--lightbox-border);
    font-size: 1.5rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.lightbox-close:hover {
    background-color: var(--lightbox-hover-bg);
    border-color: var(--lightbox-hover-border);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.lightbox-close:focus {
    background-color: var(--lightbox-focus-bg);
    border-color: var(--lightbox-focus-border);
    outline: none;
    box-shadow: 0 0 0 3px var(--lightbox-focus-ring);
}

.lightbox-close:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 56px;
    height: 56px;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: var(--lightbox-text);
    border: 1px solid var(--lightbox-border);
    font-size: 1.25rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.lightbox-nav:hover {
    background-color: var(--lightbox-hover-bg);
    border-color: var(--lightbox-hover-border);
    transform: translateY(-50%) translateX(var(--nav-hover-x, 0));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.lightbox-prev {
    --nav-hover-x: -2px;
}

.lightbox-next {
    --nav-hover-x: 2px;
}

.lightbox-nav:focus {
    background-color: var(--lightbox-focus-bg);
    border-color: var(--lightbox-focus-border);
    outline: none;
    box-shadow: 0 0 0 3px var(--lightbox-focus-ring);
}

.lightbox-nav:active {
    transform: translateY(-50%) translateX(0) scale(0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 16px 100px;
    overflow: hidden;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    touch-action: pinch-zoom pan-x pan-y;
    transition: opacity 0.3s ease, transform 0.15s ease;
}

.lightbox-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    background: var(--lightbox-footer-bg);
    transition: opacity 0.3s ease;
}

.lightbox-counter {
    color: var(--lightbox-text);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.lightbox-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 20px;
    background-color: transparent;
    color: var(--lightbox-text);
    border: 1px solid var(--lightbox-border);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.lightbox-download:hover {
    background-color: var(--lightbox-hover-bg);
    border-color: var(--lightbox-hover-border);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.lightbox-download:focus {
    background-color: var(--lightbox-focus-bg);
    border-color: var(--lightbox-focus-border);
    outline: none;
    box-shadow: 0 0 0 3px var(--lightbox-focus-ring);
}

.lightbox-download:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Tablet breakpoint (768px+) */
@media (min-width: 768px) {
    :root {
        --target-height: 220px;
    }

    .container {
        padding: 0 32px;
    }

    .hero {
        width: 100vw;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        height: 60vh;
        max-height: 550px;
        margin-bottom: 0;
    }

    .hero-title {
        font-size: 2.75rem;
    }

    .gallery-header {
        padding: 80px 32px 64px;
    }

    .gallery-title {
        font-size: 2.75rem;
    }

    .lightbox-nav {
        display: flex;
    }

    .gallery-item-info {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 14px 16px;
    }

    .gallery-link-pill {
        min-height: 40px;
        padding: 8px 16px;
        font-size: 0.70rem;
    }

    .download-actions {
        padding: 32px 0;
    }
}

/* Desktop breakpoint (1024px+) */
@media (min-width: 1024px) {
    :root {
        --target-height: 250px;
    }

    .container {
        padding: 0 48px;
    }

    .hero {
        width: 100vw;
        left: 50%;
        right: 50%;
        margin-left: -50vw;
        margin-right: -50vw;
        height: 70vh;
        max-height: 700px;
    }

    .hero-title {
        font-size: 3.5rem;
    }

    .hero-content {
        padding: 60px 40px;
    }

    .gallery-header {
        padding: 100px 48px 80px;
    }

    .gallery-title {
        font-size: 3.25rem;
    }

    .gallery-link-pill {
        min-height: 42px;
        padding: 10px 20px;
        font-size: 0.75rem;
    }

    .gallery-links-scroll {
        gap: 10px;
    }
}

/* Large desktop (1280px+) */
@media (min-width: 1280px) {
    :root {
        --target-height: 280px;
    }
}

/* Extra large desktop (1536px+) */
@media (min-width: 1536px) {
    :root {
        --target-height: 320px;
    }

    .container {
        padding: 0 64px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .gallery-item:hover {
        opacity: 1;
    }

    .gallery-item:hover .gallery-thumbnail {
        transform: none;
    }

    .gallery-item-button:focus {
        outline: none;
    }

    .gallery-item:active {
        opacity: 0.8;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .gallery-thumbnail[loading="lazy"] {
        opacity: 1;
    }

    .hero {
        opacity: 1;
        filter: blur(0);
    }
}

/* Toast Notification Styles */
.download-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    z-index: 2000;
    max-width: 90%;
    text-align: center;
    animation: fadeInUp 0.3s ease-out;
}

.download-toast.download-toast-success {
    background-color: #1a1a1a;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.download-toast.download-toast-error {
    background-color: #1a1a1a;
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.download-toast.download-toast-info {
    background-color: #1a1a1a;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Footer */
.gallery-footer {
    text-align: center;
    padding: 40px 0;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8125rem;
}