/* Kredo Progress Reader
 * Pionowy wskaźnik czytania + aktywna sekcja — desktop only (>=1280px)
 * Styl: cyberpunk, spójny z paletą --accent #A78BFA / cyan
 * z-index: 9399 (poniżej sidebar branż 9410, powyżej TOC 51)
 */

#kpr-wrap {
  display: none;
}

@media (min-width: 1280px) {
  #kpr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: fixed;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9399;
    pointer-events: none;
  }

  #kpr-section-label {
    pointer-events: auto;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a78bfa;
    opacity: 0;
    max-height: 140px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: opacity 0.35s ease, color 0.35s ease;
    background: rgba(5, 5, 15, 0.75);
    backdrop-filter: blur(6px);
    border-radius: 6px;
    padding: 6px 4px;
    border: 1px solid rgba(167, 139, 250, 0.2);
    box-shadow:
      0 0 12px rgba(167, 139, 250, 0.15),
      0 2px 8px rgba(0,0,0,0.4);
    cursor: default;
    user-select: none;
  }

  #kpr-section-label.kpr-visible {
    opacity: 1;
  }

  #kpr-track {
    pointer-events: auto;
    width: 3px;
    height: 200px;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 99px;
    position: relative;
    overflow: hidden;
    box-shadow:
      0 0 0 1px rgba(167, 139, 250, 0.08),
      0 0 10px rgba(167, 139, 250, 0.06);
  }

  #kpr-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border-radius: 99px;
    background: linear-gradient(180deg, #38bdf8 0%, #818cf8 40%, #a78bfa 100%);
    box-shadow:
      0 0 8px rgba(167, 139, 250, 0.6),
      0 0 18px rgba(56, 189, 248, 0.35);
    transform-origin: top center;
    transition: height 0.12s linear;
    height: 0%;
  }

  #kpr-dot {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #a78bfa;
    border: 1.5px solid rgba(167, 139, 250, 0.4);
    box-shadow:
      0 0 8px rgba(167, 139, 250, 0.8),
      0 0 20px rgba(167, 139, 250, 0.45);
    transition: top 0.12s linear;
    top: 0%;
    z-index: 1;
  }

  #kpr-pct {
    font-size: 0.55rem;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.05em;
    line-height: 1;
    transition: color 0.3s;
    font-variant-numeric: tabular-nums;
  }

  #kpr-wrap:hover #kpr-pct {
    color: #a78bfa;
  }

  @media (prefers-reduced-motion: reduce) {
    #kpr-fill,
    #kpr-dot {
      transition: none;
    }
  }
}
