/* =========================================
   BackdropBanner – Frontend styles (v0.1)
   - BG ALWAYS 100vw (full viewport)
   - Track width controlled by layout class
========================================= */

/* =========================================
   ROOT / SECTION
========================================= */
.bbanner{
  position: relative;
  min-height: var(--bb-min-h, 520px);
  height: var(--bb-min-h, 520px);
  color: var(--bb-txt, #fff);

  /* track max width (layout modes) */
  --bb-content-w: 1400px;
}

/* =========================================
   FULL-WIDTH BACKGROUND (ALWAYS)
========================================= */
.bbanner__bg{
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 0;
  width: 100vw;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.bbanner__bgLayer{
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity calc(var(--bb-tms, 450) * 1ms) ease;
  will-change: opacity;
}

.bbanner__bgLayer.is-active{ opacity: 1; }

.bbanner__overlay{
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;

  /* Läsbarhets-gradient (default-läge) */
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.55) 0%,
    rgba(0,0,0,0.35) 25%,
    rgba(0,0,0,0.15) 30%,
    rgba(0,0,0,0.00) 50%
  );
}

/* =========================================
   TRACK
========================================= */
.bbanner__track{
  position: relative;
  z-index: 1;
  height: 100%;
  padding: 0;
  gap: 0;
  box-sizing: border-box;

  /* Desktop default = flex row */
  display: flex;
  align-items: stretch;
}

/* =========================================
   ITEM (base, shared)
========================================= */
.bbanner__item{
  position: relative;
  display: block;
  overflow: hidden;
  outline: none;
  border-radius: 0;
  text-decoration: none;
  color: inherit;
}

/* Hover/Active triggar glassmorph */
.bbanner__item:hover .bbanner__glass,
.bbanner__item.is-hover .bbanner__glass,
.bbanner__item.is-active .bbanner__glass{
  opacity: 1;
  transform: translateY(0);
  background: rgba(255,255,255,0.12);
}

.bbanner__glass{
  z-index: 1;
  position: absolute;
  inset: 0;

  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(var(--bb-blur, 18px));
  border-radius: 0;

  opacity: 0;
  transform: translateY(10px);
  transition: opacity 260ms ease, transform 260ms ease;
  pointer-events: none;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -1px 0 rgba(255,255,255,0.08);
}

/* Fallback om backdrop-filter saknas (behåll vit glass, inte svart) */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))){
  .bbanner__glass{ background: rgba(255,255,255,0.10); }
}

/* =========================================
   CONTENT
========================================= */
.bbanner__content{
  position: relative;
  z-index: 2;

  height: 100%;
  min-height: 0;
  box-sizing: border-box;

  padding: 18px;
  padding-bottom: calc(10px + -20px);

  display: flex;
  flex-direction: column;
  justify-content: flex-end;

  text-align: var(--bb-align, left);

  transform: translateY(16px);
  opacity: 0.92;
  transition: transform 260ms ease, opacity 260ms ease;
}

.bbanner__title{
  margin: 0;
  line-height: 1.2;
  font-weight: 500;

  text-shadow:
    0 1px 2px rgba(0,0,0,0.35),
    0 2px 6px rgba(0,0,0,0.25);

  /* Responsive: max comes from plugin var */
  color: var(--bb-title-color, inherit);
  font-size: clamp(16px, 4.2vw, var(--bb-title-size, 20px));
}

/* Desc är dold från start */
.bbanner__desc{
  margin: 10px 0 0 0;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transform: translateY(10px);
  transition: opacity 260ms ease, transform 260ms ease, max-height 260ms ease;

  text-shadow: 0 2px 6px rgba(0,0,0,.35);

  color: var(--bb-desc-color, inherit);
  font-size: clamp(13px, 3.6vw, var(--bb-desc-size, 14px));
}

/* CTA-bild (om du väljer bild i Style-panelen) */
.bbanner__ctaImage{
  width: 60%;
  height: 60%;
  object-fit: contain;
  display: block;
}

/* CTA från start: dold/nerflyttad */
.bbanner__cta{
  margin-top: 14px;
  width: var(--bb-cta-size, 46px);
  height: var(--bb-cta-size, 46px);
  border-radius: 999px;

  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 0;
  transform: translateY(10px);
  transition: transform 260ms ease, opacity 260ms ease;

  /* default align right */
  align-self: flex-end;
}

/* Left variant */
.bbanner--cta-left .bbanner__cta{
  align-self: flex-start;
}

/* Hover/Active “lyfter upp” content + visar desc + CTA */
.bbanner__item:hover .bbanner__content,
.bbanner__item.is-hover .bbanner__content,
.bbanner__item.is-active .bbanner__content{
  transform: translateY(0);
  opacity: 1;
}

.bbanner__item:hover .bbanner__desc,
.bbanner__item.is-hover .bbanner__desc,
.bbanner__item.is-active .bbanner__desc{
  opacity: 1;
  max-height: 140px;
  transform: translateY(0);
}

.bbanner__item:hover .bbanner__cta,
.bbanner__item.is-hover .bbanner__cta,
.bbanner__item.is-active .bbanner__cta{
  opacity: calc(var(--bb-cta, 1) * 1);
  transform: translateY(0);
}

/* =========================================
   LAYOUT MODES (track only)
========================================= */
.bbanner--layout-content .bbanner__track{
  max-width: var(--bb-content-w, 1400px);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.bbanner--layout-bg-full_track-content .bbanner__track{
  max-width: var(--bb-content-w, 1200px);
  margin-left: auto;
  margin-right: auto;
}

.bbanner--layout-full .bbanner__track{
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

/* =========================================
   DESKTOP ONLY (>= 901px)
   - flex layout details + separators
========================================= */
@media (min-width: 901px){

  .bbanner__item{
    flex: 1 1 0;
    min-width: 240px;
    height: 100%;
  }

  /* separators */
  .bbanner__item{
    border-left: 1px solid rgba(255,255,255,0.15);
    border-right: 1px solid rgba(255,255,255,0.15);
  }

  /* remove outer edges */
  .bbanner__item:first-child{ border-right: none; }
  .bbanner__item:last-child{ border-left: none; }
}

/* =========================================
   MOBILE ONLY (<= 900px)
   - 2x2 grid (no swipe)
   - 90dvh height via --bb-min-h
   - clamp + line-clamp rules
========================================= */
@media (max-width: 900px){

  .bbanner{
    height: var(--bb-min-h-mobile, var(--bb-min-h, 520px));
    min-height: var(--bb-min-h-mobile, var(--bb-min-h, 520px));
  }


  .bbanner__track{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, 1fr);
    gap: 0;
    height: 100%;

    overflow: visible;
    -webkit-overflow-scrolling: auto;
    scroll-snap-type: none;

    /* single outer frame (avoid double borders) */
    border: 1px solid rgba(255,255,255,0.15);
    box-sizing: border-box;
  }

  .bbanner__item{
    min-width: 0;
    height: auto;
    flex: none;

    border: 0;
    border-left: 1px solid rgba(255,255,255,0.15);
    border-top: 1px solid rgba(255,255,255,0.15);
    box-sizing: border-box;
  }

  /* first row: no top line */
  .bbanner__item:nth-child(-n+2){ border-top: 0; }

  /* left column: no left line */
  .bbanner__item:nth-child(odd){ border-left: 0; }

  /* make sure content can't force widths */
  .bbanner__track,
  .bbanner__item,
  .bbanner__content{
    min-width: 0;
      
  }

  /* prevent long words/urls from pushing layout */
  .bbanner__title,
  .bbanner__desc{
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* line clamps (keep stable cards) */
  .bbanner__title{
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; /* you said you want 3 lines */
    overflow: hidden;
  }

  .bbanner__desc{
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
    
    
    
  /* CTA ska inte ta plats i startläget */
  .bbanner__cta{
    width: 0;
    height: 0;
    margin-top: 0;
    padding: 0;
    overflow: hidden;
  }

  /* På hover/tap: återställ */
  .bbanner__item:hover .bbanner__cta,
  .bbanner__item.is-hover .bbanner__cta,
  .bbanner__item.is-active .bbanner__cta{
    width: var(--bb-cta-size, 46px);
    height: var(--bb-cta-size, 46px);
    margin-top: 14px;
    overflow: visible;
  }
}

/* =========================================
   TOUCH DEVICES: ignore :hover (use .is-hover instead)
   Fixar "första item är blurrat" + spökhovers
========================================= */
@media (hover: none) and (pointer: coarse){
  .bbanner__item:hover .bbanner__glass{ opacity: 0; transform: translateY(10px); }
  .bbanner__item:hover .bbanner__content{ transform: translateY(16px); opacity: 0.92; }
  .bbanner__item:hover .bbanner__desc{ opacity: 0; max-height: 0; transform: translateY(10px); }
  .bbanner__item:hover .bbanner__cta{ opacity: 0; transform: translateY(10px); }
}

/* =========================================
   Astra: stoppa underline (banner items are links)
========================================= */
.ast-single-post .entry-content a.bbanner__item,
.ast-page-builder-template .entry-content a.bbanner__item,
.ast-separate-container .entry-content a.bbanner__item,
.entry-content a.bbanner__item{
  text-decoration: none !important;
}

.ast-single-post .entry-content a.bbanner__item .bbanner__title,
.ast-single-post .entry-content a.bbanner__item .bbanner__desc,
.entry-content a.bbanner__item .bbanner__title,
.entry-content a.bbanner__item .bbanner__desc{
  text-decoration: none !important;
}
