/* Card-based UI Styles */

/* Grid Background - Only visible when cards are shown */
.grid-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 999; /* Behind all cards (which start at 1001) */
    background-image: 
        /* Straight latitude lines in the middle */
        repeating-linear-gradient(0deg, 
            transparent 0px, 
            transparent 48px,
            rgba(128, 128, 128, 0.2) 49px, 
            rgba(128, 128, 128, 0.2) 51px,
            transparent 52px,
            transparent 98px,
            rgba(128, 128, 128, 0.28) 99px, 
            rgba(128, 128, 128, 0.28) 101px),
        /* Vertical longitude lines - dashed with subtle glow */
        repeating-linear-gradient(90deg, 
            transparent 0px, 
            transparent 28px,
            rgba(128, 128, 128, 0.35) 29px, 
            rgba(128, 128, 128, 0.35) 31px,
            transparent 32px,
            transparent 58px,
            rgba(128, 128, 128, 0.25) 59px, 
            rgba(128, 128, 128, 0.25) 61px);
    z-index: 1; /* Behind all capture UI elements */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.grid-background.visible {
    opacity: 1;
    visibility: visible;
}
#start-screen .logo-glow {
    border-radius: 10px;
    box-shadow: 0 0 15px 5px rgba(135, 135, 135, 0.7);
}
/* Base Card Styles - Stacked Deck System */
.ui-card {
    position: fixed;
    width: calc(100% - 20px);
    max-width: 400px;
    /* Position above toolbar (70px toolbar + 30px gap) - for non home cards */
    bottom: 20px; 
    top: max(20px, env(safe-area-inset-top, 20px)); /* Respect safe area for status bar/Dynamic Island */
    background: rgba(255, 255, 255, 0.15);  /* Increased from 0.1 for better contrast */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 35px;
    border: 1px solid rgba(255, 255, 255, 0.25);  /* Increased from 0.2 */
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Contain scrolling content */
    
    /* Center horizontally */
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    
    /* Stacked deck transitions */
    opacity: 0;
    pointer-events: none;
    transition: all 200ms cubic-bezier(.2,.8,.2,1);
    filter: blur(10px);
    z-index: 1001; /* Above grid background */
}

/* Active card state */
.ui-card.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
    filter: blur(0);
    z-index: 1002; /* Active card above background */
}

/* Background card state (when another card is shown on top) */
.ui-card.background {
    opacity: 0.6;
    transform: translateX(-50%) scale(0.92);
    filter: blur(3px) saturate(0.5);
    z-index: 1001; /* Below active card */
}

/* Lifting animation for incoming cards */
@keyframes liftIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.ui-card.lifting-in {
    animation: liftIn 250ms cubic-bezier(.2,.8,.2,1) forwards;
}

/* Pressing down animation for outgoing cards */
@keyframes pressDown {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(15px) scale(0.98);
    }
}

.ui-card.pressing-down {
    animation: pressDown 300ms cubic-bezier(.4,0,.2,1) forwards;
}

/* Close button for all cards */
.card-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 10;
}

.card-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

/* Info Card Flip Container */
.info-card-flip-container {
    perspective: 1000px;
    width: 100%;
    height: 100%;
}

.info-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.info-card-inner:not(.flipped) .card-face.card-front {
    pointer-events: auto;
}

.info-card-inner.flipped .card-face.card-back {
    pointer-events: auto;
    /* Make back opaque to prevent touch interference */
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: inherit;
}

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

/* Hide buttons during flip animation to prevent flash on mobile */
.info-card-inner.flipping .card-close-btn,
.info-card-inner.flipping .card-back-btn {
    opacity: 0;
    transition: opacity 0.1s;
}

/* Ensure buttons are visible after flip completes */
.info-card-inner:not(.flipping) .card-close-btn,
.info-card-inner:not(.flipping) .card-back-btn {
    opacity: 1;
    transition: opacity 0.3s 0.3s;
}

/* Card-specific adjustments can go here if needed */

/* Settings Menu Styles */
.settings-menu-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.settings-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.settings-menu-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
}

.settings-menu-item:active {
    transform: scale(0.98) translateX(5px);
}

/* Bottom Toolbar */
.custom-toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 20px);
    max-width: 400px;
    height: 70px;
    background: rgba(255, 255, 255, 0.15);  /* Increased from 0.1 for better contrast */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 35px;
    border: 1px solid rgba(255, 255, 255, 0.25);  /* Increased from 0.2 */
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1003;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.custom-toolbar.visible {
    opacity: 1;
    visibility: visible;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 5px;
}

.nav-btn:hover {
    color: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
}

.nav-btn.active {
    color: #4CAF50;
}

.nav-btn svg {
    width: 28px;
    height: 28px;
    margin-bottom: 4px;
}

.nav-btn span {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.camera-button {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #820000 0%, #8C1515 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px 5px rgba(52, 152, 219, 0.7);
}

.camera-button:hover {
    transform: translateX(-50%) scale(1.05);
}

.camera-button svg {
    width: 24px !important;
    height: 24px !important;
    color: white;
}

/* Settings Gear Button for Capture View */
.settings-gear-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.settings-gear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.settings-gear-btn svg {
    width: 20px;
    height: 20px;
}

/* Menu items for info card */
.menu-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 18px 20px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.menu-item.danger:hover {
    background: rgba(255, 100, 100, 0.2);
    border-color: rgba(255, 100, 100, 0.4);
}

/* Card content containers */
.card-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.card-title {
    color: white;
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);  /* Added for better readability */
}

/* Scrollbar styling */
.card-content::-webkit-scrollbar {
    width: 6px;
}

.card-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.card-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Photosphere list items */
.photosphere-item {
    margin-bottom: 15px;
    position: relative;
}

.equirectangular-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.equirectangular-preview {
    width: calc(100% - 16px);
    height: 140px;
    margin: 8px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.capture-date {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
    margin-left: 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Action buttons for camera roll */
.action-buttons {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.action-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Glass effect fallback */
@supports not (backdrop-filter: blur(25px)) {
    .ui-card,
    .custom-toolbar {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .menu-item {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* Dialog card specific - auto height based on content */
.ui-card.dialog-card {
    position: fixed !important;
    top: 50% !important;
    bottom: auto !important;
    left: 50% !important;
    right: auto !important;
    min-height: auto !important;
    height: auto !important;
    max-height: calc(100vh - 100px) !important;
    overflow: visible !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
}

.ui-card.dialog-card.visible {
    transform: translate(-50%, -50%) !important;
}

/* Dialog animations handled via JavaScript for better control */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ui-card {
        transition: opacity 150ms ease-in-out;
        animation: none !important;
    }
    
    .ui-card.visible {
        transform: translate(-50%, -50%) scale(1);
        filter: none;
    }
    
    .ui-card.background {
        transform: translate(-50%, -50%) scale(0.95);
        filter: none;
        opacity: 0.7;
    }
    
    .ui-card.lifting-in,
    .ui-card.pressing-down {
        animation: none;
    }
    
    .info-card-inner {
        transition: opacity 150ms ease-in-out;
    }
}

/* High contrast mode support for better visibility */
@media (prefers-contrast: high) {
    .ui-card {
        background: rgba(0, 0, 0, 0.95) !important;
        border: 2px solid white !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    .ui-card button {
        border: 2px solid white !important;
        background: black !important;
        color: white !important;
    }
    
    .control-btn {
        border: 2px solid white !important;
        background: black !important;
    }
    
    .settings-menu-item {
        border: 1px solid white;
        margin-bottom: 8px;
    }
    
    .grid-background {
        background: black !important;
        background-image: none !important;
    }
    
    /* Ensure text is high contrast */
    .card-title,
    .card-content {
        color: white !important;
        text-shadow: none !important;
    }
    
    /* Progress indicators */
    #progressPath {
        stroke: white !important;
    }
    
    #captureCheckmark {
        fill: white !important;
    }
}

/* Reduced motion support for users with vestibular disorders */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .ui-card {
        transition: none !important;
    }
    
    .lifting-in,
    .pressing-down {
        animation: none !important;
    }
    
    #progressPath {
        transition: none !important;
    }
    
    .info-card-inner {
        transition: none !important;
    }
    
    /* Disable blur transitions */
    .ui-card.visible,
    .ui-card.background {
        filter: none !important;
        transition: none !important;
    }
}