/* GradeAnchor Tools: calculator styles.
 * Colors come from the GradeAnchor theme (light and dark) with safe fallbacks for any other theme. */

.ga-tool {
	--ga-surface: var(--wp--preset--color--surface, #ffffff);
	--ga-surface-2: var(--wp--preset--color--surface-2, #eef2f8);
	--ga-text: var(--wp--preset--color--text, #0e1a2b);
	--ga-muted: var(--wp--preset--color--muted, #475569);
	--ga-border: var(--wp--preset--color--border, #d9e1ec);
	--ga-primary: var(--wp--preset--color--primary, #1d4ed8);
	--ga-on-primary: var(--wp--preset--color--on-primary, #ffffff);
	--ga-primary-soft: var(--wp--preset--color--primary-soft, #e3ebff);
	--ga-accent: var(--wp--preset--color--accent, #0f766e);
	--ga-accent-soft: var(--wp--preset--color--accent-soft, #ddf3ef);
	--ga-warn: var(--wp--preset--color--warn, #9a4a06);
	--ga-warn-soft: var(--wp--preset--color--warn-soft, #fdf0dc);
	--ga-danger: var(--wp--preset--color--danger, #b42318);
	--ga-mono: ui-monospace, "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", monospace;

	display: flex;
	flex-wrap: wrap;
	background: var(--ga-surface);
	color: var(--ga-text);
	border: 1px solid var(--ga-border);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.07);
	line-height: 1.5;
	margin-block: 1.5rem;
}

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

.ga-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.ga-tool [hidden] {
	display: none !important;
}

.ga-tool__form,
.ga-tool__result {
	flex: 1 1 320px;
	min-width: 0;
	padding: 28px;
	margin: 0;
}

.ga-tool__form {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.ga-tool__group {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.ga-tool__result {
	background: var(--ga-surface-2);
	display: flex;
	flex-direction: column;
	gap: 14px;
}

/* Settings row: grading type + scale */
.ga-tool__settings {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: flex-end;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--ga-border);
}

.ga-seg {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}

.ga-seg__legend,
.ga-field__label {
	display: block;
	font-size: 15px;
	font-weight: 600;
	margin: 0 0 6px;
	padding: 0;
	color: var(--ga-text);
}

.ga-seg__options {
	display: inline-flex;
	gap: 4px;
	padding: 4px;
	border-radius: 12px;
	background: var(--ga-surface-2);
	border: 1px solid var(--ga-border);
}

.ga-seg__opt {
	position: relative;
	cursor: pointer;
}

.ga-seg__opt input {
	position: absolute;
	opacity: 0;
	inset: 0;
	margin: 0;
	cursor: pointer;
}

.ga-seg__opt span {
	display: flex;
	align-items: center;
	min-height: 40px;
	padding: 0 14px;
	border-radius: 9px;
	font-size: 15px;
	font-weight: 600;
	color: var(--ga-muted);
}

.ga-seg__opt input:checked + span {
	background: var(--ga-surface);
	color: var(--ga-text);
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}

.ga-seg__opt input:focus-visible + span {
	outline: 3px solid var(--ga-primary);
	outline-offset: 2px;
}

.ga-field--scale {
	flex: 1 1 220px;
	min-width: 0;
}

/* Fields */
.ga-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ga-field .ga-field__label {
	margin: 0;
}

.ga-field__row {
	display: flex;
	gap: 8px;
}

.ga-field__row .ga-input {
	flex: 1 1 auto;
}

.ga-input {
	display: flex;
	align-items: center;
	min-width: 0;
	border: 1px solid var(--ga-border);
	border-radius: 10px;
	background: var(--ga-surface);
	overflow: hidden;
}

.ga-input:focus-within {
	border-color: var(--ga-primary);
	box-shadow: 0 0 0 3px var(--ga-primary-soft);
}

.ga-input__control {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	height: 48px;
	padding: 0 14px;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--ga-text);
	font: inherit;
	font-size: 17px;
	font-variant-numeric: tabular-nums;
	outline: none;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
}

.ga-input__control:focus,
.ga-input__control:focus-visible {
	outline: none;
	box-shadow: none;
}

/* The wrapper shows focus instead (see .ga-input:focus-within). */
.ga-input__suffix:empty {
	display: none;
}

.ga-input__control::placeholder {
	color: var(--ga-muted);
	opacity: 0.55;
}

.ga-input__suffix {
	flex: none;
	padding: 0 14px;
	color: var(--ga-muted);
	font-weight: 600;
	font-size: 15px;
}

.ga-field.is-invalid .ga-input {
	border-color: var(--ga-danger);
}

.ga-field__help,
.ga-field__error {
	margin: 0;
	font-size: 13px;
	line-height: 1.45;
}

.ga-field__help {
	color: var(--ga-muted);
}

.ga-field__error {
	color: var(--ga-danger);
	font-weight: 600;
}

.ga-select {
	width: 100%;
	height: 48px;
	padding: 0 12px;
	border: 1px solid var(--ga-border);
	border-radius: 10px;
	background-color: var(--ga-surface);
	color: var(--ga-text);
	font: inherit;
	font-size: 15px;
	cursor: pointer;
}

.ga-select:focus-visible {
	outline: 3px solid var(--ga-primary);
	outline-offset: 2px;
}

.ga-select--letter {
	flex: none;
	width: 96px;
}

/* Quick targets */
.ga-targets {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
	gap: 8px;
	margin-top: 4px;
}

.ga-target {
	min-height: 48px;
	padding: 4px 2px;
	border: 1px solid var(--ga-border);
	border-radius: 10px;
	background: var(--ga-surface);
	color: var(--ga-text);
	font: inherit;
	line-height: 1.15;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.ga-target:hover {
	border-color: var(--ga-primary);
}

.ga-target__letter {
	font-size: 16px;
	font-weight: 800;
}

.ga-target__pct {
	font-size: 12px;
	font-weight: 600;
	color: var(--ga-muted);
}

.ga-target[aria-pressed="true"] {
	background: var(--ga-primary);
	border-color: var(--ga-primary);
	color: var(--ga-on-primary);
}

.ga-target[aria-pressed="true"] .ga-target__pct {
	color: inherit;
}

/* Buttons */
.ga-tool__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 4px;
}

.ga-btn {
	min-height: 48px;
	border-radius: 10px;
	font: inherit;
	cursor: pointer;
}

.ga-btn--primary {
	flex: 1 1 180px;
	padding: 0 20px;
	border: 0;
	background: var(--ga-primary);
	color: var(--ga-on-primary);
	font-size: 16px;
	font-weight: 700;
}

.ga-btn--primary:hover {
	filter: brightness(0.94);
}

.ga-btn--ghost {
	padding: 0 16px;
	border: 1px solid var(--ga-border);
	background: transparent;
	color: var(--ga-muted);
	font-size: 14px;
	font-weight: 600;
}

.ga-btn:focus-visible,
.ga-target:focus-visible {
	outline: 3px solid var(--ga-primary);
	outline-offset: 2px;
}

/* Results */
.ga-result__empty {
	margin: 0;
	padding: 20px;
	border: 1px dashed var(--ga-border);
	border-radius: 12px;
	color: var(--ga-muted);
	font-size: 15px;
}

.ga-result__label {
	margin: 0;
	font-size: 15px;
	font-weight: 500;
	color: var(--ga-muted);
}

.ga-result__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.ga-result__value {
	font-size: clamp(40px, 4vw, 56px);
	line-height: 1;
	font-weight: 800;
	letter-spacing: -0.035em;
	color: var(--ga-primary);
	font-variant-numeric: tabular-nums;
}

.ga-result__sub {
	margin: -4px 0 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--ga-muted);
}

.ga-badge {
	padding: 5px 12px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 700;
}

.ga-badge--secured,
.ga-badge--reachable {
	background: var(--ga-accent-soft);
	color: var(--ga-accent);
}

.ga-badge--extra {
	background: var(--ga-warn-soft);
	color: var(--ga-warn);
}

.ga-bar {
	height: 10px;
	border-radius: 999px;
	background: var(--ga-border);
	overflow: hidden;
}

.ga-bar__fill {
	height: 100%;
	border-radius: 999px;
	background: var(--ga-accent);
}

.ga-bar__fill--extra {
	background: var(--ga-warn);
}

.ga-result__text {
	margin: 0;
	font-size: 15px;
}

.ga-result__notes {
	margin: 0;
	padding-left: 18px;
	font-size: 14px;
	color: var(--ga-muted);
}

.ga-math {
	background: var(--ga-surface);
	border: 1px solid var(--ga-border);
	border-radius: 12px;
	padding: 14px 16px;
}

.ga-math__label {
	margin: 0 0 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--ga-muted);
}

.ga-math__line {
	display: block;
	font-family: var(--ga-mono);
	font-size: 13px;
	line-height: 1.6;
	color: var(--ga-text);
	background: none;
	padding: 0;
	overflow-wrap: anywhere;
}

.ga-whatif {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid var(--ga-border);
	border-radius: 12px;
	overflow: hidden;
	background: var(--ga-surface);
	font-size: 15px;
	font-variant-numeric: tabular-nums;
	margin: 0;
}

.ga-whatif caption {
	caption-side: top;
	text-align: left;
	padding: 0 2px 6px;
	font-size: 13px;
	font-weight: 600;
	color: var(--ga-muted);
}

.ga-whatif th,
.ga-whatif td {
	padding: 9px 14px;
	text-align: left;
	border: 0;
	font-weight: 400;
}

.ga-whatif thead th {
	font-size: 13px;
	font-weight: 600;
	color: var(--ga-muted);
	border-bottom: 1px solid var(--ga-border);
}

.ga-whatif tbody tr + tr th,
.ga-whatif tbody tr + tr td {
	border-top: 1px solid var(--ga-border);
}

.ga-whatif tbody td:nth-child(2) {
	font-weight: 700;
}

.ga-tool__noscript {
	flex: 1 1 100%;
	margin: 0;
	padding: 16px 28px;
	color: var(--ga-danger);
	font-weight: 600;
}

@media (max-width: 600px) {
	.ga-tool__form,
	.ga-tool__result {
		padding: 20px;
	}
	.ga-tool {
		border-radius: 14px;
	}
}

/* Print: tables can split across pages. The rounded-corner clipping above
 * cuts off rows on the next page in Chrome, so drop it when printing. */
@media print {
	.ga-whatif {
		overflow: visible !important;
	}
}
