/* PixChat Web Client - Mobile-optimized styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #000;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Status Bar */
#status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    font-size: 14px;
}

#status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    background: #666;
    transition: background 0.3s;
}

#status-indicator.connecting {
    background: #f0ad4e;
    animation: pulse 1s infinite;
}

#status-indicator.connected {
    background: #5cb85c;
}

#version-badge {
    position: fixed;
    bottom: 8px;
    right: 8px;
    font-size: 12px;
    color: #fff;
    background: rgba(255, 0, 0, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 9999;
}

#status-indicator.error {
    background: #d9534f;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#status-text {
    flex: 1;
    color: #aaa;
}

#photo-counter {
    color: #fff;
    font-weight: 500;
}

/* Photo Container */
#photo-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #111;
    padding: 8px;
    /* Prevent viewer from zooming/panning - only presenter controls the view */
    touch-action: none;
}

/* Frame that matches master's presentation panel (aspect ratio set by JS) */
#photo-frame {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    background: #000;
    border-radius: 4px;
    /* Container will be sized by flexbox, aspect ratio applied via object-fit on image */
}

#photo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.1s ease-out, opacity 0.25s ease-in-out;
    transform-origin: center center;
    opacity: 1;
    /* Prevent image context menu and dragging */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

#photo.fade-out {
    opacity: 0;
}

#photo.hidden {
    display: none;
}

/* Pointer */
#pointer {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 100, 100, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(255, 100, 100, 0.8);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, left 0.1s, top 0.1s;
    z-index: 50;
}

#pointer.visible {
    opacity: 1;
}

/* Client's own pointer - shows their color when they touch */
/* Larger (90px) so it's visible around the finger */
#client-pointer {
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(100, 200, 100, 0.6); /* Default, overridden by JS */
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(100, 200, 100, 0.8);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 51;
}

#client-pointer.visible {
    opacity: 1;
}

#client-pointer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Other clients' pointers - half size of master pointer */
.other-client-pointer {
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 49;
}

.other-client-pointer.visible {
    opacity: 1;
}

#pointer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Welcome Screen */
#welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    z-index: 200;
}

#welcome-screen.hidden {
    display: none;
}

#welcome-screen h1 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#welcome-screen p {
    color: #888;
    margin-bottom: 24px;
}

#welcome-content {
    margin: 32px 0;
}

#welcome-content .hint {
    font-size: 14px;
    color: #666;
}

#demo-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 16px 48px;
    font-size: 18px;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#demo-button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
}

#demo-button:active {
    transform: scale(0.98);
}

/* Error Screen */
#error-screen,
#ended-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    z-index: 300;
}

#error-screen h2,
#ended-screen h2 {
    color: #d9534f;
    margin-bottom: 16px;
}

#ended-screen h2 {
    color: #5cb85c;
}

#ended-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

#error-screen p,
#ended-screen p {
    color: #888;
    margin-bottom: 24px;
    max-width: 300px;
}

#error-screen button,
#ended-screen button {
    background: #333;
    color: #fff;
    border: none;
    padding: 12px 32px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

#error-screen button:hover,
#ended-screen button:hover {
    background: #444;
}

/* Paused Overlay */
#paused-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

#paused-content {
    text-align: center;
    color: #fff;
}

#paused-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.8;
}

#paused-content h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #f0ad4e;
}

#paused-content p {
    font-size: 16px;
    color: #888;
}

.hidden {
    display: none !important;
}

/* Loading animation removed - photos load fast enough that spinner was more distracting than helpful */

/* Responsive adjustments */
@media (max-width: 480px) {
    #status-bar {
        height: 36px;
        font-size: 12px;
    }

    #welcome-screen h1 {
        font-size: 36px;
    }

    #demo-button {
        padding: 14px 40px;
        font-size: 16px;
    }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    #status-bar {
        padding-top: env(safe-area-inset-top);
        height: calc(40px + env(safe-area-inset-top));
    }
}

/* iOS Safari fixes - prevent flickering during pan/zoom */
.ios-safari #photo {
    transition: opacity 0.25s ease-in-out; /* remove transform transition */
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
