/**
 * NEB GPA Calculator - front-end styles.
 *
 * Colours come from --neb-* custom properties so the theme can restyle the
 * calculator without touching this file. Every property has a fallback equal
 * to the reference calculator's colour.
 */

.neb-gpa {
	--neb-primary: #4361ee;
	--neb-primary-dark: #3a56d4;
	--neb-secondary: #3f37c9;
	--neb-accent: #4895ef;
	--neb-ink: #1e293b;
	--neb-muted: #64748b;
	--neb-line: #dce5ff;
	--neb-line-soft: #e5edff;
	--neb-surface: #ffffff;
	--neb-surface-alt: #fbfdff;
	--neb-danger: #d32f2f;
	--neb-radius: 16px;
	--neb-radius-sm: 10px;

	position: relative;
	box-sizing: border-box;
	color: var(--neb-ink);
	font-size: 1rem;
	line-height: 1.6;
}

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

.neb-gpa__header {
	text-align: center;
	margin: 0 0 1.5rem;
}

.neb-gpa__title {
	margin: 0.5rem 0 0.5rem;
	font-size: clamp(1.7rem, 4vw, 2.8rem);
	font-weight: 700;
	line-height: 1.2;
	/* The reference calculator shows its heading in the brand colour. The
	   theme maps its own primary colour onto --neb-primary, so this stays
	   editable and still works standalone. */
	color: var(--neb-primary);
}

/* Two classes so the rule also wins over themes that blanket-style every
   svg element (for example `svg { display: block }`). */
.neb-gpa__title .neb-gpa__title-icon {
	display: inline-block;
	width: 0.92em;
	height: 0.92em;
	max-width: none;
	margin-right: 0.28em;
	vertical-align: -0.06em;
	fill: currentColor;
}

.neb-gpa__subtitle {
	margin: 0;
	color: var(--neb-muted);
	font-size: 1.05rem;
}

/* Pills ------------------------------------------------------------- */

.neb-pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	border-radius: 999px;
	padding: 7px 12px;
	font-size: 0.86rem;
	font-weight: 600;
	margin: 0 4px 10px;
}

.neb-pill--link {
	color: #3550d3;
	background: rgba(67, 97, 238, 0.1);
	border: 1px solid rgba(67, 97, 238, 0.28);
	text-decoration: none;
}

.neb-pill--link:hover,
.neb-pill--link:focus {
	background: rgba(67, 97, 238, 0.16);
}

.neb-pill--badge {
	color: #0b6a95;
	background: rgba(76, 201, 240, 0.16);
	border: 1px solid rgba(76, 201, 240, 0.35);
}

/* Layout ------------------------------------------------------------ */

.neb-gpa__form {
	background: rgba(255, 255, 255, 0.94);
	border: 1px solid var(--neb-line);
	border-radius: 22px;
	padding: 2rem;
	box-shadow: 0 22px 42px rgba(15, 23, 42, 0.1);
	margin: 0 0 2rem;
}

.neb-card--student {
	display: grid;
	/* min() keeps the track from forcing the card wider than a 320px phone. */
	grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
	gap: 1.5rem;
	margin-bottom: 1.25rem;
}

.neb-group-title {
	margin: 1.75rem 0 0.75rem;
	font-size: 1.15rem;
	color: var(--neb-primary-dark);
}

.neb-group-title:first-of-type {
	margin-top: 0.5rem;
}

.neb-group-hint,
.neb-helper {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 1rem;
	color: #37588f;
	background: rgba(72, 149, 239, 0.12);
	border: 1px solid rgba(72, 149, 239, 0.25);
	border-radius: var(--neb-radius-sm);
	padding: 10px 14px;
	font-size: 0.9rem;
	font-weight: 500;
}

.neb-subjects {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
	gap: 1.2rem;
	margin-bottom: 1.5rem;
}

.neb-subject {
	border: 1px solid var(--neb-line-soft);
	border-radius: var(--neb-radius);
	background: linear-gradient(180deg, #ffffff, #f9fbff);
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
	padding: 1.4rem;
	transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.neb-subject:hover,
.neb-subject:focus-within {
	transform: translateY(-3px);
	box-shadow: 0 16px 28px rgba(15, 23, 42, 0.12);
}

.neb-subject__name {
	margin: 0 0 1.1rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--neb-line-soft);
	color: var(--neb-primary);
	font-size: 1.12rem;
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 10px;
}

.neb-subject__slot-number {
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--neb-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* Fields ------------------------------------------------------------ */

.neb-field {
	margin-bottom: 1.15rem;
}

.neb-field:last-child {
	margin-bottom: 0;
}

.neb-field label {
	display: block;
	margin-bottom: 0.4rem;
	font-weight: 500;
	color: #475569;
	font-size: 0.95rem;
}

.neb-field__controls {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.neb-field input[type="text"],
.neb-field input[type="number"],
.neb-field select {
	width: 100%;
	min-width: 0;
	padding: 0.7rem 1rem;
	border: 1px solid #d6e1ff;
	border-radius: var(--neb-radius-sm);
	background-color: #fff;
	font-size: 1rem;
	font-family: inherit;
	color: inherit;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.neb-field input[type="number"] {
	flex: 0 1 8rem;
}

.neb-field select {
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 1rem;
	padding-right: 2.25rem;
}

.neb-field input:focus,
.neb-field select:focus {
	outline: none;
	border-color: #5a76f1;
	box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.neb-field--error input,
.neb-field--error select {
	border-color: var(--neb-danger);
	box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.15);
}

.neb-field__error {
	margin: 0.35rem 0 0;
	font-size: 0.85rem;
	color: var(--neb-danger);
	font-weight: 500;
}

/* Buttons ----------------------------------------------------------- */

.neb-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	justify-content: center;
	margin-top: 1.5rem;
}

.neb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	border: 2px solid transparent;
	border-radius: var(--neb-radius-sm);
	padding: 0.8rem 1.75rem;
	font-size: 1rem;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.neb-btn--primary {
	background-color: var(--neb-primary);
	color: #fff;
}

.neb-btn--primary:hover,
.neb-btn--primary:focus {
	background-color: var(--neb-primary-dark);
	color: #fff;
}

.neb-btn--secondary {
	background-color: #fff;
	color: var(--neb-primary);
	border-color: var(--neb-primary);
}

.neb-btn--secondary:hover,
.neb-btn--secondary:focus {
	background-color: var(--neb-primary);
	color: #fff;
}

.neb-btn--ghost {
	background-color: transparent;
	color: var(--neb-primary-dark);
	border-color: var(--neb-line);
}

.neb-btn--ghost:hover,
.neb-btn--ghost:focus {
	background-color: rgba(67, 97, 238, 0.08);
}

.neb-btn:focus-visible,
.neb-pill:focus-visible,
.neb-field input:focus-visible,
.neb-field select:focus-visible,
.neb-modal__close:focus-visible {
	outline: 3px solid #1d4ed8;
	outline-offset: 2px;
}

/* Alerts ------------------------------------------------------------ */

.neb-alert {
	background-color: #fef2f2;
	color: #b91c1c;
	border: 1px solid rgba(211, 47, 47, 0.25);
	border-radius: var(--neb-radius-sm);
	padding: 1rem 1.15rem;
	margin: 0 0 1rem;
	font-weight: 500;
}

.neb-error {
	color: var(--neb-danger);
	font-weight: 600;
}

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

/* Grades ------------------------------------------------------------ */

.neb-grade {
	font-weight: 700;
}

.neb-grade--aplus { color: #2e7d32; }
.neb-grade--a { color: #388e3c; }
.neb-grade--bplus { color: #0288d1; }
.neb-grade--b { color: #1976d2; }
.neb-grade--cplus { color: #f57c00; }
.neb-grade--c { color: #fb8c00; }
.neb-grade--dplus { color: #e64a19; }
.neb-grade--d { color: #d32f2f; }
.neb-grade--ng { color: #6b7280; }

/* Tables ------------------------------------------------------------ */

.neb-table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.neb-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 0.75rem;
	font-size: 0.95rem;
}

.neb-table th,
.neb-table td {
	padding: 0.7rem 0.9rem;
	text-align: left;
	border-bottom: 1px solid var(--neb-line-soft);
	white-space: nowrap;
}

.neb-table thead th {
	background: linear-gradient(120deg, #edf3ff, #f6f9ff);
	color: #1f2f55;
	font-weight: 600;
}

.neb-table tbody tr:hover {
	background-color: #f2f7ff;
}

.neb-table--marksheet tbody th {
	font-weight: 500;
	white-space: normal;
}

.neb-table--grading thead th {
	background: var(--neb-primary);
	color: #fff;
}

.neb-table--grading tbody tr:nth-child(even) {
	background-color: #f8fafc;
}

/* Mark sheet -------------------------------------------------------- */

.neb-modal[hidden] {
	display: none;
}

.neb-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 3vh 1rem;
	overflow: auto;
}

.neb-modal__backdrop {
	position: fixed;
	inset: 0;
	background-color: rgba(12, 18, 34, 0.55);
	backdrop-filter: blur(5px);
}

.neb-modal__panel {
	position: relative;
	width: 100%;
	max-width: 860px;
	background-color: #fff;
	border: 1px solid #dce6ff;
	border-radius: 20px;
	box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
	padding: 1.75rem;
	max-height: 92vh;
	overflow-y: auto;
}

.neb-modal__close {
	position: absolute;
	top: 0.6rem;
	right: 0.75rem;
	background: none;
	border: 0;
	font-size: 1.9rem;
	line-height: 1;
	color: var(--neb-muted);
	cursor: pointer;
	padding: 0.2rem 0.5rem;
	border-radius: 8px;
}

.neb-modal__close:hover {
	color: var(--neb-ink);
	background: rgba(15, 23, 42, 0.06);
}

.neb-modal__title {
	text-align: center;
	color: #2a3fbe;
	margin: 0 0 1rem;
	font-size: 1.3rem;
}

.neb-modal__actions {
	display: flex;
	justify-content: center;
	margin-top: 1rem;
}

.neb-marksheet {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.neb-marksheet__watermark {
	position: absolute;
	top: 42%;
	left: 50%;
	transform: translate( -50%, -50% ) rotate( -28deg );
	font-size: clamp(1.8rem, 6vw, 3.4rem);
	font-weight: 800;
	letter-spacing: 0.06em;
	color: rgba(67, 97, 238, 0.09);
	pointer-events: none;
	white-space: nowrap;
	z-index: 0;
}

.neb-marksheet__head {
	position: relative;
	text-align: center;
	border: 1px solid #d8e5ff;
	border-radius: 12px;
	padding: 12px;
	background: linear-gradient(180deg, #f4f8ff, #ffffff);
}

.neb-marksheet__head h3 {
	margin: 0 0 4px;
	font-size: 1.05rem;
	color: #172554;
}

.neb-marksheet__head p {
	margin: 0;
	color: #475569;
	font-size: 0.9rem;
}

.neb-marksheet__school {
	font-weight: 600;
	color: #1f2f55 !important;
}

.neb-marksheet__meta {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
	margin: 0;
}

.neb-marksheet__meta > div {
	border: 1px solid #dde8ff;
	border-radius: 10px;
	background: var(--neb-surface-alt);
	padding: 10px;
}

.neb-marksheet__meta dt {
	font-size: 0.76rem;
	color: #667a99;
	margin: 0 0 4px;
}

.neb-marksheet__meta dd {
	margin: 0;
	color: #1f2f55;
	font-size: 0.95rem;
	font-weight: 700;
	word-break: break-word;
}

.neb-summary {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
	gap: 12px;
	border: 1px solid #dbe7ff;
	border-radius: 12px;
	padding: 12px;
	background: #f8fbff;
	text-align: center;
}

.neb-summary__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.neb-summary__value {
	font-size: 2rem;
	font-weight: 700;
	line-height: 1.1;
	color: var(--neb-secondary);
}

.neb-summary__label {
	font-size: 0.82rem;
	color: #64748b;
}

.neb-status--pass { color: #15803d; font-size: 1.25rem; }
.neb-status--fail { color: #b91c1c; font-size: 1.25rem; }

.neb-marksheet__note {
	margin: 0;
	color: #475569;
	font-size: 0.85rem;
}

.neb-marksheet__note--muted {
	color: #64748b;
	font-style: italic;
}

.neb-marksheet__formula {
	margin: 0;
	padding: 8px 12px;
	background: #f1f5ff;
	border-radius: 8px;
	color: #334155;
	font-size: 0.82rem;
	text-align: center;
}

.neb-signatures {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 2rem;
	margin-top: 1.5rem;
}

.neb-signature {
	border-top: 1px dashed #8fa2c5;
	padding-top: 10px;
	text-align: center;
	color: #4d5f80;
	font-size: 0.86rem;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.neb-signature strong {
	color: #1f2f55;
	font-size: 0.92rem;
}

/* Notes ------------------------------------------------------------- */

.neb-note {
	background-color: #f5f7fa;
	padding: 1rem 1.25rem;
	border-radius: var(--neb-radius-sm);
	border-left: 4px solid var(--neb-accent);
	margin-top: 1rem;
}

.neb-section-title {
	margin: 0 0 0.5rem;
}

/* ------------------------------------------------------------------
   GPA -> percentage converter
   ------------------------------------------------------------------ */

.neb-pct {
	max-width: 900px;
	margin: 0 auto;
}

.neb-pct__intro {
	margin: 0 0 1.5rem;
	color: #334155;
	font-size: 1.05rem;
}

.neb-pct__form .neb-field__controls {
	align-items: center;
}

/* The GPA box and the scale label share one line, and both go full width on a
   narrow screen instead of squeezing the number field. */
.neb-pct__form .neb-field input[type="text"] {
	flex: 1 1 10rem;
}

/* The scale is stated next to the box the student types into, so nobody has
   to guess which scale the answer will be on. */
.neb-pct__scale {
	flex: 0 1 12rem;
	padding: 0.72rem 0.9rem;
	border: 1px solid var(--neb-line);
	border-radius: var(--neb-radius-sm);
	background: var(--neb-surface-alt);
	color: var(--neb-muted);
	font-size: 0.85rem;
	font-weight: 600;
}

.neb-pct__result {
	background: var(--neb-surface);
	border: 1px solid var(--neb-line);
	border-radius: var(--neb-radius);
	padding: 1.5rem;
	margin: 0 0 2rem;
	box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
}

.neb-pct__result[hidden] {
	display: none;
}

/* Focus lands here after calculating, so a keyboard user is taken to the
   answer instead of being left on the button. */
.neb-pct__result:focus {
	outline: 3px solid rgba(67, 97, 238, 0.35);
	outline-offset: 3px;
}

.neb-pct__result-title {
	margin: 0 0 1rem;
	font-size: 1.3rem;
	color: var(--neb-primary-dark);
}

/* The estimate is the answer, so it is drawn larger. Its colour is the same
   palette variable the other result numbers use rather than a colour of its
   own, so the theme's Secondary colour still controls it like everything else —
   and an estimate is not painted in the "passed" green the marksheet uses. */
.neb-pct .neb-summary__item--result .neb-summary__value {
	font-size: 2.4rem;
}

.neb-pct__line {
	margin: 0.9rem 0 0;
	color: #334155;
	font-size: 0.95rem;
}

.neb-pct__line strong {
	color: var(--neb-primary-dark);
}

.neb-pct__detail {
	margin: 0.6rem 0 0;
	color: var(--neb-muted);
	font-size: 0.88rem;
}

/* The estimate/provenance note sits under the form rather than inside the
   result, because it has to be readable before anything is calculated. */
.neb-pct__provenance {
	margin: 0 0 2rem;
}

.neb-pct__provenance p:last-child {
	margin-bottom: 0;
}

.neb-pct__section {
	margin: 0 0 2.5rem;
}

.neb-pct__section:last-child {
	margin-bottom: 0;
}

.neb-pct__prose p:last-child {
	margin-bottom: 0;
}

.neb-pct__links {
	list-style: none;
	margin: 1rem 0 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
	gap: 0.85rem;
}

.neb-pct__links a {
	display: block;
	padding: 0.9rem 1.1rem;
	border: 1px solid var(--neb-line);
	border-radius: var(--neb-radius-sm);
	background: var(--neb-surface);
	color: var(--neb-primary-dark);
	font-weight: 600;
	text-decoration: none;
}

.neb-pct__links a:hover,
.neb-pct__links a:focus {
	background: rgba(67, 97, 238, 0.08);
	border-color: var(--neb-primary);
}

/* Responsive -------------------------------------------------------- */

@media (max-width: 782px) {
	.neb-gpa__form {
		padding: 1.25rem;
		border-radius: 16px;
	}

	.neb-subjects {
		grid-template-columns: 1fr;
	}

	.neb-marksheet__meta {
		grid-template-columns: 1fr;
	}

	.neb-modal__panel {
		padding: 1.25rem;
		max-height: 96vh;
	}

	.neb-summary__value {
		font-size: 1.7rem;
	}

	.neb-pct .neb-summary__item--result .neb-summary__value {
		font-size: 2rem;
	}

	.neb-pct__result {
		padding: 1.25rem;
	}

	.neb-pct__scale {
		flex-basis: 100%;
		text-align: center;
	}

	.neb-actions .neb-btn {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.neb-subject,
	.neb-btn,
	.neb-field input,
	.neb-field select {
		transition: none;
	}

	.neb-subject:hover,
	.neb-subject:focus-within {
		transform: none;
	}
}

/* Screen-reader-only text ------------------------------------------- */

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