/* ==========================================================================
   SCROLL RULER TIMELINE (Interactive Telemetry Sidebar)
   Creative Studios Precision Scrubbing System
   ========================================================================== */

.scroll-ruler {
    position: fixed;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    height: min(72vh, 600px);
    width: 48px;
    z-index: 920;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    opacity: 0.9;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

/* Hide when menu or modals are open */
body.menu-open .scroll-ruler,
body.project-hud-open .scroll-ruler,
.scroll-ruler.is-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(-50%) translateX(20px);
}

/* Glass capsule background */
.scroll-ruler-shell {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    background: rgba(8, 10, 12, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 0 14px rgba(255, 255, 255, 0.02);
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.scroll-ruler:hover .scroll-ruler-shell,
.scroll-ruler.is-dragging .scroll-ruler-shell {
    background: rgba(10, 13, 16, 0.78);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 12px 42px rgba(0, 0, 0, 0.65), 0 0 28px rgba(100, 255, 218, 0.08), inset 0 0 18px rgba(255, 255, 255, 0.04);
}

/* Header & footer telemetry labels */
.ruler-cap {
    position: absolute;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    pointer-events: none;
}
.ruler-cap-top {
    top: 9px;
}
.ruler-cap-bottom {
    bottom: 9px;
}

/* Track container */
.ruler-track {
    position: relative;
    width: 32px;
    height: calc(100% - 48px);
    cursor: grab;
    touch-action: none;
    display: flex;
    justify-content: center;
}

.scroll-ruler.is-dragging .ruler-track,
body.ruler-dragging,
body.ruler-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}

/* Central vertical baseline */
.ruler-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, 
        rgba(255, 255, 255, 0.08) 0%, 
        rgba(255, 255, 255, 0.18) 50%, 
        rgba(255, 255, 255, 0.08) 100%);
    pointer-events: none;
}

/* Active progress line fill */
.ruler-progress {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    transform: translateX(-50%);
    height: 0%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), #64ffda 80%, #ffffff 100%);
    box-shadow: 0 0 8px rgba(100, 255, 218, 0.6);
    border-radius: 2px;
    pointer-events: none;
    transition: height 0.06s linear;
}
.scroll-ruler.is-dragging .ruler-progress {
    transition: none;
}

/* Generated tick marks container */
.ruler-ticks {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.ruler-tick {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 1px;
    background: rgba(255, 255, 255, 0.16);
    transition: width 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.ruler-tick.minor {
    width: 5px;
    opacity: 0.35;
}

.ruler-tick.medium {
    width: 9px;
    opacity: 0.65;
}

.ruler-tick.major {
    width: 13px;
    opacity: 0.95;
    background: rgba(255, 255, 255, 0.45);
}

.ruler-tick.passed {
    background: rgba(100, 255, 218, 0.55);
    opacity: 0.85;
}

/* Section Waypoints */
.ruler-markers {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.ruler-waypoint {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    z-index: 3;
}

.ruler-waypoint-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(5, 5, 5, 0.8);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, box-shadow 0.2s ease;
}

.ruler-waypoint:hover .ruler-waypoint-dot,
.ruler-waypoint.active .ruler-waypoint-dot {
    transform: scale(1.6);
    background: #64ffda;
    box-shadow: 0 0 10px rgba(100, 255, 218, 0.9);
}

.ruler-waypoint.passed .ruler-waypoint-dot {
    background: rgba(255, 255, 255, 0.7);
}

/* Waypoint hover badge (flyout to the left) */
.ruler-waypoint-tag {
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    background: rgba(10, 14, 18, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 10px;
    letter-spacing: 0.8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.ruler-waypoint:hover .ruler-waypoint-tag {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Scrubber Thumb (Playhead) */
.ruler-thumb {
    position: absolute;
    left: 50%;
    top: 0%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 5;
    transition: top 0.06s linear;
}

.scroll-ruler.is-dragging .ruler-thumb {
    cursor: grabbing !important;
    transition: none;
}

/* Reticle / Diamond Scrubber Icon */
.ruler-thumb-icon {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 2px solid #050505;
    border-radius: 2px;
    transform: rotate(45deg);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 18px rgba(100, 255, 218, 0.5);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, box-shadow 0.2s ease;
}

.scroll-ruler:hover .ruler-thumb-icon,
.scroll-ruler.is-dragging .ruler-thumb-icon {
    transform: rotate(45deg) scale(1.2);
    background: #64ffda;
    box-shadow: 0 0 14px rgba(100, 255, 218, 1), 0 0 28px rgba(100, 255, 218, 0.6);
}

/* Horizontal crosshair notches on sides of the thumb */
.ruler-thumb::before,
.ruler-thumb::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 5px;
    height: 1px;
    background: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}
.ruler-thumb::before {
    left: 0;
}
.ruler-thumb::after {
    right: 0;
}

/* Attached Floating Tooltip Readout */
.ruler-tooltip {
    position: absolute;
    right: 34px;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(8, 11, 15, 0.94);
    border: 1px solid rgba(100, 255, 218, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 5px 11px;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65), 0 0 14px rgba(100, 255, 218, 0.18);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    white-space: nowrap;
}

.scroll-ruler:hover .ruler-tooltip,
.scroll-ruler.is-dragging .ruler-tooltip,
.scroll-ruler.is-active .ruler-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.ruler-pct {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 11px;
    font-weight: 600;
    color: #64ffda;
    letter-spacing: 0.5px;
}

.ruler-section {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 9.5px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
}

/* Subtle telemetry pulse dot in tooltip */
.ruler-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64ffda;
    box-shadow: 0 0 6px #64ffda;
    animation: rulerPulse 1.8s infinite ease-in-out;
}

@keyframes rulerPulse {
    0%, 100% { opacity: 0.35; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Mobile & Touch breakpoint: hide on small screens to avoid obstructing content */
@media (max-width: 900px), (pointer: coarse) {
    .scroll-ruler {
        display: none !important;
    }
}
