/**
 * Buzzy Bee styles.
 *
 * Two defensive habits run through this file, both learned from a live theme
 * fighting the plugin:
 *
 *   1. Selectors are deliberately over-specific (element + class together, e.g.
 *      `table.buzzy-bee__board td`). A theme rule like `.entry-content table td`
 *      outranks a lone `.buzzy-bee__board td`, which is how stray orange borders
 *      appeared inside the leaderboard.
 *   2. Inherited properties are reset explicitly rather than assumed. Anything a
 *      theme commonly sets on tables, buttons, and headings is declared here.
 *
 * Re-skinning for another client means overriding the custom properties on
 * .buzzy-bee-root and .buzzy-bee-modal -- no selector surgery required.
 */

.buzzy-bee-root,
.buzzy-bee-modal {
	--bb-honey: #f5b301;
	--bb-honey-dark: #c98a00;
	--bb-honey-deep: #8a5a00;
	--bb-ink: #3a2e12;
	--bb-ink-soft: #6b6454;
	--bb-ink-faint: #8a8474;
	--bb-surface: #ffffff;
	--bb-shell: #faf7ef;
	--bb-line: rgba(58, 46, 18, 0.12);
}

.buzzy-bee-root *,
.buzzy-bee-root *::before,
.buzzy-bee-root *::after,
.buzzy-bee-modal *,
.buzzy-bee-modal *::before,
.buzzy-bee-modal *::after {
	box-sizing: border-box;
}

.buzzy-bee__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* When the modal is open the page behind it must not scroll. */
html.buzzy-bee-locked,
html.buzzy-bee-locked body {
	overflow: hidden;
}

/* ------------------------------------------------------------------
 * Launcher card (sits in the post)
 * ---------------------------------------------------------------- */

.buzzy-bee-root .buzzy-bee-launch {
	max-width: 560px;
	margin: 1.5rem auto;
	padding: 1.5rem;
	color: var(--bb-ink);
	text-align: center;
	background: var(--bb-shell);
	border: 1px solid var(--bb-line);
	border-radius: 14px;
}

.buzzy-bee-root .buzzy-bee-launch__eyebrow {
	margin: 0 0 4px;
	font-size: 12px;
	font-weight: 600;
	color: var(--bb-honey-deep);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.buzzy-bee-root h3.buzzy-bee-launch__title {
	margin: 0 0 8px;
	font-size: 28px;
	font-weight: 700;
	line-height: 1.15;
	color: var(--bb-ink);
}

.buzzy-bee-root .buzzy-bee-launch__blurb {
	max-width: 42ch;
	margin: 0 auto 1.25rem;
	font-size: 16px;
	line-height: 1.6;
	color: var(--bb-ink-soft);
}

.buzzy-bee-root .buzzy-bee-launch__leader {
	margin: 12px 0 0;
	font-size: 13px;
	color: var(--bb-ink-faint);
}

.buzzy-bee-root .buzzy-bee-launch__leader:empty {
	display: none;
}

/* ------------------------------------------------------------------
 * Buttons
 * ---------------------------------------------------------------- */

.buzzy-bee-root button.buzzy-bee-btn,
.buzzy-bee-modal button.buzzy-bee-btn {
	display: inline-block;
	padding: 12px 22px;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
	color: var(--bb-ink);
	text-align: center;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	background: transparent;
	border: 1px solid var(--bb-honey-dark);
	border-radius: 999px;
	box-shadow: none;
}

.buzzy-bee-root button.buzzy-bee-btn--primary,
.buzzy-bee-modal button.buzzy-bee-btn--primary {
	background: var(--bb-honey);
}

.buzzy-bee-root button.buzzy-bee-btn:hover,
.buzzy-bee-modal button.buzzy-bee-btn:hover {
	color: var(--bb-ink);
	background: var(--bb-honey-dark);
}

.buzzy-bee-root button.buzzy-bee-btn:focus-visible,
.buzzy-bee-modal button.buzzy-bee-btn:focus-visible {
	outline: 3px solid var(--bb-honey-deep);
	outline-offset: 2px;
}

.buzzy-bee-modal button.buzzy-bee-btn--quiet {
	font-weight: 400;
	color: var(--bb-ink-soft);
	background: transparent;
	border-color: transparent;
	text-decoration: underline;
}

.buzzy-bee-modal button.buzzy-bee-btn--quiet:hover {
	color: var(--bb-ink);
	background: transparent;
}

/* ------------------------------------------------------------------
 * Modal shell
 * ---------------------------------------------------------------- */

.buzzy-bee-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2vh 2vw;
	background: rgba(40, 31, 10, 0.66);
}

/* Beats the bare `display: flex` above, so the attribute alone hides it. */
.buzzy-bee-modal[hidden] {
	display: none;
}

.buzzy-bee-modal__inner {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 1080px;
	height: 96vh;
	overflow: hidden;
	color: var(--bb-ink);
	background: var(--bb-shell);
	border-radius: 16px;
}

.buzzy-bee-modal__head {
	display: flex;
	flex: 0 0 auto;
	gap: 12px;
	align-items: center;
	padding: 14px 16px;
	border-bottom: 1px solid var(--bb-line);
}

.buzzy-bee-modal h2.buzzy-bee-modal__title {
	flex: 1 1 auto;
	margin: 0;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--bb-ink);
}

.buzzy-bee-modal__brand {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: var(--bb-honey-deep);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.buzzy-bee-modal .buzzy-bee-modal__best {
	margin: 0;
	font-size: 14px;
	color: var(--bb-ink-soft);
	white-space: nowrap;
}

.buzzy-bee-modal .buzzy-bee-modal__best strong {
	font-size: 18px;
	font-weight: 700;
	color: var(--bb-ink);
}

.buzzy-bee-modal button.buzzy-bee-close {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	padding: 0;
	font-family: inherit;
	font-size: 26px;
	line-height: 1;
	color: var(--bb-ink);
	cursor: pointer;
	background: transparent;
	border: 1px solid var(--bb-line);
	border-radius: 50%;
	box-shadow: none;
}

.buzzy-bee-modal button.buzzy-bee-close:hover {
	background: rgba(58, 46, 18, 0.08);
}

.buzzy-bee-modal button.buzzy-bee-close:focus-visible {
	outline: 3px solid var(--bb-honey-deep);
	outline-offset: 2px;
}

.buzzy-bee-modal__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 12px;
	min-height: 0;
	padding: 12px;
}

/* ------------------------------------------------------------------
 * Stage + canvas
 * ---------------------------------------------------------------- */

.buzzy-bee-stage {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

/* Size is set inline by JS: the canvas keeps a fixed 420x520 playfield so every
   player gets an identical game, and the backing store is matched to the real
   displayed pixel size so nothing is upscaled and blurry. */
.buzzy-bee-modal canvas.buzzy-bee__canvas {
	display: block;
	max-width: 100%;
	max-height: 100%;
	cursor: pointer;
	border-radius: 10px;
	touch-action: manipulation;
}

.buzzy-bee-modal canvas.buzzy-bee__canvas:focus-visible {
	outline: 3px solid var(--bb-honey);
	outline-offset: 3px;
}

/* ------------------------------------------------------------------
 * In-game overlay (name entry, results)
 * ---------------------------------------------------------------- */

.buzzy-bee-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	pointer-events: none;
}

/* Only the card itself takes clicks, so taps on the surrounding canvas are not
   swallowed while the overlay is empty. */
.buzzy-bee-overlay > * {
	pointer-events: auto;
}

.buzzy-bee-overlay:empty {
	display: none;
}

.buzzy-bee-card {
	width: 100%;
	max-width: 340px;
	padding: 20px;
	text-align: center;
	background: var(--bb-surface);
	border: 1px solid var(--bb-line);
	border-radius: 14px;
	box-shadow: 0 12px 32px rgba(40, 31, 10, 0.28);
}

.buzzy-bee-modal p.buzzy-bee-card__lead {
	margin: 0 0 12px;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--bb-ink);
}

.buzzy-bee-card__row {
	display: flex;
	gap: 8px;
	align-items: stretch;
}

.buzzy-bee-modal .buzzy-bee-card input[type="text"] {
	flex: 1 1 auto;
	min-width: 0;
	width: auto;
	height: auto;
	padding: 11px 12px;
	font-family: inherit;
	font-size: 16px;
	color: var(--bb-ink);
	background: #fff;
	border: 1px solid rgba(58, 46, 18, 0.3);
	border-radius: 9px;
	box-shadow: none;
}

.buzzy-bee-modal .buzzy-bee-card input[type="text"]:focus-visible {
	outline: 3px solid var(--bb-honey);
	outline-offset: 1px;
}

.buzzy-bee-modal .buzzy-bee-card button.buzzy-bee-btn {
	flex: 0 0 auto;
	padding: 11px 16px;
	font-size: 15px;
}

.buzzy-bee-modal p.buzzy-bee-card__error {
	margin: 10px 0 0;
	font-size: 14px;
	line-height: 1.4;
	color: #a32d2d;
}

.buzzy-bee-modal p.buzzy-bee-card__error:empty {
	display: none;
}

.buzzy-bee-modal p.buzzy-bee-card__note {
	margin: 10px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--bb-ink-faint);
}

.buzzy-bee-card__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin-top: 14px;
}

/* ------------------------------------------------------------------
 * Leaderboard panel
 * ---------------------------------------------------------------- */

.buzzy-bee-side {
	display: flex;
	flex: 0 0 auto;
	flex-direction: column;
	min-height: 0;
	padding: 14px 16px;
	background: var(--bb-surface);
	border: 1px solid var(--bb-line);
	border-radius: 12px;
}

.buzzy-bee-modal h3.buzzy-bee-side__title {
	margin: 0 0 10px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--bb-ink);
	letter-spacing: -0.01em;
}

.buzzy-bee-side__scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
}

/* Element+class specificity so a theme's `.entry-content table` rules lose. */
.buzzy-bee-modal table.buzzy-bee__board {
	width: 100%;
	margin: 0;
	font-family: inherit;
	font-size: 16px;
	background: transparent;
	border: 0;
	border-collapse: collapse;
	table-layout: fixed;
}

.buzzy-bee-modal table.buzzy-bee__board th,
.buzzy-bee-modal table.buzzy-bee__board td {
	/* Every border is declared here, so nothing inherited can draw stray lines. */
	background: transparent;
	border: 0;
	border-radius: 0;
}

.buzzy-bee-modal table.buzzy-bee__board th {
	padding: 0 8px 8px 0;
	font-size: 12px;
	font-weight: 600;
	color: var(--bb-ink-faint);
	text-align: left;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	border-bottom: 1px solid var(--bb-line);
}

.buzzy-bee-modal table.buzzy-bee__board td {
	padding: 10px 8px 10px 0;
	overflow: hidden;
	font-size: 16px;
	color: var(--bb-ink);
	text-overflow: ellipsis;
	white-space: nowrap;
	border-bottom: 1px solid var(--bb-line);
}

.buzzy-bee-modal table.buzzy-bee__board tr:last-child td {
	border-bottom: 0;
}

.buzzy-bee-modal table.buzzy-bee__board th.buzzy-bee__col-rank,
.buzzy-bee-modal table.buzzy-bee__board td.buzzy-bee__col-rank {
	width: 30px;
	font-weight: 600;
	color: var(--bb-ink-faint);
	text-align: left;
}

.buzzy-bee-modal table.buzzy-bee__board th.buzzy-bee__col-score,
.buzzy-bee-modal table.buzzy-bee__board td.buzzy-bee__col-score {
	width: 56px;
	padding-right: 0;
	font-weight: 700;
	text-align: right;
}

/* Nicknames wrap rather than ellipsising. A full 14-character name does not fit
   on one line in a 260px panel, and hiding half of someone's name on a
   leaderboard is worse than letting the row grow a little. */
.buzzy-bee-modal table.buzzy-bee__board td.buzzy-bee__col-name {
	overflow: visible;
	line-height: 1.3;
	text-overflow: clip;
	white-space: normal;
	overflow-wrap: anywhere;
}

.buzzy-bee-modal table.buzzy-bee__board tr.is-you td {
	color: var(--bb-honey-deep);
	background: #faeeda;
}

.buzzy-bee-modal table.buzzy-bee__board tr.is-you td.buzzy-bee__col-rank {
	color: var(--bb-honey-deep);
	border-radius: 8px 0 0 8px;
}

.buzzy-bee-modal table.buzzy-bee__board tr.is-you td.buzzy-bee__col-score {
	padding-right: 8px;
	border-radius: 0 8px 8px 0;
}

/* Its own line, so the tag never competes with the nickname for width. */
.buzzy-bee-modal .buzzy-bee__you {
	display: block;
	font-size: 11px;
	font-weight: 600;
	color: var(--bb-honey-deep);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* Specificity has to match the `table.buzzy-bee__board td` rule above, or the
   nowrap/ellipsis meant for long nicknames truncates this sentence instead. */
.buzzy-bee-modal table.buzzy-bee__board td.buzzy-bee__empty {
	padding: 16px 8px;
	color: var(--bb-ink-faint);
	text-align: center;
	white-space: normal;
}

.buzzy-bee-modal p.buzzy-bee-side__fact {
	margin: 12px 0 0;
	font-size: 13px;
	line-height: 1.6;
	color: var(--bb-ink-faint);
}

.buzzy-bee-modal p.buzzy-bee-side__cta {
	margin: 10px 0 0;
	font-size: 14px;
}

.buzzy-bee-modal p.buzzy-bee-side__cta a {
	color: var(--bb-honey-deep);
	text-decoration: underline;
}

/* ------------------------------------------------------------------
 * Wide screens: game and leaderboard side by side.
 * This is a UI arrangement only -- the playfield itself never changes shape,
 * so a score set on a phone means the same as one set on a desktop.
 * ---------------------------------------------------------------- */

@media (min-width: 760px) {

	.buzzy-bee-modal__body {
		flex-direction: row;
		gap: 16px;
		padding: 16px;
	}

	.buzzy-bee-side {
		flex: 0 0 clamp(260px, 30%, 330px);
	}

	.buzzy-bee-modal h2.buzzy-bee-modal__title {
		font-size: 24px;
	}
}

/* Stacked layout only: cap the board so it cannot crowd the game out on a phone.
   Proportional rather than a fixed pixel value, so tall phones show more rows.
   The ceiling must stop exactly where the two-column layout starts (760px) --
   overlapping ranges leave the side panel capped while it sits beside the game. */
@media (max-width: 759px) {

	.buzzy-bee-side__scroll {
		max-height: 22vh;
	}
}

/* Short landscape windows: drop the leaderboard height so the game keeps room. */
@media (max-width: 759px) and (max-height: 620px) {

	.buzzy-bee-side {
		padding: 10px 12px;
	}

	.buzzy-bee-modal h3.buzzy-bee-side__title {
		margin-bottom: 6px;
		font-size: 18px;
	}

	.buzzy-bee-side__scroll {
		max-height: 92px;
	}

	.buzzy-bee-modal p.buzzy-bee-side__fact {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {

	.buzzy-bee-card {
		box-shadow: none;
	}
}
