/* Classifier Packing Bench (/games/classifier-packing-bench). Effects follow the Grammar Gauntlet kit, prefix cpb-. */

.cpb-hero { background: linear-gradient(135deg, #92400e, #b45309); }
.cpb-card { overflow: hidden; }

/* The stage clips every effect. */
.cpb-stage { position: relative; overflow: hidden; }

.cpb-example { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.4rem; }
.cpb-example-part { display: inline-flex; flex-direction: column; align-items: center; min-width: 3.2rem; padding: 0.3rem 0.5rem; border: 2px solid #e5c9a3; border-radius: 0.6rem; background: #fffaf0; font-size: 1.5rem; line-height: 1.1; }
.cpb-example-part small { font-size: 0.7rem; color: #6b7280; }
.cpb-example-cls { border-color: #d97706; background: #fef3c7; }
.cpb-plus { font-weight: 800; color: #92400e; }
.cpb-example-result { font-size: 1.7rem; font-weight: 800; color: #92400e; }

.cpb-band-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
@media (min-width: 768px) { .cpb-band-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cpb-band { display: flex; flex-direction: column; align-items: center; padding: 0.55rem 0.4rem; border: 2px solid #e5c9a3; border-radius: 0.75rem; background: #fff; color: #1f2937; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.cpb-band span { font-size: 0.78rem; color: #6b7280; }
.cpb-band.active, .cpb-band[aria-pressed="true"] { background: linear-gradient(135deg, #b45309, #d97706); border-color: #f59e0b; color: #fff; }
.cpb-band.active span, .cpb-band[aria-pressed="true"] span { color: #fef3c7; }
@media (hover: hover) { .cpb-band:hover:not(.active) { border-color: #b45309; } }
.cpb-band:active { transform: scale(0.97); }
.cpb-band.cpb-picked { animation: cpb-pop 0.3s ease; }

.cpb-hud { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.cpb-heart { display: inline-block; color: #dc2626; font-size: 1.15rem; }
.cpb-heart-lost { color: #9ca3af; }
.cpb-sound { margin-left: auto; }
.cpb-combo-badge { color: #fff; background: #6b7280; }
.cpb-combo-badge.cpb-combo-2 { background: #0284c7; }
.cpb-combo-badge.cpb-combo-3 { background: #7c3aed; }
.cpb-combo-badge.cpb-combo-4 { background: #ea580c; }
.cpb-combo-badge.cpb-combo-5 { background: linear-gradient(135deg, #dc2626, #f97316); animation: cpb-glow 1.2s ease-in-out infinite; }

/* The bench view reserves its height so nothing below it moves when 3D arrives. */
.cpb-scene { position: relative; height: 190px; border-radius: 0.75rem; background: linear-gradient(180deg, #2b3340, #1f2530); overflow: hidden; margin-bottom: 0.6rem; }
@media (min-width: 768px) { .cpb-scene { height: 250px; } }
.cpb-scene .cpb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cpb-scene-3d .cpb-flat { display: none; }
.cpb-flat { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; gap: 4%; padding: 0 6% 24px; }
.cpb-fbox { position: relative; flex: 0 1 28%; height: 58%; border-radius: 0.35rem; background: #c49a6c; border: 3px solid #a47c52; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.cpb-fbox-gold { background: #d9a521; border-color: #8c6a17; }
.cpb-fbox-focus { box-shadow: 0 0 0 3px #fde68a, 0 0 18px rgba(253, 230, 138, 0.6); }
.cpb-fbox-filled::before { content: ""; position: absolute; left: -3px; right: -3px; top: -10px; height: 12px; border-radius: 0.25rem; background: #a47c52; }
.cpb-fbox-label { background: #fffaf0; color: #14532d; font-weight: 800; font-size: 1rem; padding: 0.1rem 0.4rem; border-radius: 0.25rem; min-height: 1.4rem; }
.cpb-fbox-empty .cpb-fbox-label { visibility: hidden; }
.cpb-fbox-missed .cpb-fbox-label { background: #fee2e2; color: #b91c1c; }
.cpb-fbox-count { color: #fff; font-weight: 700; font-size: 0.8rem; margin-top: 0.2rem; }
/* The round green-check sticker on a correctly packed box (the 3D view draws its own). */
.cpb-fbox-check {
    position: absolute; top: -9px; right: -9px; width: 26px; height: 26px; border-radius: 50%;
    background: #16a34a; border: 2px solid #fff; color: #fff; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center; transform: rotate(-10deg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); pointer-events: none;
    animation: cpb-pop 0.35s ease;
}

.cpb-slip { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; border: 2px dashed #d6b98d; border-radius: 0.75rem; background: #fffaf0; }
.cpb-slip-pics { display: flex; flex-wrap: wrap; gap: 0.25rem; max-width: 60%; }
.cpb-slip-pics img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 0.4rem; border: 1px solid #ecdcc3; }
.cpb-slip-qty { font-size: 1.6rem; font-weight: 800; color: #92400e; line-height: 1; }
.cpb-slip-gloss { font-weight: 600; color: #1f2937; }
.cpb-slip.cpb-deal { animation: cpb-deal-in 0.3s ease backwards; }
.cpb-slip.cpb-shake { animation: cpb-shake 0.4s ease; }

.cpb-clock { height: 6px; border-radius: 3px; background: #f3e8d5; overflow: hidden; }
.cpb-clock-bar { height: 100%; width: 100%; background: #16a34a; }
.cpb-clock-urgent .cpb-clock-bar { background: #f97316; animation: cpb-pulse 0.6s ease-in-out infinite; }
.cpb-clock-off { visibility: hidden; }

.cpb-build { display: flex; justify-content: center; gap: 0.35rem; }
.cpb-slot { min-width: 2.8rem; padding: 0.15rem 0.5rem; text-align: center; font-size: 1.7rem; font-weight: 800; border-bottom: 3px solid #e5c9a3; color: #9ca3af; }
.cpb-slot-set { color: #1f2937; border-color: #b45309; }
.cpb-slot-cls.cpb-slot-set { color: #b45309; }

.cpb-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.cpb-row-label { flex: 0 0 5.4rem; font-size: 0.78rem; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.02em; }
.cpb-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.35rem; flex: 1; }
.cpb-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 3.2rem;
    border: 2px solid #e5c9a3; border-radius: 0.6rem; background: #fff; color: #1f2937;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    animation: cpb-deal-in 0.28s ease backwards;
}
.cpb-tile-h { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.cpb-tile-p { font-size: 0.72rem; color: #6b7280; }
@media (hover: hover) { .cpb-tile:hover:not(:disabled) { border-color: #b45309; transform: translateY(-2px); } }
.cpb-tile:active:not(:disabled) { transform: scale(0.97); background: #fef3c7; }
.cpb-tile.active, .cpb-tile[aria-pressed="true"] { border-color: #d97706; background: #fef3c7; box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.25); }
.cpb-tile.correct { border-color: #16a34a; background: #dcfce7; animation: cpb-pop 0.35s ease; }
.cpb-tile.wrong { border-color: #dc2626; background: #fee2e2; animation: cpb-shake 0.35s ease; }
.cpb-tile.faded { opacity: 0.5; }
.cpb-tile.cpb-picked { animation: cpb-pop 0.3s ease; }
@media (max-width: 420px) { .cpb-row-label { flex-basis: 3.9rem; font-size: 0.68rem; } }

.cpb-type-row { display: flex; gap: 0.5rem; max-width: 26rem; margin: 0 auto; }
.cpb-answer { font-size: 1.25rem; font-weight: 800; }
.cpb-chest { display: inline-block; padding: 0.75rem 1.25rem; border-radius: 0.75rem; background: #fef3c7; border: 2px solid #f59e0b; color: #78350f; }
.cpb-review li { padding: 0.35rem 0; border-bottom: 1px solid #f1e6d3; }

/* The same results stay on the page after the completion dialog is dismissed. */
.cpb-result-dialog { display: block; position: relative; width: 100%; max-width: 40rem; margin: 0 auto; padding: 1.5rem; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: 1rem; color: var(--bs-body-color, #212529); background: var(--bs-body-bg, #fff); }
.cpb-result-dialog[open] { position: fixed; width: calc(100% - 2rem); max-height: calc(100dvh - 2rem); overflow: auto; margin: auto; box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.25); }
.cpb-result-dialog::backdrop { background: rgba(15, 23, 42, 0.65); }
.cpb-result-close { position: absolute; top: 0.75rem; right: 0.75rem; }
.cpb-result-dialog:not([open]) .cpb-result-close { display: none; }
.cpb-play-again { display: inline-flex; flex-direction: column; align-items: center; min-width: 13rem; padding: 0.7rem 1.5rem; }
.cpb-play-again small { font-size: 0.75rem; font-weight: 400; }

/* ── Effects (chrome: never clickable, clipped by the stage) ───────── */
.cpb-float {
    position: absolute; transform: translate(-50%, -50%);
    font-weight: 800; font-size: 1.5rem; color: #15803d; text-shadow: 0 1px 0 #fff;
    pointer-events: none; z-index: 4;
    animation: cpb-float-up 0.9s ease-out forwards;
}
@keyframes cpb-float-up {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
    20% { transform: translate(-50%, -70%) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}
.cpb-particle {
    position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
    pointer-events: none; z-index: 3;
    animation: cpb-burst 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.cpb-spark { width: 6px; height: 6px; animation-duration: 1s; animation-fill-mode: both; }
@keyframes cpb-burst {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}
.cpb-confetti {
    position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
    pointer-events: none; z-index: 6;
    animation: cpb-confetti-fall 1.8s ease-in forwards;
}
@keyframes cpb-confetti-fall {
    0% { opacity: 1; transform: translate(0, 0) rotate(0); }
    100% { opacity: 0; transform: translate(var(--drift), 460px) rotate(var(--spin)); }
}
.cpb-combo-pop {
    position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
    font-size: clamp(1.6rem, 7vw, 2.4rem); font-weight: 900; color: #b45309;
    text-shadow: 0 2px 0 #fff, 0 6px 18px rgba(245, 158, 11, 0.45);
    white-space: nowrap; pointer-events: none; z-index: 4;
    animation: cpb-combo-pop 1.1s ease-out forwards;
}
.cpb-combo-pop-3 { color: #7c3aed; }
.cpb-combo-pop-4 { color: #ea580c; }
.cpb-combo-pop-5 { color: #dc2626; }
@keyframes cpb-combo-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
    45% { transform: translate(-50%, -50%) scale(1) rotate(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}
.cpb-toast {
    position: absolute; top: 0.6rem; left: 50%; transform: translateX(-50%);
    padding: 0.35rem 0.9rem; border-radius: 999px;
    background: #facc15; color: #422006;
    font-weight: 800; font-size: 0.9rem; white-space: nowrap;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    pointer-events: none; z-index: 4;
    animation: cpb-toast 2.1s ease forwards;
}
@keyframes cpb-toast {
    0% { opacity: 0; transform: translate(-50%, -12px); }
    12% { opacity: 1; transform: translate(-50%, 0); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -6px); }
}
.cpb-heart.cpb-heart-break { animation: cpb-heart-break 0.6s ease; }
@keyframes cpb-heart-break {
    0% { transform: scale(1); }
    30% { transform: scale(1.5); color: #ef4444; }
    60% { transform: scale(0.7) rotate(-12deg); }
    100% { transform: scale(0.85); }
}
.cpb-bump { display: inline-block; animation: cpb-bump 0.35s ease; }
@keyframes cpb-bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes cpb-pop { 0% { transform: scale(1); } 45% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes cpb-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes cpb-deal-in { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes cpb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes cpb-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.55); }
    50% { box-shadow: 0 0 0 6px rgba(249, 115, 22, 0); }
}

/* ── Dark theme: selected states named explicitly so they out-rank the plain dark rules ── */
[data-bs-theme="dark"] .cpb-band, [data-bs-theme="dark"] .cpb-tile { background: #1f2937; color: #f3f4f6; border-color: #4b5563; }
[data-bs-theme="dark"] .cpb-band span, [data-bs-theme="dark"] .cpb-tile-p, [data-bs-theme="dark"] .cpb-row-label { color: #cbd5e1; }
[data-bs-theme="dark"] .cpb-band.active,
[data-bs-theme="dark"] .cpb-band[aria-pressed="true"] { background: linear-gradient(135deg, #b45309, #d97706); border-color: #fbbf24; color: #fff; }
[data-bs-theme="dark"] .cpb-band.active span,
[data-bs-theme="dark"] .cpb-band[aria-pressed="true"] span { color: #fef3c7; }
[data-bs-theme="dark"] .cpb-tile.active,
[data-bs-theme="dark"] .cpb-tile[aria-pressed="true"] { background: #78350f; border-color: #fbbf24; color: #fff; }
[data-bs-theme="dark"] .cpb-tile.correct { background: #14532d; border-color: #22c55e; color: #fff; }
[data-bs-theme="dark"] .cpb-tile.wrong { background: #7f1d1d; border-color: #f87171; color: #fff; }
[data-bs-theme="dark"] .cpb-slip, [data-bs-theme="dark"] .cpb-example-part { background: #1f2937; border-color: #6b5434; color: #f3f4f6; }
[data-bs-theme="dark"] .cpb-example-cls { background: #451a03; }
[data-bs-theme="dark"] .cpb-slip-gloss, [data-bs-theme="dark"] .cpb-slot-set { color: #f3f4f6; }
[data-bs-theme="dark"] .cpb-slip-qty, [data-bs-theme="dark"] .cpb-example-result, [data-bs-theme="dark"] .cpb-slot-cls.cpb-slot-set { color: #fbbf24; }
[data-bs-theme="dark"] .cpb-clock { background: #374151; }
[data-bs-theme="dark"] .cpb-chest { background: #451a03; color: #fde68a; }
[data-bs-theme="dark"] .cpb-review li { border-color: #374151; }
[data-bs-theme="dark"] .cpb-float { text-shadow: none; }

/* Last in the file: reduced motion turns every effect off, not just slower. */
@media (prefers-reduced-motion: reduce) {
    .cpb-stage *, .cpb-hud * { animation: none !important; transition: none !important; }
    .cpb-tile:active:not(:disabled), .cpb-band:active { transform: none; }
}
