/* ══════════════════════════════════════════
   Smart TOC — Frontend Styles v1.0.0
   ══════════════════════════════════════════ */

:root {
    --stoc-primary: #3b82f6;
    --stoc-primary-rgb: 59, 130, 246;
    --stoc-primary-light: #60a5fa;
    --stoc-primary-lighter: #93c5fd;
    --stoc-text: #1f2937;
    --stoc-text-muted: #6b7280;
    --stoc-text-light: #9ca3af;
    --stoc-bg: #ffffff;
    --stoc-bg-hover: #f8fafc;
    --stoc-bg-active: rgba(var(--stoc-primary-rgb), 0.06);
    --stoc-border: #e5e7eb;
    --stoc-border-light: #f3f4f6;
    --stoc-radius: 14px;
    --stoc-radius-sm: 8px;
    --stoc-header-h: 80px;
    --stoc-top: calc(var(--stoc-header-h) + 16px);
}

.stoc-scroll-mt { scroll-margin-top: var(--stoc-top); }

/* ════════════════════════════════
   DESKTOP: Fixed floating sidebar
   ════════════════════════════════ */
.stoc-floating {
    display: none; /* hidden on mobile */
}
@media (min-width: 1080px) {
    .stoc-floating {
        display: block;
        position: fixed;
        top: var(--stoc-top);
        left: 20px;
        width: 260px;
        z-index: 90;
        max-height: calc(100vh - var(--stoc-header-h) - 40px);
    }
}
@media (min-width: 1400px) {
    .stoc-floating { left: calc((100vw - 1200px) / 2 - 280px); width: 260px; }
}

.stoc-card {
    background: var(--stoc-bg);
    border: 1px solid var(--stoc-border);
    border-radius: var(--stoc-radius);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    transition: box-shadow 0.3s, border-color 0.3s;
}
.stoc-card:hover {
    border-color: rgba(var(--stoc-primary-rgb), 0.2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.04), 0 8px 24px rgba(var(--stoc-primary-rgb), 0.08);
}

/* Header */
.stoc-header {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%;
    background: linear-gradient(135deg, rgba(var(--stoc-primary-rgb), 0.03), rgba(var(--stoc-primary-rgb), 0.07));
    border: none; border-bottom: 1px solid var(--stoc-border-light);
    cursor: pointer; padding: 14px 16px; transition: background 0.2s; font-family: inherit;
}
.stoc-header--static { cursor: default; }
.stoc-header:hover { background: linear-gradient(135deg, rgba(var(--stoc-primary-rgb), 0.05), rgba(var(--stoc-primary-rgb), 0.1)); }
.stoc-header:focus-visible { outline: 2px solid var(--stoc-primary-light); outline-offset: -2px; }

.stoc-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 700; color: var(--stoc-primary);
    text-transform: uppercase; letter-spacing: 0.6px;
}
.stoc-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.stoc-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    background: var(--stoc-primary); color: #fff;
    font-size: 10px; font-weight: 700; border-radius: 99px;
}
.stoc-chevron {
    width: 14px; height: 14px; color: var(--stoc-text-muted);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); flex-shrink: 0;
}
.stoc-chevron.stoc-collapsed { transform: rotate(180deg); }

/* Body */
.stoc-body { padding: 14px 16px 16px; }
.stoc-body.stoc-hidden { display: none; }

/* Progress */
.stoc-progress { margin-bottom: 14px; }
.stoc-progress-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.stoc-progress-label { font-size: 10px; font-weight: 600; color: var(--stoc-text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.stoc-progress-pct { font-size: 11px; font-weight: 800; color: var(--stoc-primary); font-variant-numeric: tabular-nums; }
.stoc-progress-track { position: relative; height: 4px; background: var(--stoc-border-light); border-radius: 99px; overflow: hidden; }
.stoc-progress-bar {
    position: absolute; inset: 0; width: 0%;
    background: linear-gradient(90deg, var(--stoc-primary), var(--stoc-primary-light), var(--stoc-primary-lighter));
    background-size: 200% 100%; border-radius: 99px; transition: width 0.2s ease-out;
    animation: stocShimmer 3s ease-in-out infinite;
}
@keyframes stocShimmer { 0%,100%{background-position:0% 50%}50%{background-position:100% 50%} }

/* Scroll container */
.stoc-scroll {
    max-height: calc(100vh - var(--stoc-header-h) - 220px);
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: var(--stoc-border) transparent;
}
.stoc-scroll::-webkit-scrollbar { width: 4px; }
.stoc-scroll::-webkit-scrollbar-track { background: transparent; }
.stoc-scroll::-webkit-scrollbar-thumb { background: var(--stoc-border); border-radius: 99px; }

/* List */
.stoc-list { list-style: none !important; margin: 0 !important; padding: 0 !important; }
.stoc-item { position: relative; margin: 0 !important; padding: 0 !important; list-style: none !important; }
.stoc-item::before { display: none !important; } /* override theme bullets */
.stoc-item--sub { padding-left: 16px !important; }

/* Connector line */
.stoc-line {
    position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px;
    background: var(--stoc-border-light); border-radius: 1px; z-index: 0; transition: background 0.4s;
}
.stoc-item--sub .stoc-line { left: 29px; }
.stoc-item.stoc-passed .stoc-line {
    background: linear-gradient(180deg, var(--stoc-primary-light), rgba(var(--stoc-primary-rgb), 0.15));
}

/* Link button */
.stoc-link {
    display: flex; align-items: flex-start; gap: 10px; width: 100%;
    background: none; border: none; cursor: pointer;
    padding: 7px 8px 7px 4px; text-align: left; font-family: inherit;
    font-size: 13px; line-height: 1.45; color: var(--stoc-text-muted);
    border-radius: var(--stoc-radius-sm); position: relative; z-index: 1;
    transition: color 0.25s, background 0.25s, padding-left 0.2s;
    text-decoration: none;
}
.stoc-link:hover { color: var(--stoc-text); background: var(--stoc-bg-hover); padding-left: 8px; }
.stoc-link:focus-visible { outline: 2px solid var(--stoc-primary-light); outline-offset: 1px; }

/* Dot */
.stoc-dot-wrap {
    position: relative; width: 18px; height: 18px; min-width: 18px;
    display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.stoc-dot {
    width: 8px; height: 8px; border-radius: 50%;
    border: 2px solid var(--stoc-border); background: var(--stoc-bg);
    position: relative; z-index: 2;
    transition: background 0.3s, border-color 0.3s, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.stoc-dot-glow {
    position: absolute; inset: 0; border-radius: 50%;
    background: var(--stoc-primary-light); opacity: 0; z-index: 1; transition: opacity 0.3s;
}
.stoc-text { flex: 1; transition: font-weight 0.2s; }

/* Active */
.stoc-link.stoc-active { color: var(--stoc-primary); background: var(--stoc-bg-active); }
.stoc-link.stoc-active .stoc-text { font-weight: 600; }
.stoc-link.stoc-active .stoc-dot { background: var(--stoc-primary); border-color: var(--stoc-primary); transform: scale(1.25); }
.stoc-link.stoc-active .stoc-dot-glow { opacity: 1; animation: stocPulse 2s ease-in-out infinite; }
@keyframes stocPulse { 0%,100%{transform:scale(1);opacity:.25}50%{transform:scale(2.2);opacity:0} }

/* Passed */
.stoc-item.stoc-passed .stoc-dot { background: rgba(var(--stoc-primary-rgb), 0.35); border-color: rgba(var(--stoc-primary-rgb), 0.35); }
.stoc-item.stoc-passed .stoc-link:not(.stoc-active) { color: var(--stoc-text); }

/* ════════════════════════════════
   MOBILE: FAB (< 1080px only)
   ════════════════════════════════ */
.stoc-fab {
    display: flex; align-items: center; gap: 8px;
    position: fixed; bottom: 20px; right: 20px; z-index: 900;
    padding: 0 16px 0 0; background: var(--stoc-primary); color: #fff;
    border: none; border-radius: 50px; cursor: pointer; font-family: inherit;
    font-size: 13px; font-weight: 600; height: 48px;
    box-shadow: 0 4px 14px rgba(var(--stoc-primary-rgb), 0.4), 0 2px 6px rgba(0,0,0,0.12);
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.25s;
    -webkit-tap-highlight-color: transparent;
}
.stoc-fab:hover { transform: translateY(-3px) scale(1.02); }
.stoc-fab:active { transform: translateY(-1px) scale(0.98); }

/* HIDE FAB on desktop, HIDE floating on mobile */
@media (min-width: 1080px) {
    .stoc-fab { display: none !important; }
}

.stoc-fab-ring { position: relative; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stoc-fab-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stoc-fab-track { stroke: rgba(255,255,255,0.15); }
.stoc-fab-fill { stroke: rgba(255,255,255,0.85); transition: stroke-dashoffset 0.2s ease-out; }
.stoc-fab-icon { width: 18px; height: 18px; position: relative; z-index: 1; }
.stoc-fab-label { line-height: 1; white-space: nowrap; }

/* ════════════════════════════════
   MOBILE: Overlay + Drawer
   ════════════════════════════════ */
.stoc-overlay { display: none; position: fixed; inset: 0; z-index: 950; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.stoc-overlay.stoc-visible { display: block; animation: stocFade 0.2s ease; }
@keyframes stocFade { from{opacity:0}to{opacity:1} }

.stoc-drawer {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 960;
    background: var(--stoc-bg); border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.15); max-height: 72vh;
    transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden; will-change: transform;
}
.stoc-drawer.stoc-open { transform: translateY(0); }
.stoc-drawer.stoc-swiping { transition: none; }

.stoc-drawer-handle { display: flex; justify-content: center; padding: 10px 0 2px; cursor: grab; touch-action: none; }
.stoc-drawer-bar { width: 40px; height: 4px; background: #d1d5db; border-radius: 99px; }
.stoc-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 20px 12px; border-bottom: 1px solid var(--stoc-border-light); }
.stoc-drawer-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--stoc-primary); text-transform: uppercase; letter-spacing: 0.5px; }
.stoc-drawer-close { background: none; border: none; cursor: pointer; padding: 8px; border-radius: var(--stoc-radius-sm); color: var(--stoc-text-muted); transition: background 0.15s; -webkit-tap-highlight-color: transparent; }
.stoc-drawer-close:hover { background: var(--stoc-bg-hover); }
.stoc-drawer-close svg { width: 20px; height: 20px; }
.stoc-drawer-nav { padding: 12px 20px 28px; overflow-y: auto; max-height: calc(72vh - 150px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Mobile items: larger touch targets */
.stoc-list--mobile .stoc-link { padding: 10px 8px 10px 4px; font-size: 14px; min-height: 44px; }
.stoc-list--mobile .stoc-dot-wrap { width: 20px; height: 20px; min-width: 20px; margin-top: 2px; }
.stoc-list--mobile .stoc-dot { width: 10px; height: 10px; }
.stoc-list--mobile .stoc-line { left: 14px; top: 32px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ════════════════════════════════
   WIDGET MODE: Sticky in sidebar
   ════════════════════════════════ */
.stoc-widget {
    position: sticky;
    top: var(--stoc-top);
    z-index: 10;
    max-height: calc(100vh - var(--stoc-header-h) - 32px);
    margin-bottom: 20px;
}

/* Before-content mode: inline, not fixed */
.stoc-desktop-inline {
    margin-bottom: 24px;
}
