/* ============================================================
   duo-trail.css — Duolingo-style S-curve trail directive
   Copy this file (along with duo-trail.js + duo-trail.html)
   into every app that uses <duo-trail>.
   ============================================================ */

/* ── Directive wrapper ────────────────────────────────────── */
.duo-trail-view {
    position: relative;
}

/* ── Loading state ────────────────────────────────────────── */
.duo-trail-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.duo-trail-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-primary, #FF9600);
    border-radius: 50%;
    animation: duo-spin 0.8s linear infinite;
}

@keyframes duo-spin {
    to { transform: rotate(360deg); }
}

/* ── Trail container ──────────────────────────────────────── */
.duo-trail-container {
    padding: 0 10px 100px;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: visible;
}

.duo-trail {
    position: relative;
    padding-top: 8px;
}

.duo-trail-item { margin-bottom: 18px; }

/* ── Module Divider ───────────────────────────────────────── */
.duo-module-divider {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-faint, rgba(255,255,255,0.4));
    letter-spacing: 0.5px;
    padding: 20px 0 8px;
    margin-bottom: 4px;
    user-select: none;
}

/* ── Sticky Module Box ────────────────────────────────────── */
.duo-sticky-module {
    position: sticky;
    top: 68px; /* fallback — overridden by JS with actual header offsetHeight */
    z-index: 40;
    display: flex;
    align-items: center;
    padding: 12px 18px;
    margin: 4px 12px 8px;
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
    transition: background-color 0.3s ease;
}

.duo-sticky-module-info { flex: 1; }

.duo-sticky-module-section {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-bottom: 2px;
}

.duo-sticky-module-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

.duo-sticky-module-icon {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-left: 12px;
}

/* ── Lesson Bubble ────────────────────────────────────────── */
.duo-bubble-wrap {
    position: relative;
    width: 72px;
    transition: margin-left 0.3s ease;
    margin-bottom: 18px;
    overflow: visible;
}

/* Connecting cord between bubbles */
.duo-bubble-wrap::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 22px;
    background: linear-gradient(to bottom, rgba(255,180,0,0.3), rgba(255,180,0,0.15));
    border-radius: 3px;
    z-index: -1;
}

.duo-bubble-wrap:first-child::before,
.duo-trail-item:first-child .duo-bubble-wrap::before {
    display: none;
}

.duo-bubble {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 28px;
    transition: transform 0.15s;
    position: relative;
    background: linear-gradient(145deg, #FFB800 0%, #E8960D 50%, #CC7A00 100%);
    border: 3px solid rgba(255,200,50,0.4);
    border-bottom: 6px solid #8B5E00;
    box-shadow:
        0 6px 0 #7A5200,
        0 8px 20px rgba(0,0,0,0.4),
        inset 0 2px 4px rgba(255,255,255,0.3),
        inset 0 -2px 4px rgba(0,0,0,0.2);
}

.duo-bubble i {
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
    position: relative;
    z-index: 1;
}

.duo-bubble:active {
    transform: scale(0.92) translateY(3px);
    box-shadow: 0 3px 0 #7A5200, 0 4px 12px rgba(0,0,0,0.4);
}

.duo-active {
    background: linear-gradient(145deg, #FFB800 0%, #E8960D 50%, #CC7A00 100%);
}

.duo-done {
    background: linear-gradient(145deg, #4CAF50 0%, #388E3C 50%, #2E7D32 100%);
    border-color: rgba(100,200,100,0.4);
}

.duo-locked {
    background: linear-gradient(145deg, #555566 0%, #3D3D4E 50%, #2A2A3A 100%);
    border-color: rgba(100,100,120,0.3);
    border-bottom-color: #1A1A28;
    color: rgba(255,255,255,0.35);
    cursor: not-allowed;
    box-shadow:
        0 6px 0 #1A1A28,
        0 8px 20px rgba(0,0,0,0.4),
        inset 0 2px 4px rgba(255,255,255,0.05);
}

.duo-locked::after { display: none; }

/* ── Lesson Popup ─────────────────────────────────────────── */
.duo-popup {
    position: absolute;
    left: -54px;
    top: 78px;
    width: 180px;
    background: var(--color-card, #1e1e2e);
    border: 1px solid var(--color-card-border, rgba(255,255,255,0.1));
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
    z-index: 500;
    text-align: center;
}

.duo-popup::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px; height: 12px;
    background: var(--color-card, #1e1e2e);
    border-top: 1px solid var(--color-card-border, rgba(255,255,255,0.1));
    border-left: 1px solid var(--color-card-border, rgba(255,255,255,0.1));
}

.duo-popup-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text, #fff);
    margin-bottom: 10px;
}

.duo-popup-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #fff !important;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid rgba(0,0,0,0.2);
}

/* Popup inside cartoon float: flow below stars (not absolute) */
.duo-cartoon-float .duo-popup {
    position: static;
    margin-top: 10px;
    width: 180px;
}

.duo-cartoon-float .duo-popup::before {
    display: none;
}

/* ── Character Float ──────────────────────────────────────── */
.duo-character-float {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 1;
}

.duo-character-float.duo-cartoon-float {
    pointer-events: auto;
    z-index: 10;
}

.duo-character-img {
    width: 220px; height: 220px;
    object-fit: contain;
    animation: duo-char-float 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}

.duo-character-shadow {
    width: 100px; height: 16px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.3) 0%, transparent 70%);
    border-radius: 50%;
    margin-top: -4px;
    animation: duo-shadow-pulse 3s ease-in-out infinite;
}

.duo-character-stars {
    display: flex;
    gap: 2px;
    margin-top: 4px;
}

.duo-character-stars i {
    font-size: 18px;
    color: #FFB800;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

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

@keyframes duo-shadow-pulse {
    0%, 100% { transform: scaleX(1);   opacity: 1; }
    50%       { transform: scaleX(0.8); opacity: 0.6; }
}

/* ── Chest ────────────────────────────────────────────────── */
.duo-chest {
    position: relative;
    width: 72px; height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s;
}

.duo-chest-img {
    width: 72px; height: 72px;
    object-fit: contain;
    display: block;
    transition: opacity 0.2s;
}

.duo-chest:active { transform: scale(0.92) translateY(3px); }

.duo-chest-done .duo-chest-img {
    opacity: 1;
    filter: drop-shadow(0 0 6px rgba(255, 200, 0, 0.7));
}

.duo-chest-done-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1a5632;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
}

.duo-chest-locked {
    cursor: not-allowed;
}

.duo-chest-locked .duo-chest-img {
    opacity: 0.35;
    filter: grayscale(1);
}

/* ── Cartoon Checkpoint ───────────────────────────────────── */
.duo-cartoon-checkpoint {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s;
}

.duo-cartoon-checkpoint:active { transform: scale(0.93); }

.duo-cartoon-checkpoint-img {
    width: 220px; height: 220px;
    object-fit: contain;
    animation: duo-char-float 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}

.duo-cartoon-locked .duo-cartoon-checkpoint-img {
    filter: grayscale(1);
    opacity: 0.4;
    animation: none;
}

.duo-cartoon-locked .duo-cartoon-stars i {
    color: rgba(255,255,255,0.2) !important;
    filter: none !important;
}

.duo-cartoon-stars {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.duo-star-on {
    font-size: 20px;
    color: #FFB800;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}

.duo-star-off {
    font-size: 20px;
    color: rgba(255,255,255,0.25);
}

/* ── Empty state ──────────────────────────────────────────── */
.duo-trail-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted, rgba(255,255,255,0.5));
}

.duo-trail-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.duo-trail-empty h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--color-text, #fff);
}

.duo-trail-empty p {
    font-size: 14px;
    color: var(--color-text-faint, rgba(255,255,255,0.4));
}
