/*
Theme Name: Lost in the Swell
Theme URI: https://www.lostintheswell.com/
Author: Lost in the Swell
Author URI: https://www.lostintheswell.com/
Description: Custom block theme for lostintheswell.com.
Requires at least: 6.7
Tested up to: 7.0
Requires PHP: 7.2
Version: 1.0.1
License: UNLICENSED
Text Domain: lostintheswell
Tags: one-column, custom-colors, custom-menu, custom-logo, editor-style, featured-images, full-site-editing, block-patterns, rtl-language-support, sticky-post, threaded-comments, translation-ready, wide-blocks, block-styles, style-variations, accessibility-ready, blog, portfolio, news
*/

/*
 * It is not recommended that you use the Theme File Editor to modify this
 * stylesheet. Instead, add the necessary style overrides via the Site Editor.
 * Minification is handled by the Autoptimize plugin in production.
 */

/*
 * Link styles
 * https://github.com/WordPress/gutenberg/issues/42319
 */
a {
	text-decoration-thickness: 1px !important;
	text-underline-offset: .1em;
}

/* Focus styles */
:where(.wp-site-blocks *:focus) {
	outline-width: 2px;
	outline-style: solid;
}

/* Increase the bottom margin on submenus, so that the outline is visible. */
.wp-block-navigation .wp-block-navigation-submenu .wp-block-navigation-item:not(:last-child) {
	margin-bottom: 3px;
}

/* Increase the outline offset on the parent menu items, so that the outline does not touch the text. */
.wp-block-navigation .wp-block-navigation-item .wp-block-navigation-item__content {
	outline-offset: 4px;
}

/* Remove outline offset from the submenus, otherwise the outline is visible outside the submenu container. */
.wp-block-navigation .wp-block-navigation-item ul.wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	outline-offset: 0;
}

/*
 * Progressive enhancement to reduce widows and orphans
 * https://github.com/WordPress/gutenberg/issues/55190
 */
h1, h2, h3, h4, h5, h6, blockquote, caption, figcaption, p {
	text-wrap: pretty;
}

/*
 * Change the position of the more block on the front, by making it a block level element.
 * https://github.com/WordPress/gutenberg/issues/65934
*/
.more-link {
	display: block;
}

/*
 * Prevents unnecessary scrollbars while handling long lines of preformatted text.
 * https://core.trac.wordpress.org/ticket/63875
 */
:where(pre) {
	overflow-x: auto;
}

/*
 * Featured-image banners sit flush against the site header.
 * Each banner is the first full-width Cover block after the header template
 * part, so the root block-gap would otherwise add a small top margin that reads
 * as a stray strip of whitespace below the header. Zero it out so the banner
 * butts directly against the header. The child combinator keeps this scoped to
 * the top-level banner covers and leaves Cover blocks inside content untouched.
 *
 * WooCommerce wraps single-product templates in a .woocommerce.product group,
 * which becomes the direct child of .wp-site-blocks instead of the Cover. The
 * root block-gap lands on that wrapper, so zero its top margin to pull the
 * banner (the wrapper's first child) up against the header. Cover blocks inside
 * the product content are unaffected.
 */
.wp-site-blocks > .wp-block-cover,
.wp-site-blocks > .woocommerce.product {
	margin-block-start: 0;
}

/*
 * The single-product banner title ("Shop") links back to the shop archive.
 * These banners have no dark-overlay wrapper for the .has-contrast-background
 * link rule to hook onto, so the link would otherwise fall back to the accent
 * link colour. Inherit the heading's light colour and drop the underline so it
 * reads as the banner title rather than a body link.
 */
.wp-block-cover__inner-container .wp-block-heading a:where(:not(.wp-element-button)) {
	color: inherit;
	text-decoration: none;
}

/*
 * Sticky footer.
 * Make the site wrapper fill at least the full viewport height and let the
 * <main> region grow, so the footer rests at the bottom of the window even
 * when the content is shorter than the viewport.
 */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

.wp-site-blocks > main {
	flex-grow: 1;
}

/*
 * Dark sections (the footer uses the "contrast" background) get light links so
 * they stay legible against the navy, overriding the ocean-blue link colour.
 * This also keeps the "logos only" social icons — which inherit currentColor —
 * white, with a light-slate hover.
 */
.has-contrast-background-color a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--base);
}

.has-contrast-background-color a:where(:not(.wp-element-button)):hover {
	color: var(--wp--preset--color--accent-2);
}

/* Footer bottom bar: a hairline divider above the copyright line. */
.lits-footer__bottom {
	margin-top: var(--wp--preset--spacing--60);
	padding-top: var(--wp--preset--spacing--40);
	border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/*
 * Contact Form 7
 * CF7 ships only minimal markup (no field styling), so bring its inputs and
 * submit button in line with the theme: Manrope body type, ocean-blue accents
 * and the same squared, borderless button used elsewhere (.wp-element-button).
 * The theme stylesheet is inlined after the plugin stylesheet, so these rules
 * win on the cascade; selectors match CF7's specificity where it sets its own.
 */

/* Stack fields with a consistent vertical rhythm (CF7 wraps each in a <p>). */
.wpcf7-form p {
	margin: 0 0 var(--wp--preset--spacing--30);
}

/* Labels sit above their control. */
.wpcf7-form label {
	display: block;
	font-weight: 600;
	line-height: 1.4;
}

/*
 * The control already breaks onto its own line, so drop CF7's <br> and use a
 * precise gap between the label text and the field.
 */
.wpcf7-form label br {
	display: none;
}

.wpcf7-form .wpcf7-form-control-wrap {
	display: block;
	margin-top: var(--wp--preset--spacing--20);
}

/* Text-style controls. */
.wpcf7-form input[type="text"],
.wpcf7-form input[type="email"],
.wpcf7-form input[type="url"],
.wpcf7-form input[type="tel"],
.wpcf7-form input[type="number"],
.wpcf7-form input[type="date"],
.wpcf7-form input[type="search"],
.wpcf7-form input[type="password"],
.wpcf7-form select,
.wpcf7-form textarea {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	padding: 0.7em 0.9em;
	color: var(--wp--preset--color--contrast);
	background-color: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--accent-2);
	border-radius: 0;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.5;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wpcf7-form textarea {
	min-height: 12em;
	resize: vertical;
}

.wpcf7-form ::placeholder {
	color: var(--wp--preset--color--accent-4);
	opacity: 1;
}

/* Focus: ocean-blue border with a soft ring. */
.wpcf7-form input:focus,
.wpcf7-form select:focus,
.wpcf7-form textarea:focus {
	outline: none;
	border-color: var(--wp--preset--color--accent-1);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wp--preset--color--accent-1) 25%, transparent);
}

/* Submit button — mirror the theme's .wp-element-button (squared, borderless). */
.wpcf7-form input[type="submit"] {
	cursor: pointer;
	padding: 1rem 2.25rem;
	color: var(--wp--preset--color--base);
	background-color: var(--wp--preset--color--accent-1);
	border: 0;
	border-radius: 0;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--medium);
	transition: background-color 0.15s ease;
}

.wpcf7-form input[type="submit"]:hover {
	background-color: var(--wp--preset--color--accent-3);
}

.wpcf7-form input[type="submit"]:focus {
	outline: 2px solid var(--wp--preset--color--accent-4);
	outline-offset: 2px;
}

.wpcf7-form input[type="submit"]:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Invalid fields and their inline validation tips. */
.wpcf7-form input.wpcf7-not-valid,
.wpcf7-form textarea.wpcf7-not-valid,
.wpcf7-form select.wpcf7-not-valid {
	border-color: #b32d2e;
}

.wpcf7-form .wpcf7-not-valid-tip {
	margin-top: var(--wp--preset--spacing--20);
	font-size: var(--wp--preset--font-size--small);
	color: #b32d2e;
}

/* Response message box (CF7 sets the border colour per submission status). */
.wpcf7 form .wpcf7-response-output {
	margin: var(--wp--preset--spacing--30) 0 0;
	padding: 0.6em 1em;
	border-width: 1px;
	border-radius: 0;
	font-size: var(--wp--preset--font-size--small);
}

/* Spinner sits just after the submit button. */
.wpcf7-form .wpcf7-spinner {
	margin: 0 0 0 0.75em;
}

/*
 * Featured products on the shop grid.
 *
 * A product flagged as "Featured" (the star in Products, or Quick Edit) is
 * promoted to a full-width row at the top of the listing instead of taking one
 * cell of the three-column grid. WooCommerce already gives us the hook: the
 * Product Collection block builds each item with get_post_class(), and
 * wc_product_post_class() adds a `featured` class to it, so no markup of ours
 * is involved. Ordering is handled in functions.php — see
 * lostintheswell_featured_products_first().
 *
 * The grid is laid out by WooCommerce as a real CSS grid
 * (.wc-block-product-template__responsive sets display: grid), so spanning the
 * row is a single declaration rather than a width calculation.
 */
.wc-block-product-template {
	container-type: inline-size;
	container-name: product-grid;
}

.wc-block-product-template > li.featured {
	grid-column: 1 / -1;
}

/*
 * The short description belongs to the promoted card only — it is what makes
 * the extra space worth giving up. The Product Summary block is in the shared
 * product template, so hide it on the ordinary grid cards. They are unaffected
 * otherwise: a display: none child generates no box, so it contributes nothing
 * to the stack WooCommerce spaces with its own margin rule.
 */
.wc-block-product-template > li:not(.featured) .wp-block-woocommerce-product-summary {
	display: none;
}

/*
 * Wide layout: image on the left, details beside it. Narrower than this the
 * promoted card keeps the stacked layout of an ordinary card and simply spans
 * the full row.
 *
 * This is a container query rather than a media query because the width the
 * grid actually gets is not monotonic in the viewport width: the shop sidebar
 * takes a third of the row until the columns stack at 782px, so the grid is
 * ~445px wide on an 820px viewport but ~615px on a 700px one. A viewport
 * breakpoint would have to be wrong at one end or the other; asking the grid
 * how wide it is is right at both.
 *
 * The empty first and last rows are what centres the details against the
 * image: they are the only `1fr` tracks, so they absorb whatever height the
 * image has over the text and split it evenly. When the text is the taller of
 * the two they collapse to nothing.
 */
@container product-grid (min-width: 600px) {
	.wc-block-product-template > li.featured {
		display: grid;
		grid-template-columns: minmax(0, 45%) minmax(0, 1fr);
		grid-template-rows: 1fr auto auto auto auto 1fr;
		grid-template-areas:
			"image ."
			"image title"
			"image summary"
			"image price"
			"image button"
			"image .";
		column-gap: var(--wp--preset--spacing--50);
	}

	.wc-block-product-template > li.featured > * {
		margin-top: 0;
		margin-bottom: 0;
	}

	.wc-block-product-template > li.featured > .wp-block-woocommerce-product-image {
		grid-area: image;
		align-self: center;
	}

	.wc-block-product-template > li.featured > .wp-block-post-title {
		grid-area: title;
		margin-bottom: var(--wp--preset--spacing--20);
	}

	.wc-block-product-template > li.featured > .wp-block-woocommerce-product-summary {
		grid-area: summary;
		margin-bottom: var(--wp--preset--spacing--30);
	}

	.wc-block-product-template > li.featured > .wp-block-woocommerce-product-price {
		grid-area: price;
		margin-bottom: var(--wp--preset--spacing--30);
	}

	.wc-block-product-template > li.featured > .wp-block-woocommerce-product-button {
		grid-area: button;
	}

	/*
	 * Grid cards centre their text under a centred image. Beside an image the
	 * same text reads as a panel, so align it to the start of its column. The
	 * product button is a flex column, so it takes align-items rather than
	 * text-align.
	 */
	.wc-block-product-template > li.featured > .has-text-align-center {
		text-align: start;
	}

	.wc-block-product-template > li.featured > .wc-block-components-product-button.align-center {
		align-items: flex-start;
	}
}

/* Override WooCommerce page max-width */
.woocommerce-account .wp-block-post-title,
.woocommerce-account main .woocommerce,
.woocommerce-cart .wp-block-post-title,
.woocommerce-cart main .woocommerce,
.woocommerce-checkout .wp-block-post-title,
.woocommerce-checkout main .woocommerce {
	max-width: 1340px !important;
}

