/**
 * Max Mega Menu — mobile Bottom Sheet
 * Visual target: iOS sheet + AUSBIA cinnabar (solid, clean).
 * Scoped to Mega Menu mobile breakpoint only (≤1300px).
 */

/* Desktop: never show injected sheet chrome */
#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-sheet-header,
#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-sheet-footer {
	display: none !important;
	visibility: hidden !important;
	pointer-events: none !important;
	width: 0 !important;
	height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	overflow: hidden !important;
	border: 0 !important;
	position: absolute !important;
	left: -9999px !important;
}

@media only screen and (max-width: 1300px) {
	#mega-menu-wrap-primary {
		--sheet-bg: #5c1210;
		--sheet-bg-deep: #3f0b09;
		--sheet-ink: #ffffff;
		--sheet-muted: rgba(255, 255, 255, 0.62);
		--sheet-line: rgba(255, 255, 255, 0.12);
		--sheet-gold: #e2b75a;
		--sheet-pad-x: 22px;
		--sheet-ease: cubic-bezier(0.32, 0.72, 0, 1);
		border-radius: 0 !important;
		background: transparent !important;
		border: 0 !important;
		box-shadow: none !important;
	}

	#mega-menu-wrap-primary::before,
	#mega-menu-wrap-primary::after {
		display: none !important;
		content: none !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item + li.mega-menu-item::before {
		display: none !important;
		content: none !important;
	}

	/* Hide plugin floating close */
	#mega-menu-wrap-primary .mega-menu-toggle ~ button.mega-close {
		display: none !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}

	/*
	 * Scrim: blur only — no full-screen dim (Safari safe-area / body paint
	 * stays unchanged). Soft darkening comes from the sheet's upward shadow.
	 * Click still hits this layer to dismiss.
	 */
	#mega-menu-wrap-primary .mega-menu-toggle.mega-menu-open:after {
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		width: 100% !important;
		height: 100dvh !important;
		content: "" !important;
		opacity: 1 !important;
		background: transparent !important;
		-webkit-backdrop-filter: blur(2px);
		backdrop-filter: blur(2px);
		cursor: pointer !important;
		z-index: 9999999998 !important;
		pointer-events: auto !important;
		transition: -webkit-backdrop-filter 0.36s var(--sheet-ease),
			backdrop-filter 0.36s var(--sheet-ease);
	}

	@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
		#mega-menu-wrap-primary .mega-menu-toggle.mega-menu-open:after {
			/* No backdrop-filter: keep transparent — sheet shadow does the work */
			background: transparent !important;
		}
	}

	/*
	 * Panel — bottom sheet.
	 * Must beat Max Mega Menu slide_right off-canvas (left:-100% / left:0).
	 * Use !important on transform/left so plugin + transitions cannot leave the
	 * panel stuck off-screen while .mega-menu-open is already set.
	 */
	#mega-menu-wrap-primary .mega-menu-toggle + #mega-menu-primary {
		left: 0 !important;
		right: 0 !important;
		top: auto !important;
		bottom: -1px !important;
		width: 100% !important;
		max-width: 100% !important;
		height: auto !important;
		min-height: min(70dvh, 100%) !important;
		max-height: min(92dvh, 100%) !important;
		margin: 0 !important;
		padding: 0 !important;
		display: flex !important;
		flex-direction: column !important;
		flex-wrap: nowrap !important;
		gap: 0 !important;
		overflow-x: hidden !important;
		overflow-y: auto !important;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		scrollbar-width: none; /* Firefox */
		-ms-overflow-style: none; /* IE/Edge legacy */
		visibility: hidden !important;
		opacity: 1 !important;
		pointer-events: none !important;
		transform: translate3d(0, 120%, 0) !important;
		transition: transform 0.36s var(--sheet-ease);
		border-radius: 24px 24px 0 0 !important;
		border: 0 !important;
		border-top: 1px solid rgba(226, 183, 90, 0.35) !important;
		/* Upward shadow = soft dim above the sheet (no full-screen scrim tint) */
		box-shadow:
		0 -1px 0 rgba(0, 0, 0, 0.2),
		0 -18px 40px rgba(0, 0, 0, 0.2),
		0 -48px 80px rgba(0, 0, 0, 0.3),
		0 -77px 140px rgba(0, 0, 0, 0.3) !important;
		background-color: var(--sheet-bg-deep) !important;
		background-image:
			linear-gradient(180deg, #6e1a14 0%, var(--sheet-bg) 42%, var(--sheet-bg-deep) 100%) !important;
		background-size: cover !important;
		background-repeat: no-repeat !important;
		/* Must stay above Mega Menu overlay :after (9999999998) */
		z-index: 9999999999 !important;
		font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
			"Segoe UI", "Microsoft YaHei", sans-serif !important;
	}

	#mega-menu-wrap-primary .mega-menu-toggle.mega-menu-open + #mega-menu-primary,
	html.mega-menu-primary-off-canvas-open #mega-menu-wrap-primary .mega-menu-toggle.mega-menu-open + #mega-menu-primary {
		visibility: visible !important;
		pointer-events: auto !important;
		transform: translate3d(0, 0, 0) !important;
		left: 0 !important;
		right: 0 !important;
	}

	#mega-menu-wrap-primary .mega-menu-toggle + #mega-menu-primary::-webkit-scrollbar {
		display: none;
		width: 0;
		height: 0;
	}

	/* ——— Header ——— */
	#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-sheet-header,
	#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-sheet-footer {
		display: block !important;
		visibility: visible !important;
		pointer-events: auto !important;
		float: none !important;
		width: 100% !important;
		height: auto !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		overflow: visible !important;
		left: auto !important;
		list-style: none !important;
		flex-shrink: 0;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-sheet-header {
		/* Scroll away with menu items (no sticky compositor layer) */
		position: relative !important;
		top: auto !important;
		z-index: 5;
		padding: 14px var(--sheet-pad-x) 12px !important;
		background: #6e1a14 !important;
		background-image: none !important;
		border-bottom: 1px solid rgba(226, 183, 90, 0.28) !important;
		box-shadow: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-header__row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		min-height: 40px;
	}

	#mega-menu-wrap-primary .ausbia-sheet-brand {
		display: inline-flex;
		align-items: center;
		gap: 10px;
		min-width: 0;
		text-decoration: none !important;
		color: var(--sheet-ink) !important;
	}

	#mega-menu-wrap-primary .ausbia-sheet-brand__mark {
		flex-shrink: 0;
		width: 32px;
		height: 32px;
		border-radius: 50%;
		object-fit: cover;
		border: 0;
		box-shadow: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-brand__mark--fallback {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		font-size: 12px;
		font-weight: 700;
		letter-spacing: 0.02em;
		color: #5c1210;
		background: #f0d28a;
	}

	#mega-menu-wrap-primary .ausbia-sheet-brand__name {
		display: none !important;
	}

	/* Top-right search (replaces close — dismiss via outside tap) */
	#mega-menu-wrap-primary .ausbia-sheet-search {
		appearance: none;
		-webkit-appearance: none;
		flex-shrink: 0;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 36px;
		height: 36px;
		margin: 0;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: rgba(255, 255, 255, 0.12);
		color: rgba(255, 244, 218, 0.92);
		cursor: pointer;
		position: relative;
		z-index: 7;
		pointer-events: auto !important;
		touch-action: manipulation;
		transition: background 0.2s ease, color 0.15s ease;
	}

	#mega-menu-wrap-primary .ausbia-sheet-search:hover,
	#mega-menu-wrap-primary .ausbia-sheet-search:focus-visible {
		background: rgba(255, 255, 255, 0.18);
		color: #fff9e9;
		outline: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-search__icon,
	#mega-menu-wrap-primary .ausbia-sheet-search__icon svg {
		display: block;
		width: 18px;
		height: 18px;
	}

	#mega-menu-wrap-primary .ausbia-sheet-search__icon svg circle,
	#mega-menu-wrap-primary .ausbia-sheet-search__icon svg path {
		stroke: currentColor;
		fill: none;
	}

	/* ——— Primary nav ——— */
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item:not(.ausbia-sheet-header):not(.ausbia-sheet-footer) {
		display: block !important;
		float: none !important;
		clear: both !important;
		width: 100% !important;
		margin: 0 !important;
		border: 0 !important;
		border-bottom: 1px solid var(--sheet-line) !important;
		box-shadow: none !important;
	}

	/* Desktop-only search icon — do not show inside mobile sheet */
	#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-header-search-item,
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-hide-on-mobile.ausbia-header-search-item {
		display: none !important;
		visibility: hidden !important;
		height: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		overflow: hidden !important;
		pointer-events: none !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item:not(.ausbia-sheet-header):not(.ausbia-sheet-footer):last-of-type {
		border-bottom-color: transparent !important;
	}

	/* Footer sits in normal flow after menu items */
	#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-sheet-footer {
		border-bottom: 0 !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item:not(.ausbia-sheet-header):not(.ausbia-sheet-footer) > a.mega-menu-link {
		display: flex !important;
		align-items: center;
		justify-content: space-between;
		gap: 16px;
		width: 100% !important;
		height: auto !important;
		min-height: 56px;
		margin: 0 !important;
		padding: 16px var(--sheet-pad-x) !important;
		line-height: 1.3 !important;
		text-align: left !important;
		font-size: 1.2rem !important;
		font-weight: 500 !important;
		letter-spacing: 0.01em;
		color: var(--sheet-ink) !important;
		background: transparent !important;
		border: 0 !important;
		border-radius: 0 !important;
		text-shadow: none !important;
		box-shadow: none !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item:not(.ausbia-sheet-header):not(.ausbia-sheet-footer) > a.mega-menu-link:hover,
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item:not(.ausbia-sheet-header):not(.ausbia-sheet-footer) > a.mega-menu-link:focus,
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item.mega-toggle-on > a.mega-menu-link,
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item.mega-current-menu-item > a.mega-menu-link,
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item.mega-current-menu-ancestor > a.mega-menu-link {
		color: #fff !important;
		background: rgba(255, 255, 255, 0.06) !important;
		font-weight: 500 !important;
	}

	/* Hide native「登录/注册」/ logout — footer CTA covers them (class set in PHP) */
	#mega-menu-wrap-primary #mega-menu-primary li.ausbia-sheet-hide-auth,
	#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-item-11735 {
		display: none !important;
		visibility: hidden !important;
		height: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		overflow: hidden !important;
		pointer-events: none !important;
	}

	/* Search row */
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item-16595 {
		max-width: 100% !important;
		width: 100% !important;
		padding: 10px var(--sheet-pad-x) 14px !important;
		border-bottom: 1px solid var(--sheet-line) !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item-16595 > a.mega-menu-link {
		display: none !important;
	}

	/* Chevron: simple triangle, right-aligned */
	#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-item-has-children > a.mega-menu-link > span.mega-indicator {
		display: inline-flex !important;
		align-items: center;
		justify-content: center;
		width: 20px;
		height: 20px;
		margin: 0 0 0 auto !important;
		opacity: 0.85;
		flex-shrink: 0;
	}

	#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-item-has-children > a.mega-menu-link > span.mega-indicator:after {
		content: "" !important;
		font-family: inherit !important;
		display: block !important;
		width: 0 !important;
		height: 0 !important;
		margin: 0 !important;
		border-left: 5px solid transparent !important;
		border-right: 5px solid transparent !important;
		border-top: 6px solid currentColor !important;
		border-bottom: 0 !important;
		transform: rotate(0deg);
		transition: transform 0.22s ease;
	}

	#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-item-has-children.mega-toggle-on > a.mega-menu-link > span.mega-indicator:after,
	#mega-menu-wrap-primary #mega-menu-primary li.mega-menu-item-has-children.mega-collapse-children.mega-toggle-on > a.mega-menu-link > span.mega-indicator:after {
		transform: rotate(180deg);
	}

	/* Submenus */
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item ul.mega-sub-menu {
		position: static !important;
		left: auto !important;
		float: none !important;
		width: 100% !important;
		max-width: none !important;
		margin: 0 !important;
		padding: 0 0 6px !important;
		border: 0 !important;
		border-radius: 0 !important;
		box-shadow: none !important;
		background: rgba(0, 0, 0, 0.18) !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item ul.mega-sub-menu li.mega-menu-item {
		border: 0 !important;
		box-shadow: none !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item ul.mega-sub-menu a.mega-menu-link {
		display: block !important;
		height: auto !important;
		min-height: 0 !important;
		line-height: 1.4 !important;
		padding: 12px var(--sheet-pad-x) 12px calc(var(--sheet-pad-x) + 12px) !important;
		text-align: left !important;
		font-size: 1rem !important;
		font-weight: 400 !important;
		color: var(--sheet-muted) !important;
		background: transparent !important;
		border: 0 !important;
		text-shadow: none !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item ul.mega-sub-menu a.mega-menu-link:hover,
	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item ul.mega-sub-menu a.mega-menu-link:focus {
		color: #fff !important;
		background: rgba(255, 255, 255, 0.05) !important;
	}

	#mega-menu-wrap-primary #mega-menu-primary > li.mega-menu-item ul.mega-sub-menu ul.mega-sub-menu a.mega-menu-link {
		padding-left: calc(var(--sheet-pad-x) + 24px) !important;
	}

	/* ——— Footer CTAs — scroll with content (no sticky pin) ——— */
	#mega-menu-wrap-primary #mega-menu-primary > li.ausbia-sheet-footer {
		position: relative !important;
		bottom: auto !important;
		z-index: 6;
		margin-top: auto !important;
		padding: 18px var(--sheet-pad-x) calc(18px + env(safe-area-inset-bottom, 0px)) !important;
		background: var(--sheet-bg-deep) !important;
		border-top: 1px solid var(--sheet-line) !important;
		border-bottom: 0 !important;
		box-shadow: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-actions {
		display: flex;
		flex-direction: column;
		gap: 10px;
	}

	#mega-menu-wrap-primary .ausbia-sheet-btn {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: 8px;
		width: 100%;
		min-height: 50px;
		padding: 13px 16px;
		border-radius: 12px;
		font-size: 1.02rem;
		font-weight: 600;
		letter-spacing: 0.01em;
		text-decoration: none !important;
		text-align: center;
		transition: background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
	}

	#mega-menu-wrap-primary .ausbia-sheet-btn:active {
		opacity: 0.88;
	}

	#mega-menu-wrap-primary .ausbia-sheet-btn--primary {
		color: #3a1204 !important;
		background: var(--sheet-gold);
		border: 0;
		box-shadow: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-btn--primary:hover,
	#mega-menu-wrap-primary .ausbia-sheet-btn--primary:focus-visible {
		background: #ebc56a;
		outline: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-btn--primary svg {
		width: 15px;
		height: 15px;
		stroke: currentColor;
		stroke-width: 2.2;
		stroke-linecap: round;
		stroke-linejoin: round;
		fill: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-btn--ghost {
		color: var(--sheet-ink) !important;
		background: transparent;
		border: 1.5px solid rgba(255, 255, 255, 0.32);
	}

	#mega-menu-wrap-primary .ausbia-sheet-btn--ghost:hover,
	#mega-menu-wrap-primary .ausbia-sheet-btn--ghost:focus-visible {
		background: rgba(255, 255, 255, 0.06);
		border-color: rgba(255, 255, 255, 0.5);
		outline: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-meta {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		margin-top: 14px;
		padding-top: 12px;
		border-top: 1px solid var(--sheet-line);
	}

	#mega-menu-wrap-primary .ausbia-sheet-lang {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		min-width: 0;
	}

	#mega-menu-wrap-primary .ausbia-sheet-lang__link {
		color: rgba(255, 255, 255, 0.55) !important;
		font-size: 0.875rem;
		font-weight: 500;
		letter-spacing: 0.01em;
		text-decoration: none !important;
		line-height: 1.2;
	}

	#mega-menu-wrap-primary .ausbia-sheet-lang__link.is-active {
		color: #fff !important;
		font-weight: 600;
	}

	#mega-menu-wrap-primary .ausbia-sheet-lang__link:hover,
	#mega-menu-wrap-primary .ausbia-sheet-lang__link:focus-visible {
		color: #fff !important;
		outline: none;
	}

	#mega-menu-wrap-primary .ausbia-sheet-lang__sep {
		color: rgba(255, 255, 255, 0.28);
		font-size: 0.875rem;
		line-height: 1;
	}

	#mega-menu-wrap-primary .ausbia-sheet-copy {
		flex-shrink: 0;
		color: rgba(255, 255, 255, 0.4);
		font-size: 0.75rem;
		letter-spacing: 0.04em;
		line-height: 1.2;
	}

	/* Prefer in-sheet language switcher — hide wpLingua floating widget on mobile */
	.wplng-switcher.insert-auto,
	.wplng-switcher.insert-auto.insert-bottom-left,
	.wplng-switcher.insert-auto.insert-bottom-right,
	.wplng-switcher.insert-auto.insert-bottom-center,
	body .wplng-switcher.insert-auto {
		display: none !important;
		visibility: hidden !important;
		pointer-events: none !important;
		opacity: 0 !important;
	}

	/* Legacy TranslatePress floater (if ever re-enabled) */
	#trp-floater-ls,
	.trp-floater-ls,
	#trp_floater_ls,
	div[id^="trp-floater-ls"] {
		display: none !important;
	}

	/* Primary mobile menu — animated SVG hamburger (replaces mega-toggle-animated) */
	#mega-menu-wrap-primary .mega-menu-toggle-animated-block {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	#mega-menu-wrap-primary .ausbia-mega-hamburger {
		cursor: pointer;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0;
		line-height: 0;
		-webkit-tap-highlight-color: transparent;
	}

	#mega-menu-wrap-primary .ausbia-mega-hamburger input {
		display: none;
		pointer-events: none;
	}

	#mega-menu-wrap-primary .ausbia-mega-hamburger svg {
		height: 2.2em;
		width: 2.2em;
		transition: transform 600ms cubic-bezier(0.4, 0, 0.2, 1);
	}

	#mega-menu-wrap-primary .ausbia-mega-hamburger .line {
		fill: none;
		stroke: #a82f28;
		stroke-linecap: round;
		stroke-linejoin: round;
		stroke-width: 3;
		transition: stroke-dasharray 600ms cubic-bezier(0.4, 0, 0.2, 1),
			stroke-dashoffset 600ms cubic-bezier(0.4, 0, 0.2, 1);
	}

	#mega-menu-wrap-primary .ausbia-mega-hamburger .line-top-bottom {
		stroke-dasharray: 12 63;
	}

	/* Open state from Mega Menu (.mega-menu-open), not checkbox — plugin calls preventDefault on click */
	#mega-menu-wrap-primary .mega-menu-toggle.mega-menu-open .ausbia-mega-hamburger svg,
	#mega-menu-wrap-primary .ausbia-mega-hamburger.is-open svg {
		transform: rotate(-45deg);
	}

	#mega-menu-wrap-primary .mega-menu-toggle.mega-menu-open .ausbia-mega-hamburger .line-top-bottom,
	#mega-menu-wrap-primary .ausbia-mega-hamburger.is-open .line-top-bottom {
		stroke-dasharray: 20 300;
		stroke-dashoffset: -32.42;
	}
}
