/**
 * =============================================================================
 * Demo section styles
 *
 * All custom classes use the demo_ prefix. The catalog is a Monogatari screen;
 * the HUD is a compact overlay at the top of the game screen so it does not
 * cover the characters (they stand at the bottom of the 1920x1080 stage).
 * =============================================================================
 **/

/* -------------------------------------------------------------------------
 * Catalog screen
 * ------------------------------------------------------------------------- */

demo-screen {
	width: 100%;
	height: 100%;
	overflow-y: auto;
	background-color: var(--screen-background-color);
	color: var(--text-color);
}

.demo_catalog {
	min-height: 100%;
	text-align: left;
}

.demo_header {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: flex-start;
	gap: 24px;
	padding: 20px 32px 18px;
	background: rgba(247, 247, 247, 0.97);
	border-bottom: 1px solid rgba(0, 0, 0, 0.12);
	backdrop-filter: blur(6px);
}

.demo_header__back {
	flex: 0 0 auto;
	margin-top: 4px;
}

.demo_header__title {
	flex: 1 1 auto;
	min-width: 0;
}

.demo_header__title h2 {
	margin: 0 0 4px;
	font-size: 36px;
	line-height: 1.1;
}

.demo_header__title p {
	margin: 0;
	font-size: 18px;
	line-height: 1.4;
	color: rgba(66, 66, 66, 0.78);
	max-width: 980px;
}

.demo_catalog__body {
	padding: 24px 32px 48px;
}

.demo_category {
	margin: 0 0 34px;
}

.demo_category__head {
	margin-bottom: 14px;
}

.demo_category__head h3 {
	margin: 0 0 4px;
	font-size: 28px;
	line-height: 1.2;
	color: #2f3a45;
}

.demo_category__head p {
	margin: 0;
	font-size: 18px;
	line-height: 1.4;
	color: rgba(66, 66, 66, 0.75);
}

.demo_cards {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 16px;
}

.demo_card {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-height: 230px;
	padding: 18px 20px 20px;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 8px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
	text-align: left;
}

.demo_card__top {
	margin-bottom: 8px;
}

.demo_card h4 {
	margin: 0 0 8px;
	font-size: 24px;
	line-height: 1.25;
	color: #26313c;
}

.demo_card p {
	margin: 0 0 16px;
	font-size: 18px;
	line-height: 1.4;
	color: rgba(66, 66, 66, 0.82);
}

.demo_card__actions {
	margin-top: auto;
}

.demo_badge {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 999px;
	font-size: 13px;
	line-height: 1.2;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	white-space: nowrap;
}

.demo_badge--builtin {
	background: #e3edf8;
	color: #2d5f8f;
}

.demo_badge--particles {
	background: #ece5f8;
	color: #634294;
}

.demo_badge--css {
	background: #fcebdc;
	color: #9a5221;
}

.demo_footer {
	margin-top: 18px;
	padding: 18px 0 0;
	border-top: 1px solid rgba(0, 0, 0, 0.12);
	font-size: 16px;
	line-height: 1.5;
	color: rgba(66, 66, 66, 0.75);
}

.demo_footer h3 {
	margin: 0 0 8px;
	font-size: 20px;
	color: #2f3a45;
}

.demo_footer p {
	margin: 0 0 6px;
}

.demo_footer code {
	padding: 1px 5px;
	border-radius: 3px;
	background: rgba(0, 0, 0, 0.06);
	font-size: 12px;
}

/* Buttons inside the demo screen get their own compact sizing. */
.demo_btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	width: auto;
	height: auto;
	min-height: 42px;
	padding: 9px 15px;
	border: 1px solid rgba(0, 0, 0, 0.18);
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.06);
	color: #26313c;
	font-size: 18px;
	line-height: 1.2;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.demo_btn:hover,
.demo_btn:focus {
	background: rgba(0, 0, 0, 0.1);
	border-color: rgba(0, 0, 0, 0.28);
}

.demo_btn:active {
	transform: translateY(1px);
}

.demo_btn--primary {
	border-color: #30465e;
	background: #30465e;
	color: #fff;
}

.demo_btn--primary:hover,
.demo_btn--primary:focus {
	background: #3d5873;
	border-color: #3d5873;
	color: #fff;
}

.demo_btn--ghost {
	background: transparent;
	border-color: rgba(0, 0, 0, 0.2);
}

.demo_btn--danger {
	border-color: #8d3b3b;
	background: #8d3b3b;
	color: #fff;
}

.demo_btn--danger:hover,
.demo_btn--danger:focus {
	background: #a44a4a;
	border-color: #a44a4a;
	color: #fff;
}

/* -------------------------------------------------------------------------
 * In-game HUD
 * ------------------------------------------------------------------------- */

.demo_hud {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 40;
	width: 100%;
	background: linear-gradient(180deg, rgba(8, 12, 18, 0.94) 0%, rgba(8, 12, 18, 0.86) 72%, rgba(8, 12, 18, 0) 100%);
	color: #fff;
	text-align: left;
	cursor: default;
}

.demo_hud[hidden] {
	display: none;
}

.demo_hud__bar {
	display: flex;
	align-items: flex-start;
	gap: 24px;
	padding: 16px 28px 24px;
}

.demo_hud__info {
	flex: 1 1 auto;
	min-width: 0;
	max-width: 1280px;
}

.demo_hud__kicker {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 4px;
}

.demo_hud__category {
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.62);
}

.demo_hud h2 {
	margin: 0 0 5px;
	font-size: 28px;
	line-height: 1.15;
	color: #fff;
}

.demo_hud p {
	margin: 0 0 8px;
	font-size: 18px;
	line-height: 1.4;
	color: rgba(255, 255, 255, 0.82);
	max-width: 1080px;
}

.demo_hud__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: flex-end;
	gap: 8px;
	flex: 0 0 auto;
	max-width: 560px;
	padding-top: 2px;
}

.demo_hud .demo_btn {
	min-height: 38px;
	padding: 8px 13px;
	border-color: rgba(255, 255, 255, 0.24);
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	font-size: 17px;
}

.demo_hud .demo_btn:hover,
.demo_hud .demo_btn:focus {
	background: rgba(255, 255, 255, 0.18);
	border-color: rgba(255, 255, 255, 0.42);
	color: #fff;
}

.demo_hud .demo_btn--ghost {
	background: transparent;
}

.demo_hud .demo_btn--danger {
	border-color: #a44a4a;
	background: #7f3232;
	color: #fff;
}

.demo_hud__command-toggle {
	margin-top: 1px;
}

.demo_hud__command {
	max-height: 54px;
	margin: 4px 0 9px;
	padding: 7px 10px;
	overflow: auto;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.55);
	color: #d9e8ff;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 16px;
	line-height: 1.4;
	white-space: pre-wrap;
	text-align: left;
}

.demo_hud__command[hidden] {
	display: none;
}

/* Hide the normal quick menu while a demo is running: save/load/back/quit
 * must not be reachable from the demo UI. Hotkeys are blocked in demo.js. */
#monogatari.demo_active quick-menu {
	display: none !important;
}

/* Particles are decorative and must not swallow clicks. */
#tsparticles,
[data-ui="particles"] {
	pointer-events: none;
}

/* -------------------------------------------------------------------------
 * Small, explicitly "our CSS" effects
 * ------------------------------------------------------------------------- */

/* Slow zoom + pan on the background element. The transform is applied to the
 * background inside the game screen, never to #monogatari. */
[data-ui="background"].demo_pan_zoom {
	animation: demo_ken_burns 18s ease-in-out infinite alternate;
	transform-origin: center center;
	will-change: transform;
}

@keyframes demo_ken_burns {
	0% {
		transform: scale(1.04) translate3d(0, 0, 0);
	}
	50% {
		transform: scale(1.12) translate3d(-1.5%, -1%, 0);
	}
	100% {
		transform: scale(1.06) translate3d(1.5%, 1%, 0);
	}
}

/* Soft breathing on a character sprite. */
[data-character].demo_breathe {
	animation: demo_breathe 6s ease-in-out infinite;
	transform-origin: center bottom;
	will-change: transform;
}

@keyframes demo_breathe {
	0%, 100% {
		transform: translateY(0) scale(1);
	}
	50% {
		transform: translateY(-6px) scale(1.005);
	}
}

/* Dim the inactive conversation partner. */
[data-character].demo_dim {
	filter: brightness(0.52) saturate(0.7);
	opacity: 0.85;
	transition: filter 0.3s ease, opacity 0.3s ease;
}

/* Vignette on the background element, under the characters. */
[data-ui="background"].demo_vignette {
	box-shadow: inset 0 0 220px 80px rgba(0, 0, 0, 0.78);
}

/* Soft blur of the background only; the slight scale prevents visible edges. */
[data-ui="background"].demo_soft_blur {
	filter: blur(4px) brightness(0.82);
	transform: scale(1.05);
	transform-origin: center center;
}

/* Framed "photo" image. */
img[data-image].demo_photo_frame {
	border: 10px solid rgba(255, 255, 255, 0.92);
	border-radius: 4px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
	box-sizing: border-box;
}

/* The global flex rules for demo buttons must not override the hidden attribute. */
.demo_btn[hidden],
.demo_hud [hidden] {
	display: none !important;
}

/* Explicit character positions for the move demo. The stock left/center/right
 * classes use `auto` values, which CSS cannot interpolate; these explicit
 * positions let the engine's existing `move transition 6s` animate smoothly.
 * The animation mechanism is still Monogatari's built-in move/transition. */
[data-character].demo_pos_left {
	left: 6%;
	right: auto;
}

[data-character].demo_pos_center {
	left: calc(50% - 243px);
	right: auto;
}

[data-character].demo_pos_right {
	left: calc(94% - 486px);
	right: auto;
}

/* Demo HUD occupies the top of the stage. NVL mode uses a full-height text
 * box, so shift its content below the HUD instead of hiding the first lines. */
#monogatari.demo_active text-box[mode="nvl"] {
	padding-top: 210px;
	box-sizing: border-box;
}

/* Centered dialogs inherit the dark body text color; make them readable over
 * the dark game scene and keep long lines inside the stage. */
#monogatari.demo_active centered-dialog {
	width: min(78%, 1400px);
	color: #fff;
	font-size: 28px;
	line-height: 1.4;
	text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

#monogatari.demo_active centered-dialog [data-content="wrapper"] {
	width: 100%;
	white-space: normal;
}

/* When the flag is off the custom element is not registered; never let it
 * appear as an empty block inside the game. */
demo-screen:not([data-screen]) {
	display: none;
}
