/* ============================================================
   MEGA MENU „Kursy" — taco2
   Kolorystyka strony: złoto (#d2ac67/#916838/#be883a/#a0752f),
   grafit/granat (#22272f/#3f434e/#454d5f), Mulish.
   Treść budowana z lokalizacji menu „menu-kursy".
   ============================================================ */

.mega-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 900;
    display: flex;
    justify-content: center;
    padding: 0 15px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity .28s cubic-bezier(.22,.61,.36,1),
                transform .28s cubic-bezier(.22,.61,.36,1),
                visibility 0s .28s;
}

.mega-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity .28s cubic-bezier(.22,.61,.36,1),
                transform .28s cubic-bezier(.22,.61,.36,1),
                visibility 0s 0s;
}

/* „Mostek" hover — przedłuża obszar najechania w górę, w lukę między
   pozycją „Kursy" a panelem, żeby kursor jej nie gubił (brak migania). */
.mega-menu.open::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 26px;
}

.mega-menu__inner {
    width: 100%;
    max-width: 1170px;
    margin-top: 0;
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 0;
    box-shadow: 0 24px 60px -20px rgba(34,39,47,.28),
                0 8px 20px -12px rgba(34,39,47,.18);
    display: grid;
    grid-template-columns: 300px 1fr;
    overflow: hidden;
}

/* ---------- Szyna kategorii (rail) ---------- */
.mega-menu__rail {
    background: #f9f9f9;
    border-right: 1px solid #e3e3e3;
    padding: 10px 14px;
    max-height: 70vh;
    overflow-y: auto;
}

.mega-menu__group + .mega-menu__group {
    margin-top: 14px;
}

.mega-menu__group-title {
    margin: 0 0 4px;
    padding: 6px 12px 0;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #916838;
}

.mega-menu__cats {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mega-menu__cats li {
    margin: 1px 0;
}

.mega-menu__cat {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    border: 0;
    border-radius: 0;
    background: none;
    cursor: pointer;
    font-family: inherit;
    color: #3f434e;
    text-align: left;
    position: relative;
    line-height: 1.25;
    transition: background .18s ease, color .18s ease;
}

.mega-menu__cat-name {
    font-size: 14px;
    font-weight: 600;
    display: block;
}

.mega-menu__cat-count {
    font-size: 11.5px;
    font-weight: 400;
    color: #8a8f9a;
    display: block;
    margin-top: 1px;
}

.mega-menu__cat-arrow {
    flex: 0 0 auto;
    opacity: 0;
    transform: translateX(-4px);
    color: #d2ac67;
    transition: opacity .18s ease, transform .18s ease;
}

.mega-menu__cat:hover {
    background: #fff;
    color: #a0752f;
}

.mega-menu__cat.active {
    background: #fff;
    color: #22272f;
    box-shadow: 0 2px 10px -6px rgba(34,39,47,.25);
}

.mega-menu__cat.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0;
    background: #d2ac67;
}

.mega-menu__cat.active .mega-menu__cat-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ---------- Panel treści ---------- */
.mega-menu__content {
    position: relative;
    padding: 28px 32px 30px;
    min-height: 380px;
}

.mega-menu__panel {
    display: none;
}

.mega-menu__panel.active {
    display: block;
    animation: megaFade .25s ease;
}

@keyframes megaFade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mega-menu__eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #d2ac67;
}

.mega-menu__title {
    font-size: 26px;
    line-height: 1.1;
    font-weight: 700;
    margin: 6px 0 8px;
    color: #22272f;
}

.mega-menu__title a {
    color: inherit;
    text-decoration: none;
    transition: color .16s ease;
}

.mega-menu__title a:hover {
    color: #a0752f;
}

.mega-menu__lead {
    margin: 0 0 20px;
    color: #5c6378;
    font-size: 14.5px;
    line-height: 1.5;
    max-width: 52ch;
}

/* Lista kursów */
.mega-menu__courses {
    columns: 2;
    column-gap: 34px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mega-menu__courses li {
    break-inside: avoid;
    margin: 0 0 2px;
}

.mega-menu__courses a {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-decoration: none;
    color: #454d5f;
    padding: 8px 6px 8px 0;
    border-radius: 0;
    transition: color .16s ease, transform .16s ease;
}

.mega-menu__courses a::before {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d4b778;
    margin-top: 7px;
    transition: background .16s ease, transform .16s ease;
}

.mega-menu__courses a span {
    font-size: 14px;
    line-height: 1.35;
}

.mega-menu__courses a:hover {
    color: #a0752f;
    transform: translateX(3px);
}

.mega-menu__courses a:hover::before {
    background: #d2ac67;
    transform: scale(1.4);
}

/* Widok „solo" (kategoria bez podstron) */
.mega-menu__solo {
    max-width: 56ch;
}

.mega-menu__solo p {
    color: #5c6378;
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 22px;
}

.mega-menu__btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: #d2ac67;
    color: #22272f;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    transition: background .2s ease, transform .2s ease, gap .2s ease;
}

.mega-menu__btn:hover {
    background: #be883a;
    color: #fff;
    transform: translateY(-1px);
    gap: 13px;
}

.mega-menu__btn svg {
    width: 15px;
    height: 15px;
}

/* Scrim pod panelem — przyciemnia stronę, ale NIE nagłówek.
   z-index:-1 chowa go za białym tłem #header (nagłówek zostaje ostry),
   pointer-events:none, by nie przechwytywał kursora znad „Kursy"
   (to powodowało miganie mega menu). */
.mega-scrim {
    position: fixed;
    inset: 0;
    background: rgba(34,39,47,.18);
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility 0s .28s;
    z-index: -1;
    pointer-events: none;
}

.mega-scrim.open {
    opacity: 1;
    visibility: visible;
    transition: opacity .28s ease, visibility 0s 0s;
}

/* ---------- DESKTOP (≥992px) ---------- */
@media (min-width: 992px) {
    /* Chowamy domyślny dropdown „Kursy" (zastępuje go mega) i akordeon mobilny */
    #nav li.has-mega > .sub-menu {
        display: none !important;
    }
    .kursy-mobile {
        display: none !important;
    }
}

/* ---------- MOBILE (≤991px) ---------- */
@media (max-width: 991px) {
    /* mega desktopowe wyłączone */
    .mega-menu,
    .mega-scrim {
        display: none !important;
    }

    /* natywne podmenu „Kursy" chowamy — zastępuje je akordeon menu-kursy */
    #nav li.has-mega > .sub-menu {
        display: none !important;
    }

    /* neutralizacja quirkowej strzałki motywu dla „Kursy" na mobile */
    #menu-menu-glowne li.has-mega.menu-item-has-children::after {
        display: none !important;
    }

    /* własny wskaźnik rozwijania przy „Kursy" */
    #nav li.has-mega > a {
        position: relative;
    }
    #nav li.has-mega > a::after {
        content: "";
        display: inline-block;
        width: 9px;
        height: 9px;
        margin-left: 12px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        transition: transform .25s ease;
        vertical-align: 3px;
    }
    #nav li.has-mega.mobile-open > a::after {
        transform: rotate(-135deg);
        vertical-align: -1px;
    }

    /* Akordeon kategorii — nadpisujemy flex/gap motywu (#nav ul, #nav ul li) */
    #nav .kursy-mobile,
    #nav .kursy-mobile li {
        display: block !important;
        flex-direction: initial !important;
        gap: 0 !important;
        margin: 0;
        padding: 0;
        list-style: none;
        float: none !important;
        width: auto !important;
    }
    #nav .kursy-mobile {
        margin: 4px 0 8px !important;
    }
    /* Domyślnie zwinięte — cała lista kategorii chowa się do czasu stuknięcia „Kursy" */
    #nav li.has-mega > .kursy-mobile {
        display: none !important;
    }
    #nav li.has-mega.mobile-open > .kursy-mobile {
        display: block !important;
    }
    .kursy-mobile__cat {
        border-top: 1px solid #efe6e4;
    }
    .kursy-mobile__toggle,
    .kursy-mobile__cat--link > a {
        display: block !important;
        width: 100%;
        text-align: left;
        background: none;
        border: 0;
        cursor: pointer;
        font: inherit;
        font-size: 15px !important;
        font-weight: 600;
        color: #454d5f !important;
        padding: 12px 8px 12px 24px !important;
        position: relative;
    }
    .kursy-mobile__toggle::after {
        content: "";
        position: absolute;
        right: 14px;
        top: 50%;
        width: 7px;
        height: 7px;
        border-right: 2px solid #b08d57;
        border-bottom: 2px solid #b08d57;
        transform: translateY(-70%) rotate(45deg);
        transition: transform .25s ease;
    }
    .kursy-mobile__cat.open .kursy-mobile__toggle {
        color: #a0752f !important;
    }
    .kursy-mobile__cat.open .kursy-mobile__toggle::after {
        transform: translateY(-30%) rotate(-135deg);
    }
    #nav .kursy-mobile .kursy-mobile__courses {
        padding: 0 0 8px !important;
        gap: 0 !important;
        display: none !important;
    }
    #nav .kursy-mobile__cat.open .kursy-mobile__courses {
        display: block !important;
    }
    .kursy-mobile__courses li a {
        display: block !important;
        font-size: 14px !important;
        font-weight: 400;
        color: #5c6378 !important;
        padding: 8px 8px 8px 40px !important;
        line-height: 1.35;
    }
    .kursy-mobile__courses li a:active,
    .kursy-mobile__courses li a:hover {
        color: #a0752f !important;
    }
    .kursy-mobile__all {
        font-weight: 600 !important;
        color: #916838 !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mega-menu,
    .mega-menu__panel.active,
    .mega-menu__btn,
    .mega-menu__courses a,
    .mega-scrim {
        transition: none !important;
        animation: none !important;
    }
}
