/*
Theme Name: SAE Theme
Theme URI: https://usa.sae.edu/
Author: SAE Institute
Author URI: https://usa.sae.edu/
Description: Landing page theme for SAE Institute USA. 
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 7.4
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: sae-theme
Tags: full-site-editing, block-templates, one-column, landing-page, custom-colors, custom-menu
*/

/* -------------------------------------------------------------------------
 * Supplemental styles.
 *
 * Everything here consumes CSS custom properties generated from theme.json —
 * there are no literal colour or size values below. Block markup covers the
 * layout; this file only handles what block attributes cannot express:
 * native form controls, media object-fit, and a couple of small utilities.
 * ---------------------------------------------------------------------- */

/* --- Hero split layout ------------------------------------------------------ */

@media (max-width: 1459px) {
	.sae-hero__split {
		gap: var(--wp--preset--spacing--75) var(--wp--preset--spacing--70) !important;
	}
}

/* Between 1100 and 1459px, narrow the fixed-width panel column instead of
   shrinking the heading's font size — the heading column has no explicit
   width, so it grows to fill whatever the panel gives up. */
@media (min-width: 1100px) and (max-width: 1459px) {
	.sae-hero__split > .wp-block-column[style*="flex-basis"] {
		flex-basis: 32% !important;
	}
}

/* Below that, even a narrowed panel column reads as a long, cramped strip
   next to the heading — stack the two columns like the default mobile
   layout already does at 782px, just starting earlier. */
@media (max-width: 1099px) {
	/* Core's own columns CSS sets `flex-wrap: nowrap !important` above
	   781px, so this needs `!important` too to actually stack here. */
	.sae-hero__split {
		flex-wrap: wrap !important;
	}

	.sae-hero__split > .wp-block-column {
		flex-basis: 100% !important;
	}
}

/* --- Request-for-information (RFI) form ---------------------------------- */

.sae-rfi-form {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--40);
}

.sae-rfi-form__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--wp--preset--spacing--35);
}

.sae-rfi-form__field {
	display: flex;
	flex-direction: column;
}

/* Visually-hidden labels: the design shows placeholder-only fields, but every
   control still needs an accessible name. */
.sae-rfi-form__label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.sae-rfi-form__input,
.sae-rfi-form__select {
	width: 100%;
	box-sizing: border-box;
	background-color: var(--wp--preset--color--graphite);
	border: var(--wp--custom--border-width--hairline) solid var(--wp--custom--surface--hairline);
	border-radius: 0;
	color: var(--wp--preset--color--white);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--base);
	line-height: var(--wp--custom--line-height--body);
	padding: var(--wp--preset--spacing--40);
	appearance: none;
}

.sae-rfi-form__input::placeholder {
	color: var(--wp--preset--color--white);
	opacity: 1;
}

.sae-rfi-form__select:invalid {
	color: var(--wp--preset--color--white);
}

.sae-rfi-form__input:focus-visible,
.sae-rfi-form__select:focus-visible,
.sae-rfi-form__submit:focus-visible {
	outline: var(--wp--custom--border-width--rule) solid var(--wp--preset--color--sky);
	outline-offset: var(--wp--preset--spacing--20);
}

.sae-rfi-form__actions {
	display: flex;
	justify-content: center;
	padding-top: var(--wp--preset--spacing--40);
}

.sae-rfi-form__submit {
	background-color: transparent;
	border: var(--wp--custom--border-width--hairline) solid var(--wp--preset--color--white);
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--white);
	cursor: pointer;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
	line-height: 1.25;
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--70);
}

.sae-rfi-form__submit:hover,
.sae-rfi-form__submit:focus {
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--carbon);
}

.sae-rfi-form__consent {
	color: var(--wp--custom--surface--muted-on-dark);
	font-size: var(--wp--preset--font-size--small);
	line-height: var(--wp--custom--line-height--body);
	margin: 0;
	padding-top: var(--wp--preset--spacing--40);
	text-align: left;
}

.sae-rfi-form__consent a {
	color: inherit;
	text-decoration: underline;
}

@media (max-width: 599px) {
	.sae-rfi-form__row {
		grid-template-columns: 1fr;
	}
}

/* --- Embedded HubSpot forms (shared across landing pages) ----------------- */

/* Every hbspt.forms.create() call site-wide should pass `css: ''` so HubSpot
   skips its own stylesheet. These rules then target `.hs-form` — the class
   HubSpot always renders — directly, so ANY embed (any portal/form id, on any
   landing page pattern) picks up the same look with no per-embed CSS class
   required. `!important` is used where HubSpot's per-field-type markup would
   otherwise vary padding/font-size/line-height between field types. */

/* A wrapping row rather than a column, so selected rows can sit side by
   side; everything else takes a full row. */
.hs-form {
	display: flex;
	flex-flow: row wrap;
	gap: var(--wp--preset--spacing--35);
}

.hs-form > * {
	flex: 0 0 100%;
}

/* HubSpot puts each single checkbox (SMS opt-in, terms acceptance) in its
   own fieldset — pair them up on one row. The min-width drops them back to
   stacked once the panel is too narrow for the labels to fit side by side. */
.hs-form > fieldset:has(.hs-fieldtype-booleancheckbox) {
	flex: 1 1 0;
	min-width: 13em !important; /* beats the fieldset reset's `min-width: 0` */
}

.hs-form fieldset {
	max-width: none !important;
	width: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	min-width: 0 !important;
}

/* Some fieldsets only wrap a field HubSpot has forced to `display: none`
   (a dependent field waiting on another answer, a disabled legal-consent
   field, etc.). Even with the reset above, an empty fieldset still took up a
   `gap` slot between the recaptcha notice and the submit button — drop it
   from the flex flow entirely when every child inside is hidden this way. If
   the client's form hides fields through a class instead of an inline style,
   add that class to this selector too. */
.hs-form fieldset:has(> *):not(:has(> :not([style*="display:none"]):not([style*="display: none"]))) {
	display: none !important;
}

.hs-form .hs-form-field {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--10);
	margin: 0;
}

/* Zip/postal code is a short value; don't stretch it full width like the
   rest of the text fields. "zip" is HubSpot's internal name for this
   contact property — adjust the selector if this client's form uses a
   different property for it. */
.hs-form .hs_zip {
	align-self: flex-start;
	width: 160px;
	max-width: 100%;
}

/* Labels are visible (HubSpot fields have no placeholder attribute like the
   static form did), styled consistently regardless of field type. */
.hs-form .hs-form-field > label,
.hs-form .hs-form-field legend {
	position: static;
	width: auto;
	height: auto;
	clip: auto;
	overflow: visible;
	white-space: normal;
	color: var(--wp--preset--color--white);
	font-family: var(--wp--preset--font-family--body) !important;
	font-size: var(--wp--preset--font-size--small) !important;
	line-height: var(--wp--custom--line-height--body) !important;
}

.hs-form input.hs-input,
.hs-form select.hs-input,
.hs-form textarea.hs-input {
	width: 100%;
	box-sizing: border-box;
	background-color: var(--wp--preset--color--graphite) !important;
	border: var(--wp--custom--border-width--hairline) solid var(--wp--custom--surface--hairline) !important;
	border-radius: 0 !important;
	color: var(--wp--preset--color--white) !important;
	font-family: var(--wp--preset--font-family--body) !important;
	font-size: var(--wp--preset--font-size--base) !important;
	line-height: var(--wp--custom--line-height--body) !important;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--35) !important;
	appearance: none;
}

.hs-form input.hs-input::placeholder,
.hs-form textarea.hs-input::placeholder {
	color: var(--wp--preset--color--white);
	opacity: 0.7;
}

.hs-form input.hs-input:focus-visible,
.hs-form select.hs-input:focus-visible,
.hs-form textarea.hs-input:focus-visible {
	outline: var(--wp--custom--border-width--rule) solid var(--wp--preset--color--sky);
	outline-offset: var(--wp--preset--spacing--20);
}

/* Checkboxes/radios carry the `.hs-input` class too; the text-field treatment
   above would stretch them, so give them back their native rendering. */
.hs-form input[type="checkbox"].hs-input,
.hs-form input[type="radio"].hs-input {
	all: revert !important;
}

/* Remove default list styling from anything HubSpot renders as <ul>/<li> —
   error messages, checkbox/radio option groups, dependent field lists. */
.hs-form ul,
.hs-form ol {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

.hs-form li {
	list-style: none !important;
}

.hs-form .hs-error-msgs {
	margin-top: var(--wp--preset--spacing--10) !important;
}

.hs-form .hs-error-msg {
	color: var(--wp--preset--color--sky);
	font-size: var(--wp--preset--font-size--small);
}

/* Any copy HubSpot wraps in a <p> — rich text, legal consent, GDPR
   disclaimers — stays legible against the theme's dark panels. */
.hs-form p, .hs-form span{
	color: var(--wp--preset--color--white) !important;
	font-size: 13px !important;
}

.hs-form p a {
	color: inherit;
	text-decoration: underline;
}

/* Legal fine print — the HubSpot rich-text consent disclosure ("We Value
   Your Privacy…") and the reCAPTCHA notice added by hubspot-forms.js. The
   wording is a TCPA consent disclosure, so it's kept in full and only made
   quieter; don't hide or truncate it without sign-off from SAE. */
.hs-form .hs-richtext p,
.hs-form .hs-richtext span,
.hs-form p.sae-recaptcha-notice {
	font-size: 11px !important;
	line-height: 1.45 !important;
	margin: 0;
	opacity: 0.75;
}

/* Run the "We Value Your Privacy" heading into the paragraph instead of
   giving it its own line (HubSpot follows it with a <br>). */
.hs-form .hs-richtext strong {
	margin-right: 0.35em;
}

.hs-form .hs-richtext strong + span > br:first-child {
	display: none;
}

/* Google allows hiding the reCAPTCHA badge only when the form shows its
   attribution text instead, so this only applies once hubspot-forms.js has
   added that notice. Visually hidden rather than `display: none`, which can
   break invisible reCAPTCHA; absolute positioning also takes it out of the
   form's flex gap. */
.hs-form {
	position: relative;
}

.hs-form:has(.sae-recaptcha-notice) .hs_recaptcha {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.hs-form .hs_submit {
	display: flex;
	justify-content: center;
	padding-top: var(--wp--preset--spacing--40);
}

.hs-form .hs-button {
	background-color: transparent;
	border: var(--wp--custom--border-width--hairline) solid var(--wp--preset--color--white);
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--white);
	cursor: pointer;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
	line-height: 1.25;
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--70);
}

.hs-form .hs-button:hover,
.hs-form .hs-button:focus {
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--carbon);
}

.wp-block-button__link:hover,
.wp-block-button__link:focus {
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--carbon);
}

/* --- Stats bar ------------------------------------------------------------ */

/* Stat figures that are words (flagged by sae_theme_flag_word_stats() in
   functions.php) shrink to fit the stat column instead of breaking
   mid-word. --sae-stat-chars is the longest word's length; 0.52em is roughly
   one average character of the heading font. Numeric figures are untouched. */
.sae-stat--word {
	container-type: inline-size;
}

.sae-stat--word > .has-2-x-large-font-size {
	font-size: min(
		var(--wp--preset--font-size--2-x-large),
		calc(100cqi / (var(--sae-stat-chars, 10) * 0.52))
	) !important;
	overflow-wrap: normal;
}

/* --- Site footer ---------------------------------------------------------- */

/* Keep the logo and the disclaimers side by side on phones instead of
   stacking: the logo column is the logo's width, the text takes the rest. */
@media (max-width: 781px) {
	footer.wp-block-group > .wp-block-columns {
		flex-wrap: nowrap !important;
	}

	footer.wp-block-group > .wp-block-columns > .wp-block-column:first-child {
		flex: 0 0 var(--wp--custom--media-width--logo-footer) !important;
	}

	footer.wp-block-group > .wp-block-columns > .wp-block-column:last-child {
		flex: 1 1 0 !important;
		min-width: 0;
	}
}

/* --- Media ---------------------------------------------------------------- */

/* Section imagery is cropped to the Figma aspect ratio rather than letterboxed. */
.sae-media-cover img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* --- Stat figures --------------------------------------------------------- */

/* The accent rule on each stat is drawn with block border attributes; this only
   guarantees the rule spans the full height of an uneven stat cell. */
.sae-stat {
	height: 100%;
}

/* --- Program cards -------------------------------------------------------- */

.sae-program-card {
	height: 100%;
}

.sae-program-card figure,
.sae-program-card img {
	width: 100%;
}

/* Source photography is 3:2; the design crops the card image to 605x325. */
.sae-program-card .sae-media-cover img {
	aspect-ratio: 605 / 325;
	object-fit: cover;
}

/* --- Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
