/*
Theme Name: Colorado Bike Law
Theme URI: https://colobikelaw.com/
Description: Child theme of Hello Elementor for Colorado Bike Law. Page layouts are built in Elementor; this theme holds site-wide CSS. Site functionality (legacy URL redirects, the static-site importer) lives in the Colorado Bike Law Core plugin.
Author: Dusty Sun
Author URI: https://www.dustysun.com/
Template: hello-elementor
Version: 0.5.0
Requires PHP: 7.4
Text Domain: colobikelaw
License: GNU General Public License v3 or later.
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/

/*
 * Site-wide CSS goes here. Colors and fonts come from the Elementor kit
 * (.dev/apply-elementor-kit.php, from the Figma "Version D" file); use its
 * custom properties (--e-global-color-*, --e-global-typography-*) rather than
 * hard-coding values.
 */

/*
 * Imported posts (colobikelaw-core .dev/import-static-site.php).
 * .cbl-lead: the subtitle some of the old articles opened with.
 * .cbl-credit: "Written by Brad Tucker, member of Bicycle Colorado..." lines.
 */
.cbl-lead {
	font-family: var(--e-global-typography-secondary-font-family), sans-serif;
	font-size: var(--e-global-typography-secondary-font-size);
	font-weight: var(--e-global-typography-secondary-font-weight);
	line-height: var(--e-global-typography-secondary-line-height);
	color: var(--e-global-color-primary);
}

.cbl-credit {
	margin-top: 2em;
	padding-top: 1em;
	border-top: 1px solid var(--e-global-color-cblline);
	font-size: 0.875em;
}

/*
 * Headings inside post content. The kit's H2-H4 are sized for page sections
 * (67px display caps); the imported posts use H2 as a subheading every few
 * paragraphs, so step them down to article scale while keeping the fonts.
 */
:is(.single-post, .single-cbl_article) :is(.page-content, .elementor-widget-theme-post-content) h2 {
	font-size: clamp(30px, 2.4vw + 12px, 40px);
	margin: 1.6em 0 0.5em;
}

:is(.single-post, .single-cbl_article) :is(.page-content, .elementor-widget-theme-post-content) h3 {
	font-size: clamp(24px, 1.4vw + 12px, 28px);
	margin: 1.4em 0 0.5em;
}

/* The Q&A article's questions are full sentences; caps make them hard to read. */
:is(.single-post, .single-cbl_article) :is(.page-content, .elementor-widget-theme-post-content) h4 {
	font-family: var(--e-global-typography-text-font-family), sans-serif;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.45;
	letter-spacing: 0;
	text-transform: none;
	margin: 1.6em 0 0.5em;
}

:is(.single-post, .single-cbl_article) :is(.page-content, .elementor-widget-theme-post-content) :is(ul, ol) {
	margin-bottom: 1em;
}

/*
 * Statute text (Colorado Law page). Built from the official C.R.S. with the
 * subsection labels as literal text — (1), (a), (I), (A) — so the numbering
 * always matches the statute; nesting level only sets the indent.
 */
.cbl-statute p {
	margin: 0 0 0.65em;
}

.cbl-statute .cbl-s1 { padding-left: 1.5em; }
.cbl-statute .cbl-s2 { padding-left: 3em; }
.cbl-statute .cbl-s3 { padding-left: 4.5em; }
.cbl-statute .cbl-s4 { padding-left: 6em; }

.cbl-statute .cbl-s-label {
	font-weight: 700;
	color: var(--e-global-color-primary);
}

.cbl-statute .cbl-s-omit {
	padding-left: 1.5em;
	letter-spacing: 0.4em;
	color: var(--e-global-color-cblgrey);
}

.cbl-statute .cbl-statute-source {
	margin-top: 1.25em;
	font-size: var(--e-global-typography-cblsmall-font-size);
	color: var(--e-global-color-cblgrey);
}

.cbl-statute .cbl-statute-source a {
	color: var(--e-global-color-secondary);
}

@media (max-width: 767px) {
	.cbl-statute .cbl-s1 { padding-left: 0.75em; }
	.cbl-statute .cbl-s2 { padding-left: 1.5em; }
	.cbl-statute .cbl-s3 { padding-left: 2.25em; }
	.cbl-statute .cbl-s4 { padding-left: 3em; }
}

/* In-page anchors land below the sticky header. */
.cbl-laws [id] {
	scroll-margin-top: 120px;
}

/*
 * .cbl-sticky: sticks while its row scrolls (desktop only). Plain CSS sticky,
 * so ancestors must not set overflow: hidden.
 * .cbl-toc: an "On this page" list. Desktop: sticky, scrolls inside itself if
 * taller than the window. Tablet/phone: collapses behind its .cbl-toc-toggle
 * header (assets/js/cbl-toc.js), items are .cbl-toc-item.
 */
@media (min-width: 1025px) {
	.cbl-sticky {
		position: sticky;
		top: var(--cbl-sticky-top, 110px);
		align-self: flex-start;
	}

	.cbl-toc {
		max-height: calc(100vh - var(--cbl-sticky-top, 110px) - 24px);
		overflow-y: auto;
		overscroll-behavior: contain;
		scrollbar-width: thin;
	}
}

@media (max-width: 1024px) {
	.cbl-toc .cbl-toc-toggle {
		cursor: pointer;
		position: relative;
		padding-right: 32px;
	}

	.cbl-toc .cbl-toc-toggle::after {
		content: "";
		position: absolute;
		right: 4px;
		top: 50%;
		width: 10px;
		height: 10px;
		border-right: 2px solid var(--e-global-color-accent);
		border-bottom: 2px solid var(--e-global-color-accent);
		transform: translateY(-75%) rotate(45deg);
		transition: transform 0.2s ease;
	}

	.cbl-toc.is-open .cbl-toc-toggle::after {
		transform: translateY(-25%) rotate(-135deg);
	}

	.cbl-toc .cbl-toc-toggle:focus-visible {
		outline: 2px solid var(--e-global-color-accent);
		outline-offset: 4px;
	}

	.cbl-toc:not(.is-open) .cbl-toc-item {
		display: none;
	}
}

/*
 * .cbl-duotone: hero photo rendered as a navy monochrome (the photo's
 * luminosity over the band's Midnight background), so every hero — including
 * each blog post's own featured image — matches the site's B&W-and-navy look.
 */
.cbl-duotone {
	background-blend-mode: luminosity;
}

/* Blog post lists (Posts widget with .cbl-post-grid). */
.cbl-post-grid .elementor-post__title a:hover,
.cbl-post-grid .elementor-post__title a:focus-visible {
	color: var(--e-global-color-secondary);
}

.cbl-post-grid .elementor-post__thumbnail__link:focus-visible,
.cbl-post-grid .elementor-post__read-more:focus-visible {
	outline: 2px solid var(--e-global-color-secondary);
	outline-offset: 4px;
}

.cbl-post-grid .elementor-post__meta-data {
	order: -1;
}

.cbl-post-grid .elementor-post__text {
	display: flex;
	flex-direction: column;
}

.cbl-post-lead .elementor-post__text {
	align-self: center;
	padding-left: 8px;
}

.cbl-post-lead .elementor-post__excerpt p {
	font-size: var(--e-global-typography-cblintro-font-size);
	line-height: var(--e-global-typography-cblintro-line-height);
}

@media (max-width: 767px) {
	.cbl-post-lead .elementor-post {
		flex-direction: column;
	}

	.cbl-post-lead .elementor-post__text {
		padding-left: 0;
	}
}

/* Excerpts end on a clean ellipsis instead of mid-sentence. */
.cbl-post-grid .elementor-post__excerpt p {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
}

.cbl-post-lead .elementor-post__excerpt p {
	-webkit-line-clamp: 4;
	line-clamp: 4;
}

@media (max-width: 767px) {
	.cbl-post-lead .elementor-post__thumbnail__link {
		margin-bottom: 22px;
	}
}

/*
 * Full-bleed heroes: the hero section spans the window; its content stays on
 * the kit's 1400px grid. .cbl-crumb lines the breadcrumb up with that grid;
 * .cbl-hero-text does the same for the text column of a split hero (Home)
 * whose photo half bleeds to the window edge.
 */
/* Beats Elementor's ".elementor.elementor .e-con > .elementor-widget { max-width: 100% }". */
.elementor.elementor .e-con > .elementor-widget.cbl-crumb {
	width: 100%;
	max-width: 1400px;
	margin-inline: auto;
}

@media (min-width: 1025px) {
	.cbl-hero-text {
		padding-left: max(30px, calc((100vw - 1400px) / 2 + 30px)) !important;
	}
}

/*
 * Search menu item (Custom Link "#search", CSS class "menu_search"): magnifier icon that opens
 * the search overlay (includes/class-search-overlay.php). The desktop bar shows only the icon
 * (the label stays for screen readers); the mobile dropdown shows icon + "Search". The icon is
 * a mask, so it takes the link's text color, hover included.
 */
.elementor-nav-menu .menu_search > a {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* !important: the Nav Menu widget's hover-pointer styles also use ::before. */
.elementor-nav-menu .menu_search > a::before {
	content: "";
	position: static !important;
	flex: none;
	width: 18px !important;
	height: 18px !important;
	opacity: 1 !important;
	transform: none !important;
	background-color: currentColor !important;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Ccircle cx='10' cy='10' r='6.5'/%3E%3Cpath d='M15 15l6 6'/%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 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Ccircle cx='10' cy='10' r='6.5'/%3E%3Cpath d='M15 15l6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* !important: the widget's own typography setting is more specific. */
.elementor-nav-menu--main .menu_search > a {
	font-size: 0 !important;
	gap: 0;
}

/*
 * Search overlay: a Midnight panel that drops from the top of the screen over a dimmed page.
 * The <dialog> itself has no padding so a click on the backdrop (target = dialog) closes it
 * while clicks inside the panel don't.
 * The label, input and buttons are styled globally by the Elementor kit (.elementor-kit-N label,
 * .elementor-kit-N input:not([type="button"]):not([type="submit"]), button:focus), so the
 * selectors below are deliberately more specific than the kit's.
 */
.cbl-search {
	position: fixed;
	inset: 0 0 auto;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--e-global-color-cblmidnight);
	color: var(--e-global-color-cblwhite);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.cbl-search[open] {
	animation: cbl-search-in 0.25s ease-out;
}

.cbl-search::backdrop {
	background: rgba(20, 25, 61, 0.6);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}

@keyframes cbl-search-in {
	from { transform: translateY(-100%); }
	to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.cbl-search[open] {
		animation: none;
	}
}

.cbl-search__inner {
	position: relative;
	max-width: 860px;
	margin: 0 auto;
	padding: 72px 24px 64px;
}

.cbl-search .cbl-search__label {
	display: block;
	margin-bottom: 20px;
	font-family: var(--e-global-typography-primary-font-family), sans-serif;
	font-size: clamp(36px, 3vw + 20px, 52px);
	font-weight: 600;
	line-height: 1;
	text-transform: uppercase;
	color: var(--e-global-color-cblwhite);
}

.cbl-search__field {
	display: flex;
	gap: 16px;
	align-items: stretch;
}

.cbl-search .cbl-search__form .cbl-search__field input.cbl-search__input {
	flex: 1;
	min-width: 0;
	padding: 12px 0;
	border: 0;
	border-bottom: 1px solid var(--e-global-color-cblwhite40);
	border-radius: 0;
	background: transparent;
	font-family: var(--e-global-typography-text-font-family), sans-serif;
	font-size: 22px;
	line-height: 1.5;
	color: var(--e-global-color-cblwhite);
}

.cbl-search .cbl-search__form .cbl-search__field input.cbl-search__input:focus,
.cbl-search .cbl-search__form .cbl-search__field input.cbl-search__input:focus-visible {
	outline: none;
	box-shadow: none;
	background: transparent;
	/* 2px gold underline is the focus indicator (in place of the site's white focus ring). */
	border-width: 0 0 2px;
	padding-bottom: 11px;
	border-bottom-color: var(--e-global-color-accent);
}

.cbl-search .cbl-search__form .cbl-search__field input.cbl-search__input::placeholder {
	color: var(--e-global-color-cblwhite58);
}

/* Hide the browser's own clear button; it renders dark on navy. */
.cbl-search .cbl-search__form .cbl-search__field input.cbl-search__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.cbl-search .cbl-search__submit {
	padding: 12px 32px;
	border: 0;
	border-radius: 0;
	background: var(--e-global-color-secondary);
	font-family: var(--e-global-typography-accent-font-family), sans-serif;
	font-size: 16px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--e-global-color-cblwhite);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.cbl-search .cbl-search__form .cbl-search__submit:hover,
.cbl-search .cbl-search__form .cbl-search__submit:focus {
	background: var(--e-global-color-cblredhover);
}

.cbl-search .cbl-search__submit:focus-visible,
.cbl-search .cbl-search__close:focus-visible {
	outline: 2px solid var(--e-global-color-accent);
	outline-offset: 3px;
}

.cbl-search .cbl-search__close {
	position: absolute;
	top: 16px;
	right: 16px;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: var(--e-global-color-cblwhite);
	cursor: pointer;
}

.cbl-search .cbl-search__inner .cbl-search__close:hover,
.cbl-search .cbl-search__inner .cbl-search__close:focus {
	background: none;
	color: var(--e-global-color-accent);
}

@media (max-width: 767px) {
	.cbl-search__inner {
		padding: 64px 16px 32px;
	}

	.cbl-search__field {
		flex-direction: column;
	}

	.cbl-search .cbl-search__form .cbl-search__field input.cbl-search__input {
		font-size: 18px;
	}
}
