/**
 * Better French Onboarding Guide
 *
 * Design Philosophy:
 * - Cohesive with existing Better French UI
 * - Educational, not forceful
 * - Uses existing design tokens
 * - Smooth, premium animations
 */

/* ============================================
   ONBOARDING MODAL BASE
   Matches existing modal patterns (streak, paywall)
   ============================================ */
.bf-onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.bf-onboarding-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bf-onboarding-modal {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.2),
        0 8px 24px rgba(0, 0, 0, 0.1);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.bf-onboarding-overlay.active .bf-onboarding-modal {
    transform: scale(1) translateY(0);
}

/* Step content animations */
.bf-onboarding-header,
.bf-onboarding-content,
.bf-onboarding-actions,
.bf-onboarding-nav {
    animation: stepFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.bf-onboarding-header { animation-delay: 0.05s; opacity: 0; }
.bf-onboarding-content { animation-delay: 0.1s; opacity: 0; }
.bf-onboarding-actions,
.bf-onboarding-nav { animation-delay: 0.15s; opacity: 0; }

@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   MODAL HEADER
   ============================================ */
.bf-onboarding-header {
    padding: 40px 32px 0 32px;
    text-align: center;
}

.bf-onboarding-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--ink-muted, #475569);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    z-index: 1;
}

.bf-onboarding-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--ink, #0f172a);
}

.bf-onboarding-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink, #0f172a);
    margin: 0 0 8px 0;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.bf-onboarding-subtitle {
    font-size: 16px;
    color: var(--ink-muted, #475569);
    margin: 0;
    line-height: 1.5;
}

/* ============================================
   PROGRESS BAR (for multi-step guide)
   ============================================ */
.bf-onboarding-progress {
    display: flex;
    gap: 6px;
    padding: 40px 28px 0 28px;
}

.bf-onboarding-progress-step {
    flex: 1;
    height: 4px;
    background: rgba(15, 23, 42, 0.1);
    border-radius: 2px;
    overflow: hidden;
    transition: background 0.3s ease;
}

.bf-onboarding-progress-step.completed {
    background: var(--french-blue, #2563eb);
}

.bf-onboarding-progress-step.current {
    background: var(--french-blue, #2563eb);
}

.bf-onboarding-step-label {
    font-size: 13px;
    color: var(--ink-muted, #475569);
    text-align: center;
    padding: 12px 28px 0 28px;
    font-weight: 500;
}

/* ============================================
   MODAL CONTENT
   ============================================ */
.bf-onboarding-content {
    padding: 20px 32px;
}

.bf-onboarding-description {
    font-size: 16px;
    color: var(--ink-secondary, #1e293b);
    line-height: 1.6;
    margin: 0;
    text-align: center;
}

/* Illustration container */
.bf-onboarding-illustration {
    padding: 24px 0;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mock UI elements in illustrations */
.bf-onboarding-mock-toggle {
    display: inline-flex;
    gap: 4px;
    background: rgba(240, 240, 240, 0.8);
    border-radius: 12px;
    padding: 6px;
}

.bf-onboarding-mock-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-muted, #475569);
    border: none;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(1);
    -webkit-tap-highlight-color: transparent;
}

.bf-onboarding-mock-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
    color: var(--ink-primary, #1e293b);
}

.bf-onboarding-mock-btn:active {
    transform: scale(0.95);
}

.bf-onboarding-mock-btn.active {
    background: #ffffff;
    color: var(--french-blue, #2563eb);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Micro-animation for snappy selection feedback */
.bf-onboarding-mock-btn.just-selected {
    animation: btn-pop 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes btn-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}


/* Article preview - realistic tooltip illustration */
.bf-onboarding-article-preview {
    text-align: center;
    padding: 8px 0;
}

.bf-onboarding-article-text {
    font-size: 17px;
    line-height: 1.8;
    color: var(--ink, #0f172a);
    margin: 0;
}

.bf-onboarding-article-text .bf-faded {
    opacity: 0.4;
}

.bf-onboarding-article-text .bf-highlighted-word {
    position: relative;
    text-decoration: underline;
    text-decoration-color: var(--french-blue, #2563eb);
    text-underline-offset: 3px;
    cursor: pointer;
}

.bf-tooltip-preview {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.bf-tooltip-preview::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #ffffff;
}

.bf-tooltip-preview strong {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink, #0f172a);
}

.bf-tooltip-preview span {
    font-size: 13px;
    color: var(--ink-muted, #475569);
    font-style: italic;
}

/* Audio preview illustration */
.bf-onboarding-audio-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

/* Audio demo - matches headline style from Step 3 */
.bf-onboarding-audio-demo {
    text-align: center;
    padding: 16px 0;
}

.bf-audio-headline {
    font-size: 20px;
    font-weight: 550;
    line-height: 1.5;
    color: var(--french-blue, #2563eb);
    margin: 0 0 16px 0;
}

.bf-audio-word {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.bf-audio-word:hover {
    opacity: 0.7;
}

.bf-audio-waves {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.bf-audio-waves span {
    width: 4px;
    background: var(--french-blue, #2563eb);
    border-radius: 2px;
    animation: audioWave 1s ease-in-out infinite;
}

.bf-audio-waves span:nth-child(1) { height: 8px; animation-delay: 0s; }
.bf-audio-waves span:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.bf-audio-waves span:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.bf-audio-waves span:nth-child(4) { height: 12px; animation-delay: 0.3s; }

@keyframes audioWave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
}

/* Interactive tooltip demo - styled like real article headlines */
.bf-onboarding-interactive-demo {
    text-align: center;
    padding: 16px 0;
}

.bf-demo-headline {
    font-size: 20px;
    font-weight: 550;
    line-height: 1.5;
    color: var(--french-blue, #2563eb);
    margin: 0;
}

.bf-demo-word {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.bf-demo-word:hover {
    opacity: 0.7;
}

/* Disabled Next button state */
.bf-onboarding-btn-next.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Ensure tooltip appears above onboarding modal (tooltip appends to body) */
body:has(.bf-onboarding-overlay.active) .glass-note-tooltip {
    z-index: 10010 !important;
}

/* Tip text - simple muted style */
.bf-onboarding-tip-text {
    font-size: 13px;
    color: var(--ink-muted, #475569);
    line-height: 1.5;
    margin: 16px 0 0 0;
    text-align: center;
}

/* ============================================
   MODAL FOOTER / ACTIONS
   ============================================ */
.bf-onboarding-actions {
    padding: 24px 32px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bf-onboarding-btn-primary {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: var(--french-blue, #2563eb);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.bf-onboarding-btn-primary:hover {
    background: var(--french-blue-hover, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.bf-onboarding-btn-primary:active {
    transform: translateY(0);
}

.bf-onboarding-btn-secondary {
    width: 100%;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--ink-muted, #475569);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.bf-onboarding-btn-secondary:hover {
    color: var(--ink, #0f172a);
}

/* Back button (left-aligned in multi-step) */
.bf-onboarding-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px 24px 28px;
}

.bf-onboarding-btn-back {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-muted, #475569);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bf-onboarding-btn-back:hover {
    color: var(--ink, #0f172a);
}

.bf-onboarding-btn-next {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    background: var(--french-blue, #2563eb);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bf-onboarding-btn-next:hover {
    background: var(--french-blue-hover, #1d4ed8);
}

/* ============================================
   HELP BUTTON (Navbar)
   ============================================ */
.bf-help-btn {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    color: #b8c4ce; /* Light gray - subtle and unobtrusive */
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
}

.bf-help-btn:hover {
    color: var(--ink-muted, #64748b);
}

.bf-help-btn svg {
    width: 16px;
    height: 16px;
}

/* Help dropdown menu */
.bf-help-dropdown {
    position: fixed;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 8px;
    min-width: 220px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98) translateY(-6px);
    transform-origin: top right;
    transition: opacity 150ms ease, transform 150ms ease;
}

.bf-help-dropdown.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

.bf-help-dropdown-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-muted, #475569);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 12px 6px;
    margin: 0;
}

.bf-help-dropdown-item {
    display: block;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink, #0f172a);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background 0.15s ease;
}

.bf-help-dropdown-item:hover {
    background: rgba(37, 99, 235, 0.08);
}

.bf-help-dropdown-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 6px 0;
}

/* ============================================
   INLINE SPOTLIGHT (Feature Discovery)
   Small tooltip positioned near buttons
   ============================================ */

/* Backdrop to prevent accidental taps on underlying buttons */
.bf-inline-spotlight-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    -webkit-tap-highlight-color: transparent;
}

.bf-inline-spotlight-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.bf-inline-spotlight-backdrop.dismissing {
    opacity: 0;
}

.bf-inline-spotlight {
    position: fixed;
    z-index: 10000;
    max-width: 280px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.bf-inline-spotlight.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.bf-inline-spotlight.dismissing {
    opacity: 0;
    transform: translateY(-8px);
}

.bf-inline-spotlight-content {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08);
}

.bf-inline-spotlight-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink, #0f172a);
    margin: 0 0 6px 0;
}

.bf-inline-spotlight-description {
    font-size: 14px;
    color: var(--ink-muted, #475569);
    line-height: 1.45;
    margin: 0 0 14px 0;
}

.bf-inline-spotlight-btn {
    display: inline-block;
    background: var(--french-blue, #2563eb);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.bf-inline-spotlight-btn:hover {
    background: #1d4ed8;
}

/* Arrow pointing to trigger */
.bf-inline-spotlight-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffffff;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);
}

/* Arrow at bottom (spotlight above trigger) */
.bf-inline-spotlight[data-arrow="bottom"] .bf-inline-spotlight-arrow {
    bottom: -6px;
}

/* Arrow at top (spotlight below trigger) */
.bf-inline-spotlight[data-arrow="top"] .bf-inline-spotlight-arrow {
    top: -6px;
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .bf-inline-spotlight {
        max-width: calc(100vw - 32px);
        left: 16px !important;
        right: 16px !important;
    }

    .bf-inline-spotlight-content {
        padding: 14px 16px;
    }

    .bf-inline-spotlight-title {
        font-size: 14px;
    }

    .bf-inline-spotlight-description {
        font-size: 13px;
        margin-bottom: 12px;
    }
}

/* ============================================
   STEP CONTENT TRANSITIONS
   ============================================ */
.bf-onboarding-step {
    display: none;
}

.bf-onboarding-step.active {
    display: block;
    animation: stepFadeIn 0.3s ease;
}

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

/* ============================================
   COMPLETION STATE
   ============================================ */
.bf-onboarding-complete {
    text-align: center;
    padding: 32px 28px;
}

.bf-onboarding-complete-icon {
    font-size: 28px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--french-blue, #2563eb);
    color: #ffffff;
    border-radius: 50%;
    margin-left: auto;
    margin-right: auto;
    font-weight: 600;
    animation: celebrateIcon 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes celebrateIcon {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.bf-onboarding-complete-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ink, #0f172a);
    margin: 0 0 8px 0;
}

.bf-onboarding-complete-text {
    font-size: 15px;
    color: var(--ink-muted, #475569);
    margin: 0 0 24px 0;
    line-height: 1.5;
}

/* ============================================
   RESPONSIVE (Mobile)
   ============================================ */
@media (max-width: 480px) {
    .bf-onboarding-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .bf-onboarding-modal {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 70vh;
        max-height: 70dvh; /* Dynamic viewport height for mobile browsers */
    }

    .bf-onboarding-header {
        padding: 20px 20px 0 20px;
    }

    .bf-onboarding-content {
        padding: 16px 20px;
    }

    .bf-onboarding-actions {
        padding: 8px 20px 24px 20px;
    }

    .bf-onboarding-nav {
        padding: 0 20px 24px 20px;
    }

    .bf-onboarding-title {
        font-size: 20px;
    }

    .bf-onboarding-description {
        font-size: 15px;
    }

    .bf-onboarding-illustration {
        padding: 16px;
        min-height: 80px;
    }

    .bf-onboarding-tip-text {
        font-size: 12px;
        margin-top: 12px;
    }

    /* Help dropdown - position from left on mobile */
    .bf-help-dropdown {
        left: 16px !important;
        right: 16px !important;
        min-width: auto;
        width: calc(100% - 32px);
        max-width: 280px;
    }
}

/* ============================================
   DARK MODE SUPPORT (future)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Will be implemented when dark mode is added */
}
