/* ===========================================================================
 * Axie evolution cost calculator (/evolution-cost)
 * Self-contained. Blue "ascend" accent (matching the in-game evolution badge),
 * class-coloured part chips, theme-aware via html.theme-light / html.theme-dark.
 * ------------------------------------------------------------------------- */
.evo {
    --accent: 210 92% 56%;   /* evolution blue */
    --amber: 38 92% 50%;     /* AXS fee */
    --good: 145 63% 42%;     /* savings green */
    max-width: 940px;
    margin: 0 auto;
    padding: 22px 16px 48px;
}

/* Class colours (chips + memento tags) ----------------------------------- */
.evo {
    --cls-beast: #f0921f;
    --cls-aquatic: #00b7d4;
    --cls-plant: #63b900;
    --cls-bird: #ff6fa5;
    --cls-bug: #ff5f42;
    --cls-reptile: #b06fe0;
    --cls-mech: #8598a0;
    --cls-dawn: #b79bf0;
    --cls-dusk: #2b7f92;
    --cls-unknown: #8b8b9c;
}

/* Head -------------------------------------------------------------------- */
.evo-head { text-align: center; max-width: 720px; margin: 6px auto 20px; }
.evo-eyebrow {
    margin: 0; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.14em;
    text-transform: uppercase; color: hsl(var(--accent));
    display: inline-flex; align-items: center; gap: 7px;
}
.evo-ascend {
    display: inline-grid; place-items: center; width: 18px; height: 18px;
    border-radius: 999px; background: hsl(var(--accent)); color: #fff;
    font-size: 0.6rem; font-weight: 900; letter-spacing: -1px; line-height: 1;
    transform: translateY(-1px);
}
.evo-title {
    margin: 4px 0 0; font-size: clamp(1.6rem, 4.5vw, 2.3rem);
    font-weight: 800; letter-spacing: -0.02em;
}
.evo-sub {
    margin: 8px auto 0; max-width: 620px; font-size: 0.92rem; line-height: 1.55;
    color: var(--bulma-text-weak, #8b8b9c);
}
.evo-sub strong { color: var(--bulma-text-strong, inherit); font-weight: 700; }

/* Search ------------------------------------------------------------------ */
.evo-search {
    display: flex; gap: 8px; justify-content: center;
    max-width: 460px; margin: 18px auto 0;
}
.evo-search__input {
    flex: 1 1 auto; min-width: 0; padding: 11px 14px;
    font-size: 1rem; border-radius: 11px;
    border: 1.5px solid hsl(var(--accent) / 0.3);
    background: var(--bulma-scheme-main, #14141b); color: inherit;
    -moz-appearance: textfield;
}
.evo-search__input::-webkit-outer-spin-button,
.evo-search__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.evo-search__input:focus { outline: none; border-color: hsl(var(--accent)); box-shadow: 0 0 0 3px hsl(var(--accent) / 0.16); }
.evo-search__btn {
    flex: 0 0 auto; padding: 0 20px; font-size: 0.95rem; font-weight: 700;
    color: #fff; background: hsl(var(--accent)); border: none; border-radius: 11px;
    cursor: pointer; transition: filter .12s ease;
}
.evo-search__btn:hover { filter: brightness(1.08); }

/* Error ------------------------------------------------------------------- */
.evo-error {
    display: flex; align-items: center; gap: 12px; max-width: 560px;
    margin: 22px auto 0; padding: 14px 18px; border-radius: 12px;
    border: 1px solid hsl(0 70% 55% / 0.35); background: hsl(0 70% 55% / 0.07);
    color: var(--bulma-text-strong, inherit);
}
.evo-error__icon {
    flex: 0 0 auto; display: grid; place-items: center; width: 26px; height: 26px;
    border-radius: 999px; background: hsl(0 70% 55%); color: #fff; font-weight: 900;
}
.evo-error p { margin: 0; font-size: 0.92rem; }

/* Result shell ------------------------------------------------------------ */
.evo-result { margin-top: 22px; }

/* Axie header ------------------------------------------------------------- */
.evo-axie {
    display: flex; align-items: center; gap: 16px 20px; flex-wrap: wrap;
    padding: 12px 16px; border-radius: 14px;
    border: 1px solid var(--bulma-border-weak, #2a2a38);
    background: var(--bulma-scheme-main-bis, #1a1a24);
}
.evo-axie__main { display: flex; align-items: center; gap: 14px; min-width: 0; }
/* Class-tinted portrait so the header carries the axie's identity at a glance. */
.evo-axie__portrait {
    flex: 0 0 auto; width: 84px; height: 84px; border-radius: 16px; overflow: hidden;
    display: grid; place-items: center;
    background:
        radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--c, var(--cls-unknown)) 26%, transparent), transparent 68%),
        color-mix(in srgb, var(--c, var(--cls-unknown)) 9%, transparent);
    border: 1px solid color-mix(in srgb, var(--c, var(--cls-unknown)) 26%, transparent);
}
.evo-axie__img { width: 100%; height: 100%; object-fit: contain; }
.evo-axie__meta { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.evo-axie__id { font-size: 1.05rem; font-weight: 800; color: inherit; text-decoration: none; }
.evo-axie__id:hover { color: hsl(var(--accent)); }
.evo-axie__tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* Already-evolved parts, shown on the right of the header */
.evo-axie__done { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; text-align: right; }
.evo-axie__done-icons { display: flex; gap: 6px; }
.evo-axie__done-label { font-size: 0.75rem; color: var(--bulma-text-weak, #8b8b9c); cursor: help; }
.evo-axie__done-label b { color: var(--bulma-text-strong, inherit); font-weight: 800; font-variant-numeric: tabular-nums; }

/* Chips ------------------------------------------------------------------- */
.evo-chip {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 700; text-transform: capitalize;
    letter-spacing: 0.01em; line-height: 1.5;
    color: var(--c, var(--cls-unknown));
    background: color-mix(in srgb, var(--c, var(--cls-unknown)) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--c, var(--cls-unknown)) 45%, transparent);
}
.evo-chip--soft {
    color: var(--bulma-text-weak, #9a9aad);
    background: var(--bulma-background, #23232f);
    border-color: var(--bulma-border-weak, #33333f);
    text-transform: none;
}
.cls-beast   { --c: var(--cls-beast); }
.cls-aquatic { --c: var(--cls-aquatic); }
.cls-plant   { --c: var(--cls-plant); }
.cls-bird    { --c: var(--cls-bird); }
.cls-bug     { --c: var(--cls-bug); }
.cls-reptile { --c: var(--cls-reptile); }
.cls-mech    { --c: var(--cls-mech); }
.cls-dawn    { --c: var(--cls-dawn); }
.cls-dusk    { --c: var(--cls-dusk); }
.cls-unknown { --c: var(--cls-unknown); }

/* Part icon token (class-tinted; holds the CDN part art, tidy placeholder if it 404s) */
.evo-icon {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px;
    display: grid; place-items: center; overflow: hidden;
    background: color-mix(in srgb, var(--c, var(--cls-unknown)) 13%, transparent);
    border: 1px solid color-mix(in srgb, var(--c, var(--cls-unknown)) 24%, transparent);
}
.evo-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.evo-icon--sm { width: 30px; height: 30px; border-radius: 8px; }

/* Notice ------------------------------------------------------------------ */
.evo-notice {
    margin: 12px 0 0; padding: 9px 13px; border-radius: 10px; font-size: 0.82rem;
    color: hsl(var(--amber)); border: 1px solid hsl(var(--amber) / 0.32);
    background: hsl(var(--amber) / 0.07);
}

/* Controls ---------------------------------------------------------------- */
.evo-controls {
    display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
    margin: 18px 0 10px;
}
.evo-seg {
    display: inline-flex; padding: 3px; border-radius: 10px; gap: 2px;
    background: var(--bulma-background, #23232f); border: 1px solid var(--bulma-border-weak, #33333f);
}
.evo-seg__btn {
    padding: 5px 14px; font-size: 0.8rem; font-weight: 700; border: none; border-radius: 7px;
    background: transparent; color: var(--bulma-text-weak, #9a9aad); cursor: pointer;
}
.evo-seg__btn.is-active { background: hsl(var(--accent)); color: #fff; }

.evo-reset {
    margin-left: auto; padding: 6px 13px; font-size: 0.8rem; font-weight: 700;
    color: hsl(var(--accent)); background: transparent; cursor: pointer;
    border: 1px solid hsl(var(--accent) / 0.4); border-radius: 9px;
}
.evo-reset:hover { background: hsl(var(--accent) / 0.1); }

/* Savings banner ---------------------------------------------------------- */
.evo-savings {
    margin: 4px 0 14px; padding: 8px 13px; border-radius: 10px; font-size: 0.85rem; font-weight: 600;
}
.evo-savings.is-optimal {
    color: hsl(var(--good)); border: 1px solid hsl(var(--good) / 0.3); background: hsl(var(--good) / 0.08);
}
.evo-savings.is-suboptimal {
    color: hsl(var(--amber)); border: 1px solid hsl(var(--amber) / 0.32); background: hsl(var(--amber) / 0.08);
}
.evo-savings b { font-weight: 800; }

/* Plan hint --------------------------------------------------------------- */
.evo-planhint {
    margin: 2px 2px 11px; font-size: 0.8rem; line-height: 1.5;
    color: var(--bulma-text-weak, #8b8b9c);
}
.evo-planhint b { color: hsl(var(--amber)); font-weight: 700; }
.evo-planhint__k {
    font-size: 0.7rem; letter-spacing: 1px; color: var(--bulma-text-weak, #9a9aad);
    border: 1px solid var(--bulma-border-weak, #33333f); border-radius: 5px; padding: 0 5px;
}

/* Plan (ordered part list) ------------------------------------------------ */
.evo-plan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.evo-row {
    display: grid;
    grid-template-columns: 24px 46px 42px minmax(0, 1fr) auto auto;
    grid-template-areas:
        "handle pos icon id     cost moves"
        "handle pos icon detail cost moves";
    align-items: center; column-gap: 12px; row-gap: 5px;
    padding: 11px 14px; border-radius: 13px;
    border: 1px solid var(--bulma-border-weak, #2a2a38);
    background: var(--bulma-scheme-main-bis, #1a1a24);
    transition: border-color .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.evo-row__handle { grid-area: handle; }
.evo-row__pos { grid-area: pos; }
.evo-row > .evo-icon { grid-area: icon; }
.evo-row__id { grid-area: id; }
.evo-row__detail { grid-area: detail; }
.evo-row__cost { grid-area: cost; }
.evo-row__moves { grid-area: moves; }
.evo-row.is-dragging { opacity: 0.45; }
.evo-row.is-over { border-color: hsl(var(--accent)); box-shadow: 0 0 0 2px hsl(var(--accent) / 0.25); }
.evo-row.is-flipping { z-index: 2; }
/* Brief highlight on the row the user just moved */
.evo-row--moved { animation: evo-move-pulse .5s ease; }
@keyframes evo-move-pulse {
    0%   { background: hsl(var(--accent) / 0.22); border-color: hsl(var(--accent) / 0.6); }
    100% { background: var(--bulma-scheme-main-bis, #1a1a24); }
}
html.theme-light .evo-row--moved { animation: evo-move-pulse-light .5s ease; }
@keyframes evo-move-pulse-light {
    0%   { background: hsl(var(--accent) / 0.16); border-color: hsl(var(--accent) / 0.6); }
    100% { background: #fff; }
}
@media (prefers-reduced-motion: reduce) {
    .evo-row--moved { animation: none; }
}

.evo-row__handle {
    cursor: grab; color: var(--bulma-text-weak, #7a7a8c); font-size: 1rem;
    text-align: center; line-height: 1; touch-action: none;
}
.evo-row__handle:active { cursor: grabbing; }

/* Position token — which step in the evolution sequence this part is (order, not quantity) */
.evo-row__pos {
    display: grid; place-items: center;
    width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto;
    background: hsl(var(--accent) / 0.1); color: hsl(var(--accent));
    font-variant-numeric: tabular-nums; line-height: 1;
}
.evo-row__pos span { display: inline-flex; align-items: baseline; }
.evo-row__pos b { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.evo-row__pos small { font-size: 0.62rem; font-weight: 700; }

.evo-row__id { min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.evo-row__detail { min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.evo-row__detail .evo-instant { margin-left: auto; }
.evo-row__slot { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bulma-text-weak, #8b8b9c); }
.evo-row__name { font-size: 0.95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evo-row__mem { font-size: 0.78rem; color: var(--bulma-text-weak, #9a9aad); font-variant-numeric: tabular-nums; }
.evo-row__mem b { color: inherit; font-weight: 800; }
.evo-mem-icon { width: 19px; height: 19px; object-fit: contain; vertical-align: -5px; margin: 0 1px; }
.evo-badge-radiant {
    font-size: 0.68rem; font-weight: 700; color: hsl(280 60% 62%);
    background: hsl(280 60% 62% / 0.12); border: 1px solid hsl(280 60% 62% / 0.4);
    padding: 1px 7px; border-radius: 999px;
}
/* Collectible part that evolves WITHOUT a shell (Nightmare) — muted, so it reads as "recognised, no cost". */
.evo-badge-noshell {
    font-size: 0.66rem; font-weight: 600; text-transform: capitalize;
    color: var(--bulma-text-weak, #8b8b9c);
    background: var(--bulma-background, #23232f); border: 1px solid var(--bulma-border-weak, #33333f);
    padding: 1px 7px; border-radius: 999px;
}

/* Per-part instant "rush" toggle */
.evo-instant {
    font-size: 0.68rem; font-weight: 700; cursor: pointer; line-height: 1.5;
    padding: 1px 8px; border-radius: 999px;
    color: var(--bulma-text-weak, #8b8b9c);
    background: transparent; border: 1px solid var(--bulma-border-weak, #3a3a48);
    transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.evo-instant:hover { color: hsl(var(--amber)); border-color: hsl(var(--amber) / 0.5); }
.evo-instant.is-on {
    color: #fff; background: hsl(var(--amber)); border-color: hsl(var(--amber));
}
.evo-instant:focus-visible { outline: 2px solid hsl(var(--amber) / 0.5); outline-offset: 1px; }

.evo-row__cost { text-align: right; font-variant-numeric: tabular-nums; }
.evo-row__cost b { font-size: 1rem; font-weight: 800; }
.evo-row__cost small { display: block; font-size: 0.68rem; color: var(--bulma-text-weak, #8b8b9c); }
.evo-row__cost.is-na b { font-size: 0.8rem; font-weight: 600; color: var(--bulma-text-weak, #8b8b9c); }

.evo-row__moves { display: flex; flex-direction: column; gap: 2px; }
.evo-row__moves button {
    width: 24px; height: 20px; padding: 0; line-height: 1; cursor: pointer;
    border: 1px solid var(--bulma-border-weak, #33333f); border-radius: 6px;
    background: var(--bulma-background, #23232f); color: var(--bulma-text-weak, #9a9aad); font-size: 0.7rem;
}
.evo-row__moves button:hover:not(:disabled) { color: hsl(var(--accent)); border-color: hsl(var(--accent) / 0.5); }
.evo-row__moves button:disabled { opacity: 0.3; cursor: default; }

/* Totals ------------------------------------------------------------------ */
.evo-totals {
    margin-top: 20px; padding: 18px; border-radius: 16px;
    border: 1px solid hsl(var(--accent) / 0.25);
    background: linear-gradient(180deg, hsl(var(--accent) / 0.08), transparent 70%), var(--bulma-scheme-main-bis, #1a1a24);
}
.evo-total-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.evo-total-head__label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--bulma-text-weak, #8b8b9c); }
.evo-total-grand { font-size: clamp(1.9rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.evo-total-full { margin-top: 7px; font-size: 0.82rem; color: var(--bulma-text-weak, #8b8b9c); cursor: help; }
.evo-total-full b { color: var(--bulma-text-strong, inherit); font-weight: 800; font-variant-numeric: tabular-nums; }
.evo-total-alt { font-size: 0.9rem; color: var(--bulma-text-weak, #9a9aad); font-weight: 600; }

.evo-total-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
    margin-top: 16px;
}
.evo-total-cell {
    padding: 11px 13px; border-radius: 11px;
    background: var(--bulma-scheme-main, #14141b); border: 1px solid var(--bulma-border-weak, #2a2a38);
}
.evo-total-cell__k { font-size: 0.72rem; color: var(--bulma-text-weak, #8b8b9c); font-weight: 600; }
.evo-total-cell__v { font-size: 1.05rem; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.evo-total-cell__sub { font-size: 0.72rem; color: var(--bulma-text-weak, #8b8b9c); margin-top: 2px; }

.evo-mem-breakdown { margin-top: 14px; }
.evo-mem-breakdown__label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bulma-text-weak, #8b8b9c); }
.evo-mem-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.evo-mem-row { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.evo-mem-row__count { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
.evo-mem-row__cost { min-width: 74px; text-align: right; color: var(--bulma-text-weak, #9a9aad); font-variant-numeric: tabular-nums; }

/* Methodology ------------------------------------------------------------- */
.evo-method { margin-top: 22px; border-top: 1px solid var(--bulma-border-weak, #2a2a38); padding-top: 10px; }
.evo-method summary { cursor: pointer; font-size: 0.85rem; font-weight: 700; color: var(--bulma-text-weak, #9a9aad); }
.evo-method summary:hover { color: hsl(var(--accent)); }
.evo-method__body { font-size: 0.84rem; line-height: 1.6; color: var(--bulma-text-weak, #8b8b9c); }
.evo-method__body ul { margin: 10px 0 0; padding-left: 18px; }
.evo-method__body li { margin-bottom: 7px; }
.evo-method__body strong { color: var(--bulma-text-strong, inherit); }

/* Light theme nudges ------------------------------------------------------ */
html.theme-light .evo-search__input { background: #fff; }
html.theme-light .evo-axie,
html.theme-light .evo-row,
html.theme-light .evo-total-cell { background: #fff; }
html.theme-light .evo-totals { background: linear-gradient(180deg, hsl(var(--accent) / 0.07), transparent 70%), #fff; }
html.theme-light .evo-eyebrow { color: hsl(210 80% 46%); }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 560px) {
    /* Slim side gutters so the content gets the width. */
    .evo { padding-left: 9px; padding-right: 9px; }
    .evo-plan { gap: 7px; }
    /* The name is dropped (the large icon identifies the part). Identity band: step · big icon · class · cost;
       quantity band (memento · shell · Instant) runs underneath on one line; the ▲▼ arrows are a vertically
       centred rail down the right of the whole card. */
    .evo-row {
        grid-template-columns: auto auto minmax(0, 1fr) auto auto;
        grid-template-areas:
            "pos icon id     cost   moves"
            "detail detail detail detail moves";
        column-gap: 9px; row-gap: 5px; padding: 9px 10px;
    }
    .evo-row__handle { display: none; }
    .evo-row__name { display: none; }
    .evo-shell-n { display: none; }                 /* compact shell badge: "◈ $4.36" */
    .evo-row__pos { width: 36px; height: 36px; }
    .evo-row__pos b { font-size: 1rem; }
    .evo-icon { width: 48px; height: 48px; border-radius: 12px; }
    .evo-row__cost b { font-size: 0.95rem; }
    .evo-row__moves { display: flex; align-self: center; justify-self: center; }
    .evo-badge-radiant, .evo-badge-noshell { white-space: nowrap; }
    .evo-axie { padding: 11px 12px; }
    .evo-axie__portrait { width: 72px; height: 72px; border-radius: 14px; }
    .evo-axie__done { margin-left: 0; flex-direction: row; align-items: center; gap: 10px; text-align: left; flex-wrap: wrap; }
}
