@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,700;1,9..144,400;1,9..144,700&family=IBM+Plex+Sans:wght@300;400;500&family=IBM+Plex+Mono:wght@400&display=swap");

:root {
	color-scheme: light;

	/* ── Neutrals ── */
	--background: #f5f0e8;                                     /* cream (existing) */
	--foreground: #1a1a1a;                                     /* ink (existing) */
	--ink: var(--foreground);                                  /* alias for readability */
	--ink-2: #2f2b26;                                          /* warm charcoal — <strong>, subheads */
	--ash: #6b6560;                                            /* warm grey — captions, filenames, metadata */
	--mist: color-mix(in srgb, var(--foreground) 45%, transparent);   /* subtle, disabled */
	--muted-foreground: color-mix(in srgb, var(--foreground) 55%, transparent);   /* existing */

	/* ── Surfaces (background depth) ── */
	--surface: var(--background);                              /* alias for background */
	--surface-raised: #faf7f0;                                 /* lifted cards, elevated callouts */
	--surface-sunk: #ebe3d3;                                   /* inputs, wells, quote insets */

	/* ── Borders ── */
	--border: color-mix(in srgb, var(--accent) 15%, transparent);   /* existing subtle rule */
	--border-strong: color-mix(in srgb, var(--accent) 30%, transparent);

	/* ── Primary — purple ── */
	--accent: #7b5ea7;                                         /* existing */
	--accent-light: #c4b1d9;                                   /* existing */
	--accent-dark: #5a3f80;                                    /* hover / pressed / deep emphasis */
	--accent-foreground: #f5f0e8;                              /* existing */
	--accent-wash: color-mix(in srgb, var(--accent-light) 15%, var(--background));

	/* ── Secondary — dawn gold (new) ──
	   Pairs naturally with purple (violet + gold is the classic sacred
	   pairing) and matches the warm golden-hour light in every
	   photograph in the doc. Use for callouts, badges, or accents that
	   should feel adjacent to — not competing with — the primary. */
	--accent-2: #b8955a;                                       /* dawn gold */
	--accent-2-light: #d8bc86;                                 /* honey */
	--accent-2-dark: #8a6d3f;                                  /* grounded gold */
	--accent-2-foreground: #f5f0e8;
	--accent-2-wash: color-mix(in srgb, var(--accent-2-light) 15%, var(--background));

	/* ── Semantic states ──
	   Muted rather than saturated so they read as considered on cream.
	   Each has a matching -wash for subtle backgrounds. */
	--success: #6b8e6b;                                        /* calm sage — confirmations, "done" */
	--success-wash: color-mix(in srgb, var(--success) 12%, var(--background));
	--warning: #c99b4a;                                        /* warm amber — sits between accents */
	--warning-wash: color-mix(in srgb, var(--warning) 12%, var(--background));
	--info: #6a89a8;                                           /* dawn blue — analogous, quiet */
	--info-wash: color-mix(in srgb, var(--info) 12%, var(--background));
	--danger: #b04a4a;                                         /* dignified brick — errors, destructive */
	--danger-wash: color-mix(in srgb, var(--danger) 12%, var(--background));

	--font-display: "Fraunces", Georgia, serif;
	--font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
	--font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html {
	height: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--background);
	color: var(--foreground);
	font-family: var(--font-body);
	font-weight: 300;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
	margin: 0;
	font-family: var(--font-display);
	font-weight: 700;
	font-optical-sizing: auto;
	letter-spacing: -0.02em;
	color: var(--foreground);
}

h1 {
	line-height: 1.05;
}
h2 {
	line-height: 1.1;
}
h3 {
	line-height: 1.2;
	letter-spacing: -0.01em;
}

em {
	font-family: var(--font-display);
	font-style: italic;
	color: var(--accent);
}

a {
	color: var(--accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}
a:hover {
	color: color-mix(in srgb, var(--accent) 75%, black);
}

.eyebrow,
.mono {
	font-family: var(--font-mono);
	font-size: clamp(0.75rem, 1vw, 0.95rem);
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: var(--accent);
}

hr {
	border: 0;
	border-top: 1px solid var(--border);
	margin: 2rem 0;
}

code,
pre,
kbd {
	font-family: var(--font-mono);
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.2s !important;
	}
}

/* Return-to-library chrome — injected automatically into every HTML file
   served from /library via HTMLRewriter in functions/library/[name].ts.
   Fixed to top-left, backdrop-blurred pill so it remains legible over
   any document content. */
.return-to-library {
	position: fixed;
	top: clamp(0.75rem, 2vh, 1.25rem);
	left: clamp(0.75rem, 2vw, 1.25rem);
	z-index: 1000;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.45rem 0.95rem;
	font-family: var(--font-mono);
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--accent);
	background: color-mix(in srgb, var(--background) 82%, transparent);
	backdrop-filter: saturate(1.2) blur(10px);
	-webkit-backdrop-filter: saturate(1.2) blur(10px);
	border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
	border-radius: 999px;
	text-decoration: none;
	box-shadow: 0 2px 14px -6px color-mix(in srgb, var(--accent) 25%, transparent);
	transition:
		color 0.15s ease,
		border-color 0.15s ease,
		transform 0.15s ease;
}
.return-to-library:hover {
	color: var(--foreground);
	border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
	transform: translateX(-1px);
}
.return-to-library .arrow {
	font-family: var(--font-body);
	font-size: 0.9em;
	line-height: 1;
	transform: translateY(-1px);
}
@media print {
	.return-to-library { display: none; }
}

/* ═════════════════════════════════════════════════════════════════════
   LONG-FORM DOCUMENT PRIMITIVES
   Shared vocabulary for strategy docs, briefs, and other reading pieces
   uploaded to /library. Compose on top of an .doc-article container.
   ═════════════════════════════════════════════════════════════════════ */

.doc-article {
	max-width: 68ch;
	font-size: clamp(1rem, 1.15vw, 1.125rem);
	line-height: 1.65;
	color: color-mix(in srgb, var(--foreground) 88%, transparent);
}

.doc-article p {
	margin: 0 0 1.25rem;
}

.doc-article strong {
	font-weight: 500;
	color: var(--ink-2);
}

/* Chapter heading pattern: number · title, separated by a soft rule */
.chapter-heading {
	display: flex;
	gap: 1.25rem;
	align-items: baseline;
	margin: 5rem 0 2rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--border);
}
.chapter-heading .num {
	font-family: var(--font-mono);
	font-size: 0.85rem;
	color: var(--accent-2-dark);
	letter-spacing: 0.15em;
	min-width: 2.5rem;
	flex-shrink: 0;
}
.chapter-heading .title {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: clamp(1.75rem, 3vw, 2.5rem);
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--foreground);
	margin: 0;
}

/* Section subheading (h3): quieter than chapter, still with mono eyebrow if used */
.doc-article h3 {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: clamp(1.2rem, 1.6vw, 1.4rem);
	line-height: 1.25;
	margin: 2.5rem 0 1rem;
	color: var(--foreground);
}

/* Callout: meta-instructional block (like "How to read this draft").
   Default reads as primary (purple). Add a modifier for semantic flavor:
   .callout.callout--gold / --success / --warning / --info / --danger */
.callout {
	position: relative;
	border-left: 3px solid var(--accent);
	background: var(--accent-wash);
	padding: 1.25rem 1.5rem;
	margin: 2rem 0;
	border-radius: 0 6px 6px 0;
}
.callout > .callout-label {
	display: block;
	font-family: var(--font-mono);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.15em;
	color: var(--accent);
	margin-bottom: 0.5rem;
}
.callout p:last-child {
	margin-bottom: 0;
}

.callout.callout--gold {
	border-left-color: var(--accent-2);
	background: var(--accent-2-wash);
}
.callout.callout--gold > .callout-label { color: var(--accent-2-dark); }

.callout.callout--success {
	border-left-color: var(--success);
	background: var(--success-wash);
}
.callout.callout--success > .callout-label { color: var(--success); }

.callout.callout--warning {
	border-left-color: var(--warning);
	background: var(--warning-wash);
}
.callout.callout--warning > .callout-label { color: var(--warning); }

.callout.callout--info {
	border-left-color: var(--info);
	background: var(--info-wash);
}
.callout.callout--info > .callout-label { color: var(--info); }

.callout.callout--danger {
	border-left-color: var(--danger);
	background: var(--danger-wash);
}
.callout.callout--danger > .callout-label { color: var(--danger); }

/* Voice-quote: first-person voice, italic Fraunces, hangs to the left */
.voice-quote {
	font-family: var(--font-display);
	font-style: italic;
	font-weight: 400;
	font-size: clamp(1.25rem, 2vw, 1.65rem);
	line-height: 1.4;
	color: color-mix(in srgb, var(--foreground) 82%, transparent);
	border-left: 2px solid var(--accent);
	padding: 0.35rem 0 0.35rem 1.5rem;
	margin: 2rem 0;
	max-width: 55ch;
}

.doc-article blockquote {
	margin: 2rem 0;
	padding: 0.35rem 0 0.35rem 1.5rem;
	border-left: 2px solid var(--accent);
	color: color-mix(in srgb, var(--foreground) 78%, transparent);
	font-family: var(--font-display);
	font-style: italic;
	font-size: 1.15rem;
}
.doc-article blockquote strong {
	font-family: var(--font-body);
	font-style: normal;
	font-weight: 500;
	color: var(--accent);
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	display: block;
	margin-bottom: 0.35rem;
}

/* Decision pill: for [OPEN] markers scattered across the doc.
   Gold (accent-2) rather than purple so "decision needed" reads as
   distinct from active-navigation highlighting elsewhere. */
.decision {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	font-family: var(--font-mono);
	font-size: 0.68em;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--accent-2-dark);
	background: var(--accent-2-wash);
	border: 1px solid color-mix(in srgb, var(--accent-2) 40%, transparent);
	border-radius: 999px;
	padding: 0.2em 0.7em;
	vertical-align: middle;
	white-space: nowrap;
}

/* Anchor/tagline: standout single-line quote (like "Five women. Solid ground.") */
.anchor-line {
	font-family: var(--font-display);
	font-style: italic;
	font-weight: 700;
	font-size: clamp(1.5rem, 2.5vw, 2rem);
	line-height: 1.2;
	color: var(--accent);
	text-align: center;
	margin: 2.5rem auto;
	max-width: 20ch;
	letter-spacing: -0.01em;
}

/* Definition-style paragraph: "**Term.** ...text" hangs the term */
.doc-article .term {
	font-weight: 500;
	color: var(--foreground);
	margin-right: 0.35rem;
}

/* Poetic list: generous line-height, mono-italic feel (like the Shame Script bank) */
.poetic-list {
	list-style: none;
	padding: 0;
	margin: 2rem 0;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	font-family: var(--font-display);
	font-style: italic;
	font-size: 1.1rem;
	color: color-mix(in srgb, var(--foreground) 80%, transparent);
}
.poetic-list li::before {
	content: "· ";
	color: var(--accent);
	font-weight: 700;
	font-style: normal;
	margin-right: 0.4em;
}
.poetic-list li.the-line {
	color: var(--accent);
	font-weight: 700;
	padding-top: 0.5rem;
	margin-top: 0.5rem;
	border-top: 1px solid var(--border);
}

/* Standard lists in a doc-article */
.doc-article ul:not(.poetic-list):not(.doc-toc-list),
.doc-article ol {
	padding-left: 1.5rem;
	margin: 0 0 1.5rem;
}
.doc-article ul:not(.poetic-list):not(.doc-toc-list) li,
.doc-article ol li {
	margin: 0.4rem 0;
}
.doc-article ul li::marker {
	color: var(--accent);
}

/* Tables */
.doc-article table {
	width: 100%;
	border-collapse: collapse;
	margin: 2rem 0;
	font-size: 0.95rem;
	font-family: var(--font-body);
}
.doc-article th,
.doc-article td {
	text-align: left;
	padding: 0.85rem 1rem 0.85rem 0;
	border-bottom: 1px solid var(--border);
	vertical-align: top;
}
.doc-article th {
	font-family: var(--font-mono);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--accent);
	font-weight: 500;
	border-bottom: 1px solid var(--accent);
}

/* Horizontal rule with center accent */
.doc-article hr {
	border: none;
	margin: 4rem auto;
	height: 1px;
	background: var(--border);
	width: 40%;
	position: relative;
	overflow: visible;
}
.doc-article hr::after {
	content: "·";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -60%);
	background: var(--background);
	padding: 0 0.75rem;
	color: var(--accent);
	font-size: 1.5rem;
	line-height: 1;
}

/* Sidenote / soft caption paragraph (italic small) */
.doc-article .sidenote {
	font-style: italic;
	font-size: 0.9rem;
	color: var(--ash);
	margin: 1.5rem 0;
}

/* Real document image — used when a placeholder is replaced by an
   actual asset. Full-width, warm rounding, soft accent-tinted shadow
   so the image feels like it belongs to the doc's palette. */
.doc-image {
	margin: 3rem 0;
}
.doc-image img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 12px;
	box-shadow: 0 8px 40px -18px color-mix(in srgb, var(--accent) 30%, transparent);
}
.doc-image figcaption {
	margin-top: 0.85rem;
	font-family: var(--font-body);
	font-style: italic;
	font-size: 0.9rem;
	color: var(--muted-foreground);
	line-height: 1.5;
	text-align: center;
	max-width: 55ch;
	margin-left: auto;
	margin-right: auto;
}

/* Image placeholder: explicit "insert graphic here" chrome for drafts */
.image-placeholder {
	margin: 3rem 0;
}
.image-placeholder .box {
	border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent);
	background: color-mix(in srgb, var(--accent-light) 8%, var(--background));
	border-radius: 10px;
	padding: 2rem 2rem 1.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	min-height: 200px;
	justify-content: center;
	position: relative;
}
.image-placeholder .box::before {
	content: "◇";
	position: absolute;
	top: 0.85rem;
	right: 1rem;
	font-size: 1.2rem;
	color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.image-placeholder .label {
	font-family: var(--font-mono);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.15em;
	color: var(--accent);
}
.image-placeholder .caption {
	font-family: var(--font-body);
	font-size: 0.95rem;
	color: color-mix(in srgb, var(--foreground) 70%, transparent);
	margin: 0;
	line-height: 1.55;
	font-style: italic;
}
.image-placeholder .caption strong {
	font-family: var(--font-body);
	font-style: normal;
	font-weight: 500;
	color: var(--foreground);
	display: block;
	margin-bottom: 0.35rem;
	font-size: 0.9rem;
	letter-spacing: 0.01em;
}

/* Reveal on scroll — subtle fade + rise on a single element */
.reveal-on-scroll {
	opacity: 0;
	transform: translateY(24px);
	transition:
		opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
		transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
	will-change: opacity, transform;
}
.reveal-on-scroll.revealed {
	opacity: 1;
	transform: translateY(0);
}

/* Reveal children with a staggered fade + rise.
   Cheaper than observing every element individually — one
   IntersectionObserver per parent (usually a chapter/section), then CSS
   transition-delay staggers the direct children. */
.reveal-children > * {
	opacity: 0;
	transform: translateY(20px);
	transition:
		opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
		transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
	will-change: opacity, transform;
}
.reveal-children.revealed > * {
	opacity: 1;
	transform: translateY(0);
}
.reveal-children.revealed > :nth-child(1) { transition-delay: 0.02s; }
.reveal-children.revealed > :nth-child(2) { transition-delay: 0.10s; }
.reveal-children.revealed > :nth-child(3) { transition-delay: 0.18s; }
.reveal-children.revealed > :nth-child(4) { transition-delay: 0.26s; }
.reveal-children.revealed > :nth-child(5) { transition-delay: 0.34s; }
.reveal-children.revealed > :nth-child(6) { transition-delay: 0.42s; }
.reveal-children.revealed > :nth-child(n + 7) { transition-delay: 0.50s; }

@media (prefers-reduced-motion: reduce) {
	.reveal-on-scroll,
	.reveal-on-scroll.revealed,
	.reveal-children > *,
	.reveal-children.revealed > * {
		opacity: 1;
		transform: none;
		transition: none;
	}
}
