/* style-misc.css — avatar picker + iPhone/iOS compatibility fixes. Split VERBATIM out of
   style.css (2026-06-27), loaded in original order; cascade byte-identical. */

/* ============================================
   Avatar Picker - Visual Image Selection
   ============================================ */
.avatar-picker-container {
    position: relative;
    width: 100%;
}

.avatar-picker-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.avatar-picker-selected:hover,
.avatar-picker-selected:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

.avatar-picker-preview {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-picker-preview img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.avatar-picker-preview .avatar-picker-name {
    font-size: 0.9rem;
    color: #212529;
}

.avatar-picker-placeholder {
    color: #6c757d;
    font-size: 0.9rem;
}

.avatar-picker-arrow {
    color: #6c757d;
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.avatar-picker-container.open .avatar-picker-arrow {
    transform: rotate(180deg);
}

.avatar-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 4px;
    max-height: 50vh;
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.avatar-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px;
    padding-bottom: 20px;
}

.avatar-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
}

.avatar-picker-item:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.avatar-picker-item.selected {
    background: #e3f2fd;
    border-color: #0d6efd;
}

.avatar-picker-item.no-avatar {
    background: #f0f0f0;
}

.avatar-picker-item img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.avatar-picker-item .avatar-placeholder-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dee2e6;
    border-radius: 6px;
    font-size: 1.5rem;
    color: #6c757d;
}

.avatar-picker-item .avatar-item-name {
    font-size: 0.65rem;
    color: #495057;
    text-align: center;
    margin-top: 4px;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dark mode support */
[data-theme="dark"] .avatar-picker-selected,
[data-theme="dark"] .avatar-picker-dropdown {
    background: #2d2d2d;
    border-color: #404040;
}

[data-theme="dark"] .avatar-picker-selected:hover,
[data-theme="dark"] .avatar-picker-selected:focus {
    border-color: #4dabf7;
}

[data-theme="dark"] .avatar-picker-item {
    background: #333;
}

[data-theme="dark"] .avatar-picker-item:hover {
    background: #444;
}

[data-theme="dark"] .avatar-picker-item.selected {
    background: #1a3a5c;
    border-color: #4dabf7;
}

[data-theme="dark"] .avatar-picker-preview .avatar-picker-name,
[data-theme="dark"] .avatar-picker-item .avatar-item-name {
    color: #e0e0e0;
}

/* Mobile optimizations for avatar picker */
@media (max-width: 576px) {
    .avatar-picker-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 65vh;
        border-radius: 16px 16px 0 0;
        margin-top: 0;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
    }
    
    .avatar-picker-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 12px;
        padding-bottom: 40px;
    }
    
    .avatar-picker-item img {
        width: 56px;
        height: 56px;
    }
    
    .avatar-picker-item .avatar-placeholder-icon {
        width: 56px;
        height: 56px;
    }
    
    .avatar-picker-item .avatar-item-name {
        font-size: 0.7rem;
        max-width: 70px;
    }
    
    /* Add a drag handle indicator at top */
    .avatar-picker-dropdown::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: 8px auto;
    }
    
    /* Backdrop overlay for mobile */
    .avatar-picker-container.open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1049;
    }
}

/* Fast Track blinking yellow animation */
@keyframes fast-track-blink {
    0%, 100% { 
        background-color: #ffc107;
        border-color: #ff9800;
        box-shadow: 0 0 10px rgba(255, 193, 7, 0.8);
    }
    50% { 
        background-color: #fff9c4;
        border-color: #ffc107;
        box-shadow: 0 0 20px rgba(255, 193, 7, 1);
    }
}

.player-tile.fast-track {
    animation: fast-track-blink 0.5s ease-in-out 10;
    border-width: 3px;
    z-index: 10;
}

/* Fast Track indicator badge */
.fast-track-badge {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #000;
    font-size: 0.5rem;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    z-index: 11;
}

/* Wild Turkey highlight animation */
@keyframes wild-turkey-blink {
    0%, 100% {
        background-color: #fd7e14;
        border-color: #dc3545;
        box-shadow: 0 0 12px rgba(253, 126, 20, 0.9);
    }
    50% {
        background-color: #ffe5d0;
        border-color: #fd7e14;
        box-shadow: 0 0 22px rgba(253, 126, 20, 1);
    }
}

.player-tile.wild-turkey-highlight {
    animation: wild-turkey-blink 0.5s ease-in-out 10;
    border-width: 3px;
    z-index: 10;
}

/* Wild Turkey indicator badge */
.wild-turkey-badge {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #fd7e14, #dc3545);
    color: #fff;
    font-size: 0.5rem;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    z-index: 11;
}

/* Fastest-answer streak badge container */
.player-tile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 2px;
    justify-content: center;
}

/* ⚡ streak badge */
.badge-fastest-streak {
    background: linear-gradient(135deg, #0dcaf0, #0d6efd);
    color: #fff;
    font-size: 0.55rem;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Toast notification container */
#host-toast-container {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
    max-width: 300px;
}

.host-toast {
    background: rgba(33,37,41,0.92);
    border-left: 4px solid #0d6efd;
    border-radius: 6px;
    padding: 8px 12px;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    font-size: 0.78rem;
    line-height: 1.4;
    pointer-events: auto;
    animation: toast-slide-in 0.25s ease;
    color: #e9ecef;
    opacity: 0.85;
}

.host-toast.success { border-color: #198754; }
.host-toast.danger  { border-color: #dc3545; }
.host-toast.warning { border-color: #ffc107; }
.host-toast.info    { border-color: #0dcaf0; }

@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 0.85; transform: translateX(0); }
}
@keyframes toast-fade-out {
    from { opacity: 0.85; }
    to   { opacity: 0; transform: translateX(-30px); }
}

/* Animation for connection pulse */
@keyframes pulse-green {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Animation for new answers */
@keyframes highlight-answer {
    0% { 
        background-color: #fff3cd;
        transform: scale(1);
    }
    50% { 
        background-color: #ffc107;
        transform: scale(1.02);
    }
    100% { 
        background-color: #fff3cd;
        transform: scale(1);
    }
}

.player-tile.new-answer {
    animation: highlight-answer 1s ease-out;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .player-tile-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 4px;
    }
    
    .player-tile {
        padding: 5px;
        min-height: 60px;
    }
    
    .player-tile-name {
        font-size: 0.65rem;
        max-width: 75px;
    }
    
    .player-tile-score {
        font-size: 0.55rem;
    }
}

/* Accessibility enhancements */
.player-tile:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.player-tile[aria-label]:hover::after {
    content: attr(aria-label);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* ===== iPhone/iOS COMPATIBILITY FIXES ===== */
/* Fix touch behavior on iOS devices */
.numeric-calculator button {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    cursor: pointer;
}

/* Enhanced touch feedback for iOS */
.numeric-calculator button:active {
    transform: scale(0.95);
    background-color: #e9ecef;
    transition: transform 0.1s;
}

/* Larger touch targets for mobile */
@media (max-width: 768px) {
    .numeric-calculator button {
        font-size: 2rem;
        padding: 1.5rem;
        height: 80px;
        min-height: 80px;
    }
    
    .numeric-calculator {
        gap: 12px;
        max-width: 350px;
    }
}

/* Specific fixes for iPhone Safari */
@supports (-webkit-touch-callout: none) {
    .numeric-calculator button {
        -webkit-appearance: none;
        appearance: none;  /* FIXED: Added standard property for compatibility */
        border-radius: 12px;
    }
    
    .choice {
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        -webkit-touch-callout: none;
        touch-action: manipulation;
    }
    
    /* Fix for Safari double-tap zoom */
    .choice, .numeric-calculator button {
        touch-action: manipulation;
    }
}

/* Better visual feedback for all touch devices */
.choice:active, .btn:active {
    transform: scale(0.98);
    transition: transform 0.1s;
}

/* Evil Mode Indicator - Subtle warning banner */
/* FIX 3: Reduced z-index to 999 to prevent overlap with banner/navigation elements */
.evil-mode-indicator {
    position: fixed;
    top: 50px; /* Position below any header/banner that might be at top: 0 */
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #8b0000 0%, #dc143c 100%);
    color: white;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    z-index: 999; /* Lower than typical navigation z-index (1000+) */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: evilModePulse 2s ease-in-out infinite;
}

.evil-mode-indicator i {
    animation: evilModeShake 1s ease-in-out infinite;
}

@keyframes evilModePulse {
    0%, 100% {
        opacity: 0.9;
    }
    50% {
        opacity: 1;
    }
}

@keyframes evilModeShake {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

/* Legacy evil mode body padding REMOVED - icon-only indicator now used
   Previously this added padding-top: 40px causing UI shift behind tiles */

/* ========================================
   PHASE 2: MOBILE-FIRST STABLE LAYOUT CSS
   UI REDESIGN - FIXED LAYOUTS
   ======================================== */

/* ========================================
   PHASE 5: UI SYSTEM TOGGLE (Task 5.1.1-5.1.3)
   Hide legacy UI elements when new UI is active
   ======================================== */
body.new-ui-active .legacy-ui-element {
    display: none !important;
}

/* Show legacy elements when new UI is disabled */
body:not(.new-ui-active) .legacy-ui-element {
    display: block;
}

/* Hide the entire old question area when new UI is active (unless legacy type) */
body.new-ui-active #qArea:not(.legacy-active) {
    display: none !important;
}

/* Hide old choices container when new UI is active (unless legacy type) */
body.new-ui-active #choices:not(.legacy-active) {
    display: none !important;
}

/* Hide old session info when new UI is active (moved to drawer) */
body.new-ui-active #sessionInfo {
    display: none !important;
}

/* Hide new question modal when new UI is active (use old popup instead) */
body.new-ui-active .question-modal-overlay {
    display: none !important;
}

