/* World Flags Game - Custom Styles */

/* Mobile-First Responsive Design */

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent iOS zoom on input focus */
    -webkit-text-size-adjust: 100%;
    /* Add safe area padding for devices with notches */
    padding-bottom: env(safe-area-inset-bottom);
    /* Ensure full page is scrollable */
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent zoom on iOS when focusing inputs */
input, select, textarea {
    font-size: 16px !important;
}

/* Mode Selection Buttons */
.mode-btn {
    cursor: pointer;
    transform: scale(1);
    transition: all 0.2s ease;
}

.mode-btn:hover {
    transform: scale(1.02);
}

.mode-btn:active {
    transform: scale(0.98);
}

.mode-btn.selected-mode {
    border-width: 3px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.study-mode-btn.selected-mode,
.practice-mode-btn.selected-mode {
    border-color: #4f46e5;
    background-color: #eef2ff;
}

.quiz-mode-btn.selected-mode {
    border-color: #059669;
    background-color: #d1fae5;
}

.timed-mode-btn.selected-mode {
    border-color: #ea580c;
    background-color: #fff7ed;
}

/* Flag Image */
.flag-image {
    width: 320px;
    max-width: 100%;
    height: auto;
    border: 3px solid #e5e7eb;
    transition: transform 0.3s ease;
}

.flag-image:hover {
    transform: scale(1.02);
}

/* Answer Buttons - Mobile First */
.answer-btn {
    min-height: 56px; /* Adjusted for better mobile fit */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 12px;
    background-color: white;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 15px;
    text-align: left;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Disable hover and active states when transitioning (prevents highlight carryover with Auto Next) */
body.transitioning .answer-btn {
    pointer-events: none; /* Prevent any interaction during transition */
    opacity: 0.3; /* Fade out buttons during transition */
    transition: opacity 0.15s ease;
    /* Force reset all visual states */
    border-color: #d1d5db !important;
    background-color: white !important;
    transform: none !important;
    box-shadow: none !important;
    border-width: 2px !important;
}

body.transitioning .answer-btn .option-letter {
    background-color: #e5e7eb !important;
    color: #1f2937 !important;
}

body.transitioning .answer-btn:hover {
    border-color: #d1d5db;
    background-color: white;
    transform: none;
    box-shadow: none;
}

body.transitioning .answer-btn:active {
    border-color: #d1d5db;
    background-color: white;
    transform: none;
    box-shadow: none;
}

.answer-btn:hover:not(:disabled) {
    border-color: #3b82f6;
    background-color: #eff6ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.answer-btn:active:not(:disabled) {
    transform: translateY(0);
}

.answer-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: #e5e7eb;
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
    margin-right: 10px;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
    font-weight: 500;
    color: #1f2937;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.3;
}

/* Answer States */
.answer-btn.selected {
    border-color: #3b82f6;
    border-width: 3px;
    background-color: #eff6ff;
}

.answer-btn.selected .option-letter {
    background-color: #3b82f6;
    color: white;
}

.answer-btn.correct {
    border-color: #10b981;
    background-color: #d1fae5;
    border-width: 3px;
}

.answer-btn.correct .option-letter {
    background-color: #10b981;
    color: white;
}

.answer-btn.incorrect {
    border-color: #ef4444;
    background-color: #fee2e2;
    border-width: 3px;
}

.answer-btn.incorrect .option-letter {
    background-color: #ef4444;
    color: white;
}

/* Navigation Buttons */
.nav-btn {
    min-height: 48px;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* Disabled state - reduced opacity, no pointer cursor */
.nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Enabled state - full opacity, pointer cursor on hover */
.nav-btn:not(:disabled) {
    opacity: 1;
    cursor: pointer;
}

/* Feedback Text Colors */
.feedback-correct {
    color: #10b981;
}

.feedback-incorrect {
    color: #ef4444;
}

.feedback-try-again {
    color: #f59e0b;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.shake {
    animation: shake 0.5s ease;
}

/* Loading Spinner */
.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #4f46e5;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Modal Overlay Animation */
#resultsModal:not(.hidden),
#confirmModal:not(.hidden) {
    animation: fadeIn 0.3s ease;
}

/* Responsive Adjustments */
@media (min-width: 640px) {
    .answer-btn {
        font-size: 16px;
        padding: 12px 16px;
        min-height: 64px;
    }

    .option-letter {
        width: 36px;
        height: 36px;
        font-size: 18px;
        margin-right: 12px;
    }
}

@media (min-width: 768px) {
    .answer-btn {
        font-size: 18px;
        padding: 14px 18px;
    }

    .option-letter {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

@media (min-width: 1024px) {
    .answer-btn:hover:not(:disabled) {
        transform: translateY(-3px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }
}

/* Keyboard Navigation - only show outline for keyboard users */
.answer-btn:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* Remove focus outline when clicking with mouse */
.answer-btn:focus:not(:focus-visible) {
    outline: none;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .nav-btn,
    button {
        display: none;
    }
}

/* Dark Mode Support */
.dark .answer-btn {
    background-color: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

.dark .answer-btn:hover:not(:disabled) {
    border-color: #60a5fa;
    background-color: #1e3a5f;
}

.dark .answer-btn.correct {
    border-color: #10b981;
    background-color: #064e3b;
}

.dark .answer-btn.incorrect {
    border-color: #ef4444;
    background-color: #7f1d1d;
}

.dark .answer-btn.selected {
    border-color: #60a5fa;
    background-color: #1e3a5f;
}

.dark .option-letter {
    background-color: #4b5563;
    color: #f3f4f6;
}

.dark .answer-btn.correct .option-letter {
    background-color: #10b981;
    color: white;
}

.dark .answer-btn.incorrect .option-letter {
    background-color: #ef4444;
    color: white;
}

.dark .option-text {
    color: #f3f4f6;
}

.dark .feedback-correct {
    color: #34d399;
}

.dark .feedback-incorrect {
    color: #f87171;
}

.dark .facts-container {
    background: #1e293b;
    border-color: #334155;
}

.dark .facts-header {
    color: #38bdf8;
}

.dark .facts-list li {
    color: #cbd5e1;
}

.dark .facts-list li:before {
    color: #38bdf8;
}

.dark .flag-image {
    border-color: #4b5563;
}

/* Timed mode specific styles */
.timer-bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.timer-display {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.timer-display.warning {
    color: #f59e0b;
    animation: pulse 1s ease-in-out infinite;
}

.timer-display.critical {
    color: #ef4444;
    animation: pulse 0.5s ease-in-out infinite;
}

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

.dark .timer-bar {
    background: #374151;
}

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

/* Prevent text selection on game elements */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus visible for better keyboard navigation */
*:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* Flag Facts Section */
.facts-container {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    animation: fadeIn 0.3s ease-in;
}

.facts-header {
    font-size: 18px;
    font-weight: 700;
    color: #0369a1;
    margin: 0 0 16px 0;
}

.facts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.facts-list li {
    font-size: 16px;
    line-height: 1.6;
    color: #334155;
    margin-bottom: 12px;
    padding-left: 20px;
    position: relative;
}

.facts-list li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #0369a1;
    font-weight: bold;
}

.facts-list li:last-child {
    margin-bottom: 0;
}

/* Mobile optimization for facts */
@media (max-width: 640px) {
    .facts-container {
        padding: 16px;
        margin: 16px 0;
    }

    .facts-header {
        font-size: 16px;
    }

    .facts-list li {
        font-size: 15px;
    }
}

/* Country Flag Notes */
.fact-note {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
    font-style: italic;
}

.fact-note strong {
    color: #78350f;
    font-style: normal;
}

.dark .fact-note {
    background: #451a03;
    border-color: #d97706;
    color: #fde68a;
}

.dark .fact-note strong {
    color: #fef3c7;
}
