/*
 * CADchat globals
 *
 * Base typography, body styles, and accessibility utilities. No layout primitives
 * for specific patterns live here — those go in patterns.css.
 *
 * Order of cascade rules:
 *   1. tokens.css declares the design tokens
 *   2. globals.css (this file) applies them to base elements
 *   3. nav.css, footer.css, patterns.css, compat.css apply per-component rules
 */

/* === Body & base typography === */

html {
	-webkit-text-size-adjust: 100%;
	-ms-text-size-adjust: 100%;
}

body {
	font-family: var(--cc-font-body);
	color: var(--cc-color-text-primary);
	background: var(--cc-color-bg-page);
	line-height: var(--cc-lh-normal);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	margin: 0;
}

/* Headings inherit color from heading token, not body. */
h1, h2, h3, h4, h5, h6 {
	color: var(--cc-color-text-heading);
	font-family: var(--cc-font-body);
}

/*
 * Heading styles are SCOPED to .cc-section (our pattern wrapper) so they
 * don't trample existing GenerateBlocks/Elementor content authored for the
 * previous theme. New patterns get the type system; old content keeps
 * whatever the parent theme + the page's inline styles set.
 *
 * Plain <p> styling is global since the body type scale is universally safe.
 */

.cc-section h1, .cc-section .has-heading-h1 {
	font-size: var(--cc-type-h1);
	font-weight: var(--cc-fw-black);
	line-height: var(--cc-lh-tight);
	letter-spacing: var(--cc-ls-h1);
}

.cc-section h2, .cc-section .has-heading-h2 {
	font-size: var(--cc-type-h2);
	font-weight: var(--cc-fw-black);
	line-height: 1.10;
	letter-spacing: var(--cc-ls-h2);
}

.cc-section h3, .cc-section .has-heading-h3 {
	font-size: var(--cc-type-h3);
	font-weight: var(--cc-fw-bold);
	line-height: 1.10;
}

.cc-section h4, .cc-section .has-heading-h4 {
	font-size: var(--cc-type-h4);
	font-weight: var(--cc-fw-semibold);
}

.cc-section h5, .cc-section .has-heading-h5 {
	font-size: var(--cc-type-h5);
	font-weight: var(--cc-fw-semibold);
}

.cc-section p {
	font-size: var(--cc-type-body);
	line-height: var(--cc-lh-normal);
	margin: 0 0 var(--cc-space-4);
}

a {
	color: var(--cc-color-brand-primary);
	text-decoration: none;
	transition: opacity var(--cc-duration-fast) var(--cc-easing-standard);
}

a:hover {
	opacity: 0.75;
}

a:focus-visible {
	outline: 2px solid var(--cc-color-brand-primary);
	outline-offset: 2px;
	border-radius: var(--cc-radius-sm);
}

/* === Eyebrow utility (small uppercase label above a heading) === */
.cc-eyebrow {
	display: inline-block;
	font-family: var(--cc-font-mono);
	font-size: var(--cc-type-eyebrow);
	font-weight: var(--cc-fw-bold);
	letter-spacing: var(--cc-ls-eyebrow);
	text-transform: uppercase;
	color: var(--cc-color-brand-primary);
	margin: 0 0 var(--cc-space-4);
}

/* === Layout primitives === */

.cc-container {
	width: 100%;
	max-width: var(--cc-container-max);
	margin-inline: auto;
	padding-inline: var(--cc-section-pad-x-mobile);
}

@media (min-width: 768px) {
	.cc-container {
		padding-inline: var(--cc-section-pad-x-desktop);
	}
}

.cc-container--narrow { max-width: var(--cc-container-narrow); }
.cc-container--prose  { max-width: var(--cc-container-prose); }

/* Section block — vertical rhythm + optional background variants */
.cc-section {
	padding-block: var(--cc-section-pad-y-mobile);
}

@media (min-width: 768px) {
	.cc-section {
		padding-block: var(--cc-section-pad-y-desktop);
	}
}

.cc-section--alt   { background: var(--cc-color-bg-section-alt); }
.cc-section--alt2  { background: var(--cc-color-bg-section-alt2); }
.cc-section--tint  { background: var(--cc-color-brand-primary-tint); }
.cc-section--fade  { background: var(--cc-color-brand-primary-fade); }
.cc-section--brand {
	background: linear-gradient(140deg, var(--cc-color-brand-primary) 0%, var(--cc-color-brand-primary-deep) 100%);
	color: var(--cc-color-text-on-dark);
}
.cc-section--brand h1,
.cc-section--brand h2,
.cc-section--brand h3,
.cc-section--brand p {
	color: inherit;
}

/* === Accessibility === */

/* Visually hidden, screen-reader accessible. */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Skip to main content (a11y). Visible only when focused. */
.skip-link {
	position: absolute;
	top: -100px;
	left: 0;
	z-index: 9999;
	padding: var(--cc-space-2) var(--cc-space-4);
	background: var(--cc-color-text-heading);
	color: var(--cc-color-text-on-dark);
	text-decoration: none;
	font-weight: var(--cc-fw-semibold);
}

.skip-link:focus {
	top: 0;
}

/* === Reveal-on-scroll animation === */

/* Initial state — overridden by reveal.js when JS is available. */
.reveal-on-scroll {
	opacity: 0;
	transform: translateY(8px);
	transition: opacity var(--cc-duration-slow) var(--cc-easing-standard),
		transform var(--cc-duration-slow) var(--cc-easing-standard);
}

.reveal-on-scroll.is-revealed {
	opacity: 1;
	transform: translateY(0);
}

/* No-JS fallback — never trap content invisible. */
.no-js .reveal-on-scroll {
	opacity: 1;
	transform: none;
}

/* === Image defaults === */

img {
	max-width: 100%;
	height: auto;
	display: block;
}

/* === Selection === */
::selection {
	background: var(--cc-color-brand-primary-tint);
	color: var(--cc-color-text-heading);
}
