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

/* Screen reader only content - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Debug Panel Button Styling */
.debug-btn {
    display: block;
    width: 100%;
    margin: 6px 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.debug-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.debug-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.2);
}

/* Special button styles */
.debug-btn.danger {
    background: rgba(140, 21, 21, 0.3);
    border-color: rgba(140, 21, 21, 0.5);
}

.debug-btn.danger:hover {
    background: rgba(140, 21, 21, 0.5);
    border-color: rgba(140, 21, 21, 0.7);
}

.debug-btn.primary {
    background: rgba(140, 21, 21, 0.2);
    border-color: rgba(140, 21, 21, 0.4);
}

.debug-btn.primary:hover {
    background: rgba(140, 21, 21, 0.3);
    border-color: rgba(140, 21, 21, 0.5);
}

/* Toggle button states */
.debug-btn.toggle-on {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
}

.debug-btn.toggle-on:hover {
    background: rgba(76, 175, 80, 0.4);
    border-color: rgba(76, 175, 80, 0.6);
}

.debug-btn.toggle-off {
    background: rgba(255, 152, 0, 0.3);
    border-color: rgba(255, 152, 0, 0.5);
}

.debug-btn.toggle-off:hover {
    background: rgba(255, 152, 0, 0.4);
    border-color: rgba(255, 152, 0, 0.6);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #camera-viewport {
        border: 3px solid white !important;
    }
    
    #alignment-indicator {
        border: 4px solid white !important;
        background: black !important;
    }
    
    #alignment-indicator.approaching {
        background: white !important;
        border-color: white !important;
    }
    
    #alignment-indicator.aligned {
        background: white !important;
        border-color: white !important;
    }
    
    #instructions {
        background: black !important;
        color: white !important;
        border: 2px solid white !important;
    }
    
    #roll-line-static-left,
    #roll-line-static-right,
    #roll-line-moving {
        background: white !important;
    }
    
    .bottom-controls button {
        border: 2px solid white !important;
        background: black !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #alignment-indicator {
        transition: none !important;
    }
    
    #roll-line-moving {
        transition: none !important;
    }
    
    .bottom-controls button {
        transition: none !important;
    }
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    background: #000;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 3D Scene container */
#scene-container {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

/* Camera viewport */
#camera-viewport {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    border: 2px dashed rgb(212, 212, 212);
    overflow: hidden;
    z-index: 20;
    background: transparent;
    pointer-events: none;
    border-radius: 10px;
}

/* Alignment indicator - white circle in center */
#alignment-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid white;
    border-radius: 50%;
    pointer-events: none;
    z-index: 25;
    transition: all 0.3s ease;
    opacity: 0;
}

#alignment-indicator.visible {
    opacity: 1;
}

#alignment-indicator.approaching {
    border-color: orange;
    background: rgba(255, 165, 0, 0.1);
}

#alignment-indicator.aligned {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.3);
    animation: pulseAlign 1s ease-out;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

/* Roll indicator for device alignment - iOS style */
#roll-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 40px;
    pointer-events: none;
    z-index: 24;
}

/* Static reference lines on sides */
#roll-line-static-left,
#roll-line-static-right {
    position: absolute;
    top: 50%;
    width: 15px;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    transform: translateY(-50%);
}

#roll-line-static-left {
    left: 0;
}

#roll-line-static-right {
    right: 0;
}

/* Moving center line */
#roll-line-moving {
    position: absolute;
    top: 50%;
    left: 20px;
    right: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    transform-origin: center;
    transition: transform 0.2s ease-out, background-color 0.3s ease;
}

#roll-line-moving.level {
    background: rgba(76, 175, 80, 1);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

#roll-line-moving.tilted {
    background: rgba(255, 165, 0, 0.8);
}

/* Orange dot overlay for approaching hotspots */
.hotspot-overlay {
    position: absolute;
    width: 40px;
    height: 40px;
    background: orange;
    border-radius: 50%;
    border: 3px solid white;
    pointer-events: none;
    z-index: 24;
    opacity: 0;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.hotspot-overlay.visible {
    opacity: 1;
}

/* Hidden capture elements */
#camera-full {
    position: absolute;
    top: -9999px;
    left: -9999px;
    visibility: hidden;
}

#capture-canvas {
    display: none;
}

/* Bottom controls container */
.bottom-controls {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 300px;
    z-index: 30;
}

/* Side control buttons (gray) */
.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: gray;
    border: 3px solid rgba(255, 255, 255, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 24px;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.control-btn svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

.control-btn:hover {
    transform: scale(1.1);
    background-color: #666;
}

.control-btn:active {
    transform: scale(0.95);
}

.gallery-btn-start-screen {
    position: absolute;
    right: 10px;
    bottom: 10px;
}

.settings-btn-start-screen {
    position: absolute;
    left: 10px;
    bottom: 10px;
}

/* Capture button container */
#capture-btn-container {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: white;
    border: 3px solid rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

/* Progress circle */
#captureProgress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    pointer-events: none;
}

#progressPath {
    transition: stroke-dashoffset 0.3s ease;
}

/* Checkmark SVG */
#captureCheckmark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    fill: orange;
    z-index: 1;
    pointer-events: none;
}

/* Instructions */
#instructions {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 24px;
    text-align: center;
    z-index: 30;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Start screen */
/* #start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
} */

#start-screen h1 {
    font-size: 32px;
    margin-bottom: 0px;
    font-weight: 600;
}

#start-screen .logo {
    margin-bottom: 5px;
}

#start-screen .instructions {
    margin: 30px;
    text-align: center;
    max-width: 350px;
}

#start-screen .step {
    margin: 20px 0;
    font-size: 18px;
    opacity: 0.9;
}

#start-btn {
    margin-top: 40px;
    background: #8C1515;
    color: white;
    border: 3px solid transparent;
    padding: 18px 40px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background-clip: padding-box;
}

/* Animated gradient border */
#start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    margin: -3px;
    border-radius: inherit;
    background: linear-gradient(45deg, #620059, #651C32, #E04F39, #620059);
    background-size: 300% 300%;
    animation: gradient-rotate 3s ease infinite;
}

@keyframes gradient-rotate {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

#start-btn:hover {
    background: #B83A4B;
    transform: scale(1.05);
}

#start-btn:hover::before {
    animation-duration: 1.5s;
}

#start-btn:active {
    background: #820000;
    transform: scale(0.95);
}

/* Start button styled class for reuse */
.start-btn-styled {
    width: 100%;
    margin-top: 10px;
    background: #8C1515;
    color: white;
    border: 3px solid transparent;
    padding: 18px 40px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background-clip: padding-box;
}

/* Animated gradient border */
.start-btn-styled::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    margin: -3px;
    border-radius: inherit;
    background: linear-gradient(45deg, #620059, #651C32, #E04F39, #620059);
    background-size: 300% 300%;
    animation: gradient-rotate 3s ease infinite;
}

.start-btn-styled:hover {
    background: #B83A4B;
    transform: scale(1.05);
}

.start-btn-styled:hover::before {
    animation-duration: 1.5s;
}

.start-btn-styled:active {
    background: #820000;
    transform: scale(0.95);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.stitching-content {
    text-align: center;
    color: white;
    padding: 20px;
    max-width: 90%;
}

.stitching-content h2 {
    font-size: 24px;
    margin-bottom: 20px;
}

.stitching-progress {
    margin: 20px 0;
}

.progress-bar {
    width: 300px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    overflow: hidden;
    margin: 10px auto;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

#stitch-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #8C1515 0%, #C41E3A 50%, #8C1515 100%);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(140, 21, 21, 0.5);
    position: relative;
}

#stitch-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
}

#stitch-status {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
}

#stitch-details {
    text-align: center;
}

#preview-canvas {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

/* Stitching action buttons */
.stitch-action-btn {
    background: #8C1515;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 10px;
}

.stitch-action-btn:hover {
    background: #B83A4B;
    transform: scale(1.05);
}

.stitch-action-btn:active {
    background: #820000;
    transform: scale(0.95);
}

/* Animations */
@keyframes pulseAlign {
    0% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 1;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.3); 
        opacity: 0.8;
    }
    100% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 1;
    }
}

@keyframes stampEffect {
    0% { 
        transform: scale(1) rotate(0deg); 
        opacity: 0.9;
    }
    50% { 
        transform: scale(0.95) rotate(-2deg); 
        opacity: 1;
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        opacity: 0.9;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #camera-viewport {
        width: 70%;
        height: 50%;
    }
    
    .bottom-controls {
        width: 250px;
        bottom: 20px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
    }
    
    .control-btn svg {
        width: 28px;
        height: 28px;
    }
    
    #capture-btn-container {
        width: 55px;
        height: 55px;
    }
    
    #capture-btn {
        width: 55px;
        height: 55px;
    }
    
    #capture-checkmark {
        font-size: 26px;
    }
}