/* ============================================================
   RS Mega Menu — Frontend
   ============================================================

   Design tokens (override in theme CSS if needed):
   --rs-megamenu-accent: #A695B7
   --rs-megamenu-bg:     #F1EDF6
   --rs-megamenu-text:   #444444
   --rs-megamenu-white:  #ffffff
   ============================================================ */

:root {
	--rs-megamenu-accent: #A695B7;
	--rs-megamenu-bg:     #F1EDF6;
	--rs-megamenu-text:   #444444;
	--rs-megamenu-white:  #ffffff;
}

/* ---- Dropdown Container ---- */
.rs-megamenu-dropdown {
	position: fixed;
	top: 107px;
	left: 0;
	right: 0;
	z-index: 9999;
	display: none;
	justify-content: center;
}

.rs-megamenu-dropdown.is-visible {
	display: flex;
}

/* ---- Main Wrapper (CSS Grid) ----
   Grid layout lets image and panel share the same row,
   so image height = panel height automatically.

   |  (empty)  |   tabs   |  ← row 1 (auto)
   |   image   |   panel  |  ← row 2 (1fr, stretches)
   -------------------------------------------------------- */

.rs-megamenu-wrapper {
	box-sizing: border-box;
	display: grid;
	width: 1067px;
	max-width: 100%;
	grid-template-columns: 307px 1fr;
	grid-template-rows: auto 1fr;
	column-gap: 20px;
	row-gap: 8px;
	padding: 20px;
	background: var(--rs-megamenu-bg);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.16);
}

/* Content wrapper becomes transparent to grid */
.rs-megamenu-content {
	display: contents;
}

/* ---- Image (row 2, bottom-aligned within cell) ---- */
.rs-megamenu-image {
	grid-column: 1;
	grid-row: 2;
	align-self: end;
	min-height: 0;
}

.rs-megamenu-image img {
	width: 100%;
	height: 100%;
	min-height: 250px;
	object-fit: cover;
	border-top-left-radius: 20px;
	border-top-right-radius: 40px;
	display: block;
}

.rs-megamenu-image-placeholder {
	width: 100%;
	height: 100%;
	min-height: 250px;
	background: #d9d9d9;
	border-top-left-radius: 20px;
	border-top-right-radius: 40px;
}

/* ---- Tab Bar (row 1, right column) ---- */
.rs-megamenu-tabs {
	grid-column: 2;
	grid-row: 1;
	background: var(--rs-megamenu-bg);
	display: flex;
	align-items: center;
	gap: 20px;
	flex-wrap: wrap;
}

.rs-megamenu-tab {
	padding: 16px;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	background: none;
	border: none;
	border-bottom: 2px solid transparent;
	font-size: 18px;
	font-family: 'Noto Serif TC', serif;
	font-weight: 400;
	line-height: 1.6;
	letter-spacing: 0.9px;
	color: var(--rs-megamenu-text);
	white-space: nowrap;
	transition: color 0.2s, border-color 0.2s;
}

.rs-megamenu-tab:hover,
.rs-megamenu-tab.active {
	color: var(--rs-megamenu-accent);
	border-bottom-color: var(--rs-megamenu-accent);
}

/* ---- Panel (row 2, right column) ---- */
.rs-megamenu-panel {
	grid-column: 2;
	grid-row: 2;
	padding: 32px 16px;
	background: var(--rs-megamenu-white);
	display: grid;
	width: 1067px;
	max-width: 100%;
	grid-template-columns: repeat(2, 1fr);
	align-content: start;
	min-height: 250px;
}

/* ---- Item ---- */
.rs-megamenu-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 8px;
	text-decoration: none;
	color: var(--rs-megamenu-text);
	transition: opacity 0.15s;
	min-width: 0;               /* prevent overflow into adjacent cells */
}

.rs-megamenu-item:hover {
	opacity: 0.7;
}

.rs-megamenu-item-icon {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
}

.rs-megamenu-item-name {
	font-size: 16px;
	font-family: 'Noto Serif TC', serif;
	font-weight: 400;
	line-height: 1.6;
	letter-spacing: 0.8px;
	overflow-wrap: break-word;   /* break very long strings */
	word-break: break-word;
	min-width: 0;
}

/* ---- Loading Spinner ---- */
.rs-megamenu-panel.is-loading {
	min-height: 120px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.rs-megamenu-panel.is-loading::after {
	content: '';
	width: 28px;
	height: 28px;
	border: 3px solid #eee;
	border-top-color: var(--rs-megamenu-accent);
	border-radius: 50%;
	animation: rs-spin 0.6s linear infinite;
}

@keyframes rs-spin {
	to { transform: rotate(360deg); }
}

/* ============================================================
   RWD — 950px ~ 1440px
   ============================================================ */

@media (max-width: 1439px) and (min-width: 950px) {
	.rs-megamenu-wrapper {
		grid-template-columns: clamp(180px, 22vw, 307px) 1fr;
		column-gap: 16px;
		padding: 16px;
	}

	.rs-megamenu-tabs {
		gap: 12px;
	}

	.rs-megamenu-tab {
		padding: 12px 10px;
		font-size: clamp(14px, 1.3vw, 18px);
	}

	.rs-megamenu-panel {
		padding: 24px 12px;
	}

	.rs-megamenu-item-name {
		font-size: clamp(13px, 1.15vw, 16px);
	}
}

/* ============================================================
   950px+ — hide native sub-menus & arrows on triggers
   ============================================================ */

@media (min-width: 950px) {
	li.rs-megamenu-has-mega > ul,
	li.rs-megamenu-has-mega > ol,
	li.rs-megamenu-has-mega > .sub-menu,
	li.rs-megamenu-has-mega > .children {
		display: none !important;
	}

	li.rs-megamenu-has-mega > a::after,
	li.rs-megamenu-has-mega > a::before,
	li.rs-megamenu-has-mega > button::after,
	li.rs-megamenu-has-mega > .sub-menu-toggle,
	li.rs-megamenu-has-mega > a > .dropdown-caret,
	li.rs-megamenu-has-mega > a > svg.dropdown-icon {
		display: none !important;
	}
}

/* ============================================================
   Below 950px — hide mega menu entirely
   ============================================================ */

@media (max-width: 949px) {
	.rs-megamenu-dropdown {
		display: none !important;
	}
}
