/* Gambrell Bingo — card styles (Good Life Bingo design).
   Mobile-first; the two-column desktop layout starts at 960px. */

.gambrell-bingo {
	--gambrell-bingo-apricot: #ffc573;
	--gambrell-bingo-apricot-50: #ffe2b9;
	--gambrell-bingo-apricot-27: #ffefd9;
	--gambrell-bingo-black: #000000;
	--gambrell-bingo-white: #ffffff;
	--gambrell-bingo-navy: #3a4b56;
	--gambrell-bingo-font-heading: "Sora", sans-serif;
	--gambrell-bingo-font-body: "DM Sans", sans-serif;

	color: var(--gambrell-bingo-black);
	font-family: var(--gambrell-bingo-font-body);
	/* Fill the parent container; the container supplies background and spacing.
	   inline-size containment lets the layout respond to the container's
	   actual width rather than the viewport. */
	width: 100%;
	container-type: inline-size;
	/* Named so the toolbar can be its own container without stealing the
	   card-level queries from its descendants. */
	container-name: gambrell-bingo-card;
}

.gambrell-bingo,
.gambrell-bingo *,
.gambrell-bingo *::before,
.gambrell-bingo *::after {
	box-sizing: border-box;
}

/* :where() keeps this reset at class-level specificity so the component
   rules below always win over it, while still beating theme button styles. */
.gambrell-bingo :where(button) {
	appearance: none;
	-webkit-appearance: none;
	border: none;
	background: none;
	font: inherit;
	color: inherit;
	cursor: pointer;
	padding: 0;
	margin: 0;
	text-transform: none;
	box-shadow: none;
	border-radius: 0;
}

.gambrell-bingo button:focus-visible {
	outline: 3px solid var(--gambrell-bingo-black);
	outline-offset: 2px;
}

/* ---- Intro column ---- */

.gambrell-bingo__title {
	font-family: var(--gambrell-bingo-font-heading);
	font-weight: 600;
	font-size: 32px;
	line-height: 48px;
	color: var(--gambrell-bingo-black);
	margin: 0 0 16px;
}

.gambrell-bingo__description {
	font-size: 18px;
	line-height: 28px;
	letter-spacing: 0.18px;
	margin-bottom: 16px;
}

.gambrell-bingo__description p {
	font-size: 18px;
	line-height: 28px;
	letter-spacing: 0.18px;
	margin: 0 0 16px;
}

.gambrell-bingo__description ul,
.gambrell-bingo__description ol {
	margin: 0 0 16px;
	padding-left: 27px;
}

.gambrell-bingo__description li {
	margin-bottom: 8px;
}

.gambrell-bingo__description > :last-child {
	margin-bottom: 0;
}

.gambrell-bingo__generate {
	display: inline-block;
	background: var(--gambrell-bingo-black);
	color: var(--gambrell-bingo-white);
	font-family: var(--gambrell-bingo-font-heading);
	font-weight: 700;
	font-size: 16px;
	line-height: 24px;
	letter-spacing: 0.48px;
	text-align: center;
	padding: 12px 28px;
	border: 2px solid var(--gambrell-bingo-black);
	border-radius: 100px;
	width: 280px;
	max-width: 100%;
	transition: opacity 0.15s ease;
}

.gambrell-bingo__generate:hover {
	opacity: 1;
	background: linear-gradient(151deg, #00b4c3 23.41%, #a0d300 91.08%);
	color: var(--gambrell-bingo-black);
}

/* ---- Play column ---- */

.gambrell-bingo__play {
	position: relative;
	margin-top: 24px;
}

.gambrell-bingo__toolbar {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	/* Once the tags gain their text labels the row can outgrow the play column
	   (worst around a 935-1085px card, where the two-column layout has started
	   but is still narrow). Let Reset drop to its own line rather than overrun
	   the edge. */
	flex-wrap: wrap;
	gap: 16px;
	margin-bottom: 12px;
	/* Its own container, so the tag labels can respond to the width the
	   toolbar actually has rather than to the card's layout breakpoint. */
	container-type: inline-size;
	container-name: gambrell-bingo-toolbar;
}

.gambrell-bingo__tags {
	display: flex;
	align-items: center;
	/* The three labelled buttons need ~470px. Below that they wrap among
	   themselves rather than running past the toolbar's edge. */
	flex-wrap: wrap;
	gap: 12px 24px;
}

/* On the narrowest toolbars the icon tags plus Reset are a few pixels over the
   width available, dropping Reset to a second line. Trimming the gap between
   the tags buys back 8px, enough to keep the row together down to a 320px
   viewport (a 260px toolbar) with a couple of pixels to spare. */
@container gambrell-bingo-toolbar (max-width: 330px) {
	.gambrell-bingo__tags {
		column-gap: 20px;
	}
}

.gambrell-bingo__tag {
	display: flex;
	align-items: center;
	gap: 6px;
	background: var(--gambrell-bingo-black);
	border-radius: 16px;
	padding: 12px;
	transition: opacity 0.15s ease;
}

.gambrell-bingo__tag:hover {
	opacity: 0.8;
}

.gambrell-bingo__tag-icon {
	display: block;
	width: 10px;
	height: 10px;
	flex-shrink: 0;
}

.gambrell-bingo__tag-label {
	display: none;
	font-family: var(--gambrell-bingo-font-body);
	font-weight: 600;
	font-size: 14px;
	line-height: 1;
	letter-spacing: 0.14px;
	color: var(--gambrell-bingo-white);
	white-space: nowrap;
}

/* Icon-only tags are a space measure; show the full labelled buttons as soon
   as the toolbar itself has room for them, whatever the card layout is doing.
   Must follow the display: none above — same specificity, so source order
   decides. */
@container gambrell-bingo-toolbar (min-width: 500px) {
	.gambrell-bingo__tag-label {
		display: block;
	}
}

.gambrell-bingo__reset {
	font-family: var(--gambrell-bingo-font-heading);
	font-weight: 600;
	font-size: 16px;
	line-height: 24px;
	color: var(--gambrell-bingo-black);
	border-bottom: 2px solid var(--gambrell-bingo-black);
	white-space: nowrap;
	/* Keeps it against the right edge on the line it lands on — space-between
	   would otherwise park it on the left once it wraps. */
	margin-left: auto;
}

/* ---- Popovers (Share link / QR code) ---- */

.gambrell-bingo__popover {
	position: absolute;
	z-index: 20;
	top: 52px;
	left: 0;
	background: var(--gambrell-bingo-white);
	border: 2px solid var(--gambrell-bingo-black);
	border-radius: 8px;
	padding: 16px;
	filter: drop-shadow(8px 10px 6.4px rgba(0, 0, 0, 0.23));
}

.gambrell-bingo__popover--share {
	width: min(522px, 100%);
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.gambrell-bingo__popover--share[hidden],
.gambrell-bingo__popover--qr[hidden] {
	display: none;
}

.gambrell-bingo__popover--qr {
	width: min(392px, 100%);
	display: flex;
	align-items: center;
	gap: 16px;
}

.gambrell-bingo__popover-title {
	font-family: var(--gambrell-bingo-font-body);
	font-weight: 600;
	font-size: 24px;
	line-height: 1.3;
	letter-spacing: 0.24px;
	color: var(--gambrell-bingo-black);
	margin: 0;
	padding-right: 36px;
}

.gambrell-bingo__popover-close {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.gambrell-bingo__popover-close img {
	display: block;
	width: 32px;
	height: 32px;
}

.gambrell-bingo__share-row {
	display: flex;
	align-items: stretch;
	gap: 8px;
	width: 100%;
}

.gambrell-bingo__share-url {
	flex: 1;
	min-width: 0;
	background: var(--gambrell-bingo-white);
	border: 2px solid var(--gambrell-bingo-black);
	border-radius: 4px;
	padding: 8px 16px;
	font-family: var(--gambrell-bingo-font-body);
	font-size: 18px;
	line-height: 28px;
	letter-spacing: 0.18px;
	color: rgba(58, 75, 86, 0.7);
}

.gambrell-bingo__copy {
	flex-shrink: 0;
	background: var(--gambrell-bingo-black);
	color: var(--gambrell-bingo-white);
	border: 2px solid var(--gambrell-bingo-black);
	border-radius: 100px;
	padding: 10px 26px;
	font-family: var(--gambrell-bingo-font-heading);
	font-weight: 700;
	font-size: 16px;
	line-height: 24px;
	letter-spacing: 0.48px;
	white-space: nowrap;
}

.gambrell-bingo__copy--copied {
	background: var(--gambrell-bingo-white);
	color: var(--gambrell-bingo-black);
}

.gambrell-bingo__qr {
	width: 115px;
	height: 115px;
	flex-shrink: 0;
}

.gambrell-bingo__qr svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* ---- BINGO! banner ---- */

.gambrell-bingo__banner {
	font-family: var(--gambrell-bingo-font-heading);
	font-weight: 700;
	font-size: 24px;
	line-height: 32px;
	letter-spacing: 0.15em;
	text-align: center;
	color: var(--gambrell-bingo-black);
	margin: 0 0 12px;
	animation: gambrell-bingo-pop 0.4s ease-out;
}

@keyframes gambrell-bingo-pop {
	0% { transform: scale(0.5); opacity: 0; }
	70% { transform: scale(1.1); }
	100% { transform: scale(1); opacity: 1; }
}

/* ---- Board ---- */

.gambrell-bingo__grid {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	/* Long phrases wrap past the cell's aspect ratio, and cells clip rather
	   than grow (their overflow: hidden suppresses the content-based minimum
	   height). syncRowHeight() measures the tallest label and publishes a row
	   height here; without JS, rows fall back to the aspect ratio below. */
	grid-auto-rows: var(--gambrell-bingo-row, auto);
	border: 2px solid var(--gambrell-bingo-black);
	border-radius: 8px;
	overflow: hidden;
	background: var(--gambrell-bingo-white);
}

.gambrell-bingo__cell {
	position: relative;
	/* An aspect ratio suppresses stretch alignment, so a cell would sit at its
	   ratio height inside a taller measured row. Pinning both axes fills the
	   row when one is measured; when rows are auto, the percentage height is
	   indefinite and the ratio drives the cell's height as before. Both are
	   needed — with only a definite height the ratio starts sizing the width. */
	aspect-ratio: 76 / 88;
	width: 100%;
	height: 100%;
	background: var(--gambrell-bingo-white);
	border: 1px solid var(--gambrell-bingo-black);
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 6%;
	overflow: hidden;
}

/* Edge to edge on a phone a cell is only ~74px across, where 6% spends nearly
   9px of the line on padding and can cost a long phrase a whole line. A flat
   3px still keeps the text off the borders. Set from syncGridBleed()'s class
   so it applies exactly when the negative margins do. */
.gambrell-bingo__grid--bleed .gambrell-bingo__cell {
	padding: 3px;
}

/* Corner cells follow the grid's inner curve (8px outer radius minus the
   2px border) so a marked cell's fill doesn't clip the rounded border. */
.gambrell-bingo__cell:first-child {
	border-top-left-radius: 6px;
}

.gambrell-bingo__cell:nth-child(5) {
	border-top-right-radius: 6px;
}

.gambrell-bingo__cell:nth-child(21) {
	border-bottom-left-radius: 6px;
}

.gambrell-bingo__cell:last-child {
	border-bottom-right-radius: 6px;
}

.gambrell-bingo__cell:disabled {
	cursor: default;
}

.gambrell-bingo__cell-label {
	font-family: var(--gambrell-bingo-font-body);
	font-weight: 400;
	font-size: 10px;
	line-height: 12px;
	letter-spacing: 0.1px;
	color: var(--gambrell-bingo-black);
	/* As a flex item the label's automatic minimum is the longest word, which
	   holds the line box open and leaves break-word nothing to break. Zeroing
	   it lets a word longer than the cell (e.g. "Infrastructure" on a phone)
	   actually wrap instead of spilling over the borders. */
	min-width: 0;
	overflow-wrap: break-word;
}

/* Hyphenation is scoped to the words that need it — bingo.js wraps anything
   12 characters or longer in this span. Left on the whole label it also breaks
   words that fit fine ("Com-munity"), which reads as an error on a card. */
.gambrell-bingo__long-word {
	-webkit-hyphens: auto;
	hyphens: auto;
}

.gambrell-bingo__cell--free .gambrell-bingo__cell-label {
	font-weight: 700;
	font-size: 14px;
	line-height: 16px;
	letter-spacing: 0.14px;
}

/* Inactive preview before the visitor generates their card */
.gambrell-bingo--start .gambrell-bingo__cell-label {
	opacity: 0.6;
}

/* Marked cell: apricot fill, dimmed label, X across the square */
.gambrell-bingo__cell[aria-pressed="true"] {
	background: var(--gambrell-bingo-apricot);
}

.gambrell-bingo__cell[aria-pressed="true"] .gambrell-bingo__cell-label {
	opacity: 0.4;
}

.gambrell-bingo__cell[aria-pressed="true"]::before,
.gambrell-bingo__cell[aria-pressed="true"]::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 160%;
	height: 2px;
	background: var(--gambrell-bingo-black);
	pointer-events: none;
}

.gambrell-bingo__cell[aria-pressed="true"]::before {
	transform: translate(-50%, -50%) rotate(46deg);
}

.gambrell-bingo__cell[aria-pressed="true"]::after {
	transform: translate(-50%, -50%) rotate(-46deg);
}

/* ---- Desktop (two-column) layout, driven by the container's width ---- */

@container gambrell-bingo-card (min-width: 900px) {
	.gambrell-bingo__inner {
		display: grid;
		grid-template-columns: minmax(0, 455fr) minmax(0, 625fr);
		gap: 42px;
		align-items: center;
	}

	.gambrell-bingo__title {
		font-size: 38px;
		line-height: 48px;
		letter-spacing: -0.38px;
		margin-bottom: 23px;
	}

	.gambrell-bingo__generate {
		width: auto;
		font-size: 24px;
		line-height: 32px;
		letter-spacing: 0.72px;
		padding: 24px 40px;
		margin-top: 8px;
	}

	.gambrell-bingo__play {
		margin-top: 0;
	}

	.gambrell-bingo__toolbar {
		margin-bottom: 8px;
	}

	.gambrell-bingo__popover {
		top: 44px;
	}

	.gambrell-bingo__cell {
		aspect-ratio: 125 / 129;
	}

	.gambrell-bingo__cell-label {
		font-size: 14px;
		line-height: 16px;
		letter-spacing: 0.14px;
	}
}

/* Previous card sits beside Reset board; the wrapper takes over the auto
   margin so the pair stay together when the toolbar wraps. */
.gambrell-bingo__toolbar-actions {
	display: flex;
	align-items: flex-end;
	gap: 16px;
	margin-left: auto;
}

.gambrell-bingo__toolbar-actions .gambrell-bingo__reset {
	margin-left: 0;
}

.gambrell-bingo__previous {
	font-family: var(--gambrell-bingo-font-heading);
	font-weight: 600;
	font-size: 16px;
	line-height: 24px;
	color: var(--gambrell-bingo-black);
	border-bottom: 2px solid var(--gambrell-bingo-black);
	white-space: nowrap;
}

/* Transient prompt after a deal, offering to take the previous card back. */
.gambrell-bingo__undo {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px 12px;
	margin-bottom: 12px;
	padding: 10px 14px;
	border: 2px solid var(--gambrell-bingo-black);
	font-family: var(--gambrell-bingo-font-heading);
	font-size: 15px;
	line-height: 22px;
}

.gambrell-bingo__undo[hidden] {
	display: none;
}

.gambrell-bingo__undo-btn {
	font-family: inherit;
	font-weight: 700;
	font-size: 15px;
	line-height: 22px;
	color: var(--gambrell-bingo-black);
	border-bottom: 2px solid var(--gambrell-bingo-black);
	white-space: nowrap;
}

/* The prompt is a live-region convenience, not part of the printed card. */
@media print {
	.gambrell-bingo__undo,
	.gambrell-bingo__previous {
		display: none !important;
	}
}
