/* ==========================================================================
   ATP Mega Menu
   Desktop (>1080px): full-width panels drop from the header on hover/click.
   One shared "backplate" morphs its height and colour between panels, the
   gold indicator slides between triggers, and panel content staggers in.
   Mobile (<=1080px): panels become drill-down layers inside the drawer.
   ========================================================================== */

.mega {
  --m-bg: var(--ink);
  --m-fg: var(--cream);
  --m-muted: #B9B2A5;
  --m-line: rgba(255, 254, 241, .12);
  --m-card: rgba(255, 254, 241, .05);
  --m-card-hover: rgba(255, 254, 241, .09);
  --m-accent: var(--gold);
}
.mega--light {
  --m-bg: var(--cream);
  --m-fg: var(--ink);
  --m-muted: #6B6466;
  --m-line: rgba(35, 31, 32, .12);
  --m-card: var(--white);
  --m-card-hover: var(--white);
  --m-accent: var(--gold-deep);
}

/* ---------- Triggers ---------- */
.mega-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 10px; background: none; border: 0; cursor: pointer;
  font-size: .98rem; font-weight: 500; color: var(--ink); position: relative;
}
.mega-trigger__caret { width: 16px; height: 16px; transition: transform .3s var(--ease); }
.mega-trigger[aria-expanded="true"] .mega-trigger__caret { transform: rotate(180deg); }
.mega-trigger[aria-current="page"] span { color: var(--gold-deep); }
.mega__back { display: none; }

/* ---------- Desktop ---------- */
@media (min-width: 1081px) {
  .site-header { --header-line: transparent; }
  .site-header.mega-open { box-shadow: none; border-color: var(--line); background: var(--cream); backdrop-filter: none; }
  /* every ancestor up to the header stays static, so panels span the full header width */
  .nav-list, .nav-item.has-mega, .site-nav { position: static; }

  .mega-indicator {
    position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; z-index: 2; list-style: none;
    background: var(--gold-deep); border-radius: 2px; opacity: 0; pointer-events: none;
    transition: transform .35s var(--ease), width .35s var(--ease), opacity .2s;
  }
  .mega-indicator.is-visible { opacity: 1; }

  /* the shared morphing surface */
  .mega-backplate {
    position: absolute; left: 0; right: 0; top: 100%; height: 0;
    background: var(--ink); overflow: hidden; pointer-events: none;
    transition: height .45s var(--ease), background-color .35s ease, box-shadow .3s;
    z-index: 0;
  }
  .mega-backplate[data-theme="light"] { background: var(--cream); }
  .site-header.mega-open .mega-backplate { box-shadow: 0 40px 80px -30px rgba(10, 8, 9, .55); }
  .mega-backplate::before { /* subtle brand pattern on dark panels */
    content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .35s;
    background: url("/assets/img/pattern-mark.png") right -60px top -40px / 720px auto no-repeat;
    -webkit-mask-image: linear-gradient(90deg, transparent 35%, #000 100%); mask-image: linear-gradient(90deg, transparent 35%, #000 100%);
  }
  .mega-backplate[data-theme="dark"]::before { opacity: .22; }
  .mega-backplate::after { /* gold hairline at the top edge */
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-deep) 20%, var(--gold) 50%, var(--gold-deep) 80%, transparent);
    opacity: .7;
  }

  .mega {
    position: absolute; left: 0; right: 0; top: 100%;
    padding: 40px 0 46px; color: var(--m-fg);
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(-6px);
    transition: opacity .22s ease, transform .35s var(--ease), visibility 0s linear .35s;
    z-index: 1;
  }
  .mega.is-active {
    opacity: 1; visibility: visible; pointer-events: auto; transform: none;
    transition: opacity .3s ease .05s, transform .4s var(--ease), visibility 0s;
  }
  /* staggered entrance */
  .mega .mega-stagger { opacity: 0; transform: translateY(10px); transition: opacity .35s ease, transform .5s var(--ease); }
  .mega.is-active .mega-stagger { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 55ms + 60ms); }

  .mega-scrim {
    position: fixed; inset: 0; z-index: 99; background: rgba(20, 16, 17, .45);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility 0s linear .35s;
  }
  .mega-scrim.is-visible { opacity: 1; visibility: visible; transition: opacity .35s ease, visibility 0s; }
}

/* ---------- Shared panel pieces ---------- */
.mega__grid { display: grid; gap: clamp(28px, 3vw, 48px); align-items: stretch; }
.mega__grid--inventory { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.45fr) minmax(250px, .9fr); }
.mega__grid--brokerage { grid-template-columns: 1fr 1fr minmax(260px, .85fr); }
.mega__grid--about { grid-template-columns: repeat(4, 1fr); gap: 20px; }

.mega__label { font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; font-weight: 500; color: var(--m-accent); margin: 0 0 16px; }
.mega__label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.mega__all, .mega__link-arrow { font-size: .9rem; font-weight: 500; color: var(--m-fg); text-decoration: none; display: inline-flex; align-items: center; gap: .45em; transition: gap .2s var(--ease), color .2s; }
.mega__all::after, .mega__link-arrow::after { content: "→"; color: var(--m-accent); }
.mega__all:hover, .mega__link-arrow:hover { gap: .75em; color: var(--m-accent); }

/* Search */
.mega-search { position: relative; display: flex; margin-bottom: 18px; border: 1px solid var(--m-line); border-radius: 6px; background: var(--m-card); transition: border-color .2s, box-shadow .2s; }
.mega-search:focus-within { border-color: var(--m-accent); box-shadow: 0 0 0 3px rgba(210, 188, 104, .18); }
.mega-search__icon { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--m-muted); pointer-events: none; }
.mega-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 13px 10px 13px 42px; font-size: .95rem; color: var(--m-fg); }
.mega-search input::placeholder { color: var(--m-muted); }
.mega-search input:focus { outline: none; }
.mega-search button { border: 0; margin: 4px; padding: 0 16px; border-radius: 4px; background: var(--gold-deep); color: var(--ink); font-weight: 500; font-size: .9rem; cursor: pointer; transition: background .2s; }
.mega-search button:hover { background: var(--gold); }

/* Category list */
.mega-cats { list-style: none; display: grid; gap: 2px; }
.mega-cats a {
  position: relative; display: grid; grid-template-columns: 30px 1fr auto; gap: 14px; align-items: center;
  padding: 11px 14px; border-radius: 6px; text-decoration: none; color: var(--m-fg);
  transition: background .2s, padding-left .25s var(--ease);
}
.mega-cats a::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: var(--m-accent); transform: scaleY(0); transition: transform .25s var(--ease); border-radius: 2px; }
.mega-cats a:hover, .mega-cats a:focus-visible, .mega-cats a.is-current { background: var(--m-card-hover); padding-left: 18px; }
.mega-cats a:hover::before, .mega-cats a:focus-visible::before, .mega-cats a.is-current::before { transform: scaleY(1); }
.mega-cats__icon { width: 26px; height: 26px; color: var(--m-accent); }
.mega-cats__text { display: flex; flex-direction: column; line-height: 1.25; }
.mega-cats__text strong { font-family: var(--font-head); font-weight: 600; font-size: 1.28rem; }
.mega-cats__text small { font-size: .8rem; color: var(--m-muted); margin-top: 2px; }
.mega-count { min-width: 28px; height: 24px; padding: 0 8px; border-radius: 999px; display: inline-grid; place-items: center; font-size: .76rem; font-weight: 600; border: 1px solid var(--m-line); color: var(--m-muted); transition: background .2s, color .2s, border-color .2s; }
.mega-count:empty { display: none; }
.mega-cats a:hover .mega-count, .mega-cats a.is-current .mega-count { background: var(--gold); border-color: var(--gold); color: var(--ink); }

/* Live aircraft preview */
.mega-preview { display: grid; gap: 12px; transition: opacity .2s ease; }
.mega-preview.is-swapping { opacity: 0; }
.mega-ac {
  display: grid; grid-template-columns: 148px 1fr; gap: 18px; align-items: center;
  padding: 10px; border-radius: 8px; text-decoration: none; color: var(--m-fg);
  background: var(--m-card); border: 1px solid var(--m-line);
  transition: transform .3s var(--ease), background .25s, border-color .25s;
}
.mega-ac:hover, .mega-ac:focus-visible { transform: translateX(4px); background: var(--m-card-hover); border-color: rgba(210, 188, 104, .5); }
.mega-ac__media { position: relative; aspect-ratio: 16 / 10; border-radius: 5px; overflow: hidden; background: rgba(255, 254, 241, .9); }
.mega-ac__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.mega-ac__media img.is-profile { object-fit: contain; padding: 6%; }
.mega-ac:hover .mega-ac__media img { transform: scale(1.06); }
.mega-ac__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mega-ac__body strong { font-family: var(--font-head); font-size: 1.3rem; font-weight: 600; line-height: 1.15; }
.mega-ac__body small { font-size: .82rem; color: var(--m-muted); }
.mega-ac__meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--m-muted); }
.mega-ac__meta span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--m-accent); margin-right: 14px; vertical-align: middle; }
.mega-ac__status { align-self: flex-start; font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--m-accent); font-weight: 600; }
.mega-preview__empty { padding: 28px; border: 1px dashed var(--m-line); border-radius: 8px; color: var(--m-muted); }
.mega-preview__empty strong { display: block; font-family: var(--font-head); font-size: 1.4rem; color: var(--m-fg); margin-bottom: 4px; }

/* Feature card */
.mega-feature { display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; background: var(--ink-3); border: 1px solid var(--m-line); }
.mega-feature__media { aspect-ratio: 16 / 10; overflow: hidden; }
.mega-feature__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.mega-feature:hover .mega-feature__media img { transform: scale(1.05); }
.mega-feature__body { padding: 22px 22px 24px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.mega-feature__kicker { margin: 0; font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.mega-feature__title { margin: 0; font-family: var(--font-head); font-size: 1.5rem; line-height: 1.15; color: var(--cream); }
.mega-feature__phone { font-family: var(--font-head); font-size: 1.9rem; font-weight: 600; color: var(--gold); text-decoration: none; margin: 4px 0 6px; }
.mega-feature__phone:hover { color: var(--gold-soft); }

/* Big image tiles (brokerage) */
.mega-tile { position: relative; display: block; min-height: 360px; border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--white); isolation: isolate; box-shadow: 0 20px 40px -24px rgba(20, 16, 17, .6); }
.mega-tile__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform 1.1s var(--ease); }
.mega-tile__shade { position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(20, 16, 17, .05) 0%, rgba(20, 16, 17, .35) 45%, rgba(20, 16, 17, .92) 100%); transition: background .4s; }
.mega-tile:hover .mega-tile__img, .mega-tile:focus-visible .mega-tile__img { transform: scale(1.06); }
.mega-tile:hover .mega-tile__shade, .mega-tile:focus-visible .mega-tile__shade { background: linear-gradient(180deg, rgba(20, 16, 17, .2) 0%, rgba(20, 16, 17, .6) 40%, rgba(20, 16, 17, .95) 100%); }
.mega-tile__body { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 28px; display: flex; flex-direction: column; gap: 6px; }
.mega-tile__kicker { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.mega-tile__title { font-family: var(--font-head); font-size: clamp(1.8rem, 2.3vw, 2.3rem); font-weight: 600; line-height: 1.05; }
.mega-tile__desc { font-size: .9rem; color: rgba(255, 255, 255, .82); max-width: 34ch; }
.mega-steps { display: flex; flex-wrap: wrap; gap: 8px; max-height: 0; opacity: 0; overflow: hidden; transform: translateY(8px); transition: max-height .45s var(--ease), opacity .3s, transform .45s var(--ease), margin .45s var(--ease); }
.mega-steps > span { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; padding: 5px 11px 5px 5px; border-radius: 999px; background: rgba(255, 254, 241, .12); border: 1px solid rgba(210, 188, 104, .4); backdrop-filter: blur(4px); }
.mega-steps b { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--ink); font-family: var(--font-head); font-size: .85rem; }
.mega-tile:hover .mega-steps, .mega-tile:focus-visible .mega-steps { max-height: 80px; opacity: 1; transform: none; margin: 8px 0 4px; }
.mega-tile__cta { display: inline-flex; align-items: center; gap: .5em; font-weight: 500; font-size: .92rem; margin-top: 6px; color: var(--gold); transition: gap .25s var(--ease); }
.mega-tile__cta::after { content: "→"; }
.mega-tile:hover .mega-tile__cta { gap: .85em; }

/* Text links (brokerage side column) */
.mega-links { list-style: none; display: grid; gap: 2px; margin-bottom: 20px; }
.mega-links a { display: flex; flex-direction: column; padding: 12px 14px; margin: 0 -14px; border-radius: 6px; text-decoration: none; color: var(--m-fg); transition: background .2s, transform .25s var(--ease); }
.mega-links a:hover, .mega-links a:focus-visible { background: var(--cream-2); transform: translateX(4px); }
.mega--dark .mega-links a:hover { background: var(--m-card-hover); }
.mega-links strong { font-family: var(--font-head); font-size: 1.3rem; font-weight: 600; }
.mega-links strong::after { content: " →"; color: var(--m-accent); opacity: 0; transition: opacity .2s; }
.mega-links a:hover strong::after { opacity: 1; }
.mega-links small { font-size: .84rem; color: var(--m-muted); }
.mega-cta-card { padding: 22px; border-radius: 10px; background: var(--navy); color: var(--cream); display: flex; flex-direction: column; align-items: flex-start; gap: 14px; position: relative; overflow: hidden; }
.mega-cta-card::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 140px; height: 130px; background: url("/assets/img/atplogos2-05.svg") center / contain no-repeat; opacity: .14; }
.mega-cta-card__title { margin: 0; font-family: var(--font-head); font-style: italic; font-size: 1.35rem; line-height: 1.25; }

/* Photo cards (about) */
.mega-card { position: relative; display: block; aspect-ratio: 4 / 4.4; border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--white); isolation: isolate; }
.mega-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform 1s var(--ease), filter .4s; }
.mega-card::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(20, 16, 17, 0) 35%, rgba(20, 16, 17, .88) 100%); transition: opacity .3s; }
.mega-card::after { content: ""; position: absolute; inset: 0; border: 1px solid rgba(210, 188, 104, 0); border-radius: inherit; transition: border-color .3s, inset .3s var(--ease); pointer-events: none; }
.mega-card:hover img, .mega-card:focus-visible img { transform: scale(1.07); }
.mega-card:hover::after, .mega-card:focus-visible::after { border-color: rgba(210, 188, 104, .8); inset: 8px; border-radius: 6px; }
.mega-card__body { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 22px; display: flex; flex-direction: column; gap: 3px; }
.mega-card__title { font-family: var(--font-head); font-size: 1.65rem; font-weight: 600; line-height: 1.1; display: inline-flex; align-items: center; gap: .35em; }
.mega-card__title::after { content: "→"; font-family: var(--font-body); font-size: 1rem; color: var(--gold); opacity: 0; transform: translateX(-6px); transition: opacity .25s, transform .3s var(--ease); }
.mega-card:hover .mega-card__title::after { opacity: 1; transform: none; }
.mega-card__desc { font-size: .85rem; color: rgba(255, 255, 255, .8); }
.mega-card__badge { position: absolute; top: 14px; left: 14px; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; background: var(--gold); color: var(--ink); padding: 6px 10px; border-radius: 3px; }
.mega-card__play { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(210, 188, 104, .95); color: var(--ink); box-shadow: 0 0 0 6px rgba(210, 188, 104, .25); transition: transform .3s var(--ease); }
.mega-card__play svg { width: 16px; height: 16px; margin-left: 2px; }
.mega-card:hover .mega-card__play { transform: scale(1.1); }
.mega-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--m-line); font-size: .92rem; }
.mega-bar__item { display: inline-flex; align-items: center; gap: 8px; color: var(--m-fg); text-decoration: none; }
.mega-bar__item svg { width: 17px; height: 17px; color: var(--m-accent); }
a.mega-bar__item:hover { color: var(--m-accent); }
.mega-bar .mega__link-arrow { margin-left: auto; }

@media (min-width: 1081px) and (max-width: 1280px) {
  .mega__grid--inventory { grid-template-columns: minmax(260px, 1fr) minmax(0, 1.3fr); }
  .mega__grid--inventory .mega-feature { display: none; }
  .mega__grid--brokerage { grid-template-columns: 1fr 1fr minmax(240px, .8fr); }
  .mega-tile { min-height: 320px; }
}

/* ---------- Mobile drill-down ---------- */
@media (max-width: 1080px) {
  .mega-backplate, .mega-scrim, .mega-indicator { display: none !important; }
  .nav-item.has-mega { position: static; border-bottom: 1px solid var(--line); }
  .mega-trigger { width: 100%; justify-content: space-between; padding: 16px 0; font-size: 1.12rem; text-align: left; }
  .mega-trigger__caret { transform: rotate(-90deg); width: 20px; height: 20px; }
  .mega-trigger[aria-expanded="true"] .mega-trigger__caret { transform: rotate(-90deg); }

  .mega {
    position: absolute; inset: 0; z-index: 3; overflow-y: auto; overscroll-behavior: contain;
    background: var(--m-bg); color: var(--m-fg);
    padding: 96px 22px 40px;
    transform: translateX(100%); visibility: hidden;
    transition: transform .42s var(--ease), visibility 0s linear .42s;
  }
  .mega.is-active { transform: none; visibility: visible; transition: transform .42s var(--ease), visibility 0s; }
  .mega .container { padding: 0; }
  .mega__back {
    display: inline-flex; align-items: center; gap: 6px; margin: 0 0 18px; padding: 8px 12px 8px 6px;
    background: var(--m-card); border: 1px solid var(--m-line); border-radius: 999px; color: var(--m-fg);
    font-size: .9rem; font-weight: 500; cursor: pointer;
  }
  .mega__back svg { width: 18px; height: 18px; color: var(--m-accent); }

  .mega__grid, .mega__grid--inventory, .mega__grid--brokerage { display: flex; flex-direction: column; gap: 22px; }
  .mega__grid--about { grid-template-columns: 1fr 1fr; gap: 12px; }
  .mega__col--preview { display: none; }
  .mega-feature { flex-direction: row; }
  .mega-feature__media { display: none; }
  .mega-feature__title { font-size: 1.25rem; }
  .mega-feature__phone { font-size: 1.6rem; }
  .mega-tile { min-height: 210px; }
  .mega-tile__desc { display: none; }
  .mega-tile__body { padding: 18px 20px; }
  .mega-steps { display: none; }
  .mega-card { aspect-ratio: 1 / 1.05; }
  .mega-card__title { font-size: 1.25rem; }
  .mega-card__desc { display: none; }
  .mega-card__body { padding: 14px; }
  .mega-bar { flex-direction: column; align-items: flex-start; }
  .mega-bar .mega__link-arrow { margin-left: 0; }
  .mega-cats a { padding: 12px 10px; }
  .site-nav.has-layer { overflow: hidden; }
}
@media (max-width: 340px) {
  .mega__grid--about { grid-template-columns: 1fr; }
  .mega-card { aspect-ratio: 16 / 9; }
}

@media (prefers-reduced-motion: reduce) {
  .mega, .mega .mega-stagger, .mega-backplate, .mega-indicator { transition: none !important; }
}
@media (max-width: 1080px) {
  .site-header.layer-open .brand { opacity: 0; pointer-events: none; transition: opacity .2s; }
}

/* New-aircraft alerts sign-up (inventory panel) */
.mega-alert { display: flex; gap: 8px; margin-top: 6px; }
.mega-alert input { flex: 1; min-width: 0; height: 42px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--m-line); background: rgba(255,254,241,.06); color: var(--cream); font: inherit; font-size: .9rem; }
.mega-alert input::placeholder { color: rgba(255,254,241,.5); }
.mega-alert input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.mega-alert .btn { height: 42px; white-space: nowrap; }
.mega-alert__note { margin: 0; font-size: .75rem; color: rgba(255,254,241,.55); }
.mega-alert input[aria-invalid="true"] { border-color: #e08a7a; }
.mega-alert__done { margin: 6px 0 0; padding: 12px 14px; border-radius: 6px; background: rgba(210,188,104,.12); color: var(--gold); font-size: .9rem; line-height: 1.4; }
