/* mod_my_menu - เมนูแบบกล่อง */

/*
 * Every setting arrives as a custom property written on the <nav> itself, so
 * two of these modules side by side can look nothing like each other while
 * sharing this one stylesheet. Each fallback is the template's own colour,
 * which is what makes an untouched module match the rest of the site.
 */
.my-mnu {
	--mnu-bg: #e6f4f8;
	--mnu-bg2: var(--mnu-bg);
	--mnu-line: var(--my-line, #d7e3ec);
	--mnu-head: var(--my-dark, #13203a);
	--mnu-head-bg: transparent;
	--mnu-bar: var(--my-primary, #1b5fa8);
	--mnu-rule: rgba(19, 32, 58, .14);
	--mnu-link: var(--my-primary, #1b5fa8);
	--mnu-hover: var(--my-dark, #13203a);
	--mnu-hover-bg: rgba(255, 255, 255, .6);
	--mnu-active: var(--my-dark, #13203a);
	--mnu-bullet: currentColor;
	--mnu-divider: rgba(19, 32, 58, .1);
	--mnu-marker: disc;
	--mnu-radius: 16px;
	--mnu-pad: 18px;
	--mnu-gap: 8px;
	--mnu-size: .95rem;
	--mnu-head-size: 1.05rem;
	--mnu-head-icon: .95em;
	--mnu-bullet-size: .68em;

	display: block;
	background: linear-gradient(160deg, var(--mnu-bg), var(--mnu-bg2));
	border-radius: var(--mnu-radius);
	padding: var(--mnu-pad);
	border: 0;
}

.my-mnu.has-line { border: 1px solid var(--mnu-line); }
.my-mnu.has-shadow { box-shadow: 0 6px 20px rgba(16, 40, 80, .12); }

/* --------------------------------------------------------------- header -- */
.my-mnu__head {
	display: flex; align-items: center; gap: 9px;
	font-size: var(--mnu-head-size); font-weight: 700; line-height: 1.4;
	color: var(--mnu-head); background: var(--mnu-head-bg);
	padding-bottom: 12px; margin-bottom: 12px;
}

/* The upright stroke beside the title, as on the rest of the site. */
.my-mnu__head.has-bar { padding-inline-start: 11px; position: relative; }
.my-mnu__head.has-bar::before {
	content: ""; position: absolute; inset-inline-start: 0; top: 2px;
	width: 4px; height: calc(var(--mnu-head-size) * 1.2);
	border-radius: 999px; background: var(--mnu-bar);
}

/*
 * A plain straight line the full width of the header. Nothing rounds this
 * element, because a border-radius would curl the ends of that line upward
 * and it would stop looking like a rule at all.
 */
.my-mnu__head.has-rule { border-bottom: 1px solid var(--mnu-rule); border-radius: 0; }

/*
 * A header given its own background becomes a band across the top of the box
 * rather than floating text, which is what anybody choosing a colour there
 * is picturing. Only then is it worth rounding - and never on the edge the
 * rule sits on.
 */
.my-mnu__head.has-bg {
	padding: 10px 12px; margin: calc(var(--mnu-pad) * -1) calc(var(--mnu-pad) * -1) 12px;
	border-start-start-radius: calc(var(--mnu-radius) - 1px);
	border-start-end-radius: calc(var(--mnu-radius) - 1px);
}

.my-mnu__head.has-bg.has-bar { padding-inline-start: 23px; }
.my-mnu__head.has-bg.has-bar::before { inset-inline-start: 12px; }
.my-mnu__head-icon { color: var(--mnu-bar); font-size: var(--mnu-head-icon, .95em); }

/* ไอคอนจากภายนอก (รูปภาพ) - ขนาดตามช่องขนาดไอคอนเดียวกัน */
.my-mnu__head-img {
	font-size: inherit;
	flex: 0 0 auto;
	width: auto;
	height: calc(var(--mnu-head-icon, .95em) * 1.35);
	max-width: 4em;
	object-fit: contain;
}
.my-mnu__head-text { min-width: 0; }

/* ---------------------------------------------------------------- links -- */
.my-mnu__list {
	list-style: var(--mnu-marker) outside;
	margin: 0; padding: 0 0 0 1.15em;
	display: flex; flex-direction: column; gap: var(--mnu-gap);
}

/* An icon bullet, or none at all, is drawn by us rather than by the list. */
.my-mnu.bullet-none .my-mnu__list,
.my-mnu.bullet-icon .my-mnu__list,
.my-mnu.bullet-image .my-mnu__list { list-style: none; padding-inline-start: 0; }

.my-mnu__item { margin: 0; color: var(--mnu-bullet); }

.my-mnu__link {
	display: inline-flex; align-items: baseline; gap: 8px;
	color: var(--mnu-link); font-size: var(--mnu-size); line-height: 1.55;
	text-decoration: none;
	transition: color .16s ease, background-color .16s ease,
		padding-inline-start .16s ease, opacity .16s ease;
}

.my-mnu__link.is-plain { color: var(--mnu-head); font-weight: 600; cursor: default; }

.my-mnu__bullet { flex: 0 0 auto; font-size: var(--mnu-bullet-size, .68em); color: var(--mnu-bullet); }

/* รูปภาพนำหน้ารายการ - ขนาดตามช่องขนาดสัญลักษณ์ วางกึ่งกลางบรรทัด */
.my-mnu__bullet--img {
	/* The size box is in em of the line, not of the (already shrunk) icon. */
	font-size: inherit;
	width: auto;
	height: calc(var(--mnu-bullet-size, .68em) * 1.8);
	max-width: 3em;
	object-fit: contain;
	align-self: center;
}
.my-mnu__text { min-width: 0; }

/* Nesting reads as indentation, one step per level. */
.my-mnu__item.level-2 { padding-inline-start: 14px; }
.my-mnu__item.level-3 { padding-inline-start: 28px; }
.my-mnu__item.level-4 { padding-inline-start: 42px; }

.my-mnu__note {
	display: block; font-size: .76rem; opacity: .72;
	margin-top: 2px; padding-inline-start: 16px;
}

/* A line between one item and the next, when the menu is long. */
.my-mnu.has-dividers .my-mnu__item + .my-mnu__item {
	border-top: 1px solid var(--mnu-divider);
	padding-top: var(--mnu-gap);
}

/* ------------------------------------------------------------ underline -- */
.my-mnu.under-always .my-mnu__link { text-decoration: underline; text-underline-offset: 3px; }
.my-mnu.under-hover .my-mnu__link:hover,
.my-mnu.under-hover .my-mnu__link:focus-visible {
	text-decoration: underline; text-underline-offset: 3px;
}

/*
 * "ไม่มีเส้นใต้" has to say so out loud. The template underlines every link
 * under the pointer, and that rule is more specific than the plain one on
 * .my-mnu__link above, so without this the setting appears to do nothing.
 *
 * High contrast mode is deliberately left out: underlining every link is the
 * whole point of it, and a module option must not take that away.
 */
body:not(.my-contrast) .my-mnu.under-none .my-mnu__link,
body:not(.my-contrast) .my-mnu.under-none .my-mnu__link:hover,
body:not(.my-contrast) .my-mnu.under-none .my-mnu__link:focus-visible {
	text-decoration: none;
}

/* ---------------------------------------------------------------- hover -- */
/*
 * Same story as the underline: the template also changes a link's colour
 * under the pointer, so "ไม่เปลี่ยนอะไร" has to hold the colour still itself.
 */
.my-mnu.hover-none .my-mnu__link:hover,
.my-mnu.hover-none .my-mnu__link:focus-visible { color: var(--mnu-link); }

.my-mnu.hover-colour .my-mnu__link:hover,
.my-mnu.hover-colour .my-mnu__link:focus-visible { color: var(--mnu-hover); }

.my-mnu.hover-fill .my-mnu__link {
	border-radius: 8px; padding: 3px 9px; margin-inline-start: -9px;
}
.my-mnu.hover-fill .my-mnu__link:hover,
.my-mnu.hover-fill .my-mnu__link:focus-visible {
	color: var(--mnu-hover); background: var(--mnu-hover-bg);
}

/* The whole row steps aside a little, the way a pressed key gives. */
.my-mnu.hover-slide .my-mnu__link:hover,
.my-mnu.hover-slide .my-mnu__link:focus-visible {
	color: var(--mnu-hover); padding-inline-start: 6px;
}

.my-mnu .my-mnu__link.is-plain:hover { color: var(--mnu-head); background: none; padding-inline-start: 0; }

/* --------------------------------------------------------- current page -- */
.my-mnu.marks-active .my-mnu__item.is-active > .my-mnu__link,
.my-mnu.marks-active .my-mnu__item.is-onpath > .my-mnu__link {
	color: var(--mnu-active); font-weight: 700;
}

.my-mnu.marks-active .my-mnu__item.is-onpath > .my-mnu__link { font-weight: 600; }

/* A heading in the menu is a label, not something to press. */
.my-mnu__item.is-heading > .my-mnu__link {
	color: var(--mnu-head); font-weight: 700;
	font-size: calc(var(--mnu-size) * .92); text-transform: none; opacity: .85;
}

@media (prefers-reduced-motion: reduce) {
	.my-mnu__link { transition: none; }
}
