@font-face {
    font-family: 'W95FA';
    src: url('fonts/W95FA.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --text-secondary: #555555;
    --border-color: rgba(0, 0, 0, 0.08);
    --overlay-bg: rgba(255, 255, 255, 0.95);
    --shadow-color: rgba(0, 0, 0, 0.1);

    /* Glass system */
    --glass-bg: rgba(240, 240, 245, 0.55);
    --glass-bg-hover: rgba(235, 235, 242, 0.72);
    --glass-blur: 16px;
    --glass-border: 1px solid rgba(0, 0, 0, 0.08);
    --glass-shadow:
        0 2px 16px rgba(0, 0, 0, 0.06),
        0 0 1px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    --glass-shadow-hover:
        0 4px 24px rgba(0, 0, 0, 0.1),
        0 0 1px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);

    /* Active / selected state */
    --glass-active-bg: #FF6200;
    --glass-active-text: #ffffff;
    --glass-active-shadow:
        0 2px 16px rgba(255, 98, 0, 0.25),
        0 0 1px rgba(255, 98, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    transition: background 0.3s ease;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Category Filter Bar */
#filter-bar {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 100;
}

/* ========== GLASS PILL BASE ========== */
.glass-pill {
    backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
    background: var(--glass-bg);
    border: var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    transition: all 0.25s ease;
}

/* Safari perf (desktop + iOS): backdrop-filter blur over a WebGL canvas is very
   expensive on WebKit. Reduce blur radius and use a more opaque background to
   compensate visually. JS adds .is-safari to <html> for desktop Safari. */
.is-safari .glass-pill,
.is-safari .glass-pill:hover {
    --glass-blur: 8px;
    background: rgba(240, 240, 245, 0.78);
}

.glass-pill:hover {
    background: var(--glass-bg-hover);
    box-shadow: var(--glass-shadow-hover);
}

/* Focus state for keyboard navigation (accessibility) */
.glass-pill:focus-visible {
    outline: 2px solid var(--text-color);
    outline-offset: 2px;
}

/* Toggle button */
.filter-toggle {
    padding: 6px 14px;
    color: var(--text-secondary);
    font-size: 11px;
    letter-spacing: 0.5px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-toggle:hover {
    color: var(--text-color);
}

.filter-toggle.open {
    background: var(--glass-active-bg);
    color: var(--glass-active-text);
    border-color: transparent;
    box-shadow: var(--glass-active-shadow);
}

/* Pills container — single row, collapsed by default */
.filter-pills {
    display: flex;
    gap: 6px;
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-width 0.35s ease, opacity 0.25s ease;
    white-space: nowrap;
    /* No overflow:hidden — avoids compositing artifact (visible rectangle)
       behind glass-pill children with backdrop-filter */
}

.filter-pills.open {
    max-width: 500px;
    opacity: 1;
    pointer-events: auto;
}

.filter-btn {
    padding: 6px 14px;
    color: var(--text-secondary);
    font-size: 11px;
    letter-spacing: 0.5px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-btn:hover {
    color: var(--text-color);
}

.filter-btn.active {
    background: var(--glass-active-bg);
    color: var(--glass-active-text);
    border-color: transparent;
    box-shadow: var(--glass-active-shadow);
}

/* Project count indicator */
#project-count {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 16px;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    z-index: 100;
    transition: opacity 0.3s ease;
}

#project-count.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Keyboard Navigation Hint */
#nav-hint {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 12px;
    z-index: 100;
    color: var(--text-secondary);
    cursor: default;
}

.arrow-cluster {
    display: grid;
    grid-template-columns: auto auto auto;
    grid-template-rows: auto auto auto;
    place-items: center;
    gap: 2px;
    font-size: 7px;
    line-height: 1;
}

.arrow-up    { grid-column: 2; grid-row: 1; }
.arrow-left  { grid-column: 1; grid-row: 2; }
.arrow-center { grid-column: 2; grid-row: 2; width: 6px; height: 6px; }
.arrow-right { grid-column: 3; grid-row: 2; }
.arrow-down  { grid-column: 2; grid-row: 3; }

.arrow-cluster span {
    opacity: 0.6;
}

/* Loading Screen */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

#loading.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.loading-logo {
    width: 400px;
    height: auto;
    animation: logoFadeIn 0.8s ease-out;
    background: transparent;
    object-fit: cover;
    clip-path: inset(8% 0 0 0);
    margin-top: -2%;
}

@keyframes logoPulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
        filter: brightness(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
        filter: brightness(1.2);
    }
}

@keyframes logoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 0.4;
        transform: scale(1);
    }
}

/* Page transitions */
.page-enter {
    animation: pageEnter 0.4s ease-out;
}

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

.page-transition-out {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/* Bottom Navigation */
#bottom-nav {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 100;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 20px;
}

.nav-btn {
    padding: 8px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 12px;
    letter-spacing: 1px;
    white-space: nowrap;
}

.nav-btn:hover {
    color: #111;
}

/* Project Overlay */
#project-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#project-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#close-overlay {
    position: absolute;
    top: 30px;
    right: 30px;
    background: none;
    border: none;
    font-size: 36px;
    cursor: pointer;
    color: var(--text-color);
    transition: transform 0.2s ease;
}

#close-overlay:hover {
    transform: scale(1.2);
}

#project-content {
    text-align: center;
    max-width: 600px;
    padding: 20px;
}

#project-title {
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 30px;
    color: var(--text-color);
}

#project-title.effects-lab-font {
    font-family: 'W95FA', sans-serif;
    font-size: 24px;
    letter-spacing: 1px;
}

/* Carousel */
#carousel-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

#carousel-media {
    position: relative;
    max-width: 100%;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#project-image,
#project-video {
    max-width: 100%;
    max-height: 50vh;
    object-fit: contain;
}

#project-video {
    box-shadow: 0 10px 40px var(--shadow-color);
    display: none;
    border-radius: 4px;
}

#project-video::-webkit-media-controls-panel {
    background: rgba(0, 0, 0, 0.7);
}

.carousel-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.carousel-btn:hover {
    color: #111;
}

.carousel-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-btn.hidden {
    visibility: hidden;
}

#carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 0;
}

#carousel-dots.hidden {
    display: none;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    opacity: 0.3;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.carousel-dot:hover {
    opacity: 0.6;
}

.carousel-dot.active {
    opacity: 1;
}

/* Carousel loading spinner */
#carousel-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    min-height: 200px;
}

.carousel-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#project-description {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

#project-link {
    display: inline-block;
    padding: 12px 30px;
    background: var(--text-color);
    color: var(--bg-color);
    text-decoration: none;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

#project-link:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

/* Selected project indicator */
.project-selected-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--text-color);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project-selected-indicator.visible {
    opacity: 1;
}

/* Mobile tap hint — shown on first tap to teach double-tap interaction */
.tap-hint {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--text-color);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.tap-hint.visible {
    opacity: 1;
}

/* Grid View toggle — mobile only */
.mobile-grid-toggle {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 50;
    padding: 10px 20px;
    font-size: 11px;
    letter-spacing: 1px;
    text-decoration: none;
    color: #fff;
    background: #FF6200;
    border: none;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-grid-toggle {
        display: block;
    }
    #bottom-nav {
        bottom: 20px;
        gap: 8px;
    }

    .nav-btn {
        padding: 6px 12px;
        font-size: 10px;
    }

    #project-title {
        font-size: 12px;
    }

    /* Show mobile hint instead of hiding completely */
    #nav-hint {
        top: auto;
        bottom: 70px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        white-space: nowrap;
    }

    /* Filter bar repositioned to bottom on mobile */
    #filter-bar {
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: column-reverse;
        align-items: center;
    }

    .filter-pills {
        /* Override desktop slide — use vertical popup instead */
        max-width: none;
        white-space: normal;
        flex-wrap: wrap;
        justify-content: center;
        position: absolute;
        bottom: calc(100% + 8px);
        left: 50%;
        transform: translateX(-50%);
        width: max-content;
        max-width: 85vw;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease, transform 0.25s ease;
        transform: translateX(-50%) translateY(6px);
    }

    .filter-pills.open {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0);
    }

    .filter-toggle,
    .filter-btn {
        padding: 8px 14px;
        font-size: 11px;
    }

    #project-count {
        bottom: 60px;
    }
}
