:root {
    --primary-color: #d4af37;
    /* Gold/Bronze accent */
    --bg-dark: #241404;
    --bg-card: rgba(255, 255, 255, 0.0);
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --glass-bg: rgba(36, 20, 4, 0.5);
    /* Trasparenza col colore del legno per far vedere il blur sotto */
    --glass-border: #d4af3733;
    --font-serif: 'Vast Shadow', serif;
    --font-accent: "Rye", serif;
    --font-handwritten: "Playwrite AU SA", cursive;
}

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

html {
    scroll-behavior: smooth;
    overscroll-behavior-y: none;
    background-color: #000;
}

/* Language Switcher */
#language-switcher {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 1005;
    font-family: var(--font-accent);
    font-size: 1.1rem;
    color: var(--text-muted);
    letter-spacing: 2px;
}

#language-switcher .lang-btn {
    cursor: pointer;
    transition: all 0.3s ease;
}

#language-switcher .lang-btn:hover {
    color: #fff;
}

#language-switcher .lang-btn.active {
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--glass-border), var(--primary-color), var(--glass-border));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

body {
    background: transparent;
    color: var(--text-main);
    font-family: var(--font-serif);
    line-height: 1.6;
    overflow-x: clip;
    max-width: 100vw;
}

/* Sfondo fisso perfetto per iOS, non salta mai */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    background-image: url('https://www.transparenttextures.com/patterns/dark-wood.png');
    z-index: -10;
    pointer-events: none;
}

.wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Header & Logo */
.header {
    text-align: center;
    padding: 15px 0 0 0;
    animation: fadeInDown 1s ease-out;
}

#logo-image img {
    max-height: 220px;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.3));
    transition: transform 0.3s ease;
}

#logo-image img:hover {
    transform: scale(1.05);
}

#logo-caption {
    font-family: var(--font-accent);
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 700px;
    margin: 10px auto 20px auto;
    padding: 0 20px;
}


/* Top Navigation */
.top-nav {
    display: flex;
    align-items: center;
    height: 70px;
    margin: 10px -10px 10px -10px;
    padding: 0 30px;
    font-family: var(--font-accent);

    position: -webkit-sticky;
    position: sticky;
    top: 0px;
    z-index: 1001;

    /* Look a Targa */
    background-color: #000000;
    background-image: url('https://www.transparenttextures.com/patterns/dark-leather.png');
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    transition: all 0.3s ease;
}

.top-nav-logo {
    position: absolute;
    left: 30px;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1002;
    pointer-events: none;
}

.top-nav-logo img {
    height: 45px;
    width: auto;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.3));
}

/* --- STATO STICKY --- */
.top-nav.is-sticky .top-nav-logo {
    opacity: 1;
}

.top-nav.is-sticky .top-nav-logo img {
    height: 45px;
    filter: none;
}

.top-nav-links {
    display: flex;
    gap: 40px;
    height: 100%;
    align-items: center;
    margin: 0 auto;
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.top-nav-links a {
    text-decoration: none;
    color: var(--primary-color);
    font-size: 1.5rem;
    position: relative;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.top-nav-links a:hover,
.top-nav-links a.active {
    opacity: 1;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
    transform: translateY(-2px);
}

/* Video Section */
.video-container {
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 60px;
    border: 1px solid var(--glass-border);
    background: #000;
}

/* Category Sticky Nav */
.category-nav-wrapper {
    position: -webkit-sticky;
    /* Support for Safari */
    position: sticky;
    top: 69px;
    /* Sta sotto al top nav che è 70px */
    z-index: 1000;
    /* Look a Targa */
    background-color: #000000;
    background-image: url('https://www.transparenttextures.com/patterns/dark-leather.png');
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);

    margin: 10px -10px 40px -10px;
    height: 60px;
    padding: 0;
    transition: all 0.3s ease;
}

.category-nav {
    display: flex;
    align-items: center;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 20px;
    gap: 25px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    position: relative;
    /* Dissolvenza ai lati per eliminare il taglio netto */
    mask-image: linear-gradient(to right, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%);
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.category-nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-family: var(--font-accent);
    font-size: 1.1rem;
    white-space: nowrap;
    position: relative;
    transition: all 0.3s ease;
    padding: 5px 5px 8px 5px;
    /* Più spazio in basso per la linea */
}

.category-nav a:hover {
    color: #fff;
    /* Bianco all'hover, non oro */
}

.category-nav a.active {
    color: var(--primary-color);
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.nav-indicator {
    position: absolute;
    bottom: 12px;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary-color);
    transition: left 0.3s cubic-bezier(0.25, 1, 0.5, 1), width 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
    border-radius: 2px;
    pointer-events: none;
    z-index: 10;
}

/* Menu Container */
#menu-container {
    display: grid;
    gap: 80px;
}

.category-section {
    scroll-margin-top: 100px;
}

.category-header {
    text-align: center;
    margin-bottom: 40px;
}

.category-title {
    font-family: var(--font-accent);
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: normal;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

.category-subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 5px;
    /* Increased letter spacing */
    opacity: 0.7;
    position: relative;
    display: inline-block;
    padding: 0 20px;
}

.category-subtitle::before,
.category-subtitle::after {
    content: '•';
    color: var(--primary-color);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.category-subtitle::before {
    left: 0;
}

.category-subtitle::after {
    right: 0;
}

.menu-items-list {
    display: grid;
    gap: 20px;
}

.menu-item {
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid rgba(224, 224, 224, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.menu-item:hover {
    border-color: var(--glass-border);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-5px) scale(1.01);
}

.item-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 15px;
}

.item-name {
    font-weight: normal;
    font-size: 1.2rem;
    text-transform: uppercase;
    color: var(--text-main);
    letter-spacing: 1px;
}

.item-price {
    font-family: var(--font-serif);
    color: var(--primary-color);
    font-size: 1.2rem;
}

.item-translation {
    font-family: var(--font-handwritten);
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 8px;
    opacity: 0.8;
    text-transform: uppercase;
}

.frozen-tag {
    font-size: 0.7rem;
    color: #ff6b6b;
    margin-left: 8px;
    font-style: italic;
    opacity: 0.9;
}

.frozen-disclaimer {
    margin-top: 15px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: right;
    opacity: 0.8;
}

.sizes-list {
    margin-top: 15px;
    padding-left: 15px;
    display: grid;
    gap: 12px;
}

.size-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    font-size: 1rem;
    /* Slightly larger for readability */
    color: var(--text-main);
    opacity: 0.9;
}

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

.size-dots {
    flex-grow: 1;
    border-bottom: 1px dashed rgba(160, 160, 160, 0.2);
}

.size-price {
    font-family: var(--font-accent);
    color: var(--primary-color);
    font-size: 1.1rem;
}

.footer-info {
    text-align: center;
    padding: 60px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 100px;
}

.menu-item.has-image {
    cursor: pointer;
}

.menu-item.has-image:hover .item-name,
.menu-item.expanded .item-name {
    color: var(--primary-color);
}

.item-image-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, margin-top 0.4s ease-in-out, opacity 0.4s ease-in-out;
    opacity: 0;
    margin-top: 0;
}

.menu-item.expanded .item-image-dropdown {
    max-height: 2000px;
    /* Aumentato per non tagliare le foto grandi su PC */
    margin-top: 15px;
    opacity: 1;
}

.item-image-dropdown img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    display: block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

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

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .wrapper {
        padding: 15px;
    }

    .header {
        padding: 20px 0;
    }

    #logo-image img {
        max-height: 150px;
    }

    .category-title {
        font-size: 2rem;
    }

    .item-name {
        font-size: 0.95rem;
    }

    .top-nav {
        gap: 10px;
        margin: 0 -10px 10px -10px;
        padding: 0 10px;
        height: 60px;
    }

    .top-nav-logo {
        left: -28px;
    }

    .top-nav-logo img {
        height: 35px;
    }

    .top-nav.is-sticky .top-nav-links {
        padding-left: 60px;
    }

    .top-nav-links {
        gap: 12px;
    }

    .top-nav-links a {
        font-size: 0.95rem;
    }

    .category-nav-wrapper {
        margin: 0 -10px 30px -10px;
        padding: 10px 0;
        /* Force sticky to work by ensuring no parent has overflow: hidden if possible, 
           but since wrapper has no overflow, this should be fine. 
           We use a slight top offset to help with mobile browser headers. */
        top: 59px;
    }

    .nav-indicator {
        bottom: 2px;
    }

    .menu-item {
        padding: 15px;
    }

    .video-container iframe {
        height: auto;
        aspect-ratio: 16 / 9;
    }

    .frozen-disclaimer {
        font-size: 0.6rem;
    }
}

/* SPA Pages Layout */
.pages-container {
    position: relative;
    width: 100%;
    min-height: 60vh;
    margin-bottom: 50px;
}

.page {
    display: none;
    width: 100%;
    transform-origin: top center;
    animation-duration: 0.6s;
    animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
    animation-fill-mode: forwards;
}

.page.active {
    display: block;
}

.page.zoom-fade {
    animation-name: zoomFade;
}

@keyframes zoomFade {
    from {
        transform: translateY(-50px) scale(0.80);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* INFINITE CANVAS GALLERY */
.infinite-viewport {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    /* Nasconde ciò che è fuori dal rettangolo visibile */
    position: relative;
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
    cursor: grab;
    background-color: #0a0a0a;
    /* Sfondo scuro per il canvas */
    touch-action: none;
    /* Disabilita lo scorrimento del browser sul canvas */
}

.infinite-viewport:active {
    cursor: grabbing;
}

.infinite-canvas {
    position: absolute;
    top: 0;
    left: 0;
    will-change: transform;
    display: grid;
    /* La griglia principale conterrà 3x3 Chunk (9 in totale) */
    grid-template-columns: repeat(3, auto);
    grid-template-rows: repeat(3, auto);
    gap: 15px;
    padding: 0;
    /* Padding rimosso per il calcolo preciso del modulo */
}

/* Un Mega-Chunk contiene una griglia di Chunk più piccoli */
.mega-chunk {
    display: grid;
    grid-template-columns: repeat(4, auto);
    /* M_X = 4 */
    grid-template-rows: repeat(4, auto);
    /* M_Y = 4 */
    gap: 15px;
}

/* Ogni blocco è una griglia 4x4 perfetta */
.canvas-chunk {
    display: grid;
    grid-template-columns: repeat(4, 250px);
    grid-auto-rows: 250px;
    gap: 15px;
}

/* Dimensioni asimmetriche */
.span-2x2 {
    grid-column: span 2;
    grid-row: span 2;
}

.span-2x1 {
    grid-column: span 2;
    grid-row: span 1;
}

.span-1x2 {
    grid-column: span 1;
    grid-row: span 2;
}

.span-1x1 {
    grid-column: span 1;
    grid-row: span 1;
}

.canvas-item {
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
    cursor: pointer;
    pointer-events: auto;
}

.canvas-item:hover .gallery-img {
    transform: scale(1.05);
}

.infinite-canvas * {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    .infinite-viewport {
        height: 60vh;
        width: calc(100% + 60px);
        /* 100% del contenitore + i 40px dei padding totali */
        margin-left: -30px;
        /* Bilancia il padding sinistro di 20px */
        border-radius: 10;
        max-width: 100vw;
        /* Sicurezza per evitare scroll orizzontali del body */
    }

    .infinite-canvas {
        gap: 10px;
    }

    .mega-chunk {
        gap: 10px;
    }

    .canvas-chunk {
        grid-template-columns: repeat(4, 150px);
        grid-auto-rows: 150px;
        gap: 10px;
    }
}

/* LIGHTBOX */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

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

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.lightbox-close:hover {
    color: var(--primary-color);
}