/* ===========================================================================
   form-bridge.css — MONA Smart Form wearing the GTL form.

   The plugin renders a flat list of `<p class="msf-field" data-key="…">`
   (class-msf-form.php:167) and offers no filter over that markup. The approved
   design groups the same inputs as `.form-card > form > .field-row > .field`
   (common.css:678). Rather than fork the plugin — which would mean owning its
   entries, validation, mail and spam handling forever — the grouping and the
   look are rebuilt here from `data-key`, and the plugin keeps the form.

   Every rule is scoped to `.msf-form`, so nothing here reaches a form placed
   anywhere else, and every value is read from the design's own tokens: this
   file sets no colour, radius or spacing of its own.

   Loaded after common.css and page.css, only on views that carry a form.
   =========================================================================== */

/* ---------- the form as a whole ---------- */

/*
 * Two columns, as `.field-row` is, and a container query for the same reason
 * the design gives one: this form also sits in a narrow column at 1024px, and
 * two inputs side by side there cut their own placeholders off.
 */
.msf-form {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0 14px;
	container-type: inline-size;
}

/* One field per row is the default; the pairs opt in below. */
.msf-form .msf-field {
	grid-column: 1 / -1;
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0 0 16px;
}

.msf-form .msf-field[data-key="name"],
.msf-form .msf-field[data-key="phone"],
.msf-form .msf-field[data-key="grade"],
.msf-form .msf-field[data-key="campus"],
.msf-form .msf-field[data-key="email"],
.msf-form .msf-field[data-key="school"] {
	grid-column: span 1;
}

@container (max-width: 500px) {
	.msf-form .msf-field {
		grid-column: 1 / -1;
	}
}

/*
 * The message box is the one field the design hides by default: the brief puts
 * it on the contact page only, and the templates mark that with
 * [data-form-message] around the form.
 */
.msf-form .msf-field[data-key="message"] {
	display: none;
}

[data-form-message] .msf-form .msf-field[data-key="message"] {
	display: flex;
}

/* ---------- labels and inputs ---------- */

.msf-form .msf-field > label {
	font-weight: 600;
	font-size: .9rem;
	color: var(--black);
}

/* The asterisk carries meaning, so it needs the 4.5:1 red, not the accent one. */
.msf-form .msf-req {
	color: var(--red-700);
}

/*
 * Typed against the plugin's own attribute selectors (.msf-form input[type=text]
 * and friends, form.css:6), which outrank a bare element selector however late
 * this file loads.
 */
.msf-form input[type="text"],
.msf-form input[type="email"],
.msf-form input[type="tel"],
.msf-form input[type="number"],
.msf-form input[type="date"],
.msf-form select,
.msf-form textarea {
	font: inherit;
	font-size: .98rem;
	color: var(--black);
	width: 100%;
	padding: 13px 15px;
	border: 1.5px solid var(--line-strong);
	border-radius: var(--r-sm);
	background: var(--white);
	transition: border-color .2s, box-shadow .2s;
}

.msf-form textarea {
	resize: vertical;
	min-height: 88px;
	line-height: 1.55;
}

.msf-form input::placeholder,
.msf-form textarea::placeholder {
	color: var(--gray-soft);
}

.msf-form input:focus,
.msf-form select:focus,
.msf-form textarea:focus,
.msf-form input[type="text"]:focus,
.msf-form input[type="email"]:focus,
.msf-form input[type="tel"]:focus {
	outline: none;
	border-color: var(--black);
	box-shadow: 0 0 0 3px rgba(9, 11, 12, .08);
}

/* The caret the design draws, since the native one cannot be styled. */
.msf-form select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%23090B0C'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 16px;
	padding-right: 40px;
}

/*
 * site.js replaces the select with the design's own popup and hides the real
 * one behind it. Without this the hidden select keeps its 48px of height and
 * pushes the popup off its own row.
 */
.msf-form .select__native {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

/* ---------- the field error the plugin prints ---------- */

.msf-form .msf-field-error {
	display: block;
	font-size: .82rem;
	color: var(--red-700);
	font-weight: 600;
}

.msf-form [aria-invalid="true"] {
	border-color: var(--red);
}

/* ---------- choices: the design's chips ---------- */

.msf-form .msf-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.msf-form .msf-choice {
	display: inline-flex;
	padding: 8px 14px;
	border-radius: var(--r-pill);
	border: 1.5px solid var(--line-strong);
	font-size: .88rem;
	font-weight: 600;
	color: var(--black);
	cursor: pointer;
	transition: background .2s, border-color .2s, color .2s;
}

/*
 * The plugin puts the input inside the label with the text beside it, where
 * the design has a hidden input and a chip. :has() reads the state without
 * asking the plugin to change its markup.
 */
.msf-form .msf-choice input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.msf-form .msf-choice:has(input:checked) {
	background: var(--dark);
	border-color: var(--dark);
	color: var(--white);
}

.msf-form .msf-choice:has(input:focus-visible) {
	outline: 3px solid var(--red);
	outline-offset: 2px;
}

/* ---------- submit, status, note ---------- */

.msf-form > p:last-of-type {
	grid-column: 1 / -1;
	margin: 4px 0 0;
}

/* The design's primary button, full width, at the size the register band uses. */
.msf-form .msf-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 17px 32px;
	border: 1.5px solid transparent;
	border-radius: var(--r-pill);
	background: var(--red);
	color: var(--white);
	font-weight: 700;
	font-size: 1.05rem;
	line-height: 1.2;
	transition: transform .2s var(--ease), background .2s, box-shadow .2s;
}

.msf-form .msf-btn:hover {
	background: var(--red-700);
	transform: translateY(-2px);
}

.msf-form .msf-btn:active {
	transform: translateY(1px) scale(.985);
}

.msf-form .msf-btn[disabled] {
	opacity: .65;
	transform: none;
}

/*
 * The status line. Empty until the plugin writes into it, and the design only
 * ever styles the failure — success takes the visitor to the thank-you page.
 */
.msf-form .msf-status {
	grid-column: 1 / -1;
	margin-top: 12px;
	padding: 0;
	border-radius: var(--r-sm);
	font-size: .9rem;
	font-weight: 600;
}

.msf-form .msf-status-err {
	padding: 12px 14px;
	background: var(--red-700);
	color: var(--white);
}

.msf-form .msf-status-ok {
	padding: 12px 14px;
	background: var(--smoke);
	color: var(--black);
}

/*
 * The classic path's success banner, inside the popup only.
 *
 * Every page carries the registration popup, so a page reached with ?msf=ok —
 * which is where the plugin sends a visitor who submitted the DOWNLOAD form
 * without JavaScript — prints "MONA đã nhận được thông tin" into a form nobody
 * filled in. The string is hard-coded in the plugin (class-msf-form.php:122),
 * so hiding it here is the only lever short of forking. It stays visible on a
 * form that is actually on the page, and the error banner stays everywhere.
 */
.js-cta-modal .msf-alert {
	display: none;
}

/* The note the theme prints under the form, from the Biểu mẫu settings. */
.form-card > .form-note {
	margin-top: 12px;
}

/* ---------- the narrow band the popup sits in ---------- */

@media (max-width: 560px) {
	.msf-form .msf-btn {
		padding: 15px 24px;
		font-size: 1rem;
	}
}
