/**
 * Modules — design turn 7, artboard 7a/7b.
 *
 * Values from the artboard's markup; see docs/design-specs/turn-7-modules.md.
 * Palette comes from admin-tokens.css, so this screen follows light/dark with
 * the rest of the suite.
 *
 * The state swatches use the same vocabulary as the Overview's stream legend —
 * solid, half-filled, outline — deliberately, so the two screens teach each
 * other rather than each inventing a language.
 */

.ag-mod {
	--m-text:   var(--ag-text);
	--m-soft:   var(--ag-text-soft);
	--m-mute:   var(--ag-text-mute);
	--m-label:  var(--ag-text-faint);
	--m-rule:   var(--ag-rule);
	--m-hair:   var(--ag-rule-soft);
	--m-border: var(--ag-border);
	--m-bg:     var(--ag-bg);
	--m-bg-alt: var(--ag-bg-sunk);
	--m-accent: var(--ag-accent);
	--m-ink:    var(--ag-accent-ink);
	--m-warn:   var(--ag-warn);
	--m-warn-rule:   var(--ag-warn-rule);
	--m-warn-ground: var(--ag-warn-ground);

	--m-cols: 130px 1fr 148px 300px 96px;

	font-family: var(--ag-sans);
	color: var(--m-text);
	max-width: 1200px;
}

.ag-mod__lede {
	max-width: 78ch;
	margin: 0 0 20px;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--m-soft);
}

.ag-mod__lede strong { color: var(--m-text); font-weight: 600; }

.ag-mod__panel {
	background: var(--m-bg);
	border: 1px solid var(--m-border);
	border-radius: 3px;
	overflow: hidden;
}

/* ─── header ──────────────────────────────────────────────────────────── */

.ag-mod__head {
	display: grid;
	grid-template-columns: var(--m-cols);
	align-items: end;
	padding: 9px 0 8px;
	background: var(--m-bg-alt);
	border-bottom: 1px solid var(--m-rule);
}

.ag-mod__head span {
	font-size: 9px;
	font-weight: 600;
	letter-spacing: .13em;
	text-transform: uppercase;
	color: var(--m-label);
}

.ag-mod__head span:first-child { padding-left: 16px; }
.ag-mod__h-switch { padding-right: 16px; text-align: right; }

/* ─── rows ────────────────────────────────────────────────────────────── */

.ag-mod__row {
	display: grid;
	grid-template-columns: var(--m-cols);
	align-items: start;
	padding: 13px 0;
	border-bottom: 1px solid var(--m-hair);
	border-left: 2px solid var(--m-text);
}

.ag-mod__row:hover { background: var(--ag-bg-hover); }

/* On but unable to run: the one state that wants attention. */
.ag-mod__row--blocked {
	border-left-color: var(--m-warn-rule);
	background: var(--m-warn-ground);
}

.ag-mod__row--off { border-left-color: var(--m-border); }

/* ─── state ───────────────────────────────────────────────────────────── */

.ag-mod__state { padding-left: 16px; }

.ag-mod__state-head { display: flex; align-items: center; gap: 8px; }

.ag-mod__swatch {
	display: inline-block;
	width: 9px;
	height: 9px;
	flex: none;
	background: var(--m-text);
}

/* half-filled — on, but not running */
.ag-mod__swatch--blocked {
	border: 1px solid var(--m-warn);
	background: linear-gradient(90deg, var(--m-warn) 50%, transparent 50%);
}

.ag-mod__swatch--off { border: 1px solid var(--m-border); background: none; }

.ag-mod__state-label { font-size: 11.5px; font-weight: 600; color: var(--m-text); }
.ag-mod__row--blocked .ag-mod__state-label { color: var(--m-warn); }
.ag-mod__row--off .ag-mod__state-label { color: var(--m-mute); }

.ag-mod__state-sub {
	display: block;
	font-size: 11px;
	line-height: 1.45;
	color: var(--m-warn);
	margin-top: 4px;
	opacity: .85;
}

/* ─── module ──────────────────────────────────────────────────────────── */

.ag-mod__module { padding-right: 18px; min-width: 0; }

.ag-mod__name { font-size: 13.5px; font-weight: 600; color: var(--m-text); }

.ag-mod__desc {
	font-size: 12px;
	line-height: 1.5;
	color: var(--m-soft);
	margin-top: 4px;
}

.ag-mod__slug {
	font-family: var(--ag-mono);
	font-size: 10.5px;
	color: var(--m-mute);
	margin-top: 6px;
}

.ag-mod__tag { color: var(--m-label); }

/* ─── loads ───────────────────────────────────────────────────────────── */

.ag-mod__loads { padding-right: 14px; min-width: 0; }

.ag-mod__loads-when { font-size: 11.5px; color: var(--m-text); }

.ag-mod__loads-why {
	font-size: 11px;
	line-height: 1.45;
	color: var(--m-mute);
	margin-top: 4px;
}

/* ─── needs ───────────────────────────────────────────────────────────── */

.ag-mod__needs { padding-right: 16px; min-width: 0; }

.ag-mod__needs-copy {
	font-size: 12px;
	line-height: 1.5;
	color: var(--m-soft);
}

.ag-mod__needs-copy code,
.ag-mod__notice code {
	font-family: var(--ag-mono);
	font-size: 11px;
}

/* The exact sentence a site will show, quoted. */
.ag-mod__notice {
	margin-top: 8px;
	padding: 9px 11px;
	border: 1px solid var(--m-warn-rule);
	border-radius: 2px;
	background: var(--ag-warn-code);
	font-size: 11.5px;
	line-height: 1.5;
	color: var(--m-text);
}

.ag-mod__notice-lead {
	display: block;
	font-size: 10px;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--m-warn);
	margin-bottom: 4px;
}

.ag-mod__aside {
	margin-top: 8px;
	font-size: 11.5px;
	line-height: 1.45;
	color: var(--m-mute);
}

/* ─── switch ──────────────────────────────────────────────────────────── */

.ag-mod__switch {
	padding-right: 16px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
}

.ag-mod__toggle { display: inline-flex; cursor: pointer; }

/* The input stays in the layout for focus and hit area, but is not painted. */
.ag-mod__toggle input {
	position: absolute;
	opacity: 0;
	width: 34px;
	height: 18px;
	margin: 0;
	cursor: pointer;
}

.ag-mod__track {
	display: inline-block;
	position: relative;
	width: 34px;
	height: 18px;
	border-radius: 9px;
	background: var(--m-border);
	transition: background .12s ease;
}

.ag-mod__knob {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--m-bg);
	transition: transform .12s ease;
}

.ag-mod__toggle input:checked + .ag-mod__track { background: var(--m-text); }
.ag-mod__toggle input:checked + .ag-mod__track .ag-mod__knob { transform: translateX(16px); }

/* On-but-blocked: the switch is on, so it reads on — in the warning colour,
   because "on" here does not mean "working". */
.ag-mod__row--blocked .ag-mod__toggle input:checked + .ag-mod__track { background: var(--m-warn-rule); }

.ag-mod__toggle input:focus-visible + .ag-mod__track {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.ag-mod__switch-note {
	font-size: 10.5px;
	line-height: 1.4;
	color: var(--m-warn);
	text-align: right;
	max-width: 92px;
}

/* ─── legend + notes ──────────────────────────────────────────────────── */

.ag-mod__legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 22px;
	padding: 11px 16px;
	background: var(--m-bg-alt);
	font-size: 11px;
	color: var(--m-mute);
}

.ag-mod__legend span { display: flex; align-items: center; gap: 8px; }

.ag-mod__actions { margin: 16px 0; }

.ag-mod__save {
	font-family: var(--ag-sans);
	font-size: 12.5px;
	font-weight: 600;
	padding: 9px 16px;
	border: 1px solid var(--m-accent);
	background: var(--m-accent);
	color: var(--m-ink);
	border-radius: 2px;
	cursor: pointer;
}

.ag-mod__save:focus-visible { outline: 2px solid #2271b1; outline-offset: 2px; }

.ag-mod__notes {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 16px;
}

.ag-mod__note {
	background: var(--m-bg);
	border: 1px solid var(--m-border);
	border-radius: 3px;
	padding: 14px 16px 16px;
}

.ag-mod__note-head {
	font-size: 10px;
	font-weight: 600;
	letter-spacing: .13em;
	text-transform: uppercase;
	color: var(--m-label);
	margin-bottom: 7px;
}

.ag-mod__note p {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.6;
	color: var(--m-soft);
}

/* ─── narrow ──────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
	.ag-mod__head { display: none; }

	.ag-mod__row {
		grid-template-columns: 1fr;
		gap: 8px;
		padding: 14px 16px 14px 14px;
	}

	.ag-mod__state,
	.ag-mod__module,
	.ag-mod__loads,
	.ag-mod__needs,
	.ag-mod__switch {
		padding-left: 0;
		padding-right: 0;
	}

	.ag-mod__switch { align-items: flex-start; }
	.ag-mod__switch-note { text-align: left; max-width: none; }
}
