/**
 * EthnoGuessr - Enhancement Styles
 * Loading states, tutorial system, toasts, and improved animations
 */

/* ============================================
   LOADING OVERLAY & SPINNER
   ============================================ */
#loading-overlay {
    position: fixed;
    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: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-spinner {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: #eec566;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 75%;
    height: 75%;
    border-top-color: #c0392b;
    animation-duration: 1s;
    animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
    width: 50%;
    height: 50%;
    border-top-color: #eec566;
    animation-duration: 0.75s;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    position: absolute;
    bottom: -30px;
    color: #eec566;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
#loading-progress {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    max-width: 80%;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #eec566;
    border-radius: 20px;
    padding: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 99999;
}

#loading-progress.active {
    opacity: 1;
}

.progress-bar-fill {
    height: 20px;
    background: linear-gradient(90deg, #c0392b 0%, #eec566 50%, #c0392b 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
    box-shadow: 0 0 10px rgba(238, 197, 102, 0.5);
}

.progress-text {
    text-align: center;
    color: #eec566;
    margin-top: 5px;
    font-size: 12px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #eec566;
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
}

.toast-message {
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
}

.toast-success {
    border-color: #27ae60;
}

.toast-success .toast-icon {
    color: #27ae60;
}

.toast-error {
    border-color: #c0392b;
}

.toast-error .toast-icon {
    color: #c0392b;
}

.toast-warning {
    border-color: #f39c12;
}

.toast-warning .toast-icon {
    color: #f39c12;
}

.toast-info {
    border-color: #eec566;
}

.toast-info .toast-icon {
    color: #eec566;
}

/* ============================================
   TUTORIAL SYSTEM
   ============================================ */
#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#tutorial-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.tutorial-spotlight {
    position: fixed;
    border: 3px solid #eec566;
    border-radius: 8px;
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.75),
        0 0 20px rgba(238, 197, 102, 0.8),
        inset 0 0 20px rgba(238, 197, 102, 0.3);
    transition: all 0.4s ease;
    pointer-events: none;
    z-index: 100001;
}

.tutorial-highlight {
    position: relative;
    animation: tutorial-glow 2s ease-in-out infinite;
}

@keyframes tutorial-glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(238, 197, 102, 0.5);
    }
    50% {
        box-shadow: 0 0 25px rgba(238, 197, 102, 0.9);
    }
}

.tutorial-dialog {
    position: fixed;
    background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
    border: 2px solid #eec566;
    border-radius: 12px;
    padding: 20px;
    max-width: 400px;
    z-index: 100002;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: tutorial-fade-in 0.3s ease-out;
}

@keyframes tutorial-fade-in {
    0% {
        opacity: 0;
        filter: blur(10px);
    }
    100% {
        opacity: 1;
        filter: blur(0);
    }
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.tutorial-title {
    color: #eec566;
    font-size: 20px;
    margin: 0;
}

.tutorial-skip {
    background: none;
    border: none;
    color: #eec566;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    transition: transform 0.2s ease;
}

.tutorial-skip:hover {
    transform: scale(1.2);
    color: #c0392b;
}

.tutorial-content {
    color: #fff;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-progress {
    color: #eec566;
    font-size: 14px;
}

.tutorial-buttons {
    display: flex;
    gap: 10px;
}

.tutorial-prev,
.tutorial-next {
    padding: 8px 16px;
    background: #c0392b;
    color: #fff;
    border: 1px solid #eec566;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.tutorial-prev:hover:not(:disabled),
.tutorial-next:hover {
    background: #a93226;
    transform: scale(1.05);
}

.tutorial-prev:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tutorial-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    color: #eec566;
    border: 2px solid #eec566;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    max-width: 300px;
    z-index: 100000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.tutorial-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   CONFIRMATION DIALOG
   ============================================ */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.confirm-overlay.active {
    opacity: 1;
}

.confirm-dialog {
    background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
    border: 2px solid #eec566;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    animation: confirm-bounce 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes confirm-bounce {
    0% {
        transform: scale(0.7);
    }
    100% {
        transform: scale(1);
    }
}

.confirm-message {
    color: #fff;
    font-size: 18px;
    text-align: center;
    margin: 0 0 25px 0;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 30px;
    border: 2px solid #eec566;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.confirm-yes {
    background: #c0392b;
    color: #fff;
}

.confirm-yes:hover {
    background: #a93226;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(192, 57, 43, 0.5);
}

.confirm-no {
    background: transparent;
    color: #eec566;
}

.confirm-no:hover {
    background: rgba(238, 197, 102, 0.1);
    transform: scale(1.05);
}

/* ============================================
   SMOOTH TRANSITIONS & ANIMATIONS
   ============================================ */
.smooth-fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.smooth-slide-up {
    animation: slideUp 0.5s ease-out;
}

.smooth-zoom-in {
    animation: zoomIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

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

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   IMPROVED BUTTON STATES
   ============================================ */
button:not(:disabled) {
    position: relative;
    overflow: hidden;
}

button:not(:disabled)::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

button:not(:disabled):active::before {
    width: 300px;
    height: 300px;
}

/* ============================================
   KEYBOARD NAVIGATION INDICATORS
   ============================================ */
:focus-visible {
    outline: 3px solid #eec566;
    outline-offset: 3px;
}

.keyboard-shortcut-hint {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #eec566;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

button:hover .keyboard-shortcut-hint {
    opacity: 1;
}

/* ============================================
   RESPONSIVE IMPROVEMENTS
   ============================================ */
@media (max-width: 768px) {
    #toast-container {
        right: 10px;
        left: 10px;
        top: 10px;
    }

    .toast {
        min-width: auto;
        width: 100%;
        transform: translateY(-100px);
    }

    .toast.show {
        transform: translateY(0);
    }

    .tutorial-dialog {
        max-width: 90%;
        margin: 20px;
    }

    .confirm-dialog {
        padding: 20px;
    }

    .confirm-buttons {
        flex-direction: column;
    }

    .confirm-btn {
        width: 100%;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tutorial-spotlight {
        border-width: 5px;
    }

    .toast {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

