:root {
  /* Colors */
  --orbita-red: #DC2626;
  --orbita-red-dark: #B91C1C;
  --orbita-blue: #1E40AF;
  --orbita-blue-hover: #1D4ED8;
  --orbita-dark-bg: #000000;
  --orbita-light-gray: #9CA3AF;
  --orbita-dark-gray: #374151;
  --orbita-glass-bg: rgba(55, 65, 81, 0.4);
  --orbita-glass-border: rgba(96, 110, 128, 0.5);
  --orbita-glass-hover: rgba(55, 65, 81, 0.7);

  /* Typography */
  --font-family-base: "FKGroteskNeue", "Geist", "Inter", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-mono: "Berkeley Mono", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, monospace;
}

/* Reset e Base Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-family-base); background-color: var(--orbita-dark-bg); color: #ffffff; overflow-x: hidden; min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body.no-scroll { overflow: hidden; }

/* Splash Animation Styles */
#splash-container { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: var(--orbita-dark-bg); display: flex; justify-content: center; align-items: center; z-index: 1000; perspective: 800px; }
#solar-system { position: relative; width: 400px; height: 400px; transform-style: preserve-3d; background: transparent; transition: filter 0.5s ease; }
.gooey-effect { filter: url(#goo); }
#loading-indicator { position: absolute; bottom: 20%; left: 0; width: 100%; text-align: center; color: var(--orbita-light-gray); font-size: 14px; letter-spacing: 2px; text-transform: uppercase; }
.loading-text { display: inline-block; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
.sphere { position: absolute; top: 50%; left: 50%; border-radius: 50%; transform-style: preserve-3d; backface-visibility: hidden; transform-origin: center center; will-change: transform; }
.sphere.red { background: radial-gradient(circle at 30% 30%, var(--orbita-red), var(--orbita-red-dark)); box-shadow: 0 0 20px rgba(220, 38, 38, 0.8); }
.sphere.silver { background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), rgba(200, 200, 200, 0.7)); box-shadow: 0 0 15px rgba(255, 255, 255, 0.6); }
.sphere.large { width: 24px; height: 24px; }
.sphere.medium { width: 18px; height: 18px; }
.sphere.small { width: 12px; height: 12px; }
@keyframes orbit { 0% { transform: translate(-50%, -50%) rotateZ(0) translateX(var(--orbit-distance)) rotateZ(0); } 100% { transform: translate(-50%, -50%) rotateZ(360deg) translateX(var(--orbit-distance)) rotateZ(-360deg); } }
#flash-effect { position: absolute; top: 50%; left: 50%; width: 100px; height: 100px; background: radial-gradient(circle, var(--orbita-red), transparent); border-radius: 50%; opacity: 0; transform: translate(-50%, -50%); pointer-events: none; }
.flash-animation { animation: flash 1s ease-out forwards; }
@keyframes flash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(10); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(20); } }

/* Main Content Layout */
#main-content { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity 0.5s ease-out; }
#main-content.hidden { display: none; }
.fade-in { animation: fadeIn 0.8s ease-out forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Header Styles */
header { text-align: center; margin-bottom: 24px; width: 100%; }
.title-orbita { font-size: 54px; font-weight: 800; color: var(--orbita-red); margin-bottom: 12px; letter-spacing: 3px; text-transform: uppercase; text-shadow: 0 0 15px rgba(220, 38, 38, 0.5); }
.subtitle { font-size: 24px; font-style: italic; color: var(--orbita-light-gray); margin: 0; letter-spacing: 1px; }

/* Model Container */
#model-container { width: 100%; max-width: 700px; height: 600px; margin-bottom: 32px; position: relative; border-radius: 10px; overflow: hidden; background-color: #000; }
model-viewer { width: 100%; height: 100%; background-color: transparent; --poster-color: transparent; }
.loading-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; background-color: rgba(0, 0, 0, 0.7); color: white; }
.loading-spinner { width: 40px; height: 40px; border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: var(--orbita-red); animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Main Controls (Desktop First) --- */
#camera-controls { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 700px; }
.controls-group { display: flex; justify-content: center; gap: 16px; width: 100%; }
.controls-group > * { flex: 1 1 0; } 

.btn { border: 1px solid transparent; border-radius: 12px; font-size: 15px; font-weight: 500; cursor: pointer; transition: all 0.2s ease-out; outline: none; display: inline-flex; align-items: center; justify-content: center; font-family: inherit; padding: 10px 18px; height: 48px; color: #FFFFFF; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); }
.btn-icon { margin-right: 10px; display: inline-flex; align-items: center; }

/* Specific Button Styles */
.btn-change-model { background-color: var(--orbita-blue); }
.btn-change-model:hover { background-color: var(--orbita-blue-hover); }
.btn-reset { background-color: var(--orbita-red); }
.btn-reset:hover { background-color: var(--orbita-red-dark); }
.btn-extra { background-color: var(--orbita-glass-bg); border: 1px solid var(--orbita-glass-border); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.btn-extra:hover { background-color: var(--orbita-glass-hover); border-color: var(--orbita-light-gray); }
#auto-rotate.active { background-color: var(--orbita-red) !important; border-color: var(--orbita-red); box-shadow: 0 0 10px var(--orbita-red); }

.controls-group.secondary-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

/* Dropdown Menu Styles */
.dropdown-container {
    position: relative;
    display: flex;
}
.dropdown-container > .btn {
    width: 100%;
}
.dropdown-menu { position: absolute; bottom: 110%; left: 0; width: 100%; background-color: rgba(45, 55, 72, 0.7); border: 1px solid var(--orbita-glass-border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-radius: 8px; list-style: none; padding: 8px; z-index: 100; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
.dropdown-menu.hidden { display: none; }
.dropdown-menu li { color: #e2e8f0; padding: 10px 12px; border-radius: 4px; cursor: pointer; transition: background-color 0.2s; text-align: center; font-size: 14px; }
.dropdown-menu li:hover { background-color: var(--orbita-red); }


/* Fullscreen Overlay Controls */
#fullscreen-overlay-controls, #fullscreen-overlay-controls.hidden { display: none; }
body.model-fullscreen-active #fullscreen-overlay-controls,
body.ios-fullscreen-active #fullscreen-overlay-controls { 
    position: absolute; 
    top: 16px; 
    left: 0; 
    right: 0; 
    z-index: 100; 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    padding: 0 16px; 
    pointer-events: none; 
}
#fullscreen-left-controls { display: flex; gap: 12px; pointer-events: auto; }
.btn-overlay { background-color: rgba(30, 30, 30, 0.7); color: #FFFFFF; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: all 0.2s ease; padding: 0; }
.btn-overlay:hover { background-color: rgba(0, 0, 0, 0.8); border-color: rgba(255, 255, 255, 0.4); transform: scale(1.05); }
#view-dropdown-fullscreen-container { pointer-events: auto; }
#view-dropdown-fullscreen-container .dropdown-menu { bottom: auto; top: 100%; right: 0; left: auto; transform: none; width: auto; }

/* Fullscreen Mode Styles & iOS Fallback */
body.ios-fullscreen-active {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
body.model-fullscreen-active header, body.model-fullscreen-active #camera-controls, body.model-fullscreen-active #shortcuts-info,
body.ios-fullscreen-active header, body.ios-fullscreen-active #camera-controls, body.ios-fullscreen-active #shortcuts-info { 
    display: none; 
}
body.model-fullscreen-active #main-content,
body.ios-fullscreen-active #main-content { 
    padding: 0; 
    justify-content: stretch; 
    height: 100%;
}
body.model-fullscreen-active #model-container,
body.ios-fullscreen-active #model-container { 
    max-width: none; 
    width: 100%; 
    height: 100%; 
    margin: 0; 
    border-radius: 0; 
}

/* Shortcuts info */
#shortcuts-info { margin-top: 24px; text-align: center; font-size: 12px; color: var(--orbita-light-gray); }
kbd { background-color: var(--orbita-dark-gray); border-radius: 3px; border: 1px solid #4B5563; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); display: inline-block; font-family: var(--font-family-mono); font-size: 11px; line-height: 1; padding: 3px 5px; margin: 0 2px; vertical-align: middle; }

/* Model Error Placeholder */
.model-error { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--orbita-light-gray); text-align: center; flex-direction: column; padding: 32px; background-color: rgba(55, 65, 81, 0.05); border-radius: 12px; border: 1px dashed #374151; }
.model-error h3 { color: var(--orbita-red); margin-bottom: 16px; font-size: 18px; font-weight: 500; }

/* --- START: AR Styles (Default Button) --- */
/* Stili per il pulsante AR rotondo di default */
model-viewer::part(ar-button) {
    border: 1px solid var(--orbita-glass-border);
    background-color: var(--orbita-glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    bottom: 16px;
    right: 16px;
    transition: transform 0.2s, background-color 0.2s;
}

model-viewer::part(ar-button):hover {
    background-color: var(--orbita-glass-hover);
}

model-viewer::part(ar-button):active {
    transform: scale(0.95);
}

/* Stili per il prompt AR */
#ar-prompt {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 10;
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: #fff;
    background-color: rgba(0,0,0,0.5);
    padding: 16px;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    animation: ar-prompt-fade-in 0.5s ease-out;
    max-width: 80%;
}
@keyframes ar-prompt-fade-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Show prompt only when AR session has started and is initializing */
model-viewer[ar-status="session-started"] > #ar-prompt {
    display: flex;
}
#ar-prompt .ar-prompt-icon {
    animation: ar-prompt-elongate 2s infinite ease-in-out alternate;
}
#ar-prompt .ar-prompt-icon svg {
    animation: ar-prompt-circle 4s linear infinite;
}
@keyframes ar-prompt-elongate {
    from { transform: translateX(20px); }
    to   { transform: translateX(-20px); }
}
@keyframes ar-prompt-circle {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
#ar-prompt p {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
/* --- END: AR Styles --- */


/* --- Gallery & Lightbox (unchanged) --- */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 1100; opacity: 0; transition: opacity 0.3s ease-in-out; display: flex; justify-content: center; align-items: center; }
.overlay:not(.hidden) { opacity: 1; }
.overlay.hidden { display: none; }
.btn-close-overlay { position: fixed; top: 20px; right: 20px; z-index: 1200; background: none; border: none; color: #fff; cursor: pointer; opacity: 0.7; transition: opacity 0.2s, transform 0.2s; }
.btn-close-overlay:hover { opacity: 1; transform: scale(1.1); }
#gallery-grid-container { width: 100%; height: 100%; overflow-y: auto; padding: 80px 5%; }
#gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.gallery-header { grid-column: 1 / -1; color: #FFFFFF; font-size: 1.5rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; padding-bottom: 10px; margin-top: 20px; margin-bottom: 10px; border-bottom: 1px solid var(--orbita-dark-gray); cursor: default; }
.gallery-header:first-child { margin-top: 0; }
.gallery-item { position: relative; cursor: pointer; overflow: hidden; border-radius: 8px; background-color: #1f2937; aspect-ratio: 1 / 1; transition: transform 0.3s ease, box-shadow 0.3s ease; }
.gallery-item:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.4); }
.gallery-item img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.5s ease; }
.gallery-item img.loaded { opacity: 1; }
.gallery-item .play-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50px; height: 50px; background-color: rgba(0,0,0,0.5); border-radius: 50%; display: flex; justify-content: center; align-items: center; pointer-events: none; opacity: 0.8; transition: opacity 0.2s; }
.gallery-item:hover .play-icon { opacity: 1; }
.gallery-loader { grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; height: 100px; }
.gallery-loader::after { content: ''; width: 40px; height: 40px; border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: var(--orbita-red); animation: spin 1s linear infinite; }
#lightbox-overlay { z-index: 1200; }
#lightbox-content-wrapper { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; padding: 40px; transition: padding 0.3s ease; }
#lightbox-content {}
#lightbox-content img, #lightbox-content video { display: block; max-width: calc(100vw - 80px); max-height: calc(100vh - 80px); object-fit: contain; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); transition: max-width 0.3s ease, max-height 0.3s ease; }
.btn-nav-overlay { position: fixed; top: 50%; transform: translateY(-50%); z-index: 1250; background: rgba(0,0,0,0.2); border: none; color: #fff; cursor: pointer; opacity: 0.6; transition: opacity 0.2s, background-color 0.2s; border-radius: 50%; width: 50px; height: 50px; align-items: center; justify-content: center; }
.btn-close-overlay, .btn-nav-overlay { display: none; }
#gallery-overlay:not(.hidden) .btn-close-overlay, #lightbox-overlay:not(.hidden) .btn-close-overlay, #lightbox-overlay:not(.hidden) .btn-nav-overlay { display: flex; }
.btn-nav-overlay:hover { opacity: 1; background: rgba(0,0,0,0.4); }
#lightbox-prev-btn { left: 20px; }
#lightbox-next-btn { right: 20px; }

/* --- Responsive Design (Mobile) --- */
@media (max-width: 768px) {
    .controls-group > * { flex: revert !important } 
    .title-orbita { font-size: 36px; }
    .subtitle { font-size: 18px; }
    #model-container { height: 45vh; margin-bottom: 24px; }
    
    #camera-controls { 
        gap: 16px;
        padding: 0 16px;
        max-width: 450px;
        margin-left: auto;
        margin-right: auto;
    }
    .main-actions { flex-direction: column; }
    .utility-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    .btn-utility {
        height: 60px;
        flex-direction: column;
        font-size: 12px;
        padding: 8px;
        gap: 5px;
    }
    .btn-utility .btn-icon { margin-right: 0; }

    #shortcuts-info { display: none; }
    
    model-viewer::part(ar-button) {
        width: 40px;
        height: 40px;
        bottom: 12px;
        right: 12px;
    }

    #ar-prompt { bottom: 16px; }

    #gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .gallery-header { font-size: 1.2rem; }
    #lightbox-content-wrapper { padding: 20px; }
    #lightbox-content img, #lightbox-content video { max-width: calc(100vw - 40px); max-height: calc(100vh - 40px); }
    .btn-nav-overlay { width: 40px; height: 40px; }
    #lightbox-prev-Abtn { left: 10px; }
    #lightbox-next-btn { right: 10px; }
}
@media (max-width: 480px) {
    .title-orbita { font-size: 32px; }
    .subtitle { font-size: 16px; }
    #model-container { height: 40vh; }
    .btn-utility { height: 55px; font-size: 11px; }
    #gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}

/* Accessibility */
.btn:focus-visible, #ar-button:focus-visible { box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.5); outline: none; }
model-viewer::part(default-progress-bar) { background-color: var(--orbita-red); }
@font-face { font-family: 'FKGroteskNeue'; src: url('https://r2cdn.perplexity.ai/fonts/FKGroteskNeue.woff2') format('woff2'); }