/* Header mega menu (inc/mega-menu.php, assets/js/mega-menu.js) and footer detector call to action.
   Desktop (> 960 px): full-width panels under the header bar. Phones and tablets: accordion inside the menu drawer. */

/* ------------------------------------------------------------------ Top entries */
.mega-menu { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; }
.mega-top {
	display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; border: 0; border-radius: 9px; background: none;
	font: inherit; font-size: .9rem; font-weight: 650; line-height: 1.2; color: #3f5373; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.mega-top .icon-chevron { width: 15px; height: 15px; transition: transform .18s ease; }
.mega-top:hover, .mega-item.is-open > .mega-top, .mega-item.is-current > .mega-top { color: var(--blue); background: #f2f6ff; }
.mega-item.is-open > .mega-top .icon-chevron { transform: rotate(180deg); }
.mega-top:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.mega-top-ico { display: flex; }
.mega-top-ico svg { width: 16px; height: 16px; }
.mega-item.is-highlight > .mega-top { color: var(--blue-dark); background: #eaf2ff; box-shadow: inset 0 0 0 1px #c6d9ff; }
.mega-item.is-highlight > .mega-top:hover, .mega-item.is-highlight.is-current > .mega-top { background: #dce9ff; color: var(--blue-dark); }
.nav-mobile-cta { display: none; }

/* ------------------------------------------------------------------ Panels (desktop) */
.mega-panel {
	display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 55; background: #fff;
	border-top: 1px solid var(--line); border-bottom: 1px solid var(--edge); box-shadow: 0 30px 50px -18px rgba(16, 36, 73, .26);
	max-height: calc(100vh - 110px); overflow-y: auto; overscroll-behavior: contain;
}
.mega-item.is-open > .mega-panel { display: block; animation: mega-in .16s ease-out; }
.no-js .mega-item:hover > .mega-panel, .no-js .mega-item:focus-within > .mega-panel { display: block; }
@keyframes mega-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.site-header.has-mega::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 100vh; z-index: 54; background: rgba(16, 36, 73, .14); pointer-events: none; animation: mega-fade .16s ease-out; }
@keyframes mega-fade { from { opacity: 0; } to { opacity: 1; } }

.mega-inner { display: grid; grid-template-columns: repeat(var(--mega-cols, 3), minmax(0, 1fr)); gap: 8px 26px; padding: 26px 0 22px; }
.mega-inner.has-aside { grid-template-columns: repeat(var(--mega-cols, 3), minmax(0, 1fr)) minmax(270px, 300px); }
.mega-heading { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 0 10px; font-size: .74rem; font-weight: 800; letter-spacing: .06em; line-height: 1.3; text-transform: uppercase; color: var(--muted); }
.mega-heading a { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.mega-heading a:hover { color: var(--blue); }
.mega-heading-ico { display: flex; color: var(--blue); }
.mega-heading-ico svg { width: 15px; height: 15px; }
.mega-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mega-link { display: flex; gap: 12px; align-items: flex-start; padding: 9px 10px; border-radius: 11px; color: var(--ink); text-decoration: none; transition: background-color .12s; }
.mega-link:hover, .mega-link[aria-current] { background: #f3f7ff; color: var(--ink); }
.mega-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; background: #eaf2ff; color: var(--blue); display: grid; place-items: center; }
.mega-ico svg { width: 18px; height: 18px; }
.mega-txt { display: grid; gap: 2px; min-width: 0; padding-top: 1px; }
.mega-title { font-size: .92rem; font-weight: 700; line-height: 1.3; }
.mega-link:hover .mega-title, .mega-link[aria-current] .mega-title { color: var(--blue); }
.mega-desc { font-size: .8rem; line-height: 1.4; color: var(--muted); }

/* Cards (right column) */
.mega-aside { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; min-width: 0; }
.mega-card { padding: 16px 18px; border: 1px solid var(--edge); border-radius: 14px; background: var(--light); }
.mega-card-link { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: .98rem; font-weight: 800; line-height: 1.3; text-decoration: none; }
.mega-card-link:hover { color: var(--blue); }
.mega-card-ico { flex: none; width: 32px; height: 32px; border-radius: 10px; background: #fff; color: var(--blue); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.mega-card-ico svg { width: 17px; height: 17px; }
.mega-card-desc { margin: 6px 0 0; font-size: .82rem; line-height: 1.45; color: var(--muted); }
.mega-card.is-detector { border-color: transparent; background: linear-gradient(120deg, #0b1b3f 0%, #12306b 70%, #1d63ed 150%); box-shadow: 0 12px 28px rgba(11, 27, 63, .2); }
.mega-card.is-detector .mega-card-link { color: #fff; }
.mega-card.is-detector .mega-card-link:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.mega-card.is-detector .mega-card-link:focus-visible { outline-color: #fff; }
.mega-card.is-detector .mega-card-ico { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: none; }
.mega-card.is-detector .mega-card-desc { color: #c7d4f3; }
.mega-detect { display: flex; gap: 6px; margin-top: 12px; padding: 5px; border-radius: 11px; background: #fff; }
.mega-detect input { flex: 1; min-width: 0; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: .9rem; color: var(--ink); }
.mega-detect input:focus { outline: 2px solid var(--blue); outline-offset: 0; }
.mega-detect .btn { padding: 8px 13px; font-size: .84rem; white-space: nowrap; box-shadow: none; }
.mega-detect .btn:hover { transform: none; }
.mega-card-sub { margin: 12px 0 4px; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mega-posts { list-style: none; margin: 0; padding: 0; }
.mega-posts li { padding: 7px 0; border-top: 1px solid var(--edge); }
.mega-posts li:first-child { border-top: 0; }
.mega-posts a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .85rem; font-weight: 650; line-height: 1.35; color: #33476a; text-decoration: none; }
.mega-posts a:hover { color: var(--blue); }

/* Bottom bar: hub page and secondary links */
.mega-foot { grid-column: 1 / -1; list-style: none; margin: 10px 0 0; padding: 14px 10px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 28px; }
.mega-foot a { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; font-weight: 700; color: var(--blue); text-decoration: none; }
.mega-foot a:hover { color: var(--blue-dark); text-decoration: underline; text-underline-offset: 3px; }
.mega-foot-ico { display: flex; }
.mega-foot-ico svg { width: 16px; height: 16px; }

@media (max-width: 1180px) and (min-width: 961px) {
	.mega-top { padding: 9px 9px; font-size: .86rem; }
	.mega-inner { gap: 8px 16px; }
	.mega-inner.has-aside { grid-template-columns: repeat(var(--mega-cols, 3), minmax(0, 1fr)) minmax(240px, 260px); }
	.mega-link { gap: 10px; padding: 8px; }
	.mega-ico { width: 30px; height: 30px; }
}
@media (max-width: 1100px) and (min-width: 961px) {
	.mega-top { padding: 8px 7px; gap: 4px; }
	.mega-top-ico { display: none; }
	.site-header .brand-logo { height: 32px; width: auto; }
	.lang-switch summary { padding: 7px 8px; gap: 5px; }
}

/* ------------------------------------------------------------------ Phones and tablets: accordion in the drawer */
@media (max-width: 960px) {
	.main-nav { max-height: calc(100vh - 66px); max-height: calc(100dvh - 66px); overflow-y: auto; overscroll-behavior: contain; }
	.mega-menu { flex-direction: column; align-items: stretch; gap: 2px; }
	.mega-top { width: 100%; min-height: 50px; justify-content: space-between; padding: 12px 10px; font-size: 1rem; }
	.mega-top .icon-chevron { width: 18px; height: 18px; }
	.mega-item.is-current > .mega-top { background: none; }
	.mega-item.is-open > .mega-top { background: #f2f6ff; }
	.mega-item.is-highlight { order: -1; margin: 2px 0 8px; }
	.mega-item.is-highlight > .mega-top, .mega-item.is-highlight > .mega-top:hover, .mega-item.is-highlight.is-current > .mega-top { justify-content: center; gap: 8px; background: var(--blue); color: #fff; box-shadow: none; }
	.mega-panel { position: static; display: none; border: 0; box-shadow: none; max-height: none; overflow: visible; }
	.mega-item.is-open > .mega-panel { animation: none; }
	.mega-inner, .mega-inner.has-aside { display: block; width: auto; padding: 6px 0 12px 8px; }
	.mega-col + .mega-col, .mega-aside { margin-top: 14px; }
	.mega-desc { display: none; }
	.mega-link { align-items: center; min-height: 46px; padding: 7px 10px; }
	.mega-ico { width: 30px; height: 30px; border-radius: 9px; }
	.mega-ico svg { width: 17px; height: 17px; }
	.mega-txt { padding: 0; }
	.mega-title { font-size: .96rem; font-weight: 650; }
	.mega-aside { display: grid; gap: 10px; }
	.mega-foot { flex-direction: column; gap: 0; margin-top: 12px; padding: 6px 10px 0; }
	.mega-foot a { min-height: 44px; }
	.site-header.has-mega::after { display: none; }
	/* Without JavaScript: the menu is shown under the bar (panels open on focus), no drawer button. */
	.no-js .site-header { position: static; }
	.no-js .nav-shell { flex-wrap: wrap; height: auto; min-height: 66px; padding: 10px 0; }
	.no-js .menu-toggle { display: none; }
	.no-js .main-nav { order: 10; flex: 1 1 100%; max-height: none; overflow: visible; }
}
@media (max-width: 650px) {
	.nav-mobile-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
	.nav-mobile-cta .btn { flex: 1 1 auto; justify-content: center; padding: 13px 18px; }
	.nav-mobile-cta .account-link { min-height: 44px; font-size: .95rem; }
	.nav-mobile-cta .account-link span { display: inline; }
}

/* ------------------------------------------------------------------ Footer: detector call to action */
.footer-detector {
	display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(300px, 430px); gap: 14px 22px; align-items: center;
	margin-top: 40px; padding: 22px 26px; border: 1px solid #cfe0ff; border-radius: 16px; background: linear-gradient(110deg, #eaf2ff, #fff 75%);
}
.footer-detector-ico { width: 48px; height: 48px; border-radius: 14px; background: var(--blue); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 18px rgba(23, 101, 244, .25); }
.footer-detector-ico svg { width: 24px; height: 24px; }
.footer-detector h2 { margin: 0 0 3px; font-size: 1.15rem; line-height: 1.3; letter-spacing: -.01em; }
.footer-detector p { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--muted); }
.footer-detect { display: flex; gap: 8px; padding: 6px; border: 1px solid #c9d5e8; border-radius: 12px; background: #fff; }
.footer-detect:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 101, 244, .18); }
.footer-detect input { flex: 1; min-width: 0; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: .95rem; color: var(--ink); }
.footer-detect input:focus { outline: none; }
.footer-detect .btn { white-space: nowrap; box-shadow: none; }
.footer-detect .btn:hover { transform: none; }
.footer-detector + .footer-grid, .site-footer > .container:first-child + .footer-grid { padding-top: 40px; }
@media (max-width: 960px) {
	.footer-detector { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
	.footer-detect { grid-column: 1 / -1; }
}
@media (max-width: 650px) {
	.footer-detector { margin-top: 28px; padding: 18px; gap: 12px 14px; }
	.footer-detector-ico { width: 40px; height: 40px; border-radius: 12px; }
	.footer-detector-ico svg { width: 20px; height: 20px; }
	.footer-detect .btn { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
	.mega-item.is-open > .mega-panel, .site-header.has-mega::after { animation: none; }
	.mega-top .icon-chevron, .mega-link { transition: none; }
}
@media print { .mega-panel, .nav-mobile-cta, .footer-detector { display: none !important; } }
