/* =========================================
   Clips Carousel (css/clips.css) — Fixed 160px cards, capped box width
   ========================================= */

/* Config variables */
.clips-section {
  --thumb-w: 160px;
  --thumb-h: 115px;
  --gap: 12px;
  --cards: 5; /* desktop default */
}

/* Section wrapper */
.clips-section {
  margin-top: 0;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px;
  background-color: #f6f6f6;
  border: 0;
  padding: 0;
}

/* Inner content: box look + width cap + centering */
.clips-section .content-text {
  background: #f6f6f6;
  border: 1px solid #bbb;
  padding: 16px;
  max-width: calc(var(--cards) * var(--thumb-w) + (var(--cards) - 1) * var(--gap));
  width: 100%;
  margin: 0 auto;
}

/* Headline */
.clips-title {
  display: block;
  width: 100%;
  margin: 0 0 10px 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #000;
  border-bottom: 1px solid #777;
  padding-bottom: 6px;
}

/* Carousel shell */
.clips-carousel {
  position: relative;
  width: 100%;
}

/* Viewport */
.clips-viewport {
  overflow: hidden;
  width: 100%;
}

/* Track */
.clips-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--thumb-w);
  gap: var(--gap);
  overflow-x: auto;
  padding: 6px 2px;
  margin: 0;
  list-style: none;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.clips-track::-webkit-scrollbar { display: none; }

/* Card */
.clips-card {
  scroll-snap-align: start;
  user-select: none;
  background: #fff;
  border: 0;
  border-radius: 6px;
  width: var(--thumb-w);
  min-width: var(--thumb-w);
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Clickable image */
.clips-thumb-wrap { display: block; text-decoration: none; }
.clips-thumb-center { display: contents; }

/* Thumbnail */
.clips-thumb {
  display: block;
  width: var(--thumb-w);
  height: var(--thumb-h);
  object-fit: cover;
  border-bottom: 1px solid #ccc;
  border-radius: 6px 6px 0 0;
  margin: 0;
}

/* Title */
.clips-title-link {
  display: block;
  width: var(--thumb-w);
  box-sizing: border-box;
  padding: 8px;
  text-decoration: none;
  color: #000;
  font-weight: 600;
  line-height: 1.25;
  font-size: 0.95rem;
}

/* Clamp title */
.clips-title-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3.6em;
}

/* Arrows */
.clips-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 1px solid #999;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, background 0.12s ease;
  z-index: 2;
}
.clips-arrow-left  { left: 4px; }
.clips-arrow-right { right: 4px; }
.clips-arrow:hover   { transform: translateY(-50%) scale(1.05); background: #fff; }
.clips-arrow:disabled { opacity: 0.4; cursor: default; }

/* Drag cursor */
.clips-track.grab { cursor: grab; }
.clips-track.grabbing { cursor: grabbing; }

/* Focus ring */
.clips-track:focus {
  outline: 2px solid #d4af37;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .clips-track { scroll-behavior: auto; }
  .clips-arrow { transition: none; }
}

/* ==========================
   Responsive
   ========================== */
@media (min-width: 1100px) {
  .clips-section { --cards: 5; }
}

@media (min-width: 768px) and (max-width: 1099px) {
  .clips-section { --cards: 3; }
}

@media (max-width: 767px) {
  .clips-section { --cards: 2; }

  /* Remove desktop cap so box fills mobile width */
  .clips-section .content-text {
    max-width: none;
  }

  /* Remove side padding so first/last cards touch edges */
  .clips-track {
    padding-left: 0;
    padding-right: 0;
  }

  .clips-arrow {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  .clips-track {
    align-items: flex-start; /* stop cards from stretching to tallest */
  }
  .clips-card {
    height: auto; /* let height shrink to fit content */
  }
}

/* Trim bottom space of the Clips box on phones */
@media (max-width: 767px) {
  .clips-section .content-text {
    padding-bottom: 8px;     /* was 16px */
  }
  .clips-title {
    margin-bottom: 8px;      /* a hair tighter under the headline */
  }
  .clips-carousel {
    margin-bottom: 0;        /* don’t add any extra spacing under the rail */
  }
  .clips-viewport {
    padding-bottom: 0;       /* make sure no inner padding adds height */
  }
  .clips-track {
    padding-bottom: 0;       /* remove the 6px bottom pad we set globally */
  }
  .clips-card {
    margin-bottom: 0;        /* just in case a global adds margins to li */
  }
}

/* Keep Vault thumbnails the same size on phones */
@media (max-width: 767px) {
  /* outranks .content-block img on mobile */
  .content-block.clips-section .content-text .clips-thumb {
    width: var(--thumb-w) !important;   /* 160px */
    height: var(--thumb-h) !important;  /* 115px */
    object-fit: cover !important;
    display: block;
    margin: 0; /* don't let margins fake “height” */
  }

  /* keep card width locked to the thumb so rows stay neat */
  .content-block.clips-section .content-text .clips-card {
    width: var(--thumb-w) !important;
    min-width: var(--thumb-w) !important;
  }
}

/* ===== Silk-only tweaks (Kindle Fire) ===== */
.ua-silk .clips-section { --cards: 5 !important; }

/* Keep the Clips box at the 5-card cap (848px) so Silk doesn't downshift to 3 */
.ua-silk .clips-section .content-text {
  max-width: calc(5 * var(--thumb-w) + 4 * var(--gap)) !important;
}

/* Remove inner rail “wings” on Silk only (does not change desktop/other browsers) */
.ua-silk .clips-track {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ============================
   Silk-only tweaks: Modern Clips
   ============================ */
body.silk #clips-modern-section .content-text {
  /* keep the nice box, just trim inner padding so edges align */
  padding-left: 8px;
  padding-right: 8px;
}

body.silk #clips-modern-section .clips-track {
  /* remove inner rail padding so first/last cards kiss the edges */
  padding-left: 0;
  padding-right: 0;
}

/* Force 5-up on Silk so there are no “wings” */
body.silk #clips-modern-section {
  --cards: 5;
}
