/* Chooser de rubro del CTA del hero (popover desktop / bottom sheet mobile). */

.hero:has(.hero-rubro-chooser.is-open) {
  overflow: visible;
}

/* La animación de .hero-visual crea un stacking context posterior en el DOM
   y tapaba el panel (position:fixed queda atrapado en .hero-content). */
.hero:has(.hero-rubro-chooser) .hero-text {
  position: relative;
  z-index: 2;
}

.hero:has(.hero-rubro-chooser) .hero-visual {
  z-index: 0;
}

/* fadeInUp + fill-mode:both deja transform en .hero-actions y convierte
   position:fixed del sheet en coords del botón (no del viewport). */
.hero:has(.hero-rubro-chooser) .hero-actions {
  animation-name: fadeIn;
}

.hero-rubro-chooser {
  position: relative;
}

.hero-rubro-trigger {
  font-family: inherit;
  white-space: normal;
}

.hero-rubro-chevron {
  flex-shrink: 0;
  margin-left: var(--spacing-sm);
  transition: transform var(--transition-fast);
}

.hero-rubro-chooser.is-open .hero-rubro-chevron {
  transform: rotate(180deg);
}

.hero-rubro-panel {
  position: absolute;
  top: auto;
  right: auto;
  bottom: calc(100% + var(--spacing-sm));
  left: 0;
  z-index: var(--z-popover);
  width: max-content;
  min-width: 520px;
  max-width: min(640px, calc(100vw - var(--spacing-2xl)));
  padding: var(--spacing-md);
  background-color: var(--bg-white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
}

.hero-rubro-panel:focus {
  outline: none;
}

.hero-rubro-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.hero-rubro-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.hero-rubro-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm);
  border: 0;
  border-radius: var(--border-radius-md);
  background: transparent;
  cursor: pointer;
}

.hero-rubro-close:hover {
  background-color: var(--gray-50);
}

.hero-rubro-close:focus {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.hero-rubro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--spacing-xs);
}

.hero-rubro-link {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
  color: var(--text-default);
  text-decoration: none;
  font-weight: 500;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.hero-rubro-link:hover {
  background-color: var(--gray-50);
  color: var(--blue-700);
}

.hero-rubro-link:focus {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.hero-rubro-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.hero-rubro-fallback {
  display: block;
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--gray-200);
  color: var(--text-muted);
  text-align: center;
  text-decoration: none;
  font-weight: 500;
}

.hero-rubro-fallback:hover {
  color: var(--blue-700);
}

.hero-rubro-fallback:focus {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.hero-rubro-secondary {
  align-self: center;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hero-rubro-secondary:hover {
  color: var(--blue-700);
}

.hero-rubro-backdrop {
  display: none;
}

html.hero-rubro-open,
body.hero-rubro-open {
  overflow: hidden;
}

body.hero-rubro-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

@media (max-width: 768px) {
  .hero-actions .hero-rubro-chooser,
  .hero-actions .hero-rubro-chooser .btn {
    width: 100%;
    max-width: 100%;
  }

  /* body.hero-rubro-open: el overlay se mueve a body en mobile (home.js). */
  .hero-rubro-chooser.is-open .hero-rubro-backdrop,
  body.hero-rubro-open .hero-rubro-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal-backdrop);
    background-color: var(--gray-900);
    opacity: 0.4;
  }

  .hero-rubro-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-rubro-panel {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: 80vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-xl);
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
    z-index: var(--z-modal);
  }
}
