/* ═══════════════════════════════════════
   Gallery — Layout & Sidebar
   ═══════════════════════════════════════ */

:root {
    --gallery-sidebar-col: 190px;
    --gallery-section-gap: 28px;
    --gallery-section-pad-top: 104px;
    --gallery-section-pad-right: 27px;
    --gallery-section-pad-bottom: 120px;
    --gallery-section-pad-left: 9px;
    --gallery-sidebar-width: 203px;
    --gallery-sidebar-pad-top: 14px;
    --gallery-sidebar-pad-right: 10px;
    --gallery-sidebar-pad-bottom: 16px;
    --gallery-sidebar-pad-left: 6px;
    --gallery-track-gap: 28px;
}

.section-gallery {
    position: relative;
    display: grid;
    grid-template-columns: var(--gallery-sidebar-col) minmax(0, 1fr);
    gap: var(--gallery-section-gap);
    align-items: start;
    padding: var(--gallery-section-pad-top) var(--gallery-section-pad-right) var(--gallery-section-pad-bottom) var(--gallery-section-pad-left);
    background:
        radial-gradient(circle, rgba(0,0,0,0.06) 1px, transparent 1px) 0 0 / 24px 24px,
        var(--bg);
}

.section-gallery::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 218px;
    background: rgba(227,228,233,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(0,0,0,0.08);
    z-index: 1;
}

/* ── Sidebar ── */

.gallery-sidebar {
    position: sticky;
    top: 96px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: var(--gallery-sidebar-width);
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    padding: var(--gallery-sidebar-pad-top) var(--gallery-sidebar-pad-right) var(--gallery-sidebar-pad-bottom) var(--gallery-sidebar-pad-left);
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.sidebar-projects {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: none;
}

.sidebar-projects::-webkit-scrollbar { width: 0; }

/* ── Category Accordion ── */

.sidebar-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.sc-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    height: 34px;
    cursor: pointer;
    border-radius: 80px;
    background: #fff;
    border: 1px solid transparent;
    transition: background var(--motion-base) var(--ease-standard), border-color var(--motion-base) var(--ease-standard), height var(--motion-base) var(--ease-standard), transform var(--motion-fast) var(--ease-emphasis);
    user-select: none;
}

.sc-header:hover {
    background: rgba(255,255,255,0.85);
    transform: translateY(-1px);
}

.sidebar-category.expanded .sc-header {
    background: #3dcdad;
    border-color: #fff;
    height: 38px;
}

.sidebar-category.expanded .sc-header:hover {
    background: #35c4a4;
}

.sc-name-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 1;
    min-width: 0;
    line-height: 1;
    padding-bottom: 2px;
}

.sc-name-en {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #9e9e9e;
    white-space: nowrap;
    letter-spacing: -0.3px;
    text-transform: capitalize;
    transition: color 0.3s ease;
}

.sidebar-category.expanded .sc-name-en { color: #fff; }

.sc-name-cn {
    font-size: 9px;
    font-weight: 400;
    color: #9e9e9e;
    text-align: right;
    margin-top: 1px;
    transition: color 0.3s ease;
}

.sidebar-category.expanded .sc-name-cn { color: rgba(255,255,255,0.9); }

.sc-arrow {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
    color: #9e9e9e;
    transition: transform var(--motion-base) var(--ease-standard), color var(--motion-base) var(--ease-standard);
}

.sidebar-category.expanded .sc-arrow {
    transform: rotate(90deg);
    color: #fff;
}

.sc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--motion-slow) var(--ease-standard);
}

.sc-body-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 8px;
    background: #fff;
    border-radius: 14px;
    margin-top: 2px;
    max-height: calc(100vh - 279px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.sc-body-inner::-webkit-scrollbar { width: 3px; }
.sc-body-inner::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

/* ── Project Thumbnail ── */

.sc-project {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity var(--motion-base) var(--ease-standard), transform var(--motion-fast) var(--ease-emphasis);
}

.sc-project:hover {
    opacity: 0.64;
    transform: scale(1.015);
}

.sc-project.active {
    opacity: 1;
    transform: scale(1);
}

.sc-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 135 / 79;
    border-radius: 10px;
    overflow: hidden;
    filter: grayscale(1);
    border: 2px solid transparent;
    background: #e8e8e8;
    background-image: linear-gradient(90deg, #e8e8e8 0%, #f2f2f2 40%, #e8e8e8 80%);
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
    transition: box-shadow var(--motion-base) var(--ease-standard), filter var(--motion-base) var(--ease-standard), border-color var(--motion-base) var(--ease-standard);
}

.sc-project:hover .sc-cover {
    filter: grayscale(0.3);
}

.sc-project.active .sc-cover {
    filter: grayscale(0);
    border-color: #3dcdad;
    box-shadow: 0 0 0 2px rgba(61,205,173,0.2), 0 2px 10px rgba(0,0,0,0.08);
}

.sc-num {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 2;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 6px;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: rgba(255,255,255,0.85);
    font-family: 'Outfit', sans-serif;
    font-size: 9px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    transition: background 0.3s ease, color 0.3s ease;
}

.sc-project.active .sc-num {
    background: #3dcdad;
    color: #fff;
}

.sc-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sc-cover img.loaded {
    opacity: 1;
}

.sc-cover.media-loaded {
    animation: none;
    background-image: none;
}

.sc-cover-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.sc-title {
    font-size: 8px;
    font-weight: 500;
    color: #86868b;
    text-align: center;
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
}

.sc-project.active .sc-title {
    color: #373737;
    font-weight: 600;
}

.sc-empty {
    font-size: 9px;
    color: #86868b;
    text-align: center;
    padding: 12px 0;
    letter-spacing: 0.04em;
}

.sidebar-counter {
    margin-top: 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* ── Current Project Pill ── */

.gallery-now {
    position: absolute;
    top: 24px;
    right: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    height: 51px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 80px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.35s cubic-bezier(0.23,1,0.32,1),
                transform 0.35s cubic-bezier(0.23,1,0.32,1);
}

.gallery-now.visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-now-num {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #48dbbd;
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

.gallery-now-name {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: #000;
    letter-spacing: -0.4px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ── Main Track ── */

.gallery-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.gallery-track {
    display: flex;
    flex-direction: column;
    gap: var(--gallery-track-gap);
    min-width: 0;
}

#gallery-track {
    width: 100%;
    padding: 0 62px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .section-gallery {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 64px 0 80px;
    }

    .gallery-sidebar { display: none; }
    .section-gallery::before { display: none; }
    .gallery-main { gap: 0; }
    .gallery-track { gap: 16px; }
    .gallery-now { display: none; }

    #gallery-track {
        padding: 0 14px;
    }
}

@media (max-width: 480px) {
    .section-gallery {
        padding: 56px 0 64px;
    }

    .gallery-track { gap: 12px; }

    #gallery-track {
        padding: 0 10px;
    }
}
