/* ============================================================
   VSCO-Style Dark Photo Gallery
   ============================================================ */

/* Design tokens */
:root {
    --bg: #0d0d0d;
    --bg-2: #141414;
    --bg-3: #1c1c1c;
    --surface: #1a1a1a;
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);

    --text-primary: #f0ece4;
    --text-secondary: #8a8680;
    --text-muted: #4a4845;
    --text-accent: #c8b89a;

    --overlay-bg: rgba(13, 13, 13, 0.85);
    --modal-bg: rgba(8, 8, 8, 0.96);

    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'DM Serif Display', Georgia, serif;

    --radius-sm: 4px;
    --radius-md: 8px;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
    overflow: hidden;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ── Header ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background-color: rgba(13, 13, 13, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-primary);
    opacity: 0.9;
    transition: opacity var(--transition);
}

.site-logo:hover {
    opacity: 1;
}

.nav-count {
    font-size: 0.75rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Common circular control style */
.nav-btn-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    transition: all 0.2s;
    color: var(--text-secondary);
}

.nav-btn-circle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.nav-icon-btn {
    appearance: none;
    -webkit-appearance: none;
}

.nav-icon-btn.active {
    background: rgba(255, 255, 255, 0.18);
    color: var(--text-accent);
    border-color: var(--text-accent);
}

.nav-icon-btn .material-symbols-outlined {
    font-size: 1.25rem;
}

/* ── Gallery Wrapper ── */
.gallery-wrapper {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
}

/* ── Hero Tagline ── */
.gallery-hero {
    padding: 4rem 0 2.5rem;
}

.gallery-tagline {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* ── Masonry Grid ── */
.masonry-grid {
    columns: 4 280px;
    column-gap: 10px;
    margin-top: 1rem;
}

.photo-card {
    break-inside: avoid;
    margin-bottom: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background-color: var(--bg-3);
}

.photo-thumb {
    position: relative;
    overflow: hidden;
    display: block;
    width: 100%;
}

.photo-thumb img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform var(--transition-slow);
    will-change: transform;
}

/* Hover overlay */
.photo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.72) 0%,
            rgba(0, 0, 0, 0.18) 45%,
            transparent 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.25rem 1rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.photo-card:hover .photo-overlay {
    opacity: 1;
}

.photo-card:hover .photo-thumb img {
    transform: scale(1.03);
}

.overlay-title {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #fff;
    line-height: 1.3;
}

.overlay-location {
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 0.2rem;
}

/* ── Loading State ── */
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 8rem 2rem;
}

.loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: pulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.2;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 8rem 2rem;
}

.empty-icon {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    opacity: 0.2;
}

.empty-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.empty-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 300;
}

.empty-hint code {
    font-family: 'Courier New', monospace;
    background-color: var(--bg-3);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--text-accent);
    font-size: 0.8rem;
}

/* ── Modal / Lightbox ── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: var(--modal-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: stretch;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Lightbox Layout ── */
.lightbox {
    display: flex;
    width: 100%;
    height: 100vh;
    position: relative;
}

.lightbox-close {
    position: fixed;
    top: 1.25rem;
    right: 1.5rem;
    z-index: 1100;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.lightbox-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1050;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.lightbox-arrow:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.lightbox-arrow--prev {
    left: 2rem;
}

.lightbox-arrow--next {
    right: 2rem;
}

/* Controls wrapper for auto-hide */
.lightbox-controls {
    transition: opacity 0.4s ease;
}

.lightbox-controls.controls-hidden {
    opacity: 0;
    pointer-events: none;
}

/* Slide animations for photo transitions */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(60px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-60px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-from-right {
    animation: slideInFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in-from-left {
    animation: slideInFromLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem 3rem 3rem;
    overflow: hidden;
    background-color: var(--bg);
}

.lightbox-image img {
    max-width: 100%;
    max-height: calc(100vh - 6rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.lightbox-meta {
    width: 300px;
    flex-shrink: 0;
    padding: 4rem 2.5rem 3rem;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background-color: var(--bg-2);
}

.meta-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.25;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.meta-description {
    font-size: 0.875rem;
    font-weight: 300;
    color: var(--text-secondary);
    line-height: 1.7;
}

.meta-fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.meta-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.meta-label {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.meta-value {
    font-size: 0.875rem;
    font-weight: 300;
    color: var(--text-secondary);
}

.meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.1rem;
}

.tag {
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background-color: var(--bg-3);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    transition: all var(--transition);
}

.tag:hover {
    color: var(--text-accent);
    border-color: var(--border-hover);
}

.meta-filename {
    margin-top: auto;
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

/* ── Footer ── */
.site-footer {
    margin-top: auto;
    padding: 4rem 2rem;
    border-top: 1px solid var(--border);
    background-color: var(--bg);
}

.footer-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.footer-tagline {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ── Tag Input Chips ── */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 48px;
    transition: border-color var(--transition);
    cursor: text;
}

.tag-input-container:focus-within {
    border-color: var(--text-accent);
}

.tag-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background-color: var(--bg-2);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tag-chip-remove {
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted);
    transition: color var(--transition);
}

.tag-chip-remove:hover {
    color: var(--text-accent);
}

#tag-input-field {
    flex: 1;
    min-width: 120px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.2rem 0;
}

#tag-input-field:focus {
    outline: none;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .masonry-grid {
        columns: 3 220px;
    }

    .lightbox-meta {
        width: 260px;
        padding: 4rem 1.75rem 3rem;
    }
}

@media (max-width: 768px) {
    .header-inner {
        padding: 0 1.25rem;
    }

    .gallery-wrapper {
        padding: 0 0.75rem 4rem;
    }

    .gallery-hero {
        padding: 2.5rem 0 1.5rem;
    }

    .masonry-grid {
        columns: 2 160px;
        column-gap: 6px;
    }

    .photo-card {
        margin-bottom: 6px;
    }

    /* On mobile, lightbox stacks vertically */
    .lightbox {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    .lightbox-image {
        padding: 4rem 1rem 1.5rem;
        flex: none;
    }

    .lightbox-image img {
        max-height: 55vh;
    }

    .lightbox-meta {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 2rem 1.5rem 3rem;
        gap: 1.25rem;
    }

    .meta-filename {
        margin-top: 1rem;
    }
}

@media (max-width: 480px) {
    .site-header {
        position: relative;
    }

    .header-inner {
        padding: 0 1rem;
        height: 50px;
    }

    .search-input {
        display: none;
        /* Hide search bar on very small phones to avoid overflow */
    }

    .masonry-grid {
        columns: 2 auto;
        column-gap: 4px;
        margin-top: 0.5rem;
    }

    .photo-card {
        margin-bottom: 4px;
    }

    .gallery-tagline {
        font-size: 1.25rem;
    }

    .footer-inner {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }

    .lightbox-image {
        padding: 3rem 0;
        background-color: #000;
    }

    .lightbox-image img {
        max-height: 70vh;
        width: 100%;
        border-radius: 0;
    }

    .lightbox-arrow {
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.5);
    }
}

/* ── Upload Interface ── */
.upload-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.upload-header {
    text-align: center;
    margin-bottom: 2rem;
}

.upload-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-primary);
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    background-color: var(--bg-3);
    min-height: 300px;
    position: relative;
    overflow: hidden;
}

.upload-dropzone.dragover {
    border-color: var(--text-accent);
    background-color: rgba(200, 184, 154, 0.05);
}

.upload-dropzone:hover {
    border-color: var(--border-hover);
}

.upload-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upload-preview {
    position: absolute;
    inset: 0;
    display: none;
    background-color: var(--bg-3);
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.upload-preview.active {
    display: block;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.form-input,
.form-textarea {
    width: 100%;
    background-color: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: border-color var(--transition);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--text-accent);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
}

.btn-primary {
    background-color: var(--text-primary);
    color: var(--bg);
}

.btn-primary:hover {
    background-color: #fff;
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }
}