/*
Theme Name: KACP Theme
Theme URI: https://kacp.willstech.org
Author: William Carson
Author URI: https://willstech.org
Description: A block theme for the Kentucky Association of Chiefs of Police. Built with full site editing, a navy/gold palette, and ready-made templates.
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Version: 1.2.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: kacp-theme
Tags: full-site-editing, block-patterns, custom-colors, custom-logo, custom-menu
*/

/* ------------------------------------------------------------------
 * Sticky shrinking header
 *
 * WordPress wraps template parts in their own element
 * (<header class="wp-block-template-part">). Sticky must be applied to
 * that wrapper - sticking the inner group only lets it travel until the
 * wrapper's bottom edge, i.e. it never pins.
 * ------------------------------------------------------------------ */
.wp-site-blocks > header.wp-block-template-part {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 1000;
}

.site-header {
	--kacp-logo-height: 96px;
	--kacp-header-pad: clamp(1.25rem, 2.5vw, 1.75rem);
	background-color: var(--wp--preset--color--surface);
	border-bottom: 4px solid var(--wp--preset--color--secondary);
	padding-top: var(--kacp-header-pad);
	padding-bottom: var(--kacp-header-pad);
	box-shadow: 0 2px 12px rgba(0, 17, 48, 0.08);
	transition:
		padding-top 0.3s ease,
		padding-bottom 0.3s ease,
		box-shadow 0.3s ease;
}

.site-header .site-logo {
	margin: 0;
	flex-shrink: 0;
}

.site-header .site-logo img {
	display: block;
	height: var(--kacp-logo-height);
	width: auto;
	object-fit: contain;
	transition: height 0.3s ease;
}

.wp-block-group.site-brand a {
	text-decoration: none;
}

/* Static header text colors (readable on white, not link-blue) */
.site-header .wp-block-site-title,
.site-header .wp-block-site-title a {
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.site-header .primary-navigation .wp-block-navigation-item__content {
	color: var(--wp--preset--color--contrast);
}

.site-header .primary-navigation a:hover {
	color: var(--wp--preset--color--primary);
}

/* Shrunk state (toggled by JS once the page is scrolled) */
.is-scrolled .site-header {
	--kacp-logo-height: 52px;
	--kacp-header-pad: 0.5rem;
	box-shadow: 0 6px 20px rgba(0, 17, 48, 0.16);
}

.is-scrolled .site-header .site-tagline {
	max-height: 0;
	opacity: 0;
	margin: 0;
	overflow: hidden;
}

.site-header .site-tagline {
	color: var(--wp--preset--color--muted);
	max-height: 2em;
	opacity: 1;
	overflow: hidden;
	transition: opacity 0.25s ease, max-height 0.25s ease, margin 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
	.site-header,
	.site-header .site-logo img,
	.site-header .site-tagline {
		transition: none;
	}
}

/* ------------------------------------------------------------------
 * Legislative Updates box (matches kacp.org homepage)
 * ------------------------------------------------------------------ */
.leg-updates {
	position: relative;
	background-color: #b1dbf1;
	overflow: hidden;
	padding-top: var(--wp--preset--spacing--70);
	padding-bottom: var(--wp--preset--spacing--70);
}

.leg-updates .leg-photo {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 100%;
	width: auto;
	max-width: none;
	margin: 0;
	pointer-events: none;
	z-index: 0;
}

.leg-updates .leg-photo img {
	display: block;
	height: 100%;
	width: auto;
	max-width: none;
	object-fit: cover;
	object-position: left bottom;
}

/* Two-class selectors out-specify WP's generated flex layout styles,
   which are printed after the theme stylesheet. */
.wp-block-group.leg-inner {
	position: relative;
	z-index: 1;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: flex-start;
	row-gap: var(--wp--preset--spacing--40);
	column-gap: var(--wp--preset--spacing--50);
}

/* Header tab sits on the left (over the capitol photo) and the text
   panel on the right, tops level with each other - kacp.org style.
   Bases mirror kacp.org's widths (calc(40% - 112px) / 46%), which
   guarantees open space between the boxes where the photo shows
   through; only when the band gets truly narrow do they stack. */
.wp-block-group.leg-header-tab,
.wp-block-group.leg-content {
	background-color: #ffffff;
	position: relative;
	z-index: 2;
	box-sizing: border-box;
	max-width: 100%;
}

.wp-block-group.leg-header-tab {
	flex: 0 1 calc(40% - 112px);
	min-width: min(21.875rem, 80vw);
	padding: 12px 16px 12px 27px;
}

.wp-block-group.leg-content {
	flex: 0 1 46%;
	min-width: min(20rem, 80vw);
	padding: 2.5vh 24px 2.5vh 20px;
}

/* Skewed white ribbon on the right edge of the tab.
   The ribbon is 62px wide and the tab must be exactly 62px tall
   (12px + 38px heading + 12px padding) so the 45-degree diagonal
   lands precisely on the bottom-right corner - same as kacp.org. */
.leg-header-tab::after {
	content: "";
	position: absolute;
	left: 100%;
	top: 0;
	width: 62px;
	height: 100%;
	transform-origin: 100% 0;
	transform: skewX(-45deg);
	background-color: #ffffff;
	z-index: -1;
}

.leg-header-tab .wp-block-heading {
	color: var(--wp--preset--color--contrast);
	margin: 0;
	font-size: 2.375rem;
	line-height: 38px;
	white-space: nowrap;
}

/* Center the Latest Update button inside its white panel */
.leg-updates .leg-content .wp-block-buttons {
	justify-content: center;
}

/* Match the kacp.org "Recent Update"-style button */
.leg-updates .wp-block-button {
	margin: 10px 0 0;
}

.leg-updates .wp-element-button,
.leg-updates .wp-block-button__link {
	background-color: #ff7c7c;
	border: 1px solid #ffffff;
	border-radius: 5px;
	color: #ffffff;
	font-weight: 700;
	min-width: 275px;
	text-align: center;
	text-transform: uppercase;
}

.leg-updates .wp-element-button:hover,
.leg-updates .wp-block-button__link:hover {
	background-color: #0d4788;
}

/* Below full-desktop width, drop the asymmetric kacp.org proportions
   and give both boxes an equal, growing share so they stay identical
   widths on one row while the band shrinks. */
@media (max-width: 1199px) {
	.wp-block-group.leg-header-tab,
	.wp-block-group.leg-content {
		flex: 1 1 calc(50% - var(--wp--preset--spacing--50));
		min-width: 0;
	}
	/* No slanted ribbon here - the gap between the boxes is narrower
	   than the 62px ribbon, so they would touch. */
	.leg-header-tab::after {
		display: none;
	}
}

@media (max-width: 781px) {
	.wp-block-group.leg-header-tab,
	.wp-block-group.leg-content {
		flex-basis: 100%;
	}
	.leg-header-tab .wp-block-heading {
		font-size: 1.75rem;
		line-height: 1.2;
		white-space: normal;
	}
	.leg-photo {
		opacity: 0.25;
	}
}

/* Training band - gold variant of the legislative box */
.training-band {
	background-color: var(--wp--preset--color--secondary);
}

/* What We Do cards */
.wp-block-columns.wwd {
	margin-top: var(--wp--preset--spacing--50);
}

.wp-block-column.wwd-card {
	background-color: var(--wp--preset--color--surface);
	border-radius: 8px;
	padding: var(--wp--preset--spacing--50);
	box-sizing: border-box;
}

.wp-block-column.wwd-card .wp-block-heading.wwd-title {
	color: var(--wp--preset--color--accent);
	margin-top: 0;
}

/* Footer navigation: top-level links only - the footer shares the
   primary menu, so collapse its submenus and chevron toggles. */
.site-footer .wp-block-navigation .has-child > .wp-block-navigation__submenu-container {
	display: none !important;
}

.site-footer .wp-block-navigation .wp-block-navigation__submenu-icon {
	display: none;
}

/* Footer logo plate (white, rounded corners) */
.site-footer .wp-block-image.footer-logo {
	margin: 0;
	flex-shrink: 0;
}

.site-footer .wp-block-image.footer-logo img {
	width: 150px;
	height: auto;
}

/* ------------------------------------------------------------------
 * Hero slideshow - a Gallery block crossfades photos behind the
 * cover overlay. Photos can be swapped from the Site Editor (the
 * gallery is a real block), while the CSS layers and animates them.
 * Selectors are structural (done the gallery's own classes) and use
 * !important so core gallery grid/flex styles can never win.
 * ------------------------------------------------------------------ */
.hero-gallery.wp-block-gallery,
.hero-gallery.wp-block-gallery.has-nested-images {
	position: absolute !important;
	inset: 0;
	z-index: 0;
	display: block !important;
	margin: 0 !important;
	flex-wrap: nowrap !important;
	column-gap: 0 !important;
	row-gap: 0 !important;
	overflow: hidden;
}

.hero-gallery.wp-block-gallery .wp-block-image,
.hero-gallery.wp-block-gallery.has-nested-images .wp-block-image:not(#individual-image) {
	position: absolute !important;
	inset: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	flex: none !important;
	flex-basis: auto !important;
	margin: 0 !important;
	opacity: 0;
	animation: kacp-hero-fade 36s infinite;
}

.hero-gallery.wp-block-gallery.has-nested-images .wp-block-image img {
	width: 100% !important;
	height: 100% !important;
	aspect-ratio: auto !important;
	object-fit: cover !important;
	object-position: center !important;
}

.hero-gallery.wp-block-gallery .wp-block-image:nth-child(1) { animation-delay: 0s; }
.hero-gallery.wp-block-gallery .wp-block-image:nth-child(2) { animation-delay: 6s; }
.hero-gallery.wp-block-gallery .wp-block-image:nth-child(3) { animation-delay: 12s; }
.hero-gallery.wp-block-gallery .wp-block-image:nth-child(4) { animation-delay: 18s; }
.hero-gallery.wp-block-gallery .wp-block-image:nth-child(5) { animation-delay: 24s; }
.hero-gallery.wp-block-gallery .wp-block-image:nth-child(6) { animation-delay: 30s; }

@keyframes kacp-hero-fade {
	0%     { opacity: 0; }
	3%     { opacity: 1; }
	16.6%  { opacity: 1; }
	20%    { opacity: 0; }
	100%   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.hero-gallery.wp-block-gallery .wp-block-image {
		animation: none;
		opacity: 0;
	}
	.hero-gallery.wp-block-gallery .wp-block-image:nth-child(1) {
		opacity: 1;
	}
}

/* ------------------------------------------------------------------
 * Small helpers that complement theme.json
 * ------------------------------------------------------------------ */
.kacp-skip-link.screen-reader-text:focus {
	clip-path: none;
	height: auto;
	width: auto;
	left: 6px;
	top: 6px;
	z-index: 100000;
}
