/* =========================================================================
   K24 Mega Menu — Phase 3
   4-column editorial panel that opens beneath top-level navigation items
   mapped to a category. Pure CSS open/close via :hover / :focus-within /
   .is-open (legacy class set by navigation.js for click-toggle).
   ========================================================================= */

.k24-mega {
    --k24m-accent: var(--k24h-accent, #DC2626);
    --k24m-bg: #FFFFFF;
    --k24m-surface: #F9FAFB;
    --k24m-border: #E5E7EB;
    --k24m-border-strong: #D1D5DB;
    --k24m-ink: #111827;
    --k24m-muted: #6B7280;
    --k24m-radius: 6px;
    --k24m-radius-sm: 4px;

    position: absolute;
    inset-inline-start: 50%;
    /* Anchor flush to the bottom edge of the nav row — no visible gap. */
    top: 100%;
    transform: translate(-50%, 4px);
    width: min(1320px, calc(100vw - 24px));
    background: var(--k24m-bg);
    /* Editorial: thin top border that visually attaches to the nav,
       hairline sides + bottom; no rounded top so it reads as one surface. */
    border: 1px solid var(--k24m-border);
    border-top: 2px solid var(--k24m-accent);
    border-radius: 0 0 var(--k24m-radius) var(--k24m-radius);
    box-shadow: 0 12px 28px rgba(8, 22, 44, .08);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    z-index: 1300;
    overflow: hidden;
}

.k24-site-navigation {
    position: relative;
    overflow: visible;
}

.k24-menu--desktop-root > .k24-menu__item.menu-item-has-mega {
    position: static;
}

[dir="rtl"] .k24-mega {
    inset-inline-start: 50%;
}

/* Open state — quick fade + 4px lift for a connected feel (not a popup). */
.k24-menu__item.menu-item-has-mega:hover > .k24-mega,
.k24-menu__item.menu-item-has-mega:focus-within > .k24-mega,
.k24-menu__item.menu-item-has-mega.is-open > .k24-mega {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

/* The legacy "::before accent strip" is removed — the 2px top border IS
   the accent and reads as a continuation of the nav. */
.k24-mega::before { content: none; }

/* ----- Inner grid ------------------------------------------------------ */
.k24-mega__inner {
    display: grid;
    grid-template-columns: 1.7fr 1.1fr 1.1fr 1fr;
    gap: 20px;
    padding: 20px 20px 20px;
    max-height: min(70vh, 620px);
    overflow-x: hidden;
    overflow-y: auto;
}

/* Vertical column dividers for editorial density without extra borders */
.k24-mega__col + .k24-mega__col {
    padding-inline-start: 20px;
    border-inline-start: 1px solid var(--k24m-border);
}

@media (max-width: 1199.98px) {
    .k24-mega { width: min(1080px, calc(100vw - 24px)); }
    .k24-mega__inner { grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 20px; padding: 20px; }
}

@media (max-width: 991.98px) {
    .k24-mega { display: none; } /* mobile uses the drawer; mega is desktop-only */
}

/* ----- Column shared --------------------------------------------------- */
.k24-mega__col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.k24-mega__heading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'ItfHuwiyaArabic', var(--font-header, inherit), sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: var(--k24m-ink);
    letter-spacing: -.015em;
    text-transform: none;
    padding-bottom: 10px;
    margin-bottom: 4px;
    border-bottom: 2px solid var(--k24m-border-strong, #D1D5DB);
    position: relative;
}
.k24-mega__heading::after {
    /* Editorial accent under the section title (4 ch wide, brand red). */
    content: "";
    position: absolute;
    inset-inline-start: 0;
    bottom: -2px;
    width: 32px;
    height: 2px;
    background: var(--k24m-accent);
}

.k24-mega__heading .k24-icon {
    width: 18px;
    height: 18px;
    font-size: 18px !important;
    color: var(--k24m-accent);
}

.k24-mega__empty {
    color: var(--k24m-muted);
    font-size: 13px;
    padding: 12px 0;
}

/* ----- Column 1: Featured ---------------------------------------------- */
.k24-mega-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--k24m-ink);
    text-decoration: none;
    transition: transform .15s ease;
}

.k24-mega-card:hover { transform: translateY(-2px); }

.k24-mega-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: var(--k24m-radius-sm);
    background: var(--k24m-surface);
}

.k24-mega-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}

.k24-mega-card:hover .k24-mega-card__media img { transform: scale(1.04); }

.k24-mega-card__badge {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    background: var(--k24m-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1;
}

.k24-mega-card__title {
    margin: 0;
    font-family: 'ItfHuwiyaArabic', var(--font-header, inherit), sans-serif;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -.015em;
    color: var(--k24m-ink);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .15s ease;
}
.k24-mega-card:hover .k24-mega-card__title { color: var(--k24m-accent); }

.k24-mega-card__excerpt {
    margin: 0;
    color: var(--k24m-muted);
    font-size: 14px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.k24-mega-card__meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--k24m-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .01em;
}
.k24-mega-card__meta .k24-icon { font-size: 14px !important; width: 14px; height: 14px; }

/* ----- Column 2: Latest list ------------------------------------------- */
.k24-mega-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.k24-mega-list__item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--k24m-ink);
    text-decoration: none;
    padding: 6px;
    border-radius: var(--k24m-radius-sm);
    transition: background .15s ease;
}
.k24-mega-list__item:hover { background: var(--k24m-surface); }

.k24-mega-list__thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--k24m-surface);
}

.k24-mega-list__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.k24-mega-list__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.k24-mega-list__title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    color: var(--k24m-ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .15s ease;
}
.k24-mega-list__item:hover .k24-mega-list__title { color: var(--k24m-accent); }

.k24-mega-list__meta {
    font-size: 12px;
    font-weight: 500;
    color: var(--k24m-muted);
}

/* ----- Column 3: Trending ---------------------------------------------- */
.k24-mega-trending {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: nb-trend;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.k24-mega-trending__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 6px;
    border-radius: var(--k24m-radius-sm);
    color: var(--k24m-ink);
    text-decoration: none;
    transition: background .15s ease;
}
.k24-mega-trending__item:hover { background: var(--k24m-surface); }

.k24-mega-trending__rank {
    flex-shrink: 0;
    font-family: 'ItfHuwiyaArabic', var(--font-header, inherit), sans-serif;
    font-size: 24px;
    font-weight: 900;
    color: var(--k24m-accent);
    line-height: 1;
    width: 32px;
    text-align: center;
    opacity: 1;
    letter-spacing: -.04em;
}

.k24-mega-trending__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.k24-mega-trending__title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    color: var(--k24m-ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .15s ease;
}
.k24-mega-trending__item:hover .k24-mega-trending__title { color: var(--k24m-accent); }

.k24-mega-trending__meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--k24m-muted);
}
.k24-mega-trending__meta .k24-icon { font-size: 14px !important; width: 14px; height: 14px; }

/* ----- Column 4: Quick links ------------------------------------------- */
.k24-mega-quicklinks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}

.k24-mega-quicklinks__item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--k24m-radius-sm);
    color: var(--k24m-ink);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    border-inline-start: 2px solid transparent;
    transition: background .15s ease, color .15s ease, border-color .15s ease, padding .15s ease;
}
.k24-mega-quicklinks__item:hover {
    background: var(--k24m-surface);
    color: var(--k24m-accent);
    border-inline-start-color: var(--k24m-accent);
    padding-inline-start: 14px;
}
.k24-mega-quicklinks__item .k24-icon {
    color: var(--k24m-muted);
    font-size: 18px !important;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.k24-mega-quicklinks__item:hover .k24-icon { color: var(--k24m-accent); }

.k24-mega__view-all {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 12px 14px;
    border: 0;
    border-top: 1px solid var(--k24m-border);
    border-radius: 0;
    color: var(--k24m-accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: -.005em;
    text-transform: uppercase;
    transition: color .15s ease, background .15s ease;
}
.k24-mega__view-all:hover {
    background: var(--k24m-surface);
    color: #B91C1C;
}
.k24-mega__view-all .k24-icon {
    font-size: 16px !important;
    width: 16px;
    height: 16px;
    transition: transform .15s ease;
}
.k24-mega__view-all:hover .k24-icon { transform: translateX(3px); }
[dir="rtl"] .k24-mega__view-all:hover .k24-icon { transform: translateX(-3px); }

/* ----- Mega + sticky compatibility ------------------------------------- */
.main-header .header-bottom.header-sticky.sticky-bar .k24-mega {
    box-shadow: 0 18px 40px rgba(8, 22, 44, .12);
}

/* ----- Suppress the legacy chevron rotate dimming below mega items ----- */
.k24-menu__item.menu-item-has-mega > .k24-menu__item-row .k24-menu__toggle {
    /* Let the ::after underline handle the active state — no extra background */
}

/* ----- Print: hide mega menu ------------------------------------------- */
@media print {
    .k24-mega { display: none !important; }
}
