/* Case study pages + homepage overlay. Everything is scoped under
   .cs-page / .cs-article / .cs-overlay so it doesn't leak into main.css. */

:root {
	--cs-bg: #141414;
	--cs-surface: #1c1c1c;
	--cs-line: rgba(255, 255, 255, 0.12);
	--cs-text: rgba(255, 255, 255, 0.82);
	--cs-muted: rgba(255, 255, 255, 0.5);
	--cs-accent: #a51d13;
	--cs-accent-hover: #c9251a;
	/* side padding that stays clear of the notch in landscape */
	--cs-gutter-l: calc(clamp(16px, 4vw, 48px) + env(safe-area-inset-left, 0px));
	--cs-gutter-r: calc(clamp(16px, 4vw, 48px) + env(safe-area-inset-right, 0px));
}

/* ── standalone page ───────────────────────────────────────────── */
.cs-page {
	margin: 0;
	background: var(--cs-bg);
	color: var(--cs-text);
	font-family: 'Source Sans Pro', sans-serif;
	font-weight: 300;
	font-size: 18px;
	line-height: 1.7;
	-webkit-font-smoothing: antialiased;
}
.cs-page *, .cs-page *::before, .cs-page *::after { box-sizing: border-box; }

.cs-topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: calc(14px + env(safe-area-inset-top, 0px)) var(--cs-gutter-r) 14px var(--cs-gutter-l);
	background: rgba(20, 20, 20, 0.88);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--cs-line);
}
.cs-home img { display: block; height: 26px; width: auto; }
.cs-back {
	color: var(--cs-muted);
	text-decoration: none;
	font-size: 0.85em;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}
.cs-back:hover { color: #fff; }

.cs-footer {
	padding: 2em var(--cs-gutter-r) calc(2em + env(safe-area-inset-bottom, 0px)) var(--cs-gutter-l);
	border-top: 1px solid var(--cs-line);
	color: var(--cs-muted);
	font-size: 0.85em;
	text-align: center;
}

/* ── article (shared by page and overlay) ──────────────────────── */
.cs-article {
	color: var(--cs-text);
	font-family: 'Source Sans Pro', sans-serif;
	font-weight: 300;
	font-size: 18px;
	line-height: 1.7;
	text-align: left;
}
.cs-article *, .cs-article *::before, .cs-article *::after { box-sizing: border-box; }
.cs-article h1, .cs-article h2 {
	color: #fff;
	font-weight: 600;
	letter-spacing: 0.01em;
	text-transform: none;
	line-height: 1.2;
	margin: 0;
}
.cs-article p { margin: 0 0 1em; }
.cs-article ul { margin: 0 0 1em; padding-left: 1.2em; }
.cs-article li { margin-bottom: 0.4em; }
.cs-article strong { color: #fff; font-weight: 600; }
.cs-article code {
	font-size: 0.9em;
	background: rgba(255, 255, 255, 0.08);
	padding: 0.1em 0.35em;
	border-radius: 3px;
}

.cs-draft-banner {
	background: #5a4a00;
	color: #ffe680;
	font-size: 0.8em;
	text-align: center;
	padding: 0.5em 1em;
}
.cs-todo {
	background: rgba(255, 214, 0, 0.18);
	color: #ffe680;
	padding: 0 0.2em;
	border-radius: 2px;
}

/* hero */
.cs-hero {
	position: relative;
	min-height: min(70vh, 640px);
	display: flex;
	align-items: flex-end;
	overflow: hidden;
}
.cs-hero-img {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
}
.cs-hero-img::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(20,20,20,0.35) 0%, rgba(20,20,20,0.82) 55%, var(--cs-bg) 100%);
}
.cs-hero-text {
	position: relative;
	width: 100%;
	max-width: 1180px;
	margin: 0 auto;
	padding: 3em var(--cs-gutter-r) 2.5em var(--cs-gutter-l);
}
.cs-eyebrow {
	color: var(--cs-muted);
	text-transform: uppercase;
	letter-spacing: 0.14em;
	font-size: 0.75em;
	font-weight: 600;
	margin-bottom: 0.6em !important;
}
.cs-title { font-size: clamp(2em, 5vw, 3.4em); margin-bottom: 0.4em !important; }
.cs-summary { max-width: 720px; font-size: 1.15em; color: rgba(255,255,255,0.9); }
.cs-client-logo { height: 30px; width: auto; margin-top: 0.6em; opacity: 0.9; }

/* body layout */
.cs-body {
	max-width: 1180px;
	margin: 0 auto;
	padding: 2.5em var(--cs-gutter-r) 4em var(--cs-gutter-l);
	display: grid;
	grid-template-columns: 260px minmax(0, 1fr);
	gap: clamp(2em, 5vw, 4.5em);
}

.cs-facts {
	align-self: start;
	position: sticky;
	top: 80px;
	font-size: 0.88em;
}
.cs-facts dl { margin: 0; }
.cs-facts dt {
	color: var(--cs-muted);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-size: 0.75em;
	font-weight: 600;
	margin-top: 1.3em;
}
.cs-facts dt:first-child { margin-top: 0; }
.cs-facts dd { margin: 0.2em 0 0; color: #fff; }
.cs-stack { list-style: none; padding: 0 !important; margin: 0.3em 0 0 !important; display: flex; flex-wrap: wrap; gap: 0.4em; }
.cs-stack li {
	margin: 0;
	border: 1px solid var(--cs-line);
	border-radius: 999px;
	padding: 0.1em 0.75em;
	font-size: 0.9em;
}

.cs-content { max-width: 760px; }

.cs-metrics {
	list-style: none;
	padding: 0 !important;
	margin: 0 0 3em !important;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	border-top: 1px solid var(--cs-line);
	border-bottom: 1px solid var(--cs-line);
}
.cs-metrics li { margin: 0; padding: 1.2em 1em 1.2em 0; }
.cs-metric-value { display: block; color: #fff; font-size: 2em; font-weight: 600; line-height: 1.1; }
.cs-metric-label { display: block; color: var(--cs-muted); font-size: 0.82em; margin-top: 0.3em; }

.cs-section { margin-bottom: 2.8em; }
.cs-section h2 {
	font-size: 1.5em;
	margin-bottom: 0.7em !important;
	padding-left: 0.7em;
	border-left: 3px solid var(--cs-accent);
}

.cs-quote {
	margin: 0 0 3em;
	padding: 1.5em 1.8em;
	background: var(--cs-surface);
	border-left: 3px solid var(--cs-accent);
}
.cs-quote p { font-size: 1.2em; color: #fff; font-style: italic; }
.cs-quote footer { color: var(--cs-muted); font-size: 0.85em; }

.cs-cta {
	padding: 2em;
	background: var(--cs-surface);
	border: 1px solid var(--cs-line);
}
.cs-cta h2 { font-size: 1.4em; margin-bottom: 0.4em !important; }
.cs-button {
	display: inline-block;
	background: var(--cs-accent);
	color: #fff !important;
	text-decoration: none;
	padding: 0.6em 1.4em;
	border-radius: 3px;
	font-weight: 600;
	font-size: 0.85em;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border: 0;
	transition: background 0.2s;
}
.cs-button:hover { background: var(--cs-accent-hover); }

@media (max-width: 860px) {
	.cs-body { grid-template-columns: 1fr; }
	.cs-facts { position: static; padding-bottom: 1.5em; border-bottom: 1px solid var(--cs-line); }
	.cs-facts dt { margin-top: 1em; }
	.cs-hero { min-height: 52vh; }
	.cs-article, .cs-page { font-size: 17px; }
}

/* ── homepage overlay ──────────────────────────────────────────── */
.cs-overlay {
	position: fixed;
	inset: 0;
	z-index: 10002; /* above the mobile menu button (10001) */
	background: var(--cs-bg);
	overflow-y: auto;
	overscroll-behavior: contain;
	opacity: 0;
	transform: translateY(24px);
	/* stays in the DOM after closing, so it must stop catching scroll and taps */
	visibility: hidden;
	transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0.3s;
}
.cs-overlay.is-open { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.cs-overlay-close {
	position: fixed;
	top: calc(14px + env(safe-area-inset-top, 0px));
	right: calc(clamp(16px, 3vw, 32px) + env(safe-area-inset-right, 0px));
	z-index: 2;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid var(--cs-line);
	background: rgba(20, 20, 20, 0.85);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	box-shadow: none;
}
.cs-overlay-close:hover { background: var(--cs-accent); }
.cs-overlay .cs-facts { top: 24px; }
.cs-overlay .cs-body { padding-bottom: calc(4em + var(--ios-bottom, env(safe-area-inset-bottom, 0px))); }
.cs-overlay .cs-hero--plain .cs-hero-text { padding-top: calc(clamp(3em, 9vw, 6em) + env(safe-area-inset-top, 0px)); }
html.cs-overlay-lock, html.cs-overlay-lock body { overflow: hidden; }

/* iOS: fill the screen behind Safari's bars (--ios-* are set in main.css) */
@supports (-webkit-touch-callout: none) and (height: 100lvh) {
	.cs-overlay { bottom: auto; height: calc(100lvh + var(--ios-extra, 0px) - var(--ios-top, 0px)); }
	/* fixed layers can't paint under the status bar: match the bar colour to the overlay instead */
	html.cs-overlay-lock, html.cs-overlay-lock body { background-color: var(--cs-bg) !important; }
	/* the page would otherwise show through in the bar areas (delay: until the fade-in ends) */
	html.cs-overlay-lock body > section,
	html.cs-overlay-lock body > article { visibility: hidden; transition: visibility 0s linear 0.3s; }
}

/* homepage slide link */
.featured-swiper .slide-text-footer .slide-case-study {
	display: inline-block;
	margin-left: 0.6em;
	color: #fff;
	border: 1px solid rgba(255,255,255,0.4);
	padding: 0.3em 0.85em;
	text-decoration: none;
	font-size: 0.8em;
	letter-spacing: 1px;
	border-radius: 3px;
	transition: border-color 0.2s, background 0.2s;
}
.featured-swiper .slide-text-footer .slide-case-study:hover { border-color: #fff; background: rgba(255,255,255,0.08); }

/* ── insights (articles + index) ───────────────────────────────── */
.post-header,
.post-body,
.post-list {
	max-width: 760px;
	margin-left: auto;
	margin-right: auto;
	padding-left: var(--cs-gutter-l);
	padding-right: var(--cs-gutter-r);
	box-sizing: content-box;
}
.post-header { padding-top: clamp(2.5em, 7vw, 4.5em); padding-bottom: 1.5em; border-bottom: 1px solid var(--cs-line); }
.post-meta { color: var(--cs-muted); font-size: 0.88em; margin: 0 !important; }
.post-body { padding-top: 2em; padding-bottom: 4em; }
.post-body h2 { font-size: 1.55em; margin: 2em 0 0.6em !important; }
.post-body h3 { color: #fff; font-weight: 600; font-size: 1.15em; margin: 1.6em 0 0.4em; text-transform: none; letter-spacing: 0; }
.post-body ol { margin: 0 0 1em; padding-left: 1.4em; }
.post-body a:not(.cs-button) { color: #fff; text-decoration: underline; text-decoration-color: var(--cs-accent); text-underline-offset: 3px; }
.post-body em { font-style: italic; }
.post-lede {
	font-size: 1.15em;
	color: rgba(255, 255, 255, 0.92);
	padding: 1.2em 1.4em;
	background: var(--cs-surface);
	border-left: 3px solid var(--cs-accent);
	margin-bottom: 1.5em !important;
}
.post-checklist li { padding-left: 0.3em; }
.post-body .cs-cta { margin-top: 3em; }

.post-list { list-style: none; padding-top: 1em; padding-bottom: 4em; }
.post-list > li { margin: 0; border-bottom: 1px solid var(--cs-line); }
.post-card { display: block; padding: 1.8em 0; text-decoration: none; color: var(--cs-text); }
.post-card h2 { font-size: 1.45em; margin: 0.15em 0 0.35em !important; transition: color 0.2s; }
.post-card p { margin: 0 0 0.5em; }
.post-card:hover h2 { color: #ff6a5c; }
.post-card-meta { color: var(--cs-muted); font-size: 0.85em; }
/* /insights index and articles: same glow as the homepage Insights section, pinned while scrolling */
.cs-page--insights {
	background: #111;
}
/* a fixed layer, because iOS Safari doesn't honour background-attachment: fixed */
.cs-page--insights::before {
	content: '';
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 100vh;
	height: 100lvh; /* constant height, so the glow doesn't resize as Safari's toolbar collapses */
	z-index: -1;
	pointer-events: none;
	background: radial-gradient(ellipse 55% 70% at 100% 0%, rgba(165,29,19,0.22) 0%, transparent 70%);
}
/* larger, fainter glow in the opposite corner. The layer runs 120px past the viewport
   so on iOS the glow carries on behind the floating toolbar instead of being cut off. */
.cs-page--insights::after {
	content: '';
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: calc(100vh + 120px);
	height: calc(100lvh + 120px);
	z-index: -1;
	pointer-events: none;
	background: radial-gradient(ellipse 90vw 95vh at 0% calc(100% - 120px), rgba(165,29,19,0.12) 0%, transparent 70%);
}
.post-empty { padding: 2em 0; color: var(--cs-muted); }

/* ── article diagrams (inline SVG) ─────────────────────────────── */
.d-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.post-figure { margin: 2.2em 0; }
.post-figure .fig-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.post-figure svg { display: block; width: 100%; min-width: 560px; height: auto; font-family: 'Source Sans Pro', sans-serif; }
.post-figure figcaption { color: var(--cs-muted); font-size: 0.82em; margin-top: 0.8em; padding-left: 0.9em; border-left: 2px solid var(--cs-line); }

.d-box        { fill: #1c1c1c; stroke: rgba(255,255,255,0.18); stroke-width: 1; }
.d-box-accent { fill: rgba(165,29,19,0.16); stroke: #c9251a; stroke-width: 1.5; }
.d-box-muted  { fill: transparent; stroke: rgba(255,255,255,0.35); stroke-width: 1.2; stroke-dasharray: 5 4; }
.d-t          { fill: #fff; font-size: 15px; font-weight: 600; }
.d-q          { fill: #fff; font-size: 14.5px; font-weight: 400; }
.d-s          { fill: rgba(255,255,255,0.6); font-size: 12.5px; }
.d-strong     { fill: rgba(255,255,255,0.88); }
.d-accent-text{ fill: #ff6a5c; }
.d-line       { stroke: rgba(255,255,255,0.4); stroke-width: 1.5; fill: none; }
.d-line-strong{ stroke: rgba(255,255,255,0.75); stroke-width: 2.5; fill: none; }
.d-line-accent{ stroke: #e0473a; stroke-width: 2.5; fill: none; }
.d-link       { stroke: rgba(201,37,26,0.6); stroke-width: 1.5; fill: none; }
.d-dash       { stroke: rgba(255,255,255,0.3); stroke-width: 1; stroke-dasharray: 4 4; fill: none; }
.d-tick       { stroke: rgba(255,255,255,0.6); stroke-width: 2; }
.d-gap        { fill: rgba(224,71,58,0.22); }
.d-dot        { fill: #e0473a; stroke: #141414; stroke-width: 2; }
.d-arrowhead  { fill: rgba(255,255,255,0.55); }
.d-arrowhead-accent { fill: #e0473a; }

.cs-related { margin: 0 0 2em !important; padding: 1em 1.2em; border: 1px solid var(--cs-line); font-size: 0.95em; }
.cs-related a { color: #fff; text-decoration: underline; text-decoration-color: var(--cs-accent); text-underline-offset: 3px; }

/* hero without an image */
.cs-hero--plain {
	min-height: auto;
	background:
		radial-gradient(ellipse 60% 120% at 85% 0%, rgba(165,29,19,0.28) 0%, transparent 70%),
		var(--cs-bg);
	border-bottom: 1px solid var(--cs-line);
}
.cs-hero--plain .cs-hero-text { padding-top: clamp(3em, 9vw, 6em); }

/* ── homepage: insights section ────────────────────────────────── */
/* Fixed px sizes: main.css sets a large base font (16pt), so em-based sizes balloon here. */
#insights.home-insights {
	min-height: 100vh;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	display: flex;
	align-items: center;
	margin: 0;
	padding: 72px clamp(16px, 4vw, 48px) 64px;
	box-sizing: border-box;
	background:
		radial-gradient(ellipse 55% 70% at 100% 0%, rgba(165,29,19,0.22) 0%, transparent 70%),
		#111;
	background-origin: border-box; /* the shorthand resets it; iOS extends sections with transparent borders */
	color: rgba(255,255,255,0.8);
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 16px;
	line-height: 1.55;
	text-align: left;
}
.home-insights-inner { width: 100%; min-width: 0; max-width: 1180px; margin: 0 auto; }
.home-insights-header { max-width: 760px; margin-bottom: 36px; }
.home-insights-eyebrow {
	margin: 0 0 8px !important;
	color: rgba(255,255,255,0.5);
	text-transform: uppercase;
	letter-spacing: 0.16em;
	font-size: 13px;
	font-weight: 600;
}
#insights h2 {
	margin: 0 0 10px !important;
	color: #fff;
	font-size: clamp(28px, 3.6vw, 44px);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	text-transform: none;
}
.home-insights-lede { margin: 0 !important; font-size: 19px; color: rgba(255,255,255,0.7); }
.home-insights-list {
	list-style: none;
	margin: 0 0 30px !important;
	padding: 0 !important;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
	gap: 22px;
}
.home-insights-list > li { margin: 0; padding: 0; }
.home-insight-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	box-sizing: border-box;
	padding: 28px 30px 24px;
	background: #1a1a1a;
	border: 1px solid rgba(255,255,255,0.1);
	border-top: 3px solid #a51d13;
	color: rgba(255,255,255,0.75) !important;
	text-decoration: none !important;
	border-bottom: 1px solid rgba(255,255,255,0.1) !important;
	transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.home-insight-card:hover { transform: translateY(-3px); background: #1f1f1f; border-color: rgba(255,255,255,0.22); border-top-color: #c9251a; }
.home-insight-tags { color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.12em; font-size: 12.5px; font-weight: 600; }
#insights .home-insight-card h3 {
	margin: 12px 0 10px !important;
	color: #fff;
	font-size: 24px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0;
	text-transform: none;
}
.home-insight-card p { margin: 0 0 18px !important; font-size: 17px; line-height: 1.55; flex: 1; }
.home-insight-meta { color: rgba(255,255,255,0.5); font-size: 14.5px; }
.home-insight-card:hover .home-insight-meta { color: #ff6a5c; }
.home-insights-all {
	display: inline-block;
	color: #fff !important;
	text-decoration: none !important;
	border: 1px solid rgba(255,255,255,0.35) !important;
	padding: 11px 20px;
	border-radius: 3px;
	font-size: 15.5px;
	letter-spacing: 0.04em;
	transition: background 0.2s, border-color 0.2s;
}
.home-insights-all:hover { background: rgba(255,255,255,0.08); border-color: #fff !important; }
@media (max-width: 736px) {
	#insights.home-insights { padding: 40px 16px 48px; }
	.home-insights-list > li:nth-child(n+3) { display: none; } /* phones: 2 latest; the rest are one tap away */
	.home-insights-header { margin-bottom: 20px; }
	.home-insights-lede { font-size: 16.5px; }
	.home-insights-list { gap: 12px; }
	.home-insight-card { padding: 20px 20px 18px; }
	#insights .home-insight-card h3 { font-size: 20px; }
	.home-insight-card p { font-size: 15.5px; margin-bottom: 12px !important; }
}
@media (max-width: 736px) and (max-height: 760px) {
	.home-insight-card p { display: none; }
	#insights .home-insight-card h3 { margin-bottom: 8px !important; }
}
/* short screens (small laptops, phones with browser bars): same text, less air */
@media (max-height: 700px) {
	#insights.home-insights { padding-top: 26px; padding-bottom: 28px; }
	.home-insights-header { margin-bottom: 22px; }
	.home-insights-list { margin-bottom: 20px !important; }
	.home-insight-card { padding-top: 20px; padding-bottom: 18px; }
	.home-insight-card p { margin-bottom: 12px !important; }
}
