/* ---------- Base / tokens ----------
   Brand palette sampled directly from the Maargamitra logo illustration
   (the book-and-paths artwork) -- see themes/margamitra/README.md for the
   source. Navy is ink/structure, Teal is the primary interactive color;
   Coral/Gold/Sky/Green rotate as accents and are not all used in one place. */
:root {
	--mm-text: #002155;
	--mm-text-muted: #4a5b78;
	--mm-border: #d8e4ea;
	--mm-accent: #02a3a0;
	--mm-accent-dark: #017673;
	--mm-navy: #002155;
	--mm-coral: #fd6e3a;
	--mm-gold: #fdb210;
	--mm-sky: #7cd6fc;
	--mm-green: #1a8856;
	--mm-bg: #fbfeff;
	--mm-bg-subtle: #f2f8fa;
	--mm-gem-bg: #fffaf0;
	--mm-gem-border: var(--mm-gold);
	--mm-gem-text: #8a5a00;
	--mm-font-heading: "Spectral", Georgia, serif;
	--mm-font-body: "Lora", Georgia, serif;
	--mm-space-1: 0.5rem;
	--mm-space-2: 1rem;
	--mm-space-3: 1.5rem;
	--mm-space-4: 2rem;
	--mm-radius: 4px;
}

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

body {
	margin: 0;
	font-family: var(--mm-font-body);
	color: var(--mm-text);
	background: var(--mm-bg);
	line-height: 1.6;
}

a {
	color: var(--mm-accent);
}

a:hover {
	color: var(--mm-coral);
}

h1, h2, h3 {
	font-family: var(--mm-font-heading);
	line-height: 1.25;
}

.mm-container {
	max-width: 900px;
	margin: 0 auto;
	padding: 0 var(--mm-space-3);
}

/* ---------- Header / nav ---------- */
.mm-site-header {
	border-bottom: 1px solid var(--mm-border);
	background: var(--mm-bg);
}

.mm-site-header-inner {
	max-width: 900px;
	margin: 0 auto;
	padding: var(--mm-space-2) var(--mm-space-3);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--mm-space-2);
}

.mm-site-title {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-family: var(--mm-font-heading);
	font-weight: 600;
	font-size: 1.25rem;
	text-decoration: none;
	color: var(--mm-navy);
}

.mm-site-logo {
	width: 32px;
	height: 32px;
	border-radius: 8px;
	object-fit: cover;
	flex-shrink: 0;
}

.mm-primary-nav ul {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: var(--mm-space-3);
	margin: 0;
	padding: 0;
}

.mm-primary-nav a {
	text-decoration: none;
	color: var(--mm-text-muted);
	font-size: 0.95rem;
}

.mm-short-names-toggle {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.85rem;
	color: var(--mm-text-muted);
	cursor: pointer;
	white-space: nowrap;
}

.mm-short-names-toggle input {
	cursor: pointer;
}

.mm-primary-nav a:hover {
	color: var(--mm-accent);
}

.mm-site-main {
	padding: var(--mm-space-4) 0;
	min-height: 50vh;
}

.mm-site-footer {
	border-top: 1px solid var(--mm-border);
	margin-top: var(--mm-space-4);
	padding: var(--mm-space-3) 0;
	color: var(--mm-text-muted);
	font-size: 0.85rem;
}

.mm-footer-legal-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: var(--mm-space-2);
}

.mm-footer-legal-links a {
	display: inline-block;
	background: var(--mm-bg-subtle);
	color: var(--mm-accent-dark);
	border: 1px solid var(--mm-border);
	border-radius: 999px;
	padding: 0.35em 0.85em;
	font-size: 0.8rem;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.15s, border-color 0.15s;
}

.mm-footer-legal-links a:hover {
	background: #e3f6f5;
	border-color: var(--mm-accent);
	color: var(--mm-accent-dark);
}

/* ---------- Plain content pages (concept/glossary pages) ---------- */
.mm-page-content h2 {
	margin-top: var(--mm-space-4);
	font-size: 1.15rem;
}

.mm-page-content p {
	margin: 0 0 var(--mm-space-2);
	max-width: 65ch;
}

.mm-page-content ul {
	max-width: 65ch;
}

.mm-concept-table,
.mm-glossary-list {
	max-width: 65ch;
}

.mm-concept-table {
	border-collapse: collapse;
	margin: var(--mm-space-2) 0;
}

.mm-concept-table th,
.mm-concept-table td {
	border: 1px solid var(--mm-border);
	padding: 0.4rem 0.75rem;
	text-align: left;
	font-size: 0.9rem;
}

.mm-concept-table thead th {
	background: var(--mm-bg-subtle);
}

.mm-glossary-list {
	line-height: 1.9;
}

/* Small contextual "what does this mean?" links next to badges/labels
   throughout the interactive pages, pointing at the matching concept page. */
.mm-info-link {
	font-size: 0.75rem;
	color: var(--mm-text-muted);
	text-decoration: none;
	border-bottom: 1px dotted var(--mm-text-muted);
	margin-left: 0.3rem;
}

.mm-info-link:hover {
	color: var(--mm-accent);
	border-color: var(--mm-accent);
}

.mm-hint {
	font-size: 0.85rem;
	color: var(--mm-text-muted);
	max-width: 560px;
}

/* ---------- Rank finder ---------- */
.mm-rank-finder {
	border: 1px solid var(--mm-border);
	border-radius: var(--mm-radius);
	padding: var(--mm-space-3);
	margin-bottom: var(--mm-space-4);
	max-width: 760px; /* widened for the multi-exam field grid, was 560px for one input */
}

.mm-rank-finder form {
	display: flex;
	flex-wrap: wrap;
	gap: var(--mm-space-2);
	align-items: end;
}

/* Multi-exam rank finder (2026-09-08): one optional field per active/
   evidence_pending/not_applicable exam, at least one required (enforced in
   rank-finder.js, not here). */
.mm-rank-fields {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: var(--mm-space-2);
	width: 100%;
}

.mm-rank-field {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
}

.mm-rank-field label {
	font-size: 0.8rem;
	color: var(--mm-text-muted);
}

.mm-rank-form-error {
	width: 100%;
	color: var(--mm-error, #b3261e);
	font-size: 0.85rem;
	margin: 0;
}

.mm-rank-finder input,
.mm-rank-finder select,
.mm-compare-picker select {
	padding: 0.4rem 0.5rem;
	border: 1px solid var(--mm-border);
	border-radius: var(--mm-radius);
	font-size: 0.95rem;
}

/* One section per exam group in the grouped results -- exam_label from the
   server, never hardcoded here. */
.mm-exam-group {
	margin-top: var(--mm-space-4);
	padding-top: var(--mm-space-3);
	border-top: 1px solid var(--mm-border);
}

.mm-exam-group:first-child {
	margin-top: var(--mm-space-3);
	padding-top: 0;
	border-top: none;
}

.mm-exam-group-heading {
	margin: 0 0 var(--mm-space-2);
	font-size: 1.15rem;
}

.mm-exam-pending-note {
	font-size: 0.85rem;
	color: var(--mm-text-muted);
	font-style: italic;
	margin: 0 0 var(--mm-space-2);
}

.mm-rank-finder button,
#mm-compare-button {
	padding: 0.45rem 1rem;
	border: 1px solid var(--mm-accent);
	background: var(--mm-accent);
	color: #fff;
	border-radius: var(--mm-radius);
	cursor: pointer;
	font-size: 0.95rem;
}

.mm-rank-finder button:hover,
#mm-compare-button:hover:not(:disabled) {
	background: var(--mm-accent-dark);
}

#mm-compare-button:disabled {
	background: var(--mm-bg-subtle);
	border-color: var(--mm-border);
	color: var(--mm-text-muted);
	cursor: not-allowed;
}

.mm-group-heading {
	margin-top: var(--mm-space-3);
	margin-bottom: 0.25rem;
	font-size: 1rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--mm-text-muted);
}

.mm-group-heading:first-child {
	margin-top: 0;
}

.mm-hidden-gem-badge {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: bold;
	background: var(--mm-gem-bg);
	color: var(--mm-gem-text);
	border: 1px solid var(--mm-gem-border);
	border-radius: 3px;
	padding: 0.05rem 0.4rem;
	vertical-align: middle;
}

/* Chances visual cue + filter (2026-09-09, user request): a colour PLUS the
   existing text label -- colour is never the only signal. Green shades read
   as the "positive" group (Very Likely/Likely/Possible per the user's own
   framing); gold/coral read as caution; grey is "no score yet". */
.mm-chance-dot {
	display: inline-block;
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 50%;
	margin-right: 0.45rem;
	vertical-align: middle;
}

.mm-chance-dot--safe { background: var(--mm-green); }
.mm-chance-dot--accessible { background: var(--mm-green); opacity: 0.65; }
.mm-chance-dot--borderline { background: var(--mm-accent); }
.mm-chance-dot--stretch { background: var(--mm-gold); }
.mm-chance-dot--unlikely { background: var(--mm-coral); }
.mm-chance-dot--pending_evidence { background: var(--mm-border); }

.mm-chance-filter-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: var(--mm-space-3);
}

.mm-chance-filter-btn {
	display: inline-flex;
	align-items: center;
	background: var(--mm-bg);
	border: 1px solid var(--mm-border);
	border-radius: 999px;
	padding: 0.3rem 0.7rem;
	font-size: 0.8rem;
	color: var(--mm-text-muted);
	cursor: pointer;
}

.mm-chance-filter-btn.is-active {
	border-color: var(--mm-accent);
	color: var(--mm-text);
	background: var(--mm-bg-subtle);
	font-weight: bold;
}

.mm-chance-filter-btn .mm-chance-dot {
	margin-right: 0.35rem;
}

/* ---------- Hidden gems page ---------- */
/* REBUILT 2026-09-10: domain picker for the HG-v2 domain-filtered search --
   same visual pattern as .mm-chance-filter-btn above, not a new one. */
.mm-domain-picker {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: var(--mm-space-3) 0;
}

.mm-domain-picker-label {
	color: var(--mm-text-muted);
	font-size: 0.85rem;
}

.mm-domain-btn {
	display: inline-flex;
	align-items: center;
	background: var(--mm-bg);
	border: 1px solid var(--mm-border);
	border-radius: 999px;
	padding: 0.3rem 0.8rem;
	font-size: 0.85rem;
	color: var(--mm-text-muted);
	cursor: pointer;
}

.mm-domain-btn.is-active {
	border-color: var(--mm-accent);
	color: var(--mm-text);
	background: var(--mm-bg-subtle);
	font-weight: bold;
}

.mm-hidden-gems-prompt,
.mm-hidden-gems-empty {
	color: var(--mm-text-muted);
	font-size: 0.9rem;
}

.mm-hidden-gems-sort-note {
	color: var(--mm-text-muted);
	font-size: 0.8rem;
	font-style: italic;
	margin: 0 0 var(--mm-space-2);
}

/* Exam-group sections (2026-09-10, user request): expandable, open by
   default, with a course count in the summary -- .mm-group-heading already
   exists for the plain (non-interactive) heading elsewhere on the site;
   this reuses its look on a <summary> element instead. */
.mm-hidden-gems-exam-group {
	margin-top: var(--mm-space-3);
}

.mm-hidden-gems-exam-group summary.mm-group-heading {
	cursor: pointer;
	list-style: none;
}

.mm-hidden-gems-exam-group summary.mm-group-heading::-webkit-details-marker {
	display: none;
}

.mm-hidden-gems-exam-group summary.mm-group-heading::before {
	content: '▸';
	display: inline-block;
	margin-right: 0.35rem;
	transition: transform 0.15s ease;
}

.mm-hidden-gems-exam-group[open] > summary.mm-group-heading::before {
	transform: rotate(90deg);
}

.mm-hidden-gem-why {
	margin-top: var(--mm-space-1);
	font-size: 0.85rem;
}

.mm-hidden-gem-why summary {
	cursor: pointer;
	color: var(--mm-gem-text);
}

.mm-hidden-gem-why p {
	margin: 0.4rem 0 0;
	color: var(--mm-text-muted);
}

.mm-hidden-gem-caveat {
	font-style: italic;
}

.mm-hidden-gem-quota {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: bold;
	background: var(--mm-bg-subtle);
	color: var(--mm-text-muted);
	border-radius: 3px;
	padding: 0.05rem 0.4rem;
	margin-right: 0.35rem;
}

.mm-hidden-gems-list {
	list-style: none;
	margin: 0 0 var(--mm-space-3);
	padding: 0;
	display: grid;
	gap: var(--mm-space-2);
}

.mm-hidden-gem-card {
	border: 1px solid var(--mm-gem-border);
	background: var(--mm-gem-bg);
	border-radius: var(--mm-radius);
	padding: var(--mm-space-2) var(--mm-space-3);
	max-width: 640px;
}

.mm-hidden-gem-title {
	font-weight: bold;
}

.mm-hidden-gem-strength,
.mm-hidden-gem-crl {
	font-size: 0.9rem;
	color: var(--mm-text-muted);
}

.mm-hidden-gem-summary {
	margin: 0.5rem 0 0;
	font-size: 0.9rem;
}

.mm-hidden-gem-card details {
	margin-top: var(--mm-space-1);
	font-size: 0.85rem;
}

.mm-hidden-gem-card summary {
	cursor: pointer;
	color: var(--mm-gem-text);
}

.mm-hidden-gem-card ul {
	margin: 0.4rem 0 0;
	padding-left: 1.2rem;
	color: var(--mm-text-muted);
}

/* ---------- Compare page ---------- */
.mm-compare-pickers {
	display: flex;
	flex-wrap: wrap;
	gap: var(--mm-space-2);
	margin-bottom: var(--mm-space-2);
}

.mm-compare-picker label {
	display: flex;
	flex-direction: column;
	font-size: 0.85rem;
	gap: 0.25rem;
}

.mm-compare-picker select {
	min-width: 220px;
}

#mm-compare-button {
	margin-bottom: var(--mm-space-3);
}

.mm-compare-table-wrap {
	overflow-x: auto;
	max-width: 100%;
}

.mm-compare-table {
	border-collapse: collapse;
	width: 100%;
}

.mm-compare-table th,
.mm-compare-table td {
	border: 1px solid var(--mm-border);
	padding: 0.5rem 0.75rem;
	text-align: left;
	vertical-align: top;
	font-size: 0.9rem;
	white-space: nowrap;
}

.mm-compare-table thead th {
	background: var(--mm-bg-subtle);
}

.mm-compare-table tbody th {
	background: #fafafa;
	white-space: nowrap;
}

/* ---------- Browse data page ---------- */
#mm-browse-search {
	display: block;
	width: 100%;
	max-width: 400px;
	margin: var(--mm-space-2) 0;
	padding: 0.45rem 0.6rem;
	border: 1px solid var(--mm-border);
	border-radius: var(--mm-radius);
	font-size: 0.95rem;
}

.mm-browse-data .mm-compare-table th {
	user-select: none;
}

.mm-browse-data .mm-compare-table th:hover {
	background: #eee;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
	.mm-rank-finder form,
	.mm-compare-picker {
		flex-direction: column;
		align-items: stretch;
	}

	.mm-container {
		padding: 0 var(--mm-space-2);
	}
}

/* ---------- Programme detail page (2026-09-11) ---------- */
.mm-breadcrumb {
	font-size: 0.8rem;
	color: var(--mm-text-muted);
	margin-bottom: var(--mm-space-3);
}

.mm-breadcrumb a {
	color: var(--mm-text-muted);
}

.mm-programme-detail-loading {
	color: var(--mm-text-muted);
}

.mm-programme-subhead {
	color: var(--mm-text-muted);
	margin-top: 0;
}

.mm-quota-badge {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: bold;
	background: var(--mm-bg-subtle);
	color: var(--mm-text-muted);
	border-radius: 3px;
	padding: 0.05rem 0.4rem;
	margin-right: 0.35rem;
}

.mm-programme-domain-card {
	background: var(--mm-bg-subtle);
	border-radius: 8px;
	padding: var(--mm-space-2) var(--mm-space-3);
	margin-bottom: var(--mm-space-3);
}

.mm-programme-domain-card h2 {
	margin-top: 0;
	font-size: 1.05rem;
}

.mm-programme-selectivity {
	font-weight: 600;
}

.mm-programme-note {
	color: var(--mm-text-muted);
	font-size: 0.9rem;
}

.mm-programme-sources {
	color: var(--mm-text-muted);
	font-size: 0.9rem;
}

.mm-programme-summary {
	line-height: 1.65;
	margin-bottom: var(--mm-space-2);
}
