/* ============================================================================
   PriceScope — interactive market time-machine chart
   Apple Liquid Glass surfaces, built on the site's --cc-* design tokens.
   ========================================================================== */

.ps-panel {
    position: relative;
    margin-top: 18px;
    border-radius: 22px;
    padding: 22px 22px 18px;
    background: var(--cc-glass);
    border: 1px solid var(--cc-glass-line);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    backdrop-filter: saturate(180%) blur(30px);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.45) inset,
        0 30px 60px -40px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    isolation: isolate;
}

/* specular top edge */
.ps-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    pointer-events: none;
}

.ps-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.ps-title-wrap { display: flex; flex-direction: column; gap: 2px; }

.ps-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cc-ink-3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.ps-title .ps-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--cc-accent);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--cc-accent) 22%, transparent);
}

/* Big headline price with tabular-nums roll */
.ps-headline {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
.ps-price {
    font-size: clamp(30px, 6vw, 44px);
    font-weight: 700;
    line-height: 1.02;
    color: var(--cc-ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.ps-delta {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    background: color-mix(in oklab, var(--cc-ink-3) 12%, transparent);
    color: var(--cc-ink-2);
}
.ps-delta.up   { color: var(--cc-success); background: color-mix(in oklab, var(--cc-success) 14%, transparent); }
.ps-delta.down { color: var(--cc-danger);  background: color-mix(in oklab, var(--cc-danger) 14%, transparent); }
.ps-asof {
    font-size: 12px;
    color: var(--cc-ink-3);
    font-variant-numeric: tabular-nums;
}

/* variant segmented control — glass pills */
.ps-variants {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.ps-pill {
    appearance: none;
    border: 1px solid var(--cc-glass-line);
    background: color-mix(in oklab, var(--cc-glass) 60%, transparent);
    color: var(--cc-ink-2);
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition:
        transform 0.4s var(--cc-ease-glass),
        background 0.3s var(--cc-ease-glass),
        color 0.3s var(--cc-ease-glass),
        box-shadow 0.3s var(--cc-ease-glass);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    line-height: 1;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.ps-pill:hover { transform: translateY(-1px); }
.ps-pill .ps-swatch {
    width: 9px; height: 9px; border-radius: 3px;
    background: currentColor;
    opacity: 0.9;
}
.ps-pill[aria-pressed="true"] {
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px -10px var(--ps-swatch-color, var(--cc-accent));
    background: var(--ps-swatch-color, var(--cc-accent));
}
.ps-pill[aria-pressed="true"] .ps-swatch { background: rgba(255,255,255,0.92); }
.ps-pill[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }

/* chart well */
.ps-chart-wrap {
    position: relative;
    width: 100%;
    margin-top: 4px;
}
.ps-chart {
    width: 100%;
    height: 280px;
    position: relative;
}
.ps-chart .u-axis text,
.ps-chart .u-legend { font-variant-numeric: tabular-nums; }

/* uPlot overrides to fit the glass theme */
.ps-chart .uplot,
.ps-chart .u-wrap { font-family: inherit; }
.ps-chart .u-legend { display: none; }
.ps-chart .u-axis { color: var(--cc-ink-3); }

/* frosted cursor tooltip */
.ps-tip {
    position: absolute;
    z-index: 6;
    pointer-events: none;
    min-width: 132px;
    padding: 9px 11px;
    border-radius: 13px;
    background: var(--cc-glass);
    border: 1px solid var(--cc-glass-line);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 18px 40px -22px rgba(0,0,0,0.6);
    transform: translate(-50%, -120%);
    opacity: 0;
    transition: opacity 0.14s ease;
    font-variant-numeric: tabular-nums;
}
.ps-tip.show { opacity: 1; }
.ps-tip-date { font-size: 11px; color: var(--cc-ink-3); margin-bottom: 5px; }
.ps-tip-row { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--cc-ink); margin-top: 2px; }
.ps-tip-row .ps-swatch { width: 8px; height: 8px; border-radius: 2px; }
.ps-tip-row .ps-tip-val { margin-left: auto; font-weight: 700; }

/* toolbar row: MA toggle + range chips */
.ps-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.ps-toggle {
    appearance: none;
    border: 1px solid var(--cc-glass-line);
    background: color-mix(in oklab, var(--cc-glass) 55%, transparent);
    color: var(--cc-ink-2);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.3s var(--cc-ease-glass);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.ps-toggle[aria-pressed="true"] {
    color: var(--cc-ink);
    border-color: color-mix(in oklab, var(--cc-accent) 50%, var(--cc-glass-line));
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--cc-accent) 30%, transparent);
}
.ps-spacer { flex: 1 1 auto; }
.ps-range { display: inline-flex; gap: 4px; }
.ps-range button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--cc-ink-3);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s var(--cc-ease-glass);
}
.ps-range button[aria-pressed="true"] {
    color: var(--cc-ink);
    background: color-mix(in oklab, var(--cc-ink-3) 14%, transparent);
}

/* timeline scrubber */
.ps-scrub {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--cc-glass-line);
}
.ps-scrub-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--cc-ink-3);
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}
.ps-track {
    position: relative;
    height: 26px;
    cursor: ew-resize;
    touch-action: none;
}
.ps-track-rail {
    position: absolute;
    top: 50%;
    left: 0; right: 0;
    height: 4px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: color-mix(in oklab, var(--cc-ink-3) 24%, transparent);
    overflow: hidden;
}
.ps-track-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 100%;
    background: linear-gradient(90deg,
        color-mix(in oklab, var(--cc-accent) 35%, transparent),
        var(--cc-accent));
    border-radius: 999px;
}
.ps-thumb {
    position: absolute;
    top: 50%;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--cc-glass-line);
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 14px -4px rgba(0,0,0,0.5), 0 0 0 4px color-mix(in oklab, var(--cc-accent) 18%, transparent);
    transition: box-shadow 0.2s var(--cc-ease-glass);
}
.ps-track:active .ps-thumb,
.ps-track:focus-within .ps-thumb {
    box-shadow: 0 4px 14px -4px rgba(0,0,0,0.5), 0 0 0 6px color-mix(in oklab, var(--cc-accent) 28%, transparent);
}

/* what-if calculator */
.ps-whatif {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 16px;
    background: color-mix(in oklab, var(--cc-glass) 70%, transparent);
    border: 1px solid var(--cc-glass-line);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
}
.ps-whatif-q {
    font-size: 13.5px;
    color: var(--cc-ink-2);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ps-whatif-q b { color: var(--cc-ink); font-variant-numeric: tabular-nums; }
.ps-amount {
    width: 96px;
    border: 1px solid var(--cc-glass-line);
    background: var(--cc-glass);
    color: var(--cc-ink);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.ps-whatif-out {
    margin-left: auto;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.ps-whatif-out .ps-roi {
    font-size: 22px;
    font-weight: 700;
}
.ps-whatif-out .ps-roi.up   { color: var(--cc-success); }
.ps-whatif-out .ps-roi.down { color: var(--cc-danger); }
.ps-whatif-out .ps-roi-sub {
    font-size: 12px;
    color: var(--cc-ink-3);
}

/* states */
.ps-state {
    padding: 36px 18px;
    text-align: center;
    color: var(--cc-ink-3);
    font-size: 14px;
}
.ps-state .ps-state-icon {
    font-size: 26px;
    display: block;
    margin-bottom: 8px;
    opacity: 0.7;
}
.ps-skel {
    height: 280px;
    border-radius: 14px;
    background: linear-gradient(100deg,
        color-mix(in oklab, var(--cc-ink-3) 8%, transparent) 30%,
        color-mix(in oklab, var(--cc-ink-3) 16%, transparent) 50%,
        color-mix(in oklab, var(--cc-ink-3) 8%, transparent) 70%);
    background-size: 200% 100%;
    animation: ps-shimmer 1.3s linear infinite;
}
@keyframes ps-shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
    .ps-pill, .ps-toggle, .ps-thumb, .ps-tip, .ps-range button { transition: none !important; }
    .ps-skel { animation: none; }
}

@media (max-width: 560px) {
    .ps-chart { height: 230px; }
    .ps-whatif-out { margin-left: 0; width: 100%; text-align: left; }
}
