/*
Theme Name: KU Graphics
Theme URI: https://kugraphics.org
Author: Greg Williams
Author URI: https://kugraphics.org
Description: A custom block theme for kugraphics.org built on MDH design research. Terracotta and paper palette, DM Serif Display + DM Sans typography, accessibility-first layout with APCA contrast compliance, structured data for SEO and AI agents.
Version: 1.0.0
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: kugraphics
Tags: blog, education, full-site-editing, block-patterns, custom-colors, custom-logo, wide-blocks, accessibility-ready
*/

/* ============================================================
   KU GRAPHICS â MDH DESIGN SYSTEM
   Built from MyDesignHelper research:
   - OKLCH color space, APCA contrast (Lcâ¥78 body)
   - Modular scale 1.2 (Minor Third)
   - Alternating spacing scale (1.33Ã / 1.5Ã)
   - Three-point responsive (640 / 960 / 1440)
   ============================================================ */

/* --- Custom Properties (beyond theme.json) --- */
:root {
	--ku-reading-width: 680px;
	--ku-golden: 1.618;
	--ku-transition: 0.2s ease;
	--ku-nav-height: 58px;
	--ku-focus-ring: 2px solid var(--wp--preset--color--accent);
}

/* --- Global Reset Refinements --- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0s !important;
		scroll-behavior: auto !important;
	}
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	overflow-wrap: break-word;
}

/* --- Focus Indicators (WCAG 2.4.7) --- */
:focus-visible {
	outline: var(--ku-focus-ring);
	outline-offset: 2px;
}

/* Remove default focus ring for mouse users */
:focus:not(:focus-visible) {
	outline: none;
}

/* --- Skip Link --- */
.skip-to-content {
	position: absolute;
	top: -100%;
	left: 50%;
	transform: translateX(-50%);
	z-index: 9999;
	padding: 0.75rem 1.5rem;
	background: var(--wp--preset--color--accent-btn);
	color: var(--wp--preset--color--card);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 500;
	text-decoration: none;
	border-radius: var(--wp--custom--radius--sm);
	transition: top var(--ku-transition);
}

.skip-to-content:focus {
	top: var(--wp--preset--spacing--10);
}

/* --- Header / Navigation --- */
.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	min-height: var(--ku-nav-height);
	background: var(--wp--preset--color--paper);
	border-bottom: 1px solid var(--wp--preset--color--border);
	backdrop-filter: blur(8px);
}

.site-header .wp-block-navigation {
	gap: 0.25rem;
}

.site-header .wp-block-navigation a {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
	font-weight: 450;
	transition: color var(--ku-transition);
}

.site-header .wp-block-navigation a:hover {
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Dropdown submenu styling */
.wp-block-navigation .wp-block-navigation__submenu-container {
	background: var(--wp--preset--color--card);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--md);
	box-shadow: var(--wp--custom--shadow--lg);
	padding: 0.5rem 0;
	min-width: 200px;
	animation: submenu-fade 0.15s ease;
}

@keyframes submenu-fade {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: translateY(0); }
}

.wp-block-navigation .wp-block-navigation__submenu-container a {
	padding: 0.5rem 1rem;
	font-size: 0.85rem;
}

.wp-block-navigation .wp-block-navigation__submenu-container a:hover {
	background: var(--wp--preset--color--accent-lt);
}

/* Submenu arrow/indicator */
.wp-block-navigation-submenu__toggle {
	gap: 0.25rem;
}

.wp-block-navigation-submenu__toggle svg {
	width: 10px;
	height: 10px;
}

/* --- Post Content Readability --- */
.entry-content > *,
.wp-block-post-content > * {
	max-width: var(--ku-reading-width);
	margin-left: auto;
	margin-right: auto;
}

.entry-content > .alignwide,
.wp-block-post-content > .alignwide {
	max-width: var(--wp--style--global--wide-size);
}

.entry-content > .alignfull,
.wp-block-post-content > .alignfull {
	max-width: none;
}

/* Paragraph spacing for long-form reading */
.wp-block-post-content p {
	margin-bottom: 1.5em;
}

.wp-block-post-content p + p {
	text-indent: 0;
}

/* --- Post Title --- */
.wp-block-post-title {
	margin-bottom: var(--wp--preset--spacing--30);
}

/* --- Post Meta (date, category, reading time) --- */
.post-meta {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--30);
	align-items: center;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--ink-muted);
	margin-bottom: var(--wp--preset--spacing--50);
	padding-bottom: var(--wp--preset--spacing--30);
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.post-meta a {
	color: var(--wp--preset--color--ink-muted);
	text-decoration: none;
}

.post-meta a:hover {
	color: var(--wp--preset--color--accent);
}

.post-meta .separator {
	color: var(--wp--preset--color--border);
}

/* --- Featured Image --- */
.wp-block-post-featured-image {
	margin-bottom: var(--wp--preset--spacing--50);
	border-radius: var(--wp--custom--radius--md);
	overflow: hidden;
}

.wp-block-post-featured-image img {
	width: 100%;
	height: auto;
	display: block;
	aspect-ratio: 16/9;
	object-fit: cover;
}

/* --- Blockquote Enhancement --- */
.wp-block-quote {
	position: relative;
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--40) var(--wp--preset--spacing--40) var(--wp--preset--spacing--50);
	background: var(--wp--preset--color--accent-lt);
	border-left: 3px solid var(--wp--preset--color--accent);
	border-radius: 0 var(--wp--custom--radius--md) var(--wp--custom--radius--md) 0;
	margin: var(--wp--preset--spacing--50) 0;
}

.wp-block-quote p {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.5;
	font-style: italic;
}

.wp-block-quote cite {
	display: block;
	margin-top: var(--wp--preset--spacing--20);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-style: normal;
	color: var(--wp--preset--color--ink-muted);
}

/* --- Further Reading Section --- */
.further-reading {
	margin-top: var(--wp--preset--spacing--60);
	padding-top: var(--wp--preset--spacing--40);
	border-top: 2px solid var(--wp--preset--color--accent);
}

.further-reading h3,
.further-reading h2 {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--x-large);
	color: var(--wp--preset--color--ink);
	margin-bottom: var(--wp--preset--spacing--30);
}

.further-reading ul {
	list-style: none;
	padding: 0;
}

.further-reading li {
	padding: var(--wp--preset--spacing--20) 0;
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.further-reading li:last-child {
	border-bottom: none;
}

.further-reading a {
	color: var(--wp--preset--color--accent);
	text-decoration: none;
	font-weight: 450;
	transition: color var(--ku-transition);
}

.further-reading a:hover {
	color: var(--wp--preset--color--accent-btn);
	text-decoration: underline;
}

/* --- Card Pattern --- */
.ku-card {
	background: var(--wp--preset--color--card);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--md);
	padding: var(--wp--preset--spacing--40);
	box-shadow: var(--wp--custom--shadow--sm);
	transition: box-shadow var(--ku-transition), transform var(--ku-transition);
}

.ku-card:hover {
	box-shadow: var(--wp--custom--shadow--lg);
	transform: translateY(-2px);
}

/* --- Post Card (Archive/Index) --- */
.post-card {
	display: grid;
	gap: 0;
	overflow: hidden;
	min-width: 0;
}

.post-card .wp-block-post-featured-image {
	margin-bottom: 0;
	overflow: hidden;
}

.post-card .wp-block-post-featured-image img {
	width: 100%;
	height: auto;
	aspect-ratio: 16/9;
	object-fit: cover;
	display: block;
}

.post-card .wp-block-post-title {
	font-size: clamp(1rem, 2vw, 1.25rem) !important;
	line-height: 1.25 !important;
	margin-bottom: 0;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.post-card .wp-block-post-title a {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

.post-card .wp-block-post-title a:hover {
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.post-card .wp-block-post-featured-image img {
	transition: opacity var(--ku-transition);
}

.post-card .wp-block-post-featured-image a:hover img {
	opacity: 0.88;
}

.post-card .wp-block-post-excerpt {
	color: var(--wp--preset--color--ink-muted);
	font-size: 0.875rem !important;
	line-height: 1.5 !important;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.post-card .wp-block-post-terms {
	font-size: 0.7rem !important;
}

.post-card .wp-block-post-terms a {
	border-left: 2px solid var(--wp--preset--color--accent);
	padding-left: 0.4em;
}

.post-card .wp-block-post-date {
	font-size: 0.75rem !important;
}

/* Fix post-template grid */
.wp-block-post-template.is-layout-grid {
	gap: 1.5rem !important;
}

.wp-block-post-template.is-layout-grid > li {
	min-width: 0;
}

/* --- Donate Banner Pattern --- */
.donate-banner {
	background: var(--wp--preset--color--dark);
	color: var(--wp--preset--color--card);
	padding: var(--wp--preset--spacing--60) var(--wp--preset--spacing--40);
	text-align: center;
	border-radius: var(--wp--custom--radius--lg);
	margin: var(--wp--preset--spacing--60) 0;
}

.donate-banner h2 {
	font-family: var(--wp--preset--font-family--display);
	color: var(--wp--preset--color--card);
	margin-bottom: var(--wp--preset--spacing--20);
}

.donate-banner p {
	color: rgba(255, 255, 255, 0.75);
	max-width: 560px;
	margin: 0 auto var(--wp--preset--spacing--40);
}

.donate-banner .wp-block-button__link {
	background: var(--wp--preset--color--card);
	color: var(--wp--preset--color--ink);
	font-weight: 500;
}

.donate-banner .wp-block-button__link:hover {
	background: var(--wp--preset--color--accent-lt);
	color: var(--wp--preset--color--accent-btn);
}

/* --- White Paper Download Pattern --- */
.white-paper-card {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: var(--wp--preset--spacing--40);
	align-items: center;
	background: var(--wp--preset--color--accent-lt);
	padding: var(--wp--preset--spacing--40);
	border-radius: var(--wp--custom--radius--md);
	border: 1px solid var(--wp--preset--color--border);
}

.white-paper-card .icon {
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--card);
	border-radius: var(--wp--custom--radius--sm);
	font-size: 1.5rem;
}

/* --- PWP Exercise Card Pattern --- */
.pwp-exercise-card {
	background: var(--wp--preset--color--card);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--md);
	padding: var(--wp--preset--spacing--40);
	position: relative;
	overflow: hidden;
}

.pwp-exercise-card::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 4px;
	height: 100%;
	background: var(--wp--preset--color--accent);
}

.pwp-exercise-card .exercise-number {
	display: inline-block;
	background: var(--wp--preset--color--accent-lt);
	color: var(--wp--preset--color--accent-btn);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	padding: 0.25rem 0.75rem;
	border-radius: var(--wp--custom--radius--pill);
	margin-bottom: var(--wp--preset--spacing--20);
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--letter-spacing--eyebrow);
}

.pwp-exercise-card .exercise-domain {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--ink-muted);
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--letter-spacing--wide);
}

/* --- Footer --- */
.site-footer {
	background: var(--wp--preset--color--dark);
	color: var(--wp--preset--color--ink-muted);
	padding: var(--wp--preset--spacing--60);
}

.site-footer a {
	color: var(--wp--preset--color--card);
	text-decoration: none;
	transition: color var(--ku-transition);
}

.site-footer a:hover {
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.site-footer .footer-body {
	color: var(--wp--preset--color--border);
}

.site-footer .footer-links {
	list-style: none;
	padding: 0;
	margin: 0;
}

.site-footer .footer-links li {
	padding: 0.2rem 0;
}

.site-footer .footer-links a {
	color: var(--wp--preset--color--border);
}

.site-footer .footer-links a:hover {
	color: var(--wp--preset--color--card);
}

.site-footer .copyright {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--ink-muted);
	margin-top: var(--wp--preset--spacing--40);
	padding-top: var(--wp--preset--spacing--40);
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Post Archive Grid --- */
.post-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: var(--wp--preset--spacing--40);
}

/* --- 404 Page --- */
.error-404 {
	text-align: center;
	padding: var(--wp--preset--spacing--80) var(--wp--preset--spacing--40);
}

.error-404 h1 {
	font-size: var(--wp--preset--font-size--gigantic);
	color: var(--wp--preset--color--accent);
}

/* --- Pagination --- */
.wp-block-query-pagination {
	margin-top: var(--wp--preset--spacing--60);
	gap: var(--wp--preset--spacing--20);
}

.wp-block-query-pagination a {
	min-width: var(--wp--custom--touch-target);
	min-height: var(--wp--custom--touch-target);
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

/* --- Reading Time Badge --- */
.reading-time {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	font-variant-numeric: tabular-nums;
}

.reading-time::before {
	content: '';
	display: inline-block;
	width: 1em;
	height: 1em;
	background: currentColor;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 6v6l4 2'/%3E%3C/svg%3E") center / contain no-repeat;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 6v6l4 2'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* --- Responsive --- */
@media (max-width: 960px) {
	.wp-block-post-template.is-layout-grid {
		grid-template-columns: repeat(2, 1fr) !important;
	}

	.white-paper-card {
		grid-template-columns: 1fr;
		text-align: center;
	}
}

@media (max-width: 640px) {
	.wp-block-post-template.is-layout-grid {
		grid-template-columns: 1fr !important;
	}

	.post-card .wp-block-post-title {
		font-size: 1.1rem !important;
	}

	.donate-banner {
		padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--30);
	}

	.site-header {
		min-height: 48px;
	}
}

/* --- Print Styles --- */
@media print {
	body {
		background: white;
		color: black;
		font-size: 12pt;
		line-height: 1.5;
	}

	.site-header,
	.site-footer,
	.donate-banner,
	.wp-block-navigation,
	.skip-to-content {
		display: none;
	}

	a[href]::after {
		content: ' (' attr(href) ')';
		font-size: 0.8em;
		color: #666;
	}

	.wp-block-post-featured-image img {
		max-height: 300px;
		object-fit: contain;
	}
}
