/* Desktop megamenu rendering.
 *
 * Activated by the layout template only for nav parents marked
 * megamenu_parent with at least 4 children. The reveal trigger is the
 * megamenu's parent [data-nav-group] entering :hover (desktop) or
 * receiving a tap-equivalent (mobile-tablet — wired by nav-megamenu.js
 * so it works with synthetic-click events too).
 *
 * Motion fidelity scales off the layout-root --motion-multiplier so the
 * "high motion" path slides the panel down and the "reduced motion" /
 * forced-zero path collapses to a fade. The slide distance is wrapped
 * in calc() against the multiplier so a 0 multiplier produces no
 * vertical travel at all.
 */

[data-nav-megamenu] {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--header-bg, var(--color-surface, #ffffff));
    color: var(--header-text, var(--color-text, inherit));
    box-shadow: var(--elevation-lg, 0 12px 32px rgba(0, 0, 0, 0.18));
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    padding: var(--spacing-lg, 1.5rem);
    z-index: 50;

    opacity: 0;
    visibility: hidden;
    transform: translateY(calc(-8px * var(--motion-multiplier, 1)));
    transition: opacity var(--anim-normal, 200ms) ease,
                visibility var(--anim-normal, 200ms) ease,
                transform var(--anim-normal, 200ms) ease;
    pointer-events: none;
}

/* Hover / focus-within on the parent nav-group reveals the panel.
 * focus-within keeps keyboard users covered without requiring a JS
 * focus-trap; nav-megamenu.js owns tap reveal on coarse pointers.
 */
[data-nav-group]:hover [data-nav-megamenu],
[data-nav-group]:focus-within [data-nav-megamenu],
[data-nav-megamenu][data-open="true"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.nav-megamenu-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md, 1rem);
}

.nav-megamenu-column {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs, 0.5rem);
    padding: var(--spacing-sm, 0.75rem);
    border-radius: var(--corner-default, 8px);
    color: inherit;
    text-decoration: none;
    transition: background var(--anim-fast, 120ms) ease;
}

.nav-megamenu-column:hover,
.nav-megamenu-column:focus-visible {
    background: var(--color-surface-muted, rgba(0, 0, 0, 0.04));
}

.nav-megamenu-column .nav-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: var(--corner-subtle, 4px);
    display: block;
}

.nav-megamenu-column-label {
    font-weight: 600;
    color: var(--header-text, inherit);
}

.nav-megamenu-column-summary {
    font-size: 0.875rem;
    color: var(--color-text-muted, rgba(0, 0, 0, 0.65));
    line-height: 1.4;
}

/* Text-only column variant: no image resolved. Reserve the same
 * vertical block so adjacent image-bearing columns stay aligned.
 */
.nav-megamenu-column--text-only::before {
    content: "";
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--color-surface-muted, rgba(0, 0, 0, 0.05));
    border-radius: var(--corner-subtle, 4px);
}

/* Mobile / tablet — the megamenu collapses to a regular dropdown so
 * the layered-mobile-nav shell is the only mobile surface. The
 * dropdown still uses the data-submenu styles the existing layout
 * already ships.
 */
@media (max-width: 1023px) {
    [data-nav-megamenu] {
        display: none;
    }
}
