/* ═══════════════════════════════════════════════════════════════
   LERNI iOS-FIRST PREMIUM UX LAYER
   Duolingo meets Headway — addictive microlearning polish
   ═══════════════════════════════════════════════════════════════ */

/* ── SAFE AREAS ── */
:root {
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --nav-h: 64px;
    --tab-h: 56px;
    --lerni-purple: #7C5CFC;
    --lerni-green: #6AC26A;
    --lerni-orange: #EC923A;
}

/* ── GLOBAL NATIVE FEEL ── */
html {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    overscroll-behavior-y: contain;
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent pull-to-refresh in standalone */
@media (display-mode: standalone) {
    body { overscroll-behavior-y: none; }
    .top-nav { padding-top: var(--sat); }
}

/* ── TOP HEADER — iOS native feel ── */
.top-nav {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 40;
    transition: box-shadow 0.2s;
}
.top-nav.scrolled {
    box-shadow: 0 1px 12px rgba(0,0,0,0.06);
}

/* ── BOTTOM TAB BAR — iOS native ── */
#mobile-nav {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0,0,0,0.08);
    padding-bottom: var(--sab);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#mobile-nav.hidden-scroll { transform: translateY(100%); }
#mobile-nav a { transition: all 0.15s; position: relative; }
#mobile-nav a.text-lerni-purple::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--lerni-purple);
}

/* Tab bar badge */
.tab-badge {
    position: absolute;
    top: -2px; right: -4px;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    background: #E74C3C;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid white;
}

/* ── PAGE TRANSITIONS ── */
.page-enter { animation: pageSlideIn 0.3s cubic-bezier(0.2, 0, 0, 1); }
@keyframes pageSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── FLOATING RESUME CTA ── */
.floating-resume {
    position: fixed;
    bottom: calc(var(--tab-h) + var(--sab) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 35;
    animation: floatUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: calc(100vw - 32px);
}
@keyframes floatUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.floating-resume .resume-btn {
    background: var(--lerni-purple);
    color: white;
    font-weight: 800;
    font-size: 14px;
    padding: 14px 28px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(124,92,252,0.35), 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    transition: all 0.2s;
    text-decoration: none;
}
.floating-resume .resume-btn:active {
    transform: scale(0.96);
    box-shadow: 0 4px 16px rgba(124,92,252,0.3);
}

/* ── STREAK CHIP ── */
.streak-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px 4px 7px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    background: linear-gradient(135deg, #FF6B35, #FF3D00);
    color: white;
    box-shadow: 0 2px 8px rgba(255,61,0,0.25);
}
.streak-chip .flame { animation: flameWiggle 1.5s ease-in-out infinite; }
@keyframes flameWiggle { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) scale(1.1); } }

/* ── CEFR PROGRESS BAR ── */
.cefr-bar { height: 8px; border-radius: 4px; background: #E8E8EF; overflow: hidden; position: relative; }
.cefr-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--lerni-purple), #9B7DFF);
    transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}
.cefr-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ── DAILY GOAL WIDGET ── */
.daily-goal {
    background: white;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.daily-goal-ring { position: relative; width: 52px; height: 52px; }
.daily-goal-ring svg { transform: rotate(-90deg); }
.daily-goal-ring .ring-bg { stroke: #E8E8EF; }
.daily-goal-ring .ring-fill {
    stroke: var(--lerni-green);
    transition: stroke-dasharray 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── LESSON CARD — thumb-zone optimized ── */
.lesson-card {
    background: white;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.06);
    padding: 16px;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}
.lesson-card:active { transform: scale(0.98); background: #FAFAFE; }
.lesson-card .completion-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.3s;
}
.lesson-card .completion-dot.done { background: var(--lerni-green); box-shadow: 0 0 0 3px rgba(106,194,106,0.2); }
.lesson-card .completion-dot.partial { background: var(--lerni-orange); box-shadow: 0 0 0 3px rgba(236,146,58,0.2); }
.lesson-card .completion-dot.empty { background: #E0E0E8; }

/* ── CELEBRATION MODAL ── */
.celebration-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.celebration-card {
    background: white;
    border-radius: 24px;
    padding: 40px 32px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    animation: celebBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
@keyframes celebBounce { 0% { opacity: 0; transform: scale(0.8) translateY(20px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

/* ── STREAK WARNING CARD ── */
.streak-warning {
    background: linear-gradient(135deg, #FFF3E6, #FEF0F0);
    border: 1.5px solid #EC923A;
    border-radius: 16px;
    padding: 16px;
    animation: gentlePulse 3s ease-in-out infinite;
}
@keyframes gentlePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(236,146,58,0); } 50% { box-shadow: 0 0 0 4px rgba(236,146,58,0.15); } }

/* ── COMEBACK SCREEN ── */
.comeback-banner {
    background: linear-gradient(135deg, #7C5CFC 0%, #9B7DFF 100%);
    border-radius: 20px;
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
}
.comeback-banner::before {
    content: '';
    position: absolute;
    top: -50%; right: -30%;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
}

/* ── TACTILE BUTTONS ── */
.btn-ios {
    font-weight: 700;
    border-radius: 14px;
    padding: 14px 24px;
    font-size: 15px;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-ios:active { transform: scale(0.97); }
.btn-ios-primary { background: var(--lerni-purple); color: white; box-shadow: 0 4px 16px rgba(124,92,252,0.25); }
.btn-ios-primary:active { box-shadow: 0 2px 8px rgba(124,92,252,0.2); }
.btn-ios-secondary { background: #F0EBFF; color: var(--lerni-purple); }
.btn-ios-success { background: var(--lerni-green); color: white; box-shadow: 0 4px 16px rgba(106,194,106,0.25); }

/* ── MINI AUDIO DOCK ── */
.audio-dock {
    position: fixed;
    bottom: calc(var(--tab-h) + var(--sab) + 8px);
    right: 16px;
    background: white;
    border-radius: 14px;
    padding: 8px 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 35;
    animation: floatUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(0,0,0,0.06);
}

/* ── OFFLINE BADGE ── */
.offline-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    background: #E8E8EF;
    color: #8E8EA0;
    font-size: 10px;
    font-weight: 700;
}
.offline-badge.available { background: #EAFBEA; color: #4DA64D; }

/* ── SWIPE HINT ── */
.swipe-hint {
    position: absolute;
    top: 50%; right: 8px;
    transform: translateY(-50%);
    width: 4px; height: 40px;
    border-radius: 2px;
    background: rgba(0,0,0,0.08);
    opacity: 0;
    animation: hintPeek 3s ease-in-out 2s;
}
@keyframes hintPeek { 0%,100% { opacity: 0; } 20%,80% { opacity: 1; } }

/* ── HAPTIC PRESS FEEDBACK ── */
.haptic:active { transform: scale(0.97); }

/* ── SKELETON LOADING ── */
.skeleton {
    background: linear-gradient(90deg, #F0F0F4 25%, #E8E8EF 50%, #F0F0F4 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 8px;
}
@keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── RESPONSIVE: DESKTOP HIDES MOBILE STUFF ── */
@media (min-width: 1024px) {
    .mobile-only { display: none !important; }
    .floating-resume { bottom: 24px; }
}
@media (max-width: 1023px) {
    .desktop-only { display: none !important; }
}
