/* ============================================================
   HAC Mega Menu — Frontend
   Tokens nach Head and Code Brand Manual v1.0
   ============================================================ */

.hac-page {
  --hac-violet: #2e2382;
  --hac-violet-50: #9184be;
  --hac-violet-25: #bcb4da;
  --hac-violet-10: #e8e6f4;
  --hac-pink: #e5007d;
  --hac-yellow: #ffdd00;
  --hac-grad: linear-gradient(45deg, #2e2382 0%, #e5007d 100%);
  --hac-grey-05: #f6f6f6;
  --hac-grey-10: #ececec;
  --hac-grey-75: #626262;
  --hac-ink: #3a3766;

  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--hac-violet);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

.hac-page *,
.hac-page *::before,
.hac-page *::after { box-sizing: border-box; }

.hac-page a { text-decoration: none; color: inherit; }

.hac-page ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ---------------- Header ---------------- */
.hac-header {
  position: relative;
  background: #fff;
  border-bottom: 1px solid var(--hac-grey-10);
}
.hac-header--sticky {
  position: sticky;
  top: 0;
  z-index: 900;
}
.hac-header__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 40px;
  height: 82px;
}

/* Wortmarke als CSS-Fallback, wenn keine Logo-URL gesetzt ist */
.hac-brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.hac-brand img { display: block; height: auto; max-height: 46px; width: auto; }
.hac-mark { display: flex; align-items: center; gap: 9px; }
.hac-mark .m-h,
.hac-mark .m-c { width: 15px; height: 26px; border-radius: 3px; background: var(--hac-violet); }
.hac-mark .m-c { background: var(--hac-pink); }
.hac-mark .m-bar { width: 22px; height: 5px; border-radius: 3px; background: var(--hac-yellow); }
.hac-mark__word {
  font-weight: 800; font-size: .95rem; letter-spacing: .03em;
  color: var(--hac-violet); white-space: nowrap; margin-left: 4px;
}
.hac-mark__word .dim { font-weight: 500; color: var(--hac-violet-50); }

/* ---------------- Navigation ---------------- */
.hac-nav { display: flex; align-items: center; margin-left: auto; }
.hac-nav__list { display: flex; align-items: center; gap: 4px; }
.hac-nav__item { position: static; display: flex; align-items: center; }

.hac-page .hac-nav__link {
  display: flex; align-items: center; gap: 7px;
  padding: 12px 16px; border-radius: 10px;
  font-weight: 600; font-size: .95rem; color: var(--hac-violet);
  transition: background-color .18s ease, color .18s ease;
}
.hac-nav__link:hover { background: var(--hac-violet-10); }
.hac-nav__link:focus-visible,
.hac-nav__toggle:focus-visible { outline: 3px solid var(--hac-pink); outline-offset: 2px; }
.hac-nav__item.is-current > .hac-nav__link { color: var(--hac-pink); }
.hac-nav__item.is-open > .hac-nav__link { background: var(--hac-violet-10); }

.hac-chev {
  width: 8px; height: 8px;
  border-right: 2px solid var(--hac-pink);
  border-bottom: 2px solid var(--hac-pink);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s ease;
}
.hac-nav__item.is-open .hac-chev { transform: rotate(-135deg) translateY(-2px); }

/* Umschalter nur auf Mobil sichtbar */
.hac-nav__toggle { display: none; background: none; border: 0; cursor: pointer; padding: 14px; }

.hac-page .hac-nav__cta {
  display: inline-block;
  margin-left: 14px; padding: 13px 26px; border-radius: 999px;
  background: var(--hac-grad); color: #fff;
  font-weight: 700; font-size: .9rem; white-space: nowrap;
}
.hac-page .hac-nav__cta:focus-visible { outline: 3px solid var(--hac-violet); outline-offset: 3px; }

/* ---------------- Mega-Panel ---------------- */
.hac-mega {
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: #fff;
  border-top: 1px solid var(--hac-grey-10);
  box-shadow: 0 24px 48px -20px rgba(46, 35, 130, .28);
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.hac-nav__item.is-open .hac-mega { opacity: 1; visibility: visible; transform: translateY(0); }

.hac-mega__inner { max-width: 1320px; margin: 0 auto; padding: 44px 24px 40px; }

.hac-mega__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 300px;
  gap: 36px;
}

/* Spaltenüberschrift */
.hac-page .hac-col__head {
  display: block;
  font-weight: 800; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--hac-pink);
  margin: 0 0 4px; padding-bottom: 12px;
  border-bottom: 2px solid var(--hac-violet-10);
}
.hac-col__note { font-size: .82rem; color: var(--hac-grey-75); margin: 12px 0 0; }

/* Gruppenüberschrift innerhalb einer Spalte */
.hac-page .hac-col__sub {
  display: block;
  font-weight: 700; font-size: .88rem; color: var(--hac-violet);
  margin: 24px 0 8px;
}
.hac-mega__col > .hac-links > .hac-group:first-child > .hac-col__sub { margin-top: 18px; }

.hac-mega__col > .hac-links { margin-top: 14px; }
.hac-group > .hac-links { margin-top: 0; }

.hac-page .hac-link {
  display: block;
  padding: 6px 10px 6px 0;
  border-radius: 6px;
  transition: color .15s ease, padding-left .15s ease;
}
.hac-link__title { display: block; font-size: .9rem; font-weight: 500; color: var(--hac-ink); }
.hac-link__desc  { display: block; font-size: .78rem; color: var(--hac-grey-75); margin-top: 1px; }
.hac-link:hover { padding-left: 6px; }
.hac-link:hover .hac-link__title { color: var(--hac-pink); }
.hac-link.is-current .hac-link__title { color: var(--hac-pink); }
.hac-link:focus-visible { outline: 2px solid var(--hac-pink); outline-offset: 2px; }

/* Badge für Compliance-Themen */
.hac-badge {
  display: inline-block; margin-left: 7px; padding: 1px 7px; border-radius: 999px;
  background: var(--hac-yellow); color: var(--hac-violet);
  font-size: .62rem; font-weight: 800; letter-spacing: .06em; vertical-align: middle;
  white-space: nowrap;
}

/* ---------------- Gradient-Panel (letzte Spalte) ---------------- */
.hac-mega__col--panel {
  background: var(--hac-grad);
  border-radius: 22px;
  padding: 30px 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.hac-mega__col--panel::after {
  content: "";
  position: absolute; right: -70px; bottom: -80px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255, 255, 255, .13);
  pointer-events: none;
}
.hac-mega__col--panel > * { position: relative; z-index: 2; }

.hac-page .hac-panel__head {
  display: block;
  font-weight: 800; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--hac-yellow); margin: 0 0 14px;
}
.hac-page .hac-panel__head { order: 1; }
.hac-panel__note {
  order: 3;
  font-size: .82rem; line-height: 1.5;
  color: rgba(255, 255, 255, .85);
  margin: 14px 0 0;
}

/* Listenelemente in den Flex-Fluss des Panels heben, damit der Button unten sitzt */
.hac-mega__col--panel > .hac-links { display: contents; }
.hac-mega__col--panel > .hac-links > li { order: 2; }
.hac-mega__col--panel > .hac-links > .hac-links__cta { order: 4; }
.hac-mega__col--panel .hac-link__title { color: rgba(255, 255, 255, .92); }
.hac-mega__col--panel .hac-link:hover .hac-link__title { color: var(--hac-yellow); }
.hac-mega__col--panel .hac-link__desc { color: rgba(255, 255, 255, .7); }
.hac-mega__col--panel .hac-link:focus-visible { outline-color: var(--hac-yellow); }

.hac-links__cta { margin-top: auto; padding-top: 24px; }
.hac-page .hac-links__cta a {
  display: block; text-align: center;
  background: var(--hac-yellow); color: var(--hac-violet);
  font-weight: 800; font-size: .88rem;
  padding: 13px 18px; border-radius: 999px;
}
.hac-page .hac-links__cta a:hover { background: #fff; }
.hac-page .hac-links__cta a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ---------------- Burger ---------------- */
.hac-burger { display: none; margin-left: auto; background: none; border: 0; cursor: pointer; padding: 10px; }
.hac-burger span { display: block; width: 26px; height: 3px; border-radius: 2px; background: var(--hac-violet); margin: 5px 0; }
.hac-burger:focus-visible { outline: 3px solid var(--hac-pink); outline-offset: 2px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1240px) {
  .hac-mega__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 36px; }
  .hac-mega__col--panel { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .hac-header__inner { height: 70px; gap: 16px; }
  .hac-burger { display: block; }

  .hac-nav {
    display: none;
    position: absolute; left: 0; right: 0; top: 100%;
    background: #fff;
    flex-direction: column; align-items: stretch;
    padding: 12px 20px 28px;
    border-top: 1px solid var(--hac-grey-10);
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    box-shadow: 0 20px 40px -20px rgba(46, 35, 130, .3);
  }
  .hac-nav.is-visible { display: flex; }
  .hac-nav__list { flex-direction: column; align-items: stretch; gap: 0; }

  .hac-nav__item { flex-wrap: wrap; }
  .hac-page .hac-nav__link { flex: 1; padding: 15px 4px; font-size: 1rem; }
  .hac-nav__item--mega > .hac-nav__link .hac-chev { display: none; }
  .hac-nav__toggle {
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 48px; width: 48px; height: 48px;
    border-radius: 10px; padding: 0;
  }
  .hac-nav__toggle .hac-chev { transform: rotate(45deg) translate(-2px, -2px); }
  .hac-nav__item.is-open .hac-nav__toggle { background: var(--hac-violet-10); }
  .hac-nav__item.is-open .hac-nav__toggle .hac-chev { transform: rotate(-135deg) translate(-2px, -2px); }

  .hac-page .hac-nav__cta { margin: 14px 0 0; text-align: center; }

  /* Nur das im Markup verbliebene Panel wird zum Akkordeon.
     Ein ausgehängtes Panel bleibt fixiert. */
  .hac-mega:not(.hac-mega--detached) {
    position: static;
    opacity: 1; visibility: visible; transform: none;
    box-shadow: none; border-top: 0;
    display: none;
    width: 100%;
  }
  .hac-nav__item.is-open .hac-mega:not(.hac-mega--detached) { display: block; }
  .hac-mega__inner { padding: 4px 0 20px; }
  .hac-mega__grid { grid-template-columns: 1fr; gap: 22px; }
  .hac-mega__col--panel { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .hac-page * { transition: none !important; }
}

/* Hinweis für Redakteure, wenn kein Menü zugewiesen ist */
.hac-mm-hint {
  font-family: 'Montserrat', sans-serif;
  background: #fff4c7; border-left: 4px solid #ffdd00;
  padding: 12px 16px; margin: 0;
}

/* ============================================================
   Übernahme-Modus
   Das Menü wird an der Menüposition des Themes ausgegeben.
   Das Panel wird per JavaScript aus der Theme-Navigation gelöst und
   direkt an <body> gehängt — sonst greifen Theme-Regeln für
   verschachtelte Navigationslisten (Off-Canvas, flex, Breitenlimits).
   ============================================================ */

.hac-page--inline { display: contents; }
.hac-page--inline .hac-nav__item { position: static; }
.hac-page--inline .hac-chev { display: inline-block; margin-left: 8px; }
.hac-page--inline .hac-nav__toggle { color: inherit; }

/* Aufnahmecontainer am Seitenende */
.hac-mega-host { position: static; }

.hac-mega--detached {
  position: fixed;
  left: 0;
  right: 0;
  top: 0; /* JS setzt die Unterkante des Headers */
  z-index: 99990;
  background: #fff;
  border-top: 1px solid var(--hac-grey-10);
  box-shadow: 0 24px 48px -20px rgba(46, 35, 130, .28);
  max-height: 82vh;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.hac-mega--detached.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .hac-mega--detached .hac-mega__inner { padding: 28px 20px 32px; }
  .hac-mega--detached .hac-mega__grid { grid-template-columns: 1fr; gap: 22px; }
}
