/* 
 * Clean, Organized CSS
 * ---------------------
 * Structure:
 * 1. Reset & Base Styles
 * 2. Layout & Containers
 * 3. Typography
 * 4. UI Components 
 * 5. Controls & Buttons
 * 6. Animations & Transitions
 * 7. Media Queries
 * 8. Utility Classes
 */

/* ============================
   1. RESET & BASE STYLES
   ============================ */
   * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent tap highlight on mobile */
    -webkit-tap-highlight-color: transparent;
}

html {
    /* Creates a non-visible "reset" area to fix iOS sticky hover */
    min-height: 100%;
    cursor: default;
}

body {
    font-family: 'Syne', sans-serif;
    background-color: #000;
    color: #fff;
    overflow: hidden;
    /* Ensures tapping elsewhere removes hover states */
    cursor: default;
}

/* ============================
   2. LAYOUT & CONTAINERS
   ============================ */
.viewer-container {
    position: absolute;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    transition: opacity 2s ease-out;
}

/* Main overlay for UI elements */
.overlay { 
    position: absolute; 
    top: 40px; 
    left: 40px; 
    z-index: 100;
    width: calc(100% - 80px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    /* Prevents the overlay from blocking panorama interactions */
    pointer-events: none;
    /* Visibility handling */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-out, 
                visibility 0.5s ease-out,
                transform 0.5s ease-out;
}

/* Make overlay visible unless hidden */
.overlay:not(.ui-hidden) {
    opacity: 1;
    visibility: visible;
}

/* Controls container positioning */
.controls {
    position: absolute;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    width: auto;
    /* Visibility handling */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-out, 
                visibility 0.5s ease-out,
                transform 0.5s ease-out;
}

/* Make controls visible unless hidden */
.controls:not(.ui-hidden) {
    opacity: 1;
    visibility: visible;
}

/* Layout for rows of buttons */
.controls-view-modes,
.controls-action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
}

/* Container for back button and coordinates */
.nav-container {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto; /* Make sure clicks work */
    transition: opacity 0.5s ease-out, 
                visibility 0.5s ease-out,
                transform 0.5s ease-out;
}

/* Special utility overlays */
#fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index: 9999;
    opacity: 1;
    transition: opacity 2s ease-out;
    pointer-events: none !important;
}

#custom-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index: 9998;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

/* Hide the default PhotoSphere loader */
.psv-loader-container {
    display: none !important;
}

/* ============================
   3. TYPOGRAPHY
   ============================ */
.title {
    font-size: 78px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    transition: opacity 0.2s ease-in-out;
    pointer-events: auto; /* Make the title clickable */
    user-select: none; /* Prevent text selection */
}

.title:hover {
    opacity: 0.7;
}

.coordinates {
    font-size: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
}

.description { 
    font-family: 'Cormorant Garamond', serif; 
    font-size: 18px; 
    font-weight: 400; 
    max-width: 600px; 
    line-height: 1.4; 
    word-wrap: break-word;
    text-align: left;
    color: rgba(255, 255, 255, 0.7);
    /* Visibility handling */
    opacity: 1; 
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    pointer-events: none; /* Don't block clicks */
    user-select: none; /* Prevent text selection */
}

/* ============================
   4. UI COMPONENTS
   ============================ */
/* UI notification for hidden controls */
#ui-hide-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    font-family: 'Cormorant Garamond', serif;
    font-size: 24px;
    font-weight: 400;
    color: white;
    text-align: center;
    /* Text shadow on all sides for better visibility */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                -2px -2px 4px rgba(0, 0, 0, 0.5),
                2px -2px 4px rgba(0, 0, 0, 0.5),
                -2px 2px 4px rgba(0, 0, 0, 0.5);
    opacity: 0;
    animation: fade-in-out 3s ease-in-out;
    pointer-events: none;
}

/* Force PhotoSphere background to black */
.psv-container {
    background: black !important;
}

/* ============================
   5. CONTROLS & BUTTONS
   ============================ */
/* Base style for all control buttons */
.controls-view-modes button,
.controls-action-buttons button {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    
    /* Button sizing */
    flex: 0 1 auto;
    width: auto;
    min-width: 50px;
    padding: 14px 28px;
    
    /* Typography */
    font-size: 1rem;
    font-weight: 600;
    
    /* Display */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    
    /* Effects */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease-in-out;
    will-change: opacity, transform;
}

/* Square action buttons */
.controls-action-buttons button {
    width: 50px;
    padding: 14px;
}

/* Button states */
button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

button.active {
    background: rgba(255, 223, 77, 0.1);
    border: 2px solid rgba(255, 223, 77, 0.3);
    color: white;
}

/* Special states for action buttons */
#btn-cycle,
#btn-hide-ui {
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-cycle svg,
#btn-hide-ui svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.85);
    transition: color 0.3s ease-in-out;
}

#btn-cycle:hover svg,
#btn-hide-ui:hover svg {
    color: white;
}

/* Unique cycle button active state */
#btn-cycle.active {
    background: rgba(135, 209, 86, 0.1); /* Green background */
    border: 2px solid rgba(135, 209, 86, 0.3); /* Green border */
}

#btn-cycle.active svg {
    color: rgba(135, 209, 86, 0.9);
    animation: gentle-rotate 10s linear infinite;
}

/* Unique UI toggle button hover state */
#btn-hide-ui:hover {
    background: rgba(239, 89, 0, 0.1);
    border: 2px solid rgba(239, 89, 0, 0.3);
}

#btn-hide-ui:hover svg {
    color: rgba(239, 89, 0, 1);
}

/* Back button styling */
.back-button {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 14px;
    background: rgba(50, 50, 50, 0.4);
    color: rgba(255, 255, 255, 0.8);
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    text-transform: lowercase;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.3s ease, 
                color 0.3s ease, 
                backdrop-filter 0.5s ease-out;
}

.back-button:hover {
    background: rgba(50, 50, 50, 0.7);
    color: #fff;
}

/* ============================
   6. ANIMATIONS & TRANSITIONS
   ============================ */
/* Define transition for UI elements to improve performance */
.overlay *,
.controls *,
.nav-container * {
    will-change: opacity, transform;
}

/* State class for hiding UI elements */
.ui-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.5s ease-in-out, 
                visibility 0.5s ease-in-out,
                transform 0.5s ease-in-out,
                background-color 0.5s ease-in-out;
}

/* Ensure interactive elements remain clickable */
.overlay .title,
.overlay button,
.overlay .nav-container {
    pointer-events: auto;
}

/* Animation for the cycle button */
@keyframes gentle-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Animation for notification fade-in-out */
@keyframes fade-in-out {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* ============================
   7. MEDIA QUERIES
   ============================ */
/* Responsive layout for smaller screens */
@media (max-width: 810px) {
    /* Typography adjustments */
    .title { 
        font-size: 40px; 
        line-height: 1.05; 
    }

    .coordinates { 
        font-size: 14px; 
    }

    .description { 
        font-size: 16px; 
    }

    /* Controls positioning */
    .controls {
        right: 20px;
        bottom: 20px;
        width: auto;
        max-width: none;
        align-items: flex-end;
    }

    /* Action buttons layout */
    .controls-action-buttons {
        justify-content: flex-end;
    }

    .controls-action-buttons button {
        width: 50px;
        min-width: 50px;
        max-width: 50px;
        padding: 14px;
        aspect-ratio: 1 / 1;
    }

    /* View mode buttons layout */
    .controls-view-modes {
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    .controls-view-modes button {
        flex-grow: 1;
        max-width: calc(50% - 8px);
        padding: 10px;
        font-size: 12px;
    }
}

/* Special handling for touch devices */
@media (hover: none) {
    /* Override hover effects for touch devices */
    .title:hover {
        opacity: 1 !important;
    }
}