/* ========================================
   INDEX PAGE: CATEGORY / PROJECT SELECTION
   ======================================== */

#category-section {
  --layout-margin: 60px;
  --accent-band-width: 20px;
  --studio-font-size: 1rem;
  --spacing-double: 80px;
  /* Default accent color fallback */
  --category-accent: #000;

  min-height: calc(var(--locked-vh, 1vh) * 100);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background-color: #FFFFFF;
  /* Prevent desktop image overlap from causing horizontal scroll */
  overflow-x: hidden;
  width: 100%;
}

#category-section .category-container {
  max-width: 100%;
  width: 100%;
  padding: 40px var(--layout-margin);
  box-sizing: border-box;
  position: relative;
}

/* Images Row Container */
#category-section .category-images-row {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 80px;
  gap: 20px;
}

/* Image Wrapper with Accent Band */
#category-section .category-image-wrapper {
  position: relative;
  width: 336px;
  flex-shrink: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#category-section .category-image-wrapper.active {
  opacity: 1;
  visibility: visible;
}

/* Desktop-specific: Distribute images evenly edge-to-edge with overlap */
@media (min-width: 768px) {
  #category-section .category-images-row {
    gap: 0;
  }

  #category-section .category-image-wrapper {
    flex: 1;
    width: auto;
    flex-shrink: 1;
  }

  /* Overlap each image with the previous by the accent band width */
  /* First image stays in place (band anchored to margin) */
  #category-section .category-image-wrapper:not(:first-child) {
    margin-left: calc(var(--accent-band-width) * -1);
  }

  /* Ensure proper stacking order - later images appear on top */
  #category-section .category-image-wrapper:nth-child(1) {
    z-index: 1;
  }

  #category-section .category-image-wrapper:nth-child(2) {
    z-index: 2;
  }

  #category-section .category-image-wrapper:nth-child(3) {
    z-index: 3;
  }

  #category-section .category-image-wrapper:nth-child(4) {
    z-index: 4;
  }

  #category-section .category-image-wrapper:nth-child(5) {
    z-index: 5;
  }

  #category-section .category-image-wrapper:nth-child(6) {
    z-index: 6;
  }

  /* Increase image size to utilize the extra space gained from overlap */
  /* Each image can extend by the band width into the previous image's space */
  #category-section .category-image-wrapper .category-image {
    width: calc(100% + var(--accent-band-width));
  }

  /* Last image should not extend beyond its wrapper to prevent horizontal overflow */
  #category-section .category-image-wrapper:last-child .category-image {
    width: 100%;
  }
}

#category-section .accent-band {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--accent-band-width);
  height: 100%;
  z-index: 2;
  transition: background-color 0.3s ease;
}

#category-section .category-image-wrapper .accent-band {
  background-color: var(--category-accent);
}

#category-section .category-image {
  width: 336px;
  height: auto;
  display: block;
  position: relative;
  z-index: 1;
  /* Center-crop landscape images to maintain consistent portrait layout */
  object-fit: cover;
  aspect-ratio: 4 / 5;
}

/* Desktop-specific: Scale images to fill containers */
@media (min-width: 768px) {
  #category-section .category-image {
    width: 100%;
  }
}

/* Studio Index Wrapper - positions nav and descriptions */
#category-section .studio-index-wrapper {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
}

/* Desktop grid layout: 3+2+1 ratio with 40px gaps */
@media (min-width: 768px) {
  #category-section .studio-index-wrapper {
    display: grid;
    grid-template-columns: 3fr 40px 2fr 40px 1fr;
  }

  #category-section .category-nav {
    grid-column: 1;
  }

  #category-section .studio-descriptions {
    grid-column: 3;
  }
}

/* Category Navigation */
#category-section .category-nav {
  display: block;
  flex-shrink: 0;
  line-height: 1.2;
}

#category-section .category-item {
  display: inline-block;
  font-family: 'Hanken Grotesk', var(--font-primary);
  font-size: max(1.5rem, 3.1vw);
  font-weight: 600;
  color: #D8D8D8;
  letter-spacing: -2px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.3s ease;
  user-select: none;
  margin-right: 0.3em;
  vertical-align: baseline;
  background: none;
  background-color: transparent;
  border: none;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#category-section .category-item:focus {
  outline: none;
}

#category-section .category-item:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

#category-section .category-item:hover,
#category-section .category-item.active {
  color: #000;
}

#category-section .category-number {
  font-family: 'Hanken Grotesk', var(--font-primary);
  font-size: max(1.5rem, 1.85vw);
  font-weight: 600;
  vertical-align: super;
  margin-left: 4px;
  font-style: normal;
}

/* Studio Descriptions Container */
#category-section .studio-descriptions {
  position: relative;
  min-height: 400px;
  align-self: flex-start;
}

#category-section .studio-description {
  position: absolute;
  top: 0;
  left: 0;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#category-section .studio-description.active {
  opacity: 1;
  visibility: visible;
}

#category-section .studio-description p {
  font-family: var(--font-primary);
  font-size: var(--refactored-body-size);
  /* Uses global reduced body size */
  font-weight: var(--refactored-body-weight, 400);
  line-height: var(--refactored-body-line-height, 1.45);
  color: #000;
  margin: 0;
}

#category-section .project-button {
  align-self: flex-end;
  background: none;
  border: none;
  font-family: 'Hanken Grotesk', var(--font-primary);
  font-size: var(--refactored-body-size);
  /* Same size as body text, just bold */
  font-weight: 600;
  cursor: pointer;
  color: #000;
  position: relative;
  display: inline-block;
  width: fit-content;
  padding: 0;
}

/* Medium screen breakpoint - adjust container sizes for tablets */
@media (max-width: 1024px) {
  #category-section .studio-descriptions {
    min-height: 300px;
  }
}

/* Tablet breakpoint - adjust container sizes for smaller tablets */
@media (max-width: 900px) {
  #category-section .studio-descriptions {
    min-height: 250px;
  }
}

/* Mobile-specific Section 2 styles */
@media (max-width: 767px) {

  /* Override flex centering to allow padding-top to work */
  #category-section {
    align-items: flex-start;
    height: auto;
  }

  /* Add margin between intermediate section and image cycle */
  #category-section .category-container {
    padding-top: 120px;
    /* 80px margin + 40px for header */
  }

  /* Stack all category images on top of each other */
  #category-section .category-images-row {
    position: relative;
    display: block;
    width: 100%;
    height: calc(var(--locked-vh, 1vh) * 60);
    max-height: calc(var(--locked-vh, 1vh) * 60);
    min-height: 400px;
    margin-bottom: 1px;
    overflow: hidden;
  }

  #category-section .category-image-wrapper {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 90vw;
    height: 100%;
    opacity: 0.3;
    visibility: visible;
    pointer-events: none;
    transition: opacity 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #category-section .category-image-wrapper.active {
    opacity: 1;
    z-index: 10;
  }

  #category-section .category-image {
    width: 100%;
    max-width: 90vw;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    margin: 0 auto;
    display: block;
  }

  /* Make accent band match the actual image height on mobile */
  #category-section .category-image-wrapper .accent-band {
    position: absolute;
    left: 0;
    width: 20px;
    z-index: 2;
    /* Height will be set by JavaScript to match image */
  }

  /* Disable pointer events on category items */
  #category-section .category-item {
    pointer-events: none;
    cursor: default;
    font-size: max(24px, 8vw);
    font-weight: 300;
  }

  #category-section .category-number {
    font-size: max(14px, 4vw);
  }

  /* Hide project descriptions on mobile */
  #category-section .studio-description {
    display: none;
  }

  #category-section .studio-index-wrapper {
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  #category-section .category-nav {
    width: 100%;
    text-align: center;
    margin-bottom: 40px;
  }

  #category-section .studio-descriptions {
    width: 100%;
    min-height: auto;
  }

  #category-section .project-button {
    pointer-events: none;
    cursor: default;
  }
}

#category-section .text-link {
  color: #000;
  text-decoration: none;
}

#category-section .text-link:hover {
  text-decoration: underline;
}