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

:root {
    /* Colors */
    --color-bg: #0C0C0E;
    --color-bg-elevated: #1C1C1E;
    --color-bg-elevated-2: #2C2C2E;
    --color-text: #F5F5F7;
    --color-text-muted: rgba(235, 235, 245, 0.6);
    --color-text-tertiary: rgba(235, 235, 245, 0.3);
    --color-accent: #2997FF;
    --color-accent-hover: #0077ED;
    --color-border: #38383A;
    --color-modal-bg: #1C1C1E;

    /* Semantic aliases for hardcoded values */
    --color-nav-link: rgba(235, 235, 245, 0.8);
    --color-subtle-border: rgba(235, 235, 245, 0.3);
    --color-subtle-hover-bg: rgba(235, 235, 245, 0.1);
    --color-subtle-hover-border: rgba(235, 235, 245, 0.6);
    --color-card-overlay-bg: rgba(255, 255, 255, 0.02);
    --color-card-hover-bg: rgba(255, 255, 255, 0.04);
    --color-overlay-white: 255, 255, 255;
    --color-navbar-bg: rgba(29, 29, 31, 0.72);

    --color-particle-hue: 0.6;

    /* Typography */
    --font-main: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Layout */
    --max-width: 980px;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --spacing-xl: 6rem;

    /* Cards */
    --card-radius: 18px;
    --card-radius-sm: 12px;

    /* Modal */
    --modal-width: 90vw;
    --transition-modal: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --z-modal: 2000;
}

[data-theme="light"] {
    --color-bg: #bebec5;
    --color-bg-elevated: #FFFFFF;
    --color-bg-elevated-2: #E8E8ED;
    --color-text: #000000;
    --color-text-muted: rgba(0, 0, 0, 0.7);
    --color-text-tertiary: rgba(0, 0, 0, 0.4);
    --color-accent: #0071E3;
    --color-accent-hover: #0077ED;
    --color-border: #D2D2D7;
    --color-modal-bg: #bebec5;
    --color-nav-link: rgba(0, 0, 0, 0.85);
    --color-subtle-border: rgba(60, 60, 67, 0.2);
    --color-subtle-hover-bg: rgba(60, 60, 67, 0.08);
    --color-subtle-hover-border: rgba(60, 60, 67, 0.4);
    --color-card-overlay-bg: rgba(0, 0, 0, 0.02);
    --color-card-hover-bg: rgba(0, 0, 0, 0.04);
    --color-overlay-white: 0, 0, 0;
    --color-navbar-bg: rgba(245, 245, 247, 0.72);

    --color-particle-hue: 0.58;
}



html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    font-size: 17px;
    line-height: 1.47;
    color: var(--color-text);
    background-color: var(--color-bg);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
    overflow: hidden;
}

main {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    row-gap: clamp(2rem, 4vw, 4rem);
}

/* ============================================
   UTILITY
   ============================================ */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ============================================
   NAVBAR 
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--color-navbar-bg, rgba(29, 29, 31, 0.72));
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--color-border);
    z-index: 1000;
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.75rem var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-logo {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    color: var(--color-nav-link);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: var(--color-text);
}

.nav-cv-btn {
    padding: 0.45rem 1rem;
    border: 1px solid var(--color-subtle-border);
    border-radius: 6px;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.3s ease;
    white-space: nowrap;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--color-nav-link);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.25s ease;
}

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

.theme-toggle svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.theme-toggle .icon-moon { opacity: 0.9; }
.theme-toggle .icon-sun { opacity: 0.4; }

[data-theme="light"] .theme-toggle .icon-moon { opacity: 0.4; }
[data-theme="light"] .theme-toggle .icon-sun { opacity: 0.9; }

.theme-toggle-track {
    position: relative;
    width: 28px;
    height: 16px;
    background: rgba(var(--color-overlay-white), 0.15);
    border-radius: 8px;
    transition: background 0.3s ease;
}

.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: var(--color-text);
    border-radius: 50%;
    transition: transform 0.3s ease;
}

[data-theme="light"] .theme-toggle-thumb {
    transform: translateX(12px);
}

[data-theme="light"] .piece-overlay,
[data-theme="light"] .project-overlay {
    color: #fff;
}

.nav-cv-btn:hover {
    background: var(--color-subtle-hover-bg);
    border-color: var(--color-subtle-hover-border);
}

.cv-short {
    display: none;
}

/* ============================================
   PAGE INTRO
   ============================================ */

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

@keyframes introFadeDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide content before JS adds data-reveal attrs, preventing FOUC flicker */
body.is-intro .hero-content,
body.is-intro .pieces-section .section-title,
body.is-intro .piece,
body.is-intro .piece-label,
body.is-intro .projects-section .section-title,
body.is-intro .projects-carousel {
    opacity: 0;
}

/* Navbar slide in*/
body.is-intro .navbar {
    animation: introFadeDown 0.35s cubic-bezier(0.23, 1, 0.32, 1) 0.05s both;
}

/* intro hero container  */
body.is-intro .hero-content[data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
}

/* Hero children stagger in */
body.is-intro .hero-content > * {
    opacity: 0;
    animation: introFadeUp 0.45s cubic-bezier(0.23, 1, 0.32, 1) both;
}
body.is-intro .hero-content h1              { animation-delay: 0.12s; }
body.is-intro .hero-content .hero-subtitle  { animation-delay: 0.22s; }
body.is-intro .hero-content .hero-description { animation-delay: 0.3s; }
body.is-intro .hero-content .btn            { animation-delay: 0.4s; }

/* Section title + cards: override data-reveal during intro */
body.is-intro .pieces-section .section-title[data-reveal],
body.is-intro .piece[data-reveal],
body.is-intro .piece-label {
    transition: none !important;
    animation: introFadeUp 0.45s cubic-bezier(0.23, 1, 0.32, 1) both;
}
body.is-intro .pieces-section .section-title[data-reveal] { animation-delay: 0.5s; }
body.is-intro .piece-wrapper:nth-child(1) .piece[data-reveal],
body.is-intro .piece-wrapper:nth-child(1) .piece-label { animation-delay: 0.6s; }
body.is-intro .piece-wrapper:nth-child(2) .piece[data-reveal],
body.is-intro .piece-wrapper:nth-child(2) .piece-label { animation-delay: 0.65s; }
body.is-intro .piece-wrapper:nth-child(3) .piece[data-reveal],
body.is-intro .piece-wrapper:nth-child(3) .piece-label { animation-delay: 0.7s; }
body.is-intro .piece-wrapper:nth-child(4) .piece[data-reveal],
body.is-intro .piece-wrapper:nth-child(4) .piece-label { animation-delay: 0.75s; }
body.is-intro .piece-wrapper:nth-child(5) .piece[data-reveal],
body.is-intro .piece-wrapper:nth-child(5) .piece-label { animation-delay: 0.8s; }
body.is-intro .piece-wrapper:nth-child(6) .piece[data-reveal],
body.is-intro .piece-wrapper:nth-child(6) .piece-label { animation-delay: 0.85s; }

/* Group projects section: title then carousel */
body.is-intro .projects-section .section-title[data-reveal],
body.is-intro .projects-carousel[data-reveal] {
    transition: none !important;
    animation: introFadeUp 0.45s cubic-bezier(0.23, 1, 0.32, 1) both;
}
body.is-intro .projects-section .section-title[data-reveal] { animation-delay: 0.85s; }
body.is-intro .projects-carousel[data-reveal]                { animation-delay: 0.95s; }

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
    padding-top: calc(var(--spacing-xl) + 60px);
}

#hero-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
    text-align: center;
}

.hero h1 {
    font-size: clamp(2.75rem, 6vw, 4rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.015em;
    line-height: 1.08;
}

.hero-subtitle {
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.hero-description {
    font-size: clamp(1rem, 1.5vw, 1.1rem);
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Button */
.btn {
    display: inline-block;
    padding: 0.875rem 2rem;
    background-color: var(--color-accent);
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 980px;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.btn:hover {
    background-color: var(--color-accent-hover);
    transform: scale(1.02);
}

/* ============================================
    TITLES
   ============================================ */
.section-title {
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    color: var(--color-text-muted);
    padding-left: 1rem;
    border-left: 3px solid var(--color-subtle-border);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 400;
    margin-bottom: var(--spacing-md);
}

.pieces-section .section-title {
    margin-left: 5%;
    color: var(--color-text);
    border-left-color: var(--color-text);
}

.projects-section .section-title {
    margin-left: 5%;
    color: var(--color-text);
    border-left-color: var(--color-text);
}

/* ============================================
   PIECES (Solo Projects)
   ============================================ */
.pieces-section {
    padding: 3rem 0 0;
}

.pieces-grid {
    --pieces-gap: clamp(1rem, 3%, 2rem);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0 5%;
    gap: var(--pieces-gap);
}

.pieces-grid > .piece-wrapper {
    flex: 0 0 calc((100% - 2 * var(--pieces-gap)) / 3);
    min-width: 0;
    box-sizing: border-box;
}

.piece {
    position: relative;
    width: 100%;
    cursor: pointer;
    overflow: hidden;
    border-radius: var(--card-radius);
    transition: all 0.7s ease-in-out;
}

/* Sibling dim effect on hover — desktop only */
@media (min-width: 769px) {
    .pieces-grid:has(.piece:hover) .piece-wrapper:not(:has(.piece:hover)) .piece {
        transform: scale(0.95);
        filter: blur(2.5px) grayscale(40%);
    }
}

.piece:hover,
.piece[data-reveal].is-visible:hover {
    transform: translateY(-10px) scale(1.05);
}

.piece > img,
.piece > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--card-radius);
    aspect-ratio: 16 / 10;
}

/* Hover preview media — stacked on top of default */
.piece .preview-hover,
.project .preview-hover {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: 0;
}

.piece .preview-hover.is-hover-active {
    opacity: 1;
}

.project .preview-hover.is-hover-active {
    opacity: 1;
    transition: opacity 0.8s ease 0.3s;
}

/* Title overlay on piece cards */
.piece-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2.5rem 1.5rem 1.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    transform: translateY(100%);
    transition: transform 0.4s ease;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
    pointer-events: none;
}

.piece:hover .piece-overlay {
    transform: translateY(0);
}

.piece-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.piece-tag {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Label below piece card — visible by default, hidden on hover */
.piece-label {
    display: block;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: 0.02em;
    margin-top: 0.6rem;
    transition: opacity 0.3s ease;
}

.piece-wrapper:has(.piece:hover) .piece-label {
    opacity: 0;
}

/* ============================================
   CARD ICONS (shared by pieces + projects)
   ============================================ */
.card-icons {
    position: absolute;
    justify-content: right;
    align-items: flex-end;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 0.35rem;
    padding: 0.6rem 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    border-radius: 0 0 var(--card-radius) var(--card-radius);
    z-index: 1;
    pointer-events: none;
}

.card-icons img {
    width: 24px;
    height: 27px;
    border-radius: 4px;
    opacity: 0.85;
    transition: opacity 0.3s ease;
    flex-shrink: 0;
}

.card-icon-logo {
    margin-right: auto;
    width: auto !important;
    height: 20px !important;
    object-fit: contain;
    order: -1;
}

.card-icon-logo[src*="fullscreen_studios"] {
    height: 36px !important;
}

.card-icon-logo[src*="uppsala-universitet"] {
    height: 52px !important;
}

.piece:hover .card-icon-logo {
    opacity: 0 !important;
}

.piece:hover .card-icons img,
.project:hover .card-icons img {
    opacity: 1;
}

/* Icons on project cards */
.project .card-icons {
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

/* ============================================
   SECTION BASE
   ============================================ */
section {
    padding: var(--spacing-xl) var(--spacing-md);
}

section h2 {
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.01em;
}

/* ============================================
   GROUP GAME PROJECTS)
   ============================================ */
.projects-section {
    padding: 0 0;
}

/* Horizontal accordion */
.projects-carousel {
    position: relative;
    margin: 0 5%;
}

.carousel-track {
    display: flex;
    height: clamp(300px, 45vw, 550px);
    gap: 4px;
}

.carousel-dots {
    display: none;
}

.project {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    cursor: pointer;
    overflow: hidden;
    border-radius: var(--card-radius);
    transition: flex 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                filter 0.5s ease;
    filter: brightness(0.55) grayscale(20%);
}

.project.is-focused {
    flex: 6 1 0;
    filter: brightness(1) grayscale(0%);
}

.project > img,
.project > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--card-radius);
}

.project .preview-hover {
    border-radius: var(--card-radius);
}

/* Title overlay — visible only when focused */
.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 2rem 2rem;
    background: linear-gradient(rgba(0, 0, 0, 0.85), transparent);
    opacity: 0;
    transition: opacity 0.4s ease 0.15s;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    pointer-events: none;
}

.project.is-focused .project-overlay {
    opacity: 1;
}

.project-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.3rem;
}

.project-role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    display: inline-block;
}

/* ============================================
   ABOUT SECTION
   ============================================ */
.about {
    background-color: var(--color-bg-elevated);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
}

.about-photo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.about-photo {
    width: 210px;
    height: 210px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    background: var(--color-bg-elevated-2);
    border: 2px solid var(--color-border);
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
    align-items: start;
}

.about-left h2 {
    margin-bottom: 1rem;
}

.about-left p {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    max-width: 400px;
}

.about-left p:last-child {
    margin-bottom: 0;
}

.about-divider {
    width: 1px;
    align-self: stretch;
    background: var(--color-border);
}

.about-right h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: -0.01em;
}

/* Skills grid */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1.25rem;
}

.skill-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.skill-item img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.skill-item:hover img {
    opacity: 1;
}

.skill-item span {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.2;
}

/* ============================================
   CONTACT SECTION 
   ============================================ */
.contact {
    scroll-margin-top: 20px;
    padding-top: clamp(4rem, 10vh, 8rem);
    padding-bottom: clamp(16rem, 70vh, 40rem);
}

.contact .container {
    text-align: center;
}

.contact p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.contact-list {
    list-style: none;
}

.contact-list li {
    margin-bottom: 0.75rem;
    color: var(--color-text-muted);
}

.contact-list a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

.contact-list a:hover {
    color: #6CB4FF;
}

/* Social icon buttons */
.social-icons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 3rem;
}

.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--color-text-tertiary);
    text-decoration: none;
    transition: color 0.3s ease, transform 0.3s ease;
}

.social-icon svg {
    width: 100%;
    height: 100%;
}

.social-icon:hover {
    color: var(--color-text);
    transform: scale(1.1);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    position: relative;
    z-index: 1;
    padding: var(--spacing-md);
    background-color: var(--color-navbar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.footer p {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
}

/* ============================================
   MODAL OVERLAY SYSTEM
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2vh 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-modal), visibility var(--transition-modal);
}

.modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* Backdrop */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px) saturate(0.25) brightness(0.65);
    -webkit-backdrop-filter: blur(6px) saturate(0.25) brightness(0.65);
    z-index: -1;
}

/* Scrollable modal container */
.modal-container {
    width: var(--modal-width);
    max-height: 97vh;
    overflow-y: auto;
    background-color: var(--color-modal-bg);
    border-radius: var(--card-radius);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    transform: translateY(40px) scale(0.96);
    transition: transform var(--transition-modal);
    position: relative;
}

.modal-overlay.is-active .modal-container {
    transform: translateY(0) scale(1);
}

/* Custom scrollbar for modal */
.modal-container::-webkit-scrollbar {
    width: 6px;
}

.modal-container::-webkit-scrollbar-track {
    background: transparent;
}

.modal-container::-webkit-scrollbar-thumb {
    background: rgba(var(--color-overlay-white), 0.12);
    border-radius: 3px;
}

.modal-container::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-overlay-white), 0.2);
}

/* Close button */
.modal-close {
    position: sticky;
    top: 1rem;
    float: right;
    margin: 1rem;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(var(--color-overlay-white), 0.06);
    color: var(--color-text);
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(var(--color-overlay-white), 0.15);
}

/* Loading state */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    gap: 1.2rem;
}

.modal-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(var(--color-overlay-white), 0.1);
    border-top-color: var(--color-text-muted);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.modal-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    padding: 2rem;
    text-align: center;
}

/* ============================================
   PROJECT DETAIL (inside modal)
   ============================================ */
.project-detail {
    padding: 0;
}

.project-detail-header {
    padding: 1rem 3rem;
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: var(--color-modal-bg);
    border-bottom: 1px solid var(--color-border);
}

.project-header-info {
    flex: 1;
    min-width: 0;
}

.project-header-image {
    flex: 0 0 auto;
    max-width: 280px;
    align-self: flex-end;
}

.project-header-image img {
    width: 100%;
    border-radius: var(--card-radius-sm);
    display: block;
    object-fit: scale-down;
}

.project-detail-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    letter-spacing: -0.015em;
}

.project-detail-subtitle {
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.project-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.meta-item {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.meta-item strong {
    color: var(--color-text);
}

/* YouTube trailer embed */
.project-detail-trailer {
    width: 50%;
    margin: 0 auto;
    padding: 1.5rem 0 0.5rem;
    aspect-ratio: 16 / 9;
}

/* Trailer inside body flow — tighter spacing */
.project-detail-trailer--inline {
    width: 70%;
    margin: 0 auto;
    padding: 0.5rem 0 1.5rem;
}

.project-detail-trailer iframe,
.project-detail-trailer video {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: var(--card-radius-sm);
    background: #000;
}

/* Hide modal videos until ready to play — prevents flash of loading spinner */
.modal-container video {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-container video.is-ready {
    opacity: 1;
}

/* Body sections */
.project-detail-body {
    padding: 2rem 3rem 3rem;
}

.project-detail-section {
    margin-bottom: 2rem;
}

.project-detail-section:last-child {
    margin-bottom: 0;
}

.project-detail-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.project-detail-section p {
    color: var(--color-text-muted);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.project-detail-section h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 1.75rem 0 0.5rem;
}

.project-detail-section h3:first-child {
    margin-top: 0;
}

/* Tech breakdown inline figures */
.tech-breakdown-figure {
    margin: 1rem auto 0;
    max-width: 60%;
}

.tech-breakdown-block .tech-breakdown-figure {
    margin-bottom: 0;
}

.media-note {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
    font-style: italic;
    margin-top: 0.5rem;
    margin-bottom: 0;
    text-align: center;
}

@media (max-width: 768px) {
    .media-note {
        text-align: left;
    }
}

.tech-breakdown-figure img {
    width: 100%;
    border-radius: var(--card-radius);
    border: 1px solid var(--color-border);
    display: block;
}

/* Side-by-side text + image layout */
.tech-breakdown-row,
.tech-breakdown-block {
    background: var(--color-card-overlay-bg);
    border: none;
    border-radius: var(--card-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}


.tech-breakdown-row {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.tech-breakdown-row--reverse {
    flex-direction: row-reverse;
}

.tech-breakdown-inner-row {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.tech-breakdown-inner-row--reverse {
    flex-direction: row-reverse;
}

.tech-breakdown-inner-row > .tech-breakdown-text {
    flex: 1;
    min-width: 0;
}

.tech-breakdown-inner-row > .tech-breakdown-text h3 {
    margin-top: 0;
}

.tech-breakdown-inner-row > .tech-breakdown-figure {
    flex: 0 0 45%;
    max-width: 45%;
    min-width: 0;
    margin: 0;
}

.tech-breakdown-block > .project-gallery--strip {
    margin-top: 1rem;
}

.read-more-toggle {
    display: none;
}

@media (max-width: 768px) {
    .tech-breakdown-inner-row,
    .tech-breakdown-inner-row--reverse {
        flex-direction: column;
    }

    .tech-breakdown-inner-row > .tech-breakdown-figure {
        flex: none;
        max-width: 100%;
    }

    .tech-breakdown-figure {
        max-width: 100%;
    }

    .tech-breakdown-block .tech-breakdown-row,
    .tech-breakdown-block .tech-breakdown-row--reverse {
        padding: 0;
        background: transparent;
        margin-bottom: 1rem;
    }

    .tech-breakdown-block .tech-breakdown-row:last-child,
    .tech-breakdown-block .tech-breakdown-row--reverse:last-child {
        margin-bottom: 0;
    }

    .tech-breakdown-text.is-collapsible .tech-breakdown-text-inner {
        position: relative;
        max-height: 7em;
        overflow: hidden;
    }

    .tech-breakdown-text.is-collapsible .tech-breakdown-text-inner::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 3.5em;
        background: linear-gradient(to bottom, transparent, var(--color-modal-bg));
        pointer-events: none;
    }

    .tech-breakdown-text.is-collapsible.is-expanded .tech-breakdown-text-inner {
        max-height: none;
    }

    .tech-breakdown-text.is-collapsible.is-expanded .tech-breakdown-text-inner::after {
        display: none;
    }

    .tech-breakdown-text.is-collapsible .read-more-toggle {
        display: inline-block;
        margin-top: 0.75rem;
        background: transparent;
        border: 1px solid var(--color-border);
        color: var(--color-text);
        padding: 0.4rem 0.9rem;
        border-radius: 999px;
        font-size: 0.85rem;
        font-weight: 500;
        font-family: inherit;
        cursor: pointer;
    }

    .tech-breakdown-text.is-collapsible .read-more-toggle:hover {
        background: var(--color-bg-elevated);
    }
}

.tech-breakdown-row .tech-breakdown-text {
    flex: 1;
    min-width: 0;
}

.tech-breakdown-row .tech-breakdown-text h3 {
    margin-top: 0;
}

.tech-breakdown-row .tech-breakdown-figure {
    flex: 0 0 45%;
    max-width: 45%;
    margin: 0;
}

@media (max-width: 768px) {
    .tech-breakdown-row,
    .tech-breakdown-row--reverse {
        flex-direction: column;
    }

    .tech-breakdown-row .tech-breakdown-figure {
        flex: none;
        max-width: 100%;
    }

}

.tech-breakdown-block h4 {
    color: var(--color-text-muted);
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.contrib-media-item figcaption {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: 0.4rem;
}

/* Compute section: text left, diagram + code right */
.plugin-params-media {
    grid-template-columns: auto auto;
    justify-content: center;
}

.plugin-params-media .contrib-media-item {
    max-height: 400px;
}

.plugin-params-media .contrib-media-item img {
    height: 100%;
    width: auto;
    aspect-ratio: auto;
}

.compute-section {
    align-items: flex-start;
}

.compute-section .tech-breakdown-text {
    flex: 0 0 25%;
    position: sticky;
    top: 1rem;
}

.compute-media-row {
    display: flex;
    gap: 1rem;
    flex: 1 1 65%;
    min-width: 0;
    align-items: stretch;
    max-height: 70vh;
    overflow: hidden;
}

.compute-diagram {
    flex: 0 0 34%;
    margin: 0;
}

.compute-diagram img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--card-radius-sm);
    border: 1px solid var(--color-border);
}

.compute-media-row .code-embed {
    flex: 1 1 74%;
    min-width: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
}

.compute-media-row .code-panel pre {
    padding: 0.8rem;
}

.compute-media-row .code-panel code {
    font-size: 0.72rem;
    line-height: 1.45;
}

@media (max-width: 900px) {
    .compute-section {
        flex-direction: column;
    }

    .compute-section .tech-breakdown-text {
        flex: none;
        position: static;
    }

    .compute-media-row {
        flex-direction: column;
        max-height: none;
        width: 100%;
    }

    .compute-diagram {
        flex: none;
        max-width: 100%;
        width: 100%;
        margin: 0 auto;
    }

    .compute-diagram img {
        height: auto;
        object-fit: contain;
    }

    .compute-media-row .code-embed {
        width: 100%;
        max-width: 100%;
    }

    .compute-media-row .code-panel pre {
        overflow-x: auto;
        max-width: 100%;
    }

    .compute-media-row .code-panel.active {
        flex: none;
        max-height: 380px;
        overflow: auto;
    }

    .plugin-params-media {
        grid-template-columns: 1fr !important;
    }

    .plugin-params-media .contrib-media-item img {
        width: 100%;
        height: auto;
        aspect-ratio: auto;
    }
}

/* Code embed blocks */
.code-embed {
    margin-top: 1.5rem;
    border-radius: var(--card-radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: #1a1a2e;
}

.code-embed-tabs {
    display: flex;
    background: var(--color-card-hover-bg);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
}

.code-tab {
    padding: 0.6rem 1.2rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-family: var(--font-main);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.code-tab:hover {
    color: var(--color-text);
}

.code-tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.code-panel {
    display: none;
    overflow: auto;
}

.code-panel.active {
    display: block;
}

.compute-media-row .code-panel.active {
    flex: 1;
}

.code-panel pre {
    margin: 0;
    padding: 1.2rem;
    overflow-x: auto;
    background: transparent;
}

.code-panel code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    color: #c9d1d9;
    tab-size: 4;
}

/* Syntax highlighting - dark theme */
.hlsl-keyword { color: #ff7b72; }
.hlsl-type    { color: #79c0ff; }
.hlsl-func    { color: #d2a8ff; }
.hlsl-num     { color: #a5d6ff; }
.hlsl-str     { color: #a5d6ff; }
.hlsl-comment { color: #8b949e; font-style: italic; }
.hlsl-attr    { color: #ffa657; }

/* Scrollbar styling for code panels */
.code-panel::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.code-panel::-webkit-scrollbar-track {
    background: transparent;
}

.code-panel::-webkit-scrollbar-thumb {
    background: rgba(var(--color-overlay-white), 0.15);
    border-radius: 3px;
}

.code-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-overlay-white), 0.25);
}

/* Contribution media grid */
.contrib-media {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.contrib-media-item {
    margin: 0;
    overflow: hidden;
    border-radius: calc(var(--card-radius) * 0.6);
    border: 1px solid var(--color-border);
}

.contrib-media-item img,
.contrib-media-item video {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    display: block;
    background: #000;
}

.contrib-media--contain .contrib-media-item img {
    object-fit: contain;
    background: #1a1a1a;
}

.contrib-media--contain .contrib-media-item video {
    object-fit: contain;
    background: #000;
}

.contrib-media-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    grid-column: 1 / -1;
}

.contrib-media-pair + .contrib-media-item {
    grid-column: 1 / -1;
    max-width: 60%;
    justify-self: center;
}

.contrib-media-item--contain img {
    object-fit: contain;
    background: #1a1a1a;
}

.contrib-media-item--contain video {
    object-fit: contain;
    background: #000;
}

.contrib-media--16x9 .contrib-media-item img,
.contrib-media--16x9 .contrib-media-item video {
    aspect-ratio: 16 / 9;
}

.contrib-media--portrait .contrib-media-item img,
.contrib-media--portrait .contrib-media-item video {
    aspect-ratio: 3 / 5;
}

.contrib-media--square .contrib-media-item img,
.contrib-media--square .contrib-media-item video {
    aspect-ratio: 1 / 1;
}

.contrib-media--tall .contrib-media-item img,
.contrib-media--tall .contrib-media-item video {
    aspect-ratio: 3 / 4;
}

/* Gallery grid inside project detail */
.project-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 0.75rem;
}

.project-gallery img,
.project-gallery video {
    width: 100%;
    border-radius: 8px;
    display: block;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border: 1px solid var(--color-border);
    transition: border-color 0.3s ease;
}

.project-gallery img:hover,
.project-gallery video:hover {
    border-color: var(--color-subtle-border);
}

/* Compact single-row gallery strip */
.project-gallery--strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    padding-bottom: 0.5rem;
}

.project-gallery--strip img,
.project-gallery--strip video {
    flex: 0 0 auto;
    width: 140px;
    height: 90px;
    aspect-ratio: auto;
    object-fit: cover;
}

.project-gallery--strip::-webkit-scrollbar {
    height: 6px;
}

.project-gallery--strip::-webkit-scrollbar-track {
    background: transparent;
}

.project-gallery--strip::-webkit-scrollbar-thumb {
    background: rgba(var(--color-overlay-white), 0.12);
    border-radius: 3px;
}

.project-gallery--strip::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-overlay-white), 0.2);
}

@media (max-width: 768px) {
    .project-gallery--strip {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 0.5rem;
    }

    .project-gallery--strip img,
    .project-gallery--strip video {
        width: 120px;
        height: 78px;
        scroll-snap-align: start;
    }

    .project-gallery--strip .gallery-more-indicator {
        display: none;
    }
}

.project-gallery--strip .gallery-more-indicator {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: linear-gradient(to right, transparent, var(--color-modal-bg));
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Tools list as pills with icons */
.tools-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
}

.tools-list li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--color-bg-elevated-2);
    color: var(--color-text-muted);
    padding: 0.4rem 1rem;
    border-radius: 980px;
    font-size: 0.85rem;
}

.tools-list .tool-icon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Project external links (repo, itch.io, etc.) */
.project-detail-links-section {
    text-align: center;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
}

.project-detail-links-section h2 {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.project-detail-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.project-detail-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-tertiary);
    text-decoration: none;
    transition: color 0.3s ease, transform 0.3s ease;
}

.project-detail-links a:hover {
    color: var(--color-text);
    transform: scale(1.15);
}

.project-detail-links img {
    width: 32px;
    height: 32px;
    filter: brightness(0.5);
    transition: filter 0.3s ease;
}

.project-detail-links a:hover img {
    filter: brightness(1);
}

/* Links inside project detail */
.project-links {
    list-style: none;
}

.project-links li {
    margin-bottom: 0.5rem;
}

.project-links a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

.project-links a:hover {
    color: #6CB4FF;
}

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */
[data-reveal] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

[data-reveal].is-visible {
    opacity: 1;
    transform: translateY(0);
}

[data-reveal].is-past {
    opacity: 0;
    transform: translateY(-20px);
}

/* Cards get reveal via JS — staggered delays */
.piece[data-reveal] {
    transition: opacity 0.6s ease, transform 0.6s ease, filter 0.7s ease-in-out;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    .nav-links {
        gap: 1.25rem;
    }

    .hero {
        padding-top: calc(var(--spacing-lg) + 60px);
    }

    section {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    /* Modal goes full-screen */
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal-container {
        width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .project-detail-header {
        padding: 0.75rem 1rem;
        flex-direction: row;
        position: relative; /* Not sticky on mobile — let it scroll away */
        gap: 0.75rem;
        align-items: center;
    }

    .project-header-image {
        display: none;
    }

    .project-detail-title {
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
    }

    .project-detail-subtitle {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }

    .project-detail-meta {
        gap: 0.25rem 0.75rem;
        font-size: 0.7rem;
    }

    .meta-item {
        font-size: 0.7rem;
    }

    .project-detail-trailer,
    .project-detail-trailer--inline {
        width: 100%;
        padding: 0.5rem 0;
    }

    .project-detail-trailer > h3,
    .project-detail-trailer--inline > h3 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .tech-breakdown-figure {
        max-width: 100%;
    }

    .project-detail-body {
        padding: 1.5rem 0;
    }

    .project-detail-section {
        padding: 0;
    }

    .skills-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    /* ArtStation-style mobile: edge-to-edge media, text stays padded */
    .project-detail-section > h2,
    .project-detail-section > h3,
    .project-detail-section > h4,
    .project-detail-section > p,
    .project-detail-section > ul,
    .project-detail-section > .project-detail-trailer > h3,
    .tech-breakdown-block > h3,
    .tech-breakdown-block > h4,
    .tech-breakdown-block > p,
    .tech-breakdown-text {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .tech-breakdown-row,
    .tech-breakdown-row--reverse,
    .tech-breakdown-block {
        background: transparent;
        padding: 0;
        margin-bottom: 1.5rem;
    }

    .tech-breakdown-block .tech-breakdown-row,
    .tech-breakdown-block .tech-breakdown-row--reverse {
        margin-bottom: 1rem;
    }

    .tech-breakdown-figure,
    .tech-breakdown-block .tech-breakdown-figure {
        margin: 0;
    }

    .tech-breakdown-figure img,
    .tech-breakdown-figure video {
        border-radius: 0;
        border: none;
    }

    .contrib-media-item img,
    .contrib-media-item video {
        border-radius: 0;
    }

    .contrib-media,
    .contrib-media-pair {
        grid-template-columns: 1fr;
        max-width: 100% !important;
        gap: 0.5rem;
    }

    .contrib-media-pair + .contrib-media-item {
        max-width: 100%;
    }

    .contrib-media-item {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .project-detail-trailer--inline video,
    .project-detail-trailer--inline iframe {
        border-radius: 0;
    }

    .project-gallery--strip {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* iOS Safari: suppress the lingering "start playback" / overlay button on inline videos */
    video::-webkit-media-controls-start-playback-button,
    video::-webkit-media-controls-overlay-play-button {
        display: none !important;
        -webkit-appearance: none !important;
    }

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

    .about-divider {
        width: 100%;
        height: 1px;
        align-self: auto;
    }

    .contact {
        padding-bottom: clamp(4rem, 17vh, 10rem);
    }

    .pieces-section {
        padding-top: 6rem;
    }

    .pieces-section .section-title {
        margin-left: 3%;
    }

    .projects-section .section-title {
        margin-left: 3%;
    }
}

/* Tablet / touch carousel breakpoint */
@media (max-width: 1400px) {
    .pieces-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        justify-content: stretch;
        margin: 0 10%;
        gap: 1rem;
    }
    .pieces-grid > .piece-wrapper {
        flex: initial;
    }
}

@media (max-width: 768px) {
    .pieces-grid {
        grid-template-columns: 1fr;
        margin: 0 5%;
    }
}

@media (max-width: 1024px) {

    .projects-carousel {
        margin: 0 0;
        overflow: hidden;
    }

    .carousel-track {
        position: relative;
        height: clamp(250px, 55vw, 400px);
        gap: 0;
        touch-action: pan-y pinch-zoom;
    }

    .carousel-track .project {
        position: absolute;
        top: 0;
        left: 10%;
        width: 80%;
        height: 100%;
        filter: brightness(0.5);
        transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                    filter 0.5s ease,
                    opacity 0.5s ease;
        transform: translateX(100%) scale(0.85);
        opacity: 0;
        pointer-events: none;
        z-index: 0;
    }

    .carousel-track .project.carousel-prev {
        transform: translateX(-28%) scale(0.82);
        filter: brightness(0.35);
        opacity: 1;
        z-index: 1;
        pointer-events: auto;
        cursor: pointer;
    }

    .carousel-track .project.carousel-active {
        transform: translateX(0) scale(1);
        filter: none;
        opacity: 1;
        z-index: 3;
        pointer-events: auto;
    }

    .carousel-track .project.carousel-next {
        transform: translateX(28%) scale(0.82);
        filter: brightness(0.35);
        opacity: 1;
        z-index: 1;
        pointer-events: auto;
        cursor: pointer;
    }

    .carousel-track .project .project-overlay {
        opacity: 0;
        transition: opacity 0.4s ease;
    }

    .carousel-track .project.carousel-active .project-overlay {
        opacity: 1;
    }

    .carousel-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        padding: 1rem 0 0;
    }

    .carousel-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        border: none;
        background: rgba(var(--color-overlay-white), 0.3);
        cursor: pointer;
        padding: 0;
        transition: background 0.3s ease;
    }

    .carousel-dot.is-active {
        background: rgba(var(--color-overlay-white), 0.9);
    }
}

/* Touch-only devices (tablets in landscape, etc.) */
@media (pointer: coarse) {
    .projects-carousel {
        margin: 0 0;
        overflow: hidden;
    }

    .carousel-track {
        position: relative;
        height: clamp(250px, 55vw, 400px);
        gap: 0;
        touch-action: pan-y pinch-zoom;
    }

    .carousel-track .project {
        position: absolute;
        top: 0;
        left: 10%;
        width: 80%;
        height: 100%;
        filter: brightness(0.5);
        transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                    filter 0.5s ease,
                    opacity 0.5s ease;
        transform: translateX(100%) scale(0.85);
        opacity: 0;
        pointer-events: none;
        z-index: 0;
    }

    .carousel-track .project.carousel-prev {
        transform: translateX(-28%) scale(0.82);
        filter: brightness(0.35);
        opacity: 1;
        z-index: 1;
        pointer-events: auto;
        cursor: pointer;
    }

    .carousel-track .project.carousel-active {
        transform: translateX(0) scale(1);
        filter: none;
        opacity: 1;
        z-index: 3;
        pointer-events: auto;
    }

    .carousel-track .project.carousel-next {
        transform: translateX(28%) scale(0.82);
        filter: brightness(0.35);
        opacity: 1;
        z-index: 1;
        pointer-events: auto;
        cursor: pointer;
    }

    .carousel-track .project .project-overlay {
        opacity: 0;
        transition: opacity 0.4s ease;
    }

    .carousel-track .project.carousel-active .project-overlay {
        opacity: 1;
    }

    .carousel-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        padding: 1rem 0 0;
    }

    .carousel-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        border: none;
        background: rgba(var(--color-overlay-white), 0.3);
        cursor: pointer;
        padding: 0;
        transition: background 0.3s ease;
    }

    .carousel-dot.is-active {
        background: rgba(var(--color-overlay-white), 0.9);
    }
}

/* Phone */
@media (max-width: 480px) {
    .nav-container {
        flex-direction: column;
        gap: 0.75rem;
    }

    .nav-links {
        gap: 1.5rem;
    }

    .nav-cv-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.85rem;
    }

    .cv-full {
        display: none;
    }

    .cv-short {
        display: inline;
    }

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

    .project-detail-trailer {
        padding: 0 1rem;
    }

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

    .pieces-grid {
        margin: 0 2%;
        grid-template-columns: 1fr;
    }

    .projects-carousel {
        margin: 0 2%;
    }

    .carousel-track {
        height: clamp(200px, 60vw, 300px);
    }
}

/* ── Lightbox ─────────────────────────────── */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    cursor: pointer;
}

.lightbox-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay .lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 6px;
    cursor: default;
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.lightbox-overlay.is-active .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 1;
    line-height: 1;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    font-size: 3.5rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    z-index: 1;
    line-height: 1;
    padding: 1rem;
    user-select: none;
}

.lightbox-arrow:hover {
    opacity: 1;
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-caption {
    position: absolute;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%);
    max-width: 80vw;
    background: rgba(30, 30, 30, 0.75);
    color: #fff;
    padding: 0.6rem 1.1rem;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: none;
    z-index: 1;
}

.contrib-media-item img,
.contrib-media-item video {
    cursor: pointer;
}

.project-gallery img,
.project-gallery video {
    cursor: pointer;
}

@media (max-width: 768px) {
    .lightbox-overlay .lightbox-content {
        max-width: 95vw;
        max-height: 80vh;
    }

    .lightbox-close {
        top: 0.75rem;
        right: 0.75rem;
        font-size: 2.5rem;
        padding: 0.5rem;
    }

    .lightbox-arrow {
        font-size: 2.5rem;
        padding: 0.75rem;
    }

    .lightbox-caption {
        bottom: 1rem;
        max-width: 90vw;
        font-size: 0.85rem;
        padding: 0.5rem 0.85rem;
    }

    .lightbox-prev {
        left: 0.25rem;
    }

    .lightbox-next {
        right: 0.25rem;
    }
}
