/* ============================================================
   PhotoHost — Premium Dark Photography Portfolio
   ============================================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-elevated: #1a1a1a;
    --bg-hover: #222222;
    --text-primary: #f0f0f0;
    --text-secondary: #888888;
    --text-muted: #555555;
    --accent: #b590d3;
    --accent-dim: rgba(200, 168, 124, 0.15);
    --border: #1e1e1e;
    --radius: 6px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-medium: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --sidebar-width: 200px;
    --header-height: 72px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* --- Loading Spinner --- */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.loading-spinner.hidden {
    display: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Header --- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
}

.header-inner {
    max-width: 1800px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.back-link {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    transition: color var(--transition-fast);
}

.back-link:hover {
    color: var(--text-primary);
}

h1 {
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 300;
    letter-spacing: 0.08em;
}

/* --- Main Layout: Sidebar + Content --- */
.gallery-layout {
    display: flex;
    max-width: 1800px;
    margin: 0 auto;
    min-height: calc(100vh - var(--header-height));
}

/* --- Sidebar Timeline --- */
.sidebar-timeline {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 1.5rem 0 2rem;
    border-right: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--bg-elevated) transparent;
}

.sidebar-timeline::-webkit-scrollbar {
    width: 3px;
}

.sidebar-timeline::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 2px;
}

.sidebar-year {
    padding: 0 1.25rem;
    margin-bottom: 0.25rem;
}

.sidebar-year-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.75rem 0 0.35rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.35rem;
}

.sidebar-month {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 400;
    transition: all var(--transition-fast);
    user-select: none;
}

.sidebar-month:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.sidebar-month.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.sidebar-month-name {
    flex: 1;
}

.sidebar-month-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.sidebar-month-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-month-toggle svg {
    width: 12px;
    height: 12px;
}

.sidebar-month.collapsed .sidebar-month-toggle {
    transform: rotate(-90deg);
}

/* --- Timeline / Main Gallery --- */
.timeline {
    flex: 1;
    min-width: 0;
    padding: 0 16px;
}

/* --- Month Section --- */
.month-section {
    margin-bottom: 0;
}

.month-header {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 1.5rem 1rem 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    position: sticky;
    top: var(--header-height);
    z-index: 10;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.month-header:hover {
    color: var(--text-primary);
}

.month-header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.month-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
    color: var(--text-muted);
}

.month-toggle-icon svg {
    width: 14px;
    height: 14px;
}

.month-section.collapsed .month-toggle-icon {
    transform: rotate(-90deg);
}

.month-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* --- Photo Grid (Masonry via CSS columns) --- */
.photo-grid {
    display: block;
    column-width: 280px;
    column-gap: 6px;
    padding: 6px 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.3s ease;
}

.month-section.collapsed .photo-grid {
    max-height: 0 !important;
    opacity: 0;
    padding: 0;
    overflow: hidden;
}

/* --- Photo Item --- */
.photo-item {
    display: inline-block;
    width: 100%;
    margin: 0 0 6px;
    break-inside: avoid;
    overflow: hidden;
    cursor: pointer;
    border-radius: var(--radius);
    outline: none;
    position: relative;
    background: var(--bg-secondary);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.photo-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.photo-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.3) 0%, transparent 40%);
    opacity: 0;
    transition: opacity var(--transition-fast);
    border-radius: var(--radius);
    pointer-events: none;
}

.photo-item:hover::after {
    opacity: 1;
}

.photo-item:hover img {
    transform: scale(1.03);
}

.photo-item:focus-visible {
    box-shadow: 0 0 0 2px var(--accent);
}

.photo-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius);
    transition: transform var(--transition-medium);
    will-change: transform;
}

.photo-item img[src=""] {
    visibility: hidden;
}

.photo-item .photo-placeholder {
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, var(--bg-secondary) 0%, var(--bg-elevated) 40%, var(--bg-secondary) 60%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* --- Lightbox --- */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox-image.loaded {
    opacity: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateY(-50%) scale(1.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.lightbox-prev {
    left: 1.5rem;
}

.lightbox-next {
    right: 1.5rem;
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.25rem;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: rotate(90deg);
}

.lightbox-info {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-info.visible {
    opacity: 1;
}

.lightbox-info strong {
    color: var(--text-primary);
    font-weight: 500;
}

.lightbox-counter {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* --- Responsive --- */

@media (min-width: 1400px) {
    .photo-grid {
        column-width: 340px;
    }
}

/* Tablet — sidebar collapses to top nav */
@media (max-width: 900px) {
    .gallery-layout {
        flex-direction: column;
    }

    .sidebar-timeline {
        width: 100%;
        height: auto;
        max-height: none;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.75rem 1rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .sidebar-year {
        display: contents;
        padding: 0;
        margin: 0;
    }

    .sidebar-year-label {
        display: none;
    }

    .sidebar-month {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
        white-space: nowrap;
        border-radius: 20px;
        border: 1px solid var(--border);
    }

    .sidebar-month-toggle {
        display: none;
    }

    .sidebar-month-count {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    h1 {
        font-size: 1.1rem;
        letter-spacing: 0.2em;
    }

    .header-inner {
        padding: 1rem 1.5rem;
    }

    .photo-grid {
        column-width: 160px;
        column-gap: 4px;
    }

    .photo-item {
        margin-bottom: 4px;
        border-radius: 4px;
    }

    .photo-item img {
        border-radius: 4px;
    }

    .month-header {
        padding: 1rem 0.75rem 0.5rem;
        top: var(--header-height);
    }

    .timeline {
        padding: 0 4px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        left: 0.75rem;
    }

    .lightbox-next {
        right: 0.75rem;
    }

    .lightbox-info {
        font-size: 0.75rem;
        padding: 0.5rem 1rem;
        bottom: 1.5rem;
        max-width: 85vw;
        white-space: normal;
    }

    .lightbox-close {
        width: 38px;
        height: 38px;
        top: 1rem;
        right: 1rem;
    }

    .lightbox-counter {
        top: 1rem;
        left: 1rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .photo-grid {
        column-width: 140px;
    }

    .header-inner {
        padding: 0.75rem 1rem;
    }

    h1 {
        font-size: 1rem;
    }

    .subtitle {
        font-size: 0.7rem;
    }

    .back-link {
        left: 1rem;
        font-size: 0.7rem;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* --- Selection --- */
::selection {
    background: var(--accent-dim);
    color: var(--text-primary);
}