/* =========================================================
   Brackenhill Joinery
   Warm organic editorial art direction.
   References in spirit: the restraint of Aesop, the
   editorial calm of Kinfolk, the material honesty of
   a fine furniture maker's portfolio.
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
	/* Brand colour system */
	--walnut: #3E2C20;   /* primary: headers, footer, text on cream */
	--oak: #A47551;      /* secondary: accents, hovers, dividers */
	--sage: #6B7C5E;     /* accent: buttons, links, sparing highlights */
	--cream: #F5EFE6;    /* dominant background */
	--charcoal: #2B2620; /* body text */

	/* Tints derived from brand */
	--cream-deep: #ECE3D5;
	--walnut-90: rgba(62, 44, 32, 0.9);
	--walnut-12: rgba(62, 44, 32, 0.12);
	--oak-20: rgba(164, 117, 81, 0.2);
	--sage-dark: #58684c;

	/* Type */
	--font-display: "Cormorant Garamond", Georgia, serif;
	--font-body: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

	/* Spacing scale (4 / 8 based) */
	--s-1: 0.25rem;
	--s-2: 0.5rem;
	--s-3: 0.75rem;
	--s-4: 1rem;
	--s-5: 1.5rem;
	--s-6: 2rem;
	--s-7: 3rem;
	--s-8: 4rem;
	--s-9: 6rem;
	--s-10: 8rem;

	--shell: 1240px;
	--radius: 3px;
	--ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

/* Smooth-scroll fallback when Lenis is not running */
html:not(.lenis) { scroll-behavior: smooth; }

body {
	font-family: var(--font-body);
	font-size: 1.0625rem;
	line-height: 1.7;
	color: var(--charcoal);
	background-color: var(--cream);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------- Layout helpers ---------- */
.shell {
	width: 100%;
	max-width: var(--shell);
	margin-inline: auto;
	padding-inline: var(--s-5);
}
.section { padding-block: clamp(4rem, 9vw, 8rem); }

.eyebrow {
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.25em;
	text-transform: uppercase;
	color: var(--oak);
	margin-bottom: var(--s-4);
}

.section-title {
	font-family: var(--font-display);
	font-weight: 600;
	font-size: clamp(2rem, 4vw, 3rem);
	line-height: 1.08;
	letter-spacing: 0.01em;
	color: var(--walnut);
}

.section-head { max-width: 38ch; margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.section-head-center { margin-inline: auto; text-align: center; }
.section-intro { margin-top: var(--s-4); max-width: 52ch; color: var(--walnut-90); }
.lead {
	font-family: var(--font-display);
	font-size: clamp(1.3rem, 2.4vw, 1.7rem);
	line-height: 1.4;
	color: var(--walnut);
	margin-bottom: var(--s-5);
}
.section p + p { margin-top: var(--s-4); }

/* ---------- Skip link ---------- */
.skip-link {
	position: absolute;
	left: var(--s-4);
	top: -3rem;
	z-index: 200;
	background: var(--walnut);
	color: var(--cream);
	padding: var(--s-2) var(--s-4);
	border-radius: var(--radius);
	transition: top 0.2s var(--ease);
}
.skip-link:focus { top: var(--s-4); }

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--s-2);
	padding: 0.9rem 1.6rem;
	font-size: 0.82rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border-radius: var(--radius);
	transition: background-color 0.3s var(--ease), color 0.3s var(--ease),
		border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.btn-primary {
	background: var(--sage);
	color: var(--cream);
	box-shadow: 0 1px 0 var(--sage-dark);
}
.btn-primary:hover { background: var(--sage-dark); transform: translateY(-2px); }
.btn-ghost {
	color: var(--walnut);
	border: 1px solid var(--walnut-12);
}
.btn-ghost:hover { border-color: var(--oak); color: var(--oak); }
.btn-block { width: 100%; }

/* ---------- Header / nav ---------- */
.site-header {
	position: fixed;
	inset: 0 0 auto 0;
	z-index: 100;
	transition: background-color 0.4s var(--ease), box-shadow 0.4s var(--ease),
		backdrop-filter 0.4s var(--ease);
}
.header-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-block: var(--s-5);
	transition: padding-block 0.4s var(--ease);
}
.site-header.is-condensed {
	background: rgba(245, 239, 230, 0.86);
	backdrop-filter: blur(10px);
	box-shadow: 0 1px 0 var(--oak-20);
}
.site-header.is-condensed .header-inner { padding-block: var(--s-3); }

.brand { display: flex; align-items: center; gap: var(--s-3); color: var(--walnut); }
.brand-stamp { color: var(--walnut); transition: transform 0.4s var(--ease); }
.brand:hover .brand-stamp { transform: rotate(-6deg); }
.stamp-letter { font-family: var(--font-display); font-weight: 600; font-size: 34px; fill: currentColor; }
.brand-words { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; }
.brand-sub {
	font-size: 0.6rem; font-weight: 600;
	letter-spacing: 0.28em; text-transform: uppercase;
	color: var(--oak); margin-top: 3px;
}

.nav-menu { display: flex; align-items: center; gap: clamp(1rem, 2.4vw, 2.4rem); }
.nav-menu a {
	font-size: 0.82rem; font-weight: 500;
	letter-spacing: 0.04em; color: var(--walnut);
	position: relative; padding-block: var(--s-1);
}
.nav-menu a:not(.nav-cta)::after {
	content: ""; position: absolute; left: 0; bottom: 0;
	width: 100%; height: 1px; background: var(--oak);
	transform: scaleX(0); transform-origin: right;
	transition: transform 0.3s var(--ease);
}
.nav-menu a:not(.nav-cta):hover::after,
.nav-menu a:not(.nav-cta):focus-visible::after { transform: scaleX(1); transform-origin: left; }
.nav-cta {
	padding: 0.55rem 1.1rem; border: 1px solid var(--oak);
	border-radius: var(--radius);
	transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
.nav-cta:hover { background: var(--oak); color: var(--cream); }

.nav-toggle { display: none; width: 44px; height: 44px; position: relative; z-index: 110; }
.nav-toggle-bar {
	display: block; width: 24px; height: 2px; background: var(--walnut);
	margin: 5px auto; transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:first-child { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:last-child { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
	position: relative;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	justify-content: center;
	overflow: hidden;
	padding-block: clamp(7rem, 14vh, 11rem) var(--s-9);
	background:
		radial-gradient(120% 90% at 80% 0%, var(--cream-deep) 0%, var(--cream) 55%);
}
/* Faint wood grain texture, parallaxed behind the headline */
.hero-grain {
	position: absolute; inset: -10% -5%;
	z-index: 0; opacity: 0.5; will-change: transform;
	background-image:
		repeating-linear-gradient(
			92deg,
			transparent 0px, transparent 6px,
			rgba(164, 117, 81, 0.05) 6px, rgba(164, 117, 81, 0.05) 7px,
			transparent 7px, transparent 14px,
			rgba(62, 44, 32, 0.04) 14px, rgba(62, 44, 32, 0.04) 15px
		);
	-webkit-mask-image: radial-gradient(120% 80% at 70% 30%, #000 30%, transparent 80%);
	        mask-image: radial-gradient(120% 80% at 70% 30%, #000 30%, transparent 80%);
}

/* FIXED: was max-width 18ch, which cropped the headline. */
.hero-inner {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: min(100%, 60rem);
}

.hero-eyebrow { color: var(--oak); max-width: 40ch; }

.hero-heading {
	font-family: var(--font-display);
	font-weight: 500;
	font-size: clamp(2.75rem, 6vw, 5rem);
	line-height: 1.06;
	letter-spacing: 0.005em;
	color: var(--walnut);
	margin-bottom: var(--s-5);
	max-width: 14ch; /* wraps to two lines without cropping words */
}

/* overflow hides the mask during the vertical wipe.
   padding keeps descenders (p, y) from being shaved while it animates. */
.reveal-line {
	display: block;
	overflow: hidden;
	padding-bottom: 0.14em;
	margin-bottom: -0.14em;
}
.reveal-mask {
	display: inline-block;
	white-space: nowrap; /* keep each line on one row, never split mid wipe */
}

.hero-sub {
	max-width: 46ch;
	font-size: clamp(1.05rem, 1.6vw, 1.2rem);
	color: var(--walnut-90);
	margin-bottom: var(--s-6);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s-4); }

.scroll-cue {
	position: absolute; left: 50%; bottom: var(--s-6);
	transform: translateX(-50%);
	display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
	z-index: 1;
}
.scroll-cue-text {
	font-size: 0.62rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--oak);
}
.scroll-cue-line {
	width: 1px; height: 48px; background: var(--oak); position: relative; overflow: hidden;
}
.scroll-cue-line::after {
	content: ""; position: absolute; inset: 0; background: var(--cream);
	animation: cueDrop 2.2s var(--ease) infinite;
}
@keyframes cueDrop {
	0% { transform: translateY(-100%); }
	60%, 100% { transform: translateY(100%); }
}

/* ---------- Heritage ---------- */
.heritage-grid {
	display: grid;
	grid-template-columns: 1.05fr 0.95fr;
	gap: clamp(2.5rem, 6vw, 6rem);
	align-items: center;
}
.heritage-copy { max-width: 56ch; }
.stat-row { display: flex; flex-wrap: wrap; gap: var(--s-7); margin-top: var(--s-7); }
.stat dt {
	font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase;
	color: var(--oak); margin-bottom: var(--s-2);
}
.stat dd {
	font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.2rem);
	font-weight: 600; color: var(--walnut); line-height: 1;
}
.heritage-figure figcaption {
	margin-top: var(--s-3); font-size: 0.8rem; color: var(--oak);
	letter-spacing: 0.02em;
}

/* ---------- Media slots (self labelling) ---------- */
.media {
	position: relative;
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--cream-deep);
	box-shadow: 0 18px 50px -28px rgba(62, 44, 32, 0.5);
}
.media::after { /* aspect ratio default 4:3 */ content: ""; display: block; padding-top: 75%; }
.media-portrait::after { padding-top: 125%; }

.media-placeholder {
	position: absolute; inset: 0; z-index: 1;
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	gap: var(--s-2); text-align: center; padding: var(--s-5);
	color: var(--oak);
	background:
		linear-gradient(135deg, var(--cream-deep) 0%, #e3d6c2 100%);
}
.media-placeholder::before { /* subtle grain on placeholder */
	content: ""; position: absolute; inset: 0; opacity: 0.5;
	background-image: repeating-linear-gradient(
		90deg, transparent 0 5px, rgba(164,117,81,0.07) 5px 6px);
}
.ph-mark { color: var(--oak); opacity: 0.7; margin-bottom: var(--s-2); }
.ph-path {
	position: relative;
	font-family: var(--font-body); font-size: 0.78rem; font-weight: 500;
	letter-spacing: 0.02em; color: var(--walnut); word-break: break-all;
}
.ph-hint {
	position: relative;
	font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--oak);
}
.media img {
	position: absolute; inset: 0; z-index: 2;
	width: 100%; height: 100%; object-fit: cover;
	transition: transform 0.7s var(--ease), opacity 0.4s var(--ease);
}
.media img.is-missing { opacity: 0; } /* falls back to labelled placeholder */

/* ---------- Grain divider ---------- */
.grain-divider {
	height: 2px; width: 100%;
	background: repeating-linear-gradient(
		90deg, var(--oak-20) 0 22px, transparent 22px 30px,
		var(--oak-20) 30px 40px, transparent 40px 70px);
	opacity: 0.8;
}

/* ---------- Services ---------- */
.service-list {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0;
	border-top: 1px solid var(--oak-20);
}
.service {
	display: flex; gap: var(--s-5);
	padding: clamp(2rem, 3.5vw, 3rem) 0;
	border-bottom: 1px solid var(--oak-20);
	position: relative;
}
.service:nth-child(odd) { padding-right: clamp(1.5rem, 4vw, 4rem); }
.service:nth-child(even) { padding-left: clamp(1.5rem, 4vw, 4rem); border-left: 1px solid var(--oak-20); }
.service-index {
	font-family: var(--font-display); font-size: 1.1rem; color: var(--oak); padding-top: 6px;
}
.service-icon {
	color: var(--sage); margin-bottom: var(--s-4); display: inline-flex;
	transition: transform 0.4s var(--ease);
}
.service:hover .service-icon { transform: translateY(-4px); }
.service h3 {
	font-family: var(--font-display); font-weight: 600;
	font-size: clamp(1.5rem, 2.4vw, 1.9rem); color: var(--walnut); margin-bottom: var(--s-3);
}
.service-body p { max-width: 44ch; color: var(--walnut-90); }

/* ---------- Gallery ---------- */
.gallery {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-auto-rows: 1fr;
	gap: clamp(1rem, 2vw, 1.75rem);
}
.gallery-item { position: relative; }
.gallery-tall { grid-row: span 2; }
.gallery-tall .media::after { padding-top: 131%; }
.gallery-wide { grid-column: span 2; }
.gallery-wide .media::after { padding-top: 64%; }
.gallery-item:hover .media img:not(.is-missing) { transform: scale(1.04); }
.gallery-item figcaption {
	margin-top: var(--s-3);
	font-size: 0.85rem; color: var(--walnut-90); letter-spacing: 0.01em;
}
.gallery-item figcaption span {
	display: block; font-family: var(--font-display); font-size: 1.05rem;
	font-weight: 600; color: var(--walnut);
}

/* ---------- Process ---------- */
.process { background: var(--walnut); color: var(--cream); }
.process .eyebrow { color: var(--oak); }
.process .section-title { color: var(--cream); }
.process-steps {
	display: grid; grid-template-columns: repeat(3, 1fr);
	gap: clamp(1.5rem, 4vw, 3.5rem);
	counter-reset: step;
}
.step { position: relative; padding-top: var(--s-6); border-top: 1px solid rgba(245,239,230,0.18); }
.step-num {
	font-family: var(--font-display); font-size: clamp(2.2rem, 4vw, 3rem);
	color: var(--oak); display: block; line-height: 1; margin-bottom: var(--s-4);
}
.step h3 {
	font-family: var(--font-display); font-weight: 600; font-size: 1.6rem;
	color: var(--cream); margin-bottom: var(--s-3);
}
.step p { color: rgba(245, 239, 230, 0.82); max-width: 36ch; }

/* ---------- Testimonials ---------- */
.quote-grid {
	display: grid; grid-template-columns: repeat(3, 1fr);
	gap: clamp(1.5rem, 3vw, 2.5rem);
}
.quote {
	background: var(--cream-deep);
	border: 1px solid var(--oak-20);
	border-radius: var(--radius);
	padding: clamp(1.75rem, 3vw, 2.5rem);
	position: relative;
}
.quote::before {
	content: "\201C";
	font-family: var(--font-display); font-size: 4rem; line-height: 0.6;
	color: var(--oak); opacity: 0.5; display: block; margin-bottom: var(--s-3);
}
.quote blockquote {
	font-family: var(--font-display); font-size: 1.3rem; line-height: 1.45;
	color: var(--walnut);
}
.quote figcaption { margin-top: var(--s-5); }
.quote-name { display: block; font-weight: 600; color: var(--walnut); font-size: 0.95rem; }
.quote-place { font-size: 0.78rem; letter-spacing: 0.06em; color: var(--oak); }

/* ---------- Contact ---------- */
.contact-grid {
	display: grid; grid-template-columns: 0.9fr 1.1fr;
	gap: clamp(2.5rem, 6vw, 5rem);
	align-items: start;
}
.contact-intro p { max-width: 42ch; color: var(--walnut-90); }
.contact-details { font-style: normal; margin-top: var(--s-7); display: grid; gap: var(--s-5); }
.contact-line { color: var(--charcoal); }
.contact-label {
	display: block; font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase;
	color: var(--oak); margin-bottom: var(--s-2);
}
.contact-line a { border-bottom: 1px solid transparent; transition: border-color 0.3s var(--ease); }
.contact-line a:hover { border-color: var(--oak); }

.enquiry-form {
	background: var(--cream-deep);
	border: 1px solid var(--oak-20);
	border-radius: var(--radius);
	padding: clamp(1.75rem, 3vw, 2.75rem);
	display: grid; gap: var(--s-5);
}
.field { display: grid; gap: var(--s-2); }
.field label {
	font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase;
	color: var(--oak); font-weight: 600;
}
.field input, .field textarea, .field select {
	font: inherit; font-size: 1rem; color: var(--charcoal);
	background: var(--cream);
	border: 1px solid var(--oak-20);
	border-radius: var(--radius);
	padding: 0.85rem 1rem;
	transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
	width: 100%;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field textarea:focus, .field select:focus {
	outline: none; border-color: var(--sage);
	box-shadow: 0 0 0 3px rgba(107, 124, 94, 0.18);
}
.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 2.5rem; }
.select-chevron {
	position: absolute; right: 1rem; top: 50%; width: 9px; height: 9px;
	border-right: 2px solid var(--oak); border-bottom: 2px solid var(--oak);
	transform: translateY(-65%) rotate(45deg); pointer-events: none;
}
/* FIXED: removed stray characters; single valid error colour */
.field-error {
	font-size: 0.78rem; color: #9c3b24; min-height: 1em;
}
.field.has-error input, .field.has-error textarea, .field.has-error select {
	border-color: #9c3b24;
}
.form-status { font-size: 0.9rem; color: var(--sage-dark); min-height: 1.2em; }

/* ---------- Footer ---------- */
.site-footer {
	background: var(--walnut); color: var(--cream);
	padding-block: clamp(3rem, 6vw, 5rem);
}
.footer-inner {
	display: grid; grid-template-columns: 1.4fr 1fr 1fr;
	gap: var(--s-7); align-items: start;
}
.footer-stamp { color: var(--oak); }
.footer-tagline {
	font-family: var(--font-display); font-size: 1.35rem; line-height: 1.4;
	margin-top: var(--s-4); max-width: 26ch; color: var(--cream);
}
.footer-nav { display: grid; gap: var(--s-3); }
.footer-nav a {
	font-size: 0.85rem; color: rgba(245, 239, 230, 0.78);
	width: fit-content; border-bottom: 1px solid transparent;
	transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.footer-nav a:hover { color: var(--cream); border-color: var(--oak); }
.footer-legal { display: grid; gap: var(--s-2); font-size: 0.78rem; color: rgba(245, 239, 230, 0.6); }

/* ---------- Scroll reveal: content visible by default ---------- */
[data-reveal] { opacity: 1; transform: none; }

/* Only when JS confirms motion is allowed do we arm the reveal */
.reveal-ready [data-reveal] {
	opacity: 0;
	transform: translateY(28px);
	transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
	will-change: opacity, transform;
}
.reveal-ready [data-reveal].is-visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
	.heritage-grid { grid-template-columns: 1fr; }
	.heritage-figure { order: -1; max-width: 460px; }
	.contact-grid { grid-template-columns: 1fr; }
	.process-steps { grid-template-columns: 1fr; gap: var(--s-6); }
	.quote-grid { grid-template-columns: 1fr; }
	.footer-inner { grid-template-columns: 1fr 1fr; }
	.footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
	.nav-toggle { display: block; }
	.nav-menu {
		position: fixed; inset: 0 0 0 auto;
		width: min(80vw, 320px);
		flex-direction: column; align-items: flex-start; justify-content: center;
		gap: var(--s-6);
		padding: var(--s-9) var(--s-7);
		background: var(--cream);
		box-shadow: -20px 0 60px -30px rgba(62,44,32,0.6);
		transform: translateX(100%);
		transition: transform 0.45s var(--ease);
	}
	.nav-menu.is-open { transform: translateX(0); }
	.nav-menu a { font-size: 1.05rem; }
	.service-list { grid-template-columns: 1fr; }
	.service:nth-child(even) { padding-left: 0; border-left: none; }
	.service:nth-child(odd) { padding-right: 0; }
	.gallery { grid-template-columns: 1fr 1fr; }
	.gallery-tall { grid-row: span 1; }
	.gallery-wide { grid-column: span 2; }
}

@media (max-width: 480px) {
	.gallery { grid-template-columns: 1fr; }
	.gallery-wide { grid-column: span 1; }
	.brand-name { font-size: 1.35rem; }
	.stat-row { gap: var(--s-6); }
	.footer-inner { grid-template-columns: 1fr; }
}

/* ---------- Focus visibility ---------- */
:focus-visible {
	outline: 2px solid var(--sage);
	outline-offset: 3px;
	border-radius: 2px;
}

/* ---------- Reduced motion: disable all non essential motion ---------- */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
	.reveal-ready [data-reveal] { opacity: 1 !important; transform: none !important; }
	.scroll-cue-line::after { animation: none; }
}