/**
 * Mindflix Smart Quiz - Public CSS
 * Modern, beautiful quiz interface with animations
 */

/* גלילה חלקה */
html {
    scroll-behavior: smooth;
}

/* מניעת קפיצות בעמוד */
body {
    scroll-padding-top: 20px;
}

/* Quiz Container */
.mindflix-quiz-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    direction: rtl;
    text-align: right;
    min-height: 600px; /* גובה מינימלי קבוע למניעת קפיצות */
    position: relative;
    scroll-margin-top: 20px; /* מרווח מלמעלה בגלילה */
}

/* Quiz Screens */
.quiz-screen {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 500px; /* גובה מינימלי קבוע לכל המסכים */
    position: relative;
}

.quiz-screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Quiz Title */
.quiz-title {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2.2em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Quiz Description */
.quiz-description {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    border-left: 4px solid #3498db;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Start Screen */
.quiz-intro {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.quiz-intro::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

.quiz-intro h3 {
    font-size: 2em;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.quiz-info {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
}

.quiz-info p {
    margin: 10px 0;
    font-size: 1.1em;
}

/* Buttons */
.quiz-btn {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.quiz-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
    z-index: -1;
}

.quiz-btn:hover::before {
    left: 100%;
}

.quiz-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.quiz-btn:active {
    transform: translateY(0);
}

.quiz-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.quiz-btn-primary {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 25px rgba(231, 76, 60, 0.5);
        transform: scale(1.02);
    }
}

.quiz-btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.3);
}

/* Progress Bar */
.quiz-progress {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db 0%, #2980b9 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progress-shine 2s ease-in-out infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    font-weight: 600;
    color: #34495e;
    font-size: 1.1em;
}

/* Timer */
.quiz-timer {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.timer-circle {
    position: relative;
    width: 120px;
    height: 120px;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: #ecf0f1;
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: #e74c3c;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.timer-progress.warning {
    stroke: #f39c12;
    animation: pulse-warning 1s ease-in-out infinite;
}

.timer-progress.danger {
    stroke: #e74c3c;
    animation: pulse-danger 0.5s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

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

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
}

/* Question Container */
.question-container {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    border: 1px solid #e1e8ed;
    transition: opacity 0.3s ease;
}

.answers-container {
    transition: opacity 0.3s ease;
}

.question-text {
    font-size: 1.4em;
    color: #2c3e50;
    margin-bottom: 25px;
    line-height: 1.6;
    font-weight: 600;
}

/* Answers */
.answers-container {
    display: grid;
    gap: 15px;
    min-height: 300px; /* גובה מינימלי קבוע לאזור התשובות */
}

.answer-option {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 60px; /* גובה מינימלי קבוע לכל תשובה */
    display: flex;
    align-items: center;
}

.answer-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(52, 152, 219, 0.1), transparent);
    transition: left 0.3s ease;
}

.answer-option:hover {
    border-color: #3498db;
    background: #f1f8ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
}

.answer-option:hover::before {
    left: 100%;
}

.answer-option.selected {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border-color: #2980b9;
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

.answer-option.correct {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    border-color: #229954;
    color: white;
    animation: correct-pulse 0.6s ease-out;
}

.answer-option.incorrect {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-color: #c0392b;
    color: white;
    animation: incorrect-shake 0.6s ease-out;
}

@keyframes correct-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1.02); }
}

@keyframes incorrect-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.answer-text {
    font-size: 1.1em;
    font-weight: 500;
    line-height: 1.4;
    width: 100%;
    text-align: right;
    color: #2c3e50;
}

/* Navigation */
.quiz-navigation {
    text-align: center;
    margin-top: 30px;
}

/* Results Screen */
.quiz-results {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.quiz-results h3 {
    font-size: 2.2em;
    color: #2c3e50;
    margin-bottom: 30px;
    font-weight: 700;
}

.score-display {
    margin-bottom: 30px;
}

.score-circle {
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    position: relative;
    background: conic-gradient(from 0deg, #3498db 0%, #3498db var(--score-percentage, 0%), #ecf0f1 var(--score-percentage, 0%), #ecf0f1 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: score-reveal 2s ease-out;
}

@keyframes score-reveal {
    from { transform: scale(0) rotate(0deg); }
    to { transform: scale(1) rotate(360deg); }
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 160px;
    height: 160px;
    background: white;
    border-radius: 50%;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.1);
}

.score-percentage {
    position: relative;
    z-index: 1;
    font-size: 3em;
    font-weight: bold;
    color: #2c3e50;
}

.score-details {
    margin-top: 20px;
}

.score-details p {
    font-size: 1.2em;
    margin: 10px 0;
    color: #34495e;
}

#score-message {
    font-size: 1.4em;
    font-weight: 600;
    color: #3498db;
    margin-top: 20px;
}

/* Loading Screen */
.loading-spinner {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p {
    font-size: 1.2em;
    color: #7f8c8d;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mindflix-quiz-container {
        padding: 15px;
    }

    .quiz-intro {
        padding: 30px 20px;
    }

    .quiz-title {
        font-size: 1.8em;
    }

    .question-container {
        padding: 20px;
    }

    .question-text {
        font-size: 1.2em;
    }

    .answer-option {
        padding: 15px;
    }

    .timer-circle {
        width: 100px;
        height: 100px;
    }

    .timer-text {
        font-size: 1.6em;
    }

    .score-circle {
        width: 150px;
        height: 150px;
    }

    .score-circle::before {
        width: 120px;
        height: 120px;
    }

    .score-percentage {
        font-size: 2.2em;
    }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    .quiz-intro {
        background: #000;
        color: #fff;
    }

    .answer-option {
        border-width: 3px;
    }

    .answer-option.selected {
        background: #000;
        color: #fff;
    }
}

/* Notifications */
.quiz-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    padding: 20px 30px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    font-size: 1.1em;
}

.quiz-notification.show {
    transform: translate(-50%, -50%) scale(1);
}

.quiz-notification-info {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.quiz-notification-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.quiz-notification-error {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.quiz-notification-success {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
}

/* Answer Selection Animation */
.answer-option.answer-selected {
    animation: answer-select 0.8s ease-out;
    position: relative;
}

.answer-option.answer-selected::after {
    content: '✓ נבחרה התשובה';
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    background: rgba(39, 174, 96, 0.95);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
    animation: checkmark-appear 0.8s ease-out;
    box-shadow: 0 2px 10px rgba(39, 174, 96, 0.3);
}

@keyframes answer-select {
    0% { transform: scale(1); }
    20% { transform: scale(1.05); }
    100% { transform: scale(1.02); }
}

@keyframes checkmark-appear {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.2);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Score Circle Variants */
.score-circle.excellent {
    background: conic-gradient(from 0deg, #27ae60 0%, #27ae60 var(--score-percentage, 0%), #ecf0f1 var(--score-percentage, 0%), #ecf0f1 100%);
}

.score-circle.good {
    background: conic-gradient(from 0deg, #3498db 0%, #3498db var(--score-percentage, 0%), #ecf0f1 var(--score-percentage, 0%), #ecf0f1 100%);
}

.score-circle.average {
    background: conic-gradient(from 0deg, #f39c12 0%, #f39c12 var(--score-percentage, 0%), #ecf0f1 var(--score-percentage, 0%), #ecf0f1 100%);
}

.score-circle.poor {
    background: conic-gradient(from 0deg, #e74c3c 0%, #e74c3c var(--score-percentage, 0%), #ecf0f1 var(--score-percentage, 0%), #ecf0f1 100%);
}

/* Additional Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.quiz-screen.active .question-container {
    animation: fadeInUp 0.5s ease-out;
}

.quiz-screen.active .quiz-progress {
    animation: fadeInDown 0.5s ease-out;
}

.quiz-screen.active .answer-option {
    animation: slideInRight 0.5s ease-out;
}

.quiz-screen.active .answer-option:nth-child(2) {
    animation-delay: 0.1s;
}

.quiz-screen.active .answer-option:nth-child(3) {
    animation-delay: 0.2s;
}

.quiz-screen.active .answer-option:nth-child(4) {
    animation-delay: 0.3s;
}

/* Focus styles for accessibility */
.quiz-btn:focus,
.answer-option:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .mindflix-quiz-container {
        display: none;
    }
}