/* =========================================================
   MENU (desktop, from 1280px up)
========================================================= */

.main-navigation {
    height: 100%;
    padding: 0 24px;
}

/* Safety net: hidden dropdowns still take up layout space; whatever happens,
   the header never adds a horizontal scrollbar to the page.
   (clip, unlike hidden, keeps the sticky header and the vertical dropdowns working) */
.site-header {
    overflow-x: clip;
}

/* Items take the full height of the header cell, so dropdowns hang
   exactly from the header's bottom line instead of from the middle */
.main-menu {
    display: flex;
    align-items: stretch;
    gap: 34px;

    height: 100%;
    margin: 0;
    padding: 0;

    list-style: none;
}

.main-menu > li {
    position: relative;
    display: flex;
    align-items: center;
}

.main-menu > li > a {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;

    font-size: 14px;
    font-weight: 400;

    color: var(--color-text);
    white-space: nowrap;

    transition: opacity 0.2s ease;
}

.main-menu > li > a:hover {
    opacity: 0.6;
}

/* Current page, or the section that contains it (e.g. "Προφίλ" while on
   "Οι χώροι μας"): same accent as the current item inside the dropdown */
.main-menu > .current-menu-item > a,
.main-menu > .current-menu-ancestor > a,
.main-menu > .current-menu-parent > a,
.main-menu > .current-post-ancestor > a {
    color: var(--color-accent);
    font-weight: 500;
}

.main-menu a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
}

/* =========================================================
   SUB MENU
   Same language as the grid: black frame, cream background,
   items edge to edge (no padding above the first / below the last).
========================================================= */

.main-menu .sub-menu {
    position: absolute;
    top: 100%; /* its top border lies on the header's bottom line: one line, no gap */
    left: calc(-18px - var(--border-size)); /* item text lines up with the menu item above */

    min-width: 250px;
    max-width: 320px;

    margin: 0;
    padding: 0;

    list-style: none;

    background: var(--color-background);
    border: var(--border-size) solid var(--border-color);
    box-shadow: 0 14px 28px rgba(26, 26, 26, 0.08);

    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);

    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;

    z-index: 99;
}

/* A dropdown that would leave the screen (items near the right edge) is
   aligned to the right side of its item instead; .open-left is set in general.js */
.main-menu > li > .sub-menu.open-left {
    left: auto;
    right: calc(-18px - var(--border-size));
}

/* Open on hover, on keyboard focus (Tab) and on tap (.is-open, set in general.js) */
.main-menu li:hover > .sub-menu,
.main-menu li:focus-within > .sub-menu,
.main-menu li.is-open > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.main-menu .sub-menu li {
    position: relative;
    width: 100%;
}

/* Thin rule between items, never above the first or below the last */
.main-menu .sub-menu li + li {
    border-top: 1px solid rgba(26, 26, 26, 0.08);
}

.main-menu .sub-menu a {
    display: block;

    padding: 11px 18px;

    font-size: 14px;
    line-height: 1.35;

    color: var(--color-text);

    transition: background-color 0.2s ease, color 0.2s ease;
}

.main-menu .sub-menu a:hover,
.main-menu .sub-menu li:focus-within > a,
.main-menu .sub-menu li.is-open > a {
    background-color: var(--color-surface);
}

/* Group heading inside a submenu (e.g. "Επιπλέον παροχές"): a label, not a link */
.main-menu .sub-menu .menu-heading > a {
    padding-top: 16px;
    padding-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
}

.main-menu .sub-menu .menu-heading > a:hover {
    background-color: transparent;
}

.main-menu .sub-menu .current-menu-item > a,
.main-menu .sub-menu .current-menu-ancestor > a {
    color: var(--color-accent);
    font-weight: 500;
}

/* Third level opens to the side of its parent item, top item level with it;
   .open-left (general.js) flips it when it would leave the screen */
.main-menu .sub-menu .sub-menu {
    top: calc(-1 * var(--border-size)); /* first item level with its parent item */
    left: 100%;
    transform: translateX(6px);
}

.main-menu .sub-menu .sub-menu.open-left {
    left: auto;
    right: 100%;
    transform: translateX(-6px);
}

.main-menu .sub-menu li:hover > .sub-menu,
.main-menu .sub-menu li:focus-within > .sub-menu,
.main-menu .sub-menu li.is-open > .sub-menu {
    transform: translateX(0);
}

/* =========================================================
   MEGA MENU ("Θεραπευτικές Υπηρεσίες", built in theme-settings.php)
   One column per group, side by side; the therapeutic services
   column is split in two so the dropdown stays short.
========================================================= */

.main-menu > li.mega-menu > .sub-menu {
    display: flex;
    width: max-content;
    min-width: 0;
    max-width: calc(100vw - 48px);
}

.main-menu > li.mega-menu > .sub-menu > li {
    width: auto;
}

/* Columns are separated by a thin rule, like the items */
.main-menu > li.mega-menu > .sub-menu > li + li {
    border-top: 0;
    border-left: 1px solid rgba(26, 26, 26, 0.08);
}

/* Group heading: label on top of its column, no "+" */
.main-menu > li.mega-menu .mega-group > a::after {
    content: none;
}

/* The group's list is always shown inside the open dropdown (no third-level flyout) */
.main-menu > li.mega-menu .mega-group > .sub-menu {
    position: static;
    min-width: 0;
    max-width: none;
    width: 250px;

    background: transparent;
    border: 0;
    box-shadow: none;

    opacity: 1;
    visibility: inherit;
    transform: none;
}

.main-menu > li.mega-menu .mega-group-general > .sub-menu {
    width: 500px;
    column-count: 2;
    column-gap: 0;
}

.main-menu > li.mega-menu .mega-group > .sub-menu > li {
    break-inside: avoid;
    border-top: 0; /* no rules between items: in two columns they never line up */
}

/* =========================================================
   MENU ARROWS
========================================================= */

/* Items with a submenu are marked with "+" */
.main-menu .menu-item-has-children > a::after {
    content: "+";
    margin-left: 8px;
    font-size: 12px;
    line-height: 1;
}

/* Inside a dropdown the "+" sits at the right end of the item */
.main-menu .sub-menu .menu-item-has-children > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.main-menu .sub-menu .menu-item-has-children > a::after {
    margin-left: 0;
}

.main-menu .menu-item-has-children > a {
    cursor: pointer;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1440px) {

    .main-menu {
        gap: 24px;
    }

}

/* Same breakpoint as the hamburger (style.css, max-width: 1279px):
   desktop menu from 1280px up, hamburger below */
@media (max-width: 1279px) {

    .main-navigation {
        display: none;
    }

}
