/* ============================================================================
 * FABULA — Characters
 *
 * The roster and the four profiles. This file holds the structure and a token
 * contract; each character's own `themes/<slug>.css` overrides the tokens (and
 * adds its ornament and motion) so every profile reads as its own artefact
 * while the layout stays one shape.
 *
 * Tokens are read off the shared `fabula.css` theme by default, so a character
 * only has to say what makes them different.
 * ========================================================================== */

/* --- Token contract ------------------------------------------------------ *
 *
 * `--ch-accent`   the character's primary hue: name, section titles and their
 *                 diamonds, panel top rules, class/skill rails, Attribute dice,
 *                 Skill Level values and the primary button.
 * `--ch-accent-2` the secondary hue: epithet, quote rule, chips, Class levels,
 *                 meta underlines, timeline dots and the arrow ornaments.
 * `--ch-rule` /   the structural hairlines. Both are always derived from
 * `--ch-rule-soft` `--ch-accent`, never from ink, so every theme's borders
 *                 read as the same material in a different colour.
 *
 * A theme may restate the surfaces, ink, accents, rules and masthead; it must
 * keep the roles above. `themes/<slug>.css` does exactly that and nothing else.
 * ------------------------------------------------------------------------- */

.ch {
	--ch-ground: var(--fu-bg);
	--ch-texture: none;
	--ch-masthead: linear-gradient(180deg, var(--fu-teal-deep), var(--fu-teal) 140%);
	--ch-panel: var(--fu-panel);
	--ch-panel-alt: var(--fu-panel-alt);
	--ch-ink: var(--fu-ink);
	--ch-ink-dim: var(--fu-ink-dim);
	--ch-ink-faint: var(--fu-ink-faint);
	--ch-accent: var(--fu-teal);
	--ch-accent-soft: var(--fu-teal-soft);
	--ch-accent-2: var(--fu-gold);
	--ch-rule: var(--fu-rule);
	--ch-rule-soft: var(--fu-rule-soft);
	--ch-glow: transparent;
	--ch-shadow: var(--fu-shadow-sm);
}

body.ch {
	background-color: var(--ch-ground);
	background-image: var(--ch-texture);
	background-attachment: fixed;
	color: var(--ch-ink);
}

.ch .fu-masthead {
	background: var(--ch-masthead);
}

.ch a {
	color: var(--ch-accent-soft);
}

.ch a:hover {
	color: var(--ch-accent-2);
}

.ch .fu-shell {
	width: min(100% - 2rem, var(--fu-shell));
	margin-inline: auto;
}

/* The crest definitions are injected once by render.js; sizing and line
   weight live with the badge that shows them. */
.ch-crest-sprite {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
}

/* --- Hero ---------------------------------------------------------------- */

.ch-hero {
	position: relative;
	overflow: hidden;
	padding: clamp(2.6rem, 7vw, 4.4rem) 0 2.2rem;
	border-bottom: 1px solid var(--ch-rule);
}

.ch-hero__inner {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 1.6rem 3rem;
	align-items: center;
}

.ch-hero__epithet {
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.32em;
	font-size: 0.76rem;
	color: var(--ch-accent-2);
	margin: 0 0 0.5rem;
}

.ch-hero__name {
	font-family: var(--fu-font-display);
	font-weight: 700;
	font-size: clamp(2.4rem, 7vw, 4.2rem);
	line-height: 1;
	letter-spacing: 0.03em;
	margin: 0;
	color: var(--ch-accent);
}

.ch-hero__aka {
	font-family: var(--fu-font-meta);
	font-size: 0.85rem;
	letter-spacing: 0.06em;
	color: var(--ch-ink-faint);
	margin: 0.5rem 0 0;
}

.ch-hero__quote {
	margin: 1.3rem 0 0;
	max-width: 44rem;
	font-size: 1.02rem;
	font-style: italic;
	line-height: 1.7;
	color: var(--ch-ink-dim);
	border-left: 2px solid var(--ch-accent-2);
	padding-left: 1rem;
}

.ch-hero__portrait {
	position: relative;
	width: clamp(150px, 22vw, 230px);
	aspect-ratio: 1;
	isolation: isolate;
}

.ch-hero__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
	border: 2px solid var(--ch-accent);
	background: var(--ch-panel);
	box-shadow:
		0 0 0 6px color-mix(in srgb, var(--ch-accent-2) 18%, transparent),
		0 12px 30px var(--ch-glow);
}

.ch-hero__crest {
	position: absolute;
	right: -3%;
	bottom: -3%;
	width: 42%;
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	padding: 7%;
	color: var(--ch-accent);
	background: var(--ch-panel);
	border: 2px solid color-mix(in srgb, var(--ch-accent) 55%, transparent);
	border-radius: 50%;
	box-shadow:
		var(--ch-shadow),
		0 0 0 4px color-mix(in srgb, var(--ch-accent) 12%, transparent);
}

.ch-hero__crest svg {
	width: 100%;
	height: 100%;
	stroke-width: 2.6;
}

/* --- Main column --------------------------------------------------------- */

.ch-main {
	padding-block: 2.4rem 3.4rem;
	max-width: 860px;
}

.ch-profile {
	display: grid;
	gap: 2.4rem;
}

.ch-section + .ch-section {
	margin-top: 0;
}

.ch-section__title {
	display: flex;
	align-items: baseline;
	gap: 0.7rem;
	font-family: var(--fu-font-display);
	font-size: 1.3rem;
	letter-spacing: 0.06em;
	color: var(--ch-accent);
	margin: 0 0 1rem;
}

.ch-section__title::before {
	content: "◆";
	color: var(--ch-accent-2);
	font-size: 0.68em;
}

/* --- Overview / sheet ---------------------------------------------------- */

.ch-panel {
	background: var(--ch-panel);
	border: 1px solid var(--ch-rule);
	border-top: 3px solid var(--ch-accent);
	border-radius: var(--fu-radius);
	box-shadow: var(--ch-shadow);
	padding: 1.4rem 1.5rem;
}

.ch-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 1rem 1.6rem;
	margin: 0;
}

.ch-stat dt {
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.16em;
	font-size: 0.7rem;
	color: var(--ch-ink-faint);
	margin-bottom: 0.25rem;
}

.ch-stat dd {
	margin: 0;
	font-size: 1.05rem;
	color: var(--ch-ink);
}

.ch-stat--wide {
	grid-column: 1 / -1;
}

.ch-attrs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.ch-attr {
	display: inline-flex;
	align-items: baseline;
	gap: 0.4rem;
	background: var(--ch-panel-alt);
	border: 1px solid var(--ch-rule-soft);
	border-radius: 2px;
	padding: 0.28rem 0.6rem;
}

.ch-attr__die {
	font-family: var(--fu-font-display);
	font-weight: 700;
	font-size: 1.05rem;
	color: var(--ch-accent);
}

.ch-attr__name {
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-size: 0.68rem;
	color: var(--ch-ink-dim);
}

.ch-synced {
	margin: 1rem 0 0;
	font-family: var(--fu-font-meta);
	font-size: 0.78rem;
	letter-spacing: 0.05em;
	color: var(--ch-ink-faint);
}

/* --- Classes & Skills ---------------------------------------------------- */

.ch-classskills {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 1rem;
}

.ch-cskills {
	background: var(--ch-panel);
	border: 1px solid var(--ch-rule-soft);
	border-left: 3px solid var(--ch-accent);
	border-radius: 0 var(--fu-radius) var(--fu-radius) 0;
	padding: 0.9rem 1rem;
}

.ch-cskills__title {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.6rem;
	margin: 0 0 0.6rem;
	font-family: var(--fu-font-display);
	font-size: 1.05rem;
	color: var(--ch-ink);
}

.ch-cskills__lvl {
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-size: 0.68rem;
	color: var(--ch-accent-2);
}

.ch-skilllist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.3rem;
}

.ch-skillrow {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.8rem;
	font-size: 0.92rem;
	border-bottom: 1px dashed var(--ch-rule-soft);
	padding-bottom: 0.3rem;
}

.ch-skillrow:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.ch-skillrow__name {
	color: var(--ch-ink);
}

.ch-skillrow__sl {
	font-family: var(--fu-font-meta);
	font-size: 0.76rem;
	letter-spacing: 0.06em;
	color: var(--ch-accent);
	white-space: nowrap;
}

/* --- Lore ---------------------------------------------------------------- */

.ch-lore p {
	margin: 0 0 1.1em;
	line-height: 1.75;
}

.ch-lore p:first-of-type {
	font-size: 1.06rem;
	color: var(--ch-ink);
}

.ch-lore p:first-of-type::first-letter {
	float: left;
	font-family: var(--fu-font-display);
	font-size: 3.3em;
	line-height: 0.78;
	padding: 0.08em 0.12em 0 0;
	color: var(--ch-accent);
}

/* --- Identity / Theme / Origin ------------------------------------------- */

.ch-meta {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 1rem;
}

.ch-metaitem {
	background: var(--ch-panel);
	border: 1px solid var(--ch-rule-soft);
	border-bottom: 3px solid var(--ch-accent-2);
	border-radius: var(--fu-radius);
	padding: 0.9rem 1rem;
}

.ch-metaitem__label {
	display: block;
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.16em;
	font-size: 0.66rem;
	color: var(--ch-ink-faint);
	margin-bottom: 0.3rem;
}

.ch-metaitem__value {
	font-family: var(--fu-font-display);
	font-size: 1.02rem;
	color: var(--ch-ink);
}

/* --- Relationships ------------------------------------------------------- */

.ch-rel-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.6rem;
}

.ch-rel {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem 1rem;
	background: var(--ch-panel);
	border: 1px solid var(--ch-rule-soft);
	border-left: 3px solid var(--ch-accent);
	border-radius: 0 var(--fu-radius) var(--fu-radius) 0;
	padding: 0.7rem 1rem;
}

.ch-rel__target {
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-size: 0.9rem;
	color: var(--ch-ink);
	min-width: 9rem;
}

.ch-rel__disp {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.ch-chip {
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-size: 0.66rem;
	color: var(--ch-accent-2);
	border: 1px solid var(--ch-rule);
	border-radius: 999px;
	padding: 0.16rem 0.6rem;
}

/* --- Timeline ------------------------------------------------------------ */

.ch-events {
	list-style: none;
	margin: 0;
	padding: 0 0 0 1.2rem;
	border-left: 2px solid var(--ch-rule);
	display: grid;
	gap: 1.4rem;
}

.ch-event {
	position: relative;
}

.ch-event::before {
	content: "";
	position: absolute;
	left: calc(-1.2rem - 5px);
	top: 0.45rem;
	width: 8px;
	height: 8px;
	transform: rotate(45deg);
	background: var(--ch-accent-2);
}

.ch-event__date {
	display: block;
	font-family: var(--fu-font-meta);
	text-transform: uppercase;
	letter-spacing: 0.14em;
	font-size: 0.72rem;
	color: var(--ch-accent);
	margin-bottom: 0.25rem;
}

.ch-event__body h3 {
	margin: 0 0 0.2rem;
	font-family: var(--fu-font-display);
	font-size: 1.06rem;
	letter-spacing: 0.02em;
	color: var(--ch-ink);
}

.ch-event__body p {
	margin: 0;
	color: var(--ch-ink-dim);
	line-height: 1.7;
}

/* --- Profile footer links ------------------------------------------------ */

.ch-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.8rem;
	margin-top: 2.6rem;
}

.ch .ch-action {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-size: 0.78rem;
	text-decoration: none;
	padding: 0.6rem 1.1rem;
	border: 1px solid var(--ch-rule);
	border-radius: var(--fu-radius);
	color: var(--ch-ink);
	background: var(--ch-panel);
	transition: background 130ms ease, border-color 130ms ease, transform 130ms ease;
}

.ch .ch-action:hover,
.ch .ch-action:focus-visible {
	background: var(--ch-panel-alt);
	border-color: var(--ch-accent-2);
	color: var(--ch-ink);
	transform: translateY(-1px);
}

.ch .ch-action--primary {
	background: var(--ch-accent);
	border-color: var(--ch-accent);
	color: #f4efe2;
}

.ch .ch-action--primary:hover,
.ch .ch-action--primary:focus-visible {
	color: #f4efe2;
}

.ch-action::after {
	content: "➤";
	color: var(--ch-accent-2);
}

/* --- Roster -------------------------------------------------------------- */

.ch-roster-head {
	padding: clamp(2.4rem, 6vw, 3.6rem) 0 0.4rem;
}

.ch-roster-head__title {
	font-family: var(--fu-font-display);
	font-size: clamp(2.2rem, 6vw, 3.2rem);
	letter-spacing: 0.1em;
	margin: 0;
	color: var(--ch-accent);
}

.ch-roster-head__sub {
	margin: 0.5rem 0 0;
	max-width: 46rem;
	color: var(--ch-ink-dim);
}

.ch-roster {
	list-style: none;
	margin: 2.2rem 0 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 1.4rem;
}

.ch-card {
	min-width: 0;
}

.ch-card__link {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.35rem;
	height: 100%;
	padding: 1.6rem 1.4rem 1.4rem;
	background:
		linear-gradient(180deg, var(--ch-panel), var(--ch-panel-alt));
	border: 1px solid var(--ch-rule);
	border-top: 3px solid var(--ch-accent);
	border-radius: var(--fu-radius);
	box-shadow: var(--ch-shadow);
	color: var(--ch-ink);
	text-decoration: none;
	transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.ch-card__link:hover,
.ch-card__link:focus-visible {
	transform: translateY(-4px);
	box-shadow: var(--fu-shadow);
	border-top-color: var(--ch-accent-2);
	color: var(--ch-ink);
}

.ch-card__portrait {
	position: relative;
	width: 4.4rem;
	height: 4.4rem;
	margin-bottom: 0.7rem;
}

.ch-card__portrait img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
	border: 2px solid var(--ch-accent);
	background: var(--ch-panel-alt);
}

.ch-card__crest {
	position: absolute;
	right: -0.45rem;
	bottom: -0.45rem;
	width: 2.1rem;
	height: 2.1rem;
	display: grid;
	place-items: center;
	padding: 0.3rem;
	color: var(--ch-accent);
	background: var(--ch-panel);
	border: 2px solid color-mix(in srgb, var(--ch-accent) 55%, transparent);
	border-radius: 50%;
}

.ch-card__crest svg {
	width: 100%;
	height: 100%;
	stroke-width: 3;
}

.ch-card__name {
	font-family: var(--fu-font-display);
	font-size: 1.4rem;
	letter-spacing: 0.03em;
	color: var(--ch-accent);
}

.ch-card__epithet {
	font-size: 0.94rem;
	color: var(--ch-ink-dim);
}

.ch-card__aka {
	font-family: var(--fu-font-meta);
	font-size: 0.76rem;
	letter-spacing: 0.06em;
	color: var(--ch-ink-faint);
}

.ch-card__meta {
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.14em;
	font-size: 0.72rem;
	color: var(--ch-accent-2);
	margin-top: 0.3rem;
}

.ch-card__tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin-top: 0.7rem;
}

.ch-card__go {
	margin-top: auto;
	padding-top: 1rem;
	font-family: var(--fu-font-head);
	text-transform: uppercase;
	letter-spacing: 0.16em;
	font-size: 0.72rem;
	color: var(--ch-ink-faint);
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.ch-card__go::after {
	content: "➤";
	color: var(--ch-accent-2);
	transition: transform 140ms ease;
}

.ch-card__link:hover .ch-card__go::after {
	transform: translateX(3px);
}

/* --- Motion -------------------------------------------------------------- */

@keyframes ch-rise {
	from {
		opacity: 0;
		transform: translateY(16px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ch-slide {
	from {
		opacity: 0;
		transform: translateX(-14px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.ch-hero__epithet,
	.ch-hero__name,
	.ch-hero__quote,
	.ch-hero__portrait {
		animation: ch-rise 620ms var(--fu-ease-settle) both;
	}

	.ch-hero__epithet { animation-delay: 40ms; }
	.ch-hero__name { animation-delay: 110ms; }
	.ch-hero__quote { animation-delay: 180ms; }
	.ch-hero__portrait { animation-delay: 140ms; }

	.ch-event {
		animation: ch-slide 560ms var(--fu-ease-out) both;
	}

	.ch-event:nth-child(2) { animation-delay: 60ms; }
	.ch-event:nth-child(3) { animation-delay: 120ms; }
	.ch-event:nth-child(4) { animation-delay: 180ms; }
	.ch-event:nth-child(5) { animation-delay: 240ms; }

	.ch-card__link {
		animation: ch-rise 560ms var(--fu-ease-settle) both;
	}

	.ch-card:nth-child(2) .ch-card__link { animation-delay: 70ms; }
	.ch-card:nth-child(3) .ch-card__link { animation-delay: 140ms; }
	.ch-card:nth-child(4) .ch-card__link { animation-delay: 210ms; }
}

/* --- Small screens ------------------------------------------------------- */

@media (width <= 760px) {
	.ch-hero__inner {
		grid-template-columns: 1fr;
	}

	.ch-hero__portrait {
		order: -1;
	}

	.ch-rel__target {
		min-width: 0;
	}
}
