/* Reading Streaks & XP widget — scoped under .te-streak-* */

.te-streak {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9990;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-color, #1a1a1a);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.te-streak-badge {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--card-bg, #ffffff);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    transition: transform 160ms ease-out, box-shadow 160ms ease-out;
}

.te-streak-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
}

.te-streak-ring {
    position: absolute;
    inset: 0;
}

.te-streak-ring svg {
    display: block;
}

.te-streak-ring-bg {
    fill: none;
    stroke: rgba(0, 0, 0, 0.08);
    stroke-width: 6;
}

.te-streak-ring-fg {
    fill: none;
    stroke: #4f8cff;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dasharray 400ms ease-out;
}

[data-theme="dark"] .te-streak-ring-bg {
    stroke: rgba(255, 255, 255, 0.12);
}

.te-streak-level {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
}

.te-streak-flame {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 18px;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 200ms ease-out, transform 200ms ease-out;
    pointer-events: none;
}

.te-streak-flame.is-on {
    opacity: 1;
    transform: scale(1);
}

@keyframes te-streak-flame-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.te-streak-flame.is-pulse {
    animation: te-streak-flame-pulse 600ms ease-out;
}

/* Card */
.te-streak-card {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 280px;
    padding: 16px 16px 14px;
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 160ms ease-out, transform 160ms ease-out;
}

.te-streak.is-expanded .te-streak-card {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.te-streak-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.te-streak-close:hover { opacity: 1; }

.te-streak-tier {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 10px;
    padding-right: 24px;
}

.te-streak-xpbar {
    height: 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

[data-theme="dark"] .te-streak-xpbar {
    background: rgba(255, 255, 255, 0.12);
}

.te-streak-xpbar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4f8cff, #6fb1ff);
    transition: width 400ms ease-out;
}

.te-streak-xptext {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 12px;
}

.te-streak-stats {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.te-streak-stats > div {
    flex: 1;
    text-align: center;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    padding: 8px 4px;
}

[data-theme="dark"] .te-streak-stats > div {
    background: rgba(255, 255, 255, 0.06);
}

.te-streak-stat-num {
    display: block;
    font-weight: 700;
    font-size: 16px;
}

.te-streak-stat-lbl {
    display: block;
    font-size: 11px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Toast */
.te-streak-toast {
    position: absolute;
    right: 0;
    bottom: 76px;
    padding: 6px 12px;
    background: #4f8cff;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(79, 140, 255, 0.45);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 220ms ease-out, transform 220ms ease-out;
}

.te-streak-toast.is-show {
    opacity: 1;
    transform: translateY(0);
}

.te-streak.is-expanded .te-streak-toast {
    /* Push the toast above the open card. */
    bottom: calc(76px + 220px);
}

/* Level-up celebration: simple radial flash */
@keyframes te-streak-levelup {
    0%   { box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(79, 140, 255, 0.55); }
    60%  { box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18), 0 0 0 22px rgba(79, 140, 255, 0); }
    100% { box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(79, 140, 255, 0); }
}

.te-streak.is-levelup .te-streak-badge {
    animation: te-streak-levelup 1200ms ease-out;
}

/* Accessibility / responsiveness */
@media (max-width: 480px) {
    .te-streak { right: 12px; bottom: 12px; }
    .te-streak-card { width: 260px; }
}

@media (prefers-reduced-motion: reduce) {
    .te-streak-badge,
    .te-streak-card,
    .te-streak-toast,
    .te-streak-ring-fg,
    .te-streak-xpbar-fill,
    .te-streak-flame {
        transition: none !important;
        animation: none !important;
    }
}
