/*
 * Due North — Insights archive (/insights/) and single insight pages.
 * Built from the "Page designs v3" Insights landing and Insight article boards, on the
 * design system in custom.css (tokens, .dn-hero, .dn-cta, .dn-insight-card, carousel).
 * Loaded on those two templates only (inc/insights.php).
 */

/* style.css gives text blocks margins; spacing on these pages comes from the flex/grid gaps. */
.dn-insights-page :where(p, ul, ol, figure),
.dn-insight-single :where(p, ul, ol, figure) {
	margin: 0;
}

.dn-insight-single .dn-insights__grid {
	padding: 0;
	list-style: none;
}

/* style.css gives every a:focus a thin dotted outline, so a clicked link kept it. Only keyboard focus gets a ring. */
.dn-insights-page a:focus:not(:focus-visible),
.dn-insight-single a:focus:not(:focus-visible) {
	outline: 0;
}

/* =========================
   INSIGHT CARD (archive grid + related)
   v3 card: 24px image → body, 12px within the body, 379 × 236 image.
========================= */

.dn-insight-card--listing {
	gap: var(--space-5);
}

.dn-insight-card--listing .dn-insight-card__body {
	gap: var(--space-3);
}

.dn-insight-card--listing .dn-insight-card__media {
	display: block;
	isolation: isolate; /* keeps the rounded corners clipping the zoomed image in Safari */
	aspect-ratio: 379 / 236;
	background: var(--c-light);
}

.dn-insight-card--listing .dn-insight-card__media img {
	transition: transform 0.6s var(--ease-out);
}

/* Hover: a gentle zoom inside the fixed frame, so the card never changes size. */
@media (hover: hover) {
	.dn-insight-card--listing:hover .dn-insight-card__media img {
		transform: scale(1.05);
	}
}

.dn-insight-card--listing:focus-within .dn-insight-card__media img {
	transform: scale(1.05);
}

.dn-insight-card__title a {
	color: inherit;
	text-decoration: none;
}

.dn-insight-card__title a:focus-visible {
	outline: 2px solid var(--c-navy);
	outline-offset: 3px;
	border-radius: 2px;
}

/* =========================
   INSIGHTS HERO
========================= */

.dn-hero--insights .dn-hero__bg {
	object-position: 50% 60%;
}

.dn-hero--insights .dn-hero__text {
	font-weight: var(--weight-light);
}

.dn-hero--insights .dn-hero__overlay {
	background:
		linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0, rgba(0, 0, 0, 0) 300px),
		linear-gradient(to right, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.55) 45%, rgba(0, 0, 0, 0.2) 75%, rgba(0, 0, 0, 0.1) 100%);
}

/* =========================
   LATEST INSIGHTS: filters, grid, pagination
========================= */

.dn-insights-list .dn-container {
	display: flex;
	flex-direction: column;
	gap: var(--space-7); /* 48px at every width */
}

.dn-insights-list__head {
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
	scroll-margin-top: calc(var(--admin-bar) + var(--header-h) + var(--space-5));
}

.dn-pills {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
}

.dn-pill,
.dn-pagination__link {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: var(--space-2) var(--space-4);
	border: 1px solid var(--c-border);
	border-radius: 25px;
	background: var(--c-white);
	color: var(--c-black);
	font-family: var(--font-body);
	font-size: 1rem;
	font-weight: var(--weight-medium);
	line-height: 1.5rem;
	text-decoration: none;
	white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
	transition:
		background-color 0.2s ease,
		border-color 0.2s ease,
		color 0.2s ease;
}

.dn-pill:visited,
.dn-pagination__link:visited {
	color: var(--c-black);
}

@media (hover: hover) {
	.dn-pill:hover,
	.dn-pagination__link:hover {
		border-color: var(--c-ink);
		color: var(--c-black);
	}
}

.dn-pill.is-active,
.dn-pagination__link.is-active {
	border-color: var(--c-ink);
	background: var(--c-ink);
	color: var(--c-white);
}

.dn-insights-results {
	display: flex;
	flex-direction: column;
	gap: var(--space-7);
	transition: opacity 0.25s ease;
}

.dn-insights-results:focus {
	outline: none;
}

/* While a filter or page loads: the current cards stay in place, dimmed. */
.dn-insights-results.is-loading {
	opacity: 0.45;
	pointer-events: none;
	cursor: progress;
}

.dn-insights-archive__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--space-7) var(--grid-gap);
	padding: 0;
	list-style: none;
}

.dn-pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--space-2);
}

.dn-pagination__link {
	justify-content: center;
	min-width: 44px;
	padding-inline: var(--space-3);
}

.dn-pagination__gap {
	display: inline-flex;
	align-items: center;
	padding-inline: var(--space-1);
}

.dn-insights-empty {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-4);
}

/* =========================
   ARTICLE INTRO
========================= */

.dn-post-intro {
	padding-block: var(--section-pad) var(--space-7);
	background: var(--c-tint-article);
}

.dn-post-intro__inner {
	display: flex;
	flex-direction: column;
	gap: var(--space-6);
}

.dn-post-intro__copy {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	max-width: 768px;
}

/* Blog H1 is one step down the site scale: the H2 size (28 → 32px). */
.dn-post-intro__title {
	color: var(--c-navy);
	font-size: var(--fs-h2);
	line-height: var(--lh-h2);
}

.dn-byline {
	display: flex;
	align-items: center;
	gap: var(--space-4);
}

.dn-byline__avatar {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	object-fit: cover;
}

.dn-byline__text {
	display: flex;
	flex-direction: column;
}

.dn-byline__name {
	font-size: var(--fs-body);
	font-weight: var(--weight-medium);
	line-height: var(--lh-body);
}

/* Author name: underlined link to the author archive, followed by ", {Position}" */
.dn-byline__author {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
	transition: color 0.2s ease;
}

.dn-byline__author:hover,
.dn-byline__author:focus-visible {
	color: var(--c-navy);
}

.dn-byline__author:focus-visible {
	outline: 2px solid var(--c-navy);
	outline-offset: 3px;
	border-radius: 2px;
}

.dn-byline__meta {
	font-size: var(--fs-body-sm);
	line-height: var(--lh-body);
}

/* =========================
   ARTICLE BODY + SIDEBAR
   Desktop: article (max 720px) | 360px sidebar. Row 1 holds the article and the sticky
   "In this article"; row 2 lines the author up with the "second opinion" box.
========================= */

.dn-post {
	padding-block: var(--space-5) var(--section-pad);
}

.dn-post__layout {
	display: grid;
	grid-template-columns: minmax(0, 720px) 360px;
	justify-content: space-between;
	align-items: start;
	gap: var(--space-5) var(--space-7);
}

.dn-post__content {
	grid-column: 1;
	grid-row: 1;
}

.dn-post__toc {
	grid-column: 2;
	grid-row: 1;
	align-self: stretch;
}

.dn-author {
	grid-column: 1;
	grid-row: 2;
}

.dn-post-cta {
	grid-column: 2;
	grid-row: 2;
}

.dn-post__layout--no-toc .dn-post-cta {
	grid-row: 1;
}

/* Article text (the post content as stored, styled here) */

.dn-prose {
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
	min-width: 0;
}

.dn-prose > *,
.dn-prose li > :is(ul, ol) {
	margin: 0;
}

.dn-prose p,
.dn-prose ul,
.dn-prose ol {
	font-size: var(--fs-body);
	font-weight: var(--weight-light);
	line-height: var(--lh-body);
}

.dn-prose ul,
.dn-prose ol {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding-left: var(--space-5);
}

.dn-prose li > :is(ul, ol) {
	margin-top: var(--space-2);
}

/* Blog H2 is the H3 size (20 → 24px, set in custom.css); headings clear the fixed header when linked. */
.dn-prose h2,
.dn-prose h3,
.dn-prose h4 {
	color: var(--c-navy);
	scroll-margin-top: calc(var(--admin-bar) + var(--header-h) + var(--space-6));
}

.dn-prose a {
	color: var(--c-navy);
	text-decoration: underline;
}

.dn-prose figure {
	margin-block: var(--space-2);
}

.dn-prose .wp-block-image img {
	border: 1px solid var(--c-border);
	border-radius: var(--radius);
	background: var(--c-white);
}

.dn-prose figcaption,
.dn-prose .wp-element-caption {
	margin: var(--space-2) 0 0;
	color: var(--c-black);
	font-size: var(--fs-body-sm);
	line-height: var(--lh-body);
	text-align: left;
}

/* Galleries: images side by side 24px apart (stacked on mobile), captions below as on the single images */
.dn-prose .wp-block-gallery.has-nested-images {
	--wp--style--unstable-gallery-gap: var(--space-5);
	gap: var(--space-5);
}

.dn-prose .wp-block-gallery.has-nested-images figure.wp-block-image {
	flex-direction: column;
}

.dn-prose .wp-block-gallery.has-nested-images figure.wp-block-image figcaption {
	position: static;
	max-height: none;
	padding: 0;
	background: none;
	color: var(--c-black);
	font-size: var(--fs-body-sm);
	text-shadow: none;
}

.dn-prose .wp-block-table {
	overflow-x: auto;
}

.dn-prose table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--fs-body-sm);
	line-height: var(--lh-body);
}

.dn-prose th,
.dn-prose td {
	padding: var(--space-3);
	border: 1px solid var(--c-border);
	text-align: left;
	vertical-align: top;
}

.dn-prose th {
	background: var(--c-light);
	font-weight: var(--weight-medium);
}

.dn-prose blockquote {
	padding-left: var(--space-5);
	border-left: 2px solid var(--c-navy);
	font-size: var(--fs-body-lg);
}

.dn-prose hr {
	width: 100%;
	height: 1px;
	border: 0;
	background: var(--c-border);
}

/* Author */

.dn-author {
	display: flex;
	align-items: center;
	gap: var(--space-4);
	padding-top: var(--space-6);
	border-top: 1px solid var(--c-border);
}

.dn-author__avatar {
	flex-shrink: 0;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	object-fit: cover;
}

.dn-author__text {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
}

/* Sidebar: "In this article" (sticky) and "Want a second opinion?" */

.dn-toc,
.dn-post-cta {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	padding: var(--space-5);
	border-radius: var(--radius);
	color: var(--c-white);
}

.dn-toc {
	position: sticky;
	top: calc(var(--admin-bar) + var(--header-h) + var(--space-6));
	overflow-y: auto; /* a long list scrolls inside the box rather than running off screen */
	max-height: calc(100vh - var(--admin-bar) - var(--header-h) - 2 * var(--space-6));
	background: var(--c-ink);
	overscroll-behavior: contain;
}

.dn-toc ol {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	margin: 0;
	padding-left: var(--space-5);
}

.dn-toc a {
	color: var(--c-white);
	font-size: var(--fs-body);
	font-weight: var(--weight-light);
	line-height: var(--lh-body);
	text-decoration: none;
}

.dn-toc a:hover {
	text-decoration: underline;
}

/* Sub-headings (h3) nest under their h2 and are numbered 2.1, 2.2 ... */
.dn-toc > ol {
	counter-reset: dn-toc;
}

.dn-toc > ol > li {
	counter-increment: dn-toc;
}

.dn-toc ol ol {
	counter-reset: dn-toc-sub;
	margin-top: var(--space-2);
	padding-left: 0;
	list-style: none;
}

.dn-toc ol ol > li {
	display: flex;
	gap: var(--space-2);
	counter-increment: dn-toc-sub;
}

.dn-toc ol ol > li::before {
	flex-shrink: 0;
	content: counter(dn-toc) "." counter(dn-toc-sub);
	font-size: var(--fs-body);
	font-weight: var(--weight-light);
	line-height: var(--lh-body);
}

.dn-post-cta {
	align-items: flex-start;
	background: var(--c-purple);
}

.dn-toc :focus-visible,
.dn-post-cta :focus-visible {
	outline-color: var(--c-mint);
}

/* =========================
   RELATED INSIGHTS
========================= */

.dn-related .dn-container {
	display: flex;
	flex-direction: column;
	gap: var(--space-7); /* 48px at every width */
}

/* =========================
   TABLET ≤1023
========================= */

@media (max-width: 1023px) {
	.dn-hero--insights .dn-hero__overlay {
		background:
			linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0, rgba(0, 0, 0, 0) 260px),
			linear-gradient(to right, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.55) 60%, rgba(0, 0, 0, 0.25) 100%);
	}

	.dn-insights-archive__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	/* Single column at the full container width: article, author, then the purple box; no "In this article". */
	.dn-post__layout {
		display: flex;
		flex-direction: column;
		gap: var(--space-6);
	}

	.dn-post__toc {
		display: none;
	}

	.dn-prose {
		width: 100%;
	}
}

/* =========================
   MOBILE ≤767
========================= */

@media (max-width: 767px) {
	.dn-hero--insights .dn-hero__overlay {
		background:
			linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0, rgba(0, 0, 0, 0) 240px),
			linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 45%, rgba(0, 0, 0, 0.15) 80%, rgba(0, 0, 0, 0.1) 100%);
	}

	.dn-insights-archive__grid {
		grid-template-columns: minmax(0, 1fr);
		row-gap: var(--space-6);
	}

	.dn-post-intro {
		padding-bottom: var(--space-6);
	}

	.dn-prose .wp-block-gallery.has-nested-images {
		--wp--style--unstable-gallery-gap: var(--space-4);
		gap: var(--space-4);
	}

	.dn-prose .wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dn-insight-card--listing .dn-insight-card__media img,
	.dn-insights-results {
		transition: none;
	}
}
