/* Brick Fractions (js/arcade/bricks.js). Every class starts with .bf- */

/* --rowh: one wall row, and the bar's inside, so a brick is the same size in both */
.bf-wrap { --rowh: clamp(48px, calc((100vh - 300px) / (var(--slots, 7) + 1.6)), 84px); position: relative; display: grid; gap: 8px; width: 100%; padding-top: 2px; }
@supports (height: 100svh) { .bf-wrap { --rowh: clamp(48px, calc((100svh - 300px) / (var(--slots, 7) + 1.6)), 84px); } }
.bf-hud { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; font: 700 14px var(--font-ui); color: var(--muted); }
.bf-hud b { color: var(--ink); font-size: 17px; }

/* the goal: wholes made out of the level's goal */
.bf-goal { position: relative; height: 26px; border-radius: 999px; overflow: hidden; display: grid; place-items: center; background: #F4ECFB; box-shadow: inset 0 2px 0 rgba(46, 42, 71, 0.06); }
.bf-goal i { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, #7FDCC9, #13A391); transition: transform 0.5s cubic-bezier(0.3, 1.4, 0.5, 1); }
.bf-goal span { position: relative; font: 800 14px var(--font-ui); color: var(--ink); }

/* the wall: candy bricks hanging from a striped beam, with sky behind the holes */
.bf-wall { position: relative; height: calc(var(--slots, 7) * var(--rowh) + 14px); border-radius: 16px 16px 8px 8px; background: linear-gradient(180deg, #DDF1FF 0%, #F1F9FF 60%, #F3FBF8 100%); box-shadow: inset 0 0 0 2px #E2EEF9; }
.bf-wall::before { content: ''; position: absolute; right: 9%; bottom: 14%; width: 74px; height: 22px; border-radius: 999px; background: #fff; opacity: 0.8; box-shadow: -26px 6px 0 -2px #fff, 22px 5px 0 -4px #fff; pointer-events: none; }
.bf-ceiling { position: absolute; left: 0; right: 0; top: 0; height: 12px; z-index: 2; overflow: hidden; border-radius: 16px 16px 0 0; background: repeating-linear-gradient(-45deg, #FFB3CF 0 10px, #FFF4F8 10px 20px); box-shadow: 0 2px 0 rgba(46, 42, 71, 0.08); }
.bf-ceiling i { position: absolute; left: 0; bottom: 0; width: 100%; height: 4px; transform: scaleX(0); transform-origin: left; background: #E2506A; }
.bf-press .bf-wall::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -2px; border-bottom: 3px dashed rgba(226, 80, 106, 0.35); pointer-events: none; }
.bf-rows { position: absolute; left: 0; right: 0; top: 14px; bottom: 0; clip-path: inset(0 -40px -400px -40px); }
.bf-row { position: absolute; left: 0; right: 0; top: 0; height: var(--rowh); transform: translateY(calc(var(--i, 0) * var(--rowh))); transition: transform 0.4s cubic-bezier(0.3, 1.25, 0.5, 1); }

/* a brick: as wide as its size, its fraction in the middle, a face on the big ones */
.bf-brick { --bk: #EEE6F7; --bk-d: #D3C6E6; position: absolute; top: 3px; bottom: 3px; margin: 0; padding: 0; border: 0; border-radius: 10px; display: grid; place-items: center; overflow: hidden; color: var(--ink); background: var(--bk) linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 45%); box-shadow: inset 0 -5px 0 var(--bk-d), inset 0 0 0 1.5px rgba(255, 255, 255, 0.45), 0 2px 3px rgba(46, 42, 71, 0.12); cursor: pointer; touch-action: manipulation; transition: transform 0.3s cubic-bezier(0.25, 1.2, 0.5, 1), opacity 0.25s, background-color 0.2s; }
button.bf-brick:active { scale: 0.94; }
.bf-d1 { --bk: #8EDFE6; --bk-d: #4FC0CB; }
.bf-d2 { --bk: #FFA6CB; --bk-d: #EC7FAD; }
.bf-d3 { --bk: #92E6C8; --bk-d: #55C9A1; }
.bf-d4 { --bk: #FFE382; --bk-d: #EBC447; }
.bf-d5 { --bk: #CDB1FF; --bk-d: #A887EC; }
.bf-d6 { --bk: #B3C0FF; --bk-d: #8896EE; }
.bf-d8 { --bk: #9AD8FF; --bk-d: #62B7EC; }
.bf-d10 { --bk: #C4ED92; --bk-d: #96CE5E; }
.bf-frac { position: relative; z-index: 1; display: inline-grid; justify-items: center; gap: 2px; padding-bottom: 3px; font: 900 calc(var(--rowh) * 0.3)/0.9 var(--font-ui); color: var(--ink); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); pointer-events: none; }
.bf-frac i { width: calc(100% + 6px); height: 2.5px; border-radius: 2px; background: currentColor; }
.bf-frac.bf-one { font-size: calc(var(--rowh) * 0.52); }
.bf-face::before, .bf-face::after { content: ''; position: absolute; top: 50%; width: 16px; height: 20px; margin-top: -11px; pointer-events: none; background: radial-gradient(circle at 50% 5px, var(--ink) 0 2.6px, transparent 3.2px), radial-gradient(7px 4px at 50% 14px, rgba(255, 96, 136, 0.42) 85%, transparent 100%); }
.bf-face::before { left: calc(50% - 22px - var(--rowh) * 0.3); }
.bf-face::after { right: calc(50% - 22px - var(--rowh) * 0.3); }
/* in the bar: its place in the wall shows as a dashed hole until the whole clears (or Undo) */
.bf-brick.bf-out { background: rgba(255, 255, 255, 0.4); box-shadow: none; outline: 2.5px dashed rgba(110, 90, 170, 0.3); outline-offset: -3px; cursor: default; }
.bf-brick.bf-out .bf-frac, .bf-brick.bf-out .bf-crack { opacity: 0.25; }
.bf-brick.bf-out::before, .bf-brick.bf-out::after { opacity: 0; }
/* too big: it jolts, keeps a little crack, and its copy pokes into the bar */
.bf-brick.bf-hit { animation: bf-jolt 0.45s; }
@keyframes bf-jolt { 20% { translate: -6px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 3px 0; } }
.bf-crack { position: absolute; left: 3px; top: 0; height: 100%; width: auto; fill: none; stroke: rgba(46, 42, 71, 0.4); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.bf-brick.bf-new { animation: bf-pop 0.42s ease-out; }
.bf-brick.bf-split { z-index: 2; pointer-events: none; animation: bf-split 0.45s ease-out forwards; }
@keyframes bf-pop { 0% { scale: 0.6; opacity: 0.3; } 60% { scale: 1.08; } 100% { scale: 1; opacity: 1; } }
@keyframes bf-split { 30% { scale: 1.06; filter: brightness(1.25); } 100% { scale: 1.2; opacity: 0; } }

/* the wall about to come down, low, or crashing into the bar */
.bf-rows.bf-rumble .bf-row { animation: bf-rumble 0.2s infinite; }
@keyframes bf-rumble { 50% { translate: 0 2px; } }
.bf-rows .bf-row.bf-crumble { pointer-events: none; animation: bf-crumble 0.6s ease-in forwards; }
@keyframes bf-crumble { to { translate: 0 140px; rotate: 3deg; opacity: 0; } }
.bf-danger .bf-wall { box-shadow: inset 0 0 0 3px rgba(226, 80, 106, 0.55); }
.bf-danger.bf-press .bf-wall::after { border-color: #E2506A; animation: bf-blink 0.9s ease-in-out infinite; }
@keyframes bf-blink { 50% { opacity: 0.3; } }
.bf-crash .bf-rows { animation: bf-quake 0.5s; }
@keyframes bf-quake { 20% { translate: -8px 4px; } 40% { translate: 7px -3px; } 60% { translate: -5px 2px; } 80% { translate: 3px 0; } }
.bf-done .bf-wall, .bf-done .bf-bar { filter: saturate(0.6) brightness(0.97); }

/* the bar: exactly one whole, with faint ticks for the family's pieces */
.bf-bar { position: relative; height: calc(var(--rowh) + 12px); margin: 4px 0 2px; border-radius: 14px; background: #fff; box-shadow: 0 0 0 4px #E6DBF8, 0 6px 0 4px #D4C5F0, var(--shadow-soft); }
.bf-ticks, .bf-in, .bf-whole { position: absolute; left: 0; right: 0; top: 6px; bottom: 6px; }
.bf-ticks i { position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; border-radius: 1px; background: rgba(110, 90, 170, 0.15); }
.bf-label { position: absolute; inset: 0; display: grid; place-items: center; font: 800 calc(var(--rowh) * 0.32) var(--font-ui); color: rgba(110, 90, 170, 0.42); pointer-events: none; transition: opacity 0.2s; }
.bf-label span { padding: 0 10px; border-radius: 999px; background: #fff; }
.bf-bar:not(.bf-empty) .bf-label { opacity: 0; }
.bf-bar.bf-shake { animation: bf-shake 0.42s; }
@keyframes bf-shake { 20% { translate: -6px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 3px 0; } }
.bf-bar.bf-flash { animation: bf-flash 0.8s ease-out; }
@keyframes bf-flash { 25% { background: #FFF4BF; box-shadow: 0 0 0 4px #FFC93C, 0 6px 0 4px #E8B32A, 0 0 26px 8px rgba(255, 201, 60, 0.7); } }
/* the room left, shown after a too-big brick */
.bf-room { position: absolute; top: 6px; bottom: 6px; z-index: 1; display: grid; place-items: center; border-radius: 10px; background: rgba(226, 80, 106, 0.1); outline: 3px dashed #E2506A; outline-offset: -5px; opacity: 0; pointer-events: none; }
.bf-room.show { opacity: 1; animation: bf-pop 0.35s ease-out; }
.bf-room .bf-frac { color: #E4544A; }
.bf-brick.bf-bad { z-index: 3; translate: 0 -24%; filter: drop-shadow(0 5px 5px rgba(46, 42, 71, 0.25)); }
.bf-brick.bf-bad.bf-back { opacity: 0; }
.bf-overlap { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(226, 80, 106, 0.75) 0 6px, rgba(255, 255, 255, 0.55) 6px 12px); }
/* a whole: the bricks glow and lift away, crumbs burst, "1 whole!" */
.bf-whole { z-index: 2; pointer-events: none; animation: bf-lift 0.9s ease-in forwards; }
@keyframes bf-lift { 25% { filter: brightness(1.2) saturate(1.2); scale: 1.03; } 100% { translate: 0 -46px; scale: 0.92; opacity: 0; } }
.bf-burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 4; pointer-events: none; }
.bf-burst i { position: absolute; left: -7px; top: -5px; width: 14px; height: 10px; border-radius: 3px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12); animation: bf-crumb 0.85s cubic-bezier(0.2, 0.7, 0.4, 1) forwards; }
@keyframes bf-crumb { 0% { transform: scale(0.5); } 75% { opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
.bf-yay, .bf-pts { position: absolute; left: 0; transform: translateX(-50%); white-space: nowrap; font-family: var(--font-ui); font-weight: 900; line-height: 1; -webkit-text-stroke: 4px #fff; paint-order: stroke fill; }
.bf-yay { top: calc(var(--rowh) * -1.05); font-size: calc(var(--rowh) * 0.62); color: #0D7F71; animation: bf-yay 0.95s ease-out both; }
.bf-pts { top: calc(var(--rowh) * -0.35); font-size: calc(var(--rowh) * 0.36); color: var(--grape-d); animation: bf-yay 0.95s 0.08s ease-out both; }
@keyframes bf-yay { 0% { opacity: 0; scale: 0.5; } 25% { opacity: 1; scale: 1.15; } 45% { scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; translate: 0 -26px; } }

/* banners over the wall: a new wall, the end */
.bf-banner { position: absolute; left: 0; right: 0; bottom: calc(var(--rowh) * 0.5); z-index: 6; display: grid; justify-content: center; gap: 4px; padding: 14px 0; text-align: center; pointer-events: none; background: radial-gradient(closest-side, rgba(255, 255, 255, 0.85), transparent); animation: bf-banner 1.4s ease-out both; }
.bf-banner b { font: 900 min(calc(var(--rowh) * 0.85), 12vw, 64px)/1 var(--font-ui); white-space: nowrap; color: #0D7F71; -webkit-text-stroke: 5px #fff; paint-order: stroke fill; }
.bf-banner small { font: 800 17px var(--font-ui); color: var(--ink); }
@keyframes bf-banner { 0% { opacity: 0; scale: 0.5; rotate: -6deg; } 20% { opacity: 1; scale: 1.1; rotate: 2deg; } 32% { scale: 1; rotate: 0deg; } 82% { opacity: 1; } 100% { opacity: 0; translate: 0 -18px; } }

/* below the bar: what happened, and Undo */
.bf-foot { display: flex; align-items: center; gap: 10px; min-height: 52px; }
@media (max-width: 600px) { .bf-foot { padding-right: 48px; } } /* Undo clear of the feedback button in the corner */
.bf-msg { flex: 1; min-width: 0; margin: 0; font: 800 16px/1.3 var(--font-ui); color: var(--grape-d); }
.bf-msg .bf-frac { font-size: 13px; vertical-align: middle; color: inherit; text-shadow: none; padding: 0; }
.bf-msg .bf-frac i { height: 2px; width: calc(100% + 3px); }
.bf-undo { flex: none; min-width: 100px; min-height: 50px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--card); color: var(--ink); font: 800 17px var(--font-ui); box-shadow: 0 4px 0 #DCD3F0, var(--shadow-soft); cursor: pointer; touch-action: manipulation; }
.bf-undo:active { transform: translateY(3px); box-shadow: 0 1px 0 #DCD3F0; }
.bf-undo:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: 0 4px 0 #DCD3F0; }

@media (prefers-reduced-motion: reduce) {
  .bf-wrap, .bf-wrap * { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; transition-duration: 0.01s !important; }
}
