/* ==========================================================================
   HEADER / MENÚ PRINCIPAL
   Un solo markup para escritorio y responsive.
   ========================================================================== */

.sh {
  --sh-green: var(--color-verde);
  --sh-ink: #1d1d1b;
  --sh-muted: #9d9d9c;
  --sh-line: #dedede;
  --sh-gray: #ededed;
  --sh-celeste: var(--color-celeste);
  --sh-topbar-h: 46px;
  --sh-radius: 8px;
  --sh-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
  --sh-font: "CircularStd", sans-serif;

  position: relative;
  z-index: 100;
  background: #fff;
  color: var(--sh-ink);
  font-family: var(--sh-font);
}

/* ==========================================================================
   FRANJA SUPERIOR
   ========================================================================== */

.sh-topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--sh-topbar-h);
  padding: 0 16px;
  background: var(--sh-celeste);
}

.sh-topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  transition: opacity 0.2s ease;
}

.sh-topbar__link:hover {
  color: #fff;
  opacity: 0.8;
}

.sh-topbar__flag {
  display: block;
  width: 16px;
  height: 28px;
  flex: none;
}

/* ==========================================================================
   HEADER PRINCIPAL
   ========================================================================== */

.sh-main-wrap {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.sh-main {
  padding-top: clamp(16px, 2.2vw, 34px);
  padding-bottom: clamp(14px, 1.8vw, 26px);
}

.sh-main__grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(220px, 437px) auto;
  align-items: center;
  gap: 18px;
}

.sh-logo {
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  line-height: 0;
}

.sh-logo img {
  display: block;
  width: auto;
  height: clamp(60px, 6.1vw, 88px);
  filter: brightness(0);
  transition: opacity 0.2s ease;
}

.sh-logo:hover img {
  opacity: 0.72;
}

/* BUSCADOR */
.sh-search {
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 437px;
  height: 40px;
  padding: 0 16px;
  background: var(--sh-gray);
  border-radius: 999px;
  justify-self: end;
  transition: box-shadow 0.2s ease;
}

.sh-search:focus-within {
  box-shadow: 0 0 0 2px rgba(65, 172, 77, 0.28);
}

.sh-search__submit {
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sh-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.sh-search__submit:hover {
  color: var(--sh-green);
}

.sh-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sh-ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  outline: none;
}

.sh-search__input::placeholder {
  color: var(--sh-muted);
  opacity: 1;
}

/* BOTONES */
.sh-actions {
  grid-column: 4;
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.sh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--sh-green);
  border-radius: 999px;
  color: var(--sh-ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sh-btn:hover {
  background: var(--sh-green);
  color: #fff;
}

.logged-in .sh-btn.is-pending {
  border-color: #e11;
  color: #e11;
}

.logged-in .sh-btn.is-pending:hover {
  background: #e11;
  color: #fff;
}

/* HAMBURGUESA */
.sh-burger {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.sh-burger span {
  display: block;
  width: 26px;
  height: 2.5px;
  background: var(--sh-ink);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ==========================================================================
   NAVEGACIÓN ESCRITORIO
   ========================================================================== */

.sh-nav {
  --sh-nav-gap: clamp(16px, 1.8vw, 22px);
  position: relative;
  padding-bottom: var(--sh-nav-gap);
}

.sh-nav-wrap {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.sh-nav__mobile-head {
  display: none;
}

.sh-nav__container {
  position: relative;
}

.sh-menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.4vw, 26px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sh-menu__item {
  position: relative;
}

/* Nivel 1 */
.sh-menu__item--level-1 > .sh-menu__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--sh-ink);
  font-family: inherit;
  font-size: clamp(15px, 1.4vw, 20px);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s ease;
}

.sh-menu__item--level-1:hover > .sh-menu__toggle,
.sh-menu__item--level-1:focus-within > .sh-menu__toggle,
.sh-menu__item--level-1.is-open > .sh-menu__toggle {
  color: var(--sh-green);
}

/* Caret */
.sh-menu__caret {
  display: block;
  flex: none;
  width: 12px;
  height: 8px;
  transition: transform 0.2s ease;
}

/* Submenús */
.sh-submenu {
  position: absolute;
  top: calc(100% + var(--sh-nav-gap, 24px));
  left: 0;
  z-index: 20;
  width: max-content;
  min-width: 184px;
  max-width: 260px;
  margin: 0;
  padding: 10px 0;
  list-style: none;
  background: #fff;
  border-radius: var(--sh-radius);
  box-shadow: var(--sh-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

/* Puente para no perder el hover en el espacio entre niveles */
.sh-menu__item--level-1 > .sh-submenu::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--sh-nav-gap, 24px));
  left: 0;
  right: 0;
  height: var(--sh-nav-gap, 24px);
}

.sh-menu__item--level-2 > .sh-submenu::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -10px;
  width: 10px;
}

/* Nivel 2 */
.sh-menu__item--level-2 > .sh-menu__toggle,
.sh-menu__item--level-2 > .sh-menu__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--sh-ink);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  cursor: pointer;
  transition: color 0.2s ease;
}

.sh-menu__item--level-2 > .sh-menu__toggle:hover,
.sh-menu__item--level-2 > .sh-menu__link:hover,
.sh-menu__item--level-2:hover > .sh-menu__toggle,
.sh-menu__item--level-2:hover > .sh-menu__link,
.sh-menu__item--level-2:focus-within > .sh-menu__toggle,
.sh-menu__item--level-2.is-open > .sh-menu__toggle {
  color: var(--sh-green);
}

.sh-menu__item--level-2 > .sh-menu__toggle .sh-menu__caret {
  transform: rotate(-90deg);
}

/* Nivel 3 */
.sh-submenu--level-3 {
  top: -10px;
  left: calc(100% + 8px);
  min-width: 184px;
  max-width: 360px;
}

.sh-menu__item--level-3 > .sh-menu__link {
  display: block;
  padding: 10px 16px;
  color: var(--sh-ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  transition: color 0.2s ease;
}

.sh-menu__item--level-3 > .sh-menu__link:hover {
  color: var(--sh-green);
}

/* Mostrar submenús */
.sh-menu__item--level-1:hover > .sh-submenu,
.sh-menu__item--level-1:focus-within > .sh-submenu,
.sh-menu__item--level-2:hover > .sh-submenu,
.sh-menu__item--level-2:focus-within > .sh-submenu,
.sh-menu__item.is-open > .sh-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Flip para no salir de pantalla */
.sh-menu__item--level-1 > .sh-submenu.is-flipped {
  left: auto;
  right: 0;
}

.sh-menu__item--level-2 > .sh-submenu.is-flipped {
  left: auto;
  right: calc(100% + 8px);
}

.sh-menu__item--level-2 > .sh-submenu.is-flipped::before {
  left: auto;
  right: -10px;
}

.sh-menu__item--level-2 > .sh-submenu.is-flipped-y {
  top: auto;
  bottom: -10px;
}

/* Medición temporal para el flip */
.sh-submenu.is-measuring {
  display: block !important;
  visibility: hidden !important;
}

/* En escritorio el flyout de nivel 3 no existe hasta que se abre,
   así no aporta ancho al documento cuando está cerrado. */
@media (min-width: 992px) {
  .sh-menu__item--level-1 > .sh-submenu,
  .sh-menu__item--level-2 > .sh-submenu {
    display: none;
  }

  .sh-menu__item--level-1:hover > .sh-submenu,
  .sh-menu__item--level-1:focus-within > .sh-submenu,
  .sh-menu__item--level-1.is-open > .sh-submenu,
  .sh-menu__item--level-2:hover > .sh-submenu,
  .sh-menu__item--level-2:focus-within > .sh-submenu,
  .sh-menu__item--level-2.is-open > .sh-submenu {
    display: block;
  }
}

/* Links pendientes: solo visibles para usuarios logueados */
.logged-in .sh-menu__link.is-pending,
.logged-in .sh-menu__link.is-pending:hover {
  color: #e11 !important;
}

/* Respaldo: si algo pendiente se renderiza sin sesión, se oculta */
body:not(.logged-in) .is-pending {
  display: none !important;
}

/* Foco */
.sh a:focus-visible,
.sh button:focus-visible {
  outline: 2px solid var(--sh-green);
  outline-offset: 3px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 991.98px) {

  .sh-main__grid {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "logo search burger"
      "logo actions actions";
    align-items: center;
    gap: 10px 12px;
  }

  .sh-logo {
    grid-area: logo;
    align-self: center;
  }

  .sh-search {
    grid-area: search;
    width: 100%;
    max-width: none;
  }

  .sh-actions {
    grid-area: actions;
    justify-self: start;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .sh-burger {
    display: flex;
    grid-area: burger;
    align-self: start;
    margin-top: -2px;
  }

  /* PANEL */
  .sh-nav {
    position: fixed;
    top: var(--sh-topbar-h);
    right: 0;
    bottom: 0;
    z-index: 300;
    width: min(522px, calc(100% - 18px));
    padding: 0;
    background: #fff;
    box-shadow: -12px 0 30px rgba(0, 0, 0, 0.14);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.3s ease, visibility 0.3s ease;
  }

  .sh-nav.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .sh-nav__mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 10px;
  }

  .sh-logo--mobile img {
    height: 64px;
  }

  .sh-close {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--sh-ink);
    cursor: pointer;
  }

  .sh-nav__container {
    width: 100%;
    max-width: none;
    padding: 0 18px 40px;
  }

  .sh-nav-wrap {
    padding-left: 0;
    padding-right: 0;
  }

  /* LISTA EN ACORDEÓN */
  .sh-menu {
    display: block;
  }

  .sh-menu__item {
    position: static;
    border-bottom: 1px solid var(--sh-line);
  }

  .sh-menu__item--level-1 {
    border-bottom: 1px solid var(--sh-line);
  }

  .sh-menu__item--level-1 > .sh-menu__toggle {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    font-size: clamp(26px, 5.2vw, 30px);
    line-height: 1.1;
    text-align: left;
    white-space: normal;
  }

  .sh-menu__item--level-2 > .sh-menu__toggle,
  .sh-menu__item--level-2 > .sh-menu__link {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    font-size: clamp(21px, 4.4vw, 26px);
    line-height: 1.15;
    text-align: left;
    white-space: normal;
  }

  .sh-menu__item--level-3 > .sh-menu__link {
    display: block;
    padding: 10px 0;
    font-size: clamp(18px, 3.7vw, 20px);
    font-weight: 400;
    line-height: 1.2;
  }

  .sh-menu__item--level-3:last-child {
    border-bottom: 0;
  }

  /* Submenú como acordeón */
  .sh-submenu {
    position: static;
    display: none;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0 0 0 18px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
  }

  .sh-menu__item.is-open > .sh-submenu {
    display: block;
  }

  .sh-menu__item--level-1.is-open > .sh-menu__toggle,
  .sh-menu__item--level-2.is-open > .sh-menu__toggle {
    color: var(--sh-green);
  }

  .sh-menu__caret {
    transform: rotate(0deg);
  }

  .sh-menu__item--level-2 > .sh-menu__toggle .sh-menu__caret {
    transform: rotate(0deg);
  }

  .sh-menu__item.is-open > .sh-menu__toggle .sh-menu__caret {
    transform: rotate(180deg);
  }

  .sh-submenu::before {
    display: none;
  }

  /* Fondo y bloqueo */
  .sh-backdrop {
    position: fixed;
    top: var(--sh-topbar-h);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 250;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .sh-backdrop.is-open {
    opacity: 1;
    visibility: visible;
  }

  /* La franja queda visible mientras el panel está abierto */
  .sh-menu-open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    overflow: hidden;
  }

  .sh-menu-open .sh {
    padding-top: var(--sh-topbar-h);
  }

  .sh-menu-open .sh-main {
    visibility: hidden;
  }

  .sh-menu-open .sh-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 400;
  }
}

@media (max-width: 479.98px) {

  .sh-main__grid {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "logo burger"
      "search search"
      "actions actions";
  }

  .sh-logo {
    grid-area: logo;
  }

  .sh-search {
    grid-area: search;
  }

  .sh-actions {
    grid-area: actions;
    justify-content: flex-start;
  }

  .sh-burger {
    grid-area: burger;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sh *,
  .sh *::before,
  .sh *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
