/* ═══════════════════════════════════════════════════════════════
 * EIR DR. · audio_layer.css
 * Mini-player TTS para artículos de Academy.
 *
 * Filosofía consistente con flow_layer / research_layer:
 *   - Capa flotante sobre el artículo legacy.
 *   - Cero modificación al HTML existente.
 *   - Cálido, minimal en reposo, informativo cuando suena.
 * ═══════════════════════════════════════════════════════════════ */

/* ─── 1. Botón flotante de invocación (top-right del artículo) */
.audio-fab {
    position: fixed;
    top: 90px;
    right: 32px;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 999px;
    color: #34d399;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    backdrop-filter: blur(20px);
    box-shadow: 0 14px 40px -16px rgba(16, 185, 129, 0.35);
    transition: all .25s ease;
}
.audio-fab:hover {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.55);
    transform: translateY(-1px);
    box-shadow: 0 18px 50px -16px rgba(16, 185, 129, 0.5);
}
.audio-fab .speaker { font-size: 14px; }
.audio-fab.hidden { display: none; }

/* ─── 2. Mini-player flotante (cuando hay audio activo) ──── */
.audio-player {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(40px);
    opacity: 0;
    pointer-events: none;
    z-index: 45;

    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    min-width: 320px;
    max-width: 540px;

    background: rgba(8, 12, 24, 0.95);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 999px;
    backdrop-filter: blur(20px);

    box-shadow: 0 24px 80px -16px rgba(0, 0, 0, 0.7),
                0 0 0 1px rgba(16, 185, 129, 0.08);

    transition: opacity .3s ease, transform .3s cubic-bezier(0.4,0,0.2,1);
}
.audio-player.alive {
    opacity: 1;
    pointer-events: all;
    transform: translateX(-50%) translateY(0);
}

.audio-player button {
    background: transparent;
    border: 0;
    color: #cbd5e1;
    width: 36px; height: 36px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
}
.audio-player button:hover { background: rgba(255,255,255,0.06); color: #34d399; }

.audio-player .play-btn {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}
.audio-player .play-btn:hover {
    background: rgba(16, 185, 129, 0.3);
}

.audio-player .progress-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.audio-player .label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    color: #64748b;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.audio-player .label-row .source-pill {
    color: #34d399;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 999px;
    padding: 1px 6px;
}
.audio-player .label-row .source-pill[data-src="webspeech"] {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
}
.audio-player .label-row .source-pill[data-src="elevenlabs"],
.audio-player .label-row .source-pill[data-src="google"] {
    color: #7dd3fc;
    background: rgba(56, 189, 248, 0.1);
}
.audio-player .timecode {
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}
.audio-player .bar {
    height: 4px;
    background: rgba(255,255,255,0.07);
    border-radius: 999px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}
.audio-player .bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    width: 0;
    transition: width .2s linear;
    border-radius: 999px;
}

.audio-player .speed {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: #cbd5e1;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all .2s ease;
}
.audio-player .speed:hover {
    border-color: rgba(16, 185, 129, 0.35);
    color: #34d399;
}

.audio-player .close-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* ─── 3. Estado de carga ─────────────────────────────────── */
.audio-fab.loading {
    pointer-events: none;
    opacity: 0.6;
}
.audio-fab.loading .speaker {
    animation: audio-pulse 1.2s ease-in-out infinite;
}
@keyframes audio-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.85); }
}

/* ─── 4. Highlight del párrafo en reproducción ─────────── */
article.prose p.audio-current,
article.prose li.audio-current {
    background: linear-gradient(120deg, rgba(16,185,129,0.08) 0%, transparent 80%);
    border-radius: 6px;
    padding: 4px 10px;
    margin-left: -10px;
    transition: background .4s ease;
}

/* ─── 5. Botón "leer este párrafo" (aparece al hover) ──── */
article.prose p, article.prose li {
    position: relative;
}
.read-para-btn {
    position: absolute;
    left: -42px;
    top: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: #475569;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity .2s ease, color .2s ease;
}
article.prose p:hover .read-para-btn,
article.prose li:hover .read-para-btn {
    opacity: 1;
}
.read-para-btn:hover {
    color: #34d399;
    background: rgba(16, 185, 129, 0.08);
}

/* ─── 6. Banner status (debajo del título cuando suena) ── */
.audio-banner {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: -8px 0 28px;
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    font-size: 12.5px;
    color: #94a3b8;
    line-height: 1.5;
}
.audio-banner.alive { display: flex; }
.audio-banner .dot {
    width: 8px; height: 8px;
    background: #34d399;
    border-radius: 999px;
    box-shadow: 0 0 8px #34d399;
    animation: audio-dot 1.2s ease-in-out infinite;
}
@keyframes audio-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ─── 7. Responsive ────────────────────────────────────── */
@media (max-width: 720px) {
    .audio-fab {
        top: auto;
        bottom: 90px;
        right: 16px;
        padding: 10px 14px;
        font-size: 10px;
    }
    .audio-player {
        min-width: 0;
        max-width: 92vw;
        bottom: 14px;
    }
    .audio-player .speed { display: none; }
    .read-para-btn { display: none; }
}
