:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f8;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --accent-color: #333333;
    --hover-color: #f0f0f0;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #3a3a3a;
    --accent-color: #ffffff;
    --hover-color: #333333;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.7);
}

/* Ensure key icons render white in dark theme for visibility */
html[data-theme="dark"] .theme-toggle svg,
html[data-theme="dark"] .filter-button svg,
html[data-theme="dark"] .filter-dialog-close svg,
html[data-theme="dark"] .social-links a svg,
html[data-theme="dark"] .lightbox-close svg,
html[data-theme="dark"] .lightbox-nav svg {
    color: #ffffff;
    fill: #ffffff;
    stroke: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== Theme Toggle ==================== */
.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 110;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    width: 44px;
    height: 44px;
    box-shadow: var(--shadow-md);
}

.theme-toggle:hover {
    background-color: var(--hover-color);
    transform: rotate(20deg);
}

/* Scroll-to-top button (matches theme-toggle style) */
.scroll-top {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 110;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    width: 44px;
    height: 44px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    pointer-events: none;
}

.scroll-top.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-top:hover {
    background-color: var(--hover-color);
    transform: translateY(-4px) scale(1.02);
}

.sun-icon {
    display: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.moon-icon {
    display: block;
    position: static;
}

/* Inverted: show sun when dark theme is active, hide moon */
html[data-theme="dark"] .sun-icon {
    display: block;
}

html[data-theme="dark"] .moon-icon {
    display: none;
}

/* ==================== Filter Dialog ==================== */
.filter-dialog {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

.filter-dialog[hidden] {
    display: none;
}

.filter-dialog-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.filter-dialog-content {
    position: relative;
    background-color: var(--bg-primary);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
    z-index: 1;
}

.filter-dialog-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    width: 40px;
    height: 40px;
}

.filter-dialog-close:hover {
    background-color: var(--hover-color);
}

/* ==================== Hero Section ==================== */
.hero-section {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    padding: 4rem 2rem;
    margin-bottom: 3rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 3rem;
    align-items: center;
}

.hero-text h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

.bio {
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.social-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    transition: var(--transition);
    text-decoration: none;
}

.social-links a:hover {
    transform: translateY(-4px);
    border-color: var(--text-primary);
    box-shadow: var(--shadow-md);
}

.hero-image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-image {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 3px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

/* ==================== Filter Section ==================== */
.filter-section {
    background-color: var(--bg-secondary);
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto 3rem;
    border-radius: 12px;
    transition: var(--transition);
    display: block;
}

.filter-section.hidden {
    display: none;
}

.filter-container {
    max-width: 1400px;
}

.filter-group {
    margin-bottom: 2rem;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-primary);
}

.filter-tags {
    padding-top: 0.2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* Smooth reveal for details/summary groups */
.filter-group summary {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
}

.filter-group .filter-tags {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.32s ease, opacity 0.28s ease;
    opacity: 0;
}

.filter-group[open] .filter-tags {
    /* Allow the group to expand up to a large portion of the viewport
       so long lists are fully visible; enable internal scrolling. */
    max-height: 75vh;
    opacity: 1;
    overflow-y: auto;
}

/* Country icon (SVG or fallback) inside filter buttons */
.country-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.country-icon svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Country icon in image overlays and lightbox */
.country-icon-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    margin-right: 0.4rem;
    flex-shrink: 0;
    vertical-align: middle;
}

.country-icon-small svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Backward compatibility for emoji flags (deprecated but kept for safety) */
.country-flag {
    display: inline-block;
    width: 1.2em;
    line-height: 1;
    margin-right: 0.5rem;
    font-size: 1.05em;
}

.filter-tag {
    padding: 0.4rem 0.6rem;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
    user-select: none;
}

.filter-tag:hover {
    border-color: var(--text-primary);
    transform: translateY(-2px);
}

.filter-tag.active {
    background-color: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

/* small count badge for filters */
.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    margin-left: 0.5rem;
    border: 1px solid var(--border-color);
}

.filter-tag .filter-label {
    display: inline-block;
}

.clear-filters {
    padding: 0.7rem 1.5rem;
    background-color: transparent;
    border: 2px solid var(--text-secondary);
    border-radius: 25px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-top: 1rem;
}

.clear-filters:hover {
    background-color: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

/* ==================== Gallery Section ==================== */
.gallery-section {
    max-width: 1400px;
    margin: 0 auto 4rem;
    padding: 0 2rem;
}

.gallery-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.search-box {
    flex: 1 1 auto;
}

.controls-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.search-box {
    position: relative;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    max-width: 400px;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

html[data-theme="dark"] .search-box input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Filter Button */
.filter-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.filter-button:hover {
    transform: translateY(-4px);
    border-color: var(--text-primary);
    box-shadow: var(--shadow-md);
}

.filter-button:active {
    transform: translateY(-2px) scale(0.98);
}

.image-counter {
    color: var(--text-secondary);
    font-size: 0.95rem;
    white-space: nowrap;
}

/* ==================== Gallery Grid ==================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 3rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    aspect-ratio: 3 / 2;
}

.gallery-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-8px);
}

.gallery-item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: var(--transition);
    background-color: var(--bg-secondary);
}

.gallery-item:hover .gallery-item-image {
    transform: scale(1.08);
    filter: brightness(0.85);
}

.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.6) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem;
    opacity: 0;
    transition: var(--transition);
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.5rem;
}

.gallery-item-location {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Location button inside overlay */
.location-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.6rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.95);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.75rem;
    transition: var(--transition);
}

.location-button:hover {
    background: rgba(255,255,255,0.14);
    transform: translateY(-2px);
}

.location-button .icon-location {
    width: 1em;
    height: 1em;
}

.location-label {
    line-height: 1;
}

/* Lightbox location button */
.lightbox-location-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.95);
    text-decoration: none;
    font-size: 0.95rem;
    border: 1px solid rgba(255,255,255,0.08);
}

.lightbox-location-button:hover {
    background: rgba(255,255,255,0.12);
}

.gallery-item-tags {
    margin-top: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.gallery-item-tag {
    display: inline-block;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.loading-message,
.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.loading-message p,
.no-results p {
    font-size: 1.1rem;
}

/* ==================== Lightbox ==================== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

.lightbox[hidden] {
    display: none;
}

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

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: -1;
}

.lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    z-index: 1;
    max-width: 95vw;
    width: 100%;
    max-height: 95vh;
    animation: slideUp 0.3s ease-out;
}

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

.lightbox-image-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 70vh;
    position: relative;
}

.lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.lightbox-nav:hover {
    transform: translateY(-50%) scale(1.2);
}

.lightbox-prev {
    left: 0;
}

.lightbox-next {
    right: 0;
}

.lightbox-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    color: white;
    width: 100%;
    max-width: 95vw;
    text-align: center;
    padding: 0 1rem;
}

.lightbox-info h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    line-height: 1.3;
}

.lightbox-info p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

.lightbox-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.lightbox-tag {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    width: 44px;
    height: 44px;
    z-index: 10;
}

.lightbox-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* ==================== Footer ==================== */
.footer {
    background-color: var(--bg-secondary);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 768px) {
    .theme-toggle {
        width: 40px;
        height: 40px;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        align-items: start;
    }

    .avatar-placeholder {
        width: 200px;
        height: 200px;
        font-size: 4rem;
    }

    .avatar-image {
        width: 120px;
        height: 120px;
        margin: 0 auto 0;
    }

    .gallery-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .search-box input {
        max-width: 100%;
    }

    .filter-button {
        width: 100%;
        max-width: 50px;
        align-self: flex-start;
    }

    .image-counter {
        order: -1;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .gallery-section {
        padding: 0 1rem;
    }

    .lightbox-image-wrapper {
        max-height: 50vh;
    }

    .lightbox-image {
        max-height: 50vh;
    }

    .lightbox-nav {
        width: 36px;
        height: 36px;
        padding: 0.5rem;
    }

    .lightbox-nav svg {
        width: 32px;
        height: 32px;
    }

    .lightbox-close {
        width: 36px;
        height: 36px;
    }

    .filter-dialog-content {
        max-width: 90vw;
        padding: 1.5rem;
    }

    .filter-section {
        margin: 0 auto 2rem;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .theme-toggle {
        width: 36px;
        height: 36px;
        top: 0.75rem;
        right: 0.75rem;
    }

    .hero-section {
        padding: 2rem 1rem;
        margin-bottom: 2rem;
    }

    .hero-text h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .social-links {
        gap: 1rem;
    }

    .social-links a {
        width: 40px;
        height: 40px;
    }

    .gallery-controls {
        gap: 0.75rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .gallery-section {
        padding: 0 0.75rem;
        margin: 0 auto 2rem;
    }

    .filter-button {
        width: 44px;
        height: 44px;
    }

    .lightbox-nav {
        display: none;
    }

    .lightbox-close {
        width: 32px;
        height: 32px;
    }

    .lightbox-image {
        max-height: 45vh;
    }

    .lightbox-image-wrapper {
        max-height: 45vh;
    }

    .lightbox-info h3 {
        font-size: 1.2rem;
    }

    .filter-dialog-content {
        padding: 1rem;
        max-width: 95vw;
    }
}

/* ==================== Accessibility ==================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-color-scheme: dark) {
    html {
        color-scheme: dark;
    }

    html:not([data-theme="light"]) {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --border-color: #3a3a3a;
        --accent-color: #ffffff;
        --hover-color: #333333;
    }
}

/* Ensure 3 columns on wider screens */
@media (min-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==================== Image Lazy Loading ==================== */
.gallery-item-image[loading="lazy"] {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--hover-color) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ==================== Smooth Scrollbar ==================== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
