/* Shared Learning Tools Styles - Mobile First */

/* ===== CSS VARIABLES ===== */
:root {
    --tool-primary: #6366f1;
    --tool-secondary: #8b5cf6;
    --tool-success: #22c55e;
    --tool-warning: #f59e0b;
    --tool-error: #ef4444;
    --tool-bg: #fafafa;
    --tool-card: #ffffff;
    --tool-text: #1f2937;
    --tool-text-light: #6b7280;

    --mastered: #22c55e;
    --learning: #f59e0b;
    --not-practiced: #e5e7eb;

    --touch-target: 44px;
}

/* ===== BASE RESET ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--tool-text);
    overflow-x: hidden;
}

/* ===== TOOL PAGE LAYOUT ===== */
.tool-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px;
}

.tool-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--tool-card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* ===== TOOL HEADER ===== */
.tool-header {
    background: linear-gradient(135deg, var(--tool-primary) 0%, var(--tool-secondary) 100%);
    color: white;
    padding: 20px 16px;
    text-align: center;
}

.tool-header h1 {
    font-size: 1.5rem;
    margin-bottom: 6px;
    font-weight: 700;
}

.tool-header p {
    font-size: 0.9375rem;
    opacity: 0.9;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: white;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
    font-size: 0.875rem;
    min-height: var(--touch-target);
    transition: background 0.2s;
}

.back-link:hover,
.back-link:active {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== TOOL CONTENT ===== */
.tool-content {
    padding: 16px;
}

/* ===== MODE TABS ===== */
.mode-tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mode-tab {
    min-height: var(--touch-target);
    padding: 10px 16px;
    border: none;
    border-radius: 25px;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--tool-bg);
    color: var(--tool-text);
    transition: all 0.2s ease;
}

.mode-tab:hover,
.mode-tab:active {
    background: #e5e7eb;
}

.mode-tab.active {
    background: var(--tool-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* ===== PROGRESS BAR ===== */
.progress-container {
    background: var(--tool-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.progress-header h3 {
    font-size: 0.9375rem;
    color: var(--tool-text);
}

.progress-stats {
    font-size: 0.8125rem;
    color: var(--tool-text-light);
}

.progress-bar {
    height: 16px;
    background: var(--not-practiced);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
}

.progress-bar .mastered {
    background: var(--mastered);
    transition: width 0.3s ease;
}

.progress-bar .learning {
    background: var(--learning);
    transition: width 0.3s ease;
}

/* ===== LEGEND ===== */
.progress-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--tool-text-light);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.mastered { background: var(--mastered); }
.legend-dot.learning { background: var(--learning); }
.legend-dot.not-practiced { background: var(--not-practiced); }

/* ===== FEEDBACK MESSAGES ===== */
.feedback {
    text-align: center;
    padding: 16px;
    border-radius: 12px;
    margin: 16px 0;
    font-size: 1.125rem;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

.feedback.correct {
    background: #dcfce7;
    color: #166534;
}

.feedback.incorrect {
    background: #fee2e2;
    color: #991b1b;
}

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

/* ===== CELEBRATION ===== */
.celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    animation: celebrate 1s ease-out forwards;
    pointer-events: none;
    z-index: 1000;
}

@keyframes celebrate {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.5); }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* ===== QUIZ INPUT ===== */
.quiz-input {
    width: 100%;
    max-width: 150px;
    padding: 16px;
    font-size: 1.75rem;
    text-align: center;
    border: 3px solid var(--tool-bg);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s;
    font-weight: 700;
    -webkit-appearance: none;
    appearance: none;
}

.quiz-input:focus {
    border-color: var(--tool-primary);
}

/* ===== SCORE DISPLAY ===== */
.score-display {
    background: var(--tool-bg);
    padding: 12px 24px;
    border-radius: 12px;
    display: inline-block;
    text-align: center;
}

.score-display .label {
    font-size: 0.8125rem;
    color: var(--tool-text-light);
    display: block;
}

.score-display .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--tool-primary);
}

/* ===== TIMER ===== */
.timer {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--tool-text);
    padding: 8px 16px;
    background: var(--tool-bg);
    border-radius: 8px;
}

.timer.warning {
    color: var(--tool-warning);
    animation: pulse 1s infinite;
}

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

/* ===== INSTRUCTIONS ===== */
.instructions {
    background: #fef3c7;
    border-left: 4px solid var(--tool-warning);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 20px;
    font-size: 0.9375rem;
    color: #92400e;
}

/* ===== TABLET+ STYLES ===== */
@media (min-width: 481px) {
    .tool-page {
        padding: 20px;
    }

    .tool-header {
        padding: 30px;
    }

    .tool-header h1 {
        font-size: 2rem;
    }

    .tool-content {
        padding: 24px;
    }

    .mode-tab {
        padding: 12px 20px;
        font-size: 0.9375rem;
    }
}

/* ===== DESKTOP STYLES ===== */
@media (min-width: 769px) {
    .tool-header h1 {
        font-size: 2.5rem;
    }

    .tool-content {
        padding: 30px;
    }
}

/* ===== iOS SAFE AREAS ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .tool-page {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
