/* =============================================================
   Article Audio Summary Pro v3
   Developed by https://generalpublichealth.com/
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&display=swap');

/* ════════════════════════════════════
   CSS Variables
════════════════════════════════════ */
.aas-widget {
    /* Dark theme */
    --c-bg:          #0d1117;
    --c-bg2:         #161b24;
    --c-bg3:         #1c2333;
    --c-border:      rgba(255,255,255,0.06);
    --c-border2:     rgba(255,255,255,0.11);
    --c-accent:      #4ade80;
    --c-accent2:     #22c55e;
    --c-accent-dim:  rgba(74,222,128,0.12);
    --c-accent-glow: rgba(74,222,128,0.22);
    --c-text:        #e2e8f0;
    --c-text2:       #94a3b8;
    --c-text3:       #475569;
    --c-btn:         rgba(255,255,255,0.06);
    --c-btn-h:       rgba(255,255,255,0.11);
    --c-shadow:      0 24px 64px rgba(0,0,0,0.65), 0 4px 20px rgba(0,0,0,0.4);
    --c-fab-shadow:  0 6px 24px rgba(74,222,128,0.28), 0 2px 8px rgba(0,0,0,0.4);
    --r:             16px;
    --font:          'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
    --panel-w:       320px;
    --fab-sz:        52px;
}

/* Light theme */
.aas-widget.aas-theme-light {
    --c-bg:          #ffffff;
    --c-bg2:         #f8fafc;
    --c-bg3:         #f1f5f9;
    --c-border:      rgba(0,0,0,0.06);
    --c-border2:     rgba(0,0,0,0.1);
    --c-accent:      #16a34a;
    --c-accent2:     #15803d;
    --c-accent-dim:  rgba(22,163,74,0.08);
    --c-accent-glow: rgba(22,163,74,0.18);
    --c-text:        #0f172a;
    --c-text2:       #475569;
    --c-text3:       #94a3b8;
    --c-btn:         rgba(0,0,0,0.04);
    --c-btn-h:       rgba(0,0,0,0.08);
    --c-shadow:      0 20px 56px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.07);
    --c-fab-shadow:  0 6px 24px rgba(22,163,74,0.22), 0 2px 8px rgba(0,0,0,0.12);
}

/* ════════════════════════════════════
   Widget Container
════════════════════════════════════ */
.aas-widget {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: var(--font);
    font-size: 13px;
}
.aas-widget.aas-pos-left  { left: 18px; }
.aas-widget.aas-pos-right { right: 18px; }

/* ════════════════════════════════════
   FAB Button
════════════════════════════════════ */
.aas-fab {
    position: relative;
    width: var(--fab-sz);
    height: var(--fab-sz);
    border-radius: 50%;
    background: linear-gradient(145deg, var(--c-accent), var(--c-accent2));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--c-fab-shadow);
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    color: #fff;
    outline: none;
    overflow: hidden;
    z-index: 2;
}
.aas-fab:hover {
    transform: scale(1.1) rotate(-3deg);
    box-shadow: 0 8px 32px var(--c-accent-glow), 0 3px 12px rgba(0,0,0,0.4);
}
.aas-fab:active { transform: scale(0.93); }

/* Logo inside FAB */
.aas-fab-logo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 2;
    transition: opacity .2s;
}
.aas-fab-icon-fallback {
    display: none;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
}

/* Playing waveform overlay on FAB */
.aas-fab-wave {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: linear-gradient(145deg, var(--c-accent), var(--c-accent2));
    border-radius: 50%;
    opacity: 0;
    transition: opacity .3s;
    z-index: 3;
}
.aas-fab-wave i {
    display: block;
    width: 3px;
    border-radius: 2px;
    background: #fff;
    height: 12px;
}
.aas-widget.is-playing .aas-fab-wave {
    opacity: 1;
}
.aas-widget.is-playing .aas-fab-wave i {
    animation: aas-fab-wave 0.9s ease-in-out infinite;
}
.aas-widget.is-playing .aas-fab-wave i:nth-child(1) { animation-delay: 0s; }
.aas-widget.is-playing .aas-fab-wave i:nth-child(2) { animation-delay: 0.15s; }
.aas-widget.is-playing .aas-fab-wave i:nth-child(3) { animation-delay: 0.3s; }
.aas-widget.is-playing .aas-fab-wave i:nth-child(4) { animation-delay: 0.45s; }
@keyframes aas-fab-wave {
    0%,100% { transform: scaleY(0.3); }
    50%      { transform: scaleY(1); }
}

/* Pulse ring */
.aas-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--c-accent);
    opacity: 0;
    pointer-events: none;
    animation: aas-pulse-idle 3s ease-out infinite;
}
@keyframes aas-pulse-idle {
    0%   { transform: scale(1);   opacity: 0.45; }
    100% { transform: scale(1.7); opacity: 0; }
}
.aas-widget.is-playing .aas-fab-pulse {
    animation: aas-pulse-play 1.4s ease-out infinite;
}
@keyframes aas-pulse-play {
    0%   { transform: scale(1);   opacity: 0.65; }
    100% { transform: scale(1.75); opacity: 0; }
}

/* ════════════════════════════════════
   FAB Label ("AI Summary" pill)
   Slides in from FAB after delay
════════════════════════════════════ */
.aas-fab-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) translateX(0);
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--c-bg);
    border: 1px solid var(--c-border2);
    color: var(--c-text);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 6px 12px 6px 10px;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .4s, transform .4s cubic-bezier(.34,1.2,.64,1);
    z-index: 1;
}

/* Positioning by side */
.aas-pos-left  .aas-fab-label { left: calc(var(--fab-sz) + 10px); }
.aas-pos-right .aas-fab-label { right: calc(var(--fab-sz) + 10px); }

/* Visible state */
.aas-fab-label.aas-label-visible {
    opacity: 1;
    pointer-events: auto;
}
.aas-fab-label span {
    color: var(--c-accent);
}
.aas-widget.is-open .aas-fab-label {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ════════════════════════════════════
   Panel
════════════════════════════════════ */
.aas-panel {
    position: absolute;
    bottom: calc(var(--fab-sz) + 10px);
    width: var(--panel-w);
    background: var(--c-bg);
    border: 1px solid var(--c-border2);
    border-radius: var(--r);
    box-shadow: var(--c-shadow);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px) scale(0.96);
    transform-origin: bottom left;
    transition: opacity .24s ease, transform .28s cubic-bezier(.34,1.2,.64,1);
}
.aas-pos-right .aas-panel {
    right: 0;
    transform-origin: bottom right;
}
.aas-pos-left .aas-panel { left: 0; }

/* Top accent line */
.aas-panel::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--c-accent), var(--c-accent2), transparent 80%);
}

/* Open */
.aas-widget.is-open .aas-panel {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* ════════════════════════════════════
   Panel Header
════════════════════════════════════ */
.aas-panel-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--c-border);
}
.aas-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.aas-logo-link { display: flex; flex-shrink: 0; }
.aas-header-logo {
    height: 28px;
    width: 28px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--c-border2);
}
.aas-header-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}
.aas-header-brand {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-accent);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.aas-header-tagline {
    font-size: 10px;
    color: var(--c-text3);
}
.aas-close-btn {
    background: var(--c-btn);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--c-text2);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.aas-close-btn:hover { background: var(--c-btn-h); color: var(--c-text); }

/* Post title row with decorative divider line */
.aas-post-title-row { margin-top: 4px; }
.aas-divider-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
}
.aas-divider-line::before,
.aas-divider-line::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-border2), transparent);
}
.aas-divider-icon {
    color: var(--c-accent);
    display: flex;
    align-items: center;
    opacity: 0.7;
}
.aas-post-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* ════════════════════════════════════
   Tabs
════════════════════════════════════ */
.aas-tabs {
    display: flex;
    gap: 5px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--c-border);
}
.aas-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 8px;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    background: var(--c-btn);
    color: var(--c-text2);
    transition: background .15s, color .15s, border-color .15s;
    letter-spacing: 0.02em;
}
.aas-tab:hover { background: var(--c-btn-h); color: var(--c-text); }
.aas-tab.aas-tab-active {
    background: var(--c-accent-dim);
    border-color: var(--c-accent);
    color: var(--c-accent);
}

/* ════════════════════════════════════
   Content Section + Decorative Divider
════════════════════════════════════ */
.aas-content-section { padding: 10px 14px 0; }

.aas-section-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.aas-divider-left,
.aas-divider-right {
    flex: 1;
    height: 1px;
    display: block;
}
.aas-divider-left  { background: linear-gradient(90deg, transparent, var(--c-accent)); }
.aas-divider-right { background: linear-gradient(90deg, var(--c-accent), transparent); }
.aas-divider-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--c-accent);
    background: var(--c-accent-dim);
    border: 1px solid var(--c-accent);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.aas-text-preview {
    max-height: 68px;
    overflow-y: auto;
}
.aas-text-preview::-webkit-scrollbar { width: 3px; }
.aas-text-preview::-webkit-scrollbar-thumb { background: var(--c-border2); border-radius: 2px; }
.aas-preview-text {
    font-size: 11px;
    line-height: 1.65;
    color: var(--c-text2);
    margin: 0;
}

/* ════════════════════════════════════
   Waveform
════════════════════════════════════ */
.aas-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2.5px;
    padding: 8px 14px 4px;
    height: 44px;
    box-sizing: content-box;
}
.aas-bar {
    width: 3px;
    border-radius: 2px;
    background: var(--c-border2);
    flex-shrink: 0;
    height: calc(18% + (var(--i,0) % 10) * 5%);
    transition: background .3s;
}
.aas-widget.is-playing .aas-bar {
    background: var(--c-accent);
    animation: aas-wave-bar 1s ease-in-out infinite;
    animation-delay: calc(var(--i) * 28ms);
}
.aas-widget.is-paused .aas-bar {
    background: var(--c-accent);
    opacity: 0.5;
}
@keyframes aas-wave-bar {
    0%,100% { transform: scaleY(0.25); }
    50%      { transform: scaleY(1); }
}

/* ════════════════════════════════════
   Progress
════════════════════════════════════ */
.aas-progress-wrap { padding: 4px 14px 0; }
.aas-progress-track {
    height: 3px;
    background: var(--c-bg3);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}
.aas-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--c-accent), var(--c-accent2));
    border-radius: 2px;
    transition: width .35s linear;
}
.aas-time-row {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--c-text3);
    margin-top: 3px;
}

/* ════════════════════════════════════
   Controls
════════════════════════════════════ */
.aas-controls {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px 10px;
}

/* Main play/pause */
.aas-btn-play-main {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--c-accent), var(--c-accent2));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 3px 14px var(--c-accent-glow);
    position: relative;
}
.aas-btn-play-main:hover { transform: scale(1.07); }
.aas-btn-play-main:active { transform: scale(0.93); }

.aas-play-icon, .aas-pause-icon { position: absolute; transition: opacity .15s; }
.aas-play-icon  { opacity: 1; }
.aas-pause-icon { opacity: 0; }
.aas-widget.is-playing .aas-play-icon  { opacity: 0; }
.aas-widget.is-playing .aas-pause-icon { opacity: 1; }

/* Small buttons */
.aas-btn-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--c-btn);
    color: var(--c-text2);
    border: 1px solid var(--c-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
}
.aas-btn-sm:hover:not([disabled]) {
    background: var(--c-btn-h);
    color: var(--c-accent);
    border-color: var(--c-accent);
}
.aas-btn-sm[disabled] { opacity: 0.3; cursor: not-allowed; }

/* Ambient button */
.aas-btn-ambient {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--c-btn);
    color: var(--c-text3);
    border: 1px solid var(--c-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
}
.aas-btn-ambient.ambient-on {
    background: var(--c-accent-dim);
    color: var(--c-accent);
    border-color: var(--c-accent);
}
.aas-btn-ambient:hover { color: var(--c-accent); }

/* Speed control */
.aas-speed-ctrl {
    margin-left: auto;
    display: flex;
    align-items: center;
    background: var(--c-bg3);
    border: 1px solid var(--c-border);
    border-radius: 20px;
    overflow: hidden;
}
.aas-spd-btn {
    background: none;
    border: none;
    color: var(--c-text2);
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    padding: 4px 9px;
    line-height: 1;
    transition: color .15s, background .15s;
    font-family: var(--font);
}
.aas-spd-btn:hover { color: var(--c-accent); background: var(--c-accent-dim); }
.aas-spd-val {
    font-size: 10px;
    font-weight: 700;
    color: var(--c-accent);
    min-width: 30px;
    text-align: center;
    padding: 0 2px;
}

/* ════════════════════════════════════
   No support
════════════════════════════════════ */
.aas-no-support {
    margin: 0;
    padding: 8px 14px;
    font-size: 11px;
    color: #f87171;
    background: rgba(248,113,113,0.08);
    border-top: 1px solid rgba(248,113,113,0.15);
}

/* ════════════════════════════════════
   Footer
════════════════════════════════════ */
.aas-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px 10px;
    font-size: 10px;
    color: var(--c-text3);
    border-top: 1px solid var(--c-border);
}
.aas-footer a { color: var(--c-accent); text-decoration: none; }
.aas-footer a:hover { text-decoration: underline; }
.aas-footer-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--c-text3);
    display: inline-block;
}

/* ════════════════════════════════════
   Mobile
════════════════════════════════════ */
@media (max-width: 380px) {
    .aas-widget { --panel-w: calc(100vw - 28px); }
    .aas-pos-left  .aas-panel { left: 0; }
    .aas-pos-right .aas-panel { right: 0; }
    .aas-fab-label { display: none; }
}
