/*
Theme Name: SSRA
Theme URI: https://www.seattlesquash.com
Description: Block theme for the Seattle Squash Racquets Association. Child of Twenty Twenty-Five. Replaces the Elementor-dependent hello-elementor theme; all layout is core blocks, all design tokens live in theme.json.
Author: Seattle Squash Racquets Association
Template: twentytwentyfive
Version: 0.1.0
Requires at least: 6.7
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: ssra
*/

/*
 * Design tokens live in theme.json, not here. This file is for the few rules
 * that blocks cannot express.
 *
 * Deliberately NOT ported from the old site's Additional CSS: every rule there
 * targeted Elementor internals (.elementor-widget-testimonial-carousel,
 * .slider_one, .elementor-form-spinner, .elementor-2345 .elementor-element-...).
 * Those selectors stop existing once Elementor is removed. The two intents worth
 * keeping were the red accent on active carousel slides and a 35vh banner height
 * on cart/checkout, both of which are expressed with tokens now.
 */

/* Skip link is visually hidden until focused - keyboard users need it first. */
.skip-link:focus {
	position: fixed;
	top: 1rem;
	left: 1rem;
	z-index: 1000;
	padding: 0.75rem 1.25rem;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	outline: 2px solid var(--wp--preset--color--accent);
}

/*
 * The site logo carries the association's name. The original header sets it to
 * 320px wide (190px on tablet), so let the block's own width win and only
 * constrain it on small screens.
 */
.wp-block-site-logo img {
	height: auto;
	max-width: 100%;
}

@media (max-width: 900px) {
	.ssra-header .wp-block-site-logo img {
		width: 190px;
	}
}

@media (max-width: 600px) {
	.ssra-header .wp-block-site-logo img {
		width: 150px;
	}
}

/*
 * Header and footer are dark (the originals were #000000D1 and #000000), so the
 * navigation and footer links need to read light. Hover yellow matches the
 * Elementor header's dropdown hover colour.
 */
.ssra-header .wp-block-navigation a:hover,
.ssra-header .wp-block-navigation a:focus,
.ssra-header .ssra-cart-link a:hover,
.ssra-header .ssra-cart-link a:focus {
	color: #F7FF00;
}

/*
 * The cart link replaced woocommerce/mini-cart (see parts/header.html for why),
 * so it has to carry the weight the mini-cart button had on its own rather than
 * inheriting it from the navigation block.
 */
.ssra-header .ssra-cart-link {
	margin: 0;
}

/*
 * It has to match the navigation links beside it, and a paragraph link picks up
 * none of that: the global link colour (#A82828) is unreadable on the black
 * header, and the underline the navigation block removes from its own links is
 * still there on this one.
 */
.ssra-header .ssra-cart-link a {
	color: var(--wp--preset--color--base);
	font-weight: 700;
	text-decoration: none;
}

.ssra-footer a:hover,
.ssra-footer a:focus {
	color: var(--wp--preset--color--primary);
}

/*
 * Footer link lists (Quick Links, Discovery) are navigation, not prose, so they
 * carry no bullets. The markup uses is-style-none, which is not a core list
 * style - this is the rule that actually makes it do something.
 */
.ssra-footer .wp-block-list.is-style-none {
	list-style: none;
	padding-left: 0;
	margin-left: 0;
}

.ssra-footer .wp-block-list.is-style-none li {
	margin-bottom: 0.35rem;
}

/*
 * The header, main and footer are siblings under .wp-site-blocks, so the global
 * 1.5rem block gap opened a stripe of page colour between the dark header and
 * the first section, and again between the last section and the footer. The
 * chrome should meet the content directly.
 */
.wp-site-blocks > header,
.wp-site-blocks > main,
.wp-site-blocks > footer {
	margin-block-start: 0;
	margin-block-end: 0;
}

/* Nor should the first/last section inside main add its own. */
.wp-site-blocks > main > :first-child {
	margin-block-start: 0;
}

.wp-site-blocks > main > :last-child {
	margin-block-end: 0;
}

/*
 * The newsletter form sits on the black footer, so WPForms' own label colours
 * are unreadable there. The input keeps a light field with dark text -
 * inverting that too would make it hard to see what you typed.
 *
 * WPForms drives label colour through its own custom properties, and its
 * selectors (div.wpforms-container-full ...) outrank a plain class rule - which
 * is why simply setting `color` here left the label black. Set the variables
 * it actually reads.
 */
.ssra-footer .wpforms-container,
.ssra-footer .wpforms-container-full {
	--wpforms-label-color: var(--wp--preset--color--base);
	--wpforms-label-sublabel-color: var(--wp--preset--color--base);
	--wpforms-label-error-color: #FFB4A2;
	--wpforms-button-background-color: var(--wp--preset--color--primary);
	--wpforms-button-text-color: var(--wp--preset--color--contrast);
}

.ssra-footer .wpforms-field-label,
.ssra-footer .wpforms-field-sublabel,
.ssra-footer .wpforms-field-description,
.ssra-footer .wpforms-required-label {
	color: var(--wp--preset--color--base);
}

.ssra-footer .wpforms-field-label {
	font-weight: 600;
}

/*
 * Contact form on the red homepage panel: labels white against the red, and a
 * full-width squash-yellow Send button so it lines up with the message box
 * above it. Colours go through WPForms' own custom properties - its selectors
 * outrank plain class rules.
 */
.ssra-contact-panel .wpforms-container,
.ssra-contact-panel .wpforms-container-full {
	--wpforms-label-color: var(--wp--preset--color--base);
	--wpforms-label-sublabel-color: var(--wp--preset--color--base);
	--wpforms-button-background-color: var(--wp--preset--color--primary);
	--wpforms-button-text-color: var(--wp--preset--color--contrast);
}

.ssra-contact-panel .wpforms-field-label,
.ssra-contact-panel .wpforms-field-sublabel,
.ssra-contact-panel .wpforms-required-label {
	color: var(--wp--preset--color--base);
}

.ssra-contact-panel .wpforms-form input.wpforms-field-medium,
.ssra-contact-panel .wpforms-form textarea.wpforms-field-medium,
.ssra-contact-panel .wpforms-form input[type="text"],
.ssra-contact-panel .wpforms-form input[type="email"] {
	width: 100%;
	max-width: 100%;
}

.ssra-contact-panel .wpforms-submit-container {
	width: 100%;
}

.ssra-contact-panel button[type="submit"],
.ssra-contact-panel .wpforms-submit {
	width: 100%;
	font-weight: 700;
}

/*
 * Newsletter signup reads as one control: the email field and the Subscribe
 * button side by side, rather than WPForms' default stack. Wraps to two rows
 * on narrow screens, where side-by-side would squeeze the input.
 */
.ssra-footer .wpforms-form {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 3px;
}

.ssra-footer .wpforms-form .wpforms-field-container {
	/* Half the column's width, and no growing - so the input stays short and the
	   button follows it directly rather than being pushed to the far edge.
	   min-width:0 still lets it shrink rather than wrap on narrow screens. */
	flex: 0 1 50%;
	min-width: 0;
	margin: 0;
}

@media (min-width: 600px) {
	.ssra-footer .wpforms-form {
		flex-wrap: nowrap;
	}
}

.ssra-footer .wpforms-form .wpforms-field {
	padding: 0;
	margin-bottom: 0;
	/* Column layout so the validation message can be reordered above the input. */
	display: flex;
	flex-direction: column;
}

/*
 * WPForms prints the validation message after the input. In the footer the
 * input sits on the last line of the page, so a message underneath it can land
 * on the very edge of the viewport. Ordering puts it above the field, between
 * the label and the box, where it is read before the input rather than after.
 * Only the visual order changes - the DOM order stays as WPForms emits it, so
 * the aria-describedby association still holds for screen readers.
 */
.ssra-footer .wpforms-form .wpforms-field > label.wpforms-field-label {
	order: -2;
}

.ssra-footer .wpforms-form .wpforms-field > .wpforms-error,
.ssra-footer .wpforms-form .wpforms-field > em.wpforms-error,
.ssra-footer .wpforms-form .wpforms-field > label.wpforms-error {
	order: -1;
	margin: 0 0 0.35rem;
	font-size: 0.85rem;
	font-style: normal;
	color: var(--wpforms-label-error-color, #FFB4A2);
}

/*
 * Pin both controls to the same height so they sit on one line. WPForms sizes
 * its input and button from separate internals, so matching them explicitly is
 * more reliable than hoping the two agree.
 */
.ssra-footer .wpforms-form input[type="email"],
.ssra-footer .wpforms-form button[type="submit"] {
	height: 46px;
	box-sizing: border-box;
	margin: 0;
}

/*
 * WPForms caps .wpforms-field-medium at max-width:60%, which is what left a
 * wide gap before the Subscribe button - the flex gap was already 3px. The
 * field should fill its container here.
 */
.ssra-footer .wpforms-form input[type="email"],
.ssra-footer .wpforms-form input.wpforms-field-medium {
	width: 100%;
	max-width: 100%;
}

.ssra-footer .wpforms-form button[type="submit"] {
	font-weight: 700;
	padding-left: 1rem;
	padding-right: 1rem;
	white-space: nowrap;
}

.ssra-footer .wpforms-form .wpforms-submit-container {
	flex: 0 0 auto;
	padding: 0;
	margin: 0;
}

/* Keep the logo hard left even when the nav wraps onto its own row. */
.ssra-header .wp-block-site-logo {
	margin-right: auto;
	text-align: left;
}

/*
 * Newsletter PDFs: title link and Download button above the preview rather than
 * below it. The core File block always emits the <object> first, and rewriting
 * that order in the markup makes the editor flag the block as invalid - so the
 * order is changed visually and the DOM is left as core wrote it.
 */
.wp-block-file.ssra-file-links-top {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.75rem;
}

.wp-block-file.ssra-file-links-top .wp-block-file__embed {
	order: 3;
	width: 100%;
}

.wp-block-file.ssra-file-links-top > a:not(.wp-block-file__button) {
	order: 1;
	font-weight: 700;
}

.wp-block-file.ssra-file-links-top .wp-block-file__button {
	order: 2;
	margin: 0;
}

/*
 * Only the outermost container should apply the root side padding.
 *
 * WordPress adds .has-global-padding to every constrained container, and does
 * not neutralise it when they nest - so a section group inside <main> was inset
 * by two or three lots of it, and page content started well inside the header
 * and footer above and below it. This lines every page up with the chrome.
 *
 * Full-width sections are exempt: they break out past the root padding by
 * design, so they still need their own to keep their contents aligned.
 */
.has-global-padding :where(.has-global-padding:not(.alignfull)) {
	padding-right: 0;
	padding-left: 0;
}

/*
 * A left- or right-floated image has to stop floating on small screens.
 *
 * Core floats .alignleft / .alignright at every width, so the Winter League
 * flyer at 380px left barely a phone's width of room for the text beside it,
 * in columns a few words wide. Below the tablet breakpoint the image goes
 * full width and the text resumes underneath it.
 */
@media (max-width: 900px) {
	.wp-block-image.alignleft,
	.wp-block-image.alignright {
		float: none;
		margin-right: 0;
		margin-left: 0;
	}

	/* the editor writes the chosen width inline, so this has to outrank it */
	.wp-block-image.alignleft img,
	.wp-block-image.alignright img {
		width: 100% !important;
		max-width: 420px;
		height: auto;
	}
}

/*
 * A section containing a floated image has to contain it.
 *
 * A float sits outside its parent's content box, so where the flyer is taller
 * than the text beside it the group's bottom padding lands above the float and
 * the image runs down into whatever follows. flow-root makes the group enclose
 * the float, restoring the gap below it.
 */
.wp-block-group:has(> .wp-block-image.alignleft),
.wp-block-group:has(> .wp-block-image.alignright) {
	display: flow-root;
}
