/* ==========================================================================
   Site chrome shared by the blog index and every post: base, header, menu
   sheet, footer, buttons and chips. Ported from arriqaaq.github.io
   (src/lib/styles/base.css, SiteHeader.svelte, SiteFooter.svelte) so the blog
   at arriqaaq.com/tech feels like the rest of the site. Tokens come from
   tokens.css. Mobile first: written for 375px, min-width queries add desktop.

   Rules here are class-scoped on purpose. Widgets and diagrams inside posts
   keep their own styling, so nothing in this file styles bare elements.
   ========================================================================== */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--topbar-h) + 16px);
	background: var(--page);
}

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

body {
	margin: 0;
	background: var(--page);
	color: var(--ink);
	font-family: var(--font-sans);
	font-size: var(--fs-body);
	line-height: var(--lh-body);
	font-feature-settings: 'cv11', 'ss01';
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

:focus-visible {
	outline: none;
	box-shadow: var(--ring);
	border-radius: var(--r-xs);
}

::selection {
	background: var(--amber);
	color: var(--ink);
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.skip {
	position: absolute;
	left: var(--s-3);
	top: -60px;
	z-index: 60;
	padding: var(--s-2) var(--s-4);
	border-radius: var(--r-pill);
	background: var(--ink);
	color: #fff;
	text-decoration: none;
}

.skip:focus {
	top: var(--s-2);
}

/* Subject colour scoping (DESIGN.md). Put one on <body>; children read
   --subject, --subject-ink and --subject-on. */
.subject--pink { --subject: var(--pink); --subject-ink: var(--pink-ink); --subject-on: var(--ink); }
.subject--purple { --subject: var(--purple); --subject-ink: var(--purple-ink); --subject-on: #fff; }
.subject--blue { --subject: var(--blue); --subject-ink: var(--blue-ink); --subject-on: #fff; }
.subject--green { --subject: var(--green); --subject-ink: var(--green-ink); --subject-on: var(--ink); }

/* ---- Layout primitives ---------------------------------------------------- */

.wrap {
	width: 100%;
	max-width: calc(var(--max) + 2 * var(--gutter));
	margin-inline: auto;
	padding-inline: var(--gutter);
}

/* ---- Eyebrow: small uppercase Inter label, in colour ---------------------- */

.eyebrow {
	display: inline-flex;
	align-items: center;
	gap: var(--s-2);
	font-family: var(--font-sans);
	font-size: var(--fs-eyebrow);
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: var(--ls-eyebrow);
	text-transform: uppercase;
	color: var(--subject-ink, var(--purple-ink));
}

.eyebrow--quiet {
	color: var(--ink-3);
}

.eyebrow--dot::before {
	content: '';
	width: 8px;
	height: 8px;
	border-radius: 2px;
	background: var(--subject, var(--pink));
}

/* ---- Buttons: pills ------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--s-2);
	min-height: var(--tap);
	padding: 12px 20px;
	border: 1px solid var(--ink);
	border-radius: var(--r-pill);
	background: var(--ink);
	color: #fff;
	font: inherit;
	font-size: var(--fs-small);
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: 0;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition:
		background var(--dur-fast) ease,
		border-color var(--dur-fast) ease,
		transform var(--dur-fast) ease;
}

.btn:hover {
	background: #2a2834;
}

.btn:active {
	transform: scale(0.98);
}

.btn--ghost {
	background: var(--page);
	color: var(--ink);
	border-color: rgba(13, 12, 19, 0.12);
}

.btn--ghost:hover {
	background: var(--surface);
	border-color: rgba(13, 12, 19, 0.2);
}

.btn--subject {
	background: var(--subject);
	border-color: var(--subject);
	color: var(--subject-on);
}

.btn--subject:hover {
	background: var(--subject);
	filter: brightness(1.06);
}

.btn--block {
	width: 100%;
	white-space: normal;
	text-align: center;
}

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: var(--tap);
	height: var(--tap);
	padding: 0;
	border: 1px solid rgba(13, 12, 19, 0.12);
	border-radius: 50%;
	background: var(--page);
	color: var(--ink);
	cursor: pointer;
	transition: background var(--dur-fast) ease;
}

.icon-btn:hover {
	background: var(--surface);
}

.icon-btn svg {
	display: block;
	width: 18px;
	height: 18px;
}

.icon-btn.quiet {
	border-color: transparent;
	background: transparent;
}

.icon-btn.quiet:hover {
	background: var(--surface);
}

/* ---- Chips (filter chips) ------------------------------------------------- */

.chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 32px;
	padding: 4px 12px;
	border: 0;
	border-radius: var(--r-sm);
	background: var(--surface);
	color: rgba(13, 12, 19, 0.8);
	font: inherit;
	font-size: var(--fs-xs);
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: 0;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition:
		background var(--dur-fast) ease,
		color var(--dur-fast) ease;
}

.chip:hover {
	background: var(--surface-2);
}

.chip[aria-pressed='true'],
.chip.is-active {
	background: var(--ink);
	color: #fff;
}

/* Horizontal scroller for chip rows on phones: no wrap, trailing-edge fade. */
.scroll-x {
	display: flex;
	gap: var(--s-2);
	overflow-x: auto;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scroll-padding-inline: var(--gutter);
	margin-inline: calc(-1 * var(--gutter));
	padding-inline: var(--gutter);
	mask-image: linear-gradient(90deg, #000 calc(100% - var(--gutter)), transparent);
}

.scroll-x::-webkit-scrollbar {
	display: none;
}

.scroll-x > * {
	flex: 0 0 auto;
	scroll-snap-align: start;
}

@media (min-width: 900px) {
	.scroll-x {
		flex-wrap: wrap;
		overflow: visible;
		margin-inline: 0;
		padding-inline: 0;
		mask-image: none;
	}
}

/* ---- Site header (sticky). Phones: logo, current section on posts, menu button.
   Desktop: inline links. ---------------------------------------------------- */

.site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	height: var(--topbar-h);
	background: rgba(255, 255, 255, 0.86);
	backdrop-filter: saturate(160%) blur(12px);
	-webkit-backdrop-filter: saturate(160%) blur(12px);
	border-bottom: 1px solid transparent;
	transition: border-color var(--dur) ease;
}

.site-header.is-scrolled {
	border-bottom-color: var(--line);
}

.site-header .bar {
	display: flex;
	align-items: center;
	gap: var(--s-3);
	height: 100%;
	max-width: calc(var(--max) + 2 * var(--gutter));
	margin-inline: auto;
	padding-inline: calc(var(--gutter) - 6px) calc(var(--gutter) - 10px);
}

.site-header .brand {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: var(--tap);
	padding-inline: 6px;
	color: inherit;
	text-decoration: none;
	flex: none;
}

.site-header .brand svg {
	display: block;
}

.site-header .wordmark {
	font-size: 1.0625rem;
	font-weight: 600;
	letter-spacing: -0.03em;
}

/* Current section replaces the wordmark on phones once the header has scrolled away. */
.site-header .section {
	display: none;
	align-items: center;
	gap: 8px;
	min-width: 0;
	flex: 1;
	min-height: var(--tap);
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	text-align: left;
	cursor: pointer;
	font: inherit;
	font-size: var(--fs-small);
	font-weight: 500;
}

.is-past .site-header .section {
	display: flex;
	animation: fade-up var(--dur) var(--ease-out);
}

.site-header .section-n {
	font-variant-numeric: tabular-nums;
	font-size: 11px;
	color: var(--pink-ink);
}

.site-header .section-c {
	flex: none;
	width: 16px;
	height: 16px;
	color: var(--ink-3);
}

.site-header .section-t {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

@media (max-width: 899px) {
	.is-past .site-header .wordmark {
		display: none;
	}
}

@keyframes fade-up {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
}

.site-header .links {
	display: none;
}

.site-header .actions {
	display: flex;
	align-items: center;
	gap: 2px;
	margin-left: auto;
	flex: none;
}

@media (min-width: 900px) {
	.site-header .links {
		display: flex;
		gap: var(--s-1);
		margin-left: var(--s-5);
	}

	.site-header .links a {
		padding: 8px 12px;
		border-radius: var(--r-pill);
		font-size: var(--fs-small);
		font-weight: 500;
		line-height: var(--lh-body);
		color: var(--ink-2);
		text-decoration: none;
		transition:
			background var(--dur-fast) ease,
			color var(--dur-fast) ease;
	}

	.site-header .links a:hover,
	.site-header .links a.is-active {
		color: var(--ink);
		background: var(--scrim);
	}

	.site-header .section {
		order: 3;
		justify-content: center;
	}

	.site-header .menu-btn {
		display: none;
	}
}

/* Full-screen menu sheet (phones). */
.sheet {
	position: fixed;
	inset: var(--topbar-h) 0 0;
	z-index: 49;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: var(--s-5) var(--gutter) calc(var(--s-6) + env(safe-area-inset-bottom));
	background: var(--page);
	overflow-y: auto;
	animation: sheet-in var(--dur) var(--ease-out);
}

.sheet[hidden] {
	display: none;
}

.sheet nav {
	display: grid;
}

.sheet nav a {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-block: var(--s-4);
	border-bottom: 1px solid var(--line);
	color: inherit;
	font-size: 1.75rem;
	font-weight: 500;
	line-height: var(--lh-heading);
	letter-spacing: -0.03em;
	text-decoration: none;
	animation: fade-up var(--dur-slow) var(--ease-out) both;
	animation-delay: calc(var(--i) * 40ms);
}

.sheet nav a span {
	font-size: 1.25rem;
	color: var(--ink-3);
}

.sheet-foot {
	display: grid;
	gap: var(--s-5);
	padding-top: var(--s-6);
}

.sheet-social {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s-5);
	font-size: var(--fs-small);
	color: var(--ink-2);
}

.sheet-social a {
	color: inherit;
	text-decoration: none;
}

@keyframes sheet-in {
	from {
		opacity: 0;
	}
}

@media (min-width: 900px) {
	.sheet {
		display: none;
	}
}

/* ---- Site footer: columns always open on desktop, tap-to-expand on phones --- */

.site-footer {
	margin-top: var(--section);
	padding-block: var(--s-7) calc(var(--s-6) + env(safe-area-inset-bottom));
	background: var(--surface);
	font-size: var(--fs-small);
	line-height: var(--lh-body);
}

.site-footer .top {
	display: grid;
	gap: var(--s-6);
}

.site-footer .logo {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: inherit;
	font-size: 1.25rem;
	font-weight: 600;
	letter-spacing: -0.03em;
	text-decoration: none;
}

.site-footer .logo svg {
	display: block;
}

.site-footer .brand p {
	margin: var(--s-3) 0 0;
	max-width: 34ch;
	color: var(--ink-2);
}

.site-footer .col {
	border-top: 1px solid var(--line-strong);
}

.site-footer .col-title {
	margin: 0;
	font-size: inherit;
	font-weight: 500;
	line-height: inherit;
	letter-spacing: 0;
}

.site-footer .col-title button {
	display: flex;
	width: 100%;
	align-items: center;
	justify-content: space-between;
	min-height: 52px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.site-footer .col-title svg {
	width: 18px;
	height: 18px;
	transition: transform var(--dur) var(--ease-out);
}

.site-footer .col.is-open .col-title svg {
	transform: rotate(180deg);
}

.site-footer .col-label {
	display: none;
}

.site-footer ul {
	display: none;
	margin: 0;
	padding: 0 0 var(--s-4);
	list-style: none;
}

.site-footer .col.is-open ul {
	display: grid;
	gap: var(--s-1);
}

.site-footer li {
	margin: 0;
}

.site-footer li a {
	display: inline-block;
	padding-block: 7px;
	color: var(--ink-2);
	text-decoration: none;
}

.site-footer li a:hover {
	color: var(--ink);
}

.site-footer .bottom {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s-2) var(--s-5);
	margin-top: var(--s-6);
	padding-top: var(--s-5);
	border-top: 1px solid var(--line-strong);
	color: var(--ink-3);
}

.site-footer .bottom a {
	color: var(--ink-3);
	text-decoration: none;
}

.site-footer .bottom a:hover {
	color: var(--ink);
}

@media (min-width: 900px) {
	.site-footer .top {
		grid-template-columns: 1fr 1.6fr;
		gap: var(--s-8);
	}

	.site-footer .cols {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: var(--s-6);
	}

	.site-footer .col {
		border-top: 0;
	}

	.site-footer .col-title button {
		display: none;
	}

	.site-footer .col-label {
		display: block;
		margin-bottom: var(--s-3);
		color: var(--ink);
	}

	.site-footer ul,
	.site-footer .col.is-open ul {
		display: grid;
		gap: 0;
	}
}
