/*
Theme Name:   Craig Pearson
Theme URI:    https://craigpearson.co.uk
Description:  Ollie child theme for craigpearson.co.uk -- a personal technical portfolio whose own build quality is the argument it makes. Tokens, templates and page compositions from docs/craigpearson-co-uk/rebuild-spec.md (COF-923), built under COF-924.
Author:       Craig Pearson
Author URI:   https://craigpearson.co.uk
Template:     ollie
Version:      0.1.0
Requires at least: 6.7
Tested up to: 7.0
Requires PHP: 8.3
License:      GNU General Public License v2 or later
License URI:  http://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  ollie-cp
*/

/*
 * Focus ring.
 *
 * Spec S4.4: Ollie's own style.css styles :focus only on input, textarea and
 * select (lines 108-112), so every link, button and navigation item on the
 * site has no visible focus indicator at all. The ring is `primary`, which
 * measures 7.75:1 against `base` and 7.08:1 against `tertiary` -- both well
 * past the 3:1 WCAG 2.2 non-text minimum.
 *
 * :focus-visible rather than :focus so a mouse click does not leave a ring
 * behind; the two-colour outline+shadow pairing keeps the ring visible on the
 * dark sections too, where `primary` alone is only 2.34:1 against `main`.
 */
:where(a, button, summary, [tabindex]:not([tabindex="-1"]), input, select, textarea):focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
	box-shadow: 0 0 0 4px var(--wp--preset--color--base);
}

.has-main-background-color :where(a, button, summary, [tabindex]:not([tabindex="-1"])):focus-visible,
.has-primary-alt-accent-background-color :where(a, button, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
	outline-color: var(--wp--preset--color--primary-alt);
	box-shadow: 0 0 0 4px var(--wp--preset--color--main);
}

/*
 * Skip link.
 *
 * Core prints `.skip-link.screen-reader-text` before the header on every block
 * theme, but only WordPress's own admin-bar stylesheet gives it a visible
 * focused state on the front end, and that is not loaded for a logged-out
 * reader. Spec S9.4 requires the skip link to be the first tab stop and to be
 * visible when focused.
 */
.skip-link.screen-reader-text:focus {
	background-color: var(--wp--preset--color--base);
	border-radius: 5px;
	box-shadow: 0 0 0 2px var(--wp--preset--color--primary);
	clip: auto !important;
	clip-path: none;
	color: var(--wp--preset--color--primary);
	display: block;
	font-size: 1rem;
	font-weight: 600;
	height: auto;
	left: 8px;
	line-height: normal;
	padding: 16px 24px;
	text-decoration: none;
	top: 8px;
	width: auto;
	z-index: 100000;
}

/*
 * Tap targets.
 *
 * Spec S9.3 requires every navigation and tag link to present at least a
 * 24x24 CSS px target at 390 (WCAG 2.2 SS2.5.8). Ollie's navigation and its
 * `is-style-term-button` post-terms both render below that at `small` and
 * `x-small` font sizes -- measured, not assumed, and `min-height` alone is
 * not enough: the "CV" item measured 18.3px WIDE in Chromium at 390 with the
 * height already satisfied, because a two-letter label is narrower than the
 * minimum in the other axis. Both dimensions, then, with the content centred
 * so nothing moves for the labels that were already wide enough.
 */
.wp-block-navigation .wp-block-navigation-item__content,
.wp-block-post-terms.is-style-term-button a {
	align-items: center;
	display: inline-flex;
	justify-content: center;
	min-height: 24px;
	min-width: 24px;
}

/*
 * The CV section navigation.
 *
 * A sticky flex row of anchor links, composed in patterns/page-cv.php. Two
 * things it must do that block attributes cannot express: sit above the page
 * content while it is stuck, and stop being sticky at 390 where the spec
 * (S9.3) forbids it overlaying the heading it links to.
 */
.cv-section-nav {
	backdrop-filter: blur(6px);
	background-color: color-mix(in srgb, var(--wp--preset--color--base) 88%, transparent);
	border-bottom: 1px solid var(--wp--preset--color--border-light);
	position: static;
	top: 0;
	z-index: 10;
}

@media (min-width: 782px) {
	.cv-section-nav {
		position: sticky;
	}
}

/*
 * Anchored CV sections must not land under the sticky nav when jumped to.
 * scroll-margin-top is the only mechanism that does this without moving the
 * element in normal flow.
 */
.cv-section {
	scroll-margin-top: 5rem;
}

/*
 * Common questions (S3.6).
 *
 * Ollie styles `core/details` with a single `summary { font-weight: 600 }`
 * rule in its theme.json and nothing else -- its own faq.php does not use the
 * block at all, so the disclosure has no affordance and no boundary. Note
 * `faq.php` is heading-plus-paragraph in columns; the spec's claim that it
 * uses core/details is wrong, and this is what makes the block usable instead.
 */
.wp-block-details {
	border-bottom: 1px solid var(--wp--preset--color--border-light);
	padding: var(--wp--preset--spacing--medium) 0;
}

.wp-block-details summary {
	cursor: pointer;
	font-size: var(--wp--preset--font-size--medium);
	list-style: none;
	padding-inline-end: 2rem;
	position: relative;
}

.wp-block-details summary::-webkit-details-marker {
	display: none;
}

.wp-block-details summary::after {
	content: "+";
	color: var(--wp--preset--color--primary);
	font-family: var(--wp--preset--font-family--monospace);
	inset-inline-end: 0;
	position: absolute;
	top: 0;
}

.wp-block-details[open] summary::after {
	content: "\2212";
}

/*
 * Reduced motion.
 *
 * Spec S9.4. Ollie's navigation overlay animates its open/close, and the
 * sticky CV nav's backdrop filter repaints on scroll; neither should move for
 * a reader who has asked for less motion.
 */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}

/*
 * Print, CV only (S5.6).
 *
 * Target: two A4 pages, no orphaned section heading, no sticky bar stamped
 * across page two. Link URLs are printed after their text inside #experience
 * and #contact only -- printing every URL on the page turns the skills list
 * into noise.
 */
@media print {
	.site-header,
	.site-footer,
	.cv-section-nav,
	.wp-block-search {
		display: none !important;
	}

	body {
		background: #fff !important;
		color: #000 !important;
		font-size: 10.5pt;
	}

	.wp-block-group,
	.wp-block-group.has-background {
		background: none !important;
		padding-block: 0.4rem !important;
	}

	main :where(.wp-block-group, .wp-block-columns) {
		max-width: none !important;
	}

	.cv-experience-row,
	.cv-education-row {
		break-inside: avoid;
		page-break-inside: avoid;
	}

	h1,
	h2,
	h3 {
		break-after: avoid;
		page-break-after: avoid;
	}

	#experience a[href^="http"]::after,
	#contact a[href^="http"]::after {
		content: " (" attr(href) ")";
		font-size: 9pt;
		word-break: break-all;
	}
}
