/* ---------- Story mode: banner, way up to the Summit, scenes, squad ---------- */

.r-mythic {
	--rarity: #9b6bff;
}

/* Home banner. */
.story-banner {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0 0 var(--sp-3);
	padding: var(--sp-2) var(--sp-4);
	border: var(--bw) solid var(--line);
	border-radius: var(--r-2);
	background: linear-gradient(120deg, #2b2a6b, #6b3fd0 60%, #ffcf33 140%);
	box-shadow: var(--shadow);
	color: #fff8ec;
	text-decoration: none;
}

.story-banner-title {
	font-size: var(--fs-3);
	font-weight: 800;
	line-height: 1.1;
}

.story-banner small {
	font-size: var(--fs-1);
	font-weight: 700;
	opacity: 0.9;
}

/* The way up: the Summit first, chapters below, the current one centred. */
.story-path {
	display: flex;
	flex-direction: column;
	gap: var(--sp-4);
	margin: var(--sp-3) 0 var(--sp-6);
	padding: 0;
	list-style: none;
}

.story-chapter,
.story-summit {
	position: relative;
	padding: var(--sp-3) var(--sp-4) var(--sp-4);
	border: var(--bw) solid var(--line);
	border-radius: var(--r-3);
	background: var(--panel);
	box-shadow: var(--shadow);
}

/* The path between two islands. */
.story-chapter::before {
	content: '';
	position: absolute;
	left: 50%;
	top: calc(-1 * var(--sp-4) - var(--bw));
	height: var(--sp-4);
	border-left: var(--bw) dashed var(--line);
}

.story-chapter h2,
.story-summit h2 {
	margin: 0;
	font-size: var(--fs-4);
	line-height: 1.1;
}

.chapter-kicker {
	margin: 0;
	color: var(--muted);
	font-size: var(--fs-1);
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.chapter-count {
	margin: 2px 0 var(--sp-2);
	font-weight: 700;
}

.story-chapter.is-current,
.story-summit.is-current {
	border-color: var(--accent);
	box-shadow: 4px 4px 0 var(--accent);
}

.story-chapter.is-cleared .chapter-count {
	color: var(--good);
}

/* Chapters not reached yet: faded content, the panel stays opaque over
   the map. */
.story-chapter.is-ahead > * {
	opacity: 0.55;
}

.chapter-bosses {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sp-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.chapter-boss {
	position: relative;
	width: 56px;
	height: 56px;
	padding: 0;
	overflow: visible;
	border: var(--bw) solid var(--rarity, var(--line));
	border-radius: var(--r-1);
	background: var(--panel);
	cursor: pointer;
}

.chapter-boss svg {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: calc(var(--r-1) - 3px);
}

.chapter-boss:not(.is-won) svg {
	filter: grayscale(0.8);
	opacity: 0.75;
}

.won-mark {
	position: absolute;
	right: -8px;
	bottom: -8px;
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	border: 2px solid var(--line);
	border-radius: var(--r-full);
	background: var(--good);
	color: #fff;
}

.won-mark svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 3;
}

.chapter-trial {
	width: 100%;
	margin-top: var(--sp-3);
}

.story-summit {
	display: grid;
	grid-template-columns: 96px 1fr;
	gap: var(--sp-3);
	align-items: center;
	background: linear-gradient(160deg, #2b2a6b, #1d1546);
	color: #fff8ec;
}

.story-summit .chapter-kicker {
	color: #ffcf33;
}

.story-summit p {
	margin: var(--sp-1) 0 var(--sp-2);
}

.summit-face {
	overflow: hidden;
	border: var(--bw) solid #ffcf33;
	border-radius: var(--r-2);
}

.summit-face svg {
	display: block;
	width: 100%;
	height: auto;
}

.story-summit.is-locked .summit-face svg {
	filter: brightness(0.35) saturate(0.4);
}

/* ---------- Story backgrounds (js/story-bg.js) ---------- */

/* Landscape illustrations: on a phone only a part shows, bg-<id> keeps the
   interesting part in view. A veil keeps texts and buttons readable. */
.bg-map {
	--story-focus: 42% 30%;
}
.bg-island-sun {
	--story-focus: 62% 50%;
}
.bg-island-moon {
	--story-focus: 40% 40%;
}
.bg-island-thunder {
	--story-focus: 70% 45%;
}
.bg-summit {
	--story-focus: 45% 50%;
}

.app.has-story-bg {
	background: linear-gradient(color-mix(in srgb, var(--paper) 30%, transparent), color-mix(in srgb, var(--paper) 80%, transparent)), var(--story-bg) var(--story-focus, center) / cover no-repeat;
}

/* The dock fades into the paper colour on plain screens; over an
   illustration that fade draws a band cut at the column margins. The
   buttons have their own border and shadow. */
.app.has-story-bg .dock {
	background: none;
}

.app-scene.has-story-bg {
	background: linear-gradient(rgba(20, 16, 31, 0) 30%, rgba(20, 16, 31, 0.6)), var(--story-bg) var(--story-focus, center) / cover no-repeat;
}

.app-fight.has-story-bg {
	background: linear-gradient(color-mix(in srgb, var(--paper) 15%, transparent), color-mix(in srgb, var(--paper) 92%, transparent) 55%), var(--story-bg) var(--story-focus, center) / cover no-repeat;
}

/* Round, points and messages stay readable over the arena. */
.app-fight.has-story-bg .feedback:not(:empty) {
	align-self: center;
	padding: 0 var(--sp-3);
	border-radius: var(--r-2);
	background: color-mix(in srgb, var(--paper) 88%, transparent);
}

.app-fight.has-story-bg .play-top {
	padding: 2px var(--sp-1);
	border-radius: var(--r-full);
	background: color-mix(in srgb, var(--paper) 85%, transparent);
}

/* ---------- Scenes: one manga panel at a time ---------- */

.app-scene {
	background: radial-gradient(circle at 50% 30%, #6b3fd0, #1d1546 75%);
}

.scene {
	flex: 1;
	display: grid;
	place-items: center;
	padding: var(--sp-4) 0;
}

.scene-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--sp-3);
	width: 100%;
	max-width: 420px;
}

.scene-panel.enter {
	animation: enter 380ms var(--ease-back);
}

.scene-face {
	width: min(62vw, 260px);
	overflow: hidden;
	border: var(--bw) solid var(--line);
	border-radius: var(--r-3);
	box-shadow: var(--shadow-lg);
}

.scene-face svg {
	display: block;
	width: 100%;
	height: auto;
}

.scene-name {
	margin: 0;
	padding: 0 var(--sp-3);
	border: 2px solid var(--line);
	border-radius: var(--r-full);
	background: #ffcf33;
	color: #14101f;
	font-weight: 800;
}

.scene-bubble {
	position: relative;
	margin: 0;
	padding: var(--sp-3) var(--sp-4);
	border: var(--bw) solid #14101f;
	border-radius: var(--r-3);
	background: #ffffff;
	color: #14101f;
	box-shadow: 4px 4px 0 #14101f;
	font-size: var(--fs-3);
	font-weight: 700;
	line-height: 1.35;
	text-align: center;
}

/* Caption: the narrator, no portrait, a manga caption box. */
.scene-panel.is-caption .scene-bubble {
	border-radius: var(--r-1);
	background: #fff5e3;
	font-style: italic;
}

/* ---------- Squad of guardian cards ---------- */

.squad-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
	gap: var(--sp-2);
	max-height: 46vh;
	margin: 0;
	padding: var(--sp-2) var(--sp-1);
	overflow-y: auto;
	list-style: none;
}

.squad-card {
	position: relative;
	width: 100%;
	aspect-ratio: 1;
	padding: 0;
	border: var(--bw) solid var(--rarity, var(--line));
	border-radius: var(--r-1);
	background: var(--panel);
	cursor: pointer;
}

.squad-card svg {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: calc(var(--r-1) - 3px);
}

.squad-card[aria-pressed='false'] svg {
	opacity: 0.7;
}

.squad-card[aria-pressed='true'] {
	box-shadow: 0 0 0 3px var(--accent);
}

.squad-rank {
	position: absolute;
	left: -6px;
	top: -6px;
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	border: 2px solid var(--line);
	border-radius: var(--r-full);
	background: var(--accent);
	color: var(--on-accent);
	font-weight: 800;
	line-height: 1;
}

.squad-share {
	position: absolute;
	right: 2px;
	bottom: 2px;
	padding: 0 4px;
	border-radius: var(--r-1);
	background: rgba(20, 16, 31, 0.8);
	color: #fff;
	font-size: 0.7rem;
	font-weight: 800;
}

/* ---------- In the fight: guardians and phases ---------- */

/* The squad sits in a third column, next to the player's HP bar. */
.fighter-player:has(.guards) {
	grid-template-columns: auto 1fr auto;
}

.guards {
	display: flex;
	gap: var(--sp-1);
	margin: 0;
	padding: 0;
	list-style: none;
}

.guard {
	width: 36px;
	height: 36px;
	overflow: hidden;
	border: 2px solid var(--rarity, var(--line));
	border-radius: var(--r-1);
	background: var(--panel);
}

.guard svg {
	display: block;
	width: 100%;
	height: 100%;
}

.guard.is-used {
	filter: grayscale(1);
	opacity: 0.45;
}

.guard.guard-block {
	animation: guard-block 700ms var(--ease-back);
}

@keyframes guard-block {
	0% {
		transform: none;
	}
	35% {
		transform: translateY(-34px) scale(1.6) rotate(-6deg);
		filter: none;
		opacity: 1;
	}
	60% {
		transform: translateY(-30px) scale(1.5) rotate(4deg);
	}
	100% {
		transform: none;
	}
}

.pop-guard {
	background: #d9ccff;
}

.speech-guard {
	top: auto;
	bottom: calc(100% - 6px);
	left: auto;
	right: var(--sp-3);
}

.speech-guard::before,
.speech-guard::after {
	display: none;
}

/* Final boss: the HP bar cut in three, one part per phase. */
.hp-phases::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 2;
	background: linear-gradient(90deg, transparent calc(33.33% - 1px), #050408 calc(33.33% - 1px), #050408 calc(33.33% + 1px), transparent calc(33.33% + 1px), transparent calc(66.66% - 1px), #050408 calc(66.66% - 1px), #050408 calc(66.66% + 1px), transparent calc(66.66% + 1px));
	pointer-events: none;
}

/* ---------- Mythic card: full art like the legendaries, violet and gold ---------- */

.card.r-mythic {
	--gem: #ffcf33;
	--frame: linear-gradient(160deg, #ffe7a3, #9b6bff 55%, #2b2a6b);
	--card-ink: #fff8ec;
}

.card.r-mythic .card-frame {
	justify-content: space-between;
	background: none;
}

.card.r-mythic .card-art {
	position: absolute;
	inset: 0;
	border: 0;
	border-radius: 0;
	z-index: 0;
}

.card.r-mythic .card-art::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(29, 21, 70, 0.6) 0%, transparent 22%, transparent 55%, rgba(29, 21, 70, 0.9) 80%);
}

.card.r-mythic .card-head,
.card.r-mythic .card-body {
	position: relative;
	z-index: 1;
	text-shadow: 0 0.5cqi 1.5cqi rgba(0, 0, 0, 0.6);
}

.card.r-mythic .card-hp {
	color: #ffcf33;
}

.card.r-mythic .layer-holo,
.card.r-mythic .layer-sparkle {
	display: block;
}

.card.r-mythic .layer-holo {
	z-index: 1;
	opacity: calc(var(--o) * 0.75);
	mask-image: radial-gradient(ellipse 38% 30% at 50% 42%, rgba(0, 0, 0, 0.2) 40%, #000 100%);
	-webkit-mask-image: radial-gradient(ellipse 38% 30% at 50% 42%, rgba(0, 0, 0, 0.2) 40%, #000 100%);
}

.card.r-mythic .gauge i:not(.on) {
	background: rgba(255, 255, 255, 0.25);
}

@media (prefers-reduced-motion: reduce) {
	.guard.guard-block,
	.scene-panel.enter {
		animation: none;
	}
}
