/**
 * Gaiha Frost Compatibility v1.0.0
 * All frontend rules are scoped to Frost / Gaiha roots.
 */

/* -------------------------------------------------------------------------
 * 1. Frost block-layout release points
 * ---------------------------------------------------------------------- */
body.gaiha-frost-theme {
	--gaiha-frost-edge: clamp(12px, 2.4vw, 32px);
}

body.gaiha-frost-theme .gaiha-frost-plugin-host,
body.gaiha-frost-theme .wp-block-post-content > .gbs-bookshelf,
body.gaiha-frost-theme .wp-block-post-content > .gaiha-mp-wrap,
body.gaiha-frost-theme .wp-block-post-content > .arazaa-post-wall-wrap,
body.gaiha-frost-theme .wp-block-post-content > .arazaa-title-wall-wrap,
body.gaiha-frost-theme .wp-block-post-content > .mongol-scroll-box {
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	box-sizing: border-box !important;
}

body.gaiha-frost-theme .is-layout-constrained > .gaiha-frost-plugin-host,
body.gaiha-frost-theme .is-layout-constrained > .gbs-bookshelf,
body.gaiha-frost-theme .is-layout-constrained > .gaiha-mp-wrap,
body.gaiha-frost-theme .is-layout-constrained > .arazaa-post-wall-wrap,
body.gaiha-frost-theme .is-layout-constrained > .arazaa-title-wall-wrap,
body.gaiha-frost-theme .is-layout-constrained > .mongol-scroll-box {
	max-width: none !important;
}

body.gaiha-frost-theme :where(
	.gbs-bookshelf,
	.gaiha-mp-wrap,
	.arazaa-post-wall-wrap,
	.arazaa-title-wall-wrap,
	.gaiha-radio-component,
	.gaiha-radio-player,
	.mongol-scroll-box
) {
	box-sizing: border-box;
}

/* Frost's global blockGap must not become an accidental internal plugin gap. */
body.gaiha-frost-theme :where(.gaiha-frost-plugin-host) {
	margin-block-start: 0 !important;
	margin-block-end: 0 !important;
}

/* -------------------------------------------------------------------------
 * 2. Gaiha Bookshelf
 * ---------------------------------------------------------------------- */
body.gaiha-frost-theme.gbs-bookshelf-page .wp-site-blocks main,
body.gaiha-frost-theme.gbs-bookshelf-page .wp-site-blocks .wp-block-post-content,
body.gaiha-frost-theme.gbs-bookshelf-page .wp-site-blocks .wp-block-post-content > .wp-block-shortcode {
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	margin-inline: 0 !important;
	padding-inline: 0 !important;
}

body.gaiha-frost-theme.gbs-bookshelf-page main .wp-block-post-title,
body.gaiha-frost-theme.gbs-bookshelf-page main .wp-block-post-date,
body.gaiha-frost-theme.gbs-bookshelf-page main .wp-block-post-author,
body.gaiha-frost-theme.gbs-bookshelf-page main .wp-block-post-terms {
	display: none !important;
}

body.gaiha-frost-theme .gbs-bookshelf {
	max-width: min(1600px, calc(100vw - (var(--gaiha-frost-edge) * 2))) !important;
}

body.gaiha-frost-theme .gbs-bookshelf.gbs-fullwidth {
	width: min(1600px, calc(100vw - (var(--gaiha-frost-edge) * 2))) !important;
	margin-inline: calc(50% - min(800px, calc(50vw - var(--gaiha-frost-edge)))) !important;
}

body.gaiha-frost-theme.gaiha-frost-gbs-template .gaiha-frost-gbs-main,
body.gaiha-frost-theme.gaiha-frost-gbs-template .gbs-fullwidth-article,
body.gaiha-frost-theme.gaiha-frost-gbs-template .gbs-fullwidth-content {
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
}

/* -------------------------------------------------------------------------
 * 3. Mongol Scroll Box — Frost is a block theme, so use the block-content
 *    branch rather than JustMedia's classic .entry-content selectors.
 * ---------------------------------------------------------------------- */
body.gaiha-frost-theme .wp-site-blocks .wp-block-post-content .mongol-scroll-box,
.editor-styles-wrapper .mongol-scroll-box,
.block-editor-iframe__body .editor-styles-wrapper .mongol-scroll-box {
	width: var(--gaiha-mongol-box-width, 100%) !important;
	max-width: var(--gaiha-mongol-box-max-width, 1200px) !important;
	min-width: 0 !important;
	min-height: var(--gaiha-mongol-box-min-height, 520px) !important;
	box-sizing: border-box !important;
}

body.gaiha-frost-theme .wp-site-blocks .wp-block-post-content .mongol-scroll-box > .wp-block-group,
.editor-styles-wrapper .mongol-scroll-box > .wp-block-group,
.block-editor-iframe__body .mongol-scroll-box > .wp-block-group {
	min-width: 0 !important;
	max-width: none !important;
}

/* Keep vertical Mongolian isolated from Frost navigation/buttons/media. */
body.gaiha-frost-theme .mongol-scroll-box {
	writing-mode: vertical-lr !important;
	-webkit-writing-mode: vertical-lr !important;
	text-orientation: mixed !important;
	-webkit-text-orientation: mixed !important;
	direction: ltr !important;
}

body.gaiha-frost-theme .mongol-scroll-box :where(button, input, select, textarea, img, video, audio, svg) {
	writing-mode: horizontal-tb;
	-webkit-writing-mode: horizontal-tb;
}

/* -------------------------------------------------------------------------
 * 4. Gaiha Card / Featured Wall / Title Wall
 * ---------------------------------------------------------------------- */
body.gaiha-frost-theme :where(.gaiha-mp-wrap, .arazaa-post-wall-wrap, .arazaa-title-wall-wrap) {
	width: 100% !important;
	max-width: none !important;
	margin-inline: auto !important;
}

body.gaiha-frost-theme :where(.gaiha-mp-wrap, .arazaa-post-wall-wrap, .arazaa-title-wall-wrap) :where(button, input, select, textarea) {
	font-family: inherit;
	letter-spacing: normal;
	text-transform: none;
}

/* -------------------------------------------------------------------------
 * 5. Gaiha Radio
 * ---------------------------------------------------------------------- */
body.gaiha-frost-theme .gaiha-radio-theme-footer {
	width: 100%;
	max-width: none;
}

body.gaiha-frost-theme .gaiha-radio-component,
body.gaiha-frost-theme .gaiha-radio-player {
	max-width: 100%;
}

body.gaiha-frost-theme .gaiha-radio-sticky,
body.gaiha-frost-theme [class*="gaiha-radio-sticky"],
body.gaiha-frost-theme [class*="gaiha-radio-floating"] {
	z-index: 99950;
}

/* -------------------------------------------------------------------------
 * 6. Frost archive/category replacement for the old JustMedia post-loop
 *    vertical archive module.
 * ---------------------------------------------------------------------- */
body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template,
body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template {
	display: flex !important;
	flex-flow: row nowrap !important;
	align-items: flex-start !important;
	gap: 38px !important;
	overflow-x: auto !important;
	overflow-y: hidden !important;
	width: 100% !important;
	max-width: 100% !important;
	margin: 0 !important;
	padding: 50px 30px 70px !important;
	list-style: none !important;
	box-sizing: border-box !important;
	scrollbar-width: auto;
	scrollbar-color: #f0a11a #e5e5e5;
}

body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template::-webkit-scrollbar,
body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template::-webkit-scrollbar {
	height: 14px;
}
body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template::-webkit-scrollbar-track,
body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template::-webkit-scrollbar-track {
	background: #e5e5e5;
	border-radius: 999px;
}
body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template::-webkit-scrollbar-thumb,
body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template::-webkit-scrollbar-thumb {
	background: #f0a11a;
	border: 3px solid #e5e5e5;
	border-radius: 999px;
}

body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template > .wp-block-post,
body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template > .wp-block-post {
	position: relative !important;
	flex: 0 0 70px !important;
	width: 70px !important;
	min-width: 70px !important;
	max-width: 70px !important;
	height: 430px !important;
	min-height: 430px !important;
	margin: 0 !important;
	padding: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
}

body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template > .wp-block-post:not(:last-child)::after,
body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template > .wp-block-post:not(:last-child)::after {
	content: "";
	position: absolute;
	top: 12px;
	bottom: 12px;
	right: -19px;
	border-right: 1px dashed #d8d8d8;
}

body.gaiha-frost-theme.archive .wp-block-post-template .wp-block-post-title,
body.gaiha-frost-theme.category .wp-block-post-template .wp-block-post-title {
	width: 70px !important;
	height: 430px !important;
	margin: 0 !important;
	padding: 0 !important;
	writing-mode: vertical-lr !important;
	-webkit-writing-mode: vertical-lr !important;
	text-orientation: mixed !important;
	white-space: nowrap !important;
	font-size: 24px !important;
	line-height: 1.32 !important;
	font-weight: 600 !important;
}

body.gaiha-frost-theme.archive .wp-block-post-template .wp-block-post-title a,
body.gaiha-frost-theme.category .wp-block-post-template .wp-block-post-title a {
	color: #222 !important;
	text-decoration: none !important;
	text-shadow: 0 2px 5px rgba(0,0,0,.18) !important;
}

body.gaiha-frost-theme.archive .wp-block-post-template .wp-block-post-title a:hover,
body.gaiha-frost-theme.category .wp-block-post-template .wp-block-post-title a:hover {
	color: #d99000 !important;
}

body.gaiha-frost-theme.archive .wp-block-post-template .wp-block-post > :not(.wp-block-post-title),
body.gaiha-frost-theme.category .wp-block-post-template .wp-block-post > :not(.wp-block-post-title) {
	display: none !important;
}

/* -------------------------------------------------------------------------
 * 7. Existing Gaiha single-post cleanup, translated to Frost core blocks.
 * ---------------------------------------------------------------------- */
body.gaiha-frost-theme.single-post main :where(
	.wp-block-post-title,
	.wp-block-post-author,
	.wp-block-post-date,
	.wp-block-post-terms
) {
	display: none !important;
}

/* Do not let the rule above touch content headings. */
body.gaiha-frost-theme.single-post main .wp-block-post-content :where(h1,h2,h3,h4,h5,h6) {
	display: revert !important;
}

/* -------------------------------------------------------------------------
 * 8. Mobile
 * ---------------------------------------------------------------------- */
@media (max-width: 782px) {
	body.gaiha-frost-theme {
		--gaiha-frost-edge: 10px;
	}

	body.gaiha-frost-theme .gbs-bookshelf.gbs-fullwidth {
		width: calc(100vw - 20px) !important;
		margin-inline: calc(50% - (50vw - 10px)) !important;
	}

	body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template,
	body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template {
		gap: 24px !important;
		padding: 24px 14px 48px !important;
	}

	body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template > .wp-block-post,
	body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template > .wp-block-post,
	body.gaiha-frost-theme.archive .wp-block-post-template .wp-block-post-title,
	body.gaiha-frost-theme.category .wp-block-post-template .wp-block-post-title {
		flex-basis: 48px !important;
		width: 48px !important;
		min-width: 48px !important;
		max-width: 48px !important;
		height: 360px !important;
		min-height: 360px !important;
		font-size: 16px !important;
	}

	body.gaiha-frost-theme.archive .wp-block-query > .wp-block-post-template > .wp-block-post:not(:last-child)::after,
	body.gaiha-frost-theme.category .wp-block-query > .wp-block-post-template > .wp-block-post:not(:last-child)::after {
		right: -12px;
	}
}

/* -------------------------------------------------------------------------
 * 9. Member Pro bridge / WPCOM Member pages
 * ---------------------------------------------------------------------- */
.gaiha-member-gate {
	width: min(760px, calc(100% - 24px));
	margin: 28px auto;
	padding: 1px;
	box-sizing: border-box;
	border: 1px solid rgba(120, 130, 145, .22);
	border-radius: 22px;
	background: rgba(255, 255, 255, .72);
	box-shadow: 0 16px 48px rgba(25, 35, 50, .10);
	backdrop-filter: blur(18px) saturate(135%);
	-webkit-backdrop-filter: blur(18px) saturate(135%);
}
.gaiha-member-gate__inner {
	padding: clamp(22px, 4vw, 38px);
	text-align: center;
}
.gaiha-member-gate__inner strong {
	display: block;
	font-size: clamp(20px, 2.4vw, 30px);
	line-height: 1.2;
	margin-bottom: 10px;
}
.gaiha-member-gate__inner p {
	margin: 0 0 18px;
	line-height: 1.7;
}
.gaiha-member-gate__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 42px;
	padding: 8px 18px;
	border-radius: 999px;
	text-decoration: none !important;
	font-weight: 600;
	background: #17191f;
	color: #fff !important;
}

body.gaiha-frost-theme.gaiha-wpcom-member-page .wp-site-blocks main,
body.gaiha-frost-theme.gaiha-wpcom-member-page .wp-site-blocks .wp-block-post-content,
body.gaiha-frost-theme.gaiha-wpcom-member-page .wp-site-blocks .wp-block-post-content > .wp-block-shortcode,
body.gaiha-frost-theme .gaiha-frost-member-host {
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	box-sizing: border-box !important;
}

body.gaiha-frost-theme.gaiha-wpcom-member-page .wp-block-post-content {
	padding-inline: var(--gaiha-frost-edge, 20px);
}

body.gaiha-frost-theme.gaiha-wpcom-member-page.gaiha-hide-member-page-title main .wp-block-post-title {
	display: none;
}

body.gaiha-frost-theme.gaiha-member-pro-ready :where(
	[class*="wpcom-member"],
	[class*="wpcom-user"],
	[class*="wpcom-account"],
	[class*="wpcom-profile"]
) {
	box-sizing: border-box;
	max-width: 100%;
}

body.gaiha-frost-theme.gaiha-member-pro-ready :where(
	[class*="wpcom-member"],
	[class*="wpcom-user"],
	[class*="wpcom-account"],
	[class*="wpcom-profile"]
) :where(input, select, textarea, button) {
	box-sizing: border-box;
	max-width: 100%;
}

/* Keep Member Pro purchase/login dialogs above Frost headers and Gaiha floating UIs. */
body.gaiha-member-pro-ready :where(
	[class*="wpcom"][class*="modal"],
	[class*="wpcom"][class*="dialog"],
	[class*="member"][class*="modal"]
) {
	z-index: 100500 !important;
}

/* Member Pro Gutenberg blocks must remain usable inside Frost constrained layouts. */
body.gaiha-frost-theme .wp-block-post-content > [class*="wp-block-wpcom"],
body.gaiha-frost-theme .wp-block-post-content > [class*="wpcom-premium"],
body.gaiha-frost-theme .wp-block-post-content > [class*="wpcom-member"] {
	max-width: 100% !important;
	box-sizing: border-box !important;
}

@media (max-width: 782px) {
	.gaiha-member-gate {
		width: calc(100% - 20px);
		border-radius: 18px;
	}
	.gaiha-member-gate__inner {
		padding: 20px 16px;
	}
	body.gaiha-frost-theme.gaiha-wpcom-member-page .wp-block-post-content {
		padding-inline: 10px;
	}
}
