/* ===============================
   Reset & Base
================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===============================
   Container — fluid, capped at 1250px
================================ */

.webstories-container {
  width: 100%;
  max-width: 1250px;
  margin: 32px auto;
  padding: 0 16px;
}

/* ===============================
   Section Title
================================ */

.section-title {
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 800;
  margin-bottom: 20px;
  color: #001070;
  line-height: 1.2;
}

/* ===============================
   Divider
================================ */

.section-divider {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 32px 0;
}

/* ===============================
   Category Block
================================ */

.category-block {
  margin-bottom: 0;
  padding: 28px 20px;
  border-radius: 12px;
  transition: background 0.2s ease;
}

/* Even sections get a soft blue tint — pure CSS, no PHP needed */
.category-block:nth-child(even) {
  background: #f3f6ff;
}

/* Divider hidden when alt-bg handles visual separation */
.category-block + .section-divider {
  margin: 8px 0;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.category-header h3 {
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 700;
  color: #111;
}

/* ===============================
   More Link
================================ */

.more-link {
  color: #001070;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.5px;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.more-link:hover {
  color: #00094a;
  text-decoration: underline;
}

/* ===============================
   Story Grid — Mobile First
   xs:  2 columns  (default, 0px+)
   sm:  3 columns  (480px+)
   md:  4 columns  (640px+)
   lg:  5 columns  (900px+)
   xl:  6 columns  (1100px+)
================================ */

.story-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

@media (min-width: 480px) {
  .story-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (min-width: 640px) {
  .story-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }
}

@media (min-width: 900px) {
  .story-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
  }
}

@media (min-width: 1100px) {
  .story-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 22px;
  }
}

/* Visual Stories section — slightly wider cards */
.story-grid.visual {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 480px) {
  .story-grid.visual {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 640px) {
  .story-grid.visual {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 900px) {
  .story-grid.visual {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 1100px) {
  .story-grid.visual {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ===============================
   Story Card
================================ */

.story-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
  /* Ensure card doesn't overflow its grid cell */
  min-width: 0;
  width: 100%;
}

.story-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.13);
}

.story-card a {
  display: block;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

/* ===============================
   Story Image — 3:4 portrait ratio
   Always fills the card width, never overflows
================================ */

.story-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  /* Prevent image from forcing card wider */
  max-width: 100%;
  height: auto;
}

/* Fallback for browsers without aspect-ratio support */
@supports not (aspect-ratio: 3 / 4) {
  .story-card img {
    height: 0;
    padding-bottom: 133.33%; /* 4/3 * 100 */
    position: relative;
  }
}

/* ===============================
   Story Title
================================ */

.story-title {
  padding: 10px 12px;
  font-size: clamp(12px, 1.5vw, 15px);
  font-weight: 600;
  color: #000b4b;
  line-height: 1.4;
  /* Clamp to 2 lines cleanly */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===============================
   Play Icon Badge
================================ */

.play-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  /* Shrink on very small screens */
  transition: opacity 0.2s ease;
}

.play-icon::before {
  content: '▶';
  color: #fff;
  font-size: 12px;
  transform: translateX(1px);
  display: block;
  line-height: 1;
}

/* ===============================
   Container padding adjustments
================================ */

@media (min-width: 600px) {
  .webstories-container {
    padding: 0 20px;
  }
}

@media (min-width: 1024px) {
  .webstories-container {
    padding: 0 24px;
    margin: 40px auto;
  }
}

/* ===============================
   Print / very small devices (< 360px)
================================ */

@media (max-width: 359px) {
  .story-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .story-title {
    font-size: 11px;
    padding: 8px;
  }

  .play-icon {
    width: 24px;
    height: 24px;
  }

  .play-icon::before {
    font-size: 10px;
  }
}