/* ═══════════════════════════════════════════════════
   KAVE — Categories Expandable Grid Section
   ═══════════════════════════════════════════════════ */

.categories {
  position: relative;
  padding: 60px 0 80px;
  background: var(--color-bg-alt);
  overflow: hidden;
}

/* ── Panel Rail ── */
.cat-rail {
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 0 5px;
  height: 64vh;
  min-height: 500px;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  transition: grid-template-columns 0.7s var(--ease);
}

.cat-panel {
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: #fff;
  min-width: 0;
}

.cat-panel .media {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.06);
  transition: transform var(--duration-slower) var(--ease), filter 0.7s var(--ease);
  filter: brightness(0.74);
}

.cat-panel:hover .media {
  transform: scale(1);
  filter: brightness(0.88);
}

/* Bottom gradient overlay */
.cat-panel::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 60%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.18) 55%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* Index number */
.cat-panel .num {
  position: absolute;
  top: 28px;
  left: 28px;
  z-index: 3;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  font-weight: 500;
}

/* Bottom text block */
.cat-panel .info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 32px 28px 34px;
}

.cat-panel .title {
  font-family: var(--font-heading);
  font-size: clamp(22px, 1.9vw, 30px);
  line-height: 1.15;
  font-weight: 400;
  letter-spacing: -0.3px;
  white-space: nowrap;
  background-image: linear-gradient(#fff, #fff);
  background-size: 0 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.7s var(--ease);
  display: inline;
  padding-bottom: 4px;
}

.cat-panel:hover .title { background-size: 100% 1px; }

.cat-panel .cta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--duration-slow) var(--ease) 0.1s, transform var(--duration-slow) var(--ease) 0.1s;
  white-space: nowrap;
}

.cat-panel .cta .arrow {
  display: block;
  width: 34px;
  height: 1px;
  background: #fff;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.65s var(--ease) 0.15s;
}

.cat-panel:hover .cta { opacity: 1; transform: translateY(0); }
.cat-panel:hover .cta .arrow { transform: scaleX(1); }

/* ── Tablet ── */
@media (max-width: 960px) {
  .categories { padding: 60px 0; }
  .cat-rail { height: 58vh; min-height: 440px; }
  .cat-panel .info { padding: 26px 22px 28px; }
  .cat-panel .num { top: 22px; left: 22px; }
}

/* ── Mobile — horizontal swipe rail ── */
@media (max-width: 760px) {
  .categories { padding: 48px 0; }

  .cat-rail {
    display: flex;
    grid-template-columns: none;
    gap: 14px;
    padding: 0 var(--gutter);
    height: auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-left: var(--gutter);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    transition: none;
  }
  .cat-rail::-webkit-scrollbar { display: none; }

  .cat-panel {
    flex: 0 0 78%;
    height: 80vw;
    max-height: 520px;
    scroll-snap-align: start;
  }

  .cat-panel .media {
    transform: scale(1);
    filter: brightness(0.78);
    transition: none;
  }

  .cat-panel::after {
    height: 65%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.25) 55%, transparent 100%);
  }

  .cat-panel .num { top: 20px; left: 20px; font-size: 10px; letter-spacing: 2px; }
  .cat-panel .info { padding: 0 22px 26px; }
  .cat-panel .title {
    white-space: normal;
    font-size: 24px;
    line-height: 1.15;
    background-size: 100% 1px;
    padding-bottom: 6px;
  }
  .cat-panel .cta {
    opacity: 1;
    transform: none;
    margin-top: 14px;
    font-size: 10px;
    letter-spacing: 1.8px;
  }
  .cat-panel .cta .arrow { transform: scaleX(1); width: 28px; }
  .cat-panel:active .media { filter: brightness(0.68); }

  /* Progress bar */
  .cat-progress {
    display: block;
    margin: 28px var(--gutter) 0;
    height: 1px;
    background: var(--color-line);
    position: relative;
    overflow: hidden;
  }
  .cat-progress span {
    position: absolute;
    left: 0; top: 0; height: 100%;
    width: 20%;
    background: var(--color-text);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
  }
}

@media (max-width: 480px) {
  .categories { padding: 40px 0; }
  .cat-panel { flex-basis: 84%; height: 96vw; max-height: 480px; }
  .cat-panel .title { font-size: 22px; }
}

/* Hide progress on desktop */
.cat-progress { display: none; }
