/*
 * Konza Villas — Mega Menu + Responsive System
 * Loaded globally (enqueued after style.css)
 *
 * Sections:
 *  1. CSS Reset / Box Model
 *  2. Responsive Typography (fluid scale)
 *  3. Header + Nav baseline
 *  4. Standard Dropdown
 *  5. Mega Menu Panel (3 layouts: villas, dining, experiences)
 *  6. Mega Menu Cards
 *  7. Mobile / Tablet Nav Overrides
 *  8. Responsive Utilities
 *  9. Accessibility Focus Styles
 * 10. Print
 */

/* ================================================================
   1. RESET & BOX MODEL
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; }
img, video, svg { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
a { color: inherit; }

/* ================================================================
   2. FLUID TYPOGRAPHY
   ================================================================ */
:root {
    --text-fluid-hero:    clamp(2.25rem, 5.5vw, 5rem);
    --text-fluid-h2:      clamp(1.75rem, 3.5vw, 3rem);
    --text-fluid-h3:      clamp(1.25rem, 2.5vw, 1.875rem);
    --text-fluid-body:    clamp(0.9375rem, 1.2vw, 1.0625rem);
    --container-max:      1320px;
    --container-pad:      clamp(1rem, 4vw, 3rem);
    --header-h:           80px;
}
html { font-size: 16px; scroll-behavior: smooth; }
body { font-size: var(--text-fluid-body); line-height: 1.75; -webkit-font-smoothing: antialiased; }
h1 { font-size: var(--text-fluid-hero); }
h2 { font-size: var(--text-fluid-h2); }
h3 { font-size: var(--text-fluid-h3); }

/* Accessible focus for reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ================================================================
   3. HEADER — RESPONSIVE
   ================================================================ */
#kv-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    z-index: 1000;
    transition: background 0.35s ease, box-shadow 0.35s ease, height 0.35s ease;
}
#kv-header.is-scrolled {
    height: 68px;
    background: var(--kv-ebony) !important;
    box-shadow: 0 2px 24px rgba(0,0,0,.35);
}
.kv-header-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-pad);
    height: 100%;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.kv-logo { flex-shrink: 0; }
.kv-logo img, .kv-logo svg { height: 46px; width: auto; }
#kv-header.is-scrolled .kv-logo img { height: 38px; }

/* ================================================================
   4. PRIMARY NAV — DESKTOP
   ================================================================ */
.kv-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}
.kv-nav-primary {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0;
}

/* Top-level link */
.kv-nav-link--top {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: rgba(245,240,232,0.82);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.25s;
    position: relative;
}
.kv-nav-link--top::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0.875rem;
    right: 0.875rem;
    height: 1px;
    background: var(--kv-gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}
.kv-menu-item--mega:hover > .kv-nav-link--top,
.kv-menu-item--has-children:hover > .kv-nav-link--top,
.kv-menu-item.is-current > .kv-nav-link--top,
.kv-nav-link--top:hover,
.kv-nav-link--top:focus-visible {
    color: var(--kv-ivory);
}
.kv-menu-item.is-current > .kv-nav-link--top::after,
.kv-menu-item--mega.is-open > .kv-nav-link--top::after,
.kv-menu-item--has-children.is-open > .kv-nav-link--top::after {
    transform: scaleX(1);
}

/* Chevron rotation */
.kv-nav-chevron { display: inline-flex; transition: transform 0.25s; }
.kv-menu-item.is-open > .kv-nav-link--top .kv-nav-chevron { transform: rotate(180deg); }

/* ================================================================
   4a. STANDARD DROPDOWN
   ================================================================ */
.kv-menu-item--has-children { position: relative; }
.kv-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: var(--kv-ebony);
    border-top: 2px solid var(--kv-gold);
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    box-shadow: 0 16px 40px rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.kv-dropdown[hidden] { display: block; opacity: 0; pointer-events: none; transform: translateY(-8px); }
.kv-menu-item--has-children.is-open > .kv-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    display: block !important;
}
.kv-nav-link--sub {
    display: block;
    padding: 0.6rem 1.25rem;
    font-size: 0.8125rem;
    color: rgba(245,240,232,0.7);
    text-decoration: none;
    transition: color 0.2s, background 0.2s, padding-left 0.2s;
    white-space: nowrap;
    letter-spacing: 0.04em;
}
.kv-nav-link--sub:hover,
.kv-nav-link--sub:focus-visible {
    color: var(--kv-gold);
    background: rgba(184,154,94,0.08);
    padding-left: 1.5rem;
}

/* ================================================================
   5. MEGA MENU PANEL
   ================================================================ */
.kv-menu-item--mega { position: static; }
.kv-mega-panel {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--kv-ebony);
    border-top: 2px solid var(--kv-gold);
    z-index: 500;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
}
.kv-mega-panel[hidden] {
    display: block;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px);
}
.kv-menu-item--mega.is-open > .kv-mega-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    display: block !important;
}
#kv-header.is-scrolled ~ * .kv-mega-panel,
#kv-header.is-scrolled .kv-mega-panel {
    top: 68px;
}

.kv-mega-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 2.5rem var(--container-pad);
    display: flex;
    gap: 2.5rem;
}

/* ================================================================
   5a. MEGA COLUMNS
   ================================================================ */
.kv-mega-col { flex: 1; min-width: 0; }
.kv-mega-col--info { flex: 0 0 240px; }
.kv-mega-col--cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    flex: 2;
}
.kv-mega-col--restaurants {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 2;
}
.kv-mega-col--list {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1.5;
    border-left: 1px solid rgba(245,240,232,0.08);
    padding-left: 2rem;
}

/* Info column content */
.kv-mega-heading {
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 300;
    color: var(--kv-ivory);
    margin: 0 0 0.75rem;
    line-height: 1.3;
}
.kv-mega-desc {
    font-size: 0.8125rem;
    color: rgba(245,240,232,0.55);
    line-height: 1.65;
    margin-bottom: 1.25rem;
}
.kv-mega-cta {
    display: inline-block;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--kv-gold);
    text-decoration: none;
    border-bottom: 1px solid rgba(184,154,94,0.35);
    padding-bottom: 2px;
    transition: border-color 0.25s, color 0.25s;
    margin-bottom: 1.5rem;
}
.kv-mega-cta:hover { color: var(--kv-gold-light); border-color: var(--kv-gold-light); }
.kv-mega-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.kv-mega-tag {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border: 1px solid rgba(184,154,94,0.3);
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(245,240,232,0.55);
    text-decoration: none;
    transition: all 0.2s;
}
.kv-mega-tag:hover { border-color: var(--kv-gold); color: var(--kv-gold); }

/* ================================================================
   6. MEGA MENU CARDS
   ================================================================ */
.kv-mega-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    overflow: hidden;
    flex: 0 0 calc(33.333% - 0.667rem);
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(245,240,232,0.08);
    transition: border-color 0.25s, transform 0.25s;
}
.kv-mega-card:hover { border-color: var(--kv-gold); transform: translateY(-3px); }

/* Dining uses row layout */
.kv-mega-col--restaurants .kv-mega-card {
    flex-direction: row;
    align-items: center;
    gap: 0.875rem;
    padding: 0.5rem;
    flex: none;
}

.kv-mega-card__img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    flex-shrink: 0;
}
.kv-mega-col--restaurants .kv-mega-card__img {
    width: 72px;
    height: 72px;
}

.kv-mega-card__body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}
.kv-mega-col--restaurants .kv-mega-card__body { padding: 0; }

.kv-mega-card__title {
    font-size: 0.875rem;
    color: var(--kv-ivory);
    font-weight: 500;
    line-height: 1.3;
}
.kv-mega-card__meta,
.kv-mega-card__hours {
    font-size: 0.6875rem;
    color: rgba(245,240,232,0.45);
    letter-spacing: 0.04em;
}
.kv-mega-card__meta { color: var(--kv-gold-light); }

/* List items for experiences */
.kv-mega-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(245,240,232,0.07);
    text-decoration: none;
    transition: padding-left 0.2s;
}
.kv-mega-list-item:hover { padding-left: 0.5rem; }
.kv-mega-list-item:last-child { border-bottom: none; }
.kv-mega-list-title { font-size: 0.9375rem; color: var(--kv-ivory); }
.kv-mega-list-cat {
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--kv-gold);
}

/* ================================================================
   7. MOBILE / TABLET RESPONSIVE
   ================================================================ */

/* ── 1280px and below: tighten desktop nav ── */
@media (max-width: 1280px) {
    .kv-nav-link--top { padding: 0.5rem 0.6rem; font-size: 0.75rem; }
    .kv-mega-col--info { flex: 0 0 200px; }
    .kv-mega-card { flex: 0 0 calc(50% - 0.5rem); }
}

/* ── 1024px: switch to mobile nav ── */
@media (max-width: 1024px) {

    :root { --header-h: 68px; }

    /* Hide desktop nav */
    .kv-nav { display: none; }

    /* Show hamburger */
    .kv-hamburger { display: flex !important; }

    /* Header actions: hide phone on small screens */
    .kv-header-phone { display: none; }

    /* Mobile drawer — full revamp */
    #kv-mobile-nav {
        position: fixed;
        inset: 0;
        top: var(--header-h);
        background: var(--kv-ebony);
        z-index: 900;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.38s cubic-bezier(0.25,0.46,0.45,0.94);
        padding: 1.5rem var(--container-pad) 4rem;
        -webkit-overflow-scrolling: touch;
    }
    #kv-mobile-nav.is-open {
        transform: translateX(0);
    }

    /* Mobile nav list */
    .kv-mobile-nav-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    .kv-mobile-nav-list .menu-item {
        border-bottom: 1px solid rgba(245,240,232,0.07);
    }
    .kv-mobile-nav-list .menu-item > a {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 0;
        font-size: 1.0625rem;
        color: rgba(245,240,232,0.85);
        text-decoration: none;
        letter-spacing: 0.04em;
        transition: color 0.2s;
    }
    .kv-mobile-nav-list .menu-item > a:hover { color: var(--kv-gold); }
    .kv-mobile-nav-list .menu-item.current-menu-item > a { color: var(--kv-gold); }

    /* Accordion toggle */
    .kv-mobile-nav-list .menu-item-has-children > a::after {
        content: '﹢';
        font-size: 1.25rem;
        color: var(--kv-gold);
        transition: transform 0.25s;
        flex-shrink: 0;
    }
    .kv-mobile-nav-list .menu-item-has-children.is-open > a::after {
        content: '﹣';
    }

    /* Sub-menu accordion */
    .kv-mobile-nav-list .sub-menu {
        list-style: none;
        padding: 0 0 0.5rem 1rem;
        margin: 0;
        display: none;
    }
    .kv-mobile-nav-list .menu-item-has-children.is-open > .sub-menu {
        display: block;
    }
    .kv-mobile-nav-list .sub-menu .menu-item > a {
        font-size: 0.9375rem;
        padding: 0.6rem 0;
        color: rgba(245,240,232,0.6);
    }
    .kv-mobile-nav-list .sub-menu .menu-item > a:hover { color: var(--kv-gold); }

    /* Mega panel on mobile: collapse to simple list */
    .kv-mega-panel {
        position: static !important;
        opacity: 1 !important;
        transform: none !important;
        border: none;
        box-shadow: none;
        background: transparent;
        max-height: none;
        pointer-events: all;
        display: none;
    }
    .kv-menu-item--mega.is-open > .kv-mega-panel {
        display: block !important;
    }
    .kv-mega-inner { flex-direction: column; padding: 0; gap: 0; }
    .kv-mega-col { flex: none; width: 100%; }
    .kv-mega-col--info { padding-bottom: 1rem; }
    .kv-mega-col--cards,
    .kv-mega-col--restaurants { flex-direction: column; gap: 0.5rem; }
    .kv-mega-card {
        flex: none;
        flex-direction: row;
        padding: 0.5rem;
        gap: 0.75rem;
    }
    .kv-mega-card__img { width: 64px; height: 64px; }
    .kv-mega-col--list { border: none; padding: 0; }
    .kv-mega-heading { font-size: 1.1rem; margin-bottom: 0.5rem; }
    .kv-mega-desc { display: none; }
}

/* ── 768px: full tablet / large phone ── */
@media (max-width: 768px) {
    /* Container */
    .kv-container, .kv-container--narrow { padding-left: var(--container-pad); padding-right: var(--container-pad); }

    /* Section padding */
    .kv-section { padding-top: 3.5rem; padding-bottom: 3.5rem; }

    /* Villa grid: single column */
    .kv-villas-grid { grid-template-columns: 1fr !important; }
    .kv-villa-card--featured { grid-column: 1; }

    /* Experiences: 2 col */
    .kv-experiences-grid { grid-template-columns: 1fr 1fr !important; }

    /* Dining layout: stack */
    .kv-dining-layout { grid-template-columns: 1fr !important; }
    .kv-dining-media { min-height: 320px; }

    /* Wellness strip */
    .kv-wellness-strip { grid-template-columns: 1fr !important; }
    .kv-wellness-media { min-height: 260px; }

    /* About stats: 2x2 */
    .kv-section .kv-container > [style*="repeat(4,1fr)"] { grid-template-columns: repeat(2,1fr) !important; }

    /* Single villa grid */
    .kv-container[style*="grid-template-columns:1fr 380px"],
    .kv-container[style*="grid-template-columns:1fr 320px"],
    .kv-container[style*="grid-template-columns:1fr 340px"],
    .kv-container[style*="grid-template-columns:1fr 400px"] {
        grid-template-columns: 1fr !important;
    }

    /* Single.php blog sidebar */
    .kv-container[style*="grid-template-columns:1fr 320px"] { grid-template-columns: 1fr !important; }

    /* Blog grid: 1 col */
    .kv-blog-grid { grid-template-columns: 1fr !important; }

    /* Offers: 1 col */
    .kv-offers-grid { grid-template-columns: 1fr !important; }

    /* Footer: 2 col */
    .kv-footer-grid { grid-template-columns: 1fr 1fr !important; }

    /* Gallery mosaic: 2 col */
    .kv-gallery-mosaic { grid-template-columns: 1fr 1fr !important; }

    /* Hero actions: stack */
    .kv-hero__actions { flex-direction: column; align-items: flex-start; }

    /* Hide desktop header phone */
    .kv-header-phone { display: none; }

    /* Single villa / restaurant -- stack sidebar */
    aside.kv-sidebar { order: -1; }
}

/* ── 480px: small phones ── */
@media (max-width: 480px) {
    :root { --container-pad: 1rem; }

    /* Experiences: 1 col */
    .kv-experiences-grid { grid-template-columns: 1fr !important; }

    /* Section headings: tighter */
    h1, h2 { word-break: break-word; }

    /* Footer: 1 col */
    .kv-footer-grid { grid-template-columns: 1fr !important; }

    /* Gallery: 1 col */
    .kv-gallery-mosaic { grid-template-columns: 1fr !important; }

    /* Events grid */
    .kv-section [style*="repeat(3,1fr)"] { grid-template-columns: 1fr !important; }
    .kv-section [style*="repeat(4,1fr)"] { grid-template-columns: 1fr 1fr !important; }

    /* Dining feature: stack */
    .kv-dining-feature { grid-template-columns: 1fr !important; direction: ltr !important; }

    /* Values: 1 col */
    .kv-section [style*="repeat(4,1fr)"] { grid-template-columns: 1fr 1fr !important; }

    /* Full-bleed buttons */
    .kv-hero__actions .kv-btn { width: 100%; text-align: center; justify-content: center; }

    /* Book bar: full width */
    .kv-bookbar__form { flex-direction: column; }
    .kv-bookbar__field { width: 100%; }
    .kv-bookbar__cta { width: 100%; text-align: center; }
}

/* ================================================================
   8. RESPONSIVE UTILITIES
   ================================================================ */

/* Fluid container */
.kv-container {
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--container-pad);
    padding-right: var(--container-pad);
}
.kv-container--narrow { max-width: 760px; }

/* Show/hide helpers */
.kv-hide-mobile { display: block; }
.kv-show-mobile { display: none; }
@media (max-width: 768px) {
    .kv-hide-mobile { display: none !important; }
    .kv-show-mobile { display: block !important; }
}

/* Overflow-x safe */
body { overflow-x: hidden; }
section, article { max-width: 100%; overflow: hidden; }

/* Images never overflow their container */
img { max-width: 100%; height: auto; }

/* Grid baseline — override inline grid styles for responsive */
@media (max-width: 768px) {
    [class*="kv-form-grid"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
    .kv-form-grid-2 { grid-template-columns: 1fr !important; }
}

/* ================================================================
   9. ACCESSIBILITY — FOCUS STYLES
   Visible, high-contrast, non-outline-removing
   ================================================================ */
:focus-visible {
    outline: 2px solid var(--kv-gold);
    outline-offset: 3px;
    border-radius: 2px;
}
/* Remove outline for mouse users */
:focus:not(:focus-visible) { outline: none; }

/* Skip link */
.skip-link.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.skip-link.visually-hidden:focus {
    width: auto; height: auto;
    padding: 0.5rem 1rem;
    clip: auto;
    white-space: normal;
    background: var(--kv-gold);
    color: var(--kv-ebony);
    top: 0; left: 0; z-index: 9999;
    font-size: 0.875rem;
    font-weight: 700;
}

/* Ensure interactive elements have min tap target */
button, a, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
}
.kv-nav-link--top, .kv-nav-link--sub, .kv-mega-cta, .kv-mega-tag,
.kv-mega-card, .kv-mega-list-item, .kv-hero__dot, .kv-rooms-dot,
.kv-testimonial-dot, .kv-hero__arrow, .kv-rooms__arrow,
.kv-testimonial-arrow, .kv-video-toggle {
    min-height: 44px;
}

/* ================================================================
   10. PRINT
   ================================================================ */
@media print {
    #kv-header, #kv-mobile-nav, .kv-mega-panel, .kv-dropdown,
    .kv-bookbar, .kv-bmodal, .kv-book-overlay, .kv-book-table-trigger,
    .kv-hero__arrow, .kv-hero__dots, .kv-rooms__arrow, .kv-rooms-dots,
    .kv-testimonial-dots, .kv-testimonial-arrow, .kv-video-toggle,
    .kv-hamburger { display: none !important; }

    body { font-size: 12pt; color: #000; background: #fff; }
    a { color: #000; text-decoration: underline; }
    h1, h2, h3 { page-break-after: avoid; }
    img { max-width: 100%; page-break-inside: avoid; }
    .kv-section { padding: 1.5rem 0; }
}

/* ================================================================
   11. MOBILE NAV ACCORDION JS HOOK
   (JS is in main.js; these classes are toggled by it)
   ================================================================ */
#kv-mobile-nav .menu-item-has-children > a {
    cursor: pointer;
    user-select: none;
}
