/*
 * Base: reset, typography scale, links, focus, motion rules (PLAN §5.4, §6; DESIGN §4, §9, §16).
 */

*,
*::before,
*::after { box-sizing: border-box; }

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: 90px;
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--page);
	color: var(--fg);
	font-family: var(--font-body);
	font-size: 16px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd, ol, ul { margin: 0; }
ol[class], ul[class],
nav ul, nav ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }

/* One select look everywhere: own chevron with room on the right (native arrows hug the border). */
select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 44px !important;
	background-image:
		linear-gradient(45deg, transparent 50%, currentColor 50%),
		linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position:
		right 22px center,
		right 17px center;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	cursor: pointer;
}
select::-ms-expand { display: none; }
button { cursor: pointer; }
[hidden] { display: none !important; }

h1, h2, h3, h4 {
	font-family: var(--font-display);
	font-weight: 400;
	font-variation-settings: "SOFT" 50;
	text-wrap: balance;
}
p { text-wrap: pretty; }

/* Arabic is always Amiri unless a decorative class says otherwise. */
[lang="ar"] { font-family: var(--font-arabic); }

/* ---- Links ---- */
a { color: var(--accent); text-underline-offset: 3px; transition: color 150ms var(--ease); }
a:hover { color: var(--accent-hover); }

/* ---- Focus (DESIGN §10.4, §16): never removed ---- */
:focus { outline: none; }
:focus-visible {
	outline: 2px solid var(--copper-raw);
	outline-offset: 3px;
	border-radius: 4px;
}

/* ---- Skip link: outside .jk-root (fixed positioning) ---- */
.skip-link {
	position: fixed;
	top: 12px;
	left: 12px;
	z-index: 60;
	padding: 10px 14px;
	border-radius: 8px;
	background: var(--ink-card);
	color: var(--parchment);
	font-weight: 700;
	font-size: 14px;
	text-decoration: none;
	opacity: 0;
	transform: translateY(-120%);
	transition: transform 150ms var(--ease), opacity 150ms var(--ease);
}
.skip-link:focus-visible,
.skip-link:focus { opacity: 1; transform: none; color: var(--parchment); }

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

/* ---- Typography scale (DESIGN §4.2) ---- */
.font-display,
.t-display, .t-page-h1, .t-detail-h1, .t-h2, .t-h2-compact, .t-h2-cta, .t-h2-project, .t-h3, .t-quote {
	font-family: var(--font-display);
	font-variation-settings: "SOFT" 50;
}
.t-display em, .t-page-h1 em, .t-h2 em, .t-h2-compact em, .t-detail-h1 em {
	font-style: italic;
	font-weight: 300;
	color: var(--fg-2);
}

.t-display {
	font-size: clamp(64px, 11.5cqi, 148px);
	font-weight: 340;
	line-height: .9;
	letter-spacing: -.03em;
}
.t-display em { display: block; }

.t-page-h1 {
	font-size: clamp(52px, 8cqi, 96px);
	font-weight: 340;
	line-height: .95;
	letter-spacing: -.025em;
}
.t-page-h1--sm {
	font-size: clamp(44px, 6.4cqi, 80px);
	line-height: .98;
}

.t-detail-h1 {
	font-size: clamp(40px, 6cqi, 72px);
	font-weight: 350;
	line-height: 1;
	letter-spacing: -.02em;
}

.t-h2 {
	font-size: clamp(34px, 4.4cqi, 52px);
	font-weight: 380;
	line-height: 1.05;
}
.t-h2 em, .t-h2-compact em { font-weight: 380; }

.t-h2-compact {
	font-size: clamp(30px, 3.6cqi, 42px);
	font-weight: 380;
	line-height: 1.05;
}

.t-h2-cta {
	font-size: clamp(36px, 5cqi, 64px);
	font-weight: 350;
	line-height: 1.02;
	letter-spacing: -.02em;
}

.t-h2-project {
	font-size: clamp(40px, 5.4cqi, 64px);
	font-weight: 350;
	line-height: 1;
	letter-spacing: -.02em;
}

.t-h3 {
	font-size: 26px;
	font-weight: 450;
	line-height: 1.15;
}

.t-lead {
	font-size: 18px;
	line-height: 1.6;
	color: var(--fg-2);
	max-width: 54ch;
}

.t-body { font-size: 17px; line-height: 1.65; }
.t-body-m { font-size: 15px; line-height: 1.6; }
.t-meta { font-size: 13px; line-height: 1.5; color: var(--muted); }

.t-label {
	font-family: var(--font-body);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .2em;
	text-transform: uppercase;
	color: var(--gold-ink);
	line-height: normal;
}
.t-label .ar,
.t-label [lang="ar"] {
	font-family: var(--font-arabic);
	font-size: 16px;
	font-weight: 400;
	letter-spacing: 0;
}

.t-quote {
	font-size: clamp(20px, 2.4cqi, 28px);
	font-style: italic;
	font-weight: 350;
	line-height: 1.4;
	max-width: 34ch;
}

.t-ayah {
	font-family: var(--font-arabic);
	font-size: clamp(34px, 5cqi, 58px);
	line-height: 1.7;
	direction: rtl;
}

.t-note {
	font-family: var(--font-display);
	font-style: italic;
	font-size: 16px;
	line-height: 1.4;
	color: var(--muted);
}

.t-watermark {
	font-family: var(--font-arabic-deco);
	font-size: clamp(100px, 14cqi, 180px);
	line-height: 1;
	color: var(--fg);
	opacity: .05;
	pointer-events: none;
	user-select: none;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---- Theme switch animation (PLAN §6.1): only while html.theme-anim ---- */
html.theme-anim,
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
	transition: background-color 250ms var(--ease), color 250ms var(--ease), border-color 250ms var(--ease), fill 250ms var(--ease), stroke 250ms var(--ease) !important;
}

/* ---- Hero safety net (PLAN §6.2.3): hidden only with JS motion on, auto-revealed after 2.5s ---- */
[data-motion="on"] [data-hero]:not([data-hero="wm"]):not([data-hero="portrait"]):not([data-hero-done]) {
	opacity: 0;
	animation: jk-safety 0s linear 2.5s forwards;
}
[data-motion="on"] [data-hero="portrait"]:not([data-hero-done]) {
	clip-path: inset(100% 0 0 0);
	animation: jk-safety-clip 0s linear 2.5s forwards;
}
@keyframes jk-safety { to { opacity: 1; } }
@keyframes jk-safety-clip { to { clip-path: inset(0 0 0 0); } }

/* ---- Lenis (PLAN §6.3) ---- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

/* ---- Reduced motion: nothing moves, nothing stays hidden ---- */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}

/* Shared SVG defs container (parts/svg-defs.php). */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Icons from <use href="#i-…">. */
.icon { width: 20px; height: 20px; flex: none; }

/* Girih pattern (DESIGN §7.2): a mask, so it takes currentColor from its context. Always decorative. */
.girih {
	background-color: currentColor;
	-webkit-mask: url("../img/girih.svg") repeat 0 0 / 64px 64px;
	mask: url("../img/girih.svg") repeat 0 0 / 64px 64px;
	pointer-events: none;
}

/* ---- Scroll reveals (motion.js). Only elements below the fold at load get .m-wait, so nothing is hidden without JS. ---- */
.m-wait { opacity: 0; }
.section-head__note.m-wait { opacity: 1; }
.section-head__note.m-wait > * { opacity: 0; }
.section-head__note::before { transition: transform 400ms var(--ease); }
.section-head__note.m-wait::before { transform: scaleX(0); }

/* Watermark text comes from CSS content: pure decoration, never read or contrast-checked as text. */
.t-watermark::before { content: attr(data-wm); }
