/*
 * Jordan Festival — Story detail (single post).
 * The whole story is one large warm-white sheet on the ivory page: back
 * link, category and date, title and lead; the featured photo; the article
 * and a quiet way back, all on the sheet's one inner width, so text and
 * photos share the same edges. Related stories sit below, on sand.
 * Builds on stories.css (tokens, category label, sample badge, cards).
 * The brand stays at the edges: a short red rule on the sheet's top edge,
 * red rules on captions and quotes, the keffiyeh selvedge under the photo
 * and at section breaks. Nothing sits behind the text.
 */

.st {
	--st-wide: 960px;  /* the sheet's inner width at most */
	--st-col: var(--st-wide); /* text shares the photo's edges */
	--st-portrait: 680px; /* a portrait featured photo's frame */
	--st-pad: 64px;    /* sheet padding */
}

/* The page and the sheet ---------------------------------------------- */
.st-stage {
	padding: 48px 0 96px;
	background: var(--sp-ivory);
}
.st-sheet {
	position: relative;
	max-width: calc(var(--st-wide) + 2 * var(--st-pad) + 2px);
	margin-inline: auto;
	padding: 48px var(--st-pad) 56px;
	background: var(--sp-card);
	border: 1px solid var(--sp-ivory-line);
	box-shadow: 0 1px 2px rgba(13, 30, 65, .04), 0 28px 64px -40px rgba(13, 30, 65, .28);
}
/* A short red rule on the sheet's top edge, over the photo's starting edge. */
.st-sheet::before {
	content: "";
	position: absolute;
	top: -1px;
	inset-inline-start: var(--st-pad);
	width: 56px;
	height: 3px;
	background: var(--jf-red);
}

/* One inner width shared by the opening, the photo and the article. */
.st-col {
	max-width: var(--st-col);
	margin-inline: auto;
}

/* Opening ------------------------------------------------------------- */
.st-back {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	font-size: 14px;
	font-weight: 600;
	color: var(--jf-navy);
}
.st-back:hover { color: var(--jf-red); }
.st-back .jf-arrow,
.st-end__link .jf-arrow { color: var(--jf-red); }
/* The arrow glyph points forward; "back" turns it round (in RTL the global flip already does). */
.st-back__arrow { transform: scaleX(-1); }
[dir="rtl"] .st-back__arrow { transform: none; }

.st-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 16px;
	margin-top: 24px;
}
a.st-cat { position: relative; color: var(--jf-red); }
/* Larger tap area for the small category label (no visual change). */
a.st-cat::after { content: ""; position: absolute; inset: -13px -8px; }
a.st-cat:hover { color: var(--jf-navy); }
.st-date { font-size: 14px; color: var(--jf-muted); }
.st-cat + .st-date { padding-inline-start: 16px; border-inline-start: 1px solid var(--jf-line); }

.st-title {
	margin-top: 18px;
	font-family: var(--jf-serif);
	font-size: clamp(38px, 4.1vw, 58px);
	font-weight: 600;
	line-height: 1.12;
	color: var(--jf-navy);
	overflow-wrap: break-word;
	text-wrap: balance;
}
/* Long titles step down so they stay a heading, not a paragraph. */
.st-title--long { font-size: clamp(32px, 3.2vw, 44px); line-height: 1.18; }

.st-lead {
	margin-top: 24px;
	font-size: 21px;
	line-height: 1.6;
	color: var(--jf-ink-2);
	text-wrap: pretty;
}

/* Featured photo: across the sheet's inner width. */
.st-hero {
	position: relative;
	margin-top: 44px;
}
.st-hero__media {
	position: relative;
	overflow: hidden;
	aspect-ratio: 2 / 1;
	background: var(--sp-media);
}
.st-hero__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.st-hero__media::after,
.st-hero--brand::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	height: 6px;
	background: url("../images/brand/keffiyeh-selvedge.svg") repeat-x 0 0 / 6px 6px;
}

/* Portrait photo: a square frame, centred. */
.st-hero--portrait {
	max-width: var(--st-portrait);
	margin-inline: auto;
}
.st-hero--portrait .st-hero__media { aspect-ratio: 1 / 1; }
.st-hero--portrait .st-hero__media img { object-position: 50% 40%; }

/* No photo: a short navy lattice band with the emblem. */
.st-hero--brand {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 4 / 1;
	background:
		repeating-linear-gradient(45deg, rgba(255, 255, 255, .045) 0 1px, transparent 1px 22px),
		repeating-linear-gradient(-45deg, rgba(255, 255, 255, .045) 0 1px, transparent 1px 22px),
		var(--jf-navy);
}
.st-hero--brand .sp-emblem { width: 52px; height: auto; opacity: .6; }

/* Captions (featured photo and photos in the article). */
.st-caption,
.st-content figcaption,
.st-content .wp-caption-text {
	display: flex;
	gap: 10px;
	margin-top: 12px;
	font-size: 14px;
	line-height: 1.55;
	color: var(--jf-muted);
	text-align: start;
}
.st-caption::before,
.st-content figcaption::before,
.st-content .wp-caption-text::before {
	content: "";
	flex: none;
	width: 16px;
	height: 1px;
	margin-top: .78em;
	background: var(--jf-red);
}

/* Article ---------------------------------------------------------------- */
.st-content {
	margin-top: 56px;
	font-size: 19px;
	line-height: 1.75;
	color: var(--jf-ink-2);
	overflow-wrap: break-word;
}
.st-content::after { content: ""; display: table; clear: both; }
.st-content > * + * { margin-top: 1.25em; }
.st-content > :first-child { margin-top: 0; }

.st-content h2,
.st-content h3,
.st-content h4,
.st-content h5,
.st-content h6 {
	clear: both;
	color: var(--jf-navy);
	text-wrap: balance;
}
.st-content h2 {
	margin-top: 2.1em;
	font-family: var(--jf-serif);
	font-size: 31px;
	font-weight: 600;
	line-height: 1.25;
}
.st-content h3 {
	margin-top: 1.8em;
	font-size: 23px;
	font-weight: 700;
	line-height: 1.35;
}
.st-content h4,
.st-content h5,
.st-content h6 {
	margin-top: 1.7em;
	font-size: 19px;
	font-weight: 700;
	line-height: 1.4;
}
.st-content :is(h2, h3, h4, h5, h6) + * { margin-top: .65em; }

.st-content strong,
.st-content b { font-weight: 700; color: var(--jf-navy); }

/* Links: navy text, a thin red underline. */
.st-content a {
	color: var(--jf-navy);
	white-space: normal;
	text-decoration: underline;
	text-decoration-color: var(--jf-red);
	text-decoration-thickness: 1px;
	text-underline-offset: 4px;
}
.st-content a:hover { color: var(--jf-red); }
.st-content a:has(> img) { text-decoration: none; }

.st-content ul,
.st-content ol { padding-inline-start: 1.3em; }
.st-content li { padding-inline-start: .3em; }
.st-content li + li,
.st-content li > ul,
.st-content li > ol { margin-top: .5em; }
.st-content ul > li::marker { color: var(--jf-red); }
.st-content ol > li::marker { color: var(--jf-navy); font-weight: 600; }

.st-content blockquote {
	position: relative;
	margin-block: 2em;
	padding-top: 24px;
	font-family: var(--jf-serif);
	font-size: 25px;
	font-weight: 600;
	line-height: 1.45;
	color: var(--jf-navy);
}
.st-content blockquote::before {
	content: "";
	position: absolute;
	top: 0;
	inset-inline-start: 0;
	width: 40px;
	height: 2px;
	background: var(--jf-red);
}
.st-content blockquote p + p { margin-top: .7em; }
.st-content blockquote cite,
.st-content blockquote footer {
	display: block;
	margin-top: 14px;
	font-family: var(--jf-font);
	font-size: 15px;
	font-style: normal;
	font-weight: 600;
	line-height: 1.5;
	color: var(--jf-muted);
}

/* Section break: a short keffiyeh selvedge. */
.st-content hr {
	clear: both;
	width: 72px;
	height: 6px;
	margin: 2.6em auto;
	border: 0;
	background: url("../images/brand/keffiyeh-selvedge.svg") repeat-x 0 0 / 6px 6px;
}

/* Images and captions. */
.st-content img {
	max-width: 100%;
	height: auto;
	margin-inline: auto;
}
.st-content figure,
.st-content .wp-caption {
	max-width: 100%;
	margin-block: 2em;
}
.st-content p:has(> img:only-child),
.st-content p:has(> a:only-child > img) { margin-block: 2em; }
.st-content figure img,
.st-content .wp-caption img { width: 100%; }
/* Portrait photos are kept to a comfortable height. */
.st-content img.st-portrait { width: auto; max-width: min(100%, 520px); }
.st-content .wp-caption:has(img.st-portrait),
.st-content figure:has(> img.st-portrait) { max-width: 520px; margin-inline: auto; }
.st-content .wp-caption:has(img.st-portrait) img { width: 100%; }
.st-content .alignleft,
.st-content .alignright { max-width: 50%; margin-block: .35em 1em; }
.st-content .alignleft { float: left; margin-right: 32px; }
.st-content .alignright { float: right; margin-left: 32px; }
.st-content .aligncenter { margin-inline: auto; }
.st-content .alignleft img,
.st-content .alignright img { width: 100%; }

/* Galleries ([gallery]): an even grid of 3:2 photos. */
.st-content .gallery {
	display: grid;
	grid-template-columns: repeat(var(--st-g, 3), minmax(0, 1fr));
	gap: 10px;
	margin-block: 2em;
}
.st-content .gallery-columns-1 { --st-g: 1; }
.st-content .gallery-columns-2 { --st-g: 2; }
.st-content .gallery-columns-4,
.st-content .gallery-columns-5,
.st-content .gallery-columns-6,
.st-content .gallery-columns-7,
.st-content .gallery-columns-8,
.st-content .gallery-columns-9 { --st-g: 4; }
.st-content .gallery-item { margin: 0; min-width: 0; }
.st-content .gallery-icon img {
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
}
.st-content .gallery-columns-1 .gallery-icon img { aspect-ratio: auto; }
.st-content .gallery-caption { margin-top: 8px; font-size: 13px; }
.st-content .gallery-caption::before { display: none; }

/* Block markup pasted into a story (block styles are not loaded). */
.st-content .wp-block-gallery {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}
.st-content .wp-block-gallery.columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-content .wp-block-gallery figure { margin: 0; }
.st-content .wp-block-gallery img { aspect-ratio: 3 / 2; object-fit: cover; }

/* Embedded media. */
.st-content iframe,
.st-content video,
.st-content embed,
.st-content object { max-width: 100%; }
.st-content iframe { border: 0; background: var(--sp-media); }
.st-content iframe[src*="youtube"],
.st-content iframe[src*="youtu.be"],
.st-content iframe[src*="vimeo"],
.st-content video {
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
}
.st-content .wp-video,
.st-content .wp-audio-shortcode { width: 100% !important; max-width: 100%; }
.st-content .wp-block-embed { margin-block: 2em; }

/* Tables and code, if a story needs them. */
.st-content table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	border-collapse: collapse;
	font-size: 16px;
	line-height: 1.5;
}
.st-content th,
.st-content td {
	padding: 10px 14px;
	border-bottom: 1px solid var(--jf-line);
	text-align: start;
	vertical-align: top;
}
.st-content th { color: var(--jf-navy); font-weight: 700; }
.st-content code {
	padding: .1em .35em;
	font-size: .88em;
	background: var(--jf-sand);
}
.st-content pre {
	overflow-x: auto;
	padding: 18px 20px;
	font-size: 15px;
	line-height: 1.6;
	background: var(--jf-sand);
}
.st-content pre code { padding: 0; background: none; }

/* Multi-page stories (<!--nextpage-->). */
.st-parts {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	margin-top: 2em;
	font-size: 16px;
	font-weight: 600;
}

/* End of the story. */
.st-end {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-top: 64px;
	padding-top: 24px;
	border-top: 1px solid var(--jf-line);
}
.st-end__mark {
	flex: none;
	width: 7px;
	height: 7px;
	background: var(--jf-red);
	transform: rotate(45deg);
}
.st-end__link {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	font-size: 15px;
	font-weight: 600;
	color: var(--jf-navy);
}
.st-end__link:hover { color: var(--jf-red); }

/* Related stories ---------------------------------------------------------- */
.st-related {
	padding: 72px 0 88px;
	background: var(--jf-sand);
	border-top: 1px solid var(--jf-line);
}
.st-related__title {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 32px;
	font-family: var(--jf-serif);
	font-size: clamp(27px, 2.2vw, 32px);
	font-weight: 600;
	line-height: 1.25;
	color: var(--jf-navy);
}
.st-related__title::before {
	content: "";
	flex: none;
	width: 28px;
	height: 2px;
	background: var(--jf-red);
}
/* A little more compact than the Stories page cards. */
.st-related .sp-card__body { padding: 20px 22px 18px; }
.st-related .sp-card__title { font-size: 20px; -webkit-line-clamp: 3; }
.st-related .sp-card__excerpt { font-size: 15px; -webkit-line-clamp: 2; }
.st-related .sp-grid--1 .sp-card__title { font-size: 24px; }
.st-related .sp-grid--2 .sp-card__body { padding: 24px 26px 22px; }

/* Arabic: Tajawal throughout, with room for the script. ------------------- */
[dir="rtl"] .st-back { font-size: 16px; }
[dir="rtl"] .st-date { font-size: 15px; }
[dir="rtl"] .st-title,
[dir="rtl"] .st-content h2,
[dir="rtl"] .st-content blockquote,
[dir="rtl"] .st-related__title {
	font-family: var(--jf-arabic);
	font-weight: 700;
}
[dir="rtl"] .st-title { font-size: clamp(36px, 3.8vw, 52px); line-height: 1.35; }
[dir="rtl"] .st-title--long { font-size: clamp(30px, 3vw, 42px); line-height: 1.45; }
[dir="rtl"] .st-lead { font-size: 20px; line-height: 1.9; }
[dir="rtl"] .st-content { font-size: 20px; line-height: 1.95; }
[dir="rtl"] .st-content h2 { font-size: 29px; line-height: 1.5; }
[dir="rtl"] .st-content h3 { font-size: 23px; line-height: 1.55; }
[dir="rtl"] .st-content h4,
[dir="rtl"] .st-content h5,
[dir="rtl"] .st-content h6 { font-size: 20px; line-height: 1.6; }
[dir="rtl"] .st-content blockquote { font-size: 24px; line-height: 1.75; }
[dir="rtl"] .st-content blockquote cite,
[dir="rtl"] .st-content blockquote footer { font-family: var(--jf-arabic); font-size: 16px; }
[dir="rtl"] .st-content ol > li::marker { font-family: var(--jf-arabic); }
[dir="rtl"] .st-content .alignleft { margin-right: 32px; margin-left: 0; }
[dir="rtl"] .st-content .alignright { margin-left: 32px; margin-right: 0; }
[dir="rtl"] .st-caption,
[dir="rtl"] .st-content figcaption,
[dir="rtl"] .st-content .wp-caption-text { font-size: 15px; line-height: 1.8; }
[dir="rtl"] .st-content .gallery-caption { font-size: 14px; }
[dir="rtl"] .st-end__link { font-size: 16px; }
[dir="rtl"] .st-related__title { font-size: clamp(26px, 2.2vw, 31px); line-height: 1.45; }
[dir="rtl"] .st-related .sp-card__title { font-size: 20px; }
[dir="rtl"] .st-related .sp-card__excerpt { font-size: 16px; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1180px) {
	.st { --st-pad: 48px; }
}
@media (max-width: 1024px) {
	.st-stage { padding: 40px 0 80px; }
	.st-sheet { padding-top: 40px; }
	.st-hero { margin-top: 40px; }
	.st-hero__media { aspect-ratio: 16 / 10; }
	.st-hero--portrait .st-hero__media { aspect-ratio: 1 / 1; }
	.st-hero--brand { aspect-ratio: 3 / 1; }
	.st-related { padding: 64px 0 76px; }
	.st-related .sp-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
	.st { --st-pad: 40px; }
}
@media (max-width: 760px) {
	.st-stage { padding: 28px 0 64px; }
	.st-sheet { padding-top: 28px; padding-bottom: 44px; }
	.st-meta { margin-top: 18px; }
	.st-title { margin-top: 14px; font-size: clamp(32px, 8.2vw, 42px); line-height: 1.15; }
	.st-title--long { font-size: clamp(27px, 7vw, 34px); line-height: 1.2; }
	[dir="rtl"] .st-title { font-size: clamp(30px, 7.8vw, 40px); line-height: 1.4; }
	[dir="rtl"] .st-title--long { font-size: clamp(26px, 6.8vw, 32px); line-height: 1.5; }
	.st-lead { margin-top: 18px; font-size: 18px; }
	[dir="rtl"] .st-lead { font-size: 18px; }
	.st-hero { margin-top: 32px; }
	.st-hero__media { aspect-ratio: 3 / 2; }
	.st-hero--portrait .st-hero__media { aspect-ratio: 4 / 5; }
	.st-hero--brand { aspect-ratio: 5 / 2; }
	.st-content { margin-top: 40px; font-size: 18px; line-height: 1.72; }
	[dir="rtl"] .st-content { font-size: 18px; line-height: 1.95; }
	.st-content h2 { font-size: 26px; }
	[dir="rtl"] .st-content h2 { font-size: 25px; }
	.st-content h3,
	[dir="rtl"] .st-content h3 { font-size: 21px; }
	.st-content h4,
	[dir="rtl"] .st-content h4 { font-size: 18px; }
	.st-content blockquote { font-size: 22px; }
	[dir="rtl"] .st-content blockquote { font-size: 21px; }
	.st-end { margin-top: 48px; }
}
@media (max-width: 640px) {
	/* Phones: the sheet becomes the page, edge to edge, without a frame. */
	.st { --st-pad: var(--jf-gutter); }
	.st-stage { padding: 0; }
	.st-sheet {
		margin-inline: calc(-1 * var(--jf-gutter));
		padding-top: 24px;
		border: 0;
		box-shadow: none;
	}
	.st-sheet::before { display: none; }
	.st-content .alignleft,
	.st-content .alignright,
	[dir="rtl"] .st-content .alignleft,
	[dir="rtl"] .st-content .alignright {
		float: none;
		max-width: 100%;
		margin: 2em auto;
	}
	.st-content .gallery,
	.st-content .wp-block-gallery.columns-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	.st-content .gallery-columns-1 { grid-template-columns: minmax(0, 1fr); }
	.st-related { padding: 48px 0 60px; }
	.st-related__title { margin-bottom: 24px; }
	.st-related .sp-grid--3 { grid-template-columns: minmax(0, 1fr); }
}
