/* =========================================================================
 * ETA countdown — ring (popup) + slim time bar (compact surfaces)
 * Driven by --eta-fraction (0..1) and data-eta-state on [data-opt-eta-wrap]
 * ========================================================================= */

[data-opt-eta-wrap] {
    --eta-fraction: 1;
    --eta-accent: var(--primary-color, #0d9488);
    --eta-accent-soft: color-mix(in srgb, var(--eta-accent) 18%, transparent);
}

[data-opt-eta-wrap][data-eta-state="closing"] {
    --eta-accent: #d97706;
}

[data-opt-eta-wrap][data-eta-state="overrun"] {
    --eta-accent: #dc2626;
}

[data-opt-eta-value] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Hide spinner when ring countdown is visible */
.popup-eta-ring:not([hidden]) + .popup-spinner {
    display: none !important;
}

.popup-eta-ring[hidden] {
    display: none !important;
}

.popup-eta-ring {
    position: relative;
    width: 148px;
    height: 148px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
}

.popup-eta-ring-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.popup-eta-ring-track,
.popup-eta-ring-progress {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
}

.popup-eta-ring-track {
    stroke: var(--bg-tertiary, #e5e7eb);
    opacity: 0.9;
}

.popup-eta-ring-progress {
    stroke: var(--eta-accent);
    stroke-dasharray: 100;
    stroke-dashoffset: calc(100 - (var(--eta-fraction) * 100));
    transition: stroke-dashoffset 0.85s linear, stroke 0.35s ease;
    filter: drop-shadow(0 0 6px var(--eta-accent-soft));
}

.popup-eta-ring-center {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0 0.75rem;
    text-align: center;
}

.popup-eta-ring-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-primary, #0f172a);
    line-height: 1.1;
}

.popup-eta-ring-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #64748b);
    max-width: 7.5rem;
    line-height: 1.2;
}

.popup-eta-ring[data-eta-state="closing"] .popup-eta-ring-value {
    color: #b45309;
}

.popup-eta-ring[data-eta-state="overrun"] .popup-eta-ring-value {
    color: #dc2626;
}

.popup-eta-ring[data-eta-state="overrun"] {
    animation: eta-overrun-pulse 1.6s ease-in-out infinite;
}

@keyframes eta-overrun-pulse {
    0%, 100% { transform: scale(1); filter: none; }
    50% { transform: scale(1.03); filter: drop-shadow(0 0 12px rgba(220, 38, 38, 0.35)); }
}

@media (prefers-reduced-motion: reduce) {
    .popup-eta-ring[data-eta-state="overrun"] {
        animation: none;
    }
    .popup-eta-ring-progress {
        transition: none;
    }
}

/* Compact ETA: countdown row + single labeled time meter */
.wq-eta-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.wq-eta-row [data-opt-eta-label] {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
}

.wq-eta-value,
.wq-eta-row [data-opt-eta-value] {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary, #0f172a);
    line-height: 1.1;
}

.wq-eta-meter {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 0.45rem;
    border-radius: 999px;
    background: var(--bg-tertiary, #e5e7eb);
    overflow: hidden;
}

.wq-eta-meter-fill {
    display: block;
    height: 100%;
    width: calc(var(--eta-fraction) * 100%);
    border-radius: inherit;
    background: linear-gradient(90deg, var(--eta-accent), color-mix(in srgb, var(--eta-accent) 70%, white));
    transition: width 0.85s linear, background 0.35s ease;
}

.wq-eta-caption {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary, #64748b);
}

.wq-running-eta,
.progress-eta {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0;
}

.wq-running-eta[data-eta-state="closing"] .wq-eta-value,
.wq-running-eta[data-eta-state="closing"] [data-opt-eta-value],
.progress-eta[data-eta-state="closing"] .wq-eta-value,
.progress-eta[data-eta-state="closing"] [data-opt-eta-value] {
    color: #b45309;
}

.wq-running-eta[data-eta-state="overrun"] .wq-eta-value,
.wq-running-eta[data-eta-state="overrun"] [data-opt-eta-value],
.progress-eta[data-eta-state="overrun"] .wq-eta-value,
.progress-eta[data-eta-state="overrun"] [data-opt-eta-value] {
    color: #dc2626;
    font-weight: 800;
}

.wq-running-eta[data-eta-state="closing"] .wq-eta-caption,
.progress-eta[data-eta-state="closing"] .wq-eta-caption {
    color: #b45309;
}

.wq-running-eta[data-eta-state="overrun"] .wq-eta-caption,
.progress-eta[data-eta-state="overrun"] .wq-eta-caption {
    color: #dc2626;
}

@media (prefers-reduced-motion: reduce) {
    .wq-eta-meter-fill {
        transition: none;
    }
}
