/*
 * Jordan Festival — Stories (the posts page, story categories and tags).
 * A compact ivory opening with the featured story set into it, then every
 * story as calm cards on sand (the homepage card DNA), category links and
 * numbered pages. No sidebar, no masonry: one reading rhythm.
 */

/* Display serif (SIL OFL, self-hosted), as on the homepage. */
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/playfair-display-600-0000.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

.sp {
	--sp-ivory: #FBF8F2;
	--sp-ivory-line: #EAE3D7;
	--sp-card: #FFFDF9;
	--sp-media: #ECE5D9;
	--sp-line-strong: #CDBFA9;
}

/* Shared ------------------------------------------------------------- */
.sp-kicker,
.sp-feature__label {
	display: flex;
	align-items: center;
	gap: 14px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .2em;
	text-transform: uppercase;
	color: var(--jf-navy);
}
.sp-rule { flex: none; width: 28px; height: 2px; background: var(--jf-red); }

.sp-card__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
}
.sp-cat {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--jf-red);
}
.sp-cat .diamond { flex: none; width: 5px; height: 5px; }
/* "Preview Content": a quiet label (small ring + text) on demo records. */
.sp-sample {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	min-height: 22px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .12em;
	line-height: 1.3;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--jf-ink-2);
}
.sp-sample::before {
	content: "";
	flex: none;
	width: 6px;
	height: 6px;
	border: 1px solid currentColor;
	border-radius: 50%;
	opacity: .75;
}

/* Whole card / feature is one link: the title link's ::after covers it. */
.sp-card__link,
.sp-card__link:hover {
	white-space: normal; /* links default to nowrap site-wide */
	color: inherit;
}
.sp-card__link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.sp-card__link:focus-visible { outline: none; }
.sp-card__link:focus-visible::after { outline: 2px solid var(--jf-navy); outline-offset: 4px; }

.sp-card__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 6px 16px;
	margin-top: auto;
	padding-top: 18px;
}
.sp-more {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 600;
	color: var(--jf-navy);
	transition: color .2s ease;
}
.sp-more .jf-arrow { color: var(--jf-red); transition: transform .2s ease; }
.sp-date { font-size: 13px; color: var(--jf-muted); }

/* Opening ------------------------------------------------------------ */
.sp-open {
	padding: 64px 0 56px;
	background: var(--sp-ivory);
	border-bottom: 1px solid var(--sp-ivory-line);
}
.sp-open--with-feature { padding-bottom: 72px; }
.sp-open__grid {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: 32px;
	align-items: end;
}
.sp-open__head { grid-column: 1 / span 7; min-width: 0; }
.sp-open__title {
	margin-top: 20px;
	font-family: var(--jf-serif);
	font-size: clamp(44px, 4.6vw, 68px);
	font-weight: 600;
	line-height: 1.05;
	letter-spacing: -.01em;
	color: var(--jf-navy);
	overflow-wrap: break-word;
	text-wrap: balance;
}
.sp-open__intro {
	grid-column: 8 / span 5;
	max-width: 34em;
	font-size: 18px;
	line-height: 1.7;
	color: var(--jf-ink-2);
	text-wrap: pretty;
}

/* Featured story ------------------------------------------------------ */
/*
 * The photo across most of the width; the story's panel set over its
 * lower edge. A static keffiyeh selvedge binds the photo's foot.
 */
.sp-feature {
	position: relative;
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: 32px;
	align-items: end;
	margin-top: 48px;
}
.sp-feature__media {
	position: relative;
	grid-column: 1 / span 8;
	grid-row: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	aspect-ratio: 16 / 10;
	background: var(--sp-media);
}
.sp-feature__media img:not(.sp-emblem) {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .7s ease;
}
.sp-feature__media::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	height: 6px;
	background: url("../images/brand/keffiyeh-selvedge.svg") repeat-x 0 0 / 6px 6px;
}
.sp-feature--no-image .sp-feature__media {
	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);
}
.sp-feature--no-image .sp-emblem { width: 64px; height: auto; opacity: .6; }

.sp-feature__panel {
	position: relative;
	z-index: 1;
	grid-column: 8 / span 5;
	grid-row: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	margin-bottom: -40px;
	padding: 36px 36px 30px;
	background: var(--sp-card);
	border: 1px solid var(--jf-line);
	box-shadow: 0 24px 48px -32px rgba(13, 30, 65, .35);
	transition: border-color .25s ease, box-shadow .25s ease;
}
.sp-feature__panel .sp-card__meta { margin-top: 22px; }
.sp-feature__title {
	margin-top: 12px;
	font-family: var(--jf-serif);
	font-size: clamp(26px, 2.3vw, 34px);
	font-weight: 600;
	line-height: 1.22;
	color: var(--jf-navy);
	overflow-wrap: break-word;
	text-wrap: pretty;
}
.sp-feature__excerpt {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 4;
	overflow: hidden;
	margin-top: 14px;
	font-size: 16px;
	line-height: 1.7;
	color: var(--jf-ink-2);
}
.sp-feature .sp-card__foot { padding-top: 24px; }

.sp-feature:hover .sp-feature__media img:not(.sp-emblem) { transform: scale(1.03); }
.sp-feature:hover .sp-feature__panel,
.sp-feature:focus-within .sp-feature__panel { border-color: var(--sp-line-strong); }
.sp-feature:hover .sp-more { color: var(--jf-red); }
.sp-feature:hover .sp-more .jf-arrow { transform: translateX(3px); }
[dir="rtl"] .sp-feature:hover .sp-more .jf-arrow { transform: translateX(-3px) scaleX(-1); }

/* All stories --------------------------------------------------------- */
.sp-list {
	padding: 72px 0 88px;
	background: var(--jf-sand);
	color: var(--jf-navy);
}
.sp-open--with-feature + .sp-list { padding-top: 104px; }
.sp-list__head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 18px 40px;
	margin-bottom: 32px;
}
.sp-list__title {
	font-family: var(--jf-serif);
	font-size: clamp(28px, 2.4vw, 34px);
	font-weight: 600;
	line-height: 1.2;
	color: var(--jf-navy);
}
.sp-list__page {
	margin-inline-start: 10px;
	font-family: var(--jf-font);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: .02em;
	color: var(--jf-muted);
}

/* Category links: plain server-side links that wrap; the current one underlined in red. */
.sp-filter__list {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 26px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.sp-filter__link {
	position: relative;
	display: inline-block;
	padding: 10px 0 8px;
	border-bottom: 2px solid transparent;
	font-size: 15px;
	font-weight: 600;
	color: var(--jf-ink-2);
	transition: color .2s ease, border-color .2s ease;
}
.sp-filter__link:hover { color: var(--jf-navy); border-bottom-color: var(--jf-line); }
.sp-filter__link[aria-current="page"] { color: var(--jf-navy); border-bottom-color: var(--jf-red); }
.sp-filter__link:focus-visible { outline: 2px solid var(--jf-navy); outline-offset: 3px; }
/* Larger tap area for short labels such as "All" (no visual change; half the gap each side). */
.sp-filter__link::after { content: ""; position: absolute; inset: 0 -10px; min-height: 44px; }

/* Grid: 3 / 2 / 1 columns. */
.sp-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 32px 28px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.sp-grid__cell { display: flex; min-width: 0; }

.sp-card {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
	background: var(--sp-card);
	border: 1px solid var(--jf-line);
	transition: border-color .25s ease, box-shadow .25s ease;
}
.sp-card__media {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: var(--sp-media);
}
.sp-card__media img:not(.sp-emblem) {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .6s ease;
}
/* No photo: a quiet sand lattice with the brand emblem. */
.sp-card--no-image .sp-card__media {
	background:
		repeating-linear-gradient(45deg, rgba(13, 30, 65, .05) 0 1px, transparent 1px 20px),
		repeating-linear-gradient(-45deg, rgba(13, 30, 65, .05) 0 1px, transparent 1px 20px),
		var(--sp-media);
}
.sp-card .sp-emblem { width: 44px; height: auto; opacity: .5; }
.sp-card__media::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	height: 6px;
	background: url("../images/brand/keffiyeh-selvedge.svg") repeat-x 0 0 / 6px 6px;
	transform: scaleX(0);
	transform-origin: left;
	transition: transform .45s ease;
}
[dir="rtl"] .sp-card__media::after { transform-origin: right; }

.sp-card__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
	padding: 24px 26px 22px;
}
.sp-card__title {
	margin-top: 12px;
	font-family: var(--jf-serif);
	font-size: 22px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--jf-navy);
	overflow-wrap: break-word;
	text-wrap: pretty;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 4;
	overflow: hidden;
}
.sp-card__body > .sp-card__title:first-child { margin-top: 0; }
.sp-card__excerpt {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
	margin-top: 10px;
	font-size: 16px;
	line-height: 1.65;
	color: var(--jf-ink-2);
}

.sp-card:hover,
.sp-card:focus-within { border-color: var(--sp-line-strong); box-shadow: 0 10px 28px -18px rgba(13, 30, 65, .35); }
.sp-card:hover .sp-card__media img:not(.sp-emblem) { transform: scale(1.04); }
.sp-card:hover .sp-card__media::after,
.sp-card:focus-within .sp-card__media::after { transform: scaleX(1); }
.sp-card:hover .sp-more { color: var(--jf-red); }
.sp-card:hover .sp-more .jf-arrow { transform: translateX(3px); }
[dir="rtl"] .sp-card:hover .sp-more .jf-arrow { transform: translateX(-3px) scaleX(-1); }

/* One or two stories: wider horizontal cards instead of empty columns. */
.sp-grid--1 .sp-card,
.sp-grid--2 .sp-card { display: grid; grid-template-columns: minmax(0, 46%) minmax(0, 1fr); }
.sp-grid--1 .sp-card__media,
.sp-grid--2 .sp-card__media { aspect-ratio: auto; min-height: 240px; height: 100%; }
.sp-grid--1 .sp-card__body,
.sp-grid--2 .sp-card__body { padding: 28px 30px 26px; }
.sp-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sp-grid--1 { grid-template-columns: minmax(0, 900px); }
.sp-grid--1 .sp-card__media { min-height: 300px; }
.sp-grid--1 .sp-card__title { font-size: 26px; }

/* Pagination ----------------------------------------------------------- */
.sp-pages { margin-top: 56px; }
.sp-pages__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.sp-pages .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-width: 44px;
	height: 44px;
	padding: 0 12px;
	border: 1px solid transparent;
	font-size: 15px;
	font-weight: 600;
	color: var(--jf-navy);
	transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.sp-pages a.page-numbers { border-color: var(--jf-line); background: var(--sp-card); }
.sp-pages a.page-numbers:hover { border-color: var(--jf-navy); }
.sp-pages a.page-numbers:focus-visible { outline: 2px solid var(--jf-navy); outline-offset: 3px; }
.sp-pages .page-numbers.current { background: var(--jf-navy); border-color: var(--jf-navy); color: #fff; }
.sp-pages .page-numbers.dots { min-width: 24px; padding: 0; color: var(--jf-muted); }
.sp-pages .prev,
.sp-pages .next { padding: 0 18px; }
.sp-pages__item--prev { margin-inline-end: 8px; }
.sp-pages__item--next { margin-inline-start: 8px; }
.sp-pages__arrow { color: var(--jf-red); }
/* The arrow glyph points forward; "Previous" turns it back (in RTL the global flip already does). */
.sp-pages__arrow--prev { transform: scaleX(-1); }
[dir="rtl"] .sp-pages__arrow--prev { transform: none; }

/* No stories ------------------------------------------------------------ */
.sp-empty {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	max-width: 760px;
	padding: 28px 30px;
	background: var(--sp-card);
	border: 1px solid var(--jf-line);
}
.sp-empty .diamond { flex: none; margin-top: 10px; }
.sp-empty__text { font-size: 18px; line-height: 1.7; color: var(--jf-ink-2); }
.sp-empty__link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
	padding-block: 6px;
	font-size: 15px;
	font-weight: 600;
	color: var(--jf-navy);
}
.sp-empty__link .jf-arrow { color: var(--jf-red); }
.sp-empty__link:hover { color: var(--jf-red); }

/* Arabic: Tajawal throughout, no tracking or capitals, more line height. */
[dir="rtl"] .sp-kicker,
[dir="rtl"] .sp-feature__label { font-size: 16px; letter-spacing: 0; text-transform: none; }
[dir="rtl"] .sp-open__title,
[dir="rtl"] .sp-feature__title,
[dir="rtl"] .sp-list__title,
[dir="rtl"] .sp-card__title { font-family: var(--jf-arabic); font-weight: 700; letter-spacing: 0; }
[dir="rtl"] .sp-open__title { font-size: clamp(42px, 4.4vw, 64px); line-height: 1.3; }
[dir="rtl"] .sp-open__intro { font-size: 19px; line-height: 1.9; }
[dir="rtl"] .sp-feature__title { font-size: clamp(26px, 2.2vw, 32px); line-height: 1.5; }
[dir="rtl"] .sp-feature__excerpt { font-size: 17px; line-height: 1.85; }
[dir="rtl"] .sp-list__title { font-size: clamp(28px, 2.3vw, 33px); line-height: 1.4; }
[dir="rtl"] .sp-list__page { font-family: var(--jf-arabic); letter-spacing: 0; font-size: 16px; }
[dir="rtl"] .sp-cat { font-size: 14px; letter-spacing: 0; text-transform: none; }
[dir="rtl"] .sp-sample { font-size: 12px; letter-spacing: 0; text-transform: none; }
[dir="rtl"] .sp-card__title { font-size: 21px; line-height: 1.55; }
[dir="rtl"] .sp-grid--1 .sp-card__title { font-size: 25px; }
[dir="rtl"] .sp-card__excerpt { font-size: 17px; line-height: 1.8; }
[dir="rtl"] .sp-more,
[dir="rtl"] .sp-filter__link,
[dir="rtl"] .sp-pages .page-numbers { font-size: 16px; }
[dir="rtl"] .sp-date { font-size: 14px; }
[dir="rtl"] .sp-empty__text { font-size: 18px; line-height: 1.9; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1024px) {
	.sp-open { padding: 56px 0 48px; }
	.sp-open--with-feature { padding-bottom: 64px; }
	.sp-open__head { grid-column: 1 / -1; }
	.sp-open__intro { grid-column: 1 / span 9; margin-top: 20px; }
	.sp-feature { margin-top: 40px; }
	.sp-feature__media { grid-column: 1 / span 7; aspect-ratio: 5 / 4; }
	.sp-feature__panel { grid-column: 7 / span 6; margin-bottom: -32px; padding: 30px 28px 26px; }
	.sp-list { padding: 64px 0 76px; }
	.sp-open--with-feature + .sp-list { padding-top: 88px; }
	.sp-grid,
	.sp-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 20px; }
	.sp-grid--2 .sp-card { display: flex; }
	.sp-grid--2 .sp-card__media { aspect-ratio: 16 / 9; min-height: 0; height: auto; }
	.sp-grid--2 .sp-card__body { padding: 24px 26px 22px; }
	.sp-card__body { padding: 22px 22px 20px; }
	.sp-card__title { font-size: 21px; }
	.sp-grid--1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
	/* The feature stacks: photo, then its panel lifted slightly over it. */
	.sp-feature { display: block; }
	.sp-feature__media { aspect-ratio: 16 / 10; }
	.sp-feature__panel { margin: -28px 16px 0; padding: 26px 24px 22px; }
	.sp-open--with-feature { padding-bottom: 48px; }
	.sp-open--with-feature + .sp-list { padding-top: 56px; }
	.sp-grid--1 .sp-card { display: flex; }
	.sp-grid--1 .sp-card__media { aspect-ratio: 16 / 9; min-height: 0; height: auto; }
	.sp-grid--1 .sp-card__body { padding: 22px 22px 20px; }
}
@media (max-width: 640px) {
	.sp-open { padding: 44px 0 40px; }
	.sp-open__grid { display: block; }
	.sp-open__intro { font-size: 17px; }
	[dir="rtl"] .sp-open__intro { font-size: 17px; }
	.sp-open__title { margin-top: 16px; font-size: clamp(38px, 10.5vw, 48px); }
	[dir="rtl"] .sp-open__title { font-size: clamp(36px, 10vw, 46px); }
	.sp-feature { margin-top: 32px; }
	.sp-feature__panel { margin: -24px 12px 0; padding: 22px 20px 20px; }
	.sp-feature__title { font-size: 24px; }
	[dir="rtl"] .sp-feature__title { font-size: 24px; }
	.sp-list { padding: 48px 0 60px; }
	.sp-list__head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 24px; }
	.sp-filter__list { gap: 0 20px; }
	.sp-grid,
	.sp-grid--2,
	.sp-grid--1 { grid-template-columns: minmax(0, 1fr); gap: 20px; }
	.sp-card__body,
	.sp-grid--2 .sp-card__body,
	.sp-grid--1 .sp-card__body { padding: 20px 20px 18px; }
	.sp-card__title,
	.sp-grid--1 .sp-card__title { font-size: 21px; }
	[dir="rtl"] .sp-card__title,
	[dir="rtl"] .sp-grid--1 .sp-card__title { font-size: 21px; }
	.sp-card__foot { padding-top: 16px; }
	.sp-more { padding-block: 6px; }
	.sp-pages { margin-top: 40px; }
	.sp-pages__list { gap: 6px; }
	.sp-pages .prev,
	.sp-pages .next { padding: 0 14px; }
	.sp-pages__item--prev,
	.sp-pages__item--next { margin-inline: 0; }
	.sp-empty { padding: 22px 20px; }
}
@media (max-width: 380px) {
	/* Very narrow: the Previous / Next words go; arrows and accessible names remain. */
	.sp-pages .prev > span:not(.jf-arrow),
	.sp-pages .next > span:not(.jf-arrow) {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
	.sp-pages .prev,
	.sp-pages .next { padding: 0; min-width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
	.sp-card,
	.sp-feature__panel,
	.sp-card__media img:not(.sp-emblem),
	.sp-feature__media img:not(.sp-emblem),
	.sp-card__media::after,
	.sp-more,
	.sp-more .jf-arrow,
	.sp-filter__link,
	.sp-pages .page-numbers { transition: none; }
	.sp-card:hover .sp-card__media img:not(.sp-emblem),
	.sp-feature:hover .sp-feature__media img:not(.sp-emblem),
	.sp-card:hover .sp-more .jf-arrow,
	.sp-feature:hover .sp-more .jf-arrow { transform: none; }
	[dir="rtl"] .sp-card:hover .sp-more .jf-arrow,
	[dir="rtl"] .sp-feature:hover .sp-more .jf-arrow { transform: scaleX(-1); }
}
