/* Row-based calculators (Grade, GPA): rows, switches, planner and result extras.
 * Loads on top of tools.css. Each tool sets --ga-row-cols for its desktop columns. */

/* Form and result stack, each full width: rows need the room. */
.ga-tool--stacked .ga-tool__form,
.ga-tool--stacked .ga-tool__result {
	flex-basis: 100%;
}

/* Rows */
.ga-rows {
	container-type: inline-size;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ga-rows__help {
	margin: 0 0 4px;
	font-size: 14px;
	color: var(--ga-muted);
}

.ga-rows__head,
.ga-row {
	display: grid;
	grid-template-columns: var(--ga-row-cols, minmax(0, 1fr) 7.5rem 7rem 44px);
	gap: 8px;
	align-items: center;
}

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

.ga-rows__list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ga-row__cell {
	min-width: 0;
}

.ga-row__cap {
	display: none;
}

.ga-row__input {
	width: 100%;
	height: 44px;
	padding: 0 12px;
	border: 1px solid var(--ga-border);
	border-radius: 10px;
	background: var(--ga-surface);
	color: var(--ga-text);
	font: inherit;
	font-size: 16px;
	outline: none;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
}

.ga-row__select {
	padding-right: 8px;
	-webkit-appearance: auto;
	appearance: auto;
	cursor: pointer;
}

.ga-row__input--num {
	font-variant-numeric: tabular-nums;
}

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

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

.ga-row__input[aria-invalid="true"] {
	border-color: var(--ga-danger);
}

.ga-row__suffix {
	position: relative;
}

.ga-row__suffix .ga-row__input {
	padding-right: 28px;
}

.ga-row__suffix span {
	position: absolute;
	right: 11px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--ga-muted);
	font-weight: 600;
	font-size: 14px;
	pointer-events: none;
}

.ga-row__remove {
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid transparent;
	border-radius: 10px;
	background: transparent;
	color: var(--ga-muted);
	font: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.ga-row__remove:hover:not(:disabled) {
	border-color: var(--ga-border);
	color: var(--ga-danger);
}

.ga-row__remove:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

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

.ga-row__error {
	grid-column: 1 / -1;
	margin: 0;
	font-size: 13px;
	font-weight: 600;
	color: var(--ga-danger);
}

.ga-rows__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin-top: 4px;
}

.ga-btn--add {
	color: var(--ga-primary);
	border-style: dashed;
}

.ga-btn--add:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.ga-rows__total {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--ga-muted);
	font-variant-numeric: tabular-nums;
}

.ga-rows__total.is-over {
	color: var(--ga-danger);
}

.ga-rows__error:focus {
	outline: none;
}

/* Narrow: name on its own line, numbers below.
 * The media query covers every phone, including older iPhones without container queries.
 * The container query also handles narrow columns on wider screens. */
@media (max-width: 600px) {
	.ga-rows__head {
		display: none;
	}
	.ga-row {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
		padding: 10px;
		border: 1px solid var(--ga-border);
		border-radius: 12px;
		background: var(--ga-surface-2);
	}
	.ga-row__cell--name {
		grid-column: 1 / -1;
	}
	.ga-row__cell--remove {
		grid-column: 3;
		grid-row: 2;
	}
	.ga-row__cell--wide {
		grid-column: 1 / 3;
		grid-row: 3;
	}
	.ga-row__cap {
		display: block;
		margin: 0 0 4px;
		font-size: 12px;
		font-weight: 600;
		color: var(--ga-muted);
	}
	.ga-row__cell--remove {
		align-self: end;
	}
}

@container (max-width: 460px) {
	.ga-rows__head {
		display: none;
	}
	.ga-row {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
		padding: 10px;
		border: 1px solid var(--ga-border);
		border-radius: 12px;
		background: var(--ga-surface-2);
	}
	.ga-row__cell--name {
		grid-column: 1 / -1;
	}
	.ga-row__cell--remove {
		grid-column: 3;
		grid-row: 2;
	}
	.ga-row__cell--wide {
		grid-column: 1 / 3;
		grid-row: 3;
	}
	.ga-row__cap {
		display: block;
		margin: 0 0 4px;
		font-size: 12px;
		font-weight: 600;
		color: var(--ga-muted);
	}
	.ga-row__cell--remove {
		align-self: end;
	}
}

/* Planner */
.ga-plan {
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding-top: 20px;
	border-top: 1px solid var(--ga-border);
}

.ga-plan__body {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 20px;
}

.ga-switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 12px;
	min-height: 44px;
	cursor: pointer;
	font-size: 15px;
	font-weight: 600;
	align-self: flex-start;
}

.ga-switch input {
	position: absolute;
	opacity: 0;
	width: 44px;
	height: 26px;
	margin: 0;
	cursor: pointer;
}

.ga-switch__track {
	position: relative;
	flex: none;
	width: 44px;
	height: 26px;
	border-radius: 999px;
	background: var(--ga-border);
	transition: background 0.15s;
}

.ga-switch__track::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--ga-surface);
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.3);
	transition: transform 0.15s;
}

.ga-switch input:checked + .ga-switch__track {
	background: var(--ga-primary);
}

.ga-switch input:checked + .ga-switch__track::after {
	transform: translateX(18px);
}

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

@media (prefers-reduced-motion: reduce) {
	.ga-switch__track,
	.ga-switch__track::after {
		transition: none;
	}
}

/* Result */
.ga-result__main,
.ga-result__plan {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ga-result__plan {
	padding-top: 16px;
	border-top: 1px solid var(--ga-border);
}

.ga-result__value--sm {
	font-size: clamp(32px, 3.2vw, 44px);
}

.ga-badge--letter {
	background: var(--ga-primary-soft);
	color: var(--ga-primary);
	font-size: 15px;
	padding: 5px 14px;
}

.ga-result__callout {
	margin: 0;
	padding: 12px 14px;
	border-radius: 10px;
	background: var(--ga-surface);
	border: 1px solid var(--ga-border);
	font-size: 14px;
}

.ga-breakdown tfoot th,
.ga-breakdown tfoot td {
	border-top: 1px solid var(--ga-border);
	font-weight: 700;
}

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

.ga-breakdown tbody th {
	overflow-wrap: anywhere;
}

.ga-math__label--gap {
	margin-top: 10px;
}

@media (max-width: 600px) {
	.ga-breakdown th,
	.ga-breakdown td {
		padding: 8px 10px;
		font-size: 14px;
	}
}
