/* ============================================================
 * Neurosaver — warm editorial layer
 *
 * A shared visual language for light and dark themes. The base files keep
 * component layout and behaviour; this layer controls atmosphere, reading
 * rhythm, typography and surface hierarchy across every public template.
 * ============================================================ */

/* ---------- PAGE ATMOSPHERE + READING BASICS ---------- */
html {
	scroll-padding-top: calc(var(--header-h) + 1.25rem);
}

html,
body {
	background-color: var(--bg);
}

body {
	min-height: 100vh;
	background-image:
		radial-gradient(circle at 8% -8%, var(--ambient-warm), transparent 32rem),
		radial-gradient(circle at 96% 9%, var(--ambient-cool), transparent 30rem);
	background-repeat: no-repeat;
	color: var(--text);
	line-height: 1.65;
}

p,
li,
figcaption {
	text-wrap: pretty;
}

h1,
h2,
h3,
.display,
.section-title,
.section-head__title {
	font-family: var(--font-display);
	font-weight: 700;
	letter-spacing: -0.018em;
	text-wrap: balance;
}

::selection {
	background: color-mix(in srgb, var(--accent) 78%, var(--bg-elev-1));
	color: var(--accent-fg);
}

:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
}

.eyebrow {
	color: var(--accent);
	font-weight: 650;
	letter-spacing: .1em;
}

.muted {
	color: var(--text-muted);
}

/* ---------- HEADER ---------- */
.site-header {
	background: var(--header-bg);
	border-bottom-color: color-mix(in srgb, var(--border) 82%, transparent);
	box-shadow: 0 1px 0 color-mix(in srgb, var(--surface-glow) 45%, transparent);
	backdrop-filter: saturate(115%) blur(18px);
	-webkit-backdrop-filter: saturate(115%) blur(18px);
}

.site-header__inner {
	gap: 1.25rem;
}

.site-header__logo {
	gap: .7rem;
}

.site-header__logo-icon {
	width: 34px;
	height: 34px;
	filter: drop-shadow(0 5px 12px color-mix(in srgb, var(--accent) 22%, transparent));
}

.site-header__logo-wordmark {
	gap: .42rem;
}

.site-header__logo-name {
	font-family: var(--font-display);
	font-size: 1.18rem;
	letter-spacing: -.025em;
}

.site-header__logo-suffix,
.site-footer__tag {
	background-image: linear-gradient(110deg, var(--accent), var(--accent-end));
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .035em;
}

.site-nav {
	gap: .12rem;
	margin-inline-start: 1rem;
}

.site-nav__item {
	position: relative;
	padding: .55rem .7rem;
	border-radius: var(--r-sm);
	font-weight: 520;
}

.site-nav__item:hover {
	background: var(--surface-soft);
}

.site-nav__item.is-active {
	background: var(--accent-tint);
	color: var(--accent-bright);
}

.site-nav__item.is-active::after {
	position: absolute;
	right: .7rem;
	bottom: .25rem;
	left: .7rem;
	height: 1px;
	background: currentColor;
	content: '';
	opacity: .45;
}

.site-search__input {
	width: 210px;
	padding: .55rem .9rem;
	background: color-mix(in srgb, var(--bg-elev-1) 84%, transparent);
	border-color: var(--border);
	border-radius: var(--r-md);
	box-shadow: inset 0 1px 0 var(--surface-glow);
}

.site-search__input:focus {
	background: var(--bg-elev-1);
	box-shadow: 0 0 0 3px var(--accent-tint), inset 0 1px 0 var(--surface-glow);
}

.theme-toggle,
.site-search-toggle,
.site-nav-toggle {
	border: 1px solid var(--border);
	background: var(--surface-soft);
	box-shadow: inset 0 1px 0 var(--surface-glow);
}

.theme-toggle:hover,
.site-search-toggle:hover,
.site-nav-toggle:hover {
	border-color: var(--border-strong);
	background: var(--bg-elev-1);
}

/* ---------- HEROES + ACTIONS ---------- */
.home-hero,
.library-hero,
.catalog-hero {
	position: relative;
}

.home-hero {
	padding-block: clamp(4.5rem, 9vw, 7.25rem) clamp(2.5rem, 5vw, 4rem);
}

.home-hero::after {
	display: block;
	width: min(11rem, 30vw);
	height: 1px;
	margin: clamp(2.75rem, 5vw, 4rem) auto 0;
	background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
	content: '';
}

.home-hero__title,
.library-hero__title,
.catalog-hero__title,
.term__title,
.guide__title,
.news__title,
.about-hero__name {
	font-family: var(--font-display);
	font-weight: 700;
	letter-spacing: -.028em;
}

.home-hero__title {
	max-width: 13ch;
	margin-inline: auto;
	font-size: clamp(2.75rem, 6.8vw, 5.25rem);
	line-height: .99;
}

.home-hero__accent,
.library-hero__accent {
	background-image: linear-gradient(105deg, var(--accent-bright), var(--accent) 54%, var(--accent-end));
}

.home-hero__deck,
.library-hero__deck,
.catalog-hero__deck {
	line-height: 1.72;
}

.btn,
.random-cta {
	border-radius: var(--r-md);
	font-weight: 650;
	letter-spacing: -.005em;
}

.btn {
	min-height: 44px;
	padding-inline: 1.2rem;
}

.btn--primary,
.catalog__filters-toggle,
.error-search__submit,
.nsl-subscribe__submit {
	background: linear-gradient(135deg, var(--accent-bright), var(--accent));
	color: var(--accent-fg);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 10px 22px color-mix(in srgb, var(--accent) 18%, transparent);
}

.btn--primary:hover,
.error-search__submit:hover {
	background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 82%, var(--text)));
	transform: translateY(-1px);
}

.btn--ghost {
	background: var(--surface-soft);
	border-color: var(--border);
	box-shadow: inset 0 1px 0 var(--surface-glow);
}

/* ---------- SECTION RHYTHM ---------- */
.section-head {
	align-items: center;
	padding-bottom: .95rem;
	border-bottom: 1px solid var(--border);
}

.section-head__title,
.section-title,
.library__title {
	font-weight: 700;
}

.section-head__more {
	padding: .38rem .65rem;
	border-radius: var(--r-sm);
	color: var(--accent-bright);
	font-weight: 650;
}

.section-head__more:hover {
	background: var(--accent-tint);
	color: var(--accent-bright);
}

.home-news,
.home-guides,
.home-sections,
.home-cta {
	padding-block: clamp(2.75rem, 6vw, 5rem);
}

.home-news--top {
	padding-top: 1.25rem;
}

/* ---------- SHARED SURFACES + CARDS ---------- */
:where(
	.feature-card,
	.home-section-card,
	.guide-tile,
	.news-tile,
	.related-card,
	.next-step,
	.home-cta__card,
	.search-featured,
	.about-links a,
	.catalog-card
) {
	background: linear-gradient(155deg, var(--surface-glow), transparent 48%), var(--bg-elev-1);
	border-color: var(--border);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-sm);
}

:where(
	.feature-card,
	.home-section-card,
	.guide-tile,
	.news-tile,
	.related-card,
	.next-step,
	.home-cta__card,
	.search-featured,
	.about-links a,
	.catalog-card
):hover {
	background: linear-gradient(155deg, var(--surface-glow), transparent 55%), var(--bg-elev-1);
	border-color: color-mix(in srgb, var(--accent) 68%, var(--border));
	box-shadow: var(--shadow-md);
	transform: translateY(-2px);
}

.feature-card__title,
.home-section-card__title,
.guide-tile__title,
.news-tile__title,
.related-card__title,
.next-step__title,
.home-cta__title,
.catalog-card__title {
	font-family: var(--font-display);
	font-weight: 700;
	letter-spacing: -.015em;
}

.home-section-card,
.home-cta__card {
	padding: clamp(1.5rem, 3vw, 2rem);
}

.home-section-card__icon,
.home-cta__icon {
	background: var(--accent-tint);
	border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
	color: var(--accent-bright);
	box-shadow: inset 0 1px 0 var(--surface-glow);
}

.guide-tile__cover,
.news-tile__cover,
.feature-card__image,
.catalog-card__media {
	background: var(--bg-elev-2);
}

.guide-tile__body,
.news-tile__body {
	gap: .65rem;
}

.guide-tile__kicker,
.news-tile__topic,
.feature-card__kicker,
.home-section-card__cta {
	color: var(--accent-bright);
}

.guide-tile__audience,
.news__topic-pill,
.guide__kicker {
	background: var(--accent-tint);
	border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
	color: var(--accent-bright);
}

/* ---------- ARCHIVES, LISTS + FILTERS ---------- */
.filter-chip,
.featured-slider__mode,
.map-legend__item,
.catalog__chip,
.pagination .page-numbers {
	background: var(--surface-soft);
	border-color: var(--border);
	box-shadow: inset 0 1px 0 var(--surface-glow);
}

.filter-chip.is-active,
.featured-slider__mode.is-active,
.catalog__chip.is-active,
.pagination .page-numbers.current {
	background: var(--accent-tint);
	border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
	color: var(--accent-bright);
}

.term-rows {
	border-top-color: var(--border-strong);
}

.term-row {
	padding-block: 1.35rem;
	border-bottom-color: var(--border);
}

.term-row:hover {
	background: linear-gradient(90deg, var(--surface-soft), transparent 72%);
}

.term-row__title,
.term-list__link {
	font-family: var(--font-display);
	font-weight: 700;
}

.term-row__num {
	color: var(--accent);
}

/* ---------- ARTICLE HEADERS + READING COLUMN ---------- */
.term__breadcrumbs {
	padding-block: 1.4rem;
	letter-spacing: .075em;
}

.term__hero,
.guide__hero,
.news__hero {
	position: relative;
}

.term__hero {
	padding-block: clamp(2rem, 5vw, 4rem) 1.25rem;
}

.term__title {
	max-width: 17ch;
	font-size: clamp(3rem, 7vw, 6.3rem);
	line-height: .94;
}

.term__subtitle {
	font-family: var(--font-display);
	font-style: italic;
}

.term__meta {
	gap: .25rem;
	padding: .8rem;
	background: var(--surface-soft);
	border: 1px solid var(--border);
	border-radius: var(--r-md);
	box-shadow: inset 0 1px 0 var(--surface-glow);
}

.term__meta-cell {
	padding: .35rem 1rem;
	border-inline-end-color: var(--border);
}

.term__body-grid {
	gap: clamp(2.5rem, 5vw, 4.5rem);
}

.term__deck {
	max-width: 52ch;
	font-family: var(--font-display);
	font-size: clamp(1.25rem, 2.2vw, 1.6rem);
	font-weight: 400;
	line-height: 1.55;
}

.term__content,
.guide__body,
.news__body {
	font-size: clamp(1.035rem, .98rem + .22vw, 1.15rem);
	line-height: 1.78;
}

.term__content {
	max-width: 67ch;
}

.guide__body,
.news__body {
	max-width: 46rem;
}

:where(.term__content, .guide__body, .news__body) h2 {
	margin-top: clamp(3rem, 7vw, 4.5rem);
	margin-bottom: 1rem;
	font-family: var(--font-display);
	font-size: clamp(1.75rem, 3vw, 2.35rem);
	font-weight: 700;
	line-height: 1.18;
	letter-spacing: -.018em;
}

:where(.term__content, .guide__body, .news__body) h3 {
	margin-top: 2.4rem;
	margin-bottom: .8rem;
	font-family: var(--font-display);
	font-size: clamp(1.3rem, 2vw, 1.62rem);
	font-weight: 700;
	line-height: 1.3;
}

:where(.term__content, .guide__body, .news__body) p {
	margin-bottom: 1.25rem;
}

:where(.term__content, .guide__body, .news__body) li::marker {
	color: var(--accent);
	font-weight: 700;
}

:where(.term__content, .guide__body, .news__body) ul {
	list-style: disc;
}

:where(.term__content, .guide__body, .news__body) ol {
	list-style: decimal;
}

:where(.term__content, .guide__body, .news__body) a {
	color: var(--accent-bright);
	text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
	text-decoration-thickness: 1px;
	text-underline-offset: .18em;
}

:where(.term__content, .guide__body, .news__body) blockquote {
	position: relative;
	margin-block: 2rem;
	padding: 1.35rem 1.5rem 1.35rem 1.7rem;
	background: linear-gradient(135deg, var(--accent-tint), transparent), var(--bg-elev-1);
	border: 1px solid var(--border);
	border-inline-start: 3px solid var(--accent);
	border-radius: 0 var(--r-md) var(--r-md) 0;
	box-shadow: var(--shadow-sm);
	color: var(--text-muted);
}

:where(.term__content, .guide__body, .news__body) code,
:where(.term__content, .guide__body, .news__body) kbd,
:where(.term__content, .guide__body, .news__body) pre {
	background: var(--bg-elev-1);
	border-color: var(--border);
}

.term__cover img.term__cover-img,
.guide__body figure,
.news__figure,
.term-video {
	border-color: var(--border);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-md);
}

.term__cover img.term__cover-img {
	background: transparent;
}

/* ---------- CALLOUTS + TABLES ---------- */
:where(.term__content, .news__body, .guide__body) .nsl-callout {
	gap: 1rem;
	padding: 1.2rem 1.3rem;
	background: linear-gradient(135deg, var(--callout-bg), transparent 80%), var(--bg-elev-1);
	border: 1px solid color-mix(in srgb, var(--callout-accent, var(--accent)) 28%, var(--border));
	border-inline-start-width: 1px;
	border-radius: var(--r-md);
	box-shadow: var(--shadow-sm);
}

:where(.term__content, .news__body, .guide__body) .nsl-callout__title {
	letter-spacing: .065em;
}

:where(.term__content, .news__body, .guide__body) table {
	background: var(--bg-elev-1);
	border-color: var(--border);
	box-shadow: var(--shadow-sm);
}

:where(.term__content, .news__body, .guide__body) th {
	background: var(--bg-elev-2);
	font-family: var(--font-display);
}

/* ---------- GUIDE TOC + RELATED READING ---------- */
.guide__hero {
	padding-block: clamp(2rem, 6vw, 4.5rem);
}

.guide__title,
.news__title {
	line-height: 1.04;
}

.guide__lead,
.news__lead {
	line-height: 1.62;
}

.guide__toc {
	background: linear-gradient(155deg, var(--surface-glow), transparent 55%), var(--bg-elev-1);
	border-color: var(--border);
	box-shadow: var(--shadow-sm);
}

.guide__toc-link {
	border-left-color: var(--border);
	border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.guide__toc-link.is-active {
	background: var(--accent-tint);
	border-left-color: var(--accent);
	color: var(--accent-bright);
}

.term__related-section,
.term__related-guides,
.term__adjacent,
.guide__hub {
	border-color: var(--border);
}

.related-grid,
.next-steps__grid {
	gap: 1.15rem;
}

/* ---------- SUBSCRIPTION ---------- */
.nsl-subscribe {
	background:
		radial-gradient(circle at 18% 0%, var(--ambient-warm), transparent 28rem),
		linear-gradient(180deg, var(--surface-soft), transparent),
		var(--bg);
	border-color: var(--border);
}

.nsl-subscribe__title,
.nsl-subscribe-result__title,
.about-cta__title {
	font-family: var(--font-display);
	font-weight: 700;
	letter-spacing: -.018em;
}

.nsl-subscribe__email {
	background: var(--bg-elev-1);
	border-color: var(--border);
	border-radius: var(--r-md);
	box-shadow: inset 0 1px 0 var(--surface-glow);
}

.nsl-subscribe__email:focus {
	box-shadow: 0 0 0 3px var(--accent-tint), inset 0 1px 0 var(--surface-glow);
}

.nsl-subscribe__submit {
	border-radius: var(--r-md);
}

.nsl-subscribe__gift,
.nsl-lead-modal__dialog {
	background: linear-gradient(155deg, var(--surface-glow), transparent 52%), var(--bg-elev-1);
	border-color: var(--border);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-lg);
}

/* ---------- CATALOG ---------- */
.catalog__toolbar,
.catalog__filters {
	background: color-mix(in srgb, var(--bg-elev-1) 94%, transparent);
	border-color: var(--border);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-sm);
}

.catalog__search,
.catalog__sort {
	background-color: var(--bg-elev-2);
	border-color: var(--border);
	border-radius: var(--r-md);
}

.catalog__search:focus-within,
.catalog__sort:focus {
	box-shadow: 0 0 0 3px var(--accent-tint);
}

.catalog-hero__count {
	color: var(--accent-bright);
}

/* ---------- CONNECTION MAP ---------- */
.map-canvas-wrap {
	background:
		radial-gradient(ellipse at 26% 18%, var(--ambient-warm), transparent 58%),
		radial-gradient(ellipse at 74% 82%, var(--ambient-cool), transparent 58%),
		var(--bg-elev-1);
	border-color: var(--border);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-md);
}

.map-tooltip,
.map-controls,
.map-hint {
	background: color-mix(in srgb, var(--bg-elev-1) 94%, transparent);
	border-color: var(--border);
	box-shadow: var(--shadow-md);
}

.map-tooltip__title {
	font-family: var(--font-display);
}

.nsl-node__label {
	stroke: var(--bg-elev-1);
}

/* ---------- FOOTER ---------- */
.site-footer {
	margin-top: clamp(4rem, 8vw, 7rem);
	padding-block: 2.5rem;
	background: linear-gradient(180deg, transparent, var(--surface-soft));
	border-top-color: var(--border);
}

.site-footer__logo {
	font-family: var(--font-display);
	font-size: 1.08rem;
}

.site-footer__copy {
	line-height: 1.65;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
	.site-header__inner {
		gap: .75rem;
	}

	.term__body-grid,
	.term__body-wrap:not(.has-cover) .term__body-grid {
		gap: 2.5rem;
	}
}

@media (max-width: 880px) {
	:root {
		--header-h: 64px;
	}

	.site-header__logo-name {
		font-size: 1.08rem;
	}

	.site-nav {
		background: var(--bg-elev-1);
		border-color: var(--border);
		box-shadow: var(--shadow-lg);
	}

	.home-hero {
		padding-top: 3.75rem;
	}

	.term__meta {
		padding: .65rem;
	}

	.guide__body {
		padding-inline: 0;
	}
}

@media (max-width: 560px) {
	body {
		background-image:
			radial-gradient(circle at 0 -2%, var(--ambient-warm), transparent 22rem),
			radial-gradient(circle at 100% 12%, var(--ambient-cool), transparent 20rem);
	}

	.site-header__logo-icon {
		width: 31px;
		height: 31px;
	}

	.site-header__logo-suffix {
		display: none;
	}

	.home-hero__title {
		font-size: clamp(2.6rem, 13vw, 4rem);
	}

	.term__title {
		font-size: clamp(2.65rem, 14vw, 4.4rem);
	}

	.term__meta-cell {
		padding-inline: .75rem;
	}

	.section-head {
		align-items: flex-start;
	}

	:where(.term__content, .guide__body, .news__body) blockquote,
	:where(.term__content, .news__body, .guide__body) .nsl-callout {
		padding: 1rem;
	}
}

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

@media (prefers-contrast: more) {
	:root {
		--border: var(--border-strong);
	}

	.site-nav__item,
	.site-search__input,
	.theme-toggle {
		font-weight: 650;
	}
}
