/* education-game.css - Bacto Builder, the game on the Education page (markup: <template id="bacto-game"> in wiki/pages/education.html, logic: static/js/education-game.js) */
/* played by ear; the stage is a .pane, so light/dark/reduce-transparency follow the site; the plasticine buttons and hearts are photos set by the JS once they load */

.bb {
    --bb-ink:       var(--text-strong, #243024);
    --bb-body:      var(--text-body, #3A4B3A);
    --bb-muted:     var(--text-muted, #4B5A49);
    /* the home problem cards' grounds, as on Entrepreneurship */
    --bb-soil:      #E9D6B8;
    --bb-water:     #CFE2EC;
    --bb-tile:      rgba(255,255,255,0.62);
    --bb-tile-line: rgba(27,27,24,0.10);
    --bb-core:      #2F3D2F;
    --bb-core-ink:  rgba(255,255,255,0.94);
    --bb-clay-ink:  #1B1B18;              /* text printed on the light plasticine */
    --bb-heart:     #B4563F;
    --bb-head:      'Quicksand', sans-serif;
    --bb-font:      'Quicksand', sans-serif;
    position: relative;
    margin-block: 0.5rem 1rem;
    font-family: var(--bb-font);
    color: var(--bb-body);
}
html[data-dark] .bb {
    --bb-soil:      rgba(233,214,184,0.13);
    --bb-water:     rgba(207,226,236,0.13);
    --bb-tile:      var(--d-glass-strong, rgba(255,255,255,0.11));
    --bb-tile-line: var(--d-glass-border, rgba(255,255,255,0.10));
    --bb-core:      var(--d-btn, #3F5340);
    --bb-heart:     #E08A6E;
}

.bb-sr {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── the stage: a pane in the text column; "bigger screen" lifts it over the page ── */
.bb-stage {
    --pane-radius: var(--radius-card, 30px);
    height: clamp(460px, 74vh, 660px);
    overflow: hidden;
    isolation: isolate;
}
.bb.is-big .bb-stage {
    position: fixed;
    inset: 0;
    height: auto;
    border-radius: 0;
    z-index: 1000;
}
html.bb-lock { overflow: hidden; }

.bb-screen {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 4rem 1.25rem 1.5rem;
    text-align: center;
    overflow-y: auto;
}
.bb-screen > :first-child { margin-top: auto; }
.bb-screen > :last-child  { margin-bottom: auto; }
.bb-screen[hidden], .bb [hidden] { display: none !important; }

.bb-eyebrow {
    margin: 0;
    font-family: var(--bb-head);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--bb-muted);
}
.bb-title {
    margin: 0;
    font-family: var(--bb-head);
    font-weight: 600;
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    line-height: 1.05;
    color: var(--bb-ink);
    text-wrap: balance;
}
.bb-title:focus { outline: none; }
.bb-lead {
    margin: 0;
    max-width: 32em;
    font-size: 1.05rem;
    line-height: 1.6;
}
/* ── buttons: the site's dark core pill until the plasticine photo arrives ── */
.bb-btn {
    min-height: 3.1rem;
    padding: 0.8rem 1.6rem;
    border: 1px solid var(--bb-tile-line);
    border-radius: 999px;
    background: var(--bb-tile);
    color: var(--bb-ink);
    font-family: var(--bb-head);
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.2;
    cursor: pointer;
}
.bb-btn--primary {
    background: var(--bb-core);
    border-color: transparent;
    color: var(--bb-core-ink);
}
.bb-btn--round {
    width: 2.9rem;
    min-height: 2.9rem;
    padding: 0;
    display: grid;
    place-items: center;
}
.bb-btn--round svg { display: block; width: 1.2rem; height: 1.2rem; }
.bb.is-big .bb-btn--round { box-shadow: inset 0 0 0 2px var(--bb-ink); }
.bb-row { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

/* plasticine: a photo stretched over the button, the words stay real text (screen readers) */
.bb--clay-button  .bb-btn--primary,
.bb--clay-button2 .bb-btn:not(.bb-btn--primary):not(.bb-btn--round),
.bb--clay-round   .bb-btn--round,
.bb--clay-button2 .bb-pad-btn {
    border-color: transparent;
    background-color: transparent;
    background-position: center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    color: var(--bb-clay-ink);
    text-shadow: 0 1px 0 rgba(255,255,255,0.55);
}
.bb--clay-button  .bb-btn--primary  { background-image: var(--bb-img-button);  padding-inline: 2.2rem; }
.bb--clay-button2 .bb-btn:not(.bb-btn--primary):not(.bb-btn--round) { background-image: var(--bb-img-button-2); padding-inline: 2rem; }
.bb--clay-round   .bb-btn--round    { background-image: var(--bb-img-round); }
.bb--clay-button2 .bb-pad-btn       { background-image: var(--bb-img-button-2); }

/* ── the kids' bacteria ── */
.bb-parade { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 0.6rem; max-width: 46rem; }
.bb-parade img { height: clamp(36px, 6vw, 58px); filter: drop-shadow(0 4px 5px rgba(27,27,24,0.25)); animation: bb-bob 2.4s ease-in-out infinite; }
.bb-parade img:nth-child(odd) { animation-delay: -1.2s; }
@keyframes bb-bob { 50% { transform: translateY(-5px) rotate(-3deg); } }

.bb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 0.75rem;
    width: 100%;
    max-width: 52rem;
}
.bb-kid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.5rem 0.55rem;
    border: 1px solid var(--bb-tile-line);
    border-radius: 20px;
    background: var(--bb-tile);
    color: var(--bb-ink);
    cursor: pointer;
}
.bb-kid img { width: 100%; height: 5.5rem; object-fit: contain; filter: drop-shadow(0 4px 5px rgba(27,27,24,0.25)); }
.bb-kid span { font-family: var(--bb-head); font-weight: 700; font-size: 0.98rem; }

/* ── how to play: the chosen bacterium on top, then three cards ── */
.bb-btn--small { min-height: 2.6rem; padding: 0.5rem 1.2rem; font-size: 0.95rem; }
.bb-who-img {
    height: clamp(5.5rem, 14vw, 8rem);
    max-width: 60%;
    object-fit: contain;
    filter: brightness(1) opacity(1) drop-shadow(0 8px 10px rgba(27,27,24,0.28));
    animation: bb-bob 2.4s ease-in-out infinite;
}
.bb-intro .bb-title { margin-top: -0.25rem; }
/* the draw: the bacterium is a shadow until it is revealed */
.bb.is-drawing .bb-who-img { filter: brightness(0) opacity(0.55); transform: scale(0.92); animation: bb-wobble 0.5s ease-in-out infinite; }
.bb.is-drawing .bb-step-art--move img { filter: brightness(0) opacity(0.4); }
.bb.is-drawing [data-t="playingAs"] { display: none; }
/* the reveal is a one-off animation, not a filter transition (Safari can leave those dark); when it ends the picture is back to its normal look */
.bb.is-revealed .bb-who-img { animation: bb-reveal 0.7s ease-out; }
@keyframes bb-reveal { from { transform: scale(0.85); filter: brightness(0) opacity(0.55) drop-shadow(0 8px 10px rgba(27,27,24,0.28)); } 60% { transform: scale(1.06); } }
@keyframes bb-wobble { 25% { transform: scale(0.92) rotate(-4deg); } 75% { transform: scale(0.92) rotate(4deg); } }
.bb-who { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 0.9rem; }
.bb-who p { margin: 0; font-size: 1.05rem; }
.bb-who b { font-family: var(--bb-head); font-weight: 700; color: var(--bb-ink); }
.bb-intro .bb-lead { max-width: 34em; }
.bb-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
    width: 100%;
    max-width: 50rem;
    margin-block: 0.25rem;
}
.bb-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 1rem 1rem 1.1rem;
    border: 1px solid var(--bb-tile-line);
    border-radius: 22px;
    background: var(--bb-tile);
}
.bb-step h4 { margin: 0; font-family: var(--bb-head); font-weight: 700; font-size: 1.2rem; color: var(--bb-ink); }
.bb-step p { margin: 0 0 auto; font-size: 0.98rem; line-height: 1.5; }
.bb-step .bb-btn { margin-top: 0.4rem; }
.bb-step-art { height: 3.4rem; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.bb-step-art img { height: 100%; max-width: 5rem; object-fit: contain; filter: drop-shadow(0 4px 5px rgba(27,27,24,0.22)); }
.bb-step-art--move { color: var(--bb-muted); font-size: 1rem; }
.bb-step-art--move span:not([data-art]) { opacity: 0.7; }
.bb-step-art--move [data-art] { height: 100%; display: flex; }
.bb-note { margin: 0; max-width: 32em; font-size: 0.92rem; color: var(--bb-muted); }
.bb-check {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    max-width: 36rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--bb-tile-line);
    border-radius: 18px;
    background: var(--bb-tile);
    text-align: left;
    cursor: pointer;
}
.bb-check input { width: 1.5rem; height: 1.5rem; accent-color: var(--bb-core); flex: none; }

/* ── the game ── */
.bb-game {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #2b4762 center / cover no-repeat;
}
.bb-game:focus { outline: none; }
.bb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.bb-hud { position: absolute; top: 0.7rem; left: 0.75rem; right: 4.2rem; display: flex; flex-wrap: wrap; gap: 0.5rem; pointer-events: none; }
.bb-pill {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid rgba(255,255,255,0.55);
    border-radius: 999px;
    background: rgba(255,255,255,0.86);
    color: #1B1B18;
    font-weight: 700;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}
.bb-pill img { width: 1.25rem; height: 1.25rem; object-fit: contain; }
.bb-heart { display: inline-block; width: 1.35rem; height: 1.2rem; line-height: 1.2rem; text-align: center; color: var(--bb-heart); background-position: center; background-size: contain; background-repeat: no-repeat; }
.bb-heart::before { content: '♥'; }
.bb-heart.is-lost::before { content: '♡'; }
.bb--hearts .bb-heart::before { content: ''; }
.bb--hearts .bb-heart { background-image: var(--bb-img-heart); width: 1.6rem; height: 1.45rem; }
.bb--hearts .bb-heart.is-lost { background-image: var(--bb-img-heart-empty, var(--bb-img-heart)); }
.bb--hearts:not(.bb--hearts-empty) .bb-heart.is-lost { opacity: 0.3; filter: grayscale(1); }
.bb-hint {
    position: absolute;
    top: 6.5rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 2rem);
    margin: 0;
    padding: 0.55rem 1rem;
    border-radius: 14px;
    background: rgba(255,255,255,0.9);
    color: #1B1B18;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
    transition: opacity 0.6s;
}
.bb-hint.is-off { opacity: 0; }

/* the controls: the slider is what VoiceOver adjusts (swipe up/down) */
.bb-pad {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: grid;
    grid-template-columns: minmax(5.5rem, 1fr) minmax(8rem, 2fr) minmax(5.5rem, 1fr) auto auto;
    grid-template-areas: "l s r st ex";
    gap: 0.5rem;
    max-width: 52rem;
    margin-inline: auto;
    padding: 0.6rem;
}
.bb-pad-btn { min-height: 3.1rem; border-radius: 999px; border: 1px solid rgba(255,255,255,0.55); background: rgba(255,255,255,0.88); color: #1B1B18; font-family: var(--bb-head); font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.bb-pad-btn[data-act="left"]  { grid-area: l; }
.bb-pad-btn[data-act="right"] { grid-area: r; }
.bb-pad .bb-btn[data-act="status"] { grid-area: st; }
.bb-pad .bb-btn[data-act="stop"]   { grid-area: ex; }
.bb-pad .bb-btn { min-height: 3.1rem; padding: 0.4rem 1.1rem; font-size: 0.95rem; background-color: rgba(255,255,255,0.88); color: #1B1B18; }
.bb-slot { grid-area: s; display: flex; align-items: center; padding: 0 0.8rem; border-radius: 999px; background: rgba(255,255,255,0.88); }
.bb-lane { -webkit-appearance: none; appearance: none; width: 100%; height: 3.1rem; margin: 0; background: transparent; cursor: pointer; }
.bb-lane::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: rgba(27,27,24,0.25); }
.bb-lane::-webkit-slider-thumb { -webkit-appearance: none; width: 2.3rem; height: 2.3rem; margin-top: calc(4px - 1.15rem); border-radius: 50%; border: 3px solid #fff; background: var(--bb-core); }
.bb-lane::-moz-range-track { height: 8px; border-radius: 99px; background: rgba(27,27,24,0.25); }
.bb-lane::-moz-range-thumb { width: 2rem; height: 2rem; border-radius: 50%; border: 3px solid #fff; background: var(--bb-core); }
.bb--clay-round .bb-lane::-webkit-slider-thumb { border: 0; background: var(--bb-img-round) center / 100% 100% no-repeat; }
.bb--clay-round .bb-lane::-moz-range-thumb     { border: 0; background: var(--bb-img-round) center / 100% 100% no-repeat; }

/* ── result ── */
.bb-score { font-family: var(--bb-head); font-weight: 600; font-size: clamp(4rem, 12vw, 7rem); line-height: 1; color: var(--bb-ink); }
.bb-end-kid { height: 6.5rem; filter: drop-shadow(0 6px 8px rgba(27,27,24,0.3)); }
.bb-best { margin: 0; font-weight: 700; color: var(--bb-muted); }

/* ── corner: bigger screen ── */
.bb-corner { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 5; display: flex; gap: 0.4rem; }
.bb-corner .bb-btn { min-height: 2.9rem; padding: 0.4rem 0.9rem; font-size: 0.9rem; }
/* the round button keeps no side padding, so its icon sits in the middle */
.bb-corner .bb-btn--round { flex: none; width: 2.9rem; padding: 0; }

/* ── the site's display settings ── */
html[data-reduce-motion] .bb-parade img, html[data-reduce-motion] .bb-who-img { animation: none; }
@media (prefers-reduced-motion: reduce) { .bb-parade img, .bb-who-img { animation: none; } }
html[data-high-contrast] .bb .bb-btn,
html[data-high-contrast] .bb .bb-pad-btn {
    background-image: none !important;
    border: 2px solid var(--bb-ink) !important;
    text-shadow: none !important;
}
html[data-high-contrast] .bb .bb-btn--primary { background-color: var(--bb-core) !important; color: var(--bb-core-ink) !important; }
@media (forced-colors: active) {
    .bb .bb-btn, .bb .bb-pad-btn, .bb .bb-kid, .bb .bb-step {
        background: ButtonFace !important;
        color: ButtonText !important;
        border: 2px solid ButtonText !important;
        text-shadow: none !important;
    }
    .bb-heart { forced-color-adjust: none; }
}
/* narrow: moving on top, the two small buttons under it */
@media (max-width: 46rem) {
    .bb-pad { grid-template-columns: 1fr 1.6fr 1fr; grid-template-areas: "l s r" "st st ex"; }
    .bb-pad .bb-btn { min-height: 2.7rem; padding-inline: 0.8rem; }
    .bb-pad-btn { font-size: 1rem; }
}
@media (max-width: 34rem) {
    .bb-stage { height: clamp(520px, 82vh, 700px); }
    /* phones: each card lies flat, picture on the left */
    .bb-step { display: grid; grid-template-columns: 4.5rem 1fr; grid-template-areas: "a h" "a p" "a b"; justify-items: start; column-gap: 0.9rem; row-gap: 0.3rem; padding: 0.85rem 1rem; text-align: left; }
    .bb-step-art { grid-area: a; align-self: center; justify-self: center; height: 3rem; gap: 0.15rem; }
    .bb-step-art img { max-width: 3.6rem; }
    .bb-step h4 { grid-area: h; font-size: 1.1rem; }
    .bb-step p { grid-area: p; margin: 0; }
    .bb-step .bb-btn { grid-area: b; margin-top: 0.2rem; }
}
/* very narrow: the slider gets its own row, Left and Right sit under it */
@media (max-width: 21rem) {
    .bb-pad { grid-template-columns: 1fr 1fr; grid-template-areas: "s s" "l r" "st ex"; }
}
