/*
 * Shared playing-card + game-chrome styles for Klondike, Spider, FreeCell
 * and Mahjong. Registered as the "gst-cards-css" handle in functions.php.
 */

/* "How to play" quick panel — sits above the board, collapsible.
   Deliberately 3 short lines: the full rules live in the page content. */
.gst-howto {
	background: #fff;
	border: 1px solid var(--wp--preset--color--border, #E5E7EB);
	border-radius: 10px;
	padding: 8px 12px;
	margin-bottom: 12px;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--wp--preset--color--medium, #6B7280);
}
.gst-howto > summary {
	cursor: pointer;
	font-weight: 700;
	font-size: 13.5px;
	color: var(--wp--preset--color--dark, #111827);
	list-style: none;
	display: flex;
	align-items: center;
	gap: 6px;
}
.gst-howto > summary::-webkit-details-marker { display: none; }
.gst-howto > summary::after {
	content: '▾';
	margin-left: auto;
	color: var(--wp--preset--color--primary, #2563EB);
	transition: transform .15s ease;
}
.gst-howto[open] > summary::after { transform: rotate(180deg); }
.gst-howto ol {
	margin: 8px 0 2px;
	padding-left: 20px;
}
.gst-howto li { margin: 0 0 4px; }
.gst-howto li:last-child { margin-bottom: 0; }
.gst-howto b { color: var(--wp--preset--color--dark, #111827); font-weight: 600; }

/* board chrome */
.gst-game {
	background: linear-gradient(180deg, #F8FAFF, #EFF4FF);
	border: 1px solid #DBEAFE;
	border-radius: var(--wp--custom--radius--lg, 16px);
	padding: 14px;
}
.gst-game-bar {
	display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
	margin-bottom: 12px;
}
.gst-gbtn {
	border: 1px solid var(--wp--preset--color--border, #E5E7EB);
	background: #fff; color: var(--wp--preset--color--dark, #111827);
	border-radius: 8px; padding: 8px 14px; font: 600 13.5px/1 inherit;
	font-family: inherit; cursor: pointer;
}
.gst-gbtn:hover { border-color: var(--wp--preset--color--primary, #2563EB); color: var(--wp--preset--color--primary, #2563EB); }
.gst-gbtn.is-primary { background: var(--wp--preset--color--primary, #2563EB); border-color: var(--wp--preset--color--primary, #2563EB); color: #fff; }
.gst-gbtn.is-primary:hover { background: var(--wp--preset--color--primary-dark, #1D4ED8); color: #fff; }
.gst-gbtn[disabled] { opacity: .45; cursor: default; pointer-events: none; }
.gst-game-bar select {
	border: 1px solid var(--wp--preset--color--border, #E5E7EB); border-radius: 8px;
	padding: 7px 10px; font: 600 13.5px/1 inherit; font-family: inherit; background: #fff;
}
.gst-game-stats {
	margin-left: auto; display: flex; gap: 14px;
	font-size: 13px; font-weight: 600; color: var(--wp--preset--color--medium, #6B7280);
}
.gst-game-stats b { color: var(--wp--preset--color--dark, #111827); }

/* board + piles */
.gst-board { position: relative; --pcw: 72px; --pch: 100px; user-select: none; -webkit-user-select: none; }
.gst-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }
.gst-pile {
	position: relative; width: var(--pcw); min-height: var(--pch);
	border-radius: 8px;
}
.gst-pile.is-slot {
	border: 1.5px dashed rgba(37, 99, 235, .35);
	background: rgba(255, 255, 255, .5);
}
.gst-pile.is-slot::after {
	content: attr(data-label); position: absolute; inset: 0;
	display: flex; align-items: center; justify-content: center;
	font-size: 18px; color: rgba(37, 99, 235, .4); font-weight: 700;
}

/* cards */
.gst-pcard {
	position: absolute; left: 0; top: 0;
	/* border-box so the 1px border can't push cards past the board edge
	   (10-column Spider on a phone has no pixels to spare) */
	box-sizing: border-box;
	width: var(--pcw); height: var(--pch);
	background: #fff; border: 1px solid #C7D2E5; border-radius: 7px;
	box-shadow: 0 1px 2px rgba(17, 24, 39, .12);
	color: var(--wp--preset--color--dark, #111827);
	cursor: pointer; overflow: hidden;
	font-family: var(--wp--preset--font-family--heading, sans-serif);
}
.gst-pcard.is-red { color: #DC2626; }
.gst-pcard .pc-tl, .gst-pcard .pc-br {
	position: absolute; font-size: calc(var(--pcw) * .24); font-weight: 700; line-height: 1.05;
	display: flex; flex-direction: column; align-items: center;
}
.gst-pcard .pc-tl { top: 3px; left: 4px; }
.gst-pcard .pc-br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.gst-pcard .pc-tl i, .gst-pcard .pc-br i { font-style: normal; font-size: calc(var(--pcw) * .2); }
.gst-pcard .pc-c {
	position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
	font-size: calc(var(--pcw) * .5); opacity: .85;
}
.gst-pcard.is-down { background: repeating-linear-gradient(135deg, #2563EB 0 6px, #1D4ED8 6px 12px); border-color: #1D4ED8; }
.gst-pcard.is-down > * { display: none; }
.gst-pcard.is-sel { outline: 3px solid #F59E0B; outline-offset: -1px; z-index: 60 !important; }
.gst-pcard.is-sel ~ .gst-pcard { outline: 3px solid #F59E0B; outline-offset: -1px; }
.gst-pcard.is-hint { outline: 3px solid #16A34A; outline-offset: -1px; }

/* win overlay */
.gst-win {
	position: absolute; inset: 0; z-index: 200;
	display: flex; align-items: center; justify-content: center;
	background: rgba(17, 24, 39, .35); border-radius: 12px;
}
.gst-win-box {
	background: #fff; border-radius: 14px; padding: 26px 34px; text-align: center;
	box-shadow: var(--wp--custom--shadow--lg, 0 10px 30px rgba(17, 24, 39, .2));
}
.gst-win-box h3 { margin: 0 0 8px; font-size: 22px; }
.gst-win-box p { margin: 0 0 16px; color: var(--wp--preset--color--medium, #6B7280); font-weight: 600; }

@media (max-width: 600px) {
	.gst-game { padding: 8px; }
	.gst-row { gap: 5px; }
	.gst-game-stats { gap: 8px; font-size: 11.5px; }
	.gst-gbtn { padding: 7px 10px; font-size: 12.5px; }
}

/* ---------------- juice: effects layer ---------------- */
.gst-fx { position: absolute; inset: 0; z-index: 300; pointer-events: none; overflow: hidden; }
.gst-fx .gst-dragging { pointer-events: none; }

/* shake "no" (shared by cards + tiles + buttons) */
@keyframes gstShake {
	0%, 100% { translate: 0 0; }
	20% { translate: -5px 0; } 40% { translate: 5px 0; }
	60% { translate: -3px 0; } 80% { translate: 3px 0; }
}
.is-shake { animation: gstShake .32s ease; }

/* dragging clones + ghosted originals */
.gst-dragging {
	position: absolute !important;
	box-shadow: 0 14px 28px rgba(17, 24, 39, .28) !important;
	z-index: 400 !important;
	will-change: transform;
}
.is-ghost { opacity: .35; }

/* particles */
.gst-part {
	position: absolute; width: 7px; height: 7px; border-radius: 50%;
	animation: gstPart .6s ease-out forwards;
}
@keyframes gstPart {
	from { transform: translate(0, 0) scale(1); opacity: 1; }
	to { transform: translate(var(--px, 20px), var(--py, -20px)) scale(.3); opacity: 0; }
}

/* rising floater text ("Nice!", "New best!") */
.gst-float {
	position: absolute; transform: translateX(-50%);
	font: 800 20px/1 var(--wp--preset--font-family--heading, sans-serif);
	color: var(--wp--preset--color--primary, #2563EB);
	text-shadow: 0 1px 0 #fff;
	animation: gstFloat 1.25s ease-out forwards;
	white-space: nowrap;
}
.gst-float.is-gold { color: #B45309; }
@keyframes gstFloat {
	from { translate: 0 0; opacity: 0; scale: .7; }
	20% { opacity: 1; scale: 1.1; }
	to { translate: 0 -46px; opacity: 0; scale: 1; }
}

/* confetti */
.gst-conf {
	position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
	animation: gstConf 2s linear forwards;
}
@keyframes gstConf {
	from { transform: translate(0, 0) rotate(0); opacity: 1; }
	to { transform: translate(var(--cx, 0), 640px) rotate(720deg); opacity: .85; }
}

/* cascading win cards */
.gst-casc { position: absolute !important; z-index: 350 !important; will-change: transform; }

/* drag needs the finger — cards must not scroll the page mid-drag */
.gst-board .gst-pcard { touch-action: none; }

/* progress bar (foundation % / pairs cleared / runs done) */
.gst-progressbar {
	height: 5px; border-radius: 3px; margin-bottom: 10px;
	background: rgba(37, 99, 235, .12); overflow: hidden;
}
.gst-progressbar i {
	display: block; height: 100%; width: 0;
	border-radius: 3px;
	background: linear-gradient(90deg, var(--wp--preset--color--primary, #2563EB), var(--wp--preset--color--success, #16A34A));
	transition: width .35s ease;
}

/* icon buttons (mute) */
.gst-gbtn.is-icon { padding: 8px 10px; }

/* how-to grid: steps beside the animated demo */
.gst-howto-grid { display: flex; gap: 18px; align-items: center; }
.gst-howto-grid ol { flex: 1; }
.gst-demo {
	flex-shrink: 0; width: 168px; height: 116px; position: relative;
	background: linear-gradient(180deg, #F8FAFF, #EFF4FF);
	border: 1px solid #DBEAFE; border-radius: 10px; overflow: hidden;
}
.gst-demo .dc {
	position: absolute; width: 38px; height: 53px;
	background: #fff; border: 1px solid #C7D2E5; border-radius: 5px;
	box-shadow: 0 1px 3px rgba(17, 24, 39, .15);
	font: 700 13px/1 var(--wp--preset--font-family--heading, sans-serif);
	color: #111827; padding: 3px 0 0 4px; box-sizing: border-box;
}
.gst-demo .dc.red { color: #DC2626; }
.gst-demo .ok {
	position: absolute; font-size: 17px; font-weight: 800; color: #16A34A; opacity: 0;
}
.gst-demo .dtile {
	position: absolute; width: 34px; height: 44px;
	background: linear-gradient(180deg, #FFFFFF, #F0F3F8); border: 1px solid #C7D2E5;
	border-bottom: 4px solid #CBD5E1; border-radius: 5px;
	display: flex; align-items: center; justify-content: center;
	font: 700 17px/1 serif; color: #1D4ED8; box-sizing: border-box;
}
.gst-demo .dtile.grey { filter: grayscale(1) brightness(.92); }
@media (max-width: 600px) {
	.gst-howto-grid { flex-direction: column; align-items: stretch; }
	.gst-demo { width: 100%; }
}
