/*
 * menu-widget-horizontal-dropdown.css
 *
 * Horizontal nav + CSS-only hover dropdown of immediate menupoint
 * children. Neutral primitives — per-region CSS overrides come from the
 * design panel (root, list, link, submenu).
 *
 * Mobile note: hover-open is desktop-only. Touch devices won't reveal
 * the submenu. A click-toggle JS variant can be added later without
 * touching this base CSS.
 */

.menu-widget-horizontal-dropdown {
    display: block;
    width: 100%;
    font-family: var(--mc-theme-font-body, system-ui, -apple-system, "Segoe UI", sans-serif);
    color: var(--mc-theme-color-ink, #151515);
}

.menu-widget-horizontal-dropdown--sticky {
    position: sticky;
    top: calc(var(--mcfw-widget-sticky-design-offset, 0px) + var(--mcfw-widget-sticky-top, 0px));
    z-index: var(--mcfw-widget-sticky-z-index, 120);
    background: color-mix(in srgb, var(--mc-theme-color-paper, #ffffff) 96%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--mc-theme-color-ink, #151515) 8%, transparent);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.menu-widget-horizontal-dropdown--sticky .menu-widget-horizontal-dropdown-list {
    min-height: 64px;
    padding: 10px 18px;
    box-sizing: border-box;
}

/* Design-mode preview: the widget is wrapped in a `.layout-item` frame,
 * so the inner nav cannot visibly stick on its own because it is bounded
 * by that wrapper. Promote the wrapper itself to sticky when it contains
 * a sticky horizontal dropdown, and neutralize the inner sticky so the
 * preview behaves like the public page. */
.layout-item:has(> .menu-widget-horizontal-dropdown--sticky) {
    position: sticky;
    top: calc(var(--mcfw-widget-sticky-design-offset, 0px) + var(--mcfw-widget-sticky-top, 0px));
    z-index: var(--mcfw-widget-sticky-z-index, 140);
    overflow: visible;
}

.layout-item:has(> .menu-widget-horizontal-dropdown--sticky) > .menu-widget-horizontal-dropdown--sticky {
    position: static;
}

.menu-widget-horizontal-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

.menu-widget-horizontal-dropdown-list > li {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.menu-widget-horizontal-dropdown-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
    line-height: 1.2;
    transition: background-color 120ms ease, color 120ms ease;
    white-space: nowrap;
}

.menu-widget-horizontal-dropdown-link:hover,
.menu-widget-horizontal-dropdown-link:focus-visible {
    background: color-mix(in srgb, var(--mc-theme-color-ink, #151515) 6%, transparent);
    text-decoration: none;
}

.menu-widget-horizontal-dropdown-list > li.is-active .menu-widget-horizontal-dropdown-link,
.menu-widget-horizontal-dropdown-list > li.is-active .menuitem-link-widget {
    background: color-mix(in srgb, var(--mc-theme-color-accent, #0170b9) 14%, transparent);
    color: var(--mc-theme-color-accent, #0170b9);
    font-weight: 600;
}

/* Parent items with children get a small chevron after the link. */
.menu-widget-horizontal-dropdown-list > li.has-children > .menuitem-link-widget::after,
.menu-widget-horizontal-dropdown-list > li.has-children > .menu-widget-horizontal-dropdown-link::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 6px;
    border: 4px solid transparent;
    border-top-color: currentColor;
    transform: translateY(2px);
    opacity: 0.6;
}

/* Submenu — absolutely positioned under the parent <li>, revealed on hover. */
.menu-widget-horizontal-dropdown-submenu {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: var(--mc-theme-color-paper, #ffffff);
    border: 1px solid color-mix(in srgb, var(--mc-theme-color-ink, #151515) 10%, transparent);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease, visibility 120ms;
}

.menu-widget-horizontal-dropdown-list > li:hover > .menu-widget-horizontal-dropdown-submenu,
.menu-widget-horizontal-dropdown-list > li:focus-within > .menu-widget-horizontal-dropdown-submenu,
.menu-widget-horizontal-dropdown-list > li.is-edit-locked > .menu-widget-horizontal-dropdown-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-widget-horizontal-dropdown-submenu > li {
    display: block;
}

.menu-widget-horizontal-dropdown-submenu > li.is-active .menuitem-dropdown-child-widget,
.menu-widget-horizontal-dropdown-submenu > li.is-active .menu-widget-horizontal-dropdown-child-link {
    background: color-mix(in srgb, var(--mc-theme-color-accent, #0170b9) 12%, transparent);
    color: var(--mc-theme-color-accent, #0170b9);
    font-weight: 600;
}

/* Fallback link when no `menuitem_dropdown_child_widget` is registered. */
.menu-widget-horizontal-dropdown-child-link {
    display: block;
    padding: 6px 14px;
    color: inherit;
    text-decoration: none;
    line-height: 1.3;
    white-space: nowrap;
}

.menu-widget-horizontal-dropdown-child-link:hover,
.menu-widget-horizontal-dropdown-child-link:focus-visible {
    background: color-mix(in srgb, var(--mc-theme-color-ink, #151515) 6%, transparent);
    text-decoration: none;
}

/* Author-only empty state — only emitted in design mode. */
.menu-widget-horizontal-dropdown-empty {
    color: color-mix(in srgb, var(--mc-theme-color-ink, #151515) 46%, transparent);
    font-style: italic;
    padding: 8px 12px;
}

.menu-widget-horizontal-dropdown-empty-template {
    width: 100%;
}
