/**
 * Rajasthan Typing Master - Custom Styles
 * Mobile Responsive & Font Fixes
 */

/* ===== FONT FACE DECLARATIONS ===== */
@font-face {
    font-family: 'Kruti Dev 010';
    src: url('../fonts/krutidev010.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Mangal';
    src: url('../fonts/mangal.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Mangal';
    src: url('../fonts/mangal-bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* ===== CSS VARIABLES ===== */
:root {
    --primary: #1A73E8;
    --primary-dark: #1557B0;
    --primary-light: #4A9EFF;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
}

/* ===== BASE STYLES ===== */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== MOBILE RESPONSIVE FIXES ===== */

/* Container padding for mobile */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Hero section text sizing */
    h2.text-4xl {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    /* Stats grid - 2 columns on mobile */
    .grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    
    /* Stats cards smaller on mobile */
    .stat-card {
        padding: 0.75rem !important;
    }
    
    .stat-value {
        font-size: 1.25rem !important;
    }
    
    .stat-label {
        font-size: 0.75rem !important;
    }
    
    /* Timer display */
    .timer-display {
        font-size: 1.25rem !important;
    }
    
    /* Typing container */
    .typing-container {
        padding: 1rem !important;
        min-height: 120px !important;
    }
    
    #passageDisplay {
        font-size: 1rem !important;
        line-height: 1.8 !important;
    }
    
    /* Buttons full width on mobile */
    .btn-primary,
    .btn-secondary {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Modal content */
    .modal-content {
        padding: 1rem !important;
        width: 95% !important;
        margin: 1rem !important;
    }
    
    /* Form elements */
    .select-field {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* Header adjustments */
    header h1 {
        font-size: 1.25rem !important;
    }
    
    header .text-sm {
        font-size: 0.75rem !important;
    }
    
    /* Glass card padding */
    .glass-card {
        padding: 1rem !important;
    }
    
    /* Step cards */
    .step-card {
        padding: 1rem !important;
    }
    
    .step-number {
        width: 2.5rem !important;
        height: 2.5rem !important;
        font-size: 1rem !important;
    }
    
    /* Feature cards */
    .feature-card {
        padding: 1rem !important;
    }
    
    /* Footer adjustments */
    footer .grid {
        gap: 1.5rem !important;
    }
}

/* ===== HINDI FONT CLASSES ===== */
.font-kruti {
    font-family: 'Kruti Dev 010', 'Mangal', 'Noto Sans Devanagari', serif !important;
    font-size: 24px !important;
    line-height: 2.2 !important;
    direction: ltr !important;
    unicode-bidi: normal !important;
    font-display: swap !important;
}

.font-mangal {
    font-family: 'Mangal', 'Kruti Dev 010', 'Noto Sans Devanagari', serif !important;
    font-size: 20px !important;
    line-height: 2 !important;
    direction: ltr !important;
    unicode-bidi: normal !important;
    font-display: swap !important;
}

/* Ensure Hindi fonts display properly - OVERRIDE ALL */
#passageDisplay.font-kruti,
#passageDisplay.font-mangal {
    font-feature-settings: normal !important;
    -webkit-font-feature-settings: normal !important;
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Remove text-lg override */
#passageDisplay.text-lg {
    font-size: inherit !important;
}

/* Character spans for typing */
#passageDisplay .char {
    display: inline !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
}

/* Base passage text styles */
.passage-text {
    font-size: 18px;
    line-height: 1.8;
    color: #374151;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ===== GLASSMORPHISM ===== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 1rem;
}

.glass-card-dark {
    background: rgba(26, 115, 232, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(26, 115, 232, 0.2);
    box-shadow: 0 8px 32px rgba(26, 115, 232, 0.2);
    border-radius: 1rem;
}

/* ===== TYPING AREA ===== */
.typing-container {
    position: relative;
    min-height: 200px;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 1rem;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    overflow-x: auto;
}

.typing-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.typing-container.error-mode {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Character highlighting */
.char {
    display: inline;
    position: relative;
    transition: all 0.1s ease;
    border-radius: 2px;
    padding: 0 1px;
}

.char.current {
    background-color: var(--primary);
    color: white;
    animation: blink 1s infinite;
}

.char.correct {
    color: #10b981;
}

.char.incorrect {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
    text-decoration: underline;
}

.char.space {
    white-space: pre;
}

.char.space.incorrect::after {
    content: '•';
    color: #ef4444;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.7; }
}

.typing-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: default;
    z-index: 10;
    font-size: 16px;
    color: transparent;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
}

/* ===== STATS DISPLAY ===== */
.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(26, 115, 232, 0.15);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* ===== PROGRESS BARS ===== */
.progress-bar {
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

/* ===== TIMER DISPLAY ===== */
.timer-display {
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
}

.timer-display.warning {
    color: #f59e0b;
    animation: pulse 1s infinite;
}

.timer-display.danger {
    color: #ef4444;
    animation: pulse 0.5s infinite;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(26, 115, 232, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #374151;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-secondary:hover {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== FORM ELEMENTS ===== */
.select-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background: white;
    font-size: 1rem;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

.select-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* ===== FAQ ACCORDION ===== */
.faq-item {
    border-bottom: 1px solid #e5e7eb;
}

.faq-question {
    width: 100%;
    padding: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: #1f2937;
    transition: color 0.2s ease;
    font-size: 1rem;
}

.faq-question:hover {
    color: var(--primary);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-item.active .faq-answer {
    max-height: 500px;
    padding-bottom: 1rem;
}

/* ===== FEATURE CARDS ===== */
.feature-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.feature-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(26, 115, 232, 0.1);
    transform: translateY(-4px);
}

/* ===== STEP CARDS ===== */
.step-card {
    position: relative;
    text-align: center;
    padding: 1.5rem;
}

.step-number {
    width: 3rem;
    height: 3rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0 auto 1rem;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-up {
    animation: slideUp 0.5s ease forwards;
}

/* ===== LOADING SPINNER ===== */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== MESSAGES ===== */
.message {
    padding: 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.message-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #047857;
}

.message-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #b91c1c;
}

/* ===== PRINT STYLES ===== */
@media print {
    header, footer, .no-print {
        display: none !important;
    }
    
    .typing-container {
        border: 1px solid #000;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) {
    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
    }
    
    .stat-card:hover {
        transform: none;
    }
}

/* ===== LANDSCAPE MODE ON MOBILE ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 80vh;
    }
}
