/* ==========================================================================
   TAYRA TOURS — RESPONSIVE MEGA MENU
   Desktop: parent items with children open a wide multi-column mega panel.
   Mobile: hamburger toggles a slide-in drawer with accordion sub-menus.
   Driven by the WordPress "primary" menu (add sub-items in Appearance → Menus).
   Works for both the home header (.tayra-menu-list) and the inner header
   (.tayra-tabs-menu).
   ========================================================================== */

/* Hamburger toggle — hidden on desktop, shown on mobile. */
.tayra-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.2s ease;
}
.tayra-nav-toggle:hover { background: rgba(127, 127, 127, 0.12); }
.tayra-nav-toggle svg { width: 26px; height: 26px; }

/* ==========================================================================
   DESKTOP MEGA MENU  (>= 993px)
   ========================================================================== */
@media (min-width: 993px) {

  .tayra-menu-list,
  .tayra-tabs-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .tayra-menu-list > .menu-item,
  .tayra-tabs-menu > .menu-item { position: relative; }

  /* Caret indicator for parents */
  .tayra-menu-list > .menu-item-has-children > a,
  .tayra-tabs-menu > .menu-item-has-children > a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
  }
  .tayra-menu-list > .menu-item-has-children > a::after,
  .tayra-tabs-menu > .menu-item-has-children > a::after {
    content: "";
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 8px;
    height: 8px;
    border: 0 solid currentColor;
    border-right-width: 2px;
    border-bottom-width: 2px;
    border-radius: 1px;
    transform: translateY(-2px) rotate(45deg);
    transform-origin: center;
    transition: transform 0.25s ease;
    opacity: 0.75;
  }
  /* Hide any hardcoded SVG chevrons in parent links to prevent duplicate carets */
  .tayra-menu-list > .menu-item-has-children > a > svg,
  .tayra-tabs-menu > .menu-item-has-children > a > svg {
    display: none !important;
  }
  .tayra-menu-list > .menu-item-has-children:hover > a::after,
  .tayra-menu-list > .menu-item-has-children:focus-within > a::after,
  .tayra-menu-list > .menu-item-has-children.is-mega-open > a::after,
  .tayra-tabs-menu > .menu-item-has-children:hover > a::after,
  .tayra-tabs-menu > .menu-item-has-children:focus-within > a::after,
  .tayra-tabs-menu > .menu-item-has-children.is-mega-open > a::after {
    transform: translateY(1px) rotate(225deg);
  }

  /* ---- The mega panel (a level-1 item's direct sub-menu) ---- */
  .tayra-menu-list .sub-menu,
  .tayra-tabs-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    list-style: none;
    margin: 0;
    background: var(--tayra-color-surface, #fff);
    border: 1px solid var(--tayra-color-border, #DCE8DD);
    border-radius: 16px;
    box-shadow: 0 24px 55px rgba(11, 27, 18, 0.18);
    padding: 1.6rem 1.75rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    z-index: 300;
  }

  /* Level-1 panel: wide auto-column grid, centred on its trigger item so it
     never spills off the viewport edge. */
  .tayra-menu-list > .menu-item > .sub-menu,
  .tayra-tabs-menu > .menu-item > .sub-menu {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(12px);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    gap: 0.4rem 1.75rem;
    box-sizing: border-box;
    width: min(960px, 94vw);
    margin-top: 0.5rem;
    padding: 1.9rem 2.1rem;
  }

  /* Reveal on hover / keyboard focus / JS class */
  .tayra-menu-list > .menu-item-has-children:hover > .sub-menu,
  .tayra-menu-list > .menu-item-has-children:focus-within > .sub-menu,
  .tayra-tabs-menu > .menu-item-has-children:hover > .sub-menu,
  .tayra-tabs-menu > .menu-item-has-children:focus-within > .sub-menu,
  .menu-item-has-children.is-mega-open > .sub-menu {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(-50%) translateY(0) !important;
  }

  /* Level-3 static columns must stay visible inside the open panel. */
  .sub-menu .sub-menu {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
  }

  /* Bridge the gap between item and panel so hover doesn't drop */
  .tayra-menu-list > .menu-item-has-children::before,
  .tayra-tabs-menu > .menu-item-has-children::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.75rem;
  }

  /* Level-2 links (column entries / column headings) */
  .sub-menu .menu-item { margin: 0; }
  .tayra-menu-list .sub-menu a,
  .tayra-tabs-menu .sub-menu a {
    display: block;
    padding: 0.5rem 0.6rem;
    border-radius: 9px;
    color: var(--tayra-color-heading, #143321);
    font-family: var(--tayra-font-body, sans-serif);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.35;
    /* Long tour names must wrap inside their column, never overflow into the
       next one (app.css sets nowrap on these, so override with !important). */
    white-space: normal !important;
    overflow-wrap: anywhere;
    transition: background 0.18s ease, color 0.18s ease;
  }
  .sub-menu a:hover { background: var(--tayra-color-surface-alt, #F1F5F2); color: var(--tayra-color-primary, #0B7A3E); }

  /* A level-2 item that itself has children becomes a column with a heading */
  .sub-menu .menu-item-has-children > a {
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tayra-color-primary, #0B7A3E);
    padding-left: 0.6rem;
    margin-bottom: 0.25rem;
    pointer-events: none; /* heading only */
  }
  .sub-menu .menu-item-has-children > a::after { display: none; }

  /* Level-3 sub-menu rendered statically inside its column */
  .sub-menu .sub-menu {
    position: static;
    display: block;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    max-width: none;
    border-radius: 0;
  }
  .sub-menu .sub-menu a { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 0.88rem; color: var(--tayra-color-body, #455A4A); }
  .sub-menu .sub-menu a:hover { color: var(--tayra-color-primary, #0B7A3E); }

  /* ====================================================================
     TWO-PANE MEGA PANEL: left categories + right grid + bottom CTA
     Reflects the modern Mercury/Stripe style layout with active arrow pointer.
     ==================================================================== */
  .sub-menu.mega-2pane {
    display: block !important;
    width: min(940px, 95vw) !important;
    max-width: 960px !important;
    padding: 0 !important;
    border-radius: 20px !important;
    background: #FFFFFF !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 24px 60px -12px rgba(11, 27, 18, 0.18), 0 0 1px 1px rgba(0, 0, 0, 0.04) !important;
    overflow: hidden !important;
  }

  .mega-inner {
    display: flex;
    align-items: stretch;
    min-height: 400px;
  }

  /* Left rail: category list with icon + title + description + active arrow */
  .mega-left {
    flex: 0 0 285px;
    display: flex;
    flex-direction: column;
    padding: 1.4rem 1rem;
    background: #F8FAFB;
    border-right: 1px solid #EAEFF2;
    box-sizing: border-box;
  }
  .mega-eyebrow-left {
    font-family: var(--tayra-font-heading, sans-serif);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748B;
    margin: 0 0 0.85rem 0.5rem;
  }
  .mega-cat-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .mega-cat {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: none;
    border-radius: 14px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  }
  .mega-cat:hover {
    background: rgba(255, 255, 255, 0.7);
  }
  .mega-cat.is-active {
    background: #FFFFFF;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  }

  /* Right-pointing arrow indicator on active category (matches reference design) */
  .mega-cat.is-active::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 8px solid #FFFFFF;
    z-index: 10;
    filter: drop-shadow(2px 0 1px rgba(0, 0, 0, 0.04));
  }

  .mega-cat-icon {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(11, 122, 62, 0.08);
    color: var(--tayra-color-primary, #0B7A3E);
    transition: transform 0.2s ease;
  }
  .mega-cat:hover .mega-cat-icon,
  .mega-cat.is-active .mega-cat-icon {
    transform: scale(1.06);
  }
  .mega-cat-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
  }

  /* Category color accents */
  .mega-cat--tradicional .mega-cat-icon {
    background: rgba(2, 132, 199, 0.1);
    color: #0284C7;
  }
  .mega-cat--hiking .mega-cat-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
  }
  .mega-cat--atv .mega-cat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
  }
  .mega-cat--adventure .mega-cat-icon {
    background: rgba(139, 92, 246, 0.1);
    color: #7C3AED;
  }

  .mega-cat-txt {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
  }
  .mega-cat-title {
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 700;
    font-size: 0.94rem;
    line-height: 1.25;
    color: #0F172A;
    letter-spacing: 0;
    text-transform: none;
    transition: color 0.18s ease;
  }
  .mega-cat.is-active .mega-cat-title {
    color: var(--tayra-color-primary, #0B7A3E);
  }
  .mega-cat-desc {
    font-family: var(--tayra-font-body, sans-serif);
    font-size: 0.75rem;
    line-height: 1.35;
    color: #64748B;
  }

  /* Right pane: header + grid of links with outline icons + bottom CTA */
  .mega-right {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #FFFFFF;
    padding: 1.5rem 1.85rem 1.2rem;
    box-sizing: border-box;
  }
  .mega-eyebrow {
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tayra-color-primary, #0B7A3E);
    margin: 0 0 1.25rem 0.25rem;
  }
  .mega-pane {
    display: none;
    animation: megaPaneFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  .mega-pane.is-active {
    display: block;
  }
  @keyframes megaPaneFadeIn {
    from {
      opacity: 0;
      transform: translateY(5px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mega-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.85rem;
    row-gap: 0.35rem;
    margin-bottom: 0.5rem;
  }
  .mega-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    color: #1E293B !important;
    font-family: var(--tayra-font-body, sans-serif);
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: normal !important;
    text-decoration: none;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
  }
  .mega-link:hover {
    background: #F8FAFC;
    color: var(--tayra-color-primary, #0B7A3E) !important;
    transform: translateX(3px);
  }
  .mega-link-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--tayra-color-primary, #0B7A3E);
    transition: transform 0.16s ease;
  }
  .mega-link:hover .mega-link-icon {
    transform: scale(1.1);
  }
  .mega-link-icon svg {
    width: 19px;
    height: 19px;
  }

  .mega-link-txt {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
  }

  /* Badges matching reference (NEW, POPULAR, duration) */
  .mega-badge {
    display: inline-block;
    font-family: var(--tayra-font-heading, sans-serif);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 5px;
    line-height: 1;
    vertical-align: middle;
  }
  .mega-badge--new {
    background: #EEF2FF;
    color: #4F46E5;
  }
  .mega-badge--popular {
    background: #FEF3C7;
    color: #D97706;
  }
  .mega-badge--duration {
    background: #F1F5F9;
    color: #475569;
    font-size: 0.64rem;
    font-weight: 600;
  }

  /* Bottom CTA banner matching reference design */
  .mega-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding-top: 1.15rem;
    margin-top: 1.25rem;
    border-top: 1px solid #E2E8F0;
    background: #FFFFFF;
  }
  .mega-cta-content {
    min-width: 0;
  }
  .mega-cta-title {
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 700;
    font-size: 0.92rem;
    color: #0F172A;
    margin-bottom: 2px;
    line-height: 1.3;
  }
  .mega-cta-desc {
    font-family: var(--tayra-font-body, sans-serif);
    font-size: 0.77rem;
    color: #64748B;
    line-height: 1.35;
  }
  .mega-cta-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.4rem;
    border: 1.5px solid #CBD5E1;
    background: #FFFFFF;
    color: #0F172A !important;
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    border-radius: 999px;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
  }
  .mega-cta-btn:hover {
    border-color: var(--tayra-color-primary, #0B7A3E);
    color: var(--tayra-color-primary, #0B7A3E) !important;
    background: rgba(11, 122, 62, 0.04);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 122, 62, 0.1);
  }

  /* Hide the mobile drawer entirely on desktop */
  .tayra-mobile-nav { display: none !important; }
}

/* ==========================================================================
   MOBILE  (<= 992px)  — hide desktop nav, show hamburger + drawer
   ========================================================================== */
@media (max-width: 992px) {

  .tayra-nav-toggle { display: inline-flex; }

  /* Hide the desktop menus */
  .tayra-header--home .tayra-nav,
  .tayra-header--inner .tayra-header-level-nav {
    display: none !important;
  }

  /* Drawer */
  .tayra-mobile-nav {
    position: fixed;
    inset: 0;
    z-index: 9998;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .tayra-mobile-nav.is-open { visibility: visible; opacity: 1; }

  .tayra-mobile-nav-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 15, 10, 0.55);
  }

  .tayra-mobile-nav-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: min(88vw, 380px);
    background: var(--tayra-color-surface, #fff);
    box-shadow: -16px 0 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tayra-mobile-nav.is-open .tayra-mobile-nav-panel { transform: translateX(0); }

  .tayra-mobile-nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--tayra-color-border, #DCE8DD);
  }
  .tayra-mobile-nav-title {
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--tayra-color-primary, #0B7A3E);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .tayra-mobile-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--tayra-color-surface-alt, #F1F5F2);
    color: var(--tayra-color-heading, #143321);
    border-radius: 10px;
    cursor: pointer;
  }

  .tayra-mobile-menu {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    flex: 1;
  }
  .tayra-mobile-menu .menu-item { border-bottom: 1px solid var(--tayra-color-divider, #E8EFE9); }
  .tayra-mobile-menu a {
    display: block;
    padding: 0.95rem 1.35rem;
    color: var(--tayra-color-heading, #143321);
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 600;
    font-size: 0.98rem;
  }
  .tayra-mobile-menu .current-menu-item > a { color: var(--tayra-color-primary, #0B7A3E); }

  /* Row that holds the parent link + expand toggle */
  .tayra-mobile-menu .menu-item-has-children > .mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .tayra-mobile-menu .menu-item-has-children > .mobile-row > a { flex: 1; }
  .mobile-submenu-toggle {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border: none;
    background: none;
    color: var(--tayra-color-primary, #0B7A3E);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-submenu-toggle svg { transition: transform 0.28s ease; }
  .menu-item.is-open > .mobile-row .mobile-submenu-toggle svg { transform: rotate(180deg); }

  /* Accordion sub-menu */
  .tayra-mobile-menu .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--tayra-color-surface-alt, #F1F5F2);
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
  }
  .tayra-mobile-menu .menu-item.is-open > .sub-menu { grid-template-rows: 1fr; }
  .tayra-mobile-menu .sub-menu > * { overflow: hidden; min-height: 0; }
  .tayra-mobile-menu .sub-menu a {
    padding: 0.7rem 1.35rem 0.7rem 2.15rem;
    font-family: var(--tayra-font-body, sans-serif);
    font-weight: 500;
    font-size: 0.92rem;
    color: var(--tayra-color-body, #455A4A);
  }
  .tayra-mobile-menu .sub-menu .sub-menu a { padding-left: 3rem; }

  /* Footer area of the drawer (optional CTA/lang) */
  .tayra-mobile-nav-foot {
    padding: 1.1rem 1.35rem 1.5rem;
    border-top: 1px solid var(--tayra-color-border, #DCE8DD);
  }
  .tayra-mobile-nav-cta {
    display: block;
    text-align: center;
    background: var(--tayra-color-primary, #0B7A3E);
    color: #fff;
    font-family: var(--tayra-font-heading, sans-serif);
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.85rem 1rem;
    border-radius: 12px;
  }
}

/* Lock body scroll when the drawer is open */
body.tayra-nav-open { overflow: hidden; }
