/**
 * Bible Memory
 *
 * The verse is always a grid of word slots sitting on hairline baselines,
 * so a hidden word reads as a blank on a worksheet rather than a missing tile.
 * All six modes are views onto that same grid.
 *
 * Everything is scoped to .bm-app and uses system fonts, so the plugin makes
 * no external requests and inherits nothing surprising from the theme.
 */

.bm-app {
	--bm-ink: #14171c;
	--bm-ink-soft: #565c66;
	--bm-paper: #f1f2ee;
	--bm-card: #fbfbf9;
	--bm-rule: #cfd2ca;
	--bm-accent: #245b5e;
	--bm-accent-soft: #e2ecea;
	--bm-gold: #b07d2b;
	--bm-correct: #3f7048;
	--bm-miss: #9c3b2c;

	--bm-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
	--bm-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	--bm-gap: 1rem;
	--bm-radius: 3px;

	box-sizing: border-box;
	max-width: 46rem;
	margin: 0 auto;
	padding: 1.5rem 1.25rem 2.5rem;
	background: var(--bm-paper);
	color: var(--bm-ink);
	font-family: var(--bm-sans);
	font-size: 1rem;
	line-height: 1.5;
}

.bm-app *,
.bm-app *::before,
.bm-app *::after {
	box-sizing: inherit;
}

.bm-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Top bar ---------- */

.bm-topbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: baseline;
	justify-content: space-between;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--bm-rule);
}

.bm-app .bm-h2 {
	margin: 0;
	font-family: var(--bm-serif);
	font-size: 1.5rem;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--bm-ink);
}

.bm-topbar__who {
	margin: 0.15rem 0 0;
	font-size: 0.8125rem;
	color: var(--bm-ink-soft);
}

.bm-topbar__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

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

.bm-app .bm-btn {
	display: inline-block;
	padding: 0.5rem 0.9rem;
	border: 1px solid var(--bm-accent);
	border-radius: var(--bm-radius);
	background: var(--bm-accent);
	color: #fff;
	font-family: var(--bm-sans);
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background 120ms ease, color 120ms ease;
}

.bm-app .bm-btn:hover {
	background: #1b494c;
	border-color: #1b494c;
	color: #fff;
}

.bm-app .bm-btn--ghost {
	background: transparent;
	border-color: var(--bm-rule);
	color: var(--bm-ink-soft);
}

.bm-app .bm-btn--ghost:hover {
	background: var(--bm-accent-soft);
	border-color: var(--bm-accent);
	color: var(--bm-accent);
}

.bm-app .bm-btn:focus-visible,
.bm-app [data-bm-word]:focus-visible,
.bm-app input:focus-visible,
.bm-app textarea:focus-visible,
.bm-app .bm-chip:focus-visible,
.bm-app .bm-mode:focus-visible {
	outline: 2px solid var(--bm-accent);
	outline-offset: 2px;
}

.bm-app .bm-btn[disabled] {
	opacity: 0.45;
	cursor: not-allowed;
}

/* ---------- Install hint ---------- */

.bm-install-hint {
	margin: 0.75rem 0 0;
	padding: 0.6rem 0.75rem;
	border-left: 3px solid var(--bm-gold);
	background: var(--bm-card);
	font-size: 0.8125rem;
	color: var(--bm-ink-soft);
}

/* ---------- Stats ---------- */

.bm-stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 1px;
	margin: 1rem 0 0;
	background: var(--bm-rule);
	border: 1px solid var(--bm-rule);
}

.bm-stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.1rem;
	padding: 0.7rem 0.35rem;
	background: var(--bm-card);
	text-align: center;
}

.bm-stat__num {
	font-family: var(--bm-serif);
	font-size: 1.375rem;
	font-weight: 600;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.bm-stat:first-child .bm-stat__num {
	color: var(--bm-gold);
}

.bm-stat__label {
	font-size: 0.6875rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--bm-ink-soft);
}

/* ---------- Verse picker ---------- */

.bm-verses {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	align-items: center;
	margin: 1.25rem 0 0;
}

.bm-verses__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.bm-verse-tab {
	display: inline-flex;
	align-items: baseline;
	gap: 0.4rem;
	padding: 0.4rem 0.7rem;
	border: 1px solid var(--bm-rule);
	border-radius: var(--bm-radius);
	background: var(--bm-card);
	color: var(--bm-ink-soft);
	font-size: 0.8125rem;
	cursor: pointer;
}

.bm-verse-tab[aria-selected="true"] {
	border-color: var(--bm-accent);
	background: var(--bm-accent-soft);
	color: var(--bm-accent);
	font-weight: 600;
}

.bm-verse-tab__week {
	font-size: 0.6875rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	opacity: 0.7;
}

.bm-verse-tab__best {
	font-size: 0.6875rem;
	font-variant-numeric: tabular-nums;
	color: var(--bm-correct);
}

/* ---------- Add-your-own form ---------- */

.bm-addform {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
	margin-top: 0.9rem;
	padding: 0.9rem;
	border: 1px solid var(--bm-rule);
	background: var(--bm-card);
}

.bm-field {
	display: block;
}

.bm-field--wide {
	grid-column: 1 / -1;
}

.bm-field__label {
	display: block;
	margin-bottom: 0.2rem;
	font-size: 0.6875rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--bm-ink-soft);
}

.bm-app input[type="text"],
.bm-app textarea {
	width: 100%;
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--bm-rule);
	border-radius: var(--bm-radius);
	background: #fff;
	color: var(--bm-ink);
	font-family: var(--bm-sans);
	font-size: 0.9375rem;
	line-height: 1.45;
}

.bm-app textarea {
	font-family: var(--bm-serif);
	font-size: 1.0625rem;
	resize: vertical;
}

.bm-addform__actions {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.bm-addform__error {
	margin: 0;
	font-size: 0.8125rem;
	color: var(--bm-miss);
}

/* ---------- Panel ---------- */

.bm-stage {
	margin-top: 1.25rem;
}

.bm-empty {
	padding: 2rem 1rem;
	border: 1px dashed var(--bm-rule);
	text-align: center;
	color: var(--bm-ink-soft);
}

.bm-panel {
	padding: 1.25rem;
	border: 1px solid var(--bm-rule);
	background: var(--bm-card);
}

.bm-reference {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: baseline;
	padding-bottom: 0.6rem;
	border-bottom: 1px solid var(--bm-rule);
}

.bm-reference__ref {
	font-family: var(--bm-serif);
	font-size: 1.125rem;
	font-weight: 600;
}

.bm-reference__translation {
	font-size: 0.6875rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--bm-ink-soft);
}

/* ---------- Read-through step ---------- */

.bm-read {
	padding-top: 1rem;
}

.bm-read__label {
	margin: 0 0 0.5rem;
	font-size: 0.6875rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--bm-ink-soft);
}

.bm-app .bm-read__text {
	margin: 0 0 1rem;
	padding: 0 0 0 1rem;
	border-left: 2px solid var(--bm-gold);
	font-family: var(--bm-serif);
	font-size: 1.25rem;
	line-height: 1.6;
}

/* ---------- Mode tabs ---------- */

.bm-modes {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin: 1rem 0 0.75rem;
}

.bm-mode {
	padding: 0.35rem 0.6rem;
	border: 1px solid transparent;
	border-radius: var(--bm-radius);
	background: transparent;
	color: var(--bm-ink-soft);
	font-family: var(--bm-sans);
	font-size: 0.8125rem;
	cursor: pointer;
}

.bm-mode[aria-selected="true"] {
	border-color: var(--bm-accent);
	color: var(--bm-accent);
	font-weight: 600;
}

.bm-hint {
	margin: 0 0 0.9rem;
	font-size: 0.8125rem;
	color: var(--bm-ink-soft);
}

/* ---------- The word grid: the signature ---------- */

.bm-grid {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.15rem 0.4rem;
	font-family: var(--bm-serif);
	font-size: 1.25rem;
	line-height: 2.1;
}

.bm-word {
	position: relative;
	display: inline-block;
	padding: 0 0.06em 0.12em;
	border-bottom: 1px solid transparent;
	white-space: pre;
	transition: color 120ms ease, border-color 120ms ease;
}

/* A hidden word keeps its own width, so the shape of the verse is never a clue you lose. */
.bm-word--hidden {
	border-bottom-color: var(--bm-rule);
	color: transparent;
}

.bm-word--revealed {
	color: var(--bm-ink);
	animation: bm-fade 140ms ease-out;
}

.bm-word--next {
	border-bottom-color: var(--bm-gold);
	border-bottom-width: 2px;
}

.bm-word--stub {
	color: var(--bm-ink-soft);
	border-bottom-color: var(--bm-rule);
	letter-spacing: 0.02em;
}

.bm-word--correct {
	color: var(--bm-correct);
	border-bottom-color: var(--bm-correct);
}

.bm-word--miss {
	color: var(--bm-miss);
	border-bottom-color: var(--bm-miss);
	text-decoration: line-through;
	text-decoration-thickness: 1px;
}

.bm-word__answer {
	display: block;
	font-family: var(--bm-sans);
	font-size: 0.6875rem;
	line-height: 1.2;
	color: var(--bm-ink-soft);
}

.bm-word__input {
	width: 100%;
	padding: 0 0.15em;
	border: 0;
	border-bottom: 2px solid var(--bm-gold);
	border-radius: 0;
	background: transparent;
	font-family: var(--bm-serif);
	font-size: inherit;
	line-height: inherit;
	color: var(--bm-ink);
}

.bm-word--gap {
	min-width: 2.5em;
}

@keyframes bm-fade {
	from {
		opacity: 0;
		transform: translateY(2px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* ---------- Word bank (scramble) ---------- */

.bm-bank {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin-top: 1rem;
	padding-top: 0.9rem;
	border-top: 1px dashed var(--bm-rule);
}

.bm-chip {
	padding: 0.3rem 0.55rem;
	border: 1px solid var(--bm-rule);
	border-radius: var(--bm-radius);
	background: var(--bm-paper);
	font-family: var(--bm-serif);
	font-size: 1rem;
	cursor: pointer;
}

.bm-chip:hover {
	border-color: var(--bm-accent);
	color: var(--bm-accent);
}

.bm-chip[data-used="1"] {
	opacity: 0.3;
	pointer-events: none;
}

/* ---------- Controls and result ---------- */

.bm-typearea {
	margin-top: 0.5rem;
}

.bm-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 1.1rem;
	padding-top: 0.9rem;
	border-top: 1px solid var(--bm-rule);
}

.bm-result {
	margin-top: 1rem;
}

.bm-accuracy__track {
	height: 8px;
	border: 1px solid var(--bm-rule);
	background: var(--bm-paper);
	overflow: hidden;
}

.bm-accuracy__fill {
	height: 100%;
	background: var(--bm-gold);
	transition: width 280ms ease;
}

.bm-accuracy__fill[data-band="good"] {
	background: var(--bm-correct);
}

.bm-accuracy__fill[data-band="poor"] {
	background: var(--bm-miss);
}

.bm-accuracy__label {
	margin: 0.4rem 0 0;
	font-size: 0.875rem;
	font-variant-numeric: tabular-nums;
}

.bm-result__saved {
	margin: 0.3rem 0 0;
	font-size: 0.75rem;
	color: var(--bm-ink-soft);
}

.bm-foot {
	margin-top: 1.25rem;
}

.bm-foot__note {
	margin: 0;
	font-size: 0.75rem;
	line-height: 1.5;
	color: var(--bm-ink-soft);
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
	.bm-app {
		padding: 1.1rem 0.9rem 2rem;
	}

	.bm-stats {
		grid-template-columns: repeat(2, 1fr);
	}

	.bm-addform {
		grid-template-columns: 1fr;
	}

	.bm-grid {
		font-size: 1.125rem;
		line-height: 2;
	}

	.bm-app .bm-read__text {
		font-size: 1.125rem;
	}

	.bm-controls .bm-btn {
		flex: 1 1 auto;
		text-align: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bm-app *,
	.bm-app *::before,
	.bm-app *::after {
		animation-duration: 0.001ms !important;
		transition-duration: 0.001ms !important;
	}
}
