/*
Theme Name: Ollie Truecraft
Theme URI: https://truecraft.example
Description: Truecraft child theme for Ollie. Design. Build. Renovate.
Author: Chris Begley
Template: ollie
Version: 1.0.0
Requires at least: 6.6
Tested up to: 7.1
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: ollie-truecraft
*/

/* Motion: smooth anchor scrolling and a one-time reveal for blocks with the
   `cjb-reveal` class. `cjb-motion` is set on <html> by an inline head script only
   when the visitor hasn't asked for reduced motion, so nothing is hidden without JS. */
@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}

	.cjb-motion .cjb-reveal {
		opacity: 0;
		transform: translate3d(0, 1rem, 0);
		transition:
			opacity 0.7s cubic-bezier(0.22, 0.61, 0.36, 1),
			transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
		transition-delay: var(--cjb-reveal-delay, 0ms);
	}

	.cjb-motion .cjb-reveal.is-revealed {
		opacity: 1;
		transform: none;
	}
}

/* Archivo is always set semi-expanded; the look depends on it. */
h1, h2, h3, h4, h5, h6,
.has-heading-font-family {
	font-stretch: 112%;
}

h1, h2, h3 {
	text-wrap: balance;
}

p {
	text-wrap: pretty;
}

/* SVG site logo has no intrinsic size in the editor canvas; fill the resizable box. */
.editor-styles-wrapper .wp-block-site-logo img {
	width: 100%;
}

/* Buttons: 44px minimum touch target. */
.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
}

/* Outline buttons: 1px border at 45% of the text colour (replaces Ollie's 2px outline). */
.wp-block-buttons .wp-block-button.is-style-outline .wp-block-button__link {
	border: 1px solid color-mix(in srgb, currentColor 45%, transparent);
	outline: 0;
}

/* Focus: teal on light backgrounds, brass on teal. */
:root {
	--cjb-focus: var(--wp--preset--color--primary);
}

.has-primary-background-color,
.has-primary-alt-accent-background-color {
	--cjb-focus: var(--wp--preset--color--primary-alt);
}

a:focus-visible,
button:focus-visible,
.wp-block-button__link:focus-visible,
.wp-block-buttons .wp-block-button.is-style-outline .wp-block-button__link:focus-visible {
	outline: 2px solid var(--cjb-focus);
	outline-offset: 3px;
}

/* Navigation on teal: white underline on hover. */
.has-primary-background-color .wp-block-navigation-item__content:hover,
.has-primary-alt-accent-background-color .wp-block-navigation-item__content:hover {
	color: var(--wp--preset--color--white);
	text-decoration: underline;
	text-underline-offset: 6px;
}

.has-primary-alt-accent-background-color .wp-block-navigation-item__content:hover {
	text-decoration: none;
}

/* Header with a collapsed menu: keep "Start your project" and the hamburger together. */
@media (max-width: 959.98px) {
	/* Never wrap the hamburger to a second row; the logo gives way first. */
	header.wp-block-template-part .wp-block-group.alignwide:has(.is-style-collapse-960) {
		flex-wrap: nowrap;
	}

	header.wp-block-template-part .wp-block-group.alignwide:has(.is-style-collapse-960) > .wp-block-site-logo {
		flex-shrink: 1;
		min-width: 0;
	}

	header.wp-block-template-part .wp-block-group:has(> .wp-block-navigation.is-style-collapse-960) {
		flex-wrap: nowrap;
		flex-shrink: 0;
		column-gap: var(--wp--preset--spacing--xx-small);
	}
}

/* Below 375px the header button is dropped; it is still in the overlay menu. */
@media (max-width: 374.98px) {
	header.wp-block-template-part .wp-block-group:has(> .wp-block-navigation.is-style-collapse-960) > .wp-block-buttons {
		display: none;
	}
}

/* Phones: compact the header so logo, button and hamburger share one row (fits 375px).
   !important is needed to beat the button's inline padding and preset font-size class. */
@media (max-width: 480px) {
	header.wp-block-template-part .wp-block-group.alignwide:has(.is-style-collapse-960) {
		column-gap: var(--wp--preset--spacing--x-small);
	}

	header.wp-block-template-part .wp-block-group:has(> .wp-block-navigation.is-style-collapse-960) > .wp-block-buttons .wp-block-button__link {
		font-size: var(--wp--preset--font-size--label) !important;
		padding-right: var(--wp--preset--spacing--x-small) !important;
		padding-left: var(--wp--preset--spacing--x-small) !important;
	}
}

/* Footer links on Deep Teal. */
.has-primary-alt-accent-background-color a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--on-teal-muted);
}

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

/* Contact form (placeholder markup in a Custom HTML block; not wired to a handler yet). */
.cjb-form {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--small-plus);
	margin: 0;
}

.cjb-form__row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
	gap: var(--wp--preset--spacing--small-plus);
}

.cjb-form__field {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--xx-small);
}

.cjb-form__field label {
	font-size: var(--wp--preset--font-size--label);
	font-weight: 600;
	line-height: 1.2;
	color: var(--wp--preset--color--main);
}

.cjb-form__field input,
.cjb-form__field select,
.cjb-form__field textarea {
	box-sizing: border-box;
	width: 100%;
	min-height: 48px;
	margin: 0;
	padding: 12px 14px;
	font: inherit;
	font-size: 16px;
	line-height: 1.25;
	color: var(--wp--preset--color--main);
	background: var(--wp--preset--color--white);
	border: 1px solid var(--wp--custom--color--field-border);
	border-radius: 2px;
	box-shadow: none;
}

.cjb-form__field textarea {
	resize: vertical;
}

.cjb-form__field input:focus,
.cjb-form__field select:focus,
.cjb-form__field textarea:focus {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 1px;
	border-color: var(--wp--preset--color--primary);
}

/* Submit picks up theme.json button styles via .wp-element-button; this adds size and the arrow. */
.cjb-form__submit {
	align-self: flex-start;
	display: inline-flex;
	align-items: center;
	gap: 0.625rem;
	min-height: 52px;
	border: 0;
	cursor: pointer;
}

.cjb-form__submit::after {
	content: "";
	flex: none;
	width: 18px;
	height: 18px;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M3 9 H15 M10 4 L15 9 L10 14' fill='none' stroke='black' stroke-width='1.75'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M3 9 H15 M10 4 L15 9 L10 14' fill='none' stroke='black' stroke-width='1.75'/%3E%3C/svg%3E") center / contain no-repeat;
}
