/* =========================================================
   Crest — global styles
   1. Design tokens (Figma variables)
   2. Base / reset
   3. Typography utilities
   4. Buttons & tags
   5. Layout utilities
   6. Section backgrounds & light/dark theming
   7. Header
   8. Footer
   9. Archive / misc
   ========================================================= */

/* ---------------------------------------------------------
   1. Design tokens — mirrors Figma variable collection
   --------------------------------------------------------- */
:root {
	/* Colour */
	--c-blue-300: #2270e0;
	--c-blue-100: #7faced;
	--c-blue-75: #a4c4f2;
	--c-grey-300: #f6f6f6;
	--c-grey-200: #f8f8f8;
	--c-border: #e6e6e6;
	--c-grey-text: #919191;
	--c-black: #000000;
	--c-white: #ffffff;

	/* Semantic aliases — these are what blocks reference for text, rules and
	   accent colour. `.crest-theme--dark` (section 6) remaps them in one place
	   so a section can sit on a dark background without every block
	   redeclaring its own colours. */
	--c-fg: var(--c-black);
	--c-fg-muted: var(--c-grey-text);
	--c-rule: var(--c-border);
	--c-accent: var(--c-blue-300);

	/* Component padding scale */
	--sp-3xs: 4px;
	--sp-2xs: 8px;
	--sp-xs: 12px;
	--sp-s: 16px;
	--sp-m: 20px;
	--sp-l: 32px;
	--sp-xl: 48px;
	--sp-2xl: 64px;
	--sp-3xl: 96px;
	--sp-4xl: 128px;

	/* Section rhythm */
	--section-y: clamp(64px, 6.7vw, 128px);
	--section-y-sm: clamp(40px, 3.3vw, 64px);

	/* Gutter system: fluid 10vw gutter (192px at the 1920 design width),
	   but never let content exceed --content-max. The percentage resolves
	   against the padded container, so backgrounds stay full-bleed while
	   content is centred in a 1536px column on ultra-wide screens. */
	--content-max: 1536px;
	--gutter-base: clamp(20px, 10vw, 192px);
	--gutter: max(var(--gutter-base), calc((100% - var(--content-max)) / 2));

	/* Radius */
	--radius-s: 4px;
	--radius-m: 8px;
	--radius-l: 12px;
	--radius-card: 30px;

	/* Type — family */
	--font-base: "Restart Hard", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

	/* Type — scale (desktop values from Figma, fluid below 1920) */
	--fs-display: clamp(2.75rem, 4.17vw, 5rem);        /* 80/85 */
	--lh-display: 1.0625;
	--fs-h1: clamp(2.5rem, 3.39vw, 4.0625rem);          /* 65/80 */
	--lh-h1: 1.23;
	--fs-h2: clamp(2rem, 2.6vw, 3.125rem);              /* 50/55 */
	--lh-h2: 1.1;
	--fs-h3: clamp(1.75rem, 2.08vw, 2.5rem);            /* 40/45 */
	--lh-h3: 1.125;
	--fs-h4: 1.375rem;                                  /* 22/30 ls 2% */
	--fs-h5: 1.25rem;                                   /* 20/24 */
	--fs-card-title: 1.625rem;                          /* 26/30 */

	/* Misc */
	--header-h: 99px;
}

/* ---------------------------------------------------------
   2. Base / reset
   --------------------------------------------------------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

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

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

body {
	margin: 0;
	font-family: var(--font-base);
	font-size: 1rem;
	font-weight: 300;
	line-height: 1.375;
	color: var(--c-black);
	background: var(--c-white);
	-webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5, h6, p, ul, ol, figure {
	margin: 0;
}

a {
	color: inherit;
	text-decoration: none;
}

button {
	font: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	color: inherit;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

.skip-link:focus {
	position: fixed !important;
	top: 8px;
	left: 8px;
	z-index: 1000;
	width: auto;
	height: auto;
	clip: auto;
	padding: 12px 20px;
	background: var(--c-blue-300);
	color: var(--c-white);
	border-radius: var(--radius-m);
}

/* ---------------------------------------------------------
   3. Typography utilities
   --------------------------------------------------------- */
.t-display {
	font-size: var(--fs-display);
	line-height: var(--lh-display);
	font-weight: 300;
}

.t-h1 {
	font-size: var(--fs-h1);
	line-height: var(--lh-h1);
	font-weight: 300;
}

.t-h2 {
	font-size: var(--fs-h2);
	line-height: var(--lh-h2);
	font-weight: 300;
}

.t-h3 {
	font-size: var(--fs-h3);
	line-height: var(--lh-h3);
	font-weight: 300;
}

.t-h5 {
	font-size: var(--fs-h5);
	line-height: 1.2;
	font-weight: 400;
}

/* Section intro / lead — Figma "Desktop/H4" 22/30, +2% tracking */
.t-lead {
	font-size: var(--fs-h4);
	line-height: 1.364;
	font-weight: 300;
	letter-spacing: 0.02em;
}

/* Body Copy/Lg Light — 16/22, +2% tracking */
.t-body-lg {
	font-size: 1rem;
	line-height: 1.375;
	font-weight: 300;
	letter-spacing: 0.02em;
}

/* Body Copy/Md Light — 15/22 */
.t-body-md {
	font-size: 0.9375rem;
	line-height: 1.467;
	font-weight: 300;
}

/* Body Copy/Sm Light — 14/22, +2% tracking */
.t-body-sm {
	font-size: 0.875rem;
	line-height: 1.571;
	font-weight: 300;
	letter-spacing: 0.02em;
}

/* ---------------------------------------------------------
   4. Buttons & tags — Figma "Button/Button Default" 12/12 +10%
   --------------------------------------------------------- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	height: 40px;
	padding: 0 var(--sp-m);
	border-radius: var(--radius-m);
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	white-space: nowrap;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn--solid {
	background: var(--c-blue-300);
	color: var(--c-white);
}

.btn--solid:hover,
.btn--solid:focus-visible {
	background: #1a5cbf;
}

.btn--white {
	background: var(--c-white);
	color: var(--c-blue-300);
}

.btn--white:hover,
.btn--white:focus-visible {
	background: var(--c-grey-300);
}

.btn--outline-white {
	border: 1px solid var(--c-white);
	color: var(--c-white);
}

.btn--outline-white:hover,
.btn--outline-white:focus-visible {
	background: var(--c-white);
	color: var(--c-blue-300);
}

.btn--outline-blue {
	border: 1px solid var(--c-blue-300);
	color: var(--c-blue-300);
}

.btn--outline-blue:hover,
.btn--outline-blue:focus-visible {
	background: var(--c-blue-300);
	color: var(--c-white);
}

/* Icon-only square button (carousel arrows) */
.btn--icon {
	width: 40px;
	padding: 0;
}

.btn--icon:disabled {
	opacity: 0.35;
	pointer-events: none;
}

/* Tag pill — Figma "Button/Button Sm" 10px +10% on Grey 300 */
.tag {
	display: inline-flex;
	align-items: center;
	padding: var(--sp-2xs);
	border-radius: var(--radius-s);
	background: var(--c-grey-300);
	color: var(--c-blue-300);
	font-size: 0.625rem;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	white-space: nowrap;
}

/* ---------------------------------------------------------
   5. Layout utilities
   --------------------------------------------------------- */
.container {
	padding-inline: var(--gutter);
}

.section {
	padding-block: var(--section-y);
}

/* ---------------------------------------------------------
   6. Section backgrounds & light/dark theming

   Every Crest block can override its section background from the editor
   (helpers.php → crest_section_bg). With no override chosen, no class is
   printed at all and the block's own stylesheet is untouched.

   The selectors are doubled on purpose: block stylesheets are enqueued at
   render time, i.e. after main.css, so a plain `.crest-bg--grey-300` would
   lose the source-order tie against `.crest-sectors { background: … }`.
   Doubling wins on specificity instead of order. The `background` shorthand
   (not background-color) is what clears the gradient sections.
   --------------------------------------------------------- */
.crest-bg--white.crest-bg--white {
	background: var(--c-white);
}

.crest-bg--grey-300.crest-bg--grey-300 {
	background: var(--c-grey-300);
}

.crest-bg--blue-100.crest-bg--blue-100 {
	background: var(--c-blue-100);
}

.crest-bg--blue-300.crest-bg--blue-300 {
	background: var(--c-blue-300);
}

.crest-bg--black.crest-bg--black {
	background: var(--c-black);
}

/* Stated explicitly so `color: inherit` inside a light section resolves to
   the body colour rather than whatever an ancestor happened to set. */
.crest-theme--light {
	color: var(--c-black);
}

.crest-theme--dark {
	color: var(--c-white);
	--c-fg: var(--c-white);
	--c-fg-muted: rgba(255, 255, 255, 0.65);
	--c-rule: rgba(255, 255, 255, 0.24);
	--c-accent: var(--c-white);
}

/* Blue buttons vanish on a blue or black section — flip them to white. */
.crest-theme--dark .btn--solid {
	background: var(--c-white);
	color: var(--c-blue-300);
}

.crest-theme--dark .btn--solid:hover,
.crest-theme--dark .btn--solid:focus-visible {
	background: var(--c-grey-300);
}

.crest-theme--dark .btn--outline-blue {
	border-color: var(--c-white);
	color: var(--c-white);
}

.crest-theme--dark .btn--outline-blue:hover,
.crest-theme--dark .btn--outline-blue:focus-visible {
	background: var(--c-white);
	color: var(--c-blue-300);
}

/* Project cards keep their white body panel on a dark section, so their copy
   has to opt back out of the inherited white text. */
.crest-theme--dark .project-card__body {
	color: var(--c-black);
}

/* ---------------------------------------------------------
   7. Header
   --------------------------------------------------------- */
.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: var(--c-white);
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0); /* transparent at rest, animates in when stuck */
	transition: box-shadow 0.25s ease;
}

.site-header.is-stuck {
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
}

.site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-l);
	padding: var(--sp-m) var(--gutter);
	min-height: var(--header-h);
}

.site-logo {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-shrink: 0;
}

.site-logo__mark {
	width: 50px;
	height: 59px;
}

.site-logo__wordmark {
	width: 94px;
	height: 30px;
}

.site-logo__tag {
	max-width: 94px;
	color: var(--c-blue-300);
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	position: relative;
	top: 4px;
}

.site-nav {
	display: flex;
	align-items: center;
	gap: var(--sp-2xs);
}

.site-nav__menu {
	display: flex;
	align-items: center;
	gap: var(--sp-2xs);
	list-style: none;
	margin: 0;
	padding: 0;
}

.site-nav__menu li {
	position: relative;
}

.site-nav__menu a {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: 40px;
	padding: 0 var(--sp-m);
	border-radius: var(--radius-m);
	background: var(--c-white);
	color: var(--c-blue-300);
	font-size: 0.75rem;
	font-weight: 500;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	transition: background-color 0.2s ease;
}

.site-nav__menu a:hover,
.site-nav__menu a:focus-visible,
.site-nav__menu .current-menu-item > a {
	background: var(--c-grey-300);
}

/* Caret for items with a dropdown */
.site-nav__menu .menu-item-has-children > a::after {
	content: "";
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
}

.site-nav__menu .sub-menu {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	z-index: 110;
	min-width: 240px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	list-style: none;
	margin: 0;
	padding: var(--sp-2xs);
	background: var(--c-white);
	border-radius: var(--radius-m);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
	/* Hidden via visibility (not display) so hiding can be delayed — the mouse
	   gets a grace period to travel from the trigger into the panel. */
	visibility: hidden;
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity 0.15s ease 0.25s, transform 0.15s ease 0.25s,
		visibility 0s linear 0.4s;
}

/* Transparent bridge across the 4px gap (plus horizontal slack for a diagonal
   approach) so the pointer never crosses dead space and drops the hover. */
.site-nav__menu .sub-menu::before {
	content: "";
	position: absolute;
	bottom: 100%;
	left: -12px;
	right: -12px;
	height: 12px;
}

.site-nav__menu li:hover > .sub-menu,
.site-nav__menu li:focus-within > .sub-menu {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
	.site-nav__menu .sub-menu {
		transform: none;
		transition: opacity 0s linear 0.25s, visibility 0s linear 0.25s;
	}
}

.site-nav__menu .sub-menu a {
	width: 100%;
	height: auto;
	padding: 12px var(--sp-s);
	white-space: nowrap;
}

.nav-toggle {
	display: none;
	flex-direction: column;
	gap: 6px;
	padding: 10px;
}

.nav-toggle__bar {
	width: 24px;
	height: 2px;
	background: var(--c-blue-300);
	transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ---------------------------------------------------------
   8. Footer
   --------------------------------------------------------- */
.site-footer {
	background: var(--c-blue-300);
	color: var(--c-white);
}

.site-footer__inner {
	display: flex;
	flex-direction: column;
	gap: var(--sp-2xl);
	padding: var(--sp-4xl) var(--gutter);
}

.site-footer__top {
	display: flex;
	align-items: flex-start;
	gap: var(--sp-m);
}

.site-footer__brand {
	display: flex;
	align-items: center;
	gap: var(--sp-m);
	flex: 1;
}

.site-footer__logo {
	width: 120px;
	height: 141px;
	flex-shrink: 0;
}

.site-footer__tagline {
	font-size: 1.875rem;
	font-weight: 400;
	line-height: 1;
	letter-spacing: 0.02em;
}

.site-footer__contact {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: var(--sp-l);
}

/* Figma "Body Copy/Lg Caption Regular" 22/45 */
.site-footer__label {
	font-size: 1.375rem;
	font-weight: 400;
	line-height: 1;
}

/* Figma "Desktop/H2" 50/55 */
.site-footer__contact-links {
	font-size: var(--fs-h2);
	line-height: var(--lh-h2);
	font-weight: 300;
}

.site-footer__contact-links a:hover,
.site-footer__contact-links a:focus-visible {
	color: var(--c-blue-100);
}

.site-footer__bottom {
	display: flex;
	align-items: flex-start;
	border-top: 1px solid var(--c-white);
	padding-top: var(--sp-2xl);
	gap: var(--sp-l);
}

.site-footer__col--company {
	flex: 1;
}

.site-footer__cols {
	flex: 1;
	display: flex;
	gap: var(--sp-l);
}

.site-footer__cols .site-footer__col {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: var(--sp-l);
}

.site-footer__col--company {
	display: flex;
	flex-direction: column;
	gap: var(--sp-l);
}

/* Figma "Body Copy/Caption Regular" 15/26 */
.site-footer__text,
.site-footer__menu {
	font-size: 0.9375rem;
	font-weight: 400;
	line-height: 1.733;
}

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

.site-footer__menu a:hover,
.site-footer__menu a:focus-visible {
	color: var(--c-blue-100);
}

/* ---------------------------------------------------------
   9. Archive / misc
   --------------------------------------------------------- */
.project-archive__header {
	margin-bottom: var(--sp-2xl);
}

.project-archive__grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--sp-m);
}

.page-title {
	padding-top: var(--section-y-sm);
}

.error-404 {
	min-height: 60vh;
}

.error-404__code {
	margin-bottom: var(--sp-m);
	color: var(--c-accent);
}

.error-404__text {
	max-width: 40ch;
	margin-top: var(--sp-l);
	color: var(--c-fg-muted);
}

.error-404__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sp-s);
	margin-top: var(--sp-2xl);
}

/* Project card — shared by carousel block + archive grid */
.project-card {
	display: flex;
	flex-direction: column;
}

.project-card__media {
	display: block;
	flex-shrink: 0;
	height: 360px;
	border-top-left-radius: var(--radius-card);
	overflow: hidden;
}

.project-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

.project-card:hover .project-card__img {
	transform: scale(1.04);
}

/* Grows to fill the card, so cards stretched by their row (grid) or
   track (carousel) stay equal height when titles wrap differently. */
.project-card__body {
	flex-grow: 1;
	display: flex;
	flex-direction: column;
	gap: var(--sp-m);
	padding: var(--sp-l);
	background: var(--c-white);
	border-bottom-right-radius: var(--radius-card);
}

/* Figma "Body Copy/Md Regular" 22/28 */
.project-card__title {
	font-size: 1.375rem;
	font-weight: 400;
	line-height: 1.273;
}

.project-card__title a:hover,
.project-card__title a:focus-visible {
	color: var(--c-blue-300);
}

/* Figma "Body Copy/Sm Light" 14/22 +2% */
.project-card__summary {
	font-size: 0.875rem;
	font-weight: 300;
	line-height: 1.571;
	letter-spacing: 0.02em;
}

.project-card__tags {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sp-3xs);
	list-style: none;
	margin: auto 0 0; /* pin to the card foot so tags line up across a row */
	padding: 0;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 1100px) {
	:root {
		--gutter-base: clamp(20px, 5vw, 64px);
	}
}

@media (max-width: 900px) {
	:root {
		--header-h: 76px;
	}

	.site-logo__mark {
		width: 38px;
		height: 45px;
	}

	.site-logo__wordmark {
		width: 76px;
		height: 24px;
	}

	.site-logo__tag {
		display: none;
	}

	.nav-toggle {
		display: flex;
	}

	.site-nav {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		display: none;
		flex-direction: column;
		align-items: stretch;
		gap: var(--sp-2xs);
		padding: var(--sp-m) var(--gutter) var(--sp-l);
		background: var(--c-white);
		box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08);
	}

	.site-nav.is-open {
		display: flex;
	}

	/* The screen-reader label is the button's first child, so the bars are
	   the last two children — :first-child would miss the top bar. */
	.is-nav-open .nav-toggle__bar:nth-last-child(2) {
		transform: translateY(4px) rotate(45deg);
	}

	.is-nav-open .nav-toggle__bar:last-child {
		transform: translateY(-4px) rotate(-45deg);
	}

	.site-nav__menu {
		flex-direction: column;
		align-items: stretch;
	}

	.site-nav__menu a {
		height: 48px;
	}

	.site-nav__menu .sub-menu {
		position: static;
		display: flex;
		visibility: visible;
		opacity: 1;
		transform: none;
		transition: none;
		box-shadow: none;
		padding: 0 0 0 var(--sp-s);
	}

	.site-nav__menu .sub-menu::before {
		display: none;
	}

	.site-nav > .btn {
		justify-content: center;
	}

	.site-footer__top,
	.site-footer__bottom {
		flex-direction: column;
		gap: var(--sp-2xl);
	}

	.site-footer__logo {
		width: 80px;
		height: 94px;
	}

	.project-archive__grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 600px) {
	.site-footer__cols {
		flex-direction: column;
	}

	.project-archive__grid {
		grid-template-columns: 1fr;
	}

	.project-card__media {
		height: 280px;
	}
}
