/**
 * @file
 * Header Slider — carousel horizontal de cards.
 *
 * Desktop (≥ 768px): rail vertical de iconos + 3 cards visibles (hero
 *   42% + 2 secundarias 27% c/u) + flechas prev/next. Las cards animan
 *   por left/width.
 *
 * Mobile (< 768px): rail y flechas ocultos. Las cards en scroll-snap
 *   horizontal nativo (gesto táctil), una y media visible a la vez.
 *
 * Variables CSS:
 *   --rk-brand / --rk-accent — del BrandResolver (host actual).
 *   --c1 / --c2 — gradiente por card (configurable por el editor).
 *   --bg — URL de la imagen de fondo de la card (opcional).
 */

/* ---- Scope --------------------------------------------------------- */
.hs {
  --rk-brand: #e6196b;
  --rk-accent: #ffd84d;
  /* Espacio arriba para no colisionar con navbars fixed-top. En webscasinos
     el navbar oscuro tapa ~60px del top; con 80px dejamos respiro. Los
     proyectos sin navbar fija pueden overridear con:
       .hs { --hs-top-clear: 20px; }                                    */
  --hs-top-clear: 80px;

  position: relative;
  width: 100%;
  max-width: 1340px;
  margin: 0 auto;
  padding: var(--hs-top-clear) 14px 22px;
  font-family: inherit;
  color: #14101a;
  box-sizing: border-box;
}
.hs *, .hs *::before, .hs *::after { box-sizing: border-box; }

/* ============================================================
   DESKTOP (≥ 768 px)
   ============================================================ */
@media (min-width: 768px) {

  .hs {
    display: grid;
    grid-template-columns: 64px 1fr;
    grid-template-areas:
      "rail carousel"
      "rail arrows";
    column-gap: 14px;
    row-gap: 12px;
  }

  /* ---- Rail vertical de iconos ----------------------------------- */
  .hs__rail {
    grid-area: rail;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #ebe6ee;
    align-self: start;
  }
  .hs__rail-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: color-mix(in srgb, var(--c1, var(--rk-brand)) 12%, transparent);
    color: var(--c2, var(--rk-brand));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
  }
  .hs__rail-btn i { font-size: 16px; line-height: 1; }
  .hs__rail-btn:hover { transform: translateY(-1px); }
  .hs__rail-btn.is-active {
    background: var(--rk-brand);
    color: #fff;
  }

  /* ---- Carousel -------------------------------------------------- */
  .hs__carousel {
    grid-area: carousel;
    position: relative;
    height: 360px;
    /* overflow:hidden recorta las cards en offL/offR para que NO se
       extiendan visualmente sobre el rail (que está en la otra columna
       del grid). Sin esto, una card invisible (opacity:0) sentada en
       left:-32% recibía los clicks del rail. */
    overflow: hidden;
    border-radius: 22px;
  }

  .hs__card {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 14px 28px rgba(20,16,26,0.10);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff !important;
    text-decoration: none !important;
    isolation: isolate;
    transition: left 0.5s cubic-bezier(.2,.8,.2,1),
                width 0.5s cubic-bezier(.2,.8,.2,1),
                opacity 0.35s ease;
    will-change: left, width;
    cursor: pointer;
  }
  .hs__card.is-no-transition { transition: none !important; }
  .hs__card:hover { color: #fff !important; text-decoration: none !important; }
  /* Belt-and-suspenders: las cards "is-hidden" (offL/offR) no aceptan
     clicks aunque el overflow:hidden ya las recorta. */
  .hs__card.is-hidden { pointer-events: none; }

  /* Background image (z-0). */
  .hs__card-bg {
    position: absolute; inset: 0;
    background-image: var(--bg);
    background-size: cover;
    background-position: center;
    z-index: 0;
  }
  /* Brand tint (z-1) — gradiente por card. */
  .hs__card-tint {
    position: absolute; inset: 0;
    background: linear-gradient(160deg, var(--c1) 0%, var(--c2) 100%);
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
  }
  /* Si hay imagen, bajamos opacidad del tint para que la imagen respire. */
  .hs__card[style*="--bg"] .hs__card-tint { opacity: 0.55; }

  /* Shade inferior para legibilidad del título (z-2). */
  .hs__card-shade {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
    z-index: 2;
  }

  /* Contenido (z-3). */
  .hs__card-eyebrow,
  .hs__card-deco,
  .hs__card-bottom {
    position: absolute;
    z-index: 3;
  }

  .hs__card-eyebrow {
    top: 16px; left: 16px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.92);
    color: var(--c2);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .hs__card-deco {
    right: -8px; bottom: -8px;
    width: 130px; height: 130px;
    border-radius: 999px;
    background: rgba(255,255,255,0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: width 0.45s cubic-bezier(.2,.8,.2,1),
                height 0.45s cubic-bezier(.2,.8,.2,1);
  }
  .hs__card-deco i { font-size: 52px; color: #fff; line-height: 1; }

  .hs__card.is-sm .hs__card-deco { width: 96px; height: 96px; }
  .hs__card.is-sm .hs__card-deco i { font-size: 40px; }

  /* Logo overlay: cuando la card tiene logo_url, el deco-icon FA se
     oculta y aparece el logo centrado y en blanco (filter CSS).
     Inspirado en .bono-card__overlay-logo de custom.css. */
  .hs__card.has-logo .hs__card-deco { display: none; }
  .hs__card-logo {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
    width: 60%;
    max-width: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .hs__card-logo img {
    width: 100%;
    max-height: 80px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.92;
  }
  .hs__card.is-sm .hs__card-logo {
    width: 70%;
    max-width: 130px;
  }
  .hs__card.is-sm .hs__card-logo img { max-height: 50px; }

  .hs__card-bottom {
    bottom: 18px; left: 18px; right: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
  }

  /* h3 con !important para neutralizar estilos agresivos del theme. */
  .hs__card-title {
    margin: 0 !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    text-transform: uppercase !important;
    color: #fff !important;
    font-size: 26px !important;
    max-width: 60%;
    transition: font-size 0.45s ease, max-width 0.45s ease;
  }
  .hs__card.is-sm .hs__card-title {
    font-size: 18px !important;
    max-width: 70%;
  }
  /* Neutralizar pseudos del theme (subrayados, líneas…). */
  .hs__card-title::before,
  .hs__card-title::after { content: none !important; display: none !important; }

  .hs__card-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff;
    color: var(--c2);
    font-size: 13px;
    font-weight: 800;
    width: fit-content;
    pointer-events: auto;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  }
  .hs__card-cta i { font-size: 10px; }
  .hs__card:hover .hs__card-cta {
    transform: translateY(-1px);
    background: var(--rk-brand);
    color: #fff;
    box-shadow: 0 6px 16px rgba(230,25,107,0.30);
  }
  .hs__card.is-sm .hs__card-cta-label { display: none; }
  .hs__card.is-sm .hs__card-cta { padding: 8px 10px; }

  /* ---- Flechas prev / next --------------------------------------- */
  .hs__arrows {
    grid-area: arrows;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-right: 4px;
  }
  .hs__arrow {
    width: 38px; height: 38px;
    border-radius: 999px;
    border: 1px solid #ebe6ee;
    background: #fff;
    color: #14101a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .hs__arrow i { font-size: 14px; line-height: 1; }
  .hs__arrow:hover {
    background: var(--rk-brand);
    color: #fff;
    border-color: var(--rk-brand);
  }

}  /* fin desktop */


/* ============================================================
   MOBILE (< 768 px) — scroll horizontal nativo
   ============================================================ */
@media (max-width: 767.98px) {

  /* En mobile el navbar es más bajo, así que recortamos el padding top
     que dejamos para librar el navbar fixed. Si lo necesitas más/menos
     en tu proyecto, overridea con `.hs { --hs-top-clear: Npx; }` desde
     un media query a nivel de site. */
  .hs { --hs-top-clear: 20px; }

  /* Sin display:flex en .hs — el orden HTML (carousel primero, rail
     después en el twig) ya pone el rail debajo del carousel. Eso
     evita que las cards cambien de tamaño por sizing de flex. */
  .hs__arrows { display: none; }

  /* Rail mobile: fila horizontal centrada de iconos pequeños debajo
     del scroll de cards. Cliquearlos hace scrollTo a la card. */
  .hs__rail {
    display: flex;
    flex-direction: row;
    gap: 8px;
    justify-content: center;
    align-items: center;
    padding: 12px 8px 4px;
    background: transparent;
    border: none;
  }
  .hs__rail-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: color-mix(in srgb, var(--c1, var(--rk-brand)) 14%, transparent);
    color: var(--c2, var(--rk-brand));
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    padding: 0;
  }
  .hs__rail-btn i { font-size: 13px; line-height: 1; }
  .hs__rail-btn:hover { transform: translateY(-1px); }
  .hs__rail-btn.is-active {
    background: var(--rk-brand);
    color: #fff;
  }

  .hs__carousel {
    position: relative;
    height: auto;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 4px 16px 18px;
    margin: 0 -14px;
    scrollbar-width: none;
  }
  .hs__carousel::-webkit-scrollbar { display: none; }

  .hs__card {
    position: relative;
    flex: 0 0 82vw;
    max-width: 320px;
    height: 280px;
    scroll-snap-align: start;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 24px rgba(20,16,26,0.18);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff !important;
    text-decoration: none !important;
    isolation: isolate;
    cursor: pointer;
  }

  .hs__card-bg {
    position: absolute; inset: 0;
    background-image: var(--bg);
    background-size: cover;
    background-position: center;
    z-index: 0;
  }
  .hs__card-tint {
    position: absolute; inset: 0;
    background: linear-gradient(160deg, var(--c1) 0%, var(--c2) 100%);
    z-index: 1;
  }
  .hs__card[style*="--bg"] .hs__card-tint { opacity: 0.55; }
  .hs__card-shade {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(0,0,0,0.55) 100%);
    z-index: 2;
  }

  .hs__card-eyebrow,
  .hs__card-deco,
  .hs__card-bottom {
    position: absolute;
    z-index: 3;
  }

  .hs__card-eyebrow {
    top: 12px; left: 12px;
    padding: 3px 8px;
    border-radius: 5px;
    background: rgba(255,255,255,0.92);
    color: var(--c2);
    font-family: inherit;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .hs__card-deco {
    right: -6px; bottom: -6px;
    width: 100px; height: 100px;
    border-radius: 999px;
    background: rgba(255,255,255,0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
  }
  .hs__card-deco i { font-size: 40px; color: #fff; line-height: 1; }

  /* Logo overlay en mobile — igual lógica que desktop, dimensiones
     ajustadas a la card de 280px de alto. */
  .hs__card.has-logo .hs__card-deco { display: none; }
  .hs__card-logo {
    position: absolute;
    top: 38%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
    width: 65%;
    max-width: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .hs__card-logo img {
    width: 100%;
    max-height: 60px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.92;
  }

  .hs__card-bottom {
    bottom: 14px; left: 14px; right: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .hs__card-title {
    margin: 0 !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    text-transform: uppercase !important;
    color: #fff !important;
    font-size: 20px !important;
    max-width: 70%;
  }
  .hs__card-title::before,
  .hs__card-title::after { content: none !important; display: none !important; }

  .hs__card-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #fff;
    color: var(--c2);
    font-size: 12px;
    font-weight: 800;
    width: fit-content;
  }
  .hs__card-cta i { font-size: 9px; }

}  /* fin mobile */
