/* ============================================================================
   GX Rate Calculator — shared component styles
   ----------------------------------------------------------------------------
   Used by /rates/ and /free-tools.html. Self-contained — relies only on CSS
   variables from sb-shared.css (--sb-ice, --sb-violet, --sb-fuchsia, etc.).

   Classes all prefixed with .idx- for the Index namespace.
   Do not add non-calculator classes here (heatmap, methodology, etc.
   stay in rates/index.html).
   ============================================================================ */

/* ── Calculator shell ───────────────────────────────────────── */
.idx-calc {
    max-width: 860px;
    margin: 0 auto;
}

.idx-calc-tabs {
    display: flex; flex-wrap: wrap; gap: 8px;
    justify-content: center;
    margin-bottom: var(--sb-space-lg);
}
.idx-calc-tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--sb-border);
    border-radius: 10px;
    color: var(--sb-text-secondary);
    font-family: var(--sb-font);
    font-size: 0.88rem; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.idx-calc-tab svg { width: 16px; height: 16px; stroke: currentColor; transition: stroke 0.25s ease; }
.idx-calc-tab:hover { color: var(--sb-text-primary); border-color: rgba(56,189,248,0.5); transform: translateY(-1px); }
.idx-calc-tab.active { background: rgba(56,189,248,0.10); border-color: var(--sb-ice); color: var(--sb-ice); box-shadow: 0 0 0 3px rgba(56,189,248,0.08); }

.idx-calc-sentence {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px;
    font-size: 1.2rem; line-height: 2.2; color: var(--sb-text-secondary); font-weight: 300;
    padding: var(--sb-space-2xl) var(--sb-space-xl); border-radius: var(--sb-radius-lg);
    background: linear-gradient(var(--sb-card-fill), var(--sb-card-fill)) padding-box, var(--sb-gradient) border-box;
    border: 1px solid transparent;
    margin-bottom: var(--sb-space-xl);
}
.idx-calc-sentence .sb-select {
    font-size: 1.1rem; font-weight: 600; color: var(--sb-ice); font-family: var(--sb-font);
    background: rgba(56,189,248,0.08); border: 1px solid rgba(56,189,248,0.3); border-radius: 8px;
    padding: 8px 34px 8px 14px; min-width: 150px; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2338BDF8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: all 0.2s ease;
}
.idx-calc-sentence .sb-select:hover { background-color: rgba(56,189,248,0.14); border-color: rgba(56,189,248,0.5); }
.idx-calc-sentence .sb-select:focus { outline: none; border-color: var(--sb-ice); box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }

/* ── Result card ────────────────────────────────────────── */
.idx-result {
    padding: var(--sb-space-2xl); border-radius: var(--sb-radius-lg); position: relative; overflow: hidden;
    background: linear-gradient(var(--sb-card-fill), var(--sb-card-fill)) padding-box, var(--sb-gradient) border-box;
    border: 1px solid transparent;
    transition: opacity 0.3s ease;
}
.idx-result.updating { opacity: 0.6; }

.idx-result-empty { text-align: center; color: var(--sb-text-muted); padding: var(--sb-space-2xl); font-size: 0.95rem; }
.idx-result-empty-icon { width: 48px; height: 48px; margin: 0 auto var(--sb-space-md); color: var(--sb-ice); opacity: 0.6; }

.idx-result-headline { text-align: center; margin-bottom: var(--sb-space-xl); }
.idx-result-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--sb-text-muted); margin-bottom: 12px; display: inline-flex; align-items: center; gap: 8px; }
.idx-result-label::before, .idx-result-label::after { content: ''; display: inline-block; width: 24px; height: 1px; background: linear-gradient(90deg, transparent, var(--sb-border)); }
.idx-result-label::after { background: linear-gradient(90deg, var(--sb-border), transparent); }
.idx-result-price {
    font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 4rem; line-height: 1;
    background: var(--sb-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
    letter-spacing: -0.02em;
}
.idx-result-range { color: var(--sb-text-secondary); font-size: 0.95rem; margin-top: 10px; letter-spacing: 0.01em; }

.idx-result-advice {
    display: inline-block; text-align: center;
    padding: 10px 18px; color: var(--sb-ice);
    font-size: 0.95rem; line-height: 1.5; font-weight: 500;
    background: rgba(var(--sb-ice-rgb), 0.12);
    border: 1px solid rgba(var(--sb-ice-rgb), 0.45);
    border-radius: 10px;
    box-shadow: 0 0 18px rgba(var(--sb-ice-rgb), 0.15), inset 0 1px 0 rgba(255,255,255,0.04);
    margin: var(--sb-space-lg) auto;
}
.idx-result-advice-wrap { text-align: center; }
.idx-result-advice strong { color: #fff; font-weight: 700; }

.idx-result-meta {
    display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center;
    padding-top: var(--sb-space-md); border-top: 1px solid var(--sb-border);
    font-size: 0.78rem; color: var(--sb-text-muted);
}
.idx-result-meta strong { color: var(--sb-text-primary); font-weight: 600; }
.idx-live-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--sb-ice); margin-right: 8px; vertical-align: middle;
    box-shadow: 0 0 6px rgba(var(--sb-ice-rgb), 0.5);
    animation: idx-breathe 3.4s ease-in-out infinite;
}
@keyframes idx-breathe {
    0%, 100% { box-shadow: 0 0 4px rgba(var(--sb-ice-rgb), 0.35), 0 0 8px rgba(var(--sb-ice-rgb), 0.15); }
    50%      { box-shadow: 0 0 10px rgba(var(--sb-ice-rgb), 0.75), 0 0 18px rgba(var(--sb-ice-rgb), 0.35); }
}
.idx-source-badge {
    display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 6px;
    border: 1px solid var(--sb-border); background: rgba(255,255,255,0.02);
    font-size: 0.75rem; color: var(--sb-text-secondary);
}

/* ── Distribution curve (p25/p50/p75/p90) ────────────────── */
.idx-curve { position: relative; margin: 32px 6px 72px; }
.idx-curve-svg { width: 100%; height: 180px; display: block; overflow: visible; cursor: crosshair; }
.idx-curve-fill { fill: url(#idx-curve-grad); opacity: 0.5; transition: opacity 0.2s ease; }
.idx-curve-stroke { fill: none; stroke: rgba(var(--sb-ice-rgb), 0.9); stroke-width: 2; filter: drop-shadow(0 0 8px rgba(var(--sb-ice-rgb),0.55)); }
.idx-curve-axis { stroke: rgba(255,255,255,0.08); stroke-width: 1; }
.idx-curve-tick-line { stroke: rgba(255,255,255,0.06); stroke-width: 1; }
.idx-curve-tick-mark { stroke: rgba(255,255,255,0.25); stroke-width: 1; }
.idx-curve-tick-label { fill: var(--sb-text-muted); font-size: 10px; font-family: 'Inter', sans-serif; text-anchor: middle; }
.idx-curve-marker { stroke: rgba(255,255,255,0.4); stroke-width: 1; stroke-dasharray: 3 4; }
.idx-curve-marker.is-p50 { stroke: #fff; stroke-width: 2.5; stroke-dasharray: none; filter: drop-shadow(0 0 6px rgba(255,255,255,0.9)) drop-shadow(0 0 14px rgba(255,255,255,0.45)); }
.idx-curve-marker.is-p90 { stroke: var(--sb-fuchsia); stroke-width: 2; stroke-dasharray: none; }
.idx-curve-dot-halo { fill: rgba(var(--sb-ice-rgb), 0.18); }
.idx-curve-dot-ring { fill: var(--sb-ice); }
.idx-curve-dot-core { fill: #fff; }
.idx-curve-caps { position: absolute; left: 0; right: 0; bottom: -52px; height: 48px; pointer-events: none; }
.idx-curve-cap { position: absolute; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.idx-curve-cap .pct { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--sb-text-muted); }
.idx-curve-cap .val { font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 0.9rem; color: var(--sb-text-primary); display: block; margin-bottom: 2px; }
.idx-curve-cap.is-p50 .val { color: var(--sb-ice); font-size: 1rem; }
.idx-curve-cap.is-p50 .pct { color: var(--sb-ice); font-weight: 700; }
.idx-curve-cap.is-p90 .pct { color: var(--sb-fuchsia); }

.idx-chart-modes {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin: 12px 0 6px;
}

.idx-curve-crosshair {
    position: absolute; top: 0; width: 1px;
    background: linear-gradient(180deg, rgba(var(--sb-ice-rgb),0) 0%, rgba(var(--sb-ice-rgb),0.6) 15%, rgba(var(--sb-ice-rgb),0.6) 100%);
    pointer-events: none; z-index: 3; box-shadow: 0 0 8px rgba(var(--sb-ice-rgb),0.5);
}
.idx-curve-tooltip {
    position: absolute; transform: translate(-50%, -100%);
    background: rgba(10,14,26,0.96); border: 1px solid rgba(var(--sb-ice-rgb),0.4);
    border-radius: 8px; padding: 6px 10px; pointer-events: none; z-index: 4;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,0.55); margin-top: -8px;
}
.idx-curve-tooltip-price { color: var(--sb-ice); font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 1rem; line-height: 1; }
.idx-curve-tooltip-pct { color: var(--sb-text-muted); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* Histogram + box plot renders inside the same SVG slots */
.idx-curve-bar { fill: url(#idx-curve-grad); opacity: 0.55; }
.idx-curve-bar-edge { fill: none; stroke: rgba(var(--sb-ice-rgb),0.7); stroke-width: 1; }
.idx-box-whisker { stroke: rgba(255,255,255,0.55); stroke-width: 2; stroke-linecap: round; }
.idx-box-box { fill: rgba(var(--sb-ice-rgb),0.18); stroke: rgba(var(--sb-ice-rgb),0.8); stroke-width: 1.5; }
.idx-box-median { stroke: #fff; stroke-width: 3; filter: drop-shadow(0 0 6px rgba(255,255,255,0.8)); }
.idx-box-p90 { stroke: var(--sb-fuchsia); stroke-width: 2; }

/* ── Mobile breakpoints ──────────────────────────────────── */
@media (max-width: 600px) {
    .idx-calc-sentence { font-size: 0.98rem; line-height: 1.9; gap: 6px; padding: var(--sb-space-lg); }
    .idx-calc-sentence .sb-select { min-width: 120px; font-size: 0.95rem; }
    .idx-result-price { font-size: 2.6rem; }
}

@media (max-width: 640px) {
    .idx-calc-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .idx-calc-tab { padding: 10px 12px; font-size: 0.78rem; width: 100%; flex: none; justify-content: center; min-height: 44px; }
    .idx-calc-tab svg { width: 14px; height: 14px; }
    .idx-calc-tab span { white-space: nowrap; }

    .idx-calc-sentence {
        display: grid; grid-template-columns: repeat(3, 1fr);
        gap: 4px 8px; padding: var(--sb-space-md); line-height: 1.4;
    }
    .idx-calc-sentence > span {
        grid-row: 1; text-align: center; font-size: 0.78rem; opacity: 0.65;
        text-transform: uppercase; letter-spacing: 0.06em; width: auto; margin: 0;
    }
    .idx-calc-sentence .sb-select {
        grid-row: 2; font-size: 15px; min-width: 0; width: 100%;
        padding: 10px 28px 10px 10px; min-height: 44px; flex: none;
        background-position: right 8px center;
    }

    .idx-result { padding: var(--sb-space-lg) var(--sb-space-md); }
    .idx-result-headline { margin-bottom: var(--sb-space-md); }
    .idx-result-label { font-size: 0.66rem; letter-spacing: 0.08em; }
    .idx-result-label::before, .idx-result-label::after { width: 16px; margin: 0 8px 3px; }
    .idx-result-range { font-size: 0.86rem; }
    .idx-result-advice { font-size: 0.92rem; padding: var(--sb-space-md); line-height: 1.55; }
    .idx-result-meta { flex-direction: column; align-items: flex-start; gap: 8px; padding-top: var(--sb-space-sm); }
    .idx-result-meta .idx-source-badge { width: 100%; justify-content: center; }
}

@media (max-width: 520px) {
    .idx-curve-svg { height: 150px; }
    .idx-curve-cap .val { font-size: 0.78rem; }
    .idx-curve-cap .pct { font-size: 0.54rem; }
    .idx-chart-modes { gap: 8px; flex-wrap: wrap; }
}

@media (max-width: 380px) {
    .idx-calc-tab { padding: 8px 10px; font-size: 0.72rem; }
    .idx-calc-tab svg { width: 12px; height: 12px; }
    .idx-result-price { font-size: 2.2rem; }
}
