/* =============================================================
   Scroll Progress & Reading Time — Frontend Styles v2.0
   Zero third-party dependencies. All CSS custom properties
   degrade gracefully if not defined by the theme.
   ============================================================= */

/* ── Progress bar ── */
#sprt-progress-bar-wrap {
    position: fixed;
    left: 0;
    width: 100%;
    z-index: 99999;
    pointer-events: none;
    background: transparent;
}
#sprt-progress-bar-wrap.sprt-top    { top: 0; }
#sprt-progress-bar-wrap.sprt-bottom { bottom: 0; }
#sprt-progress-bar {
    height: 100%;
    width: 0%;
    background: #4f46e5;
    transition: width 200ms linear;
    will-change: width;
}

/* ── Meta bar (reading time + TOC button) ── */
.sprt-meta-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.sprt-reading-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: #6b7280;
    padding: 5px 12px;
    background: #f3f4f6;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    line-height: 1;
}
.sprt-reading-time svg { flex-shrink: 0; }

.sprt-meta-toc-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8125rem;
    color: #6b7280;
    padding: 5px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    font-family: inherit;
}
.sprt-meta-toc-btn:hover { background: #e5e7eb; color: #374151; }

body.sprt-dark .sprt-reading-time,
body.sprt-dark .sprt-meta-toc-btn {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.12);
    color: #9ca3af;
}

/* ── Sticky indicator ── */
#sprt-sticky-indicator {
    position: fixed;
    z-index: 99990;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
#sprt-sticky-indicator.sprt-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
}

/* Badge style */
#sprt-sticky-indicator.sprt-style-badge {
    bottom: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: #4f46e5;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(79,70,229,0.35);
    min-width: 54px;
    text-align: center;
    line-height: 1.2;
    font-family: inherit;
}
#sprt-sticky-indicator.sprt-style-badge #sprt-time-left {
    font-size: 0.65rem;
    font-weight: 400;
    opacity: 0.85;
    white-space: nowrap;
}

/* Bar style */
#sprt-sticky-indicator.sprt-style-bar {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    background: rgba(255,255,255,0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid #e5e7eb;
    font-size: 0.8125rem;
    color: #374151;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    font-family: inherit;
}
body.sprt-dark #sprt-sticky-indicator.sprt-style-bar {
    background: rgba(17,17,17,0.94);
    border-top-color: rgba(255,255,255,0.1);
    color: #d1d5db;
}
#sprt-sticky-indicator.sprt-style-bar #sprt-sticky-pct { font-weight: 600; }
#sprt-sticky-indicator.sprt-style-bar #sprt-time-left {
    color: #9ca3af;
    font-size: 0.75rem;
}

/* Circle style */
#sprt-sticky-indicator.sprt-style-circle {
    bottom: 80px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}
body.sprt-dark #sprt-sticky-indicator.sprt-style-circle { background: #1f2937; }
#sprt-circle-svg {
    position: absolute;
    width: 60px;
    height: 60px;
    top: 0; left: 0;
    transform: rotate(-90deg);
}
#sprt-circle-bg    { stroke: #e5e7eb; }
#sprt-circle-progress { transition: stroke-dasharray 200ms linear; }
#sprt-sticky-indicator.sprt-style-circle #sprt-sticky-pct {
    position: relative;
    z-index: 1;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #111;
    font-family: inherit;
}
body.sprt-dark #sprt-sticky-indicator.sprt-style-circle #sprt-sticky-pct { color: #f9fafb; }
#sprt-sticky-indicator.sprt-style-circle #sprt-time-left { display: none; }

/* ── Reader toolbar (font size + focus mode) ── */
#sprt-toolbar {
    position: fixed;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    z-index: 99980;
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
#sprt-toolbar.sprt-visible {
    opacity: 1;
    pointer-events: auto;
}
#sprt-toolbar button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#sprt-toolbar button:hover {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}
#sprt-focus-btn.sprt-active {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}
body.sprt-dark #sprt-toolbar button {
    background: #1f2937;
    border-color: rgba(255,255,255,0.12);
    color: #d1d5db;
}

/* ── Table of contents ── */
#sprt-toc-toggle {
    position: fixed;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    z-index: 99980;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.3s;
    opacity: 0;
    pointer-events: none;
}
#sprt-toc-toggle.sprt-visible { opacity: 1; pointer-events: auto; }
#sprt-toc-toggle:hover,
#sprt-toc-toggle.sprt-active  { background: #4f46e5; color: #fff; border-color: #4f46e5; }
body.sprt-dark #sprt-toc-toggle {
    background: #1f2937;
    border-color: rgba(255,255,255,0.12);
    color: #d1d5db;
}

#sprt-toc-panel {
    position: fixed;
    top: 50%;
    left: 68px;
    transform: translateY(-50%);
    z-index: 99981;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    width: 260px;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sprt-slide-in 0.2s ease;
}
body.sprt-dark #sprt-toc-panel {
    background: #1f2937;
    border-color: rgba(255,255,255,0.1);
}
@keyframes sprt-slide-in {
    from { opacity: 0; transform: translateY(-50%) translateX(-8px); }
    to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
#sprt-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #111;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}
body.sprt-dark #sprt-toc-header {
    color: #f9fafb;
    border-bottom-color: rgba(255,255,255,0.08);
}
#sprt-toc-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 4px;
    font-family: inherit;
}
#sprt-toc-close:hover { color: #374151; }
#sprt-toc-nav {
    overflow-y: auto;
    padding: 8px 0;
}
#sprt-toc-nav a {
    display: block;
    padding: 6px 14px;
    font-size: 0.8125rem;
    color: #374151;
    text-decoration: none;
    line-height: 1.4;
    border-left: 2px solid transparent;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
body.sprt-dark #sprt-toc-nav a { color: #d1d5db; }
#sprt-toc-nav a:hover { background: #f3f4f6; color: #4f46e5; }
body.sprt-dark #sprt-toc-nav a:hover { background: rgba(255,255,255,0.06); }
#sprt-toc-nav a.sprt-toc-active {
    color: #4f46e5;
    border-left-color: #4f46e5;
    background: #f5f3ff;
    font-weight: 500;
}
body.sprt-dark #sprt-toc-nav a.sprt-toc-active { background: rgba(79,70,229,0.15); }
#sprt-toc-nav a.sprt-toc-h3 { padding-left: 26px; font-size: 0.75rem; }
#sprt-toc-nav a.sprt-toc-h4 { padding-left: 38px; font-size: 0.75rem; }

/* ── Scroll to top button ── */
#sprt-scroll-top {
    position: fixed;
    bottom: 80px;
    left: 20px;
    z-index: 99980;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, background 0.15s, color 0.15s, border-color 0.15s;
}
#sprt-scroll-top:not([hidden]) { opacity: 1; pointer-events: auto; }
#sprt-scroll-top:hover { background: #4f46e5; color: #fff; border-color: #4f46e5; }
body.sprt-dark #sprt-scroll-top {
    background: #1f2937;
    border-color: rgba(255,255,255,0.12);
    color: #d1d5db;
}

/* ── Resume reading toast ── */
#sprt-resume-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    z-index: 99995;
    background: #1f2937;
    color: #f9fafb;
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    font-size: 0.875rem;
    min-width: 240px;
    max-width: 320px;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease;
    opacity: 0;
    font-family: inherit;
}
#sprt-resume-toast:not([hidden]) {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
#sprt-resume-msg { line-height: 1.4; }
#sprt-resume-actions { display: flex; gap: 8px; }
#sprt-resume-yes, #sprt-resume-no {
    flex: 1;
    padding: 7px 12px;
    border-radius: 8px;
    border: none;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}
#sprt-resume-yes { background: #4f46e5; color: #fff; }
#sprt-resume-no  { background: rgba(255,255,255,0.12); color: #d1d5db; }
#sprt-resume-yes:hover { opacity: 0.9; }
#sprt-resume-no:hover  { background: rgba(255,255,255,0.18); }

/* ── Share-selection bubble ── */
#sprt-share-bubble {
    position: absolute;
    z-index: 99996;
    background: #1f2937;
    border-radius: 8px;
    padding: 6px 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex;
    gap: 2px;
}
#sprt-share-bubble::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
    border-bottom: none;
}
#sprt-share-copy {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: none;
    border: none;
    color: #f9fafb;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 6px;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s;
}
#sprt-share-copy:hover { background: rgba(255,255,255,0.1); }
#sprt-share-copy.sprt-copied { color: #6ee7b7; }

/* ── Completion overlay + CSS confetti ── */
#sprt-completion-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
}
#sprt-completion-overlay:not([hidden]) { opacity: 1; }
#sprt-confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
#sprt-completion-card {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 20px;
    padding: 44px 56px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,0.2);
    animation: sprt-bounce-in 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
body.sprt-dark #sprt-completion-card { background: #1f2937; color: #f9fafb; }
@keyframes sprt-bounce-in {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
#sprt-completion-check {
    width: 68px;
    height: 68px;
    background: #4f46e5;
    color: #fff;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 68px;
    margin: 0 auto 16px;
}
#sprt-completion-card p {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    font-family: inherit;
}
body.sprt-dark #sprt-completion-card p { color: #f9fafb; }

/* ── Focus mode ── */
body.sprt-focus-mode #sprt-toolbar,
body.sprt-focus-mode #sprt-toc-toggle { opacity: 1; pointer-events: auto; }

/* ── Responsive device visibility ── */
@media (max-width: 600px)               { .sprt-hide-mobile  { display: none !important; } }
@media (min-width: 601px) and (max-width: 1024px) { .sprt-hide-tablet  { display: none !important; } }
@media (min-width: 1025px)              { .sprt-hide-desktop { display: none !important; } }

/* ── Responsive layout adjustments ── */
@media (max-width: 768px) {
    #sprt-toolbar   { right: 8px; }
    #sprt-toc-toggle{ left: 8px; }
    #sprt-toc-panel { left: 56px; width: calc(100vw - 72px); max-width: 280px; }
    #sprt-scroll-top{ left: 8px; bottom: 70px; }
    #sprt-sticky-indicator.sprt-style-badge,
    #sprt-sticky-indicator.sprt-style-circle { right: 8px; bottom: 70px; }
}
