/* ===================================================
   Black Mirror - Design System
   ===================================================
   
   Design Philosophy:
   - Futuristic, Apple-like polish
   - Calm, confident, device-grade
   - Minimal animations (< 300ms)
   - System font stack
   - Near-black with cool cyan accent
   =================================================== */

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

:root {
    /* Color Palette */
    /* OLED-optimized: true black (#000000) for primary background */
    /* True black means pixels are OFF on OLED, saving power and providing perfect contrast */
    --bg-primary: #000000;
    --bg-secondary: #141418;
    --bg-panel: #1A1A1F;
    --accent-cyan: #00D9FF;
    --accent-blue: #5E9FFF;
    --accent-violet: #8B7FFF;
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B5;
    --text-tertiary: #6E6E73;
    --success: #00FF88;
    --error: #FF5C5C;
    --error-muted: #8B3A3A;
    
    /* Typography */
    --font-system: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 40px;
    --spacing-2xl: 64px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* ===================================================
   Base Styles
   =================================================== */

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

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-system);
    background: var(--bg-primary); /* True black (#000000) for OLED optimization */
    color: var(--text-primary);
    font-weight: var(--font-weight-regular);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* No texture overlay - pure black for OLED power savings */
}

/* ===================================================
   Typography
   =================================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

h1 {
    font-size: 32px;
    font-weight: var(--font-weight-semibold);
}

h2 {
    font-size: 24px;
}

h3 {
    font-size: 20px;
}

p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===================================================
   Buttons
   =================================================== */

button {
    font-family: var(--font-system);
    font-size: 15px;
    font-weight: var(--font-weight-medium);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

button:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px) scale(1.02);
    transition: all var(--transition-fast) cubic-bezier(0.4, 0, 0.2, 1);
}

button:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    transition: all 100ms cubic-bezier(0.4, 0, 0.2, 1);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border-color: var(--accent-cyan);
    font-weight: var(--font-weight-semibold);
}

.btn-primary:hover:not(:disabled) {
    background: #00C4E6;
    border-color: #00C4E6;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--accent-blue);
    border-color: rgba(94, 159, 255, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(94, 159, 255, 0.1);
    border-color: var(--accent-blue);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border-color: rgba(255, 92, 92, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(255, 92, 92, 0.1);
    border-color: var(--error);
}

.btn-warning {
    background: transparent;
    color: #FFA500;
    border-color: rgba(255, 165, 0, 0.3);
}

.btn-warning:hover:not(:disabled) {
    background: rgba(255, 165, 0, 0.1);
    border-color: #FFA500;
}

.btn-success {
    background: transparent;
    color: var(--success);
    border-color: rgba(0, 255, 136, 0.3);
}

.btn-success:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--success);
}

/* ===================================================
   Inputs
   =================================================== */

input[type="text"],
input[type="file"] {
    font-family: var(--font-system);
    font-size: 15px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    width: 100%;
    transition: all var(--transition-fast);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
    transform: scale(1.01);
    transition: all var(--transition-fast) cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="text"]::placeholder {
    color: var(--text-tertiary);
}

input[type="file"] {
    padding: 8px;
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

/* ===================================================
   Panels & Surfaces
   =================================================== */

.panel {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    backdrop-filter: blur(10px);
}

.panel-glow {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ===================================================
   Status Messages
   =================================================== */

.status {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: var(--font-weight-medium);
    text-align: center;
    transition: all var(--transition-base);
    border: 1px solid transparent;
}

.status.success {
    background: rgba(0, 255, 136, 0.1);
    color: var(--success);
    border-color: rgba(0, 255, 136, 0.2);
}

.status.error {
    background: rgba(255, 92, 92, 0.1);
    color: var(--error);
    border-color: rgba(255, 92, 92, 0.2);
}

.status.info {
    background: rgba(0, 217, 255, 0.1);
    color: var(--accent-cyan);
    border-color: rgba(0, 217, 255, 0.2);
}

/* ===================================================
   Animations
   =================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes scanLine {
    0% {
        transform: translateY(-100%);
        opacity: 0;
        /* Ease in - starts slow */
    }
    20% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translateY(100%);
        opacity: 0;
        /* Ease out - ends slow */
    }
}

@keyframes breatheOpacity {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.animate-breathe {
    animation: breatheOpacity 4s ease-in-out infinite;
}

@keyframes radialPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
        /* Spring-like ease in */
    }
    50% {
        transform: scale(1.05);
        opacity: 0.4;
    }
    100% {
        transform: scale(1.1);
        opacity: 0;
        /* Spring-like ease out */
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-base) ease-out;
}

.animate-scale-in {
    animation: scaleIn var(--transition-base) ease-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ===================================================
   Navigation
   =================================================== */

.nav {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.nav a {
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 14px;
    margin: 0 var(--spacing-md);
    transition: color var(--transition-fast);
    font-weight: var(--font-weight-medium);
}

.nav a:hover {
    color: var(--accent-cyan);
}

/* ===================================================
   Utility Classes
   =================================================== */

.text-center {
    text-align: center;
}

.text-secondary {
    color: var(--text-secondary);
}

.text-tertiary {
    color: var(--text-tertiary);
}

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.hidden {
    display: none;
}

/* ===================================================
   Recognition Page Specific
   =================================================== */

.recognition-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    position: relative;
    gap: var(--spacing-xl);
}

/* Wrapper for camera and result panel (same position) */
.camera-result-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    aspect-ratio: 4 / 3;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: opacity 200ms ease-out, filter 250ms cubic-bezier(0.4, 0, 0.2, 1);
    /* GPU acceleration for smooth transitions */
    transform: translateZ(0);
    backface-visibility: hidden;
}

.video-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius-lg);
    padding: 2px;
    background: linear-gradient(135deg, 
        rgba(0, 217, 255, 0.1) 0%, 
        rgba(139, 127, 255, 0.1) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, 
                  linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.video-container.scanning::before {
    opacity: 1;
}

/* Pulse animation synchronized with capture cadence (500ms) */
.video-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    border: 2px solid var(--accent-cyan);
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease-out;
}

.video-container.pulse-active::after {
    opacity: 0.15;
    animation: capturePulse 200ms ease-out;
}

@keyframes capturePulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    50% {
        opacity: 0.15;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* Breath animation before recognition result (1s) */
.video-container.breath-animation {
    animation: breathScan 1s ease-in-out;
}

.video-container.breath-animation::before {
    opacity: 1;
    animation: breathGlow 1s ease-in-out;
}

@keyframes breathScan {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    25% {
        transform: scale(0.98);
        filter: brightness(0.95);
    }
    50% {
        transform: scale(1.02);
        filter: brightness(1.1);
    }
    75% {
        transform: scale(0.99);
        filter: brightness(0.98);
    }
}

@keyframes breathGlow {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.8;
    }
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}

.scan-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 2px solid var(--accent-cyan);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.scan-indicator.active {
    opacity: 0.6;
    animation: radialPulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to bottom, 
        transparent, 
        var(--accent-cyan), 
        transparent);
    opacity: 0;
    pointer-events: none;
}

.scan-line.active {
    opacity: 1;
    animation: scanLine 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.result {
    text-align: center;
    opacity: 0;
    transform: scale(0.95);
    transition: all var(--transition-base);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.result.visible {
    opacity: 1;
    transform: scale(1);
}

.result-name {
    font-size: 48px;
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.02em;
    line-height: 1.2;
    /* Decisive animation - will be set inline for precise control */
    opacity: 0;
    transform: scale(0.98);
}

.result-name.granted {
    color: var(--success);
}

.result-name.unknown {
    color: var(--text-secondary);
}

.result-name.denied {
    color: var(--text-secondary);
}

.result-name.error {
    color: var(--error);
    font-size: 24px;
    font-weight: var(--font-weight-medium);
}

.result-details {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: var(--spacing-sm);
    font-weight: var(--font-weight-regular);
    line-height: 1.6;
    opacity: 0.7;
}

/* Result panel (replaces camera when recognized) */
.result-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    text-align: center;
    opacity: 0;
    transform: scale(0.98) translateZ(0);
    transition: opacity 200ms ease-out, transform 200ms ease-out;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2;
    /* GPU acceleration */
    backface-visibility: hidden;
    will-change: opacity, transform;
}

.result-panel.visible {
    opacity: 1;
    transform: scale(1) translateZ(0);
    pointer-events: auto;
    /* Remove will-change after animation completes */
}

.greeting-line {
    font-size: 24px;
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-sm);
    line-height: 1.4;
}

.name-line {
    font-size: 56px;
    color: var(--success);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-sm);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.profile-line {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-md);
    line-height: 1.4;
    opacity: 0.8;
}

.verified-line {
    font-size: 14px;
    color: var(--text-tertiary);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-lg);
    opacity: 0.7;
}

.verified-line .distance {
    font-size: 11px;
    margin-left: var(--spacing-sm);
    opacity: 0.5;
}

.message-lines {
    margin-top: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    align-items: center;
}

.message-line {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: var(--font-weight-regular);
    line-height: 1.5;
}

/* Auth code section */
.auth-code-section {
    display: none;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    text-align: center;
}

.auth-code-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.auth-code-display {
    font-size: 72px;
    color: var(--accent-cyan);
    font-weight: var(--font-weight-semibold);
    margin: var(--spacing-md) 0;
    letter-spacing: 0.4em;
    line-height: 1;
}

.auth-code-info {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

.auth-timer {
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
}

.auth-code-url {
    margin-top: var(--spacing-xs);
    opacity: 0.7;
}

.monospace {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Source Code Pro', monospace;
}

/* Camera visibility states */
.video-container.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease-out;
}

.video-container.visible {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 200ms ease-out;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: var(--spacing-sm);
    background: var(--text-tertiary);
}

.status-indicator.granted {
    background: var(--success);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.6);
}

.status-indicator.denied {
    background: var(--text-tertiary);
}

.status-indicator.unknown {
    background: var(--text-tertiary);
    opacity: 0.6;
}

/* ===================================================
   Neural Breath Idle Animation
   =================================================== */

.neural-breath-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease-out;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
}

/* Processing overlay mode - dark overlay on camera */
.neural-breath-container.processing {
    background: rgba(11, 11, 14, 0.85);
    backdrop-filter: blur(2px);
}

/* Idle mode - full replacement */
.neural-breath-container.idle {
    background: var(--bg-primary);
}

.neural-breath-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.neural-network-svg {
    width: 85%;
    height: 85%;
    max-width: 480px;
    max-height: 360px;
    overflow: visible;
}

#neuralRotatingGroup {
    transform-origin: 200px 150px;
    animation: neuralOscillate 24s ease-in-out infinite;
    will-change: transform;
}

.neural-node-group {
    /* PERFORMANCE: GPU acceleration hints */
    will-change: transform;
    transform: translateZ(0); /* Force GPU layer creation */
    contain: layout style paint; /* Isolate rendering */
}

.neural-node {
    fill: var(--accent-cyan);
    opacity: 0.5;
    filter: drop-shadow(0 0 2px rgba(0, 217, 255, 0.3));
    animation: neuralBreathe 8s ease-in-out infinite;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                filter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, filter;
    /* Note: transform is on parent .neural-node-group for GPU acceleration */
}

.neural-edge {
    stroke: var(--accent-cyan);
    stroke-width: 0.5;
    fill: none;
    opacity: 0.5;
    animation: neuralEdgeBreathe 8s ease-in-out infinite;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                stroke-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, stroke-width;
}

.neural-pulse {
    stroke: var(--accent-cyan);
    stroke-width: 2; /* Increased from 1.5 for better visibility */
    fill: none;
    opacity: 0;
}

.neural-pulse.pulse-active {
    animation: neuralPulse 0.5s ease-out;
}

.neural-idle-text {
    margin-top: var(--spacing-lg);
    font-size: 14px;
    color: var(--text-tertiary);
    font-weight: var(--font-weight-medium);
    opacity: 0.7;
    text-align: center;
}

.neural-idle-text .hint {
    font-size: 12px;
    margin-top: var(--spacing-xs);
    opacity: 0.5;
}

@keyframes neuralOscillate {
    0% {
        transform: rotate(-5deg) scale(1);
    }
    33% {
        transform: rotate(2deg) scale(1.02);
    }
    66% {
        transform: rotate(5deg) scale(1.03);
    }
    100% {
        transform: rotate(-5deg) scale(1);
    }
}

@keyframes neuralBreathe {
    0%, 100% {
        opacity: 0.45;
        filter: drop-shadow(0 0 2px rgba(0, 217, 255, 0.3));
        transform: scale(1);
    }
    25% {
        opacity: 0.7;
        filter: drop-shadow(0 0 5px rgba(0, 217, 255, 0.6));
        transform: scale(1.08);
    }
    50% {
        opacity: 0.95;
        filter: drop-shadow(0 0 10px rgba(0, 217, 255, 0.9));
        transform: scale(1.18);
    }
    75% {
        opacity: 0.7;
        filter: drop-shadow(0 0 5px rgba(0, 217, 255, 0.6));
        transform: scale(1.08);
    }
}

/* Edge breathing (separate animation for edges) */
.neural-edge {
    animation: neuralEdgeBreathe 8s ease-in-out infinite;
}

@keyframes neuralEdgeBreathe {
    0%, 100% {
        opacity: 0.2; /* Increased from 0.08 for better visibility */
        stroke-width: 0.5;
    }
    25% {
        opacity: 0.35; /* Increased from 0.2 */
        stroke-width: 0.7;
    }
    50% {
        opacity: 0.5; /* Increased from 0.4, still dimmer than pulses (0.6) */
        stroke-width: 1.1;
    }
    75% {
        opacity: 0.35; /* Increased from 0.2 */
        stroke-width: 0.7;
    }
}

@keyframes neuralPulse {
    0% {
        opacity: 0;
        stroke-dashoffset: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        opacity: 0;
        stroke-dashoffset: -100%;
    }
}

/* ===================================================
   Long-Dwell Incremental Reveal Layers
   =================================================== */

/* Dwell layers container */
.dwell-layers {
    position: absolute;
    bottom: var(--spacing-lg);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-md);
    pointer-events: none;
    z-index: 20;
}

/* Individual layer - slides up and fades in */
.dwell-layer {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    pointer-events: auto;
    /* No transition - we use animation instead for physics-based motion */
}

/* Staggered reveal timing for smooth "docking" */
.dwell-layer.layer-1 { transition-delay: 0ms; }
.dwell-layer.layer-2 { transition-delay: 50ms; }
.dwell-layer.layer-3 { transition-delay: 100ms; }
.dwell-layer.layer-4 { transition-delay: 150ms; }

/* ===================================================
   Dwell-Beings: The Oracle Cards
   "They are not UI elements. They are inhabitants."
   =================================================== */

/* Layer 1: Ambient time display - "The Chronometer" */
.ambient-time {
    background: rgba(26, 26, 31, 0.9);
    backdrop-filter: blur(20px);
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
    /* Subtle glow that breathes */
    box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.08),
                0 8px 32px rgba(0, 0, 0, 0.4);
    animation: cardBreathe 7s ease-in-out infinite;
}

.ambient-time::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent,
        rgba(0, 217, 255, 0.3),
        transparent
    );
    opacity: 0.6;
    animation: scanLine 3s ease-in-out infinite;
}

@keyframes scanLine {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.time-display {
    font-size: 56px;
    font-weight: 300;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -2px;
    position: relative;
    font-variant-numeric: tabular-nums;
    /* Subtle breathing glow */
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.1);
    animation: timeGlow 3s ease-in-out infinite;
}

@keyframes timeGlow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(0, 217, 255, 0.1),
                     0 0 40px rgba(0, 217, 255, 0.05);
    }
    50% {
        text-shadow: 0 0 30px rgba(0, 217, 255, 0.15),
                     0 0 60px rgba(0, 217, 255, 0.08);
    }
}

.date-display {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: var(--font-weight-medium);
    opacity: 0.7;
}

/* Layer 2: Weather placeholder - "The Sensor" */
.weather-card {
    background: rgba(26, 26, 31, 0.9);
    backdrop-filter: blur(20px);
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-size: 14px;
    color: var(--text-secondary);
    position: relative;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05),
                0 8px 32px rgba(0, 0, 0, 0.3);
    animation: cardBreathe 7s ease-in-out infinite 0.5s;
}

.weather-icon {
    font-size: 28px;
    opacity: 0.6;
    filter: grayscale(0.3);
    transition: transform 0.3s ease-out;
}

.weather-card:hover .weather-icon {
    transform: scale(1.1);
}

.weather-text {
    flex: 1;
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.5px;
}

/* Layer 3: System status - "The Monitor" */
.status-card {
    background: rgba(26, 26, 31, 0.9);
    backdrop-filter: blur(20px);
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    position: relative;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05),
                0 8px 32px rgba(0, 0, 0, 0.3);
    animation: cardBreathe 7s ease-in-out infinite 1s;
}

.status-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, 
        rgba(0, 217, 255, 0.03) 0%,
        transparent 50%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.status-card:hover::after {
    opacity: 1;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: var(--spacing-xs) 0;
    position: relative;
}

.status-row::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 1px;
    background: rgba(0, 217, 255, 0.3);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-row:hover::before {
    width: 100%;
}

.status-label {
    color: var(--text-tertiary);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
}

.status-value {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease-out;
}

.status-value.online {
    color: var(--accent-cyan);
    position: relative;
}

.status-value.online::after {
    content: '';
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.5; transform: translateY(-50%) scale(1.2); }
}

/* Layer 4: Presence hints - "The Memory" */
.presence-card {
    background: rgba(26, 26, 31, 0.9);
    backdrop-filter: blur(20px);
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05),
                0 8px 32px rgba(0, 0, 0, 0.3);
    animation: cardBreathe 7s ease-in-out infinite 1.5s;
}

.presence-row {
    line-height: 1.6;
    padding: var(--spacing-xs) 0;
    position: relative;
    transition: color 0.2s ease-out;
}

.presence-row:hover {
    color: var(--text-primary);
}

/* Universal breathing animation for all cards */
@keyframes cardBreathe {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.08),
                    0 8px 32px rgba(0, 0, 0, 0.4);
    }
    50% {
        transform: scale(1.002);
        box-shadow: 0 0 0 1px rgba(0, 217, 255, 0.12),
                    0 12px 40px rgba(0, 0, 0, 0.5);
    }
}

/* Enhanced reveal animation with physics */
.dwell-layer.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: cardReveal 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardReveal {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    60% {
        transform: translateY(-2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===================================================
   Broken Glass Privacy Animation
   =================================================== */

/* Privacy protection overlay */
.glass-break-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.glass-break-overlay.active {
    animation: glassShatter 600ms ease-out forwards;
}

@keyframes glassShatter {
    0% {
        opacity: 1;
        background: radial-gradient(circle at center, 
            transparent 0%, 
            rgba(0, 217, 255, 0.1) 50%);
    }
    20% {
        background: 
            /* Crack lines radiating from center */
            linear-gradient(45deg, transparent 48%, rgba(255,255,255,0.8) 50%, transparent 52%),
            linear-gradient(-45deg, transparent 48%, rgba(255,255,255,0.8) 50%, transparent 52%),
            linear-gradient(90deg, transparent 48%, rgba(255,255,255,0.6) 50%, transparent 52%),
            linear-gradient(0deg, transparent 48%, rgba(255,255,255,0.6) 50%, transparent 52%);
    }
    100% {
        opacity: 0;
        transform: scale(1.1);
    }
}

/* Glass shards falling effect */
.glass-shard {
    position: absolute;
    background: linear-gradient(135deg, 
        rgba(255,255,255,0.3) 0%, 
        rgba(0,217,255,0.2) 100%);
    border: 1px solid rgba(255,255,255,0.4);
    animation: shardFall 800ms ease-in forwards;
    pointer-events: none;
}

@keyframes shardFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(180deg);
        opacity: 0;
    }
}

/* ===================================================
   Enrollment Page Specific
   =================================================== */

.enroll-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-xl);
    min-height: 100vh;
}

.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-2xl);
    padding: var(--spacing-lg) 0;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    max-width: 150px;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
    font-size: 16px;
    background: var(--bg-panel);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: var(--text-tertiary);
    transition: all var(--transition-base);
}

.step.active .step-number {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: var(--bg-primary);
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.4);
}

.step.completed .step-number {
    background: var(--success);
    border-color: var(--success);
    color: var(--bg-primary);
}

.step-label {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: var(--font-weight-medium);
    text-align: center;
}

.step.active .step-label {
    color: var(--text-primary);
}

.step-connector {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 var(--spacing-sm);
    margin-top: -20px;
}

.step.completed + .step-connector,
.step-connector.completed {
    background: var(--success);
}

.capture-counter {
    font-size: 18px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: var(--spacing-lg) 0;
    text-align: center;
}

.capture-counter .count {
    color: var(--accent-cyan);
    font-size: 24px;
}

.quality-feedback {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: var(--spacing-sm);
    text-align: center;
    min-height: 20px;
}

.quality-feedback.error {
    color: var(--error);
}

.quality-feedback.success {
    color: var(--success);
}

/* ===================================================
   Users/Admin Page Specific
   =================================================== */

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-xl);
    min-height: 100vh;
}

.section {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    backdrop-filter: blur(10px);
}

.section h2 {
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: var(--font-weight-semibold);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--spacing-md);
}

th {
    text-align: left;
    padding: var(--spacing-md);
    font-weight: var(--font-weight-semibold);
    font-size: 13px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

td {
    padding: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 14px;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.granted {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.badge.denied {
    background: rgba(255, 92, 92, 0.2);
    color: var(--error);
    border: 1px solid rgba(255, 92, 92, 0.3);
}

/* ===================================================
   Debug Panel
   =================================================== */

.debug-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(11, 11, 14, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--spacing-md);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1000;
    font-size: 12px;
}

.debug-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-panel-header h3 {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

.debug-panel-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 12px;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s ease, border-color 0.2s ease;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.debug-panel-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.debug-panel-toggle:active {
    background: rgba(255, 255, 255, 0.2);
}

.debug-panel-toggle .toggle-icon {
    display: inline-block;
    transition: transform 0.2s ease;
    user-select: none;
}

.debug-panel-content {
    transition: opacity 0.2s ease;
}

.debug-panel-content[style*="display: none"] {
    display: none !important;
}

.debug-panel .status {
    margin-top: var(--spacing-sm);
}

.debug-panel .status-item {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 4px 0;
}

.debug-panel button {
    font-size: 11px;
    padding: 6px 12px;
    margin-top: var(--spacing-xs);
}

/* ===================================================
   Debug Menu (Floating)
   =================================================== */

.debug-menu {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 2000;
}

.debug-menu-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    will-change: transform;
}

.debug-menu-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 217, 255, 0.6);
}

.debug-menu-toggle:active {
    transform: scale(0.95);
}

.debug-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1999;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.debug-menu-content {
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.debug-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-menu-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

.debug-menu-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease, color 0.2s ease;
}

.debug-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.debug-menu-items {
    display: grid;
    gap: var(--spacing-md);
}

.debug-menu-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 217, 255, 0.2);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    color: var(--text-primary);
}

.debug-menu-item:hover {
    background: rgba(0, 217, 255, 0.1);
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.2);
}

.debug-menu-item:active {
    transform: translateY(0);
}

.debug-menu-item .menu-item-icon {
    font-size: 24px;
    margin-bottom: var(--spacing-xs);
}

.debug-menu-item .menu-item-label {
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.debug-menu-item .menu-item-desc {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ===================================================
   Responsive
   =================================================== */

@media (max-width: 768px) {
    h1 {
        font-size: 24px;
    }
    
    .result-name {
        font-size: 32px;
    }
    
    .step-indicator {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .step-connector {
        display: none;
    }
}

/* ===================================================
   Cinematic Mode (Optional Feature Flag)
   =================================================== */

.cinematic-mode {
    /* Full-screen, no padding, ultra-minimal */
}

.cinematic-mode .nav {
    display: none;
}

.cinematic-mode h1 {
    display: none;
}
