/* ==========================================================================
   Alqima Urban — Base: reset, typography, accessibility primitives
   ========================================================================== */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	background: var(--c-canvas);
	color-scheme: var(--c-scheme);
	scroll-padding-top: var(--header-h);
}

@media (prefers-reduced-motion: no-preference) {
	html:not(.lenis) {
		scroll-behavior: smooth;
	}
}

body {
	margin: 0;
	color-scheme: var(--c-scheme);
	min-height: 100vh;
	min-height: 100svh;
	background: var(--c-canvas);
	color: var(--c-text);
	font-family: var(--f-body);
	font-size: var(--fs-body);
	font-weight: var(--fw-regular);
	line-height: var(--lh-body);
	letter-spacing: var(--tr-body);
	font-feature-settings: "kern", "calt";
	font-optical-sizing: auto;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	overflow-x: clip;
	/* Sticky footer: short pages (404, short page, empty search) keep the
	   footer at the bottom of the viewport (Stage 06 audit). */
	display: flex;
	flex-direction: column;
}

.site-main {
	flex: 1 0 auto;
	width: 100%;
}

:root[dir="rtl"] body {
	font-feature-settings: normal;
}

img,
picture,
video,
svg,
canvas {
	display: block;
	max-width: 100%;
}

img,
video {
	height: auto;
}

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

ul[class],
ol[class] {
	list-style: none;
	padding: 0;
}

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

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

input, select, textarea {
	font: inherit;
	color: inherit;
}

[hidden] {
	display: none !important;
}

::selection {
	background: var(--c-text);
	color: var(--c-canvas);
}

/* ------------------------------------------------------------- Typography */
h1, h2, h3, h4 {
	font-weight: var(--fw-semibold);
	line-height: var(--lh-tight);
	letter-spacing: var(--tr-heading);
	text-wrap: balance;
}

p {
	text-wrap: pretty;
}

/* Small uppercase editorial label (Latin). Arabic has no case — the RTL layer
   resets transform and tracking and nudges size for legibility. */
.label {
	font-size: var(--fs-label);
	font-weight: var(--fw-medium);
	letter-spacing: var(--tr-label);
	text-transform: uppercase;
	line-height: 1.4;
	color: var(--c-text-2);
}

.prose > * + * {
	margin-block-start: 1.2em;
}

.prose a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

/* ---------------------------------------------------------- Accessibility */
:focus {
	outline: none;
}

:focus-visible {
	outline: 1px solid var(--c-text);
	outline-offset: 4px;
	border-radius: var(--r-xs);
	box-shadow: 0 0 0 4px var(--c-focus-halo);
}

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

.skip-link {
	position: fixed;
	inset-block-start: var(--s-3);
	inset-inline-start: var(--s-3);
	z-index: var(--z-skip);
	padding: var(--s-3) var(--s-4);
	background: var(--c-text);
	color: var(--c-canvas);
	font-size: var(--fs-small);
	font-weight: var(--fw-medium);
	border-radius: var(--r-xs);
	transform: translateY(-200%);
	transition: transform var(--dur-2) var(--ease-out);
}

.skip-link:focus,
.skip-link:focus-visible {
	transform: none;
}

.site-main:focus {
	outline: none;
}

/* ----------------------------------------------------------- Film grain */
/* One static SVG turbulence tile, slightly animated by stepping its offset.
   Adds analogue texture to flat darks; costs ~1 composited layer. */
.grain {
	position: fixed;
	inset: -50%;
	z-index: var(--z-grain);
	pointer-events: none;
	opacity: 0.07;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	background-size: 220px 220px;
	mix-blend-mode: overlay;
	animation: grain-shift 1.2s steps(6) infinite;
	will-change: transform;
}

@keyframes grain-shift {
	0%   { transform: translate(0, 0); }
	20%  { transform: translate(-3%, 2%); }
	40%  { transform: translate(2%, -3%); }
	60%  { transform: translate(-2%, -1%); }
	80%  { transform: translate(3%, 3%); }
	100% { transform: translate(0, 0); }
}

/* ------------------------------------------------------ Reduced motion */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}

	.grain {
		animation: none;
	}
}
