/* =====================================================================
 * Homepage layer (front-page.php only — enqueued on is_front_page()).
 *
 * Extends the brand tokens declared in style.css; never overrides the
 * post-body typography (the homepage has none). Ported from the
 * pipeline/preview-template/homepage.html prototype, plus hybrid-cover
 * rules: a real featured <img> fills the cover when a post has one, and
 * the generative dot-field SVG sits behind it as the fallback.
 *
 * Aesthetic: scientific-editorial. A quiet typographic grid with one bold
 * compositional move — generative dot-field cover art (a nod to vector-
 * field plotting) wherever a post carries no cover image.
 * ===================================================================== */

:root {
	--home-max: 1180px;
	--home-gutter: clamp(20px, 4vw, 56px);

	/* Per-topic accent palette — drives the dot-field cover, the corner
	 * accent, and the series tile band. Stays inside the brand triad. */
	--topic-julia:    #325CE8;   /* brand blue   */
	--topic-mri:      #63CABA;   /* brand teal   */
	--topic-python:   #8300E9;   /* brand purple */
	--topic-package:  #1f7a8c;   /* desaturated teal-blue */
	--topic-basics:   #f0a830;   /* warm accent — used sparingly */
	--topic-event:    #d2386c;   /* magenta-red — for one-off events  */

	--surface: var(--color-bg);
	--surface-raised: var(--color-bg-subtle);
	--surface-rule: var(--color-border);
	--hairline: rgba(20, 28, 48, 0.06);
}
:root[data-theme="dark"] {
	--hairline: rgba(180, 200, 240, 0.06);
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--hairline: rgba(180, 200, 240, 0.06);
	}
}

/* The homepage runs full-width — wider than the post column, but the
 * header/footer chrome is unchanged (shared from style.css). */
.home {
	max-width: var(--home-max);
	margin: 0 auto;
	padding: 0 var(--home-gutter) 96px;
}

/* ---------- Featured (asymmetric hero card) ---------------------- */
/* First element on the page now (the masthead was removed), so it carries
   the top spacing the masthead used to provide. */

.home-featured {
	display: grid;
	grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
	gap: clamp(24px, 4vw, 56px);
	margin: clamp(40px, 6vw, 72px) 0 80px;
	padding: clamp(24px, 4vw, 40px);
	background: var(--surface-raised);
	border: 1px solid var(--surface-rule);
	border-radius: var(--radius-lg);
	position: relative;
	overflow: hidden;
}
.home-featured::before {
	content: "";
	position: absolute; left: 0; top: 0; right: 0;
	height: 3px;
	background: linear-gradient(
		90deg,
		var(--topic, var(--color-accent)) 0%,
		var(--topic, var(--color-accent)) 64%,
		transparent 64%
	);
}
.home-featured__text {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 18px;
	min-width: 0;
}
.home-featured__eyebrow {
	font-family: var(--font-mono);
	font-size: 0.74rem;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--topic, var(--color-accent));
	margin: 0;
}
.home-featured__title {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: clamp(1.7rem, 3.2vw, 2.4rem);
	line-height: 1.12;
	letter-spacing: -0.015em;
	color: var(--color-text-strong);
	margin: 0;
}
.home-featured__title a {
	color: inherit;
	text-decoration: none;
	background-image: linear-gradient(transparent 78%, var(--topic-soft, var(--color-accent-soft)) 78%);
	background-size: 0% 100%;
	background-repeat: no-repeat;
	transition: background-size 320ms ease;
}
.home-featured__title a:hover { background-size: 100% 100%; }
.home-featured__excerpt {
	font-size: 1.02rem;
	line-height: 1.6;
	color: var(--color-text);
	margin: 0;
}
.home-featured__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	font-family: var(--font-mono);
	font-size: 0.78rem;
	color: var(--color-text-muted);
	letter-spacing: 0.04em;
}
.home-featured__cover {
	position: relative;
	aspect-ratio: 4 / 3;
	border-radius: var(--radius-md);
	background:
		radial-gradient(120% 80% at 100% 0%, var(--topic-soft, var(--color-accent-soft)) 0%, transparent 55%),
		linear-gradient(135deg, var(--surface) 0%, var(--surface-raised) 100%);
	overflow: hidden;
	border: 1px solid var(--hairline);
}

/* ---------- Grid cards ------------------------------------------- */

.home-section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin: 64px 0 24px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--hairline);
}
.home-section-head h2 {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: clamp(1.4rem, 2.4vw, 1.75rem);
	letter-spacing: -0.01em;
	color: var(--color-text-strong);
	margin: 0;
}
.home-section-head h2 span {
	display: inline-block;
	margin-left: 12px;
	font-family: var(--font-mono);
	font-size: 0.78rem;
	letter-spacing: 0.12em;
	color: var(--color-text-muted);
	vertical-align: middle;
}
.home-section-head .home-section-link {
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 0.88rem;
	color: var(--color-accent);
	text-decoration: none;
	letter-spacing: 0.02em;
}
.home-section-head .home-section-link:hover { text-decoration: underline; }

.home-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(20px, 2.4vw, 32px);
}
.home-card {
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 22px;
	background: var(--surface);
	border: 1px solid var(--surface-rule);
	border-radius: var(--radius-md);
	transition: transform 240ms ease, border-color 240ms ease, box-shadow 240ms ease;
	position: relative;
	overflow: hidden;
}
.home-card::after {
	/* Corner accent — a thin L-shape in the topic color. */
	content: "";
	position: absolute;
	top: 0; right: 0;
	width: 28px; height: 28px;
	border-top: 2px solid var(--topic, var(--color-accent));
	border-right: 2px solid var(--topic, var(--color-accent));
	border-top-right-radius: var(--radius-md);
	opacity: 0.85;
}
.home-card:hover {
	transform: translateY(-2px);
	border-color: var(--topic, var(--color-accent));
	box-shadow: 0 12px 32px rgba(20, 28, 48, 0.06);
}
:root[data-theme="dark"] .home-card:hover {
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.home-card__cover {
	aspect-ratio: 16 / 9;
	border-radius: var(--radius-sm);
	background:
		radial-gradient(80% 70% at 70% 30%, var(--topic-soft, var(--color-accent-soft)) 0%, transparent 60%),
		linear-gradient(160deg, var(--surface-raised) 0%, var(--surface) 100%);
	overflow: hidden;
	position: relative;
	border: 1px solid var(--hairline);
}

/* Hybrid covers: a real featured image fills the cover box when present,
 * sitting above the gradient + any dot-field fallback behind it. */
.home-card__cover img,
.home-featured__cover img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.home-card__series {
	font-family: var(--font-mono);
	font-size: 0.72rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--topic, var(--color-accent));
	margin: 0;
}
.home-card__series--none {
	color: var(--color-text-muted);
}
.home-card__title {
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 1.18rem;
	line-height: 1.25;
	letter-spacing: -0.005em;
	color: var(--color-text-strong);
	margin: 0;
}
.home-card__title a {
	color: inherit;
	text-decoration: none;
}
.home-card__title a:hover { color: var(--color-accent); }
.home-card__excerpt {
	font-size: 0.96rem;
	line-height: 1.55;
	color: var(--color-text-muted);
	margin: 0;
	flex: 1;
}
.home-card__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding-top: 10px;
	border-top: 1px solid var(--hairline);
}
.home-card__tags {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 0;
	margin: 0;
	list-style: none;
}
.home-card__tags li {
	font-family: var(--font-mono);
	font-size: 0.7rem;
	color: var(--color-text-muted);
	letter-spacing: 0.04em;
}
.home-card__tags li::before { content: "#"; opacity: 0.5; }
.home-card__read {
	font-family: var(--font-mono);
	font-size: 0.7rem;
	color: var(--color-text-muted);
	letter-spacing: 0.05em;
	white-space: nowrap;
}

/* ---------- "Show more" (progressive disclosure) ---------------- */

.home-more {
	display: flex;
	justify-content: center;
	margin-top: 36px;
}
/* `display:flex` above outranks the UA `[hidden]{display:none}` rule on
   specificity, so home.js toggling `hidden` alone would never hide the button —
   this restores the hide when the filtered set is fully shown. */
.home-more[hidden] { display: none; }
.home-show-more {
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 0.95rem;
	letter-spacing: 0.01em;
	color: var(--color-text-strong);
	background: var(--surface);
	border: 1px solid var(--surface-rule);
	border-radius: 999px;
	padding: 12px 28px;
	transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}
.home-show-more:hover {
	border-color: var(--color-accent);
	color: var(--color-accent);
	background: var(--color-accent-soft);
	transform: translateY(-1px);
}

/* ---------- Discovery panel (search + series + topics) ---------- */

.discovery {
	margin: 24px 0 36px;
	padding: 14px 20px 16px;
	background: var(--surface);
	border: 1px solid var(--surface-rule);
	border-radius: var(--radius-lg);
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.home-search {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 6px 0;
	border-bottom: 1px solid var(--hairline);
	margin: -2px 0 4px;
}
.home-search__icon {
	width: 18px; height: 18px;
	flex: 0 0 18px;
	color: var(--color-text-muted);
}
.home-search__input {
	flex: 1;
	-webkit-appearance: none;
	appearance: none;
	border: none;
	outline: none;
	background: transparent;
	font-family: var(--font-heading);
	font-weight: 500;
	font-size: clamp(1.05rem, 1.6vw, 1.25rem);
	color: var(--color-text-strong);
	padding: 6px 0;
	letter-spacing: -0.005em;
}
.home-search__input::placeholder {
	color: var(--color-text-muted);
	font-weight: 400;
}
.home-search__hint {
	font-family: var(--font-mono);
	font-size: 0.74rem;
	letter-spacing: 0.08em;
	color: var(--color-text-muted);
	text-transform: uppercase;
	padding: 4px 8px;
	border: 1px solid var(--color-border);
	border-radius: 4px;
}

/* Active-filter pill bar (between search and the chip rows). */
.filter-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 6px 0 2px;
	border-bottom: 1px solid var(--hairline);
	margin-bottom: 2px;
}
.filter-bar:empty {
	display: none;
	border: none;
	margin: 0;
	padding: 0;
}
.filter-bar__label {
	font-family: var(--font-mono);
	font-size: 0.72rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--color-text-muted);
}
.filter-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 6px 5px 12px;
	background: var(--color-accent-soft);
	color: var(--color-accent);
	border-radius: 999px;
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 0.82rem;
	animation: filter-pill-in 260ms cubic-bezier(0.2, 1, 0.3, 1);
}
.filter-pill__kind {
	font-family: var(--font-mono);
	font-size: 0.62rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.7;
}
.filter-pill button {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: none;
	width: 20px; height: 20px;
	border-radius: 50%;
	color: var(--color-accent);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 160ms;
}
.filter-pill button:hover { background: rgba(0,0,0,0.06); }
:root[data-theme="dark"] .filter-pill button:hover { background: rgba(255,255,255,0.08); }
@keyframes filter-pill-in {
	from { opacity: 0; transform: translateY(-4px) scale(0.95); }
	to { opacity: 1; transform: none; }
}
.filter-clear {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: 1px solid transparent;
	color: var(--color-text-muted);
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 0.78rem;
	padding: 4px 10px;
	border-radius: 999px;
	cursor: pointer;
	margin-left: 4px;
	transition: color 160ms, background 160ms;
}
.filter-clear:hover {
	color: var(--color-accent);
	background: var(--color-accent-soft);
}
.discovery__group {
	display: grid;
	grid-template-columns: 78px 1fr;
	gap: 14px;
	align-items: baseline;
}
.discovery__group:empty { display: none; }
.discovery__label {
	font-family: var(--font-mono);
	font-size: 0.7rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--color-text-muted);
	padding-top: 5px;
}
.discovery__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
@media (max-width: 700px) {
	.discovery__group { grid-template-columns: 1fr; gap: 4px; }
	.discovery__label { padding-top: 4px; }
}

/* Compact series chip — colored dot + name + count. */
.chip-series {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 5px 11px 5px 9px;
	background: var(--surface);
	border: 1px solid var(--surface-rule);
	border-radius: 999px;
	font-family: var(--font-heading);
	font-weight: 500;
	font-size: 0.84rem;
	line-height: 1.2;
	color: var(--color-text);
	text-decoration: none;
	cursor: pointer;
	transition: border-color 160ms ease, transform 160ms ease, background 160ms ease, color 160ms ease;
}
.chip-series::before {
	content: "";
	width: 8px; height: 8px;
	border-radius: 50%;
	background: var(--topic, var(--color-accent));
	flex: 0 0 8px;
}
.chip-series:hover {
	border-color: var(--topic, var(--color-accent));
	color: var(--color-text-strong);
	transform: translateY(-1px);
}
.chip-series[aria-pressed="true"] {
	background: var(--topic-soft, var(--color-accent-soft));
	border-color: var(--topic, var(--color-accent));
	color: var(--color-text-strong);
}
.chip-series .count {
	font-family: var(--font-mono);
	font-size: 0.7rem;
	color: var(--color-text-muted);
	font-weight: 600;
}

/* Compact topic chip — monospace, subtle weight tint by frequency. */
.chip-tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 10px;
	background: var(--surface);
	border: 1px solid var(--surface-rule);
	border-radius: 999px;
	font-family: var(--font-mono);
	font-size: 0.76rem;
	line-height: 1.3;
	color: var(--color-text);
	text-decoration: none;
	cursor: pointer;
	transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.chip-tag::before { content: "#"; color: var(--color-accent); opacity: 0.55; }
.chip-tag:hover { border-color: var(--color-accent); color: var(--color-accent); }
.chip-tag[data-weight="3"] { background: var(--color-bg-subtle); }
.chip-tag[data-weight="4"], .chip-tag[data-weight="5"] {
	background: var(--color-bg-subtle);
	color: var(--color-text-strong);
	font-weight: 500;
}
.chip-tag[aria-pressed="true"] {
	background: var(--color-accent-soft);
	border-color: var(--color-accent);
	color: var(--color-accent);
	font-weight: 600;
}
.chip-tag .count {
	font-size: 0.66rem;
	color: var(--color-text-muted);
	opacity: 0.8;
}

/* ---------- Subscribe block ------------------------------------- */

/* ---------- About card (ports the Hashnode author card) --------- */

.home-about {
	margin-top: 64px;
	padding: 40px clamp(24px, 4vw, 48px);
	background: var(--surface-raised);
	border: 1px solid var(--surface-rule);
	border-radius: var(--radius-lg);
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
}
.home-about__avatar {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--surface);
}
.home-about__name {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: clamp(1.2rem, 2vw, 1.5rem);
	margin: 16px 0 4px;
	color: var(--color-text-strong);
	letter-spacing: -0.01em;
}
.home-about__count {
	font-size: 0.9rem;
	color: var(--color-text-muted);
	margin: 0 0 16px;
}
.home-about__bio {
	max-width: 52ch;
	font-size: 0.98rem;
	line-height: 1.6;
	color: var(--color-text);
	margin: 0 0 24px;
}
.home-about__links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 20px;
}
.home-about__rss {
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 0.95rem;
	letter-spacing: 0.01em;
	border-radius: var(--radius-sm);
	border: 1px solid var(--color-accent);
	color: var(--color-accent);
	background: transparent;
	transition: background 160ms ease, color 160ms ease;
}
.home-about__rss:hover { background: var(--color-accent); color: #ffffff; }
:root[data-theme="dark"] .home-about__rss:hover { color: #0d1117; }
.home-about__social {
	display: inline-flex;
	align-items: center;
	gap: 14px;
}
.home-about__social a {
	display: inline-flex;
	color: var(--color-text-muted);
	transition: color 160ms ease, transform 160ms ease;
}
.home-about__social a:hover { color: var(--color-accent); transform: translateY(-1px); }

/* ---------- Feed-picker modal ----------------------------------- */

.feed-modal {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}
.feed-modal[hidden] { display: none; }
.feed-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(8, 12, 20, 0.55);
	backdrop-filter: blur(2px);
}
.feed-modal__panel {
	position: relative;
	z-index: 1;
	width: min(560px, 100%);
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	padding: 28px clamp(20px, 4vw, 36px);
	background: var(--surface-raised);
	border: 1px solid var(--surface-rule);
	border-radius: var(--radius-lg);
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.feed-modal__x {
	position: absolute;
	top: 14px;
	right: 16px;
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--color-text-muted);
	font-size: 1.5rem;
	line-height: 1;
	transition: color 160ms ease, background 160ms ease;
}
.feed-modal__x:hover { color: var(--color-text-strong); background: var(--surface); }
.feed-modal__title {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: 1.35rem;
	margin: 0 0 6px;
	color: var(--color-text-strong);
}
.feed-modal__lede {
	font-size: 0.95rem;
	line-height: 1.5;
	color: var(--color-text);
	margin: 0 0 20px;
}
.feed-modal__group { margin-bottom: 18px; }
.feed-modal__label {
	display: block;
	font-family: var(--font-mono);
	font-size: 0.72rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--color-text-muted);
	margin-bottom: 10px;
}
.feed-modal__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.feed-modal__chip {
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	padding: 6px 12px;
	font-family: var(--font-heading);
	font-size: 0.85rem;
	font-weight: 600;
	border-radius: 999px;
	border: 1px solid var(--surface-rule);
	background: var(--surface);
	color: var(--color-text);
	transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}
.feed-modal__chip .count {
	margin-left: 6px;
	font-size: 0.78em;
	color: var(--color-text-muted);
}
.feed-modal__chip:hover { border-color: var(--color-accent); }
.feed-modal__chip[aria-pressed="true"] {
	background: var(--color-accent);
	border-color: var(--color-accent);
	color: #ffffff;
}
:root[data-theme="dark"] .feed-modal__chip[aria-pressed="true"] { color: #0d1117; }
.feed-modal__chip[aria-pressed="true"] .count { color: inherit; opacity: 0.8; }
.feed-modal__foot {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	margin-top: 24px;
	padding-top: 18px;
	border-top: 1px solid var(--surface-rule);
}
.feed-modal__url {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
	font-family: var(--font-mono);
	font-size: 0.82rem;
	color: var(--color-accent);
}
.feed-modal__go {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 18px;
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 0.92rem;
	text-decoration: none;
	border-radius: var(--radius-sm);
	background: var(--color-accent);
	color: #ffffff;
	transition: filter 160ms ease;
}
:root[data-theme="dark"] .feed-modal__go { color: #0d1117; }
.feed-modal__go:hover { filter: brightness(1.08); }

/* ---------- Empty state ----------------------------------------- */

.home-empty {
	padding: 60px 0;
	text-align: center;
	color: var(--color-text-muted);
	font-family: var(--font-heading);
	font-size: 1.05rem;
}
.home-empty code {
	font-family: var(--font-mono);
	color: var(--color-accent);
}

/* ---------- Page-load reveal ------------------------------------ */

@keyframes home-reveal {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}
.home-featured,
.discovery,
.home-section-head,
.home-grid,
.home-about {
	animation: home-reveal 600ms ease both;
}
.discovery         { animation-delay: 120ms; }
.home-section-head { animation-delay: 160ms; }
.home-grid         { animation-delay: 200ms; }
.home-about        { animation-delay: 260ms; }
@media (prefers-reduced-motion: reduce) {
	.home-featured, .discovery, .home-section-head,
	.home-grid, .home-about { animation: none; }
}

/* ---------- Responsive ------------------------------------------ */

@media (max-width: 960px) {
	.home-featured { grid-template-columns: 1fr; }
	.home-featured__cover { aspect-ratio: 16 / 10; }
	.home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
	.home-grid { grid-template-columns: 1fr; }
}
