/*
 * Header navigation: desktop megamenu and mobile accordion.
 * Uses the theme tokens from vite-base.css and typography.css (colors, radius, gradient, type scale).
 */

[x-cloak] {
  display: none !important;
}

/* Sticky tool tabs sit right under the sticky header instead of sliding beneath it.
   --hipotuca-header-h is measured by assets/js/header-nav.js; the fallback matches the default header. */
@media (min-width: 768px) {
  .hipotuca-simuladores .simulator-tabs-bar,
  .hipotuca-calculadoras .calculator-tabs-bar {
    top: var(--hipotuca-header-h, 88px) !important;
  }
}

/* ---------- Desktop triggers ---------- */

#hipotuca-site-header .hipotuca-nav__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
  border: 0 !important;
  border-radius: 0;
  background: none !important;
  box-shadow: none !important;
  cursor: pointer;
}

#hipotuca-site-header .hipotuca-nav__trigger:focus-visible,
#hipotuca-site-header .hipotuca-mnav__trigger:focus-visible,
#hipotuca-site-header .hipotuca-mega a:focus-visible,
#hipotuca-site-header .hipotuca-mega button:focus-visible {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 3px;
  border-radius: 6px;
}

#hipotuca-site-header .hipotuca-nav__chevron {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

#hipotuca-site-header [aria-expanded="true"] > .hipotuca-nav__chevron {
  transform: rotate(180deg);
}

#hipotuca-site-header .hipotuca-nav__trigger[aria-expanded="true"]:not(.font-bold) {
  color: hsl(var(--foreground)) !important;
}

/* ---------- Desktop panel ---------- */

/* Positioned against the sticky header, centred on the page frame like .site-container. */
#hipotuca-site-header .hipotuca-mega {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 2;
  width: calc(100% - (var(--layout-page-gutter) * 2));
  max-width: var(--layout-max-width);
  max-height: calc(100vh - var(--hipotuca-header-h, 88px) - 1rem);
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-top: 0;
  border-radius: 0 0 calc(var(--radius) + 0.5rem) calc(var(--radius) + 0.5rem);
  box-shadow: 0 20px 60px rgba(34, 28, 55, 0.18);
}

.hipotuca-nav-shade {
  position: fixed;
  top: var(--hipotuca-header-h, 88px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: hsl(var(--foreground) / 0.18);
}

@media (max-width: 767px) {
  .hipotuca-nav-shade {
    display: none !important;
  }
}

.hipotuca-mega__body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  padding: 28px;
}

.hipotuca-mega__intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  padding: 22px;
  border-radius: var(--radius);
  background: hsl(var(--background));
}

.hipotuca-mega__intro-icon,
.hipotuca-mega__tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--primary));
}

.hipotuca-mega__intro-icon {
  width: 44px;
  height: 44px;
}

.hipotuca-mega__intro-icon svg {
  width: 22px;
  height: 22px;
}

.hipotuca-mega__eyebrow,
.hipotuca-mega__group-title,
.hipotuca-mnav__group-title {
  font-size: var(--type-small-size) !important;
  line-height: var(--type-small-line-height) !important;
}

.hipotuca-mega__title {
  margin-top: 6px !important;
}

.hipotuca-mega__desc {
  margin-top: 8px !important;
  font-size: var(--type-small-size) !important;
  line-height: var(--type-small-line-height) !important;
}

#hipotuca-site-header .hipotuca-mega__section-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  font-weight: 700;
}

.hipotuca-mega__section-link svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.hipotuca-mega__section-link:hover svg {
  transform: translateX(3px);
}

.hipotuca-mega__groups {
  display: grid;
  grid-template-columns: repeat(var(--hipotuca-mega-cols, 2), minmax(0, 1fr));
  gap: 22px;
  align-content: start;
}

.hipotuca-mega__group-title {
  padding: 0 10px 10px;
  margin-bottom: 6px !important;
  border-bottom: 1px solid hsl(var(--border));
}

.hipotuca-mega__tools {
  display: grid;
  gap: 2px;
}

/* The parent theme gives list items bullets and margins. */
#hipotuca-site-header .hipotuca-mega__tools,
#hipotuca-site-header .hipotuca-mnav__tools {
  margin-left: 0 !important;
  padding: 0 !important;
}

#hipotuca-site-header .hipotuca-mega__tools > li,
#hipotuca-site-header .hipotuca-mnav__tools > li {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

#hipotuca-site-header .hipotuca-mega__tool {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  transition: background-color 0.15s ease;
}

#hipotuca-site-header .hipotuca-mega__tool:hover,
#hipotuca-site-header .hipotuca-mega__tool.is-current {
  background: hsl(var(--background));
}

.hipotuca-mega__tool-icon {
  width: 40px;
  height: 40px;
}

.hipotuca-mega__tool-icon svg {
  width: 20px;
  height: 20px;
}

.hipotuca-mega__tool-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hipotuca-mega__tool-label {
  font-weight: 700;
}

.hipotuca-mega__tool.is-current .hipotuca-mega__tool-label {
  color: hsl(var(--primary)) !important;
}

.hipotuca-mega__tool-desc {
  font-size: var(--type-small-size) !important;
  line-height: var(--type-small-line-height) !important;
}

.hipotuca-mega__tool-arrow {
  width: 18px;
  height: 18px;
  color: hsl(var(--muted-foreground));
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.hipotuca-mega__tool:hover .hipotuca-mega__tool-arrow,
.hipotuca-mega__tool:focus-visible .hipotuca-mega__tool-arrow {
  opacity: 1;
  transform: none;
}

.hipotuca-mega__badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px !important;
  line-height: 18px !important;
  font-weight: 700;
  vertical-align: middle;
}

.hipotuca-mega__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}

.hipotuca-mega__reassurance {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--type-small-size) !important;
  line-height: var(--type-small-line-height) !important;
}

.hipotuca-mega__reassurance svg {
  width: 18px;
  height: 18px;
  color: hsl(var(--primary));
}

.hipotuca-mega__dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: hsl(var(--muted-foreground) / 0.5);
}

#hipotuca-site-header .hipotuca-mega__cross {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
  font-size: var(--type-small-size) !important;
  line-height: var(--type-small-line-height) !important;
  cursor: pointer;
}

.hipotuca-mega__cross svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 1439px) {
  .hipotuca-mega__body {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 20px;
    padding: 22px;
  }

  .hipotuca-mega__groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1023px) {
  .hipotuca-mega__body {
    grid-template-columns: 1fr;
  }

  .hipotuca-mega__intro {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
  }

  .hipotuca-mega__intro .hipotuca-mega__desc {
    display: none;
  }

  #hipotuca-site-header .hipotuca-mega__section-link {
    margin-top: 0;
  }
}

/* Panel enter/leave, driven by x-transition classes in header.php. */
.hipotuca-mega-enter,
.hipotuca-mega-leave {
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.hipotuca-mega-from {
  opacity: 0;
}

.hipotuca-mega.hipotuca-mega-from {
  transform: translateY(-6px);
}

.hipotuca-mega-to {
  opacity: 1;
}

/* ---------- Mobile accordion ---------- */

/* The menu lives inside the sticky header: let it scroll on short screens (88px = logo bar). */
#hipotuca-mobile-nav {
  max-height: calc(100vh - 88px);
  max-height: calc(100dvh - 88px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#hipotuca-site-header .hipotuca-mnav__trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
  text-align: left;
  cursor: pointer;
}

.hipotuca-mnav__panel {
  margin-top: 12px;
  padding: 4px 0 4px 14px;
  border-left: 2px solid hsl(var(--border));
}

.hipotuca-mnav__group-title {
  margin-top: 12px !important;
}

.hipotuca-mnav__group-title:first-child {
  margin-top: 0 !important;
}

.hipotuca-mnav__tools {
  display: grid;
  gap: 2px;
  margin-top: 6px !important;
}

#hipotuca-site-header .hipotuca-mnav__tool {
  display: block;
  padding: 6px 0;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  #hipotuca-site-header .hipotuca-nav__chevron,
  .hipotuca-mega-enter,
  .hipotuca-mega-leave,
  .hipotuca-mega__tool,
  .hipotuca-mega__tool-arrow,
  .hipotuca-mega__section-link svg {
    transition: none !important;
  }

  .hipotuca-mega.hipotuca-mega-from,
  .hipotuca-mega__section-link:hover svg,
  .hipotuca-mega__tool-arrow {
    transform: none !important;
  }
}
