/* RelaxInChina — The Living Realm sunrise experience. */
.ric-realm {
	--ric-realm-image: none;
	--ric-cam-scale: 1;
	--ric-cam-x: 0%;
	--ric-cam-y: 0%;
	--ric-look-x: 0%;
	--ric-look-y: 0%;
	--ric-progress: 0%;
	--ric-cloud: #f4f0e5;
	--ric-celadon: #b9d2c4;
	--ric-jade: #557c69;
	--ric-jade-deep: #25483e;
	--ric-cinnabar: #8e4938;
	--ric-gold: #d8b46c;
	--ric-ink: #102536;
	--ric-panel: rgba(12, 30, 40, 0.78);
	--ric-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
	--ric-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	position: relative;
	max-width: none;
	margin: 0;
	color: var(--ric-cloud);
	background: var(--ric-ink);
	font-family: var(--ric-sans);
	line-height: 1.6;
	-webkit-text-size-adjust: 100%;
}

.ric-realm,
.ric-realm *,
.ric-realm *::before,
.ric-realm *::after {
	box-sizing: border-box;
}

.ric-realm__sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Cinematic threshold ---------- */
.ric-realm__prologue {
	position: relative;
	isolation: isolate;
	min-height: 100vh;
	min-height: 100svh;
	display: grid;
	align-items: end;
	overflow: hidden;
	background: #9eb5bf;
}

.ric-realm__prologue-art {
	position: absolute;
	inset: -3%;
	z-index: -3;
	background-image: var(--ric-realm-image);
	background-position: 50% 50%;
	background-size: cover;
	transform: scale(1.035);
	animation: ric-realm-opening-drift 18s ease-in-out infinite alternate;
}

.ric-realm__prologue::before,
.ric-realm__prologue::after,
.ric-realm__prologue-light {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.ric-realm__prologue::before {
	z-index: -2;
	background:
		linear-gradient(90deg, rgba(9, 27, 38, 0.78) 0%, rgba(9, 27, 38, 0.36) 35%, transparent 64%),
		linear-gradient(0deg, rgba(8, 24, 34, 0.78) 0%, transparent 48%);
}

.ric-realm__prologue::after {
	z-index: -1;
	background: radial-gradient(70% 55% at 17% 7%, rgba(255, 236, 195, 0.38), transparent 68%);
	mix-blend-mode: screen;
}

.ric-realm__prologue-light {
	z-index: -1;
	background: linear-gradient(111deg, rgba(255, 248, 218, 0.18), transparent 28% 100%);
	clip-path: polygon(4% 0, 38% 0, 58% 100%, 29% 100%);
	opacity: 0.72;
}

.ric-realm__prologue-inner {
	width: min(46rem, calc(100% - 2rem));
	margin: 0 0 clamp(2.1rem, 8vh, 6.5rem) clamp(1rem, 7vw, 7rem);
	padding: clamp(1.4rem, 3vw, 2.6rem) clamp(1.3rem, 3.5vw, 3rem);
	border-left: 2px solid rgba(216, 180, 108, 0.9);
	background: linear-gradient(100deg, rgba(8, 27, 38, 0.72), rgba(8, 27, 38, 0.25));
	box-shadow: 0 1.8rem 5rem rgba(5, 17, 25, 0.26);
	backdrop-filter: blur(6px) saturate(1.06);
}

.ric-realm__kicker,
.ric-realm__map-heading p,
.ric-realm__chapter-kicker {
	margin: 0;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.28em;
	text-transform: uppercase;
	color: #f3d79a;
}

.ric-realm__title {
	max-width: 12ch;
	margin: 0.5rem 0 0.8rem;
	font-family: var(--ric-serif);
	font-size: clamp(3rem, 8vw, 7.4rem);
	font-weight: 500;
	line-height: 0.91;
	letter-spacing: -0.045em;
	text-wrap: balance;
	text-shadow: 0 0.12em 1em rgba(2, 14, 22, 0.36);
}

.ric-realm__orientation {
	max-width: 39rem;
	margin: 0 0 1.55rem;
	font-family: var(--ric-serif);
	font-size: clamp(1rem, 1.7vw, 1.25rem);
	line-height: 1.65;
	color: #f5f1e9;
}

.ric-realm__enter,
.ric-realm__chapter-return {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.8rem;
	min-height: 46px;
	padding: 0.72rem 1.25rem;
	border: 1px solid rgba(244, 240, 229, 0.54);
	border-radius: 2px;
	color: #fff9e8;
	background: rgba(20, 58, 57, 0.5);
	font-size: 0.75rem;
	font-weight: 750;
	letter-spacing: 0.18em;
	text-decoration: none;
	text-transform: uppercase;
	transition: background-color 220ms ease, border-color 220ms ease, transform 220ms ease;
}

.ric-realm__enter:hover,
.ric-realm__chapter-return:hover {
	border-color: var(--ric-gold);
	background: rgba(27, 78, 70, 0.8);
	transform: translateY(-2px);
}

/* ---------- Realm camera ---------- */
.ric-realm__stage {
	position: relative;
	display: flow-root;
	isolation: isolate;
	min-height: 100vh;
	min-height: 100svh;
	background: #8da8b1;
}

.ric-realm__camera,
.ric-realm__atmosphere,
.ric-realm__vignette {
	position: absolute;
	inset: 0 0 auto;
	width: 100%;
	height: 100vh;
	height: 100svh;
}

.ric-realm__camera {
	z-index: 0;
	overflow: hidden;
}

.ric-realm__world {
	position: absolute;
	inset: -5%;
	transform: translate3d(
		calc(var(--ric-cam-x) + var(--ric-look-x)),
		calc(var(--ric-cam-y) + var(--ric-look-y)),
		0
	) scale(var(--ric-cam-scale));
	transform-origin: 50% 50%;
	transition: transform 1100ms cubic-bezier(0.2, 0.75, 0.18, 1);
	backface-visibility: hidden;
}

.ric-realm.has-active-chapter .ric-realm__world {
	will-change: transform;
}

.ric-realm__base,
.ric-realm__depth,
.ric-realm__sun-haze,
.ric-realm__mist {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.ric-realm__base {
	background-image: var(--ric-realm-image);
	background-position: 50% 50%;
	background-size: cover;
	opacity: 1;
	transition: opacity 420ms ease;
}

.ric-realm__depth {
	display: block;
	width: 100%;
	height: 100%;
	opacity: 0;
	transition: opacity 420ms ease;
}

.ric-realm.has-depth-webgl .ric-realm__depth {
	opacity: 1;
}

.ric-realm.has-depth-webgl .ric-realm__base {
	opacity: 0;
}

.ric-realm__sun-haze {
	background:
		radial-gradient(48% 38% at 15% 8%, rgba(255, 240, 194, 0.48), transparent 72%),
		linear-gradient(112deg, rgba(255, 249, 222, 0.12), transparent 34%);
	mix-blend-mode: screen;
}

.ric-realm__mist {
	background:
		linear-gradient(0deg, rgba(226, 235, 235, 0.23), transparent 32%),
		linear-gradient(180deg, transparent 46%, rgba(223, 232, 232, 0.12) 68%, transparent 90%);
}

.ric-realm__atmosphere {
	z-index: 1;
	pointer-events: none;
}

.ric-realm__vignette {
	z-index: 2;
	pointer-events: none;
	background:
		linear-gradient(90deg, rgba(7, 22, 31, 0.26), transparent 25% 73%, rgba(7, 22, 31, 0.2)),
		linear-gradient(0deg, rgba(7, 22, 31, 0.58), transparent 24% 76%, rgba(255, 247, 218, 0.04));
}

.ric-realm__map-heading {
	position: absolute;
	z-index: 4;
	top: clamp(1rem, 4vh, 2.5rem);
	left: clamp(1rem, 4vw, 3.5rem);
	padding: 0.8rem 1rem;
	border-left: 2px solid var(--ric-gold);
	background: rgba(10, 30, 40, 0.48);
	backdrop-filter: blur(6px);
}

.ric-realm__map-heading span {
	display: block;
	margin-top: 0.15rem;
	font-family: var(--ric-serif);
	font-size: 1rem;
	color: #fffdf5;
}

/* ---------- Beacons ---------- */
.ric-realm__beacons {
	position: absolute;
	z-index: 4;
	inset: 0 0 auto;
	height: 100vh;
	height: 100svh;
	margin: 0;
	padding: 0;
	list-style: none;
	transition: opacity 350ms ease, visibility 350ms ease;
}

.ric-realm__beacon-item {
	position: absolute;
	transform: translate(-50%, -50%);
}

.ric-realm__beacon {
	display: flex;
	align-items: center;
	gap: 0.58rem;
	min-height: 44px;
	padding: 0.42rem 0.68rem 0.42rem 0.5rem;
	border: 1px solid rgba(255, 251, 233, 0.5);
	border-radius: 2px;
	color: #fffdf3;
	background: rgba(10, 31, 40, 0.69);
	box-shadow: 0 0.8rem 2.2rem rgba(5, 20, 27, 0.24);
	backdrop-filter: blur(7px) saturate(1.1);
	text-decoration: none;
	transition: border-color 200ms ease, background-color 200ms ease, transform 200ms ease;
}

.ric-realm__beacon:hover,
.ric-realm__beacon.is-active {
	border-color: #f2d795;
	background: rgba(26, 67, 61, 0.88);
	transform: translateY(-2px);
}

.ric-realm__beacon-dot {
	position: relative;
	flex: 0 0 auto;
	width: 0.68rem;
	height: 0.68rem;
	border: 2px solid #fff7dc;
	border-radius: 50%;
	background: var(--ric-gold);
	box-shadow: 0 0 0 0.28rem rgba(216, 180, 108, 0.24), 0 0 1.2rem rgba(255, 222, 150, 0.62);
}

.ric-realm__beacon-dot::after {
	content: "";
	position: absolute;
	inset: -0.55rem;
	border: 1px solid rgba(255, 239, 190, 0.72);
	border-radius: 50%;
	animation: ric-realm-beacon-pulse 2.8s ease-out infinite;
}

.ric-realm__beacon.is-visited .ric-realm__beacon-dot {
	background: var(--ric-celadon);
	box-shadow: 0 0 0 0.28rem rgba(185, 210, 196, 0.2);
}

.ric-realm__beacon-label {
	display: grid;
	line-height: 1.18;
	text-align: left;
}

.ric-realm__beacon-name {
	font-family: var(--ric-serif);
	font-size: 0.9rem;
	font-weight: 700;
}

.ric-realm__beacon-region {
	margin-top: 0.14rem;
	font-size: 0.57rem;
	font-weight: 750;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #e7d7ad;
}

.ric-realm.has-active-chapter .ric-realm__beacons {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* ---------- HUD ---------- */
.ric-realm__hud {
	position: absolute;
	z-index: 4;
	left: clamp(1rem, 4vw, 3.5rem);
	bottom: clamp(1rem, 3vh, 2rem);
	width: min(23rem, calc(100% - 2rem));
	padding: 0.72rem 0.85rem;
	background: rgba(8, 27, 37, 0.66);
	border: 1px solid rgba(244, 240, 229, 0.24);
	backdrop-filter: blur(7px);
	transition: opacity 300ms ease;
}

.ric-realm__status {
	margin: 0 0 0.48rem;
	font-size: 0.72rem;
	letter-spacing: 0.04em;
	color: #f3eee1;
}

.ric-realm__progress {
	height: 3px;
	overflow: hidden;
	background: rgba(244, 240, 229, 0.2);
}

.ric-realm__progress-fill {
	display: block;
	width: var(--ric-progress);
	height: 100%;
	background: linear-gradient(90deg, var(--ric-celadon), var(--ric-gold));
	transition: width 500ms ease;
}

.ric-realm.has-active-chapter .ric-realm__hud {
	opacity: 0.24;
}

/* ---------- Chapters: readable fallback, cinematic enhanced panel ---------- */
.ric-realm__chapters {
	position: relative;
	z-index: 5;
	display: grid;
	gap: 1.5rem;
	margin-top: 100vh;
	margin-top: 100svh;
	padding: clamp(2rem, 7vw, 6rem) clamp(1rem, 6vw, 5rem);
	background: linear-gradient(145deg, #173345, #0d202e 62%, #142f35);
}

.ric-realm__chapter {
	width: min(46rem, 100%);
	margin: 0 auto;
	padding: clamp(1.4rem, 4vw, 2.7rem);
	border: 1px solid rgba(216, 180, 108, 0.36);
	border-radius: 2px;
	background: rgba(12, 35, 45, 0.88);
	box-shadow: 0 1.5rem 4rem rgba(3, 15, 22, 0.28);
}

.ric-realm__chapter-title {
	margin: 0.55rem 0 0.6rem;
	font-family: var(--ric-serif);
	font-size: clamp(1.75rem, 4vw, 3rem);
	font-weight: 500;
	line-height: 1.08;
	letter-spacing: -0.02em;
}

.ric-realm__chapter-body {
	margin: 0 0 1rem;
	font-size: clamp(0.98rem, 1.4vw, 1.08rem);
	color: #e8e7df;
}

.ric-realm__chapter-lens {
	margin: 0 0 1.4rem;
	padding-left: 1rem;
	border-left: 2px solid var(--ric-gold);
	font-family: var(--ric-serif);
	font-style: italic;
	color: #d6e2da;
}

.ric-realm.is-enhanced .ric-realm__stage {
	height: 100vh;
	height: 100svh;
	overflow: hidden;
}

.ric-realm.is-enhanced .ric-realm__chapters {
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 0;
	background: none;
	pointer-events: none;
}

.ric-realm.is-enhanced .ric-realm__chapter {
	position: absolute;
	right: clamp(1rem, 5vw, 5rem);
	bottom: clamp(1rem, 5vh, 4rem);
	width: min(35rem, calc(100% - 2rem));
	margin: 0;
	opacity: 0;
	visibility: hidden;
	transform: translate3d(0, 1.5rem, 0);
	pointer-events: none;
	background: linear-gradient(145deg, rgba(8, 29, 38, 0.9), rgba(17, 55, 54, 0.82));
	backdrop-filter: blur(16px) saturate(1.05);
	transition: opacity 430ms ease, transform 600ms cubic-bezier(0.16, 0.8, 0.2, 1), visibility 430ms;
}

.ric-realm.is-enhanced .ric-realm__chapter.is-active {
	opacity: 1;
	visibility: visible;
	transform: translate3d(0, 0, 0);
	pointer-events: auto;
}

/* ---------- Interaction and compatibility ---------- */
.ric-realm a:focus-visible,
.ric-realm [tabindex]:focus-visible {
	outline: 3px solid #fff7d9;
	outline-offset: 4px;
	box-shadow: 0 0 0 7px rgba(9, 31, 40, 0.82);
}

.ric-realm.is-quiet .ric-realm__atmosphere {
	display: none;
}

.ric-realm.is-quiet .ric-realm__prologue-inner,
.ric-realm.is-quiet .ric-realm__beacon,
.ric-realm.is-quiet .ric-realm__hud,
.ric-realm.is-quiet .ric-realm__chapter {
	backdrop-filter: none;
}

@keyframes ric-realm-opening-drift {
	from { transform: scale(1.035) translate3d(-0.35%, 0.1%, 0); }
	to { transform: scale(1.07) translate3d(0.4%, -0.25%, 0); }
}

@keyframes ric-realm-beacon-pulse {
	0% { opacity: 0.75; transform: scale(0.65); }
	75%, 100% { opacity: 0; transform: scale(1.38); }
}

@media (max-width: 720px) {
	.ric-realm__prologue-inner {
		margin: 0 1rem 1.25rem;
		background: linear-gradient(100deg, rgba(8, 27, 38, 0.82), rgba(8, 27, 38, 0.44));
	}

	.ric-realm__title { font-size: clamp(3rem, 17vw, 5rem); }
	.ric-realm__map-heading { top: 0.75rem; left: 0.75rem; }
	.ric-realm__map-heading p { letter-spacing: 0.16em; }
	.ric-realm__beacon-region { display: none; }
	.ric-realm__beacon { padding: 0.5rem; }
	.ric-realm__beacon-name { max-width: 6.5rem; font-size: 0.72rem; }
	.ric-realm__hud { left: 0.75rem; bottom: 0.75rem; }

	.ric-realm.is-enhanced .ric-realm__chapter {
		right: 0.75rem;
		bottom: 0.75rem;
		width: calc(100% - 1.5rem);
		max-height: min(68vh, 34rem);
		overflow: auto;
		padding: 1.25rem;
	}

	.ric-realm.has-active-chapter .ric-realm__hud { opacity: 0; }
}

@media (pointer: coarse) {
	.ric-realm__beacon { min-width: 46px; min-height: 46px; }
	.ric-realm__beacon-dot { width: 0.8rem; height: 0.8rem; }
}

@media (prefers-reduced-data: reduce) {
	.ric-realm__atmosphere { display: none; }
	.ric-realm__prologue-inner,
	.ric-realm__beacon,
	.ric-realm__hud,
	.ric-realm__chapter { backdrop-filter: none; }
}

@media (prefers-reduced-motion: reduce) {
	.ric-realm *,
	.ric-realm *::before,
	.ric-realm *::after {
		animation: none !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}

	.ric-realm__world {
		transform: none !important;
	}

	.ric-realm__prologue-art {
		transform: scale(1.02) !important;
	}
}

@media (forced-colors: active) {
	.ric-realm__enter,
	.ric-realm__beacon,
	.ric-realm__hud,
	.ric-realm__chapter,
	.ric-realm__chapter-return {
		border: 2px solid ButtonText;
		background: Canvas;
		color: CanvasText;
		backdrop-filter: none;
	}
}
