/*
 * Something Historic Stories: front-end styles.
 *
 * Colours come from CSS custom properties so the theme can restyle
 * everything; the fallbacks keep the plugin usable with any theme.
 * Only logical properties (inline-start/end) are used, so Urdu (RTL)
 * pages mirror automatically.
 */

:root {
	--sh-accent: #a67c2d;
	--sh-accent-strong: #7a5a1e;
	--sh-text: #2b2118;
	--sh-muted: #6f5d4a;
	--sh-surface: #fffaf0;
	--sh-surface-2: #f3e8d2;
	--sh-border: #e0cfae;
	--sh-radius: 10px;
	--sh-shadow: 0 1px 2px rgb(43 33 24 / 6%), 0 8px 24px rgb(43 33 24 / 8%);
}

/* Reading progress bar */
.sh-progress {
	position: fixed;
	inset-block-start: 0;
	inset-inline: 0;
	z-index: 10000;
	height: 4px;
	background: transparent;
	pointer-events: none;
}

.admin-bar .sh-progress { inset-block-start: 32px; }

@media (max-width: 782px) {
	.admin-bar .sh-progress { inset-block-start: 46px; }
}

.sh-progress__bar {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, var(--sh-accent-strong), var(--sh-accent));
	transform: scaleX(0);
	transform-origin: left center;
	will-change: transform;
}

[dir="rtl"] .sh-progress__bar,
.rtl .sh-progress__bar {
	background: linear-gradient(270deg, var(--sh-accent-strong), var(--sh-accent));
	transform-origin: right center;
}

/* Icons: arrows point the reading direction, so mirror them in RTL. */
.sh-icon { flex: none; vertical-align: middle; }
[dir="rtl"] .sh-icon,
.rtl .sh-icon { transform: scaleX(-1); }

.sh-sep { margin-inline: 0.4em; color: var(--sh-muted); }

/* Episode meta */
.sh-episode-meta {
	margin-block-end: 2em;
	padding-block-end: 1em;
	border-block-end: 1px solid var(--sh-border);
	color: var(--sh-muted);
	font-size: 0.95em;
}

.sh-episode-meta p { margin: 0 0 0.35em; }
.sh-episode-meta a { color: var(--sh-accent-strong); text-decoration: none; }
.sh-episode-meta a:hover { text-decoration: underline; }
.sh-episode-meta__series { font-weight: 600; letter-spacing: 0.02em; }
.sh-episode-label { font-weight: 600; color: var(--sh-text); }

/* Release notice */
.sh-release-notice {
	margin: 2.5em 0 1.5em;
	padding: 1em 1.25em;
	border: 1px dashed var(--sh-accent);
	border-radius: var(--sh-radius);
	background: var(--sh-surface-2);
	color: var(--sh-text);
	text-align: center;
	font-weight: 600;
}

/* Previous / next */
.sh-episode-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 1em;
	margin: 2.5em 0;
}

.sh-episode-nav__link {
	flex: 1 1 240px;
	display: flex;
	align-items: center;
	gap: 0.75em;
	padding: 1em 1.25em;
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	background: var(--sh-surface);
	color: var(--sh-text);
	text-decoration: none;
	transition: border-color 0.2s, transform 0.2s;
}

.sh-episode-nav__link:hover,
.sh-episode-nav__link:focus-visible {
	border-color: var(--sh-accent);
	transform: translateY(-2px);
	color: var(--sh-text);
}

.sh-episode-nav__link span { display: flex; flex-direction: column; min-width: 0; }
.sh-episode-nav__link small { color: var(--sh-muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.08em; }
.sh-episode-nav__link strong { font-weight: 600; }
.sh-episode-nav__link--next { justify-content: flex-end; text-align: end; margin-inline-start: auto; }

/* Episode list */
.sh-series-episodes { margin-block-start: 3em; }
.sh-series-episodes__title { font-size: 1.25em; margin-block-end: 0.75em; }
.sh-series-episodes__title a { color: inherit; }

.sh-episode-list {
	list-style: none;
	margin: 0;
	padding: 0;
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	overflow: hidden;
	background: var(--sh-surface);
}

.sh-episode-list__item + .sh-episode-list__item { border-block-start: 1px solid var(--sh-border); }

.sh-episode-list__item a {
	display: grid;
	grid-template-columns: 2.5em 1fr auto;
	align-items: center;
	gap: 0.75em;
	padding: 0.85em 1em;
	color: var(--sh-text);
	text-decoration: none;
}

.sh-episode-list__item a:hover { background: var(--sh-surface-2); }

.sh-episode-list__number {
	display: inline-grid;
	place-items: center;
	width: 2.2em;
	height: 2.2em;
	border-radius: 50%;
	border: 1px solid var(--sh-accent);
	color: var(--sh-accent-strong);
	font-weight: 700;
	font-size: 0.9em;
}

.sh-episode-list__time { color: var(--sh-muted); font-size: 0.85em; white-space: nowrap; }

.sh-episode-list__item.is-current a { background: var(--sh-surface-2); font-weight: 700; }
.sh-episode-list__item.is-current .sh-episode-list__number { background: var(--sh-accent); color: #fff; border-color: var(--sh-accent); }

/* Cards and grids */
.sh-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
	gap: 1.5em;
	margin-block: 1.5em;
}

.sh-card {
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	background: var(--sh-surface);
	overflow: hidden;
	box-shadow: var(--sh-shadow);
	transition: transform 0.2s, box-shadow 0.2s;
}

.sh-card:hover { transform: translateY(-3px); }
.sh-card__link { display: flex; flex-direction: column; height: 100%; color: var(--sh-text); text-decoration: none; }
.sh-card__link:hover { color: var(--sh-text); }
.sh-card__media { position: relative; aspect-ratio: 16 / 10; background: var(--sh-surface-2); overflow: hidden; }
.sh-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.sh-card__placeholder {
	position: absolute;
	inset: 0;
	background:
		radial-gradient(circle at 30% 30%, rgb(255 255 255 / 35%), transparent 60%),
		linear-gradient(135deg, var(--sh-surface-2), var(--sh-border));
}

.sh-card__body { padding: 1em 1.25em 1.25em; display: flex; flex-direction: column; gap: 0.4em; }
.sh-card__eyebrow { margin: 0; color: var(--sh-accent-strong); font-size: 0.8em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.sh-card__title { margin: 0; font-size: 1.2em; line-height: 1.35; }
.sh-card__excerpt { margin: 0; color: var(--sh-muted); font-size: 0.95em; }
.sh-card__meta { margin: auto 0 0; color: var(--sh-muted); font-size: 0.85em; }

.sh-badge {
	display: inline-block;
	padding: 0.2em 0.7em;
	border-radius: 999px;
	background: var(--sh-accent);
	color: #fff;
	font-size: 0.75em;
	font-weight: 700;
	letter-spacing: 0.04em;
}

.sh-card__media .sh-badge { position: absolute; inset-block-start: 0.75em; inset-inline-start: 0.75em; }
.sh-badge--completed { background: #3f6b45; }

/* Empire and series pages */
.sh-content-area { width: 100%; float: none; }

.sh-hero {
	position: relative;
	display: grid;
	min-height: 260px;
	margin-block-end: 2em;
	border-radius: var(--sh-radius);
	overflow: hidden;
	background: linear-gradient(135deg, var(--sh-surface-2), var(--sh-border));
	color: var(--sh-text);
}

.sh-hero.has-image { min-height: min(60vh, 520px); color: #fff; }
.sh-hero__image { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: cover; }
.sh-hero.has-image::after { content: ""; grid-area: 1 / 1; background: linear-gradient(to top, rgb(20 14 8 / 85%), rgb(20 14 8 / 15%) 70%); }

.sh-hero__content {
	grid-area: 1 / 1;
	align-self: end;
	position: relative;
	z-index: 1;
	padding: clamp(1.25em, 4vw, 3em);
}

.sh-hero__eyebrow { margin: 0 0 0.25em; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.85em; font-weight: 600; }
.sh-hero__eyebrow a { color: inherit; }
.sh-hero__title { margin: 0 0 0.25em; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.15; color: inherit; }
.sh-hero__period { margin: 0 0 1em; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75em; font-size: 1.1em; }

.sh-button {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.75em 1.4em;
	border-radius: 999px;
	background: var(--sh-accent);
	color: #fff;
	font-weight: 700;
	text-decoration: none;
}

.sh-button:hover,
.sh-button:focus-visible { background: var(--sh-accent-strong); color: #fff; }

.sh-intro { display: grid; gap: 2em; margin-block-end: 2.5em; font-size: 1.1em; }
.sh-intro__map { margin: 0; }
.sh-intro__map img { width: 100%; height: auto; border-radius: var(--sh-radius); border: 1px solid var(--sh-border); }
.sh-intro__map figcaption { color: var(--sh-muted); font-size: 0.85em; margin-block-start: 0.5em; }

@media (min-width: 768px) {
	.sh-intro.has-map { grid-template-columns: 3fr 2fr; align-items: start; }
}

.sh-section { margin-block-end: 3em; }
.sh-section__title { font-size: 1.6em; margin-block-end: 0.5em; }
.sh-empty { color: var(--sh-muted); font-style: italic; }

@media (prefers-reduced-motion: reduce) {
	.sh-card,
	.sh-episode-nav__link { transition: none; }
	.sh-card:hover,
	.sh-episode-nav__link:hover { transform: none; }
}
