/* --- GLOBAL RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: none !important;
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
    hyphens: none;
}

html {
    background-color: #000;
}

body {
    background-color: #000;
    color: #fff;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
}

/* --- LEAVE LOADER UTILS --- */
.no-loader #preloader {
    display: none !important;
}

/* --- PRELOADER --- */
#preloader {
    position: fixed;
    inset: 0;
    background-color: #000;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-in-out, visibility 0.8s;
}

.loader-content {
    text-align: center;
    width: 300px;
}

.loader-percent {
    font-family: 'JetBrains Mono', monospace;
    font-size: 4rem;
    color: #fff;
    margin-bottom: 10px;
    font-weight: 400;
    letter-spacing: -2px;
}

.loader-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #00f2ff;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    height: 20px;
}

.loader-bar-bg {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.loader-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: #00f2ff;
    box-shadow: 0 0 10px #00f2ff;
    transition: width 0.1s linear;
}

body.loaded #preloader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.loaded {
    overflow-y: auto;
    overflow-x: hidden;
}

/* --- BACKGROUND & NOISE --- */
#fluid-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.noise-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 300%;
    height: 300%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.2s ease-out;
    animation: noiseAnimation 0.5s steps(3) infinite;
}

@keyframes noiseAnimation {
    0% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-5%, 5%);
    }

    40% {
        transform: translate(-5%, -5%);
    }

    60% {
        transform: translate(5%, 5%);
    }

    80% {
        transform: translate(5%, -5%);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* --- CURSOR --- */
.cursor-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
    mix-blend-mode: difference;
}

#pixel-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.ring {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s, border-color 0.3s;
}

/* Hide custom cursor on mobile/tablet/touch devices */
@media (hover: none) and (pointer: coarse),
(max-width: 1024px) {
    .cursor-wrapper {
        display: none !important;
    }

    * {
        cursor: auto !important;
    }
}

/* --- MENU --- */
.menu-trigger {
    position: fixed;
    top: 40px;
    right: 40px;
    z-index: 9500;
    background: none;
    border: none;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 2px;
    mix-blend-mode: difference;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(5, 5, 5, 0.98);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 10vw;
    clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
    transition: clip-path 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

.menu-overlay.active {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.nav-links-mobile {
    list-style: none;
}

.nav-item-mobile {
    overflow: hidden;
    margin: 10px 0;
}

.nav-link-mobile {
    font-family: 'Inter', sans-serif;
    font-size: 6vw;
    text-transform: uppercase;
    text-decoration: none;
    color: #888;
    display: block;
    transition: color 0.3s ease;
}

.nav-link-mobile:hover {
    color: #fff;
}

.nav-link-mobile span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    color: #00f2ff;
    margin-right: 30px;
    vertical-align: middle;
    position: relative;
    top: -1vw;
}

.desktop-nav {
    display: none;
    position: fixed;
    top: 40px;
    right: 60px;
    z-index: 5000;
    gap: 40px;
}

.desktop-link {
    text-decoration: none;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    transition: opacity 0.3s, color 0.3s;
    position: relative;
}

.desktop-link:hover {
    opacity: 1;
    color: #00f2ff;
}

.desktop-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0%;
    height: 1px;
    background: #00f2ff;
    transition: width 0.3s ease;
}

.desktop-link:hover::after {
    width: 100%;
}

@media (min-width: 1024px) {
    .menu-trigger {
        display: none;
    }

    .menu-overlay {
        display: none;
    }

    .desktop-nav {
        display: flex;
    }
}

/* --- LAYOUT --- */
section {
    padding: 15vh 10vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    z-index: 5;
}

h1 {
    font-size: 4.5vw;
    text-transform: uppercase;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: 30px;
    font-weight: 400;
}

/* Gradient on Inner Text for H1 */
.iO-std .inner {
    background: linear-gradient(135deg, #00f2ff 0%, #ffffff 60%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    display: inline-block;
    /* Ensure clip works */
}

.iO-std {
    opacity: 0;
}

@media (max-width: 768px) {
    h1 {
        font-size: 7vw;
    }
}

h2.section-title {
    font-size: 4vw;
    text-transform: uppercase;
    margin-bottom: 60px;
    font-weight: 400;
    letter-spacing: -0.03em;
}

/* Gradient on Inner Text for Section Titles */
.section-title .inner {
    background: linear-gradient(135deg, #00f2ff 0%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

/* --- AWRITE & GLITCH STYLES --- */
.Awrite {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    text-transform: uppercase;
    color: #00f2ff;
    margin-bottom: 15px;
    opacity: 0;
    /* Changed from 1 to 0 to prevent flash */
    position: relative;
    display: inline-block;
    vertical-align: top;
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
    hyphens: none;
}

.awrite-word {
    display: inline-block;
    white-space: nowrap;
}

.char {
    display: none;
    white-space: pre;
}

.type-cursor {
    width: 8px;
    height: 1.1em;
    background: #00f2ff;
    display: none;
    vertical-align: sub;
    margin-left: 2px;
}

.cursor-blink {
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* Glitch Sottile */
.glitch-active {
    animation: glitch-anim 0.2s steps(2) both infinite;
    color: #fff !important;
}

@keyframes glitch-anim {
    0% {
        text-shadow: 1px 0 rgba(0, 242, 255, 0.7), -1px 0 rgba(255, 0, 193, 0.7);
    }

    25% {
        text-shadow: -1px 0 rgba(255, 0, 193, 0.7), 1px 0 rgba(0, 242, 255, 0.7);
    }

    50% {
        text-shadow: 1px 0 rgba(0, 242, 255, 0.7), -1px 0 rgba(255, 0, 193, 0.7);
    }

    75% {
        text-shadow: -1px 0 rgba(255, 0, 193, 0.7), 1px 0 rgba(0, 242, 255, 0.7);
    }

    100% {
        text-shadow: 1px 0 rgba(0, 242, 255, 0.7), -1px 0 rgba(255, 0, 193, 0.7);
    }
}

/* --- WORKS --- */
.works-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    width: 100%;
}

@media (min-width: 768px) {
    .works-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.work-card {
    position: relative;
    display: block;
    text-decoration: none;
    width: 100%;
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/10;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.4s ease;
    margin-bottom: 20px;
    background: #111;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.2, 1, 0.3, 1);
}

.work-card:hover .card-image-wrapper {
    border-color: #00f2ff;
}

.work-card:hover .card-image {
    transform: scale(1.05);
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

.work-card .card-meta .Awrite {
    font-size: 14px;
    color: #00f2ff;
    font-weight: 400;
}

/* Titoli Card */
.work-card .Awrite {
    font-size: 20px;
    margin-bottom: 5px;
    color: #fff;
    opacity: 1;
    font-weight: 500;
}

/* MODIFICA: Su mobile (max 768px), riduci font size a 18px */
@media (max-width: 768px) {
    .work-card .Awrite {
        font-size: 18px;
    }
}

.year-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: #888;
    transition: color 0.3s, border-color 0.3s;
}

.work-card:hover .year-tag {
    color: #00f2ff;
    border-color: #00f2ff;
}

/* --- CARD HEADER --- */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-header .Awrite {
    font-size: 14px;
    color: #00f2ff;
    margin-bottom: 0;
    font-weight: 400;
}

.card-title-reveal {
    font-size: 20px;
    text-transform: uppercase;
    color: #fff;
    /* Fallback */
    opacity: 0;
    overflow: hidden;
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.card-title-reveal .inner {
    background: linear-gradient(135deg, #00f2ff 0%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

@media (max-width: 768px) {
    .card-title-reveal {
        font-size: 18px;
    }
}

/* --- BUTTON --- */
.aura-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 20px 50px;
    background: #000;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 3px;
    text-decoration: none;
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    border: 1px solid rgba(0, 242, 255, 0.2);
    width: fit-content;
    opacity: 0;
}

.aura-btn .btn-text {
    background: linear-gradient(135deg, #00f2ff 0%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.aura-btn::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: 2px;
    padding: 1px;
    background: linear-gradient(90deg, transparent, transparent, #00f2ff, transparent, transparent);
    background-size: 200% 100%;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: destination-out;
    animation: borderFlow 4s linear infinite;
    opacity: 0.5;
}

@keyframes borderFlow {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.aura-btn:hover {
    border-color: rgba(0, 242, 255, 0.6);
    color: #00f2ff;
}

/* --- BRAND LOGO --- */
.brand-logo {
    position: fixed;
    top: 40px;
    left: 40px;
    z-index: 5000;
}

/* --- PROJECT PAGE STYLES --- */
.project-hero {
    width: 100vw;
    height: 100vh;
    padding: 0 !important;
    /* Override global section padding */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.project-image-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
}

.back-button {
    position: fixed;
    top: 40px;
    left: 40px;
    z-index: 6000;
    /* Higher than brand logo */
    color: #fff;
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    mix-blend-mode: difference;
    text-transform: uppercase;
}

/* --- MOBILE SPECIFIC OVERRIDES --- */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .project-hero-mobile {
        display: flex !important;
        width: 100%;
        height: auto;
        min-height: 50vh;
        padding-top: 80px;
        align-items: flex-start;
        position: relative;
        overflow: hidden;
        z-index: 10;
    }

    .project-image-container-mobile {
        width: 100%;
        height: auto;
    }

    .project-image-mobile {
        width: 100%;
        height: auto;
        object-fit: contain;
        opacity: 0;
        /* Hidden initially for pixel reveal */
    }
}

/* --- DESKTOP SPECIFIC OVERRIDES --- */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}