/* ==========================================================================
   db-flyout-sub.css · Daelim Belefic child theme
   --------------------------------------------------------------------------
   The menu's third level (Xae, BugHerd #107, approved 2026-11-05). Loaded
   after db-flyout.css and db-header.css, whose rules it overrides.
   1. the chevrons on items with a third level point right
   2. resting on such an item opens its pages in a second column to the
      right: the white panel extends, and the other items fade to 50%
   3. leaving the item and its column closes it again (it retracts)
   4. the photo stays the same (no per-item photos are printed)
   5. order: the white extends first, THEN the links fade in; closing runs
      the other way (links fade out, then the white retracts)
   Phones and tablets: the third level opens as an accordion inside the
   menu panel.

   Markup: li.db-flyout-parent > a + button.db-drill + div.db-flyout-drill
   (ul of links). State classes from js/db-flyout.js:
     .db-flyout.is-sub          a second column is open (panel extended)
     .db-flyout.is-sub-switch   moving from one parent item to another
     li.db-flyout-parent.is-sub-open, .db-flyout-drill.is-active
   --sub-w on the panel = width of the widest second column (set by the script).
   ========================================================================== */

:root {
  --sub-gap: 48px;              /* between the two columns (= the panel's right padding) */
  --sub-extend: 250ms;          /* the white extends / retracts */
  --sub-fade-in: 200ms;
  --sub-fade-out: 150ms;
}

@media (min-width: 1280px) {
  /* the text column keeps its width while the panel grows, so nothing in it moves */
  .db-flyout { overflow: clip; }
  .db-flyout-body { flex: none; width: calc(var(--flyout-w) - 250px); }
  .db-flyout-lists { position: relative; }

  /* the panel's width animates along with its existing open/close transitions (db-flyout.css). Closing: wait for
     the links to fade out, then retract; opening: extend at once. */
  .db-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)),
                width var(--sub-extend) var(--ease-standard) var(--sub-fade-out);
  }
  .db-nav-item:is(:hover, :focus-within, .is-open):not(.is-closed-by-esc) > .db-flyout {
    transition: opacity var(--dur-fast) var(--ease-enter), transform var(--dur-fast) var(--ease-enter), visibility 0s,
                width var(--sub-extend) var(--ease-standard) var(--sub-fade-out);
  }
  .db-nav-item:is(:hover, :focus-within, .is-open):not(.is-closed-by-esc) > .db-flyout.is-sub {
    width: calc(var(--flyout-w) + var(--sub-w, 0px));
    transition: opacity var(--dur-fast) var(--ease-enter), transform var(--dur-fast) var(--ease-enter), visibility 0s,
                width var(--sub-extend) var(--ease-enter) 0s;
  }
  /* the script resets a closed panel without animating */
  .db-flyout.is-still { transition: none !important; }

  /* second column: starts at the text column's right edge; its left padding is the gap, so the pointer can travel
     from the item to its pages without leaving the item. The open column fills the whole extension, down to the
     panel's bottom edge, and an invisible strip (::after) carries it on to the panel's right edge (the panel clips
     both overhangs), so moving right from a low item (Renewable Energy, under a two-link column) never leaves it
     (Dan, 2026-11-05: it closed in the white below Solar / Wind). */
  .db-flyout .db-flyout-drill {
    position: absolute; top: 0; bottom: -24px; left: 100%; width: max-content; padding-left: var(--sub-gap);
    transition: opacity var(--sub-fade-out) var(--ease-standard), visibility 0s linear var(--sub-fade-out);
  }
  .db-flyout .db-flyout-drill::after { content: ""; position: absolute; top: 0; bottom: 0; left: 100%; width: 100vw; }
  .db-flyout .db-flyout-drill.is-active {
    transition: opacity var(--sub-fade-in) var(--ease-enter) var(--sub-extend), visibility 0s;
  }
  /* already open, another item's pages: crossfade, no wait for the white */
  .db-flyout.is-sub-switch .db-flyout-drill.is-active { transition-delay: var(--sub-fade-out), 0s; }
  .db-flyout-drill > .db-flyout-list { display: grid; row-gap: 5.6px; }

  /* the other items fade to 50% while a second column is open */
  .db-flyout-lists > .db-flyout-list > li { transition: opacity var(--sub-extend) var(--ease-standard); }
  .db-flyout.is-sub .db-flyout-lists > .db-flyout-list > li:not(.is-sub-open) { opacity: .5; }
  /* the open item stays black (hover would turn it blue) */
  .db-flyout-parent.is-sub-open > .text-flyout-link, .db-flyout-parent.is-sub-open > .db-drill { color: var(--c-black); }
  .db-flyout-parent.is-sub-open > .text-flyout-link:hover, .db-flyout-parent.is-sub-open > .db-drill:hover { color: var(--c-blue); }
}

/* 1. chevrons on items with a third level point right (desktop panel) */
.db-flyout .db-drill::before { rotate: -90deg; }

/* --------------------------------------------------------------------------
   Phones and tablets: the third level is an accordion (same grid-rows
   animation as the menu's groups, db-header.css)
   -------------------------------------------------------------------------- */
.db-mnav__subrow { display: flex; align-items: center; }
.db-mnav__subrow > .db-mnav__link--l2 { flex: 1 1 auto; width: auto; }
.db-mnav__subtoggle {
  display: inline-flex; align-items: center; justify-content: flex-end; flex: none; width: 64px; height: 42px; padding: 0 24px 0 0;
  color: var(--c-black); background: none; border: 0; cursor: pointer;   /* chevron lines up with the group chevrons above */
}
@media (hover: hover) { .db-mnav__subtoggle:hover { color: var(--c-blue); } }   /* no "stuck" blue after a tap */
.db-mnav__subtoggle::before { transition: rotate var(--dur-accordion) var(--ease-standard); }
.db-mnav__subtoggle[aria-expanded="true"]::before { rotate: 180deg; }
.js .db-mnav__subgroup.is-open > .db-mnav__panel { grid-template-rows: 1fr; }
.db-mnav__subgroup > .db-mnav__panel > .db-mnav__sub3 {
  overflow: hidden; min-height: 0; margin-left: 0; padding-block: 0; transition: visibility var(--dur-accordion);
}
.js .db-mnav__subgroup:not(.is-open) > .db-mnav__panel > .db-mnav__sub3 { visibility: hidden; }
.db-mnav__subgroup .db-mnav__link--l3 { padding-left: 64px; }
.db-mnav__subgroup .db-mnav__sub3 > li:last-child { padding-bottom: 8px; }
