/**
 * Up West Coffee - Artisanal "Pour Fill" Scroll Indicator
 * A discreet, luxury liquid coffee vertical fill rail with dynamic fluid motion,
 * crema meniscus wave, micro-bubbles, and pour stream.
 * 
 * Engineered with dynamic header clearance so it starts safely below
 * the header and MENU button both when the header is large (before scroll)
 * and after scroll shrinks it.
 */

:root {
    --upwest-pour-track-bg: rgba(26, 13, 4, 0.06);
    --upwest-pour-track-border: rgba(26, 13, 4, 0.12);
    --upwest-pour-track-border-hover: rgba(212, 155, 106, 0.35);
    --upwest-pour-espresso: #1a0b04;
    --upwest-pour-amber: #542910;
    --upwest-pour-roast: #8a4619;
    --upwest-pour-crema: #d49b6a;
    --upwest-pour-foam: #edd5bc;
    --upwest-pour-glow: rgba(212, 155, 106, 0.45);
    --upwest-pour-top: 175px; /* Safe default before scroll shrinks the tall header */
    --upwest-pour-bottom: 36px;
    --upwest-pour-width: 9px;
    --upwest-pour-width-hover: 13px;
}

/* ==========================================================================
   0. Hide Default Browser Scrollbar
   ========================================================================== */

/* Standard (Firefox, Chrome 121+, Safari 18+) */
html:not(.show-default-scrollbar),
html:not(.show-default-scrollbar) body {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

/* WebKit / Chromium (Chrome, Safari, Edge, Opera, Brave) */
html:not(.show-default-scrollbar)::-webkit-scrollbar,
html:not(.show-default-scrollbar) body::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
    background: transparent !important;
}

/* ==========================================================================
   1. Base Track: Floating Minimalist Laboratory Glass Column
   ========================================================================== */

.upwest-pour-track {
    position: fixed;
    top: var(--upwest-pour-top, 175px);
    bottom: var(--upwest-pour-bottom, 36px);
    right: 14px;
    width: var(--upwest-pour-width, 9px);
    z-index: 999; /* Positioned below sticky header (1000+) to never block navigation */
    background: var(--upwest-pour-track-bg);
    border: 1px solid var(--upwest-pour-track-border);
    border-radius: 999px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 
        inset 0 1px 3px rgba(0, 0, 0, 0.08),
        0 4px 20px rgba(0, 0, 0, 0.06);
    overflow: visible;
    cursor: pointer;
    transition: top 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                width 0.25s cubic-bezier(0.16, 1, 0.3, 1), 
                border-color 0.25s ease,
                background-color 0.25s ease,
                box-shadow 0.25s ease;
    user-select: none;
    -webkit-user-select: none;
}

/* Noticeable Hover Expansion for Tactile Feedback */
.upwest-pour-track:hover {
    width: var(--upwest-pour-width-hover, 13px);
    background: rgba(26, 13, 4, 0.08);
    border-color: var(--upwest-pour-track-border-hover);
    box-shadow: 
        inset 0 1px 4px rgba(0, 0, 0, 0.12),
        0 6px 24px rgba(26, 13, 4, 0.12),
        0 0 12px var(--upwest-pour-glow);
}

/* Position Options */
.upwest-pour-track.pos-left {
    right: auto;
    left: 14px;
}

/* Inner Glass Cylinder (Clips the Liquid) */
.upwest-pour-cylinder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    overflow: hidden;
    background: transparent;
}

/* Carafe / Extraction Level Markings (25%, 50%, 75%) */
.upwest-pour-mark {
    position: absolute;
    right: 100%;
    margin-right: 4px;
    width: 4px;
    height: 1.5px;
    background: rgba(26, 13, 4, 0.2);
    border-radius: 1px;
    pointer-events: none;
    transition: all 0.3s ease;
}

.upwest-pour-track.pos-left .upwest-pour-mark {
    right: auto;
    left: 100%;
    margin-right: 0;
    margin-left: 4px;
}

.upwest-pour-mark.mark-25 { bottom: 25%; }
.upwest-pour-mark.mark-50 { bottom: 50%; width: 6px; }
.upwest-pour-mark.mark-75 { bottom: 75%; }

.upwest-pour-mark.is-filled {
    background: var(--upwest-pour-crema);
    box-shadow: 0 0 5px var(--upwest-pour-glow);
}

/* ==========================================================================
   2. Pour Stream: The Fine Espresso Stream Pouring Down During Scroll
   ========================================================================== */

.upwest-pour-stream {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(1);
    width: 2px;
    height: 0%; /* Dynamically updated by JS to reach the liquid surface */
    background: linear-gradient(
        180deg,
        rgba(212, 155, 106, 0.95) 0%,
        rgba(138, 70, 25, 0.85) 50%,
        rgba(26, 11, 4, 0.95) 100%
    );
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(212, 155, 106, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease, width 0.2s ease;
    z-index: 3;
}

/* Active pouring state */
.upwest-pour-track.is-pouring .upwest-pour-stream {
    opacity: 1;
}

/* Animated drip droplet trailing down the stream */
.upwest-pour-stream::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--upwest-pour-crema);
    box-shadow: 0 0 6px var(--upwest-pour-crema);
    animation: pourDripPulse 0.4s infinite alternate ease-in-out;
}

@keyframes pourDripPulse {
    0% { transform: translateX(-50%) scale(0.85); opacity: 0.8; }
    100% { transform: translateX(-50%) scale(1.2); opacity: 1; }
}

/* ==========================================================================
   3. The Coffee Liquid Column
   ========================================================================== */

.upwest-pour-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%; /* Dynamically updated by scroll progress */
    background: linear-gradient(
        180deg,
        #b87b46 0%,
        #7c3f1a 18%,
        #4a230e 45%,
        #240f06 75%,
        #120602 100%
    );
    border-radius: 0 0 999px 999px;
    transition: height 0.08s linear;
    z-index: 2;
    overflow: visible;
}

/* Full fill rounds the top */
.upwest-pour-liquid.is-full {
    border-radius: 999px;
}

/* Golden Crema Top Meniscus */
.upwest-pour-crema-head {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(
        180deg,
        rgba(237, 213, 188, 0.95) 0%,
        rgba(212, 155, 106, 0.9) 50%,
        rgba(124, 63, 26, 0.4) 100%
    );
    box-shadow: 0 0 8px rgba(212, 155, 106, 0.6);
    border-radius: 999px 999px 0 0;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 4;
}

/* Micro Fluid Wave Surface (SVG) */
.upwest-pour-wave-wrap {
    position: absolute;
    top: -4px;
    left: -2px;
    width: calc(100% + 4px);
    height: 6px;
    overflow: hidden;
    pointer-events: none;
    z-index: 5;
}

.upwest-pour-wave-wrap svg {
    width: 200%;
    height: 100%;
    fill: var(--upwest-pour-crema);
    transform: translateX(0);
    animation: waveSlosh 2.2s infinite linear;
}

@keyframes waveSlosh {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Crema Micro-Bubbles inside the liquid */
.upwest-pour-bubble {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: rgba(237, 213, 188, 0.75);
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    animation: bubbleRise 2.8s infinite ease-in;
}

.upwest-pour-bubble:nth-child(1) { left: 25%; animation-delay: 0.3s; animation-duration: 2.4s; }
.upwest-pour-bubble:nth-child(2) { left: 65%; animation-delay: 1.1s; animation-duration: 3.1s; }
.upwest-pour-bubble:nth-child(3) { left: 40%; animation-delay: 1.9s; animation-duration: 2.7s; }

@keyframes bubbleRise {
    0% {
        bottom: 0%;
        opacity: 0;
        transform: scale(0.5);
    }
    20% {
        opacity: 0.8;
        transform: scale(1);
    }
    90% {
        opacity: 0.6;
    }
    100% {
        bottom: 98%;
        opacity: 0;
        transform: scale(1.3);
    }
}

/* ==========================================================================
   4. Interactive Badge Tooltip (Shown on Hover / Scrub Only)
   ========================================================================== */

.upwest-pour-badge {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    padding: 5px 9px 5px 8px;
    background: rgba(26, 13, 4, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    color: #f7eee7;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 10;
}

.upwest-pour-track.pos-left .upwest-pour-badge {
    right: auto;
    left: calc(100% + 10px);
    transform: translateY(-50%) translateX(-6px);
}

.upwest-pour-badge-icon {
    font-size: 11px;
    line-height: 1;
    color: var(--upwest-pour-crema);
}

/* Show badge ONLY on hover or scrubbing to prevent covering text during normal reading */
.upwest-pour-track:hover .upwest-pour-badge,
.upwest-pour-track.show-badge .upwest-pour-badge {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ==========================================================================
   5. Responsive & Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .upwest-pour-track svg,
    .upwest-pour-bubble,
    .upwest-pour-stream::after {
        animation: none !important;
    }
    .upwest-pour-stream {
        display: none !important;
    }
    .upwest-pour-liquid {
        transition: height 0.2s ease-out;
    }
}

/* Mobile Screen Adjustments */
@media (max-width: 768px) {
    .upwest-pour-track {
        right: 6px;
        top: 80px;
        bottom: 20px;
        width: 6px;
    }
    .upwest-pour-track:hover {
        width: 8px;
    }
    .upwest-pour-track.pos-left {
        left: 6px;
        right: auto;
    }
    .upwest-pour-badge {
        display: none;
    }
    .upwest-pour-mark {
        display: none;
    }
}
