/* --- 1. CONFIGURAZIONE & VARIABILI --- */
:root {
    --font-main: 'Inter', sans-serif;
    --font-arcade: 'Press Start 2P', monospace;
    --bg-color: #f0f4f8;
    --bg-gradient: radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.15) 0px, transparent 50%);
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: 1px solid rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
    --accent: #2563eb;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    --accent-glow: rgba(37, 99, 235, 0.3);
    --timeline-line: #cbd5e1;
}

[data-theme="dark"] {
    --bg-color: #020617;
    --bg-gradient: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #020617 60%);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --accent: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --accent-glow: rgba(56, 189, 248, 0.2);
    --timeline-line: #334155;
}

/* --- 2. RESET & GLOBAL --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    background-size: cover;
    color: var(--text-main);
    overflow-x: hidden;
    transition: all 0.5s ease;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

/* --- 3. SCROLL SNAP LAYOUT (DESKTOP) --- */
.snap-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

section {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    perspective: 1000px;
}

.content-wrapper {
    width: 100%;
    max-width: 1100px;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    scrollbar-width: none;
    /* Firefox */
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s forwards ease-out 0.2s;
}

.content-wrapper::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 4. ULTIMATE GLASS CARD --- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--glass-border);
    border-radius: 30px;
    padding: 3.5rem;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
    width: 100%;
}

/* --- 5. TYPOGRAPHY --- */
h1 {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: -2px;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 2rem;
    color: var(--text-main);
    display: inline-block;
    position: relative;
}

h2::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 4px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

p {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.7;
}

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

.intro-tag {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 1rem;
    display: block;
}

.flag-icon {
    font-size: 4rem;
    margin-top: 2rem;
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s;
}

.flag-icon:hover {
    transform: scale(1.2) rotate(10deg);
}

/* --- 6. LAYOUT GRIDS --- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    align-items: center;
}

.align-top {
    align-items: start;
}

/* --- 7. UI CONTROLS (THEME & LANG) --- */
.theme-switch {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 999;
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    border: var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.4rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.theme-switch:hover {
    transform: scale(1.1) rotate(15deg);
    background: var(--accent);
    color: white;
    border-color: transparent;
}

.lang-switch-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 50px;
    border: var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 20px;
    transition: all 0.3s ease;
    font-family: var(--font-main);
}

.lang-btn:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
}

.lang-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 10px var(--accent-glow);
}

/* --- 8. GENERAL COMPONENTS --- */
.path-list {
    list-style: none;
    padding-left: 10px;
}

.path-list li {
    margin-bottom: 25px;
    position: relative;
    padding-left: 25px;
    border-left: 2px solid rgba(128, 128, 128, 0.2);
}

.path-list li::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 6px;
    width: 12px;
    height: 12px;
    background: var(--bg-color);
    border: 3px solid var(--accent);
    border-radius: 50%;
}

.map-placeholder {
    width: 100%;
    height: 200px;
    background: #ccc;
    border-radius: 20px;
    margin-top: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* --- 9. PASSIONI (UNIFORM LAYOUT) --- */
/* Questa sezione gestisce Vinile, Terminale e Arcade rendendoli identici nelle dimensioni */

/* Container Generici per l'allineamento testo/etichetta */
.vinyl-section,
.terminal-section,
.arcade-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.passion-label {
    margin-top: 1rem;
    font-weight: 600;
}

/* Stile Condiviso Wrapper (Dimensioni Fisse 300x320) */
.vinyl-wrapper,
.terminal-wrapper,
.arcade-frame {
    width: 100%;
    max-width: 300px;
    /* Larghezza fissa */
    height: 320px;
    /* Altezza fissa */
    margin: 0 auto;

    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Hover Effect Comune */
.vinyl-wrapper:hover,
.terminal-wrapper:hover,
.arcade-frame:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px var(--accent-glow);
    border-color: var(--accent);
}

/* --- A. VINYL --- */
.vinyl-wrapper {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

.record {
    width: 240px;
    height: 240px;
    /* Ridimensionato per stare nel box */
    background: radial-gradient(#111 20%, #222 21%, #111 22%, #181818 95%, #333 100%);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.record::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: repeating-radial-gradient(#111 0, #111 4px, #222 5px, #111 6px);
    opacity: 0.6;
    pointer-events: none;
}

.record-label {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid #fff;
    z-index: 5;
    background-size: cover;
    background-position: center;
    background-color: #111;
}

.tone-arm {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 80px;
    height: 120px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 140'%3E%3Cpath d='M45 0 L40 100 L25 125' stroke='%23bbb' stroke-width='10' fill='none'/%3E%3Crect x='20' y='120' width='25' height='35' fill='%23333'/%3E%3Ccircle cx='45' cy='0' r='15' fill='%23777'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    transform-origin: 45px 0;
    transition: transform 1s;
    pointer-events: none;
    z-index: 10;
}

.vinyl-wrapper.playing .tone-arm {
    transform: rotate(25deg);
}

.vinyl-wrapper.playing .record {
    animation: spinRecord 4s linear infinite;
    animation-delay: 0.8s;
}

@keyframes spinRecord {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* --- B. HACKING TERMINAL --- */
.terminal-wrapper {
    background: #0f172a;
    align-items: stretch;
    justify-content: flex-start;
}

.terminal-header {
    border-radius: 24px 24px 0 0;
    background: #1e293b;
    padding: 12px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.t-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.t-red {
    background: #ef4444;
}

.t-yellow {
    background: #fbbf24;
}

.t-green {
    background: #22c55e;
}

.terminal-body {
    padding: 20px;
    color: #22c55e;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    flex-grow: 1;
    overflow: hidden;
}

.cursor {
    display: inline-block;
    width: 10px;
    height: 18px;
    background: #22c55e;
    animation: blink 1s infinite;
    vertical-align: middle;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* --- C. ARCADE --- */
.arcade-frame {
    background: #1e293b;
    border: 6px solid #334155;
    padding: 20px;
    justify-content: space-between;
}

.arcade-screen-container {
    background: #000;
    width: 100%;
    height: 180px;
    border-radius: 8px;
    border: 3px solid #334155;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

#arcade-canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.arcade-controls {
    display: flex;
    justify-content: center;
    gap: 30px;
    width: 100%;
    padding-bottom: 10px;
}

.btn-red {
    width: 40px;
    height: 40px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 6px 0 #991b1b;
    cursor: pointer;
    border: 2px solid #7f1d1d;
}

.btn-red:active {
    transform: translateY(6px);
    box-shadow: none;
}


/* --- 10. PROJECTS --- */
.projects-scroll-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 10px 5px 30px 5px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    align-items: stretch;
}

.project-card {
    min-width: 300px;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.project-card:hover {
    transform: translateY(-5px);
    background: var(--glass-bg);
    border-color: var(--accent);
    box-shadow: 0 15px 30px -10px var(--accent-glow);
}

.project-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-card p {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
}

/* --- 11. SKILLS & TIMELINE --- */
.skills-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 1rem;
}

.skill-tag {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
}

.timeline-container {
    position: relative;
    border-left: none;
    padding-left: 20px;
    margin-left: 5px;
    margin-top: 15px;
    max-height: 45vh;
    overflow-y: auto;
    padding-right: 15px;
    padding-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.timeline-container::-webkit-scrollbar {
    width: 5px;
}

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

.timeline-container::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: 10px;
}

.timeline-item {
    position: relative;
    border-left: 3px solid var(--timeline-line);
    padding-bottom: 42px;
    margin-bottom: 0;
    padding-left: 32px;
}

.timeline-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 0;
    width: 15px;
    height: 15px;
    background: var(--bg-color);
    border: 3px solid var(--accent);
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 0 0 4px var(--bg-color);
}

.timeline-item:hover::before {
    background: var(--accent);
    transform: scale(1.2);
    transition: all 0.3s ease;
}

.t-year {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.t-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

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

/* Lingue */
.languages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lang-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lang-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.lang-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.lang-level {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

[data-theme="dark"] .progress-bar {
    background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 10px;
    opacity: 0.8;
}

/* =========================================
   MEDIA QUERIES (RESPONSIVE MOBILE)
   ========================================= */

@media (max-width: 900px) {

    /* 1. GRIGLIE DIVENTANO COLONNE UNICHE */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    /* 2. LAYOUT GENERALE MOBILE */
    .snap-container {
        height: auto;
        overflow-y: visible;
        scroll-snap-type: none;
    }

    section {
        height: auto;
        min-height: 100vh;
        padding: 4rem 1rem;
        display: flex;
        align-items: center;
        scroll-snap-align: none;
    }

    .content-wrapper {
        max-height: none;
        overflow: visible;
        transform: none !important;
        opacity: 1 !important;
        animation: none;
    }

    .glass-card {
        padding: 2rem 1.2rem;
        border-radius: 20px;
    }

    h1 {
        font-size: 2.8rem;
    }

    h2 {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
    }

    /* 3. SWITCHERS */
    .lang-switch-container {
        bottom: 10px;
        right: 10px;
        padding: 5px;
        gap: 2px;
    }

    .lang-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .theme-switch {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    /* 4. PROGETTI (Lista Verticale) */
    .projects-scroll-container {
        display: flex;
        flex-direction: column;
        gap: 20px;
        overflow-x: visible;
        padding-bottom: 0;
    }

    .project-card {
        min-width: 100%;
        max-width: 100%;
        padding: 1.5rem;
        transform: none !important;
    }

    .project-card:hover {
        transform: none;
        box-shadow: none;
    }

    /* 5. PASSIONI SU MOBILE (Rimpicciolire leggermente se necessario) */
    .vinyl-wrapper,
    .terminal-wrapper,
    .arcade-frame {
        width: 100%;
        max-width: 280px;
        height: 280px;
        /* Un po' più piccoli su mobile */
    }

    /* Adattamenti interni per size mobile */
    .record {
        width: 220px;
        height: 220px;
    }

    .arcade-screen-container {
        height: 150px;
    }

    .terminal-body {
        font-size: 0.8rem;
    }
}