/**
 * Onboarding Styles
 * First-Time User Tutorial - Beautiful & Engaging UI
 * 
 * Design System:
 * - Uses existing CSS variables for consistency
 * - Smooth animations for delightful experience
 * - Responsive for mobile and desktop
 * - Accessible with proper contrast and focus states
 */

/* =========================================
   CONTAINER & OVERLAY
   ========================================= */

.onboarding-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.onboarding-container.active {
    pointer-events: all;
    opacity: 1;
}

.onboarding-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    transition: background 0.3s ease;
}

.onboarding-overlay.fullscreen {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* When spotlight is active, NO blur at all - keep highlighted element crystal clear */
.onboarding-overlay.with-spotlight {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
}

body.onboarding-active {
    overflow: hidden;
}

/* =========================================
   SPOTLIGHT EFFECT
   ========================================= */

.onboarding-spotlight {
    position: absolute;
    /* Large box-shadow creates the dark overlay EXCEPT where spotlight is */
    box-shadow: 
        0 0 0 9999px rgba(0, 0, 0, 0.65);
    border: 3px solid var(--primary-color, #2d7a5b);
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    animation: spotlight-glow 2s ease-in-out infinite;
    /* Ensure the spotlight area is completely transparent/clear */
    background: transparent;
    pointer-events: none;
}

/* Glow effect without affecting visibility */
@keyframes spotlight-glow {
    0%, 100% {
        border-color: var(--primary-color, #2d7a5b);
        box-shadow: 
            0 0 0 9999px rgba(0, 0, 0, 0.65),
            0 0 20px rgba(45, 122, 91, 0.5);
    }
    50% {
        border-color: #3a9d75;
        box-shadow: 
            0 0 0 9999px rgba(0, 0, 0, 0.65),
            0 0 35px rgba(45, 122, 91, 0.8);
    }
}

/* =========================================
   CONTENT CONTAINERS
   ========================================= */

.onboarding-content {
    position: absolute;
    z-index: 10002;
    max-width: 90%;
    width: 480px;
}

.onboarding-content.fullscreen-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-content.tooltip-content {
    max-width: 340px;
    width: auto;
    min-width: 280px;
}

/* Compact tooltip for spotlight steps - smaller and less intrusive */
.tooltip-card {
    padding: 16px 18px;
    padding-top: 28px;
    border-radius: 14px;
}

.tooltip-card .step-title {
    font-size: 1.15rem;
    margin-bottom: 4px;
}

.tooltip-card .step-title-ar {
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.tooltip-card .step-content {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 12px;
}

.tooltip-card .step-content p {
    margin: 0 0 8px 0;
}

.tooltip-card .compact-text {
    margin: 0 0 10px 0 !important;
}

.tooltip-card .onboarding-progress {
    padding-top: 10px;
    margin-bottom: 12px;
}

.tooltip-card .onboarding-buttons {
    gap: 8px;
}

.tooltip-card .onboarding-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
}

/* Compact demo words for small tooltip */
.demo-words-compact {
    display: flex;
    justify-content: center;
    gap: 8px;
    direction: rtl;
    padding: 10px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    margin-bottom: 8px;
}

body.dark-mode .demo-words-compact {
    background: rgba(255, 255, 255, 0.08);
}

.demo-word-sm {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.2rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.demo-word-sm.revealed {
    color: var(--primary-color, #2d7a5b);
    background: rgba(45, 122, 91, 0.12);
}

.demo-word-sm.hidden-demo {
    color: transparent;
    background: linear-gradient(90deg, #ddd 0%, #eee 50%, #ddd 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

body.dark-mode .demo-word-sm.hidden-demo {
    background: linear-gradient(90deg, #444 0%, #555 50%, #444 100%);
    background-size: 200% 100%;
}

/* =========================================
   CARD STYLES
   ========================================= */

.onboarding-card {
    position: relative;
    background: linear-gradient(135deg, var(--card-bg, #fff) 0%, rgba(255,255,255,0.95) 100%);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: card-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .onboarding-card {
    background: linear-gradient(135deg, var(--card-bg-dark, #252a28) 0%, rgba(37, 42, 40, 0.95) 100%);
}

@keyframes card-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* =========================================
   CLOSE BUTTON (Always visible)
   ========================================= */

.onboarding-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: var(--muted-text, #666);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

body.dark-mode .onboarding-close-btn {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

.onboarding-close-btn:hover {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
    transform: scale(1.1);
}

.onboarding-close-btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Smaller close button for tooltip cards */
.tooltip-card .onboarding-close-btn {
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
}

/* Arrow indicators for tooltip positioning */
.tooltip-card::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--card-bg, #fff);
    transform: rotate(45deg);
    box-shadow: -2px -2px 5px rgba(0,0,0,0.08);
    z-index: -1;
}

/* Arrow on top (tooltip below element) */
.onboarding-content.arrow-top .tooltip-card::before {
    top: -7px;
    left: 50%;
    margin-left: -7px;
}

/* Arrow on bottom (tooltip above element) */
.onboarding-content.arrow-bottom .tooltip-card::before {
    bottom: -7px;
    top: auto;
    left: 50%;
    margin-left: -7px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.08);
}

/* Arrow on right (tooltip to left of element) */
.onboarding-content.arrow-right .tooltip-card::before {
    right: -7px;
    left: auto;
    top: 24px;
    box-shadow: 2px -2px 5px rgba(0,0,0,0.08);
}

/* Arrow on left (tooltip to right of element) */
.onboarding-content.arrow-left .tooltip-card::before {
    left: -7px;
    top: 24px;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.08);
}

/* Modal mode - centered overlay when content is too tall */
.onboarding-content.modal-mode {
    position: fixed !important;
    max-width: 90vw;
    width: 420px;
}

.onboarding-content.modal-mode .tooltip-card {
    max-height: 80vh;
    overflow-y: auto;
}

.onboarding-content.modal-mode .tooltip-card::before {
    display: none;
}

body.dark-mode .tooltip-card::before {
    background: var(--card-bg-dark, #252a28);
}

/* =========================================
   TYPOGRAPHY
   ========================================= */

.step-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color, #333);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-title-ar {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.2rem;
    color: var(--muted-text, #666);
    margin: 0 0 16px 0;
    direction: rtl;
}

.step-content {
    color: var(--text-color, #333);
    line-height: 1.7;
    margin-bottom: 20px;
}

.step-content p {
    margin: 0 0 12px 0;
}

.step-content .tip {
    background: rgba(45, 122, 91, 0.1);
    border-left: 4px solid var(--primary-color, #2d7a5b);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin: 16px 0;
    font-size: 0.9rem;
}

body.dark-mode .step-content .tip {
    background: rgba(45, 122, 91, 0.2);
}

/* =========================================
   WELCOME SCREEN
   ========================================= */

.onboarding-welcome {
    text-align: center;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.onboarding-welcome h2 {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 2.5rem;
    color: var(--primary-color, #2d7a5b);
    margin: 0 0 8px 0;
}

.welcome-subtitle {
    color: var(--muted-text, #666);
    font-size: 1.1rem;
    margin-bottom: 20px !important;
}

.welcome-message {
    font-size: 1.1rem;
    max-width: 400px;
    margin: 0 auto 24px auto !important;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
    text-align: left;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(45, 122, 91, 0.08);
    border-radius: 12px;
    transition: transform 0.2s ease;
}

.feature-item:hover {
    transform: translateX(4px);
}

.feature-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.welcome-time {
    color: var(--muted-text, #666);
    font-size: 0.9rem;
    margin-top: 20px !important;
}

/* =========================================
   MICROPHONE TEST
   ========================================= */

.onboarding-mic-test {
    text-align: center;
}

.mic-icon-container {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.mic-icon {
    font-size: 4rem;
    display: block;
}

.mic-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(45, 122, 91, 0.2);
    animation: mic-pulse-animation 1.5s ease-out infinite;
    opacity: 0;
}

.onboarding-mic-test.listening .mic-pulse {
    opacity: 1;
}

@keyframes mic-pulse-animation {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

.onboarding-mic-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color, #2d7a5b) 0%, #1e5a40 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(45, 122, 91, 0.3);
}

.onboarding-mic-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(45, 122, 91, 0.4);
}

.onboarding-mic-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.onboarding-mic-btn.success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.mic-status {
    margin: 20px 0;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

body.dark-mode .mic-status {
    background: rgba(255, 255, 255, 0.1);
}

.mic-result {
    margin: 16px 0;
}

.result-success {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: rgba(40, 167, 69, 0.1);
    border: 2px solid #28a745;
    border-radius: 12px;
    color: #28a745;
    font-weight: 600;
    animation: success-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes success-pop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.mic-tips {
    text-align: left;
    margin-top: 20px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
}

body.dark-mode .mic-tips {
    background: rgba(255, 255, 255, 0.05);
}

.mic-tips p {
    margin: 0 0 10px 0;
}

.mic-tips ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.mic-tips li {
    padding: 6px 0;
}

/* =========================================
   WORD REVEAL DEMO
   ========================================= */

.reveal-demo {
    margin: 16px 0;
}

.demo-words {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    direction: rtl;
    margin: 20px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
}

body.dark-mode .demo-words {
    background: rgba(255, 255, 255, 0.1);
}

.demo-word {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.8rem;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.demo-word.revealed {
    color: var(--primary-color, #2d7a5b);
    background: rgba(45, 122, 91, 0.15);
    animation: word-reveal 0.5s ease;
}

.demo-word.hidden-demo {
    color: transparent;
    background: linear-gradient(90deg, #ddd 0%, #eee 50%, #ddd 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

body.dark-mode .demo-word.hidden-demo {
    background: linear-gradient(90deg, #444 0%, #555 50%, #444 100%);
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes word-reveal {
    from {
        transform: scale(1.2);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.demo-caption {
    text-align: center;
    color: var(--muted-text, #666);
    font-size: 0.9rem;
}

/* =========================================
   CONTROLS GUIDE
   ========================================= */

.controls-guide {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
}

body.dark-mode .control-item {
    background: rgba(255, 255, 255, 0.08);
}

.control-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #2d7a5b);
    color: white;
    border-radius: 10px;
    font-size: 1rem;
}

.keyboard-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--muted-text, #666);
    text-align: center;
}

.keyboard-hint kbd {
    display: inline-block;
    padding: 3px 8px;
    font-family: monospace;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

body.dark-mode .keyboard-hint kbd {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

/* =========================================
   PROGRESS TRACKING GUIDE
   ========================================= */

.progress-guide {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.progress-feature {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
}

body.dark-mode .progress-feature {
    background: rgba(255, 255, 255, 0.08);
}

.progress-feature .feature-icon {
    font-size: 2rem;
}

.progress-feature strong {
    display: block;
    margin-bottom: 4px;
}

.progress-feature p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted-text, #666);
}

/* =========================================
   COMPLETION SCREEN
   ========================================= */

.onboarding-complete {
    text-align: center;
}

.completion-animation {
    position: relative;
    height: 100px;
    margin-bottom: 20px;
}

.completion-animation .checkmark {
    font-size: 4rem;
    animation: checkmark-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkmark-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.completion-animation .star {
    position: absolute;
    font-size: 1.5rem;
    animation: star-float 2s ease-in-out infinite;
}

.star-1 {
    top: 10px;
    left: 30%;
    animation-delay: 0s;
}

.star-2 {
    top: 5px;
    right: 30%;
    animation-delay: 0.3s;
}

.star-3 {
    bottom: 20px;
    left: 25%;
    animation-delay: 0.6s;
}

@keyframes star-float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-15px) rotate(15deg);
        opacity: 1;
    }
}

.onboarding-complete h2 {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 2.5rem;
    color: var(--primary-color, #2d7a5b);
    margin: 0 0 12px 0;
}

.completion-message {
    font-size: 1.1rem;
    margin-bottom: 24px !important;
}

.completion-quote {
    background: linear-gradient(135deg, rgba(45, 122, 91, 0.1) 0%, rgba(45, 122, 91, 0.05) 100%);
    border-radius: 16px;
    padding: 24px;
    margin: 24px 0;
    border-left: 4px solid var(--primary-color, #2d7a5b);
}

.arabic-quote {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.4rem;
    color: var(--primary-color, #2d7a5b);
    direction: rtl;
    margin: 0 0 12px 0 !important;
}

.quote-translation {
    font-style: italic;
    color: var(--text-color, #333);
    margin: 0 0 8px 0 !important;
}

.quote-source {
    font-size: 0.9rem;
    color: var(--muted-text, #666);
    margin: 0 !important;
}

.quick-tips {
    text-align: left;
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
}

body.dark-mode .quick-tips {
    background: rgba(255, 255, 255, 0.08);
}

.quick-tips h4 {
    margin: 0 0 12px 0;
}

.quick-tips ol {
    margin: 0;
    padding-left: 20px;
}

.quick-tips li {
    padding: 6px 0;
}

/* =========================================
   PROGRESS DOTS
   ========================================= */

.onboarding-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .onboarding-progress {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.progress-dots {
    display: flex;
    gap: 8px;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

body.dark-mode .progress-dot {
    background: rgba(255, 255, 255, 0.2);
}

.progress-dot.active {
    background: var(--primary-color, #2d7a5b);
    transform: scale(1.3);
}

.progress-dot.completed {
    background: var(--primary-color, #2d7a5b);
    opacity: 0.6;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--muted-text, #666);
}

/* =========================================
   BUTTONS
   ========================================= */

.onboarding-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.onboarding-btn {
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.onboarding-btn.primary {
    background: linear-gradient(135deg, var(--primary-color, #2d7a5b) 0%, #1e5a40 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(45, 122, 91, 0.3);
}

.onboarding-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(45, 122, 91, 0.4);
}

.onboarding-btn.secondary {
    background: transparent;
    color: var(--muted-text, #666);
    border: 2px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .onboarding-btn.secondary {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
}

.onboarding-btn.secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .onboarding-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* =========================================
   WELCOME TOAST
   ========================================= */

.onboarding-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 10003;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.onboarding-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary-color, #2d7a5b) 0%, #1e5a40 100%);
    color: white;
    border-radius: 50px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    font-weight: 500;
}

.toast-icon {
    font-size: 1.5rem;
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */

/* Large tablets and small desktops */
@media (max-width: 900px) {
    .onboarding-content {
        width: 85%;
        max-width: 500px;
    }

    .onboarding-content.tooltip-content {
        max-width: 380px;
        min-width: 280px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .onboarding-content {
        width: 90%;
        max-width: 450px;
    }

    .onboarding-content.tooltip-content {
        max-width: 340px;
        min-width: 260px;
    }

    .onboarding-card {
        padding: 28px 24px;
    }

    .tooltip-card {
        padding: 20px;
        padding-top: 32px;
    }

    .step-title {
        font-size: 1.35rem;
        padding-right: 40px; /* Space for close button */
    }

    .onboarding-close-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .welcome-features {
        gap: 10px;
    }

    .control-item {
        padding: 8px 12px;
        gap: 10px;
    }

    .control-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .progress-feature {
        padding: 12px;
        gap: 12px;
    }
}

/* Mobile phones */
@media (max-width: 600px) {
    /* Fullscreen modals - centered properly on mobile */
    .onboarding-content.fullscreen-content {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%) !important;
        width: 92%;
        max-width: none;
        max-height: 88vh;
        overflow-y: auto;
    }

    /* Tooltip content - position will be set by JS, but constrain width */
    .onboarding-content.tooltip-content {
        width: 90% !important;
        max-width: 320px;
        min-width: unset;
        left: 50% !important;
        transform: translateX(-50%);
    }

    .onboarding-card {
        padding: 20px 16px;
        border-radius: 16px;
    }

    .onboarding-card.fullscreen-card {
        padding: 24px 18px;
        padding-top: 40px;
    }

    .tooltip-card {
        padding: 14px 14px;
        padding-top: 32px;
        border-radius: 12px;
    }

    .step-title {
        font-size: 1.15rem;
        padding-right: 32px;
        word-break: break-word;
    }

    .step-title-ar {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .step-content {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .step-content p {
        margin-bottom: 8px;
    }

    .onboarding-close-btn {
        top: 10px;
        right: 10px;
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    /* Welcome screen mobile adjustments */
    .onboarding-welcome h2 {
        font-size: 1.6rem;
        margin-bottom: 4px;
    }

    .welcome-icon {
        font-size: 2.5rem;
        margin-bottom: 10px;
    }

    .welcome-subtitle {
        font-size: 0.9rem;
        margin-bottom: 12px !important;
    }

    .welcome-message {
        font-size: 0.9rem;
        margin-bottom: 16px !important;
    }

    .welcome-features {
        gap: 6px;
        margin: 14px 0;
    }

    .feature-item {
        padding: 8px 10px;
        gap: 8px;
        font-size: 0.85rem;
    }

    .feature-icon {
        font-size: 1.1rem;
    }

    .welcome-time {
        font-size: 0.8rem;
        margin-top: 12px !important;
    }

    /* Mic test mobile */
    .mic-icon {
        font-size: 2.5rem;
    }

    .mic-icon-container {
        margin-bottom: 12px;
    }

    .onboarding-mic-test h3 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .onboarding-mic-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .mic-tips {
        padding: 12px;
        font-size: 0.85rem;
    }

    .mic-tips li {
        padding: 4px 0;
    }

    /* Demo words compact on mobile */
    .demo-words-compact {
        padding: 8px;
        gap: 6px;
    }

    .demo-word-sm {
        font-size: 1rem;
        padding: 3px 6px;
    }

    /* Buttons on mobile */
    .onboarding-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .onboarding-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    /* Progress dots on mobile */
    .onboarding-progress {
        padding-top: 12px;
        margin-bottom: 12px;
    }

    .progress-dots {
        gap: 5px;
    }

    .progress-dot {
        width: 7px;
        height: 7px;
    }

    .progress-text {
        font-size: 0.75rem;
    }

    /* Completion screen mobile */
    .completion-animation {
        height: 60px;
        margin-bottom: 12px;
    }

    .completion-animation .checkmark {
        font-size: 2.5rem;
    }

    .onboarding-complete h2 {
        font-size: 1.5rem;
    }

    .completion-message {
        font-size: 0.9rem;
        margin-bottom: 16px !important;
    }

    .completion-quote {
        padding: 14px;
        margin: 14px 0;
    }

    .arabic-quote {
        font-size: 1rem;
    }

    .quote-translation {
        font-size: 0.85rem;
    }

    .quote-source {
        font-size: 0.75rem;
    }

    .quick-tips {
        padding: 12px;
    }

    .quick-tips h4 {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    .quick-tips li {
        font-size: 0.8rem;
        padding: 3px 0;
    }

    /* Toast on mobile */
    .onboarding-toast {
        bottom: 70px;
        width: 85%;
        max-width: 300px;
    }

    .toast-content {
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    /* Spotlight adjustments for mobile */
    .onboarding-spotlight {
        border-width: 2px;
        border-radius: 8px;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    .onboarding-content.fullscreen-content {
        width: 95%;
        max-height: 90vh;
    }

    .onboarding-content.tooltip-content {
        width: 92%;
        max-width: 280px;
    }

    .onboarding-card {
        padding: 16px 12px;
    }

    .onboarding-card.fullscreen-card {
        padding: 20px 14px;
        padding-top: 36px;
    }

    .tooltip-card {
        padding: 12px 10px;
        padding-top: 28px;
    }

    .step-title {
        font-size: 1rem;
    }

    .onboarding-welcome h2 {
        font-size: 1.4rem;
    }

    .welcome-icon {
        font-size: 2rem;
    }

    .demo-word-sm {
        font-size: 0.9rem;
    }

    .onboarding-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .feature-item {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .completion-animation .checkmark {
        font-size: 2rem;
    }

    .arabic-quote {
        font-size: 0.9rem;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .onboarding-content.fullscreen-content {
        max-height: 95vh;
        padding: 10px 0;
    }

    .onboarding-card {
        padding: 16px 20px;
    }

    .welcome-icon {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    .onboarding-welcome h2 {
        font-size: 1.5rem;
        margin-bottom: 4px;
    }

    .welcome-features {
        margin: 12px 0;
        gap: 6px;
    }

    .feature-item {
        padding: 6px 10px;
    }

    .completion-animation {
        height: 50px;
        margin-bottom: 10px;
    }

    .completion-animation .checkmark {
        font-size: 2rem;
    }

    .completion-quote {
        padding: 12px;
        margin: 12px 0;
    }

    .quick-tips {
        display: none;
    }

    .mic-icon-container {
        margin-bottom: 10px;
    }

    .mic-icon {
        font-size: 2.5rem;
    }
}

/* Safe area for devices with notches */
@supports (padding: max(0px)) {
    .onboarding-content {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .onboarding-toast {
        bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px));
    }
}

/* =========================================
   ACCESSIBILITY
   ========================================= */

.onboarding-btn:focus-visible,
.onboarding-mic-btn:focus-visible {
    outline: 3px solid var(--primary-color, #2d7a5b);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .onboarding-spotlight,
    .onboarding-card,
    .welcome-icon,
    .mic-pulse,
    .demo-word,
    .completion-animation .star,
    .completion-animation .checkmark {
        animation: none;
    }

    .onboarding-container,
    .onboarding-btn,
    .feature-item,
    .progress-dot {
        transition: none;
    }
}
