/* =========================================================
   BBTL Taxonomy Loop - Overlay Card UI (Responsive Height)
   - Background-image (no <img>)
   - Text/Arrow colors via CSS variables
   - Responsive height via clamp()
   - Works with Grid or Swiper
   ========================================================= */

/* -----------------------------
   Variables (defaults)
   ----------------------------- */
.bbtl-taxonomy-loop,
.bbtl-swiper{
  --bbtl-cols: 4;
  --bbtl-gap: 16px;

  /* ✅ Responsive height (min, fluid, max) */
  --bbtl-card-h: clamp(320px, 36vw, 520px);

  /* Text colors */
  --bbtl-parent-color: rgba(255,255,255,.85);
  --bbtl-title-color: #ffffff;

  /* Arrow */
  --bbtl-arrow-color: #ffffff;
  --bbtl-arrow-bg: rgba(255,255,255,.0); /* ปุ่ม arrow แบบโปร่ง (ตามดีไซน์คุณ) */
  --bbtl-arrow-bg-hover: rgba(255,255,255,.0);
  --bbtl-arrow-color-hover: #ffffff;

  /* Overlay */
  --bbtl-overlay-from: rgba(0,0,0,.70);
  --bbtl-overlay-mid:  rgba(0,0,0,.40);
  --bbtl-overlay-to:   rgba(0,0,0,0);
}

/* -----------------------------
   GRID layout (เมื่อไม่ใช้ Swiper)
   ----------------------------- */
.bbtl-taxonomy-loop{
  display: grid;
  grid-template-columns: repeat(var(--bbtl-cols), minmax(0, 1fr));
  gap: var(--bbtl-gap);
}

/* Columns responsive (ถ้าคุณอยากให้ CSS จัดเอง) */
@media (max-width: 1024px){
  .bbtl-taxonomy-loop{ --bbtl-cols: 3; }
}
@media (max-width: 768px){
  .bbtl-taxonomy-loop{ --bbtl-cols: 2; }
}
@media (max-width: 480px){
  .bbtl-taxonomy-loop{ --bbtl-cols: 1; }
}

/* -----------------------------
   Swiper layout support
   ----------------------------- */
.bbtl-swiper.swiper{ width:100%; }
.bbtl-swiper .swiper-slide{ height:auto; }

/* --- Make Swiper progressbar SHORT + centered --- */
.bbtl-swiper .swiper-pagination{
  position: static !important;   /* กัน default ของ swiper */
  width: 140px !important;       /* ✅ ปรับความสั้นตรงนี้ */
  max-width: 60% !important;     /* กันกรณีจอเล็กมาก */
  height: 4px !important;
  margin: 14px auto 0 !important;/* ✅ จัดกึ่งกลาง */
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  overflow: hidden;
}

/* Swiper uses this element as fill */
.bbtl-swiper .swiper-pagination-progressbar-fill{
  border-radius: 999px;
  background: rgba(255,255,255,.9);
}

/* -----------------------------
   CARD
   ----------------------------- */
.bbtl-card--overlay{
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 5px;
  text-decoration: none;
  background: #111;

  transform: translateY(0);
  transition: transform .2s ease, box-shadow .2s ease;
}

.bbtl-card--overlay:focus{ outline:none; }
.bbtl-card--overlay:focus-visible{
  outline: 2px solid rgba(255,255,255,.65);
  outline-offset: 2px;
}

/* Media (background image) */
.bbtl-card--overlay .bbtl-media{
  width: 100%;
  height: var(--bbtl-card-h);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-color: #000;
}

/* Overlay gradient */
.bbtl-overlay{
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--bbtl-overlay-from) 0%,
    var(--bbtl-overlay-mid) 40%,
    rgba(0,0,0,.18) 70%,
    var(--bbtl-overlay-to) 100%
  );
  z-index: 1;
  pointer-events: none;
}

/* Content */
.bbtl-content{
  position: absolute;
  left: 20px;
  right: 64px;
  bottom: 20px;
  z-index: 2;
}

.bbtl-parent{
  font-size: 20px;
  font-weight: 400;
  color: var(--bbtl-parent-color);
  opacity: .90;
  margin-bottom: 6px;
  line-height: 1.2;
}

.bbtl-title{
  font-size: 20px;
  font-weight: 500;
  color: var(--bbtl-title-color);
  line-height: 1.2;
  letter-spacing: .2px;
  text-shadow: 0 1px 12px rgba(0,0,0,.35);
}

/* Arrow (SVG) */
.bbtl-arrow{
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 2;

  width: 32px;
  height: 32px;

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

  background: var(--bbtl-arrow-bg);
  color: var(--bbtl-arrow-color);

  transition: transform .2s ease, background .2s ease, color .2s ease;
}

.bbtl-arrow-svg{
  width: 32px;
  height: 32px;
  display: block;
}

/* Hover */
.bbtl-card--overlay:hover{
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
}

.bbtl-card--overlay:hover .bbtl-arrow{
  background: var(--bbtl-arrow-bg-hover);
  color: var(--bbtl-arrow-color-hover);
  transform: translateX(2px);
}

/* Mobile spacing tweaks */
@media (max-width: 480px){
  .bbtl-content{
    left: 16px;
    right: 56px;
    bottom: 16px;
  }
  .bbtl-title{ font-size: 18px; }
  .bbtl-parent{ font-size: 15px; }
  .bbtl-arrow{
    right: 14px;
    bottom: 14px;
  }
}

/* Safety: kill old ratio padding if any exists */
.bbtl-ratio-1-1,
.bbtl-ratio-4-3,
.bbtl-ratio-16-9,
.bbtl-ratio-3-4{
  padding-top: 0 !important;
}

/* =========================================================
   GRID MODE (No Swiper)
   ใช้กับ wrapper: .bbtl-grid
   ========================================================= */

/* ใช้ variables ชุดเดียวกับ swiper */
.bbtl-grid{
  display: grid;
  gap: var(--bbtl-gap, 16px);

  /* Desktop columns (default) */
  grid-template-columns: repeat(var(--bbtl-cols-d, 3), minmax(0, 1fr));
}

/* Tablet */
@media (max-width: 1024px){
  .bbtl-grid{
    grid-template-columns: repeat(var(--bbtl-cols-t, 2), minmax(0, 1fr));
  }
}

/* Mobile */
@media (max-width: 767px){
  .bbtl-grid{
    grid-template-columns: repeat(var(--bbtl-cols-m, 1), minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------
   GRID card safety
   --------------------------------------------------------- */

/* กัน Swiper style หลุดมาทับ */
.bbtl-grid .swiper-wrapper,
.bbtl-grid .swiper-slide{
  all: unset;
}

/* ให้การ์ดใน grid สูงเท่ากันทุกใบ */
.bbtl-grid .bbtl-card--overlay{
  height: 100%;
}

/* Media ใช้ height จาก clamp() เดิม */
.bbtl-grid .bbtl-card--overlay .bbtl-media{
  height: 500px;
}

/* ---------------------------------------------------------
   Optional: equal-height content alignment
   --------------------------------------------------------- */

/* ให้ arrow + content ชิดล่างเสมอ */
.bbtl-grid .bbtl-card--overlay{
  display: flex;
  flex-direction: column;
}

.bbtl-grid .bbtl-media{
  flex: 1 1 auto;
}