/* Importa la font Fondazione */
@font-face {
    font-family: 'Fondazione';
    src: url('assets/Fondazione-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

/* Importa FFUnitRounded ProRegular */
@font-face {
    font-family: 'FFUnitRounded';
    src: url('assets/FFUnitRounded%20ProRegular.otf') format('opentype');
}

/* Importa FFUnitRounded ProBold */
@font-face {
    font-family: 'FFUnitRoundedBold';
    src: url('assets/FFUnitRounded%20ProBold.otf') format('opentype');
}

.bold-text {
    font-family: 'FFUnitRoundedBold', sans-serif;
    font-size: 20px;
}

:root {
    --theme-color: #ff2200;
}

body.theme-cyan {
    --theme-color: #2d83d3;
}

html,
body,
* {
    cursor: none !important;
}

::-webkit-slider-thumb {
    cursor: none !important;
}

::-webkit-slider-runnable-track {
    cursor: none !important;
}

::-moz-range-thumb {
    cursor: none !important;
}

::-moz-range-track {
    cursor: none !important;
}

body {
    font-family: 'FFUnitRounded', sans-serif;
    padding: 30px;
    background-color: #EEEEEE;
    color: #000000;
    overflow-x: hidden;
}

/* --- LAYOUT PORTFOLIO --- */
.portfolio-container {
    display: flex;
    max-width: 1400px;
    margin: 80px auto 0 auto;
    align-items: flex-start;
    position: relative;
}

/* --- HEADER LINE --- */
.top-red-line-container {
    display: flex;
    align-items: center;
    position: fixed;
    top: 30px;
    left: 0;
    right: 0;
    width: calc(100% - 60px);
    max-width: 1400px;
    margin: 0 auto;
    z-index: 100;
}

.red-line {
    height: 1px;
    background-color: var(--theme-color);
}

.line-left {
    position: absolute;
    top: 50%;
    right: 100%;
    width: 100vw;
}

.line-middle {
    flex: 1;
}

.line-right {
    position: absolute;
    top: 50%;
    left: 100%;
    width: 100vw;
}

.red-box {
    border: 1px solid var(--theme-color);
    padding: 8px 10px;
    font-size: 20px;
    color: #000000;
    background-color: #EEEEEE;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.red-box.active,
.red-box:hover {
    color: var(--theme-color);
}

#ufo-btn {
    font-family: 'FFUnitRounded', sans-serif;
}

/* --- STILI TOGGLE SWITCH --- */
.toggle-box {
    width: 68px;
    height: 38px;
    /* Esattamente la stessa altezza di .red-box */
    padding: 8px 4px;
    /* Padding top/bottom uguale, padding laterale ridotto per farlo più stretto */
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

#audio-toggle-btn {
    width: 38px;
    justify-content: center;
    padding: 0;
}

.toggle-handle {
    width: 50%;
    height: 140%;
    background-color: var(--theme-color);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

body.theme-cyan .toggle-handle {
    transform: translateX(100%);
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    padding-right: 40px;
    position: sticky;
    top: 80px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

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

.project-item {
    cursor: pointer;
    margin-bottom: 15px;
    font-size: 20px;
    transition: color 0.2s ease;
}

#project-bio {
    margin-bottom: 35px;
    /* Distanzia (come se saltassi una riga) BIO da Cantieri Culturali Armungia */
}

.subprojects-list {
    list-style: none;
    padding-left: 0px;
    margin: 15px 0 0 0;
}

.project-item:hover>.project-arrow,
.project-item.active>.project-arrow {
    color: var(--theme-color);
}

#master-trigger:hover .bold-text,
#master-trigger.active .bold-text {
    color: var(--theme-color);
}

.project-content {
    flex: 1;
    color: #555;
}

.category-label {
    font-family: 'FFUnitRounded', sans-serif;
    font-size: 20px;
    margin-bottom: 10px;
    color: #000000;
}

.hidden {
    display: none !important;
}

/* Contenitore principale a colonna (testo sopra, colonne sotto) */
.viewer-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.project-description {
    font-family: 'FFUnitRounded', sans-serif;
    font-size: 20px;
    line-height: 1.5;
}

.project-description p:first-child {
    margin-top: 0;
}

.project-description .project-arrow {
    color: var(--theme-color);
}

/* Le due colonne originali (dettagli e griglia) */
.viewer-columns {
    display: flex;
    gap: 40px;
    width: 100%;
}

/* --- STILI PANNELLO DETTAGLI (SINISTRA) --- */
.details-panel {
    flex: 0 0 250px;
    /* Larghezza fissa a sinistra */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-box {
    height: 350px;
    border-bottom: 1px solid var(--theme-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    position: relative;
    /* Necessario per posizionare le linee */
    overflow: hidden;
    /* Nel caso le linee escano leggermente */
}

.metric-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid #e0e0e0;
    z-index: 1;
    /* Dietro la lettera */
    pointer-events: none;
    /* Impedisce interazioni */
}

.metric-line.ascender {
    top: 21.2%;
}

.metric-line.ex-height {
    top: 26%;
}

.metric-line.cap-height {
    top: 38.3%;
}

.metric-line.baseline {
    top: 75%;
}

.metric-line.descender {
    top: 92%;
}

#big-preview {
    font-size: 250px;
    font-family: 'Fondazione', sans-serif;
    color: var(--theme-color);
    position: relative;
    z-index: 2;
    /* Sopra le linee */
    /* Applica la font da testare */
}

.info-box p {
    margin: 8px 0;
    font-size: 20px;
}

.info-box strong {
    display: inline-block;
    width: 190px;
    /* Aumentato di altri 30px come richiesto */
    color: #555;
    font-family: 'FFUnitRounded', sans-serif;
    font-weight: normal;
}

/* --- STILI GRIGLIA CARATTERI (DESTRA) --- */
.grid-panel {
    flex: 1;
    /* Prende tutto lo spazio rimanente */
}

.grid-panel h3 {
    font-size: 20px;
    margin-bottom: 15px;
    /* border-bottom: 1px solid #e0e0e0; */
    padding-bottom: 5px;
    font-family: 'FFUnitRounded', sans-serif;
    font-weight: normal;
}

.glyph-grid {
    display: grid;
    /* Crea colonne quadrate da circa 45px che si adattano allo schermo */
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    border-top: 1px solid #e0e0e0;
    border-left: 1px solid #e0e0e0;
}

.glyph-box {
    aspect-ratio: 1 / 1;
    /* Rende le celle perfettamente quadrate */
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    font-size: 20px;
    font-family: 'Fondazione', sans-serif;
    /* Applica la font da testare */
    background-color: #EEEEEE;
    color: #000000;
    transition: background 0.1s ease;
    user-select: none;
    /* Impedisce la selezione del testo trascinando il mouse */
}

/* Effetto al passaggio del mouse */
.glyph-box:hover {
    background-color: #EEEEEE;
    color: var(--theme-color);
}

/* Stile quando la cella viene cliccata/selezionata */
.glyph-box.selected {
    background-color: var(--theme-color);
    color: #ffffff;
}

/* --- STILI BOX TESTO DI PROVA --- */
.type-tester {
    font-family: 'Fondazione', sans-serif;
    font-size: 60px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    background-color: #EEEEEE;
    color: #000000;
    min-height: 100px;
    outline: none;
    transition: border-color 0.2s ease;
    word-break: break-word;
}

.type-tester:focus {
    border-color: var(--theme-color);
}

.testo-prova-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
    margin-bottom: 15px;
}

.testo-prova-header h3 {
    margin: 0;
    padding: 0;
    border: none;
}

input[type=range] {
    -webkit-appearance: none;
    width: 200px;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 1px;
    cursor: pointer;
    background: #cccccc;
    transition: background 0.2s;
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 1px;
    cursor: pointer;
    background: #cccccc;
    transition: background 0.2s;
}

input[type=range]:hover::-webkit-slider-runnable-track,
input[type=range]:focus::-webkit-slider-runnable-track,
input[type=range]:active::-webkit-slider-runnable-track {
    background: var(--theme-color);
}

input[type=range]:hover::-moz-range-track,
input[type=range]:focus::-moz-range-track,
input[type=range]:active::-moz-range-track {
    background: var(--theme-color);
}

input[type=range]::-webkit-slider-thumb {
    height: 15px;
    width: 15px;
    border-radius: 50%;
    background: #cccccc;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
    transition: background 0.2s;
}

input[type=range]::-moz-range-thumb {
    height: 15px;
    width: 15px;
    border-radius: 50%;
    background: #cccccc;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

input[type=range]:hover::-webkit-slider-thumb,
input[type=range]:focus::-webkit-slider-thumb,
input[type=range]:active::-webkit-slider-thumb {
    background: var(--theme-color);
}

input[type=range]:hover::-moz-range-thumb,
input[type=range]:focus::-moz-range-thumb,
input[type=range]:active::-moz-range-thumb {
    background: var(--theme-color);
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 900px) {

    /* --- Adattamento Header per mobile --- */
    .top-red-line-container {
        width: calc(100% - 20px);
    }

    .red-box {
        font-size: 13px;
        height: 38px;
        display: flex;
        align-items: center;
        box-sizing: border-box;
    }

    .toggle-box {
        width: 46px;
        height: 38px;
        padding: 8px 4px;
    }

    #audio-toggle-btn {
        width: 38px;
    }

    #audio-toggle-btn svg {
        width: 24px;
        height: 24px;
    }

    .portfolio-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding-right: 0;
        margin-bottom: 30px;
        position: static;
        height: auto;
        overflow-y: visible;
    }

    .viewer-container,
    .viewer-columns {
        flex-direction: column;
    }

    .details-panel {
        flex: none;
        width: 250px;
        align-self: flex-start;
        /* Evita di allungarsi fino al margine destro */
    }

    .grid-panel {
        margin-left: 40;
        /* Mantieni il margine sinistro (gap) */
        margin-right: -0px;
        /* Annulla il padding del body per agganciarsi al margine destro dello schermo */
        /* align-self: stretch (default) fa agganciare il lato destro al margine della pagina */
    }

    #fullscreen-back-btn {
        top: 20px;
        left: 20px;
        transform: none;
        /* Rimuove l'allineamento verticale centrato */
        font-size: 50px;
        /* Riduce leggermente la grandezza della freccia su schermi piccoli */
    }
}

/* --- FULLSCREEN OVERLAY --- */
#fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #EEEEEE;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#fullscreen-back-btn {
    position: absolute;
    top: 50%;
    left: 40px;
    transform: translateY(-50%);
    font-size: 80px;
    font-family: 'Fondazione', sans-serif;
    color: var(--theme-color);
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, color 0.2s ease;
}

#fullscreen-back-btn:hover {
    transform: translateY(-50%) scale(1.1);
}

#fullscreen-content-container {
    width: 80%;
    height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#fullscreen-content-container img,
#fullscreen-content-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    outline: none;
}

/* --- ORBITA (FLOATING ASSETS) --- */
#orbit-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 50;
    /* Spostato in primo piano (sotto l'header che è 100) */
    pointer-events: none;
    /* Il contenitore non blocca i click */
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#orbit-container.hidden {
    opacity: 0;
}

.orbit-item {
    position: absolute;
    pointer-events: auto;
    /* Modificato per permettere il grab */
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
    will-change: transform;
    opacity: 0.8;
    cursor: grab;
    user-select: none;
}

.orbit-item:active {
    cursor: grabbing;
}

/* Stile speciale per i glifi fluttuanti */
.orbit-glyph {
    font-family: 'Fondazione', sans-serif;
    font-size: 100px;
    color: #b0b0b0;
    /* Grigio chiaro */
    opacity: 0.4;
    user-select: none;
}

/* --- CUSTOM CURSOR --- */
#custom-cursor-base,
#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    font-family: 'FFUnitRounded', sans-serif;
    font-size: 20px;
    z-index: 999999;
    transition: font-size 0.15s ease;
    will-change: transform;
    margin-top: -2px;
    margin-left: -4px;
}

#custom-cursor-base {
    /* Il livello base usa la differenza matematica per tagliare i colori a metà */
    color: #00CCEE;
    mix-blend-mode: difference;
}

#custom-cursor {
    /* Il livello superiore spinge la brillantezza per ripristinare il rosso/azzurro esatto! */
    color: var(--theme-color);
    mix-blend-mode: lighten;
}

body.theme-cyan #custom-cursor-base {
    color: #C16B1B;
}

/* Griglia Immagini 2 Colonne */
.image-grid-2 {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

.image-grid-2 img {
    width: calc(50% - 7.5px);
    border: 1px solid #e0e0e0;
}

@media (max-width: 900px) {
    .image-grid-2 img {
        width: 100%;
    }
}

/* Postcard Flip Effect */
/* --- COMUNICAZIONE IMAGES --- */
.comunicazione-images {
    position: relative;
    width: 50%;
    margin-top: 15px;
}

.comunicazione-images img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    opacity: 0;
    transition: opacity 0.6s ease;
    cursor: pointer;
    border: 1px solid #e0e0e0;
}

.comunicazione-images img.first-image {
    position: relative;
    /* Dà l'altezza al contenitore */
}

.comunicazione-images img.active {
    opacity: 1;
    z-index: 2;
}

.postcards-container {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.postcards-container .postcard {
    width: calc(40% - 7.5px);
    margin-top: 0;
}

.postcard {
    perspective: 1000px;
    width: 100%;
    margin-top: 15px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.postcard:hover {
    transform: translateY(-4px) scale(1.02);
}

.postcard-inner {
    position: relative;
    width: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

/* --- BOOK FLIP EFFECT --- */
.book-container {
    position: relative;
    width: 90%;
    margin: 15px 0 0 0;
    perspective: 3000px;
    /* Strong perspective for 3D effect */
    border: 1px solid #e0e0e0;
    box-sizing: border-box;
}

.book-page-static {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 0;
}

.book-page-static.left {
    left: 0;
}

.book-page-static.right {
    right: 0;
}

.book-page {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
}

.book-page.turned {
    transform: rotateY(-180deg);
}

.book-page:not(.turned):hover {
    transform: rotateY(-5deg);
}

.book-page.turned:hover {
    transform: rotateY(-175deg);
}

.book-page .front,
.book-page .back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background-color: #EEEEEE;
    /* To avoid transparency issues during flip */
}

.book-page .back {
    transform: rotateY(180deg);
}

.book-page .bg,
.book-page-static .bg {
    width: 100%;
    height: 100%;
    background-size: 200% 100%;
    background-repeat: no-repeat;
}

.book-page .bg.right-half,
.book-page-static .bg.right-half {
    background-position: right center;
}

.book-page .bg.left-half,
.book-page-static .bg.left-half {
    background-position: left center;
}

.postcard.flipped .postcard-inner {
    transform: rotateY(180deg);
}

.postcard-front,
.postcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.postcard-front {
    position: relative;
    /* Determines height */
    z-index: 2;
    transform: rotateY(0deg);
}

.postcard-back {
    transform: rotateY(180deg);
}

.postcard img {
    width: 100%;
    display: block;
    border: 1px solid #e0e0e0;
}

/* --- MAPPA PIEGHEVOLE 3D --- */
.map-interactive-container {
    width: 100%;
    aspect-ratio: 1.414;
    perspective: 3000px;
    margin-top: 15px;
    margin-bottom: 15px;
    cursor: pointer;
}

.map-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom left;
}

.map-interactive-container.closed .map-wrapper {
    transform: scale(1.6);
}

.map-col {
    position: absolute;
    top: 0;
    left: 100%;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-col.col-0 {
    left: 0;
    width: 20%;
}

.map-row {
    position: absolute;
    width: 100%;
    height: 50%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-row.top-row {
    top: 0;
    transform-origin: bottom center;
}

.map-row.bottom-row {
    bottom: 0;
}

.map-face,
.map-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 0.5px solid rgba(0, 0, 0, 0.03);
    box-sizing: border-box;
}

.map-face {
    background-image: url('assets/4/tt.jpg');
    background-size: 500% 200%;
    background-repeat: no-repeat;
}

.map-back {
    background-color: #f4f4f4;
    transform: rotateY(180deg);
}

.col-0 .map-face {
    background-position-x: 0%;
}

.col-1 .map-face {
    background-position-x: 25%;
}

.col-2 .map-face {
    background-position-x: 50%;
}

.col-3 .map-face {
    background-position-x: 75%;
}

.col-4 .map-face {
    background-position-x: 100%;
}

.top-row .map-face {
    background-position-y: 0%;
}

.bottom-row .map-face {
    background-position-y: 100%;
}

/* Sequenza di APERTURA (stato senza .closed) */
.map-row.top-row {
    transition-delay: 0s;
}

.map-col.col-1 {
    transition-delay: 0.4s;
}

.map-col.col-2 {
    transition-delay: 0.6s;
}

.map-col.col-3 {
    transition-delay: 0.8s;
}

.map-col.col-4 {
    transition-delay: 1.0s;
}

/* Sequenza di CHIUSURA (stato con .closed) */
.map-interactive-container.closed .col-4 {
    transition-delay: 0s;
}

.map-interactive-container.closed .col-3 {
    transition-delay: 0.2s;
}

.map-interactive-container.closed .col-2 {
    transition-delay: 0.4s;
}

.map-interactive-container.closed .col-1 {
    transition-delay: 0.6s;
}

.map-interactive-container.closed .top-row {
    transition-delay: 1.0s;
}

.map-interactive-container.closed .top-row {
    transform: rotateX(180deg) translateZ(0.1px);
}

.map-interactive-container.closed .col-1 {
    transform: rotateY(180deg) translateZ(0.2px);
}

.map-interactive-container.closed .col-2 {
    transform: rotateY(-180deg) translateZ(-0.2px);
}

.map-interactive-container.closed .col-3 {
    transform: rotateY(180deg) translateZ(0.2px);
}

.map-interactive-container.closed .col-4 {
    transform: rotateY(-180deg) translateZ(-0.2px);
}

/* Hover più evidente */
.map-interactive-container.closed:hover .top-row {
    transform: rotateX(180deg) translateZ(0.1px);
}

.map-interactive-container.closed:hover .col-1 {
    transform: rotateY(155deg);
}

.map-interactive-container.closed:hover .col-2 {
    transform: rotateY(-155deg);
}

.map-interactive-container.closed:hover .col-3 {
    transform: rotateY(155deg);
}

.map-interactive-container.closed:hover .col-4 {
    transform: rotateY(-155deg);
}