/* ===========================================================================
 * Axie price analysis — build editor grid + sales chart.
 * Visual language shared with the Axie morph finder (.morph-target-grid):
 * a single purple accent, rounded panels, radial-glow backdrops, and hover/
 * focus affordances that read the same in light and dark themes.
 * ------------------------------------------------------------------------- */

.analysis {
    /* One accent drives the whole page. HSL parts so alpha is easy: hsl(var(--accent) / 0.x) */
    --accent: 260 91% 62%;
    --panel-radius: 22px;
}

/* ---------------------------------------------------------------------------
 * Build editor grid
 * The 5×5 grid-area map is unchanged — only the surface + controls are new.
 * --------------------------------------------------------------------------- */

.grid-container {
    display: grid;
}

.axie-grid-parent {
    justify-self: center;
    max-width: 860px;
    width: 100%;
    margin: 24px auto 8px;
    padding: clamp(16px, 3vw, 30px);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    grid-column-gap: 8px;
    grid-row-gap: 10px;
    align-items: center;
    border: 1px solid hsl(var(--accent) / 0.16);
    border-radius: var(--panel-radius);
    background: radial-gradient(90% 62% at 50% 0%, hsl(var(--accent) / 0.08), transparent 70%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

html.theme-light .axie-grid-parent {
    border-color: hsl(var(--accent) / 0.20);
    background: radial-gradient(90% 62% at 50% 0%, hsl(var(--accent) / 0.05), transparent 70%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

#axie-image-cell {
    position: relative;
    display: grid;
    place-items: center;
    max-width: 300px;
    grid-area: 3 / 3 / 4 / 4;
}

/* Soft accent halo behind the rendered axie */
#axie-image-cell::before {
    content: "";
    position: absolute;
    inset: -30% -20%;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(50% 50% at 50% 58%, hsl(var(--accent) / 0.16), transparent 72%);
}

#axie-canvas {
    position: relative;
    z-index: 1;
    transform: scale(2);
    width: 100%;
    object-fit: contain;
}

.axie-image {
    justify-self: center;
    align-self: center;
    object-fit: contain;
    transform: scale(2) translateY(-15%);
}

/* Part cells ---------------------------------------------------------------- */
#ears-cell  { grid-area: 2 / 4 / 2 / 6; }
#back-cell  { grid-area: 3 / 4 / 4 / 6; }
#tail-cell  { grid-area: 4 / 4 / 5 / 6; }
#mouth-cell { grid-area: 4 / 1 / 5 / 3; }
#eyes-cell  { grid-area: 3 / 1 / 4 / 3; }
#horn-cell  { grid-area: 2 / 1 / 2 / 3; }

.axie-part-container {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

.selected-part {
    display: flex;
    align-items: stretch;
    width: inherit;
}

.axie-part-image {
    margin-top: -5px;
    margin-bottom: -5px;
    object-fit: contain;
    width: clamp(30px, 8vw, 80px);
}

/* Part selector button ------------------------------------------------------ */
.select-part-button {
    justify-content: space-between;
    align-items: center;
    text-wrap: wrap;
    width: 75%;
    padding: 6px 8px;
    font-size: clamp(0.6rem, 1.5vw, 1rem);
    border: 1px solid hsl(var(--accent) / 0.18);
    border-radius: 12px;
    background: hsl(var(--accent) / 0.04);
    color: inherit;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.select-part-button:hover {
    border-color: hsl(var(--accent) / 0.45);
    background: hsl(var(--accent) / 0.10);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px hsl(var(--accent) / 0.18);
}

.select-part-button:focus-visible {
    outline: none;
    border-color: hsl(var(--accent));
    box-shadow: 0 0 0 3px hsl(var(--accent) / 0.30);
}

html.theme-light .select-part-button {
    background: hsl(var(--accent) / 0.05);
    border-color: hsl(var(--accent) / 0.22);
}
html.theme-light .select-part-button:hover {
    background: hsl(var(--accent) / 0.10);
    border-color: hsl(var(--accent) / 0.50);
}

.remove-part-icon {
    align-self: start;
    padding: 8px;
    margin-top: -3px;
    border-radius: 8px;
    opacity: 0.55;
    transition: opacity 120ms ease, background 120ms ease;
}
.remove-part-icon:hover {
    opacity: 1;
    background: hsl(0 80% 60% / 0.14);
}

#backSelectedPart,
#tailSelectedPart,
#earsSelectedPart {
    justify-content: end;
}
/* Right-side parts: the selector button is inset from the cell's right edge by
 * the stage-pill column (~45px). Match that so the filter input + dropdown line
 * up with the button/card instead of overhanging toward the edge. */
#backPartInputContainer,
#tailPartInputContainer,
#earsPartInputContainer {
    margin-right: 45px;
    align-self: end;
}

/* Evolution-stage toggles (1 / 2) as compact chips ------------------------- */
.part-stage-checkboxes {
    padding-left: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    gap: 4px;
}
.stage-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px 2px 5px;
    border-radius: 999px;
    font-size: 0.78rem;
    line-height: 1.2;
    border: 1px solid transparent;
    color: var(--bulma-text-weak, #8b8b9c);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.stage-checkbox:hover {
    background: hsl(var(--accent) / 0.08);
}
.stage-checkbox:has(input:checked) {
    color: inherit;
    border-color: hsl(var(--accent) / 0.35);
    background: hsl(var(--accent) / 0.12);
}
.stage-checkbox input[type="checkbox"] {
    accent-color: hsl(var(--accent));
    width: 13px;
    height: 13px;
    cursor: pointer;
}

/* Part search dropdown ------------------------------------------------------ */
.part-input-container {
    z-index: 20;
    width: 75%;
    height: 0;
}
.partSearchDropdown {
    z-index: 20;
    display: block;
    width: 100%;
}
.partSearchDropdown .dropdown-menu {
    width: 100%;
    min-width: 220px;
    padding-top: 6px;
}

/* Right-side parts open toward the right edge so the panel stays on-screen */
#earsSearchDropdown .dropdown-menu,
#backSearchDropdown .dropdown-menu,
#tailSearchDropdown .dropdown-menu {
    left: auto;
    right: 0;
}

/* Bounded, scrollable panel — matches the morph finder */
.partSearchDropdown .dropdown-content {
    max-height: 320px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    border: 1px solid hsl(var(--accent) / 0.22);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
}
html.theme-light .partSearchDropdown .dropdown-content {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}

.part-dropdown {
    object-fit: contain;
    width: clamp(28px, 5vw, 40px);
    height: clamp(28px, 5vw, 40px);
    flex-shrink: 0;
}
.partDropdownContent .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 8px;
    white-space: normal;
    transition: background 120ms ease;
}
.partDropdownContent .dropdown-item:hover {
    background: hsl(var(--accent) / 0.14);
    color: inherit;
}

/* Axie id lookup form ------------------------------------------------------- */
#id-cell {
    align-self: center;
    width: 80%;
    justify-self: end;
    grid-area: 1 / 4 / 2 / 6;
    font-size: clamp(0.65rem, 1.5vw, 1rem);
    margin-right: 7px;
}
#id-cell .field > label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--bulma-text-weak, #8b8b9c);
}
#id-cell form > div {
    gap: 6px;
}
#id-cell .input {
    border-radius: 9px;
}
#id-cell .input:focus {
    border-color: hsl(var(--accent));
    box-shadow: 0 0 0 3px hsl(var(--accent) / 0.22);
}
#id-cell .button.is-info {
    border-radius: 9px;
    background: hsl(var(--accent));
    border-color: transparent;
    font-weight: 600;
    transition: filter 120ms ease, transform 120ms ease;
}
#id-cell .button.is-info:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}
.id-error {
    margin-top: 6px;
    font-size: 0.72rem;
    line-height: 1.3;
    color: #ef4444;
}
.id-error[hidden] {
    display: none;
}

.loading-container,
#loading-axie {
    display: block;
    position: absolute;
    justify-self: center;
    align-self: end;
    height: 60px;
    z-index: 2;
}

/* Class filter (3×3 icon grid) --------------------------------------------- */
#class-cell {
    display: grid;
    align-content: center;
    grid-area: 1 / 3 / 3 / 4;
}
.checkboxes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 5px;
    place-items: center;
    text-align: center;
}
.class-checkbox {
    display: flex;
    line-height: 0;
}
/* Visually hidden but still focusable (keyboard + screen reader), unlike display:none */
.class-checkbox input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    margin: 0;
}
.class-checkbox input[type="checkbox"]:focus-visible + .checkbox-image {
    outline: 2px solid hsl(var(--accent));
    outline-offset: 2px;
}
.checkbox-image {
    width: clamp(20px, 5vw, 40px);
    height: clamp(20px, 5vw, 40px);
    cursor: pointer;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 9px;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}
.class-checkbox:hover .checkbox-image {
    transform: scale(1.08);
    background: hsl(var(--accent) / 0.10);
}
.class-checkbox input[type="checkbox"]:checked + .checkbox-image {
    border-color: hsl(var(--accent));
    background: hsl(var(--accent) / 0.18);
    box-shadow: 0 0 10px hsl(var(--accent) / 0.45);
}

/* Range sliders (level / evolved / breed) ---------------------------------- */
#breed-cell {
    min-width: 340px;
    display: flex;
    gap: 10px;
    grid-area: 5 / 2 / 6 / 5;
}
.slider-container {
    justify-items: center;
    display: grid;
    height: 55%;
}
.slider-col {
    width: 84%;
}
.slider {
    height: 6px;
    border: none;
    border-radius: 999px;
    background: hsl(var(--accent) / 0.14);
    box-shadow: none;
}
html.theme-light .slider {
    background: hsl(var(--accent) / 0.12);
}
.slider .noUi-connects {
    border-radius: 999px;
}
.slider .noUi-connect {
    background: hsl(var(--accent));
}
.slider .noUi-handle {
    height: 15px;
    width: 15px;
    top: -5px;
    right: -7px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid hsl(var(--accent));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
    cursor: grab;
}
.slider .noUi-handle:active {
    cursor: grabbing;
}
.slider .noUi-handle:focus {
    outline: none;
    box-shadow: 0 0 0 4px hsl(var(--accent) / 0.25);
}
.noUi-handle:before,
.noUi-handle:after {
    display: none;
}

.slider-inputs-row {
    font-size: clamp(0.6rem, 1.5vw, 1rem);
    display: flex;
    width: 84%;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}
.slider-inputs-row > span {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bulma-text-weak, #8b8b9c);
}
.slider-min,
.slider-max {
    width: 30%;
}
.slider-input {
    padding: 3px;
    text-align: center;
    border-radius: 8px;
}
.slider-input:focus {
    border-color: hsl(var(--accent));
    box-shadow: 0 0 0 3px hsl(var(--accent) / 0.20);
}

/* ---------------------------------------------------------------------------
 * Sales chart section
 * --------------------------------------------------------------------------- */

.analysis-chart {
    max-width: 1280px;
    margin: 28px auto 8px;
    padding: 0 16px;
}

.analysis-chart__head {
    text-align: center;
    margin-bottom: 14px;
}
.analysis-chart__eyebrow {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: hsl(var(--accent) / 0.95);
}
html.theme-light .analysis-chart__eyebrow {
    color: hsl(260 70% 48%);
}
.analysis-chart__title {
    margin: 2px 0 0;
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.analysis-chart__sub {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--bulma-text-weak, #8b8b9c);
}

/* Chart controls row: time window + price unit + skin toggle */
.analysis-chart__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 14px 0 4px;
}

/* Segmented toggles (time window + price unit) */
.unit-toggle,
.range-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: hsl(var(--accent) / 0.08);
    border: 1px solid hsl(var(--accent) / 0.16);
}
.unit-btn,
.range-btn {
    border: none;
    background: transparent;
    color: var(--bulma-text-weak, #8b8b9c);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 4px 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}
.unit-btn:hover,
.range-btn:hover {
    color: inherit;
}
.unit-btn.is-active,
.range-btn.is-active {
    background: hsl(var(--accent));
    color: #fff;
}
.unit-btn:focus-visible,
.range-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--accent) / 0.30);
}

/* Include skins/collectibles checkbox */
.skin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    color: var(--bulma-text-weak, #8b8b9c);
    cursor: pointer;
}
.skin-toggle:hover {
    color: inherit;
}
.skin-toggle input[type="checkbox"] {
    accent-color: hsl(var(--accent));
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* Summary statistics strip */
.analysis-chart__stats {
    margin-top: 12px;
}
.stat-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 92px;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid hsl(var(--accent) / 0.14);
    background: hsl(var(--accent) / 0.04);
}
.stat-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bulma-text-weak, #8b8b9c);
}
.stat-value {
    margin-top: 2px;
    font-size: 0.98rem;
    font-weight: 700;
    white-space: nowrap;
}
.stat-note {
    margin: 8px 0 0;
    text-align: center;
    font-size: 0.72rem;
    color: var(--bulma-text-weak, #8b8b9c);
}

.chart-scroll-container {
    overflow-x: auto;
    overscroll-behavior-x: contain;
}
.chart-container {
    position: relative;
    margin-right: 10px;
    padding: 14px 16px 8px;
    height: 70vh;
    min-width: 1000px;
    border: 1px solid hsl(var(--accent) / 0.14);
    border-radius: 16px;
    background: hsl(var(--accent) / 0.03);
}
html.theme-light .chart-container {
    border-color: hsl(var(--accent) / 0.16);
    background: hsl(var(--accent) / 0.02);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

/* Empty-state / error message shown in place of the chart */
.chart-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--bulma-text-weak, #8b8b9c);
    pointer-events: none;
}
/* Error variant: a non-blocking top banner that keeps the chart visible under it */
.chart-status.is-error {
    inset: 12px 12px auto 12px;
    padding: 10px 14px;
    color: #fff;
    background: #ef4444;
    border-radius: 10px;
    font-size: 0.85rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.chart-status[hidden] {
    display: none;
}

/* Chart hover card (rendered by axieAnalysis.js) --------------------------- */
#chart-tooltip {
    display: none;
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    position: absolute;
    z-index: 100;
}
#chart-tooltip .card {
    width: clamp(100px, 25vw, 250px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
#chart-tooltip .card-content {
    padding: 10px;
}
.axie-card-info {
    width: 100%;
    padding: 5px;
    position: absolute;
    display: flex;
    flex-direction: column;
}
.axie-card-info-row1 {
    display: flex;
    justify-content: end;
    align-items: center;
}
.axie-card-info-row2 {
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.breed-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.egg-icon {
    width: clamp(10px, 3vw, 30px);
}

@media (max-width: 600px) {
    .axie-grid-parent {
        padding: 12px;
        grid-column-gap: 4px;
        grid-row-gap: 6px;
    }
    .chart-container {
        padding: 8px 8px 4px;
    }
}

/* ---------------------------------------------------------------------------
 * Insight charts (distribution / value drivers / liquidity)
 * Smaller panels below the hero chart. Share the .analysis accent + eyebrow.
 * --------------------------------------------------------------------------- */
.analysis-insights {
    max-width: 1280px;
    margin: 10px auto 24px;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.insight-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
@media (max-width: 760px) {
    .insight-row {
        grid-template-columns: 1fr;
    }
}

.insight-card {
    display: flex;
    flex-direction: column;
    padding: 16px 18px 14px;
    border: 1px solid hsl(var(--accent) / 0.14);
    border-radius: 16px;
    background: hsl(var(--accent) / 0.03);
}
html.theme-light .insight-card {
    border-color: hsl(var(--accent) / 0.16);
    background: hsl(var(--accent) / 0.02);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.insight-card__head {
    margin-bottom: 6px;
}
.insight-card__title {
    margin: 2px 0 0;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.insight-card__sub {
    margin: 3px 0 0;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--bulma-text-weak, #8b8b9c);
}

.insight-card__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 10px 0 2px;
}

/* Lever selector — segmented pill, same language as the range/unit toggles */
.lever-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: hsl(var(--accent) / 0.08);
    border: 1px solid hsl(var(--accent) / 0.16);
}
.lever-btn {
    border: none;
    background: transparent;
    color: var(--bulma-text-weak, #8b8b9c);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 4px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}
.lever-btn:hover:not(:disabled) {
    color: inherit;
}
.lever-btn.is-active {
    background: hsl(var(--accent));
    color: #fff;
}
.lever-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.lever-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--accent) / 0.30);
}

/* "Test a price" input on the distribution strip */
.yourprice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bulma-text-weak, #8b8b9c);
}
.yourprice__unit {
    font-weight: 700;
    text-transform: none;
    color: inherit;
}
.yourprice__input {
    width: 96px;
    border-radius: 8px;
    text-transform: none;
    letter-spacing: normal;
}
.yourprice__input:focus {
    border-color: hsl(var(--accent));
    box-shadow: 0 0 0 3px hsl(var(--accent) / 0.20);
}
.yourprice__result {
    font-size: 0.8rem;
    font-weight: 600;
    color: hsl(var(--accent) / 0.95);
}
html.theme-light .yourprice__result {
    color: hsl(260 70% 48%);
}

.insight-chart {
    position: relative;
    height: 260px;
    margin-top: 8px;
}
.insight-chart--strip {
    height: 150px;
}

.insight-caption {
    margin: 10px 0 0;
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--bulma-text-weak, #8b8b9c);
}
.insight-caption--metrics {
    margin: 6px 0 0;
    font-weight: 600;
    color: inherit;
}
.insight-caption:empty {
    display: none;
}
