/* ── BH trainer (bh.html). Builds on learn.css and sheets.css ─────────── */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.bh .deck-card {
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.bh-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2) var(--sp-4);
}

.bh-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-4);
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.bh-stats b {
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
}

.bh-subset,
.bh-settings,
.bh-actions,
.bh-smart-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-4);
}

.bh-subset[hidden],
.bh-type[hidden],
.bh-story[hidden],
.bh-cube[hidden],
.bh-cube-body[hidden],
.bh-cube-cover[hidden] {
    display: none;
}

.bh-prompt {
    margin-top: var(--sp-2);
}

/* The question */

.bh-question {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4) var(--sp-6);
    padding: var(--sp-4);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.bh-picture {
    width: min(220px, 60vw);
    aspect-ratio: 1;
}

/* Flash: the picture has gone; answer from memory */
.bh-picture {
    position: relative;
}

.bh-picture.is-flashed > * {
    visibility: hidden;
}

.bh-picture.is-flashed::after {
    content: "?";
    position: absolute;
    inset: 12%;
    display: grid;
    place-items: center;
    border-radius: var(--r-md, 8px);
    background: var(--surface-2);
    color: var(--text-3);
    font: 700 48px / 1 var(--font-sans);
}

.bh-picture svg,
.bh-answer-pic svg {
    display: block;
    width: 100%;
    height: 100%;
}

.bh-story-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 200px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bh-story-list li {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: 6px 10px;
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.bh-story-list b {
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
}

.bh-story-list s {
    color: var(--text-3);
    font-weight: 400;
}

.bh-story-list .is-current {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.bh-story-list .is-right {
    background: var(--good-soft);
}

.bh-story-list .is-wrong {
    background: var(--bad-soft);
}

.bh-feedback {
    min-height: 1.5em;
    font-size: var(--fs-md);
    font-weight: 500;
}

.bh-feedback[data-kind="good"] { color: var(--good); }
.bh-feedback[data-kind="bad"] { color: var(--bad); }
.bh-feedback[data-kind="warn"] { color: var(--warn); }

.bh-type {
    display: flex;
    gap: var(--sp-2);
}

.bh-type .input {
    flex: 1;
    min-width: 0;
    max-width: 360px;
    height: 34px;
}

/* Answer buttons */

.bh-answers {
    display: grid;
    gap: var(--sp-2);
}

.bh-answers.is-patterns,
.bh-answers.is-cases {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.bh-answers.is-names {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

/* Two rows of six, like the Q–Y and A–H keys */
@media (min-width: 641px) {
    .bh-answers.is-patterns {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

/* The key that picks this answer */
.bh-key {
    position: absolute;
    top: 5px;
    left: 6px;
    min-width: 18px;
    padding: 1px 4px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-3);
    font: 600 11px / 1.3 var(--font-mono, monospace);
    text-align: center;
    pointer-events: none;
}

.bh-answer {
    position: relative;
}

.bh-answers.is-patterns .bh-answer {
    cursor: grab;
}

.bh-answer.is-dragging {
    opacity: 0.4;
}

.bh-answer.is-drop {
    outline: 2px dashed var(--accent);
    outline-offset: 2px;
}

.bh-answer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border: 2px solid transparent;
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text);
    font: 500 var(--fs-sm) var(--font-mono);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.bh-answer:hover {
    background: var(--surface-3);
}

.bh-answer:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.bh-answers.is-names .bh-answer {
    padding: 10px 6px;
}

.bh-answer-pic {
    display: block;
    width: 72px;
    height: 72px;
}

.bh-answer-img {
    display: block;
    width: 100%;
    max-width: 84px;
    aspect-ratio: 1;
}

.bh-answer-name {
    overflow-wrap: anywhere;
    text-align: center;
}

/* With case pictures, the names (which can give the BH pattern away) show after you answer */
.bh-answers.is-cases:not(.is-done) [data-reveal] {
    visibility: hidden;
}

.bh-answer.is-right {
    border-color: var(--good);
    background: var(--good-soft);
}

.bh-answer.is-wrong {
    border-color: var(--bad);
    background: var(--bad-soft);
}

.bh-actions kbd {
    margin-left: 6px;
    opacity: 0.8;
}

/* Virtual cube */

.bh-cube {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--line);
}

.bh-cube-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.bh-cube-wrap {
    position: relative;
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.bh .bh-cube #virtualCubeContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: min(40vh, 300px);
    overflow: hidden;
}

.bh-cube-cover {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.bh-smart {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.smart-status {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.smart-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--surface-3);
}

.smart-dot[data-state="on"] { background: var(--good); }
.smart-dot[data-state="busy"] { background: var(--warn); }

/* By pattern */

.bh-pattern {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--line);
}

.bh-pattern[hidden],
.bh-grade[hidden],
.bh-reveal[hidden],
.bh-scramble[hidden],
.bh-answers[hidden],
.bh .field[hidden],
.bh .btn[hidden] {
    display: none;
}

.bh-chips,
.bh-grade {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.bh-grade {
    gap: var(--sp-2);
}

.bh-p-details summary {
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
}

.bh-p-details[open] {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.bh-p-count {
    margin-left: var(--sp-2);
    color: var(--text-2);
    font-weight: 400;
}

#bhPGrid {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.bh-p-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-2);
}

.bh-p-head h3 {
    font-size: var(--fs-sm);
    font-weight: 600;
}

.bh-p-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 6px;
}

.bh-p-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text-2);
    font: 500 var(--fs-xs) var(--font-mono);
    cursor: pointer;
    opacity: 0.6;
}

.bh-p-btn .bh-answer-pic {
    width: 52px;
    height: 52px;
}

.bh-p-btn[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text);
    opacity: 1;
}

.bh-p-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.bh-p-meta {
    color: var(--text-3);
    font-family: var(--font-sans);
    font-size: 11px;
}

.bh-scramble {
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.bh-scramble code,
.bh-reveal code {
    font-family: var(--font-mono);
    color: var(--text);
    overflow-wrap: anywhere;
}

.bh-reveal {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3) var(--sp-5);
    padding: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-size: var(--fs-sm);
}

.bh-reveal-pic {
    width: 110px;
    height: 110px;
}

.bh-reveal-pic svg {
    width: 100%;
    height: 100%;
}

.bh-reveal-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.bh-reveal-case {
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    font-weight: 600;
}

.bh-answer-full {
    width: 84px;
    height: 84px;
}

.bh-answer-cube {
    width: 88px;
    height: 88px;
}

/* Your standard angle */

.bh-std-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.bh-std-item {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 4px 12px;
    padding: 10px;
    border-radius: var(--r-md, 10px);
    background: var(--surface-2);
}

.bh-std-item .bh-answer-cube {
    grid-row: span 2;
    width: 64px;
    height: 64px;
}

.bh-std-item .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}

.bh-std-item .setting-hint {
    margin: 0;
    font-size: 12px;
}

/* Renaming */

.bh-rename summary {
    color: var(--accent-text);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
}

.bh-rename[open] {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.bh-rename-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--sp-2);
}

.bh-rename-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.bh-rename-item .bh-answer-pic {
    flex: none;
    width: 48px;
    height: 48px;
}

.bh-rename-item .input {
    flex: 1;
    min-width: 0;
}

.bh-help ul {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin: 0;
    padding-left: 1.2em;
    color: var(--text-2);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

@media (max-width: 640px) {
    .bh-answers.is-patterns,
    .bh-answers.is-cases {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .bh-answer-pic {
        width: 100%;
        max-width: 72px;
        height: auto;
        aspect-ratio: 1;
    }

    .bh-answers.is-names {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
