/* Standalone directory entry: left aside = image, right aside = magazine article */

body.page-directory-article {
	margin: 0;
	padding: 0;
	background-color: #eae8e4;
	background-image: url("../images/wheat1.jpg");
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
	color: #000;
	overflow-x: hidden;
	/* Window does not scroll; the right .mag-sheet column scrolls */
	overflow-y: hidden;
}

body.page-directory-article main {
	display: block;
	width: 100%;
}

body.page-directory-article #header {
	position: fixed;
}

.directory-article-main {
	padding-top: calc(75px + env(safe-area-inset-top, 0px));
	box-sizing: border-box;
	min-height: 100vh;
	min-height: -webkit-fill-available;
	height: 100vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* Phase 5 — dynamic viewport height (iOS / mobile browser chrome) */
@supports (height: 100dvh) {
	.directory-article-main {
		min-height: 100dvh;
		height: 100dvh;
		max-height: 100dvh;
	}
}

.directory-article-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	width: 100%;
	flex: 1 1 auto;
	min-height: 0;
	height: 100%;
	align-items: stretch;
}

.directory-article-layout > aside.directory-article-visual {
	min-width: 0;
	height: 100%;
	min-height: 0;
	background: #c5ccd4;
	border-right: 1px solid #000;
	overflow: hidden;
	padding: 0;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}

.directory-article-layout > aside.directory-article-visual img {
	flex: 1 1 auto;
	width: 100%;
	height: 100%;
	min-height: 0;
	object-fit: cover;
	object-position: center center;
	display: block;
	margin: 0;
	border: 0;
	background: #c5ccd4;
}

/* —— Magazine sheet (right column): sole vertical scroll; left image stays fixed in band —— */
.directory-article-layout > aside.directory-article-content.mag-sheet {
	min-width: 0;
	height: 100%;
	min-height: 0;
	padding: 18px max(22px, env(safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
	box-sizing: border-box;
	background-color: #eae8e4;
	background-image: url("../images/wheat1.jpg");
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	display: flex;
	flex-direction: column;
}

.directory-article-back {
	flex: 0 0 auto;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 9px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	margin: 0 0 14px 0;
}

.directory-article-back a {
	color: #8b1538;
	text-decoration: none;
	font-weight: 600;
}

.directory-article-back a:hover {
	text-decoration: underline;
}

.mag-article {
	max-width: 100%;
}

/* Article stack grows with content; .mag-sheet scrolls (not this flex child filling viewport) */
.directory-article-layout > aside.mag-sheet > #article-mag.mag-article {
	flex: 0 0 auto;
	min-height: 0;
	min-width: 0;
	max-width: 100%;
	overflow-x: hidden;
	display: flex;
	flex-direction: column;
}

/* A / B / C: current spread slides off to the left; next enters from the right */
#article-mag.mag-page-flip-root {
	transform: translate3d(0, 0, 0);
	opacity: 1;
	transition: transform 0.52s cubic-bezier(0.32, 0.72, 0.22, 1), opacity 0.42s ease;
	will-change: transform, opacity;
}

#article-mag.mag-page-flip-root.mag-page-flip--out {
	transform: translate3d(-78%, 0, 0) rotate(-0.75deg);
	opacity: 0;
}

#article-mag.mag-page-flip-root.mag-page-flip--in {
	transition: none;
	transform: translate3d(62%, 0, 0) rotate(0.65deg);
	opacity: 0.12;
}

#article-mag.mag-page-flip-root.mag-page-flip--in.mag-page-flip--in-run {
	transition: transform 0.52s cubic-bezier(0.32, 0.72, 0.22, 1), opacity 0.45s ease;
	transform: translate3d(0, 0, 0) rotate(0deg);
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	#article-mag.mag-page-flip-root,
	#article-mag.mag-page-flip-root.mag-page-flip--out,
	#article-mag.mag-page-flip-root.mag-page-flip--in,
	#article-mag.mag-page-flip-root.mag-page-flip--in.mag-page-flip--in-run {
		transition: none !important;
		transform: none !important;
		opacity: 1 !important;
	}
}

/* Masthead: credits fixed at top, headline centered in remaining vertical space */
.mag-header {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	flex: 0 0 auto;
	min-height: clamp(160px, 30vh, 340px);
	max-height: min(42vh, 420px);
	margin: 0 0 10px 0;
	box-sizing: border-box;
}

/* Top credits: small serif, corners */
.mag-credits {
	flex: 0 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 16px;
	margin: 0 0 6px 0;
	padding: 0 2px;
	min-width: 0;
}

.mag-credit {
	margin: 0;
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 10px;
	line-height: 1.35;
	color: #000;
	min-width: 0;
	overflow-wrap: anywhere;
}

.mag-credit-left {
	text-align: left;
	font-style: normal;
}

.mag-credit-left .mag-credit-linecaps {
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.mag-credit-right {
	text-align: right;
}

.mag-credit-right strong,
.mag-credit-right .mag-credit-caps {
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

/* Massive centered sans headline — tight leading; centered in middle of masthead band */
body.page-directory-article .mag-sheet h1.mag-hed {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 0;
	min-width: 0;
	width: 100%;
	box-sizing: border-box;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
	font-weight: 700 !important;
	font-style: normal !important;
	text-transform: uppercase;
	text-align: center;
	letter-spacing: -0.055em;
	line-height: 0.82;
	margin: 0 0 18px 0;
	padding: 8px 0 12px 0;
	color: #000 !important;
	font-size: clamp(2.1rem, 5.8vw, 4.25rem) !important;
	max-width: min(22ch, 100%);
	margin-left: auto;
	margin-right: auto;
	overflow-wrap: anywhere;
	hyphens: manual;
	-webkit-hyphens: manual;
}

.mag-hed .mag-hed-line {
	display: block;
	text-align: center;
}

/* JS-driven headline typewriter (all directory entries) — caret on the active line */
.mag-hed.mag-hed--typing .mag-hed-line:last-of-type {
	position: relative;
}

.mag-hed.mag-hed--typing .mag-hed-line:last-of-type::after {
	content: "";
	display: inline-block;
	width: 0.08em;
	height: 0.78em;
	margin-left: 0.05em;
	vertical-align: -0.06em;
	background: currentColor;
	animation: mag-hed-caret-blink 0.55s step-end infinite;
}

@keyframes mag-hed-caret-blink {
	50% {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mag-hed.mag-hed--typing .mag-hed-line:last-of-type::after {
		animation: none !important;
		opacity: 0;
	}
}

/* Three-column body — natural height so .mag-sheet scrolls long copy */
.mag-body {
	margin: 0;
	padding: 0;
	flex: 0 0 auto;
	min-height: 0;
	min-width: 0;
	max-width: 100%;
	overflow-x: hidden;
	display: flex;
	flex-direction: column;
}

.mag-three-col {
	flex: 0 0 auto;
	min-height: 0;
	min-width: 0;
	max-width: 100%;
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-template-rows: auto;
	column-gap: 1.25rem;
	row-gap: 0;
	align-items: stretch;
	align-content: start;
}

/* JS body typewriter: keep paragraph boxes from collapsing while text nodes are empty */
.mag-three-col.mag-body--typing .mag-col p {
	min-height: 1.35em;
}

.mag-col {
	min-width: 0;
	min-height: 0;
	align-self: stretch;
}

.mag-col p {
	margin: 0 0 0.55em 0;
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 11px;
	line-height: 1.42;
	text-align: justify;
	text-justify: inter-word;
	hyphens: auto;
	-webkit-hyphens: auto;
	color: #111;
}

.mag-col p:last-child {
	margin-bottom: 0;
}

.mag-dateline {
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
	font-size: 9px !important;
	font-weight: 700;
	line-height: 1.35 !important;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	text-align: left;
	margin: 0 0 10px 0 !important;
	hyphens: none;
	-webkit-hyphens: none;
}

.mag-intro {
	font-style: italic;
	text-align: justify;
}

.mag-speaker {
	font-weight: 700;
	font-style: normal;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	font-size: 10px;
}

.mag-part-marker {
	margin: 0 0 10px 0;
	font-size: 10px;
	line-height: 1.45;
	text-align: justify;
}

.mag-part-nav {
	flex: 0 0 auto;
	margin: 16px 0 0 0;
	padding: 0;
	text-align: center;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.28em;
	text-transform: uppercase;
}

.mag-part-nav .mag-part-sep {
	font-weight: 400;
	letter-spacing: 0.12em;
	color: #666;
}

.mag-part-nav a {
	display: inline-block;
	margin: 0 10px;
	padding: 4px 2px;
	color: #000;
	text-decoration: none;
	letter-spacing: 0.2em;
}

.mag-part-nav a:hover {
	text-decoration: underline;
	color: #8b1538;
}

.mag-part-nav a.is-active {
	color: #8b1538;
	text-decoration: underline;
	font-weight: 700;
}

.mag-page-num {
	flex: 0 0 auto;
	margin: 10px 0 0 0;
	padding: 10px 0 0 0;
	border-top: 1px solid #000;
	text-align: center;
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 18px;
	font-weight: 700;
	color: #000;
}

.directory-article-unknown {
	flex: 0 0 auto;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 13px;
	line-height: 1.5;
}

#article-mag.is-hidden {
	display: none !important;
}

.mag-article.mag-state-empty .mag-credits {
	display: none;
}

.mag-article.mag-state-empty .mag-page-num,
.mag-article.mag-state-empty .mag-part-nav {
	display: none;
}

.mag-article.mag-state-empty .mag-three-col {
	grid-template-columns: 1fr;
	max-width: 32rem;
	margin: 0 auto;
}

@media (max-width: 900px) {
	.directory-article-layout {
		display: flex;
		flex-direction: column;
		grid-template-columns: unset;
		grid-template-rows: unset;
		flex: 1 1 auto;
		min-height: 0;
		height: 100%;
	}

	.directory-article-layout > aside.directory-article-visual {
		flex: 0 0 42vh;
		height: 42vh;
		min-height: 0;
		max-height: 42vh;
		border-right: none;
		border-bottom: 1px solid #000;
	}

	.directory-article-layout > aside.directory-article-visual img {
		min-height: 0;
		height: 100%;
		flex: 1 1 auto;
	}

	.directory-article-layout > aside.directory-article-content.mag-sheet {
		flex: 1 1 auto;
		min-height: 0;
		height: auto;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		padding: 16px max(16px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
	}

	.mag-three-col {
		grid-template-columns: 1fr;
		column-gap: 0;
	}

	.mag-col + .mag-col {
		margin-top: 1rem;
		padding-top: 1rem;
		border-top: 1px solid #ddd;
	}

	.mag-header {
		min-height: clamp(150px, 26vh, 260px);
	}

	body.page-directory-article .mag-sheet h1.mag-hed {
		font-size: clamp(1.65rem, 9vw, 2.75rem) !important;
		line-height: 0.84;
		letter-spacing: -0.04em;
		max-width: 100%;
		overflow-wrap: anywhere;
	}

	/* A / B / C: first in article stack + sticky within scroll column (nav was below long body) */
	#article-mag.mag-article #article-part-nav.mag-part-nav {
		order: -1;
		margin: 0 0 14px 0;
		position: sticky;
		top: 0;
		z-index: 3;
		padding: 10px 0 12px;
		margin-left: 0;
		margin-right: 0;
		padding-left: max(4px, env(safe-area-inset-left, 0px));
		padding-right: max(4px, env(safe-area-inset-right, 0px));
		background-color: #eae8e4;
		background-image: url("../images/wheat1.jpg");
		background-size: cover;
		background-position: center center;
		background-repeat: no-repeat;
		box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
	}
}

/* Images inside article body never wider than the scroll column */
.mag-sheet img {
	max-width: 100%;
	height: auto;
	vertical-align: middle;
}
