/* ============================================================================
   willblew.com — the whole stylesheet.
   Visual system documented in STYLEGUIDE.md at the repo top level.

   Replaces normalize.css + skeleton.css. Skeleton's grid (.container/.row/
   .columns) is gone; this file uses flow and one flex header instead.
   ========================================================================= */

:root {
	color-scheme: dark;

	/* --- Colour. Four steps, plus one accent. Never add a fifth. --------- */
	--bg:        #000000;
	--fg:        #ffffff;
	--fg-body:   rgba(255, 255, 255, 0.72);
	--fg-dim:    rgba(255, 255, 255, 0.58);
	--fg-faint:  rgba(255, 255, 255, 0.14);

	/* The one surface in the system that takes a fill. See STYLEGUIDE 4a. */
	--reader-bg: rgba(255, 255, 255, 0.04);

	/* Signal means "the next action is here" and nothing else.
	   One per page, maximum. */
	--signal:       #a7e6ec;
	--signal-soft:  rgba(167, 230, 236, 0.55);
	--signal-faint: rgba(167, 230, 236, 0.14);

	/* --- Type. Display for identity, mono for everything read. ----------- */
	--font-display: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
	--font-mono:    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

	/* --- Motion. One curve. --------------------------------------------- */
	--ease: cubic-bezier(0.16, 1, 0.3, 1);

	/* --- Measure. Mono `ch` is an exact glyph width, so this is literal. -- */
	--measure: 62ch;
}

/* --- Reset ------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--fg-body);
	font-family: var(--font-mono);
	font-weight: 400;
	line-height: 2.1;
	/* Horizontal only: `overflow: hidden` would clip long posts. */
	overflow-x: hidden;
}

img, video { max-width: 100%; height: auto; }

a { color: inherit; }

/* ============================================================================
   Atmosphere
   Three fixed, non-interactive layers. Content sits above all of them so text
   stays crisp and the noise only ever falls on background.
   ========================================================================= */

.glow, .grain { position: fixed; inset: 0; pointer-events: none; }

.glow {
	z-index: 0;
	background: radial-gradient(
		58vmax 58vmax at var(--mx, 50%) var(--my, 32%),
		rgba(255, 255, 255, 0.085),
		transparent 70%);
}

body::after {
	content: "";
	position: fixed;
	inset: 0;
	z-index: 2;
	pointer-events: none;
	background: radial-gradient(120% 88% at 50% 46%, transparent 42%, rgba(0, 0, 0, 0.72));
}

.grain {
	z-index: 3;
	opacity: 0.035;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	/* steps(1) makes it flicker like film rather than slide like a texture. */
	animation: grain-jitter 700ms steps(1) infinite;
}

@keyframes grain-jitter {
	0%   { transform: translate(0, 0); }
	25%  { transform: translate(-2%, 1%); }
	50%  { transform: translate(1%, -2%); }
	75%  { transform: translate(2%, 2%); }
	100% { transform: translate(0, 0); }
}

/* ============================================================================
   Shell
   ========================================================================= */

.header, .main, .footer {
	position: relative;
	z-index: 4;
	width: 100%;
	max-width: 74rem;
	margin: 0 auto;
	padding: 0 clamp(1.2rem, 5vw, 3rem);
}

.header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1.5rem;
	flex-wrap: wrap;
	padding-top: clamp(1.4rem, 4vw, 2.6rem);
	padding-bottom: clamp(1.4rem, 4vw, 2.4rem);
}

.main { flex: 1; padding-bottom: clamp(3rem, 8vw, 6rem); }

/* --- Identity ---------------------------------------------------------- */

/* Column so the tagline stacks under the mark; the header's baseline
   alignment still resolves against the mark, so the nav stays put.
   align-items: center centres the narrower child under the wider one - the
   negative right margins on both children are what make that land optically
   rather than mathematically, since trailing letter-space would otherwise
   push each of them left of true centre. */
.brand {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
}

.brand__tagline {
	margin: 0;
	font-size: clamp(0.58rem, 0.95vw, 0.66rem);
	letter-spacing: 0.17em;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--fg-dim);
	margin-right: -0.17em;
}

.mark {
	font-family: var(--font-display);
	font-weight: 900;
	font-size: clamp(1.35rem, 2.6vw, 1.9rem);
	letter-spacing: 0.22em;
	/* Cancels the trailing letter-space so the text sits at true left. */
	margin-right: -0.22em;
	color: var(--fg);
	text-decoration: none;
	text-transform: uppercase;
	transition: color 0.45s var(--ease);
}

.mark:hover { color: var(--fg); }

/* --- Nav --------------------------------------------------------------- */

.nav {
	display: flex;
	align-items: baseline;
	gap: clamp(1.1rem, 2.4vw, 2rem);
	flex-wrap: wrap;
}

.nav__link {
	font-size: clamp(0.68rem, 1.05vw, 0.74rem);
	font-weight: 500;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--fg-dim);
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.45s var(--ease);
}

.nav__link > span { margin-right: -0.24em; display: inline-block; }
.nav__link:hover, .nav__link:focus-visible { color: var(--fg); }

.nav__meta {
	font-size: clamp(0.62rem, 1vw, 0.7rem);
	letter-spacing: 0.17em;
	color: var(--fg-dim);
	white-space: nowrap;
}

/* ============================================================================
   Index and link lists
   ========================================================================= */

.page-title {
	font-family: var(--font-display);
	font-weight: 900;
	font-size: clamp(2.1rem, 7.6vw, 4.4rem);
	line-height: 1.02;
	letter-spacing: 0.085em;
	margin-right: -0.085em;
	color: var(--fg);
	margin: 0 0 clamp(2rem, 6vw, 3.4rem);
	text-transform: uppercase;
}

.link-list { list-style: none; margin: 0; padding: 0; }

.link-list__item { border-top: 1px solid var(--fg-faint); }
.link-list__item:last-child { border-bottom: 1px solid var(--fg-faint); }

.link-list__link {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1.4rem;
	padding: clamp(0.9rem, 2.4vw, 1.3rem) 0;
	font-size: clamp(0.72rem, 1.25vw, 0.85rem);
	letter-spacing: 0.06em;
	line-height: 1.7;
	/* Post titles sit at full white, not the 0.58 resting-interactive step.
	   They are the primary thing on the index, and the ladder's job is to make
	   the important thing loudest. See STYLEGUIDE 2. */
	color: var(--fg);
	text-decoration: none;
	transition: color 0.45s var(--ease);
}

/* Transparent border at rest so the hover underline costs no layout shift. */
.link-list__title {
	border-bottom: 1px solid transparent;
	transition: border-color 0.45s var(--ease);
}

/* The affordance: a text glyph, not an icon font or an SVG.
   A guillemet rather than an arrow - at mono's stroke weight the thin
   north-east arrow read as a speck and disappeared against the title. */
.link-list__icon {
	margin-left: 0.55em;
	color: var(--fg-body);
	font-size: 1.15em;
	font-weight: 500;
	/* The glyph carries the title's tracking otherwise, which pushes it away
	   from the word it belongs to. */
	letter-spacing: 0;
	transition: color 0.45s var(--ease);
}

.link-list__link:hover .link-list__title,
.link-list__link:focus-visible .link-list__title { border-bottom-color: var(--fg); }

.link-list__link:hover .link-list__icon,
.link-list__link:focus-visible .link-list__icon { color: var(--fg); }

.link-list__meta {
	font-size: clamp(0.6rem, 1vw, 0.68rem);
	letter-spacing: 0.19em;
	color: rgba(255, 255, 255, 0.38);
	flex: none;
}

/* Index shell: posts left, about/work right. The aside wraps underneath on
   its own when there is no room, so this needs no media query. */
.index-layout {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: clamp(2.4rem, 5vw, 4.5rem);
}

.index-layout__main  { flex: 1 1 30rem; min-width: 0; max-width: var(--measure); }
.index-layout__aside { flex: 1 1 17rem; min-width: 0; max-width: 34ch; }

.aside-block + .aside-block { margin-top: clamp(2.4rem, 6vw, 3.4rem); }

.aside-block__body p {
	font-size: clamp(0.68rem, 1.1vw, 0.78rem);
	letter-spacing: 0.06em;
	line-height: 2;
	/* Full white rather than the 0.72 body step: this is the one block of
	   first-person copy on the site and it should read as loudly as a heading. */
	color: var(--fg);
	margin: 0 0 1.1em;
}

.aside-block__body p:last-child { margin-bottom: 0; }
.aside-block__body strong { color: var(--fg); font-weight: 500; }

/* ============================================================================
   Reader
   The page a post is read on. An e-reader feel built from what the system
   already has - a hairline edge, deep margins, a measured column - rather than
   from a card, a fill, or a shadow, none of which exist here.
   ========================================================================= */

/* Fixed hairline at the very top of the viewport. --fg-faint is the unfilled
   track, --fg the read portion. Width is driven from JS via --progress. */
.reading-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	z-index: 5;
	background: var(--fg-faint);
	pointer-events: none;
}

.reading-progress__fill {
	height: 100%;
	width: 100%;
	background: var(--fg);
	transform: scaleX(var(--progress, 0));
	transform-origin: 0 50%;
}

.reader {
	/* Lifted off pure black so the column reads as a page rather than as a
	   hole cut in the background. It also masks the grain within its bounds,
	   which is the point - paper, not atmosphere. */
	background: var(--reader-bg);
	border: 1px solid var(--fg-faint);
	/* Deep margins are what make a page feel like a page. */
	padding: clamp(1.5rem, 5vw, 3.2rem) clamp(1.3rem, 4.5vw, 2.8rem);
	max-width: calc(var(--measure) + 6rem);
}

/* Running head: what an e-reader puts at the edge of the page. */
.reader__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.9rem;
	margin: 0 0 clamp(1.6rem, 4vw, 2.4rem);
	padding-bottom: clamp(0.9rem, 2.5vw, 1.2rem);
	border-bottom: 1px solid var(--fg-faint);
	font-size: clamp(0.56rem, 0.95vw, 0.64rem);
	letter-spacing: 0.19em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.38);
}

.reader__meta span + span::before {
	content: "·";
	margin-right: 0.9rem;
}

/* Inside the reader the column is the page, so it fills the width the padding
   leaves rather than carrying its own narrower cap. */
.reader .prose { max-width: none; }

/* ============================================================================
   Prose — Parsedown output plus raw-HTML posts
   ========================================================================= */

.prose { max-width: var(--measure); }

.prose > :first-child { margin-top: 0; }

.prose p,
.prose li {
	font-size: clamp(0.72rem, 1.25vw, 0.85rem);
	letter-spacing: 0.06em;
	line-height: 2.1;
	color: var(--fg-body);
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
	font-family: var(--font-display);
	font-weight: 900;
	color: var(--fg);
	letter-spacing: 0.06em;
	line-height: 1.25;
	margin: clamp(2.2rem, 6vw, 3.2rem) 0 clamp(0.8rem, 2vw, 1.1rem);
	text-transform: uppercase;
}

.prose h1 { font-size: clamp(1.4rem, 4vw, 2rem); }
.prose h2 { font-size: clamp(1.15rem, 3vw, 1.5rem); }
.prose h3 { font-size: clamp(0.95rem, 2.2vw, 1.15rem); }
.prose h4, .prose h5, .prose h6 { font-size: clamp(0.82rem, 1.6vw, 0.95rem); }

.prose a {
	color: var(--fg);
	text-decoration: none;
	border-bottom: 1px solid var(--fg-faint);
	transition: border-color 0.45s var(--ease);
}

.prose a:hover, .prose a:focus-visible { border-bottom-color: var(--fg); }

.prose ul, .prose ol { padding-left: 1.6em; }
.prose li { margin: 0.35em 0; }

.prose blockquote {
	margin: clamp(1.4rem, 4vw, 2rem) 0;
	padding-left: clamp(1rem, 3vw, 1.6rem);
	border-left: 1px solid var(--fg-faint);
	color: var(--fg-dim);
}

.prose hr {
	border: 0;
	border-top: 1px solid var(--fg-faint);
	margin: clamp(2.4rem, 7vw, 3.6rem) 0;
}

.prose code {
	font-family: var(--font-mono);
	font-size: 0.92em;
	color: var(--fg);
	background: rgba(255, 255, 255, 0.05);
	padding: 0.12em 0.4em;
}

.prose pre {
	font-family: var(--font-mono);
	font-size: clamp(0.68rem, 1.1vw, 0.78rem);
	line-height: 1.75;
	color: var(--fg-body);
	background: transparent;
	border: 1px solid var(--fg-faint);
	padding: clamp(0.9rem, 2.4vw, 1.3rem);
	/* Wide code scrolls inside its own box; the page never scrolls sideways. */
	overflow-x: auto;
	margin: clamp(1.4rem, 4vw, 2rem) 0;
}

.prose pre code { background: none; padding: 0; font-size: inherit; }

.prose table {
	width: 100%;
	border-collapse: collapse;
	font-size: clamp(0.68rem, 1.1vw, 0.78rem);
	margin: clamp(1.4rem, 4vw, 2rem) 0;
}

.prose th, .prose td {
	text-align: left;
	padding: 0.6em 0.9em 0.6em 0;
	border-bottom: 1px solid var(--fg-faint);
}

.prose th { color: var(--fg); font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; }

.prose img { display: block; margin: clamp(1.4rem, 4vw, 2rem) 0; }

/* --- Post furniture ---------------------------------------------------- */

.post__title {
	font-family: var(--font-display);
	font-weight: 900;
	font-size: clamp(1.6rem, 5.4vw, 3rem);
	line-height: 1.05;
	letter-spacing: 0.085em;
	margin-right: -0.085em;
	color: var(--fg);
	margin: 0 0 clamp(0.7rem, 2vw, 1rem);
	max-width: var(--measure);
	text-transform: uppercase;
}

.post__stamp {
	font-size: clamp(0.62rem, 1.15vw, 0.72rem);
	letter-spacing: 0.19em;
	text-transform: uppercase;
	color: var(--fg-dim);
	margin: 0 0 clamp(2.2rem, 6vw, 3.2rem);
}

/* ============================================================================
   Comments
   ========================================================================= */

.comments { max-width: var(--measure); margin-top: clamp(3rem, 8vw, 5rem); }

.comments__heading,
.section-heading {
	font-size: clamp(0.66rem, 1.1vw, 0.74rem);
	font-weight: 700;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--fg);
	margin: 0 0 clamp(1.2rem, 3vw, 1.8rem);
	padding-bottom: 0.9rem;
	border-bottom: 1px solid var(--fg-faint);
}

.comment { padding: clamp(1rem, 2.6vw, 1.4rem) 0; border-bottom: 1px solid var(--fg-faint); }

.comment__body {
	font-size: clamp(0.72rem, 1.25vw, 0.82rem);
	letter-spacing: 0.06em;
	line-height: 2;
	color: var(--fg-body);
	margin: 0 0 0.5rem;
	/* Comments are user text: never let a long token widen the page. */
	overflow-wrap: anywhere;
}

.comment__meta {
	font-size: clamp(0.58rem, 1vw, 0.66rem);
	letter-spacing: 0.19em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.38);
	margin: 0;
}

.comments__empty { color: var(--fg-dim); font-size: clamp(0.7rem, 1.2vw, 0.8rem); letter-spacing: 0.06em; }

/* ============================================================================
   Forms and controls
   Hairline borders, transparent fills. Nothing in this system takes a fill.
   ========================================================================= */

.form { margin-top: clamp(2.4rem, 6vw, 3.4rem); max-width: var(--measure); }

.field { margin-bottom: clamp(1.1rem, 3vw, 1.5rem); }

.field__label {
	display: block;
	font-size: clamp(0.6rem, 1vw, 0.68rem);
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--fg-dim);
	margin-bottom: 0.6rem;
}

.input, .textarea {
	width: 100%;
	font-family: var(--font-mono);
	font-size: clamp(0.72rem, 1.25vw, 0.82rem);
	letter-spacing: 0.06em;
	line-height: 1.8;
	color: var(--fg);
	background: transparent;
	border: 1px solid var(--fg-faint);
	border-radius: 0;
	padding: 0.7rem 0.9rem;
	transition: border-color 0.45s var(--ease);
}

.input::placeholder, .textarea::placeholder { color: rgba(255, 255, 255, 0.28); }
.input:hover, .textarea:hover { border-color: var(--fg-dim); }
.input:focus, .textarea:focus { outline: none; border-color: var(--fg); }

.textarea { resize: vertical; min-height: 7rem; }

.btn {
	display: inline-block;
	font-family: var(--font-mono);
	font-size: clamp(0.62rem, 1vw, 0.7rem);
	font-weight: 500;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--fg-dim);
	background: transparent;
	border: 1px solid var(--fg-faint);
	border-radius: 0;
	padding: 0.75em 1.6em;
	cursor: pointer;
	text-decoration: none;
	transition: color 0.45s var(--ease), border-color 0.45s var(--ease);
}

.btn:hover { color: var(--fg); border-color: var(--fg-dim); }
.btn:focus-visible { color: var(--fg); border-color: var(--fg); outline: none; }
.btn:disabled { opacity: 0.35; cursor: default; }

/* The single sanctioned accent: this is the one action on a post page. */
.btn--signal { color: var(--signal); border-color: var(--signal-faint); }
.btn--signal:hover, .btn--signal:focus-visible { color: var(--signal); border-color: var(--signal-soft); }

/* Honeypot: hidden from people, irresistible to bots. Not `display:none`,
   which some bots skip. */
.hp {
	position: absolute;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.notice {
	font-size: clamp(0.66rem, 1.1vw, 0.74rem);
	letter-spacing: 0.12em;
	color: var(--fg-dim);
	border-left: 1px solid var(--fg-faint);
	padding-left: 1rem;
	margin: 0 0 clamp(1.4rem, 3vw, 2rem);
}

/* ============================================================================
   Support banner
   ========================================================================= */

.support {
	max-width: var(--measure);
	margin-top: clamp(3rem, 8vw, 5rem);
	padding-top: clamp(1.2rem, 3vw, 1.8rem);
	border-top: 1px solid var(--fg-faint);
}

.support__link {
	font-size: clamp(0.62rem, 1vw, 0.7rem);
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--fg-dim);
	text-decoration: none;
	transition: color 0.45s var(--ease);
}

.support__link:hover, .support__link:focus-visible { color: var(--fg); }

/* ============================================================================
   Footer
   ========================================================================= */

.footer {
	padding-top: clamp(1.6rem, 4vw, 2.4rem);
	padding-bottom: clamp(1.6rem, 4vw, 2.4rem);
	border-top: 1px solid var(--fg-faint);
	max-width: 74rem;
}

.legal-note {
	font-size: clamp(0.58rem, 0.95vw, 0.66rem);
	letter-spacing: 0.14em;
	line-height: 2;
	/* Off-white, not the 0.38 metadata grey - it is a disclaimer that should be
	   readable, and at 0.38 next to full-white copy it read as disabled text. */
	color: var(--fg-body);
	margin: 0;
	max-width: 68ch;
}

/* In the aside it needs its own rule above it; in the footer the footer's
   own border already provides one. */
.aside-block--legal {
	padding-top: clamp(1.2rem, 3vw, 1.7rem);
	border-top: 1px solid var(--fg-faint);
}

/* ============================================================================
   Utility
   ========================================================================= */

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

:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

/* ============================================================================
   Motion
   Identity first, then meaning, then chrome. Chrome catches up to the page.
   ========================================================================= */

@keyframes rise-in {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: none; }
}

@keyframes wordmark-in {
	from { opacity: 0; filter: blur(22px); transform: translateY(14px) scale(0.975); }
	to   { opacity: 1; filter: blur(0);    transform: none; }
}

.page-title, .post__title { opacity: 0; animation: wordmark-in 1.9s var(--ease) 0.25s forwards; }
.post__stamp             { opacity: 0; animation: rise-in 1.3s var(--ease) 0.85s forwards; }
.prose, .link-list, .reader { opacity: 0; animation: rise-in 1.3s var(--ease) 0.95s forwards; }
.aside-block             { opacity: 0; animation: rise-in 1.3s var(--ease) 1.05s forwards; }
.comments, .form         { opacity: 0; animation: rise-in 1.1s var(--ease) 1.2s forwards; }
.header                  { opacity: 0; animation: rise-in 1.1s var(--ease) 1.55s forwards; }
.footer, .support        { opacity: 0; animation: rise-in 1.1s var(--ease) 1.6s forwards; }

@media (prefers-reduced-motion: reduce) {
	.grain { animation: none; }

	/* Content still appears; it just stops moving. */
	@keyframes rise-in    { from { opacity: 0; } to { opacity: 1; } }
	@keyframes wordmark-in { from { opacity: 0; } to { opacity: 1; } }

	.page-title, .post__title, .post__stamp, .prose, .link-list, .aside-block,
	.reader, .comments, .form, .header, .footer, .support {
		animation-duration: 0.6s !important;
		animation-delay: 0s !important;
	}

	* { transition-duration: 0.01ms !important; }
}

/* ============================================================================
   One breakpoint. Everything else is fluid via clamp().
   ========================================================================= */

@media (max-width: 30rem) {
	.header { gap: 1rem; }
	.nav { gap: 1.35rem; }
	.nav__link { padding: 0.55em 0.3em; }
	.link-list__link { flex-direction: column; gap: 0.3rem; }
}
