/* ==========================================================
   Navigazione in profondità — "immersione" nell'oceano
   Caricato dopo style.css: sovrascrive lo scroll verticale.
   ========================================================== */

:root {
    --ink: rgb(203, 211, 231);
    --ink-dim: rgb(184, 192, 211);
    --ink-faint: rgba(184, 192, 211, 0.55);
    --line: rgba(203, 211, 231, 0.16);
    --biolume: rgb(110, 225, 255);
    --abyss: 0;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background: linear-gradient(180deg, rgb(6, 22, 44) 0%, rgb(1, 5, 14) 100%);
    color: var(--ink);
}

/* ---------- Atmosfera ---------- */

.surface-light {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 45% at 50% -10%, rgba(120, 180, 230, 0.22), transparent 70%),
        radial-gradient(ellipse 30% 60% at 35% -20%, rgba(150, 210, 255, 0.10), transparent 70%);
}

#snow-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* ---------- Viewport e livelli ---------- */

#viewport {
    position: fixed;
    inset: 0;
    z-index: 5;
    overflow: hidden;
    /* Tocco e rotella sono gestiti da depth.js (anche lo scroll interno delle sezioni) */
    touch-action: none;
}

.layer {
    position: absolute;
    inset: 0;
    visibility: hidden;
    transform-origin: 50% 50%;
    will-change: transform, opacity, filter;
}

/* Gli overlay restano fissi sopra tutto */
#underwater-canvas,
#noise-canvas {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    border-radius: 0;
}

#canvas3d,
.hero {
    border-radius: 0;
}

/* ---------- Hero ---------- */

/* "About" nel menu: "bout" un po' più a destra, così la "b" non entra troppo nella "A" */
.nav-link .about-a {
    margin-right: 0.12em;
}

/* "Dive": la "i" si stacca dalla coda della D, così la parola si legge */
.nav-link .dive-i {
    margin-left: 0.18em;
}

.nav-link .dive-v {
    margin-left: -0.05em;
}

/* Menu iniziale: al passaggio del mouse le voci si spostano lentamente e con morbidezza */
.layer[data-section="hero"] .nav-item {
    transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Alone luminoso unico per l'intera parola (menu e titoli delle sezioni).
   Con un text-shadow su ogni lettera, l'alone di una lettera veniva disegnato sopra
   quelle precedenti e le sovrapposizioni (es. la "o" sulla "P") restavano visibili. */
.nav-link span,
.depth-title span {
    text-shadow: none !important;
}

.nav-link {
    text-shadow: none !important;
    filter:
        drop-shadow(0 0 6px rgba(255, 255, 255, 0.28))
        drop-shadow(0 0 18px rgba(255, 255, 255, 0.16));
    transition: filter 0.8s ease;
}

.depth-title {
    filter:
        drop-shadow(0 0 8px rgba(255, 255, 255, 0.28))
        drop-shadow(0 0 24px rgba(255, 255, 255, 0.14));
}

.layer[data-section="hero"] .nav-item:hover .nav-link {
    filter:
        drop-shadow(0 0 8px rgba(255, 255, 255, 0.4))
        drop-shadow(0 0 22px rgba(110, 225, 255, 0.35));
}

/* ---------- Sezioni in profondità ---------- */

.depth-section {
    position: absolute;
    inset: 0;
    display: flex;
    /* safe: se il contenuto è più alto dello schermo parte dall'alto invece di uscire sopra */
    align-items: safe center;
    justify-content: center;
}

.section-inner {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1100px;
    /* Nessun overflow: gli elementi non vengono mai ritagliati durante il viaggio.
       Lo scroll del contenuto più alto dello schermo è gestito da depth.js (translateY). */
    padding: 96px 96px 72px 40px;
    will-change: transform;
}

.depth-section p {
    max-width: 60ch;
    font-size: inherit;
    color: var(--ink-dim);
}

.eyebrow {
    margin: 0 0 8px;
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 13px !important;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--biolume) !important;
    opacity: 0.8;
}

.depth-title {
    margin: 0 0 40px;
    font-size: clamp(64px, 11vw, 168px);
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
}

.depth-title span {
    letter-spacing: -0.02em !important;
}

.depth-title .font-luxurious:first-child {
    margin-right: -0.12em;
}

/* About: "bout" un po' più a destra, così la "b" non entra troppo nella "A" */
#about .depth-title .font-luxurious:first-child {
    margin-right: 0.02em;
}

.depth-title .font-luxurious { font-size: 1.3em; }
.depth-title .font-instrument { font-size: 0.85em; }
.depth-title .font-pixelify { font-size: 0.95em; }

.lead {
    font-size: clamp(18px, 1.6vw, 24px) !important;
    line-height: 1.55;
    margin: 0;
}

/* Biografia: paragrafo d'apertura grande, poi testo più piccolo */
.about-bio p:not(.lead) {
    margin: 18px 0 0;
    font-size: clamp(15px, 1.1vw, 17px) !important;
    line-height: 1.7;
    color: var(--ink-faint);
}

.next-link {
    display: inline-flex;
    gap: 10px;
    margin-top: 48px;
    font-size: 12px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-faint);
    transition: color 0.3s ease;
}

.next-link:hover,
.next-link:focus-visible {
    color: var(--biolume);
}

/* Gli elementi in profondità (opacità/scala/traslazione) sono pilotati da depth.js */
[data-k] {
    will-change: translate, scale, opacity;
}

/* About */
.about-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 56px;
    align-items: start;
}

.facts {
    margin: 0;
    border-top: 1px solid var(--line);
}

.facts div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
}

.facts dt {
    color: var(--ink-faint);
}

.facts dd {
    margin: 0;
    color: var(--ink);
    text-align: right;
}

/* Competenze chiave: tre gruppi di etichette accanto alla bio */
.skills {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.skill-group h3 {
    margin: 0 0 10px;
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--biolume);
}

.skill-group ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.skill-group li {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(8, 16, 34, 0.45);
    font-size: 13px;
    color: var(--ink);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.skill-group li:hover {
    border-color: rgba(110, 225, 255, 0.5);
    box-shadow: 0 0 14px rgba(110, 225, 255, 0.15);
}

/* Portfolio */
/* Ancorato in alto: cambiando categoria il titolo non salta */
.section-portfolio {
    align-items: flex-start;
}

.section-portfolio .section-inner {
    max-width: 1140px;
}

.section-portfolio .depth-title {
    margin-bottom: 32px;
    font-size: clamp(56px, 8vw, 128px);
}

.works-bar {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

/* Schede categoria: testo essenziale, la scheda attiva "si accende" come una spia */
.works-tabs {
    position: relative;
    display: inline-flex;
    gap: 34px;
}

.works-tab-indicator {
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 0;
    height: 1px;
    background: var(--biolume);
    box-shadow: 0 0 10px var(--biolume), 0 0 22px rgba(110, 225, 255, 0.5);
    transition: transform 0.6s var(--ease-out), width 0.6s var(--ease-out);
}

.works-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border: 0;
    background: none;
    font-family: 'Funnel Display', sans-serif;
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink-faint);
    cursor: pointer;
    transition: color 0.4s ease, text-shadow 0.4s ease;
}

.works-tab::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
    transition: background 0.4s ease, box-shadow 0.4s ease, opacity 0.4s ease;
}

.works-tab:hover,
.works-tab:focus-visible {
    color: var(--ink);
    outline: none;
}

.works-tab[aria-selected="true"] {
    color: #fff;
    text-shadow: 0 0 14px rgba(110, 225, 255, 0.45);
}

.works-tab[aria-selected="true"]::before {
    background: var(--biolume);
    box-shadow: 0 0 8px var(--biolume);
    opacity: 1;
}

/* Lightbox (comportamento ripreso da PortfolioCielo) */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    touch-action: none;
    animation: lb-fade 0.2s ease-out;
}

.lightbox[hidden] {
    display: none;
}

@keyframes lb-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.lightbox-card {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: rgb(24, 24, 27);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: perspective(1000px);
    will-change: transform;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.lightbox-card.is-touch {
    transition-duration: 0.1s;
}

/* Riflesso che segue il puntatore */
.lightbox-light {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    mix-blend-mode: overlay;
    transition: opacity 0.2s ease;
}

.lightbox-img {
    position: relative;
    z-index: 1;
    display: block;
    max-width: 70vw;
    max-height: 70vh;
    object-fit: contain;
    animation: lb-fade 0.2s ease-out;
}

.lightbox-link {
    display: inline-flex;
    padding: 14px 32px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    color: #fff;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.lightbox-link[hidden] {
    display: none;
}

.lightbox-link:hover,
.lightbox-link:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    transform: scale(1.05);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: grid;
    place-items: center;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    color: #fff;
    cursor: pointer;
    opacity: 0.4;
    transform: translateY(-50%);
    transition: opacity 0.3s ease, background 0.3s ease, transform 0.3s ease;
}

.lightbox-nav svg {
    width: 28px;
    height: 28px;
}

.lightbox-nav:hover,
.lightbox-nav:focus-visible {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev { left: 32px; }
.lightbox-next { right: 32px; }

.lightbox.is-single .lightbox-nav {
    visibility: hidden;
}

/* Contact */
.section-contact .section-inner {
    text-align: center;
    padding-left: 40px;
}

.section-contact p {
    margin-left: auto;
    margin-right: auto;
}

.contact-mail {
    display: inline-block;
    margin-top: 32px;
    font-family: 'Instrument Serif', serif;
    font-size: clamp(28px, 4vw, 56px);
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    transition: color 0.3s ease, border-color 0.3s ease, text-shadow 0.3s ease;
}

.contact-mail:hover,
.contact-mail:focus-visible {
    color: var(--biolume);
    border-color: var(--biolume);
    text-shadow: 0 0 24px rgba(110, 225, 255, 0.5);
}

.socials {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 28px 0 0;
    padding: 0;
    list-style: none;
}

.socials a {
    font-size: 13px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-faint);
    text-decoration: none;
    transition: color 0.3s ease;
}

.socials a:hover,
.socials a:focus-visible {
    color: var(--ink);
}

.biolume {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46vmin;
    height: 46vmin;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(110, 225, 255, 0.22), rgba(60, 120, 255, 0.08) 45%, transparent 70%);
    filter: blur(20px);
    animation: biolume-pulse 5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes biolume-pulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.92); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
}

/* ---------- HUD ---------- */

.ascend {
    position: fixed;
    top: 24px;
    left: 28px;
    z-index: 40;
    display: inline-flex;
    gap: 8px;
    font-size: 12px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-dim);
    transition: opacity 0.5s ease, color 0.3s ease;
}

.ascend:hover,
.ascend:focus-visible {
    color: var(--biolume);
}

body[data-section="hero"] .ascend {
    opacity: 0;
    pointer-events: none;
}

.depth-hud {
    position: fixed;
    top: 50%;
    right: 28px;
    z-index: 40;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 20px;
    pointer-events: none;
}

.depth-readout {
    display: grid;
    grid-template-columns: auto auto;
    align-items: baseline;
    justify-items: end;
    column-gap: 4px;
    color: var(--ink);
}

.depth-value {
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    min-width: 4ch;
    text-align: right;
}

.depth-unit {
    font-family: 'Pixelify Sans', sans-serif;
    font-size: 12px;
    color: var(--ink-faint);
}

.depth-zone {
    grid-column: 1 / -1;
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 15px;
    color: var(--ink-faint);
}

.depth-gauge {
    position: relative;
    width: 1px;
    height: 34vh;
    margin-right: 3px;
    background: linear-gradient(180deg, var(--line), rgba(203, 211, 231, 0.04));
}

/* Area di presa della linea: larga e invisibile, così si afferra facilmente anche col dito */
.depth-gauge::before {
    content: '';
    position: absolute;
    top: -14px;
    bottom: -14px;
    left: -18px;
    width: 36px;
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
}

.gauge-dragging,
.gauge-dragging * {
    cursor: grabbing !important;
    user-select: none;
}

.depth-marks {
    margin: 0;
    padding: 0;
    list-style: none;
}

.depth-marks li {
    position: absolute;
    top: var(--pos);
    right: 0;
    transform: translateY(-50%);
}

.depth-marks a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0 6px 12px;
    color: var(--ink-faint);
    text-decoration: none;
    pointer-events: auto;
    transition: color 0.3s ease;
}

.mark-tick {
    order: 2;
    width: 9px;
    height: 1px;
    background: currentColor;
}

.mark-label {
    order: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.mark-label em {
    font-family: 'Pixelify Sans', sans-serif;
    font-style: normal;
    font-size: 10px;
    letter-spacing: 0.1em;
    opacity: 0.6;
}

.depth-hud:hover .mark-label,
.depth-marks li.is-current .mark-label,
.depth-marks a:focus-visible .mark-label {
    opacity: 1;
    transform: none;
}

.depth-marks li.is-current a,
.depth-marks a:hover {
    color: var(--ink);
}

.depth-indicator {
    position: absolute;
    left: -3px;
    width: 7px;
    height: 7px;
    margin-top: -3.5px;
    border-radius: 50%;
    background: var(--biolume);
    box-shadow: 0 0 10px var(--biolume), 0 0 24px rgba(110, 225, 255, 0.5);
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* area di presa più grande della sfera */
.depth-indicator::after {
    content: '';
    position: absolute;
    inset: -14px;
    border-radius: 50%;
}

.depth-indicator:hover,
.gauge-dragging .depth-indicator {
    transform: scale(1.6);
    box-shadow: 0 0 14px var(--biolume), 0 0 32px rgba(110, 225, 255, 0.7);
}

/* ---------- Mobile ---------- */

@media (max-width: 768px) {
    /* margini più ampi su mobile: più aria ai lati, in alto e in basso */
    .section-inner {
        padding: 96px 64px 72px 32px;
    }

    .about-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .works-tabs {
        gap: 18px;
    }

    .works-tab {
        gap: 7px;
        font-size: 10px;
        letter-spacing: 0.14em;
    }

    .lightbox {
        padding: 16px;
    }

    .lightbox-stage {
        gap: 24px;
    }

    .lightbox-img {
        max-width: 80vw;
    }

    .lightbox-link {
        padding: 12px 24px;
        font-size: 12px;
    }

    .lightbox-nav {
        padding: 12px;
    }

    .lightbox-nav svg {
        width: 24px;
        height: 24px;
    }

    .lightbox-prev { left: 16px; }
    .lightbox-next { right: 16px; }

    .depth-title {
        font-size: 17vw;
        margin-bottom: 24px;
    }

    .section-contact .section-inner {
        padding-left: 32px;
    }

    .socials {
        gap: 20px;
    }

    .ascend {
        top: 18px;
        left: 20px;
    }

    .depth-hud {
        right: 14px;
        gap: 14px;
    }

    .depth-value {
        font-size: 16px;
    }

    .depth-zone,
    .mark-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .biolume {
        animation: none;
    }
}

/* Il nome nell'hero è il titolo principale della pagina (h1): nessuno stile di titolo aggiunto */
h1.emanuele-logo {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    line-height: normal;
    color: inherit;
}
