/* ==========================================================================
   db-flyout.css · Daelim Belefic child theme
   --------------------------------------------------------------------------
   Open/close behaviour of the desktop mega-menu flyouts in the global header
   (1280px and wider). The panels work with CSS alone: hovering a nav item,
   or tabbing into it, opens its panel. db-flyout.js adds keyboard/touch
   support, ARIA state and the third-level "drill" lists on top of this.
   Also marks the link to the page you are on inside a panel or drill list
   with a red underline, matching the red bar under the current top-level item.

   Expected markup (Theme Builder header)
     nav[data-db-flyout].db-main-nav
       li.db-nav-item.db-nav-item--panel        one per top-level item with a panel
         a.db-nav-label + button.db-nav-toggle   (link + chevron button) or
         button.db-nav-label.db-nav-trigger      (button-only item)
         span.db-flyout-caret                    small white caret under the item
         div.db-flyout.db-flyout--<id>[.db-flyout--photo-right]
           div.db-flyout-photos > div.db-flyout-img[data-drill="<drill id>"]
           div.db-flyout-body > .db-flyout-lists
             ul.db-flyout-list (button.db-drill opens a drill list)
             li.db-flyout-parent > div.db-flyout-drill#<drill id> > ul.db-flyout-list  (see db-flyout-sub.css)

   State classes (only ever set by db-flyout.js)
     .is-open            panel opened by click/tap or keyboard
     .is-closed-by-esc   Esc closed it while the pointer is still over it
     .is-switching       moving straight from one item to the next: no photo wipe
     .is-sub             a third-level column is open (on .db-flyout; db-flyout-sub.css)
     .is-active          the visible drill list and its photo
     aria-current="page" on a panel link that points to this page (the script
                         sets it; the "you are here" underline keys off it)

   Timing: opens in 200ms (ease-out) with the photo wiping in over 250ms from
   the list side; closes in reverse after a 150ms hover-intent delay, so the
   panel doesn't vanish when the pointer briefly leaves it. Switching between
   items is instant.

   In Divi: wrap these rules in body:not(<Visual Builder body class>) so the
   panels stay visible and editable in the builder (check the class Divi 5
   puts on <body> in the Visual Builder). Panel position and size live in the
   header's own layout CSS (static reference: sections/g1-header.css).
   ========================================================================== */

@media (min-width: 1280px) {
  /* closed state: hidden, nudged up, fading out after the hover-intent delay */
  .db-flyout {
    z-index: var(--z-flyout);
    visibility: hidden; opacity: 0; transform: translateY(var(--move-flyout));
    transition: opacity var(--dur-fast) var(--ease-exit) var(--delay-hover-intent),
                transform var(--dur-fast) var(--ease-exit) var(--delay-hover-intent),
                visibility 0s linear calc(var(--dur-fast) + var(--delay-hover-intent));
  }
  .db-flyout-caret {
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-exit) var(--delay-hover-intent);
  }

  /* open state: hover, keyboard focus inside, or .is-open from the script */
  .db-nav-item:is(:hover, :focus-within, .is-open):not(.is-closed-by-esc) > .db-flyout {
    visibility: visible; opacity: 1; transform: none;
    transition: opacity var(--dur-fast) var(--ease-enter), transform var(--dur-fast) var(--ease-enter), visibility 0s;
  }
  .db-nav-item:is(:hover, :focus-within, .is-open):not(.is-closed-by-esc) > .db-flyout-caret { opacity: 1; transition: opacity var(--dur-fast) var(--ease-enter); }
  /* the item's chevron flips to point up while its panel is open */
  .db-nav-item:is(:hover, :focus-within, .is-open):not(.is-closed-by-esc) > .db-nav-trigger::after,
  .db-nav-item:is(:hover, :focus-within, .is-open):not(.is-closed-by-esc) > .db-nav-toggle::before { rotate: 180deg; }

  /* photo wipe: the photo is revealed from the list side outward (250ms) */
  .db-flyout-photos { clip-path: inset(0 0 0 100%); transition: clip-path 250ms var(--ease-enter) var(--delay-flyout-img); }
  .db-flyout--photo-right .db-flyout-photos { clip-path: inset(0 100% 0 0); }
  .db-nav-item:is(:hover, :focus-within, .is-open):not(.is-closed-by-esc) .db-flyout-photos { clip-path: inset(0); }

  /* switching between items: the previous panel hides at once; the new one shows without the wipe */
  .db-main-nav:has(.db-nav-item:hover) .db-nav-item:not(:hover) > .db-flyout,
  .db-main-nav:has(.db-nav-item:hover) .db-nav-item:not(:hover) > .db-flyout-caret { transition: none; }
  .db-nav-item.is-switching .db-flyout-photos { transition: none; clip-path: inset(0); }
}

/* --------------------------------------------------------------------------
   Third-level drill (any width)
   The second-level list and the drill lists share one grid cell, so the
   panel keeps its height while they crossfade (200ms); the matching photo
   crossfades in 300ms.
   Visibility is inherited from the panel, so the delayed-visibility
   transition is only set on the HIDING rules, never on the default list:
   otherwise the list would stay hidden for 200ms after the panel opens and
   keyboard focus could not enter it.
   -------------------------------------------------------------------------- */
.db-flyout-lists > .db-flyout-list { transition: opacity var(--dur-fast) var(--ease-standard); }
.db-flyout-drill { visibility: hidden; opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard), visibility 0s linear var(--dur-fast); }
.db-flyout-drill.is-active { visibility: visible; opacity: 1; transition: opacity var(--dur-fast) var(--ease-standard), visibility 0s; }

/* chevrons on parent rows inside a panel use the thin glyph, sized like the flyout links */
.db-flyout .db-drill::before { --icon: url("../svg/icon-chevron-thin.svg"); }

/* --------------------------------------------------------------------------
   You are here: the link to the current page inside a panel or drill list
   gets a 2px red underline, the same mark as the red bar under the current
   top-level item. It is an underline, not a weight or size change, so the
   list doesn't shift; hovering still turns the text blue.
   -------------------------------------------------------------------------- */
.db-flyout .text-flyout-link[aria-current="page"] {
  text-decoration-line: underline; text-decoration-thickness: 2px;
  text-decoration-color: var(--c-red); text-underline-offset: 5px;
}
