/* =====================================================================
   HOME Challenges (docs/10-trackers-round-2.md), on top of css/pkmn.css
   and css/living-dex.css (tokens, bar, search, toggles, slots, toast).

   07's identity: hairline cards, mono wayfinding, gold for done, HOME blue
   for the page accent, red only for the Pokémon Bank warning. Mobile first
   (390px); from 960px By game gets a rail of origin games on the left.
   ===================================================================== */

.hm-main {
    max-width: 46rem;
    margin: 0 auto;
    padding: 0 var(--gutter) 2.5rem;
}
.hm-head .ld-lede em { font-style: normal; color: var(--paper); }
.hm-cross { margin-top: 0.7rem; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; }
.hm-cross a { color: var(--home-ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.hm-cross a:hover { border-bottom-color: var(--home); }

/* ---- overview ---- */
.hm-overview { padding: 0 0 1rem; }
.hm-meter { margin-bottom: 0.45rem; }
.hm-cats {
    list-style: none;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem;
    margin-top: 0.8rem;
}
.hm-cat-chip {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0.3rem 0.5rem;
    width: 100%; min-height: var(--tap);
    padding: 0.45rem 0.65rem 0.5rem;
    background: var(--ground-2); border: 1px solid var(--rule);
    font-family: var(--mono); font-size: 0.68rem; text-align: left;
    cursor: pointer;
}
.hm-cat-chip:hover { border-color: var(--paper-dim); }
.hm-cat-name { text-transform: uppercase; letter-spacing: 0.12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-cat-n { color: var(--paper-dim); white-space: nowrap; }
.hm-cat-n b { color: var(--paper); }
.hm-cat-chip.is-complete .hm-cat-n b { color: var(--gold-ink); }
.hm-cat-meter { grid-column: 1 / -1; height: 3px; background: var(--rule); }
.hm-cat-meter span { display: block; height: 100%; background: var(--gold); }

/* ---- sticky bar: view switch + search ---- */
.hm-bar { grid-template-areas: "views" "tools" "meta"; }
.hm-views { grid-area: views; display: flex; }
.hm-views .seg-btn { flex: 1 1 0; }

/* ---- shared: one challenge ---- */
.hm-ch {
    position: relative;
    margin-bottom: 0.6rem;
    background: var(--ground-2);
    border: 1px solid var(--rule);
}
.hm-ch::before {
    content: ""; position: absolute; top: -1px; left: -1px;
    width: 1.6rem; height: 3px; background: var(--rule);
}
.hm-ch.is-done::before { background: var(--gold); width: 2.4rem; }
.hm-ch-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.hm-tick {
    display: flex; align-items: flex-start; gap: 0.65rem;
    width: 100%; min-height: var(--tap);
    padding: 0.7rem 0.4rem 0.5rem 0.75rem;
    background: transparent; border: 0;
    text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.hm-tick .ld-check { margin-top: 0.22rem; }
.hm-tick.is-static { cursor: default; padding-left: 0.75rem; }
.hm-ch-text { font-size: 0.9rem; line-height: 1.4; }
.hm-tick:hover .hm-ch-text { color: var(--paper); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.hm-tick[aria-pressed="true"] > .ld-check { background: var(--gold); border-color: var(--gold); }
.hm-tick[aria-pressed="true"] > .ld-check::after { border-color: var(--ground); }
.hm-ch.is-done .hm-ch-text { color: var(--paper-dim); }
.hm-ch-n {
    padding: 0.78rem 0.75rem 0 0.3rem;
    font-family: var(--mono); font-size: 0.68rem; color: var(--paper-dim); white-space: nowrap;
}
.hm-ch-n b { color: var(--paper); }
.hm-ch.is-done .hm-ch-n b { color: var(--gold-ink); }
.hm-ch-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem;
    padding: 0 0.75rem 0.65rem 2.2rem;
}
.hm-ch-meta:empty { display: none; }
.hm-reward::before { content: "Reward "; color: var(--paper-dim); }
.hm-reward {
    font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.06em;
    color: var(--gold-ink);
    padding: 0.12rem 0.4rem; border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--rule));
}
.hm-from, .hm-from-any {
    font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.04em;
    padding: 0.12rem 0.4rem;
    background: transparent; border: 1px solid var(--rule);
    color: var(--paper-dim);
}
.hm-from { cursor: pointer; min-height: 1.6rem; }
.hm-from:hover { color: var(--paper); border-color: var(--home); }
.hm-from[data-bank]::before {
    content: ""; display: inline-block; vertical-align: 0.05em;
    width: 0.4rem; height: 0.4rem; margin-right: 0.35rem; background: var(--red);
}
.hm-from-any { border-style: dashed; }
.hm-ch-note {
    margin: -0.2rem 0.75rem 0.65rem 2.2rem;
    padding-left: 0.6rem; border-left: 1px solid var(--rule);
    font-size: 0.76rem; color: var(--paper-dim); line-height: 1.45;
}

/* species of a challenge: box-style slots (the Living Dex slot styles) */
.hm-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 3px; padding: 4px;
    border-top: 1px solid var(--rule);
    background: var(--ground);
}
.hm-slot.is-hit .slot-btn { border-color: var(--home); border-style: solid; }
/* docs/12 form requirements: species name, then the form ("Combat Breed") */
.hm-grid.has-forms .slot-btn { height: 100%; min-height: 5.3rem; }
.hm-grid.has-forms .slot-art { flex: 1 0 auto; }
.slot-form {
    width: 100%;
    font-family: var(--mono); font-size: 0.52rem; line-height: 1.15;
    color: var(--home-ink); text-align: center;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}
.slot.is-caught .slot-form { color: var(--gold-ink); }
.hm-slot.just-caught .slot-img { animation: ld-settle 0.22s ease-out; }

/* docs/11 trade challenges: one tick; the Pokémon are pictures only */
.hm-pics {
    list-style: none; margin: 0; padding: 0.45rem 0.75rem 0.65rem 2.2rem;
    display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem;
}
.hm-pic { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.hm-pic .slot-art { width: 40px; height: 30px; display: grid; place-items: center; flex: none; }
.hm-pic .slot-img { width: 40px; height: 30px; image-rendering: pixelated; filter: grayscale(0.6); opacity: 0.85; }
.hm-ch.is-done .hm-pic .slot-img { filter: none; opacity: 1; }
.hm-pic-name { font-family: var(--mono); font-size: 0.62rem; color: var(--paper-dim); }
.hm-pic.is-hit .hm-pic-name { color: var(--paper); text-decoration: underline; text-decoration-color: var(--home); }

/* docs/11 legacy cutover: the countdown before, the Legacy tag after */
.hm-legacy {
    font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.04em;
    padding: 0.12rem 0.4rem;
    color: var(--paper); border: 1px dashed var(--red);
}
.hm-legacy.is-past { color: var(--paper-dim); border-color: var(--rule); }
.hm-ch.is-legacy { border-style: dashed; }
.hm-countdown {
    display: flex; align-items: center; gap: 0.7rem;
    margin-top: 0.7rem; padding: 0.5rem 0.65rem;
    border: 1px solid var(--red);
}
.hm-countdown-n {
    font-family: var(--mono); font-size: 1.35rem; font-weight: 700; line-height: 1;
    color: var(--paper); min-width: 2.2rem; text-align: center;
}
.hm-countdown-text { font-size: 0.8rem; line-height: 1.4; color: var(--paper-dim); }

/* count: a stepper */
.hm-step {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
    padding: 0.55rem 0.75rem 0.75rem;
    border-top: 1px solid var(--rule);
}
.hm-step-btn {
    width: var(--tap); height: var(--tap);
    background: transparent; border: 1px solid var(--rule);
    font-family: var(--mono); font-size: 1.05rem; line-height: 1;
    cursor: pointer;
}
.hm-step-btn:hover { border-color: var(--paper-dim); }
.hm-step-n input {
    width: 4.2rem; height: var(--tap);
    background: var(--ground); border: 1px solid var(--rule); border-radius: 0;
    color: var(--paper); text-align: center;
    font-family: var(--mono); font-size: 0.95rem;
    -moz-appearance: textfield; appearance: textfield;
}
.hm-step-n input::-webkit-inner-spin-button, .hm-step-n input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.hm-step-n input:focus-visible { outline: 2px solid var(--red); outline-offset: -1px; }
.hm-step-of { font-family: var(--mono); font-size: 0.8rem; color: var(--paper-dim); margin-right: 0.15rem; }
.hm-step-bar {
    position: relative; flex: 1 1 100%; order: 5;
    height: 4px; margin-top: 0.35rem; background: var(--rule);
}
.hm-step-bar > span { display: block; height: 100%; background: var(--gold); }
.hm-tier {
    position: absolute; top: -3px; width: 2px; height: 10px; margin-left: -1px;
    background: var(--paper-dim);
}
.hm-tier.is-on { background: var(--gold-ink); }
.hm-tiers { flex: 1 1 100%; order: 6; font-family: var(--mono); font-size: 0.62rem; color: var(--paper-dim); }
.hm-tier-n { font-weight: 400; color: var(--paper); }
.hm-tier-n.is-on { color: var(--gold-ink); }

/* ---- collapsible groups (docs/12 "As built") ---- */
.hm-fold {
    display: flex; align-items: center; gap: 0.6rem;
    width: 100%; min-height: var(--tap);
    padding: 0; margin: 0;
    background: transparent; border: 0; color: inherit;
    font: inherit; text-transform: inherit; letter-spacing: inherit; text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.hm-fold:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.hm-chev {
    flex: none; width: 0.5rem; height: 0.5rem; margin: 0 0.15rem 0 0.1rem;
    border-right: 1.5px solid var(--home-ink); border-bottom: 1.5px solid var(--home-ink);
    transform: translateY(-0.12rem) rotate(45deg);
    transition: transform 0.15s ease-out;
}
.hm-fold[aria-expanded="false"] .hm-chev { transform: rotate(-45deg); }
.hm-fold-body[hidden] { display: none !important; }
.hm-fold-bar { display: flex; justify-content: flex-end; margin: 0 0 0.6rem; }
.hm-fold-bar .ld-btn { min-height: 2.1rem; font-size: 0.62rem; }
.hm-fold-bar [hidden] { display: none; }

/* ---- By challenge ---- */
.hm-cat { margin-bottom: 1.6rem; scroll-margin-top: 7rem; }
.hm-cat.is-collapsed { margin-bottom: 0.4rem; }
.hm-cat-h { margin: 0; font: inherit; }
.hm-cat-head {
    padding: 0.2rem 0 0.5rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 0.7rem;
}
.hm-cat.is-collapsed .hm-cat-head { margin-bottom: 0; }
.hm-cat-head .hm-cat-count { margin-left: auto; white-space: nowrap; }
.hm-cat-head:hover .hm-cat-title { color: var(--paper); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.hm-cat-title {
    font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.16em;
}
.hm-cat-count { font-family: var(--mono); font-size: 0.72rem; color: var(--paper-dim); }
.hm-cat-count b { color: var(--paper); }
.hm-cat-about { margin: -0.2rem 0 0.8rem; font-size: 0.84rem; color: var(--paper-dim); }
.hm-empty-line { font-size: 0.86rem; color: var(--paper-dim); padding: 0.4rem 0 0.8rem; }

/* ---- By game ---- */
.hm-pick { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.hm-pick select {
    width: 100%; min-height: var(--tap);
    padding: 0 2.2rem 0 0.75rem;
    background: var(--ground-2) no-repeat right 0.8rem center / 0.7rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a9a595' stroke-width='1.4'/%3E%3C/svg%3E");
    border: 1px solid var(--paper-dim); border-radius: 0;
    color: var(--paper);
    font-family: var(--mono); font-size: 0.8rem;
    -webkit-appearance: none; appearance: none;
}
.hm-pick select:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
.hm-rail { display: none; }

.hm-game-head { margin-bottom: 1.1rem; }
.hm-game-k {
    font-family: var(--mono); font-size: 0.64rem;
    text-transform: uppercase; letter-spacing: 0.18em; color: var(--home-ink);
}
.hm-game-k:empty { display: none; }
.hm-game-name {
    font-size: 1.45rem; font-weight: 800; letter-spacing: -0.015em; line-height: 1.15;
    margin-top: 0.2rem;
}
.hm-bank {
    display: inline-block; vertical-align: 0.1em;
    margin-left: 0.6rem; padding: 0 0.45rem;
    border: 1px solid var(--red); color: var(--paper);
    font-family: var(--mono); font-size: 0.58rem; font-weight: 400; letter-spacing: 0.12em;
    text-transform: uppercase; white-space: nowrap;
}
.hm-game-warn { font-size: 0.84rem; }
.hm-game .pn-note { font-size: 0.84rem; margin-top: 0.6rem; }
.hm-game-stats { margin-top: 0.7rem; font-family: var(--mono); font-size: 0.72rem; color: var(--paper-dim); }
.hm-game-stats b { color: var(--paper); }
.hm-elsewhere { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin: -0.3rem 0 1rem; }
.hm-elsewhere .ld-label { margin-right: 0.3rem; }

.hm-sec { margin-bottom: 1.3rem; }
.hm-sec.is-collapsed { margin-bottom: 0.4rem; }
.hm-sec-h { margin: 0 0 0.4rem; font: inherit; }
.hm-sec-head { border-top: 1px solid var(--rule); }
.hm-sec-k { margin: 0; }
.hm-sec-n { margin-left: auto; font-family: var(--mono); font-size: 0.68rem; color: var(--paper-dim); }
.hm-sec-n b { color: var(--paper); }

.hm-mons { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.45rem; }
.hm-mon {
    display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: 0.7rem;
    padding: 4px 0.7rem 4px 4px;
    background: var(--ground-2);
    border: 1px solid var(--rule);
}
.hm-mon.is-done { border-color: var(--gold-line); }
.hm-mon .slot-btn { height: 4.2rem; }
.hm-mon .slot-name { display: none; }
.hm-mon-body { padding: 0.35rem 0 0.3rem; min-width: 0; }
.hm-mon-name { font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.hm-mon.is-done .hm-mon-name { color: var(--gold-ink); }
.hm-mon-list { list-style: none; margin-top: 0.25rem; }
.hm-mon-ch {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem;
    padding: 0.18rem 0;
    font-size: 0.76rem; line-height: 1.35; color: var(--paper-dim);
}
.hm-mon-ch + .hm-mon-ch { border-top: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); }
.hm-mon-ch .hm-ch-n { padding: 0; font-size: 0.64rem; }
.hm-mon-ch.is-done .hm-ch-n b { color: var(--gold-ink); }

@media (min-width: 600px) {
    .hm-bar {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas: "views tools" "meta meta";
    }
    .hm-views .seg-btn { flex: 0 0 auto; }
    .hm-cats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .hm-mons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hm-mon .slot-btn { height: 4.6rem; }
    .hm-mon .slot-img { width: 48px; height: 36px; }
    .hm-grid { gap: 4px; padding: 5px; }
}

@media (min-width: 960px) {
    .hm-main { max-width: 74rem; }
    .hm-head, .hm-overview { max-width: 46rem; }
    .hm-bygame {
        display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); gap: 0 1.6rem;
        align-items: start;
    }
    .hm-pick { display: none; }
    .hm-rail {
        display: block;
        position: sticky; top: 4.6rem;
        max-height: calc(100vh - 5.2rem); overflow-y: auto;
        border: 1px solid var(--rule); background: var(--ground-2);
        padding: 0.3rem 0 0.6rem;
    }
    .hm-rail-k {
        padding: 0.3rem 0.8rem 0;
        font-family: var(--mono); font-size: 0.6rem;
        text-transform: uppercase; letter-spacing: 0.18em; color: var(--paper-dim);
    }
    .hm-rail-fold { min-height: 2.2rem; gap: 0.5rem; }
    .hm-rail-k-name { min-width: 0; }
    .hm-rail-k-n { margin-left: auto; letter-spacing: 0.04em; white-space: nowrap; }
    .hm-rail-fold:hover .hm-rail-k-name { color: var(--paper); }
    .hm-rail-list { list-style: none; }
    .hm-rail-btn {
        position: relative;
        display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
        width: 100%; min-height: 2.3rem;
        padding: 0.35rem 0.8rem;
        background: transparent; border: 0;
        font-size: 0.82rem; text-align: left;
        cursor: pointer;
    }
    .hm-rail-btn:hover { background: var(--ground); }
    .hm-rail-btn[aria-pressed="true"] { background: var(--panel-2); }
    .hm-rail-btn[aria-pressed="true"]::before {
        content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--home);
    }
    .hm-rail-name { min-width: 0; }
    .hm-rail-n { font-family: var(--mono); font-size: 0.66rem; color: var(--paper-dim); white-space: nowrap; }
    .hm-rail-n b { color: var(--paper); }
    .hm-rail-btn.is-clear .hm-rail-name { color: var(--paper-dim); }
    .hm-rail-btn.is-clear .hm-rail-n { color: var(--gold-ink); }
    /* By challenge: two columns of cards per category */
    .hm-cat-body {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 0.8rem; align-items: start;
    }
    .hm-cat-body > .hm-cat-about, .hm-cat-body > .hm-empty-line { grid-column: 1 / -1; }
    .hm-cat-body > .hm-ch { margin-bottom: 0.8rem; }
}


/* ---- docs/12: Challenges | Research Tasks tabs ---- */
.hm-tabs { display: flex; margin-top: 1.1rem; }
.hm-tabs[hidden] { display: none; }
.hm-tab { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.hm-tab[aria-selected="true"] { background: var(--paper); color: var(--ground); }
.hm-tab-n { font-size: 0.64rem; letter-spacing: 0.04em; opacity: 0.75; }
.hm-tab-n:empty { display: none; }
.hm-views .seg-btn[hidden] { display: none; }
@media (min-width: 600px) {
    .hm-tabs { display: inline-flex; }
    .hm-tab { flex: 0 0 auto; padding: 0 1.1rem; }
}
