/*
 * Front-end styles.
 *
 * Everything is driven by custom properties so the theme can override
 * one line instead of fighting specificity. Defaults are dark, matching
 * the site, and inherit the theme's font rather than importing one — a
 * payout table should look like the rest of the site, not like a plugin.
 *
 * Colour scheme is an explicit setting, NOT `prefers-color-scheme`.
 * That media query reports the visitor's operating system preference,
 * which has nothing to do with what colour this site is. On a site
 * that's dark for everyone, keying off it means a visitor whose laptop
 * is in light mode gets dark-on-dark text — a bug nobody testing on a
 * dark laptop would ever see.
 */

.kmam-account,
.kmam-tracker,
.kmam-ledger,
.kmam-proofs {
	--kmam-bg: rgba(255, 255, 255, 0.04);
	--kmam-bg-solid: #16181d;
	--kmam-line: rgba(255, 255, 255, 0.14);
	--kmam-text: inherit;
	--kmam-dim: rgba(255, 255, 255, 0.62);
	--kmam-accent: #d64545;
	--kmam-ok: #3fa66a;
	--kmam-warn: #d99b2b;
	--kmam-radius: 10px;
	--kmam-gap: 1rem;

	color: var(--kmam-text);
	font-size: 1rem;
	line-height: 1.55;
}

/* Set the scheme to Light in Aid Members → Settings. */
.kmam-theme-light {
	--kmam-bg: rgba(0, 0, 0, 0.03);
	--kmam-bg-solid: #fff;
	--kmam-line: rgba(0, 0, 0, 0.14);
	--kmam-dim: rgba(0, 0, 0, 0.62);
	--kmam-ok: #2e8355;
	--kmam-warn: #a8760f;
}

/* Only for themes that genuinely follow the visitor's OS setting. */
@media (prefers-color-scheme: light) {
	.kmam-theme-auto {
		--kmam-bg: rgba(0, 0, 0, 0.03);
		--kmam-bg-solid: #fff;
		--kmam-line: rgba(0, 0, 0, 0.14);
		--kmam-dim: rgba(0, 0, 0, 0.62);
		--kmam-ok: #2e8355;
		--kmam-warn: #a8760f;
	}
}

/* ---------- shared ---------- */

.kmam-card {
	background: var(--kmam-bg);
	border: 1px solid var(--kmam-line);
	border-radius: var(--kmam-radius);
	padding: 1.25rem;
	margin: 0 0 var(--kmam-gap);
}

.kmam-card h3 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.kmam-h { margin: 1.5rem 0 0.75rem; }
.kmam-lede { color: var(--kmam-dim); margin: 0 0 1rem; }
.kmam-hint { color: var(--kmam-dim); font-size: 0.875rem; margin: 0.35rem 0 0; }
.kmam-error { color: var(--kmam-accent); }

.kmam-btn {
	display: inline-block;
	background: var(--kmam-accent);
	color: #fff;
	border: 0;
	border-radius: 6px;
	padding: 0.65rem 1.15rem;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
}

.kmam-btn:hover { filter: brightness(1.1); }
.kmam-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.kmam-notice {
	border-radius: 6px;
	padding: 0.75rem 1rem;
	margin: 0 0 var(--kmam-gap);
	border: 1px solid var(--kmam-line);
}

.kmam-notice--ok  { border-left: 3px solid var(--kmam-ok); }
.kmam-notice--bad { border-left: 3px solid var(--kmam-accent); }

/* ---------- forms ---------- */

.kmam-form .kmam-field { margin: 0 0 1rem; }
.kmam-form label { display: block; font-weight: 600; margin: 0 0 0.35rem; }

.kmam-form input[type="text"],
.kmam-form input[type="url"],
.kmam-form input[type="email"],
.kmam-form select,
.kmam-form textarea {
	width: 100%;
	max-width: 32rem;
	background: var(--kmam-bg-solid);
	color: inherit;
	border: 1px solid var(--kmam-line);
	border-radius: 6px;
	padding: 0.6rem 0.7rem;
	font: inherit;
}

.kmam-form fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.kmam-form legend { font-weight: 600; padding: 0; }
.kmam-subfield { margin: 0.5rem 0; }
.kmam-subfield label { font-weight: 400; font-size: 0.9rem; color: var(--kmam-dim); }

.kmam-check {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	font-weight: 400;
	margin: 0.5rem 0;
}

.kmam-check input { margin-top: 0.25rem; }
.kmam-privacy { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--kmam-line); }

/* ---------- tracker ---------- */

.kmam-tracker__figures {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
	gap: 0.75rem;
	margin: 0 0 1rem;
}

.kmam-figure {
	background: var(--kmam-bg);
	border: 1px solid var(--kmam-line);
	border-radius: var(--kmam-radius);
	padding: 0.9rem 1rem;
}

.kmam-figure__value {
	display: block;
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
}

.kmam-figure--lead .kmam-figure__value { font-size: 2rem; }

.kmam-figure__label {
	display: block;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--kmam-dim);
	margin-top: 0.25rem;
}

.kmam-gap {
	border-left: 3px solid var(--kmam-warn);
	padding: 0.5rem 0 0.5rem 0.85rem;
	margin: 0 0 1rem;
	color: var(--kmam-dim);
	font-size: 0.925rem;
}

.kmam-gap--negative { border-left-color: var(--kmam-accent); }

.kmam-complete {
	background: var(--kmam-bg);
	border: 1px solid var(--kmam-line);
	border-left: 3px solid var(--kmam-ok);
	border-radius: var(--kmam-radius);
	padding: 1.25rem;
	margin: 0 0 1rem;
}

.kmam-complete h3 { margin: 0 0 0.5rem; }

/* ---------- milestones ---------- */

.kmam-milestones { list-style: none; margin: 0; padding: 0; }

.kmam-milestone {
	position: relative;
	background: var(--kmam-bg);
	border: 1px solid var(--kmam-line);
	border-radius: var(--kmam-radius);
	margin: 0 0 0.6rem;
	overflow: hidden;
}

.kmam-milestone.is-current { border-color: var(--kmam-accent); }

.kmam-milestone__bar {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.kmam-milestone__fill {
	height: 100%;
	background: linear-gradient(90deg, rgba(214, 69, 69, 0.22), rgba(214, 69, 69, 0.06));
	transition: width 0.6s ease;
}

@media (prefers-reduced-motion: reduce) {
	.kmam-milestone__fill { transition: none; }
}

.kmam-milestone--distributed .kmam-milestone__fill {
	background: linear-gradient(90deg, rgba(63, 166, 106, 0.22), rgba(63, 166, 106, 0.06));
}

.kmam-milestone__body {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	align-items: center;
	justify-content: space-between;
	padding: 0.9rem 1.1rem;
}

.kmam-milestone__body h4 { margin: 0; font-size: 1.05rem; }
.kmam-milestone__terms { margin: 0.15rem 0 0; font-size: 0.875rem; color: var(--kmam-dim); }
.kmam-milestone__state { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; }
.kmam-milestone__remaining { font-size: 0.825rem; color: var(--kmam-dim); font-variant-numeric: tabular-nums; }

.kmam-pill {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	padding: 0.2rem 0.55rem;
	border-radius: 999px;
	border: 1px solid var(--kmam-line);
	white-space: nowrap;
}

.kmam-pill--funded,
.kmam-pill--pending_claim { border-color: var(--kmam-warn); color: var(--kmam-warn); }

.kmam-pill--allocated,
.kmam-pill--claimed { border-color: var(--kmam-accent); color: var(--kmam-accent); }

.kmam-pill--distributed,
.kmam-pill--paid { border-color: var(--kmam-ok); color: var(--kmam-ok); }

.kmam-pill--test {
	border-style: dashed;
	color: var(--kmam-dim);
	margin-left: 0.5rem;
	vertical-align: middle;
}

.kmam-footnote { font-size: 0.85rem; color: var(--kmam-dim); margin: 1rem 0 0; }

/* ---------- account ---------- */

.kmam-status__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.kmam-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; color: var(--kmam-dim); }

.kmam-figures { display: flex; gap: 2rem; margin: 1rem 0 0; }
.kmam-figures dt { font-size: 0.8rem; color: var(--kmam-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.kmam-figures dd { margin: 0.15rem 0 0; font-size: 1.25rem; font-weight: 700; }

.kmam-alloc__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 0 0 0.75rem; }
.kmam-alloc__amount { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kmam-alloc__milestone { color: var(--kmam-dim); margin-left: 0.5rem; }
.kmam-alloc--pending_claim { border-left: 3px solid var(--kmam-warn); }
.kmam-alloc--failed { border-left: 3px solid var(--kmam-accent); }
.kmam-alloc--paid { border-left: 3px solid var(--kmam-ok); }

.kmam-deadline { font-size: 0.875rem; color: var(--kmam-warn); margin: 0.75rem 0 0; }
.kmam-details summary { cursor: pointer; font-weight: 600; }
.kmam-details[open] summary { margin-bottom: 0.75rem; }
.kmam-details summary h3 { display: inline; }

/* ---------- ledger ---------- */

.kmam-ledger__head {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	padding: 0 0 1rem;
	margin: 0 0 1rem;
	border-bottom: 1px solid var(--kmam-line);
	color: var(--kmam-dim);
	font-size: 0.9rem;
}

.kmam-ledger__head span { display: block; font-size: 1.35rem; font-weight: 700; color: var(--kmam-text); }

.kmam-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.kmam-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--kmam-dim); padding: 0 0.75rem 0.5rem 0; }
.kmam-table td { padding: 0.6rem 0.75rem 0.6rem 0; border-top: 1px solid var(--kmam-line); font-variant-numeric: tabular-nums; }

/* ---------- proofs ---------- */

.kmam-proof { border: 1px solid var(--kmam-line); border-radius: var(--kmam-radius); padding: 0.75rem 1rem; margin: 0 0 0.5rem; }
.kmam-proof summary { cursor: pointer; }

.kmam-proof__body {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.78rem;
	white-space: pre-wrap;
	word-break: break-all;
	margin: 0.75rem 0 0;
	color: var(--kmam-dim);
}

@media (max-width: 600px) {
	.kmam-milestone__body { flex-direction: column; align-items: flex-start; }
	.kmam-milestone__state { align-items: flex-start; }
	.kmam-figures { flex-direction: column; gap: 0.75rem; }
}
