/* Beasties: Number Bite (inc/beasties-sums.php, assets/js/beasties-sums.js).
 * The board as in SumsView.swift: a dark card, the column sums on top, the row sums left, the grid a night floor of
 * tiles (family tiles in their colour, joined by bridges). Kept = digit on a yellow coin, munched = darker tile with
 * crumbs. .sms is the container; --u is one cell: the card is n + .95 (sums) + .25 (edge) cells wide. */

.sms { container-type: inline-size; width: 100%; position: relative; }
.sms-card {
	--u: calc(100cqw / (var(--n) + 1.2));
	position: relative; display: grid; box-sizing: border-box;
	grid-template-columns: calc(.95 * var(--u)) calc(var(--n) * var(--u));
	grid-template-rows: calc(.8 * var(--u)) calc(var(--n) * var(--u));
	padding: 0 calc(.25 * var(--u)) calc(.25 * var(--u)) 0;
	border-radius: max(12px, calc(.36 * var(--u)));
	background: linear-gradient(180deg, #322e53, #241e45);
	box-shadow: inset 0 0 0 3px #0e0b1a, 0 7px 0 #0e0b1a;
	color: #ede7ff; font: 800 calc(.5 * var(--u))/1 ui-rounded, "SF Pro Rounded", Nunito, system-ui, sans-serif;
	font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none;
}
.sms-cols { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.sms-rows { grid-column: 1; grid-row: 2; display: grid; grid-template-rows: repeat(var(--n), minmax(0, 1fr)); }
.sms-cl, .sms-rl {
	position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; margin: 0; border: 0;
	background: transparent; color: inherit; font: inherit; font-size: calc(.44 * var(--u)); font-weight: 900;
	border-radius: 7px; transition: background-color .25s, color .25s, opacity .4s;
}
.sms-cl { margin: calc(.06 * var(--u)) calc(.05 * var(--u)) calc(.04 * var(--u)); }
.sms-rl { margin: calc(.05 * var(--u)) calc(.03 * var(--u)) calc(.05 * var(--u)) calc(.05 * var(--u)); }
.sms-cl > b, .sms-rl > b { grid-area: 1 / 1; font-weight: 900; transition: transform .45s cubic-bezier(.3, 1.6, .5, 1), opacity .3s, color .3s; }
.sms .is-done > b { color: rgba(143, 134, 184, .45); }
.sms .is-hl { background: rgba(255, 255, 255, .13); }
.sms .is-hl > b { color: #ffd400; }
.sms .is-hl.is-done > b { color: rgba(255, 212, 0, .6); }
.sms .is-broke { background: rgba(255, 77, 109, .25); animation: sms-shake .4s ease-out; }
.sms .is-broke > b { color: #ff7d95; }
.sms .is-flash > b { animation: sms-flash .5s cubic-bezier(.3, 1.6, .5, 1); }
/* a sleeping sum: the little monster with its "z"; awake, the number springs in */
.sms-zz { grid-area: 1 / 1; position: relative; display: block; width: calc(.62 * var(--u)); opacity: 0; transform: scale(.4); transition: opacity .3s, transform .45s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none; }
.sms-zz img { display: block; width: 100%; height: auto; }
.sms-zz b { position: absolute; right: -16%; top: -30%; font-size: calc(.2 * var(--u)); font-weight: 900; color: rgba(237, 231, 255, .85); animation: sms-z 2.4s ease-in-out infinite; }
.sms .is-sleep .sms-zz { opacity: 1; transform: none; }
.sms .is-sleep > b { opacity: 0; transform: scale(1.6); }

/* the grid */
.sms-grid {
	grid-column: 2; grid-row: 2; position: relative; display: grid;
	grid-template-columns: repeat(var(--n), minmax(0, 1fr)); grid-template-rows: repeat(var(--n), minmax(0, 1fr));
	background: #1a1533; border-radius: calc(.16 * var(--u)); box-shadow: 0 0 0 2.5px #0e0b1a;
}
.sms-tiles { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: inherit; }
.sms .sc { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; margin: 0; border: 0; background: transparent; color: #ede7ff; font: inherit; }
/* munched: the tile goes darker, three crumbs stay */
.sms .sc::before {
	content: ""; position: absolute; inset: 7%; border-radius: 16%; opacity: 0;
	background:
		radial-gradient(circle at 40% 56%, rgba(143, 134, 184, .45) 0 7%, transparent 7.5%),
		radial-gradient(circle at 59% 46%, rgba(143, 134, 184, .45) 0 5.5%, transparent 6%),
		radial-gradient(circle at 52% 62%, rgba(143, 134, 184, .45) 0 4.5%, transparent 5%),
		rgba(26, 21, 51, .62);
	transition: opacity .25s ease-out calc(var(--dl, 0s) + .08s);
}
/* kept: a yellow coin behind the digit, with a little shine */
.sms .sc::after {
	content: ""; position: absolute; inset: 15%; border-radius: 50%;
	background: radial-gradient(circle at 50% 50%, transparent 58%, rgba(255, 255, 255, .55) 59% 64%, transparent 65%) no-repeat, #ffd400;
	background-size: 100% 100%; box-shadow: inset 0 0 0 max(1.5px, calc(.05 * var(--u))) #0e0b1a;
	-webkit-mask: none; transform: scale(.2); opacity: 0;
	transition: transform .3s cubic-bezier(.3, 1.6, .5, 1), opacity .15s;
}
.sms .sc > b { position: relative; z-index: 1; font-weight: 800; transition: transform .2s ease-in var(--dl, 0s), opacity .2s ease-in var(--dl, 0s), color .2s; }
.sms.is-caged .sc > b { font-size: calc(.46 * var(--u)); transform: translate(calc(.03 * var(--u)), calc(.03 * var(--u))); }
.sms.is-caged .sc::after { inset: 19%; transform: translate(calc(.03 * var(--u)), calc(.03 * var(--u))) scale(.2); }
.sms .sc.is-k::after { transform: scale(1); opacity: 1; }
.sms.is-caged .sc.is-k::after { transform: translate(calc(.03 * var(--u)), calc(.03 * var(--u))) scale(1); }
.sms .sc.is-k > b { color: #0e0b1a; }
.sms .sc.is-x::before { opacity: 1; }
.sms .sc.is-x > b { transform: scale(.05) rotate(-35deg); opacity: 0; }
.sms.is-caged .sc.is-x > b { transform: translate(calc(.03 * var(--u)), calc(.03 * var(--u))) scale(.05) rotate(-35deg); }
.sms .sc.is-pop { animation: sms-pop .26s ease-out; }
.sms .sc.is-shake { animation: sms-shake .3s ease-out; }
.sms .sc.is-shake::before { opacity: 1; background: rgba(255, 77, 109, .55); transition: none; }
.sms .sc.is-hl { background: rgba(255, 255, 255, .07); }
.sms .sc.is-key { z-index: 2; }
.sms .sc.is-key > i.sms-ring, .sms .sc.is-key::marker { display: none; }
.sms .sc.is-key { box-shadow: inset 0 0 0 2.5px #ffd400; border-radius: 18%; animation: sms-key 1.2s ease-in-out infinite; }
.sms .sc.is-ghost { box-shadow: inset 0 0 0 2.5px #4db8ff; border-radius: 18%; background: rgba(77, 184, 255, .2); }
.sms .sc.is-ghost > b { color: #bfe6ff; }
.sms .sc.is-broke { background: rgba(255, 77, 109, .22); }
.sms .sc.is-peek { background: rgba(255, 212, 0, .3); border-radius: 18%; }
/* what if: a tried mark is striped (kept) or crossed (munched), until it goes away again */
.sms .sc.is-tk::after { opacity: 1; transform: scale(1); background: repeating-linear-gradient(45deg, #ffd400 0 3px, #c9a600 3px 6px); }
.sms .sc.is-tk > b { color: #0e0b1a; }
.sms .sc.is-tx::before { opacity: 1; background: repeating-linear-gradient(-45deg, rgba(255, 77, 109, .35) 0 3px, rgba(26, 21, 51, .55) 3px 6px); transition: none; }
.sms .sc.is-tx > b { opacity: .45; text-decoration: line-through; text-decoration-color: #ff4d6d; }
.sms .sc.is-hint { z-index: 2; }
.sms .sc.is-hint > b { animation: sms-pop .4s ease-out; }

/* the family sums: a small tag at the top left of the family's first tile */
.sms-tag {
	position: absolute; z-index: 2; pointer-events: none;
	left: calc(var(--x) * var(--u) + .03 * var(--u)); top: calc(var(--y) * var(--u) + .03 * var(--u));
	min-width: calc(.3 * var(--u)); min-height: calc(.28 * var(--u)); padding: 0 calc(.06 * var(--u)); box-sizing: border-box;
	display: grid; place-items: center; border-radius: calc(.09 * var(--u)); background: var(--tc);
	font-size: max(9px, calc(.24 * var(--u))); font-weight: 900; color: #ede7ff; transform-origin: 0 0;
	transition: background-color .3s, color .3s, opacity .4s;
}
.sms-tag.is-done { background: var(--td); color: #8f86b8; }
.sms-tag.is-hl { box-shadow: 0 0 0 2px #ffd400; color: #ffd400; }
.sms-tag.is-flash { animation: sms-tag .5s cubic-bezier(.3, 1.6, .5, 1); }
.sms-tag.is-broke { box-shadow: 0 0 0 2px #ff4d6d; color: #ff7d95; animation: sms-shake .4s ease-out; }
/* a family lit up: its cells glow */
.sms .sc.is-fam { background: rgba(255, 255, 255, .1); border-radius: 18%; }

/* overlays: sweeps of finished lines, the touch, the "needs" badge */
.sms-ov { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.sms-sw { position: absolute; overflow: hidden; border-radius: 6px; }
.sms-sw b { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 212, 0, .75) 45%, rgba(255, 212, 0, .75) 55%, transparent); animation: sms-sweep .6s cubic-bezier(.4, 0, .2, 1) both; }
.sms-sw.is-v b { background: linear-gradient(180deg, transparent, rgba(255, 212, 0, .75) 45%, rgba(255, 212, 0, .75) 55%, transparent); animation-name: sms-sweep-v; }
.sms-touch { position: absolute; width: calc(100% / var(--n)); height: calc(100% / var(--n)); display: grid; place-items: center; }
.sms-touch::before { content: ""; width: 70%; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, .35); box-shadow: 0 0 0 3px rgba(255, 255, 255, .7); animation: sms-touch .45s ease-out forwards; }
.sms-touch.is-hold::before { animation: sms-hold .6s ease-out forwards; background: conic-gradient(#ffd400 var(--p, 0%), rgba(255, 255, 255, .25) 0); }
.sms-need {
	position: absolute; z-index: 6; white-space: nowrap; pointer-events: none;
	padding: 3px 8px; border-radius: 999px; background: #ffd400; color: #120f24; box-shadow: 0 0 0 2px #0e0b1a, 0 4px 10px rgba(0, 0, 0, .35);
	font: 800 max(10px, calc(.22 * var(--u)))/1.15 ui-rounded, "SF Pro Rounded", Nunito, system-ui, sans-serif;
	animation: sms-in .3s cubic-bezier(.3, 1.6, .5, 1);
}
.sms-need.is-zero { background: #7ed957; }
.sms-need.is-bad { background: #ff4d6d; color: #fff; }
.sms-rl .sms-need { left: 2px; top: -30%; transform: translateY(-50%); }
/* a column's badge sits under its column (above it, Gnatz peeks) */
.sms-cl .sms-need { left: 50%; top: calc(100% + var(--n) * var(--u) + .12 * var(--u)); transform: translateX(-50%); }
.sms-tag .sms-need { left: 0; top: -4px; transform: translateY(-100%); }

/* solved: the coins hop in a wave, the sums step back */
.sms.is-party .sms-cols, .sms.is-party .sms-rows, .sms.is-party .sms-tag { opacity: .35; }
.sms.is-party:not(.is-static) .sc.is-k { animation: sms-hop .55s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(var(--d) * 50ms); }
.sms:not(.is-live) .sc::before, .sms:not(.is-live) .sc::after, .sms:not(.is-live) .sc > b { transition: none; }

@keyframes sms-pop { 0% { transform: scale(1); } 25% { transform: scale(.82); } 65% { transform: scale(1.08); } 100% { transform: none; } }
@keyframes sms-shake { 0%, 100% { transform: none; } 20% { transform: translateX(5px); } 45% { transform: translateX(-5px); } 70% { transform: translateX(3px); } }
@keyframes sms-flash { 0% { transform: scale(1); } 30% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes sms-tag { 0% { transform: scale(1); } 30% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes sms-key { 0%, 100% { box-shadow: inset 0 0 0 2.5px #ffd400; } 50% { box-shadow: inset 0 0 0 2.5px #ffd400, 0 0 14px 3px rgba(255, 212, 0, .55); } }
@keyframes sms-sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes sms-sweep-v { 0% { transform: translateY(-100%); } 100% { transform: translateY(100%); } }
@keyframes sms-touch { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.15); opacity: 0; } }
@keyframes sms-hold { 0% { transform: scale(.7); opacity: 1; --p: 0%; } 85% { transform: scale(1); opacity: 1; --p: 100%; } 100% { transform: scale(1.15); opacity: 0; --p: 100%; } }
@keyframes sms-in { 0% { opacity: 0; scale: .6; } 100% { opacity: 1; scale: 1; } }
@keyframes sms-hop { 0%, 100% { translate: 0 0; } 35% { translate: 0 calc(-.28 * var(--u)); } }
@keyframes sms-z { 0%, 100% { transform: translateY(0); opacity: .85; } 50% { transform: translateY(-3px); opacity: .45; } }
@property --p { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
@media (prefers-reduced-motion: reduce) { .sms *, .sms *::before, .sms *::after { animation: none !important; transition: none !important; } }

/* ---------- on the game screen ---------- */
.gx.is-sums .gx-title .gx-stars { margin-top: 3px; gap: 2px; justify-content: center; }
.gx.is-sums .gx-title .st { width: 15px; height: 15px; }
.gx.is-sums .gx-head { margin-top: 2px; }
.bst-phone .gx-stage.is-sums { margin-top: auto; }
.bst-phone .gx.is-sums .gx-bottom { margin-bottom: auto; padding-bottom: 8%; }
.bst-phone .gx.is-sums .gx-tools { margin-top: 30px; }
.gx-stage.is-sums .sms { position: relative; z-index: 1; }
.gx-stage.is-sums .gx-peek, .sms-stage .gx-peek { z-index: 2; }
.gx.is-sums .sms-ti { position: relative; display: block; }
.gx.is-sums .sms-ti > svg { display: block; width: 22px; height: 22px; padding: 6px 13px; border-radius: 999px; transition: background-color .2s, color .2s; }
.gx.is-sums .gx-tool.is-active .sms-ti > svg { background: #ffd400; color: #120f24; }
.gx.is-sums .gx-tool.is-off { opacity: .45; }
.gx.is-sums .gx-tool.is-press .sms-ti { animation: bst-press .3s ease-out; }
.sms-price { position: absolute; right: -2px; top: -7px; display: inline-flex; align-items: center; gap: 1px; padding: 1px 5px; border-radius: 999px; background: #120f24; box-shadow: inset 0 0 0 1px rgba(237, 231, 255, .5); color: #ede7ff; font-style: normal; font-size: .58rem; font-weight: 800; }
.sms-price .st-price { width: 8px; height: 8px; }

/* ---------- guide ---------- */
.bst-board-card.is-sums { padding: 14px 14px 22px; max-width: 440px; }
.sms-stage { --pw: 19%; position: relative; padding-top: calc(var(--pw) * .764); }
.sms-stage .gx-peek { --px: .5; }
.bst-tier.is-sums .bst-tier-board { margin-bottom: 6px; }
.bst-tier.is-sums .sms-card { box-shadow: inset 0 0 0 2px #0e0b1a, 0 4px 0 #0e0b1a; }

/* ---------- overview ---------- */
.bst-mini.is-sums { background: #241e45; }
.bst-fan-card.is-sums { display: flex; align-items: center; padding: 10px; background: #1a1533; }
.bst-fan-card.is-sums .sms { align-self: center; }
.bst-game-well.is-sums { max-width: 200px; }
.bst-game.is-sums .bst-game-monster { display: none; }
/* how it works, step 2: one row shows itself, digit by digit (loops) */
.bst-how-sms { width: 62%; }
.bst-how-sms .sc.is-r::before, .bst-how-sms .sc.is-r::after { animation: sms-how 6s ease-out infinite both; animation-delay: calc(var(--d) * 110ms); transition: none; }
.bst-how-sms .sc.is-r > b { animation: sms-how-b 6s ease-out infinite both; animation-delay: calc(var(--d) * 110ms); transition: none; }
.bst-how-sms .sc.is-r.is-k > b { animation: none; }
@keyframes sms-how { 0%, 12% { opacity: 0; scale: .4; } 18% { opacity: 1; scale: 1.15; } 24%, 80% { opacity: 1; scale: 1; } 90%, 100% { opacity: 0; } }
@keyframes sms-how-b { 0%, 12% { opacity: 1; } 18%, 80% { opacity: 0; } 90%, 100% { opacity: 1; } }
.bst-how-board.is-sums { width: 60%; display: grid; place-items: center; }
.bst-how-board.is-sums .sms { animation: bst-unblur 5s ease-in-out infinite; }

/* ---------- one level ---------- */
.bst-level.is-sums .bst-boards { align-items: start; }
.bst-sms-stage { padding: 10px 10px 16px; border-radius: 22px; background: linear-gradient(180deg, #2f294f, #241e45); box-shadow: inset 0 0 0 3px #0e0b1a, 0 8px 0 #0e0b1a, 0 30px 60px -30px rgba(0, 0, 0, .7); }
.bst-sms-stage .sms-card { box-shadow: inset 0 0 0 2px #0e0b1a, 0 5px 0 #0e0b1a; }
.bst-level.is-sums .sms button { cursor: pointer; }
.bst-level.is-sums .sms button.sc:hover:not(.is-k):not(.is-x) { background: rgba(255, 255, 255, .1); border-radius: 18%; }
.bst-level.is-sums .sms button.sms-cl:hover, .bst-level.is-sums .sms button.sms-rl:hover { background: rgba(255, 255, 255, .1); }
.bst-level.is-sums .sms button:focus-visible { outline: 2px solid #ffd400; outline-offset: -2px; }
.bst-level.is-sums .bst-player-bar { margin-top: 16px; }
.bst-level.is-sums.is-done .sms-say { color: var(--zap); font-weight: 700; }
.bst-spoiler.is-sums { display: grid; place-items: center; padding: 14px 14px 22px; border-radius: 22px; background: radial-gradient(80% 80% at 50% 30%, #3a2f74, #1a1533); box-shadow: inset 0 0 0 3px #0e0b1a; }
.sms-sol { width: 100%; transition: filter .35s ease, transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.bst-spoiler.is-sums:not(.is-open) .sms-sol { filter: blur(18px) saturate(.5); transform: scale(.94); }
.bst-spoiler.is-sums .bst-cover { border-radius: 22px; }
.bst-level.is-sums .bst-move-list ol { columns: 2 24em; }
@media (max-width: 760px) { .bst-level.is-sums .bst-boards { max-width: 560px; } }
@media (max-width: 420px) { .bst-sms-stage, .bst-spoiler.is-sums { padding: 6px 6px 12px; border-radius: 16px; } }
