/* ========================================
   EPSILON SECTION STYLES
   Cleaned for parent site integration
   ======================================== */

/* Section-scoped variables (moved from :root to prevent global pollution) */
#epsilon-section {
  --color-epsilon: #FFF584;

  /* Epsilon Section - Adjustable values */
  --epsilon-margin: 40px;
  /* Doubled from previous 20px per user request */
  /* 1/3 of standard 60px layout margin */
  --epsilon-image-text-gap: min(60px, 4vw);
  /* Gap between image and text - caps at 60px, scales down */
  --epsilon-content-width: min(520px, 32vw);
  /* Width of image and text boxes - caps at 520px, scales down */
  --epsilon-scroll-distance: calc(var(--locked-vh) * 300);
  /* Total scroll distance for 5 steps - lower = faster */

  /* Porous Light Layout Variables */
  /* Design canvas: 1920×962px = 100vh section with everything inside */
  --pl-section-margin: clamp(40px, calc(var(--locked-vh) * 10), 120px);
  /* Reduced from 13vh to give more room for content */
  --pl-gap: clamp(20px, 4vw, 80px);
  /* Use viewport width for horizontal gap */
  --pl-image-size-ratio: 74;
  --pl-image-width: min(calc(var(--locked-vh) * 70), 45vw);
  /* Cap image width at 45vw to prevent text squeeze */
  --pl-text-width-ratio: 0.75;
  /* Reverted to 0.75 for 75% image width ratio */
  --pl-font-size: clamp(18px, 1.2vw, 22px);
  /* Reduced ~15% for better laptop/desktop readability */

  /* Note: overflow-x removed to preserve sticky positioning for color tags */
  /* Pan track overflow is contained by .epsilon-zone-b { overflow: hidden; } */
}

/* ========================================
   MOBILE SLIDESHOW (SECTION 5)
   ======================================== */

.mobile-slideshow-wrapper {
  width: 100%;
  position: relative;
}

.mobile-slideshow-container {
  width: 100vw;
  overflow: hidden;
  position: relative;
  margin-left: calc(-1 * var(--thirds-margin, 0px));
}

@media (max-width: 767px) {
  .mobile-slideshow-container {
    margin-left: 0;
  }
}

.mobile-slideshow-track {
  display: flex;
  width: 300%;
  /* 3 slides at 100% each */
}

.mobile-slide {
  width: 100vw;
  flex-shrink: 0;
  position: relative;
}

.mobile-slide .image-hover-wrapper {
  width: 100%;
  /* Use grid to ensure accent bar correctly sizes with the image */
  display: grid;
  grid-template-areas: "stack";
}

.mobile-slide .image-hover-wrapper>* {
  grid-area: stack;
}

.mobile-slide .image-hover-wrapper img {
  /* Image establishes the cell size */
  width: 100%;
  height: auto;
}

.mobile-slide .image-hover-wrapper .hover-accent-bar {
  /* Override absolute positioning - grid handles sizing */
  position: relative;
  height: auto;
  align-self: stretch;
  justify-self: start;
}

.mobile-slide .image-hover-wrapper .hover-color-block {
  /* Override absolute positioning - grid handles layout */
  position: relative;
  bottom: auto;
  right: auto;
  /* Position at bottom-right within the grid cell */
  align-self: end;
  justify-self: end;
  margin: var(--color-overlay-margin, 20px);
}

.mobile-slide img {
  width: 100%;
  height: auto;
  display: block;
}

/* Mobile slideshow overlay - disable hover, use tap via ColorOverlay.js */
/* Core show-overlay styles are in color-overlay.css */
@media (max-width: 767px) {

  .mobile-slideshow-wrapper .image-hover-wrapper:hover .hover-accent-bar,
  .mobile-slideshow-wrapper .image-hover-wrapper:hover .hover-color-block {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* Slideshow Dot Navigation */
.slideshow-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  margin-top: 0;
}

.slideshow-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #D8D8D8;
  cursor: pointer;
  transition: all 0.3s ease;
}

.slideshow-dot.active {
  background-color: var(--color-epsilon);
  transform: scale(1.2);
}

.slideshow-dot:hover {
  background-color: #999;
}

.slideshow-dot.active:hover {
  background-color: var(--color-epsilon);
}

/* ========================================
   Responsive: Desktop/Mobile Visibility
   ======================================== */
/* Desktop: hide mobile-only elements, desktop-only uses natural display */
#epsilon-section .mobile-only {
  display: none;
}

@media (max-width: 767px) {
  #epsilon-section .desktop-only {
    display: none;
  }

  #epsilon-section .mobile-only {
    display: block;
  }
}


/* ========================================
   EPSILON SECTION - SCROLLYTELLING
   ======================================== */

/* Main wrapper - creates scroll distance */

.epsilon-section-wrapper {
  position: relative;
  height: var(--epsilon-scroll-distance);
  width: 100%;
}

/* Sticky view - pinned during scroll via ScrollTrigger
   ScrollTrigger handles pinning with position: fixed during active scroll range.
   CSS positioning is relative to allow normal document flow when not pinned. */
.epsilon-sticky-view {
  position: relative;

  /* Uses locked viewport height for stability with mobile browser toolbars */
  height: calc(var(--locked-vh) * 100);

  width: 100%;
  z-index: 50;

  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
}

/* ----------------------------------------
   ZONE A: Construction Details (Top 65%)
   ---------------------------------------- */
.epsilon-zone-a {
  position: relative;
  height: calc(var(--locked-vh) * 65);
  width: 100%;
  overflow: hidden;
}

/* ----------------------------------------
   DETAIL UNIT - Combined Image + Text Container
   ---------------------------------------- */
.detail-unit {
  position: absolute;
  top: calc(var(--locked-vh) * 15);
  /* Stable Hang Line */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: calc(var(--epsilon-content-width) * 2 + var(--epsilon-image-text-gap));
  height: auto;
  /* Hug content */
  bottom: auto;
  /* Do not stretch */
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  /* Align image and text tops */
  justify-content: center;
  gap: var(--epsilon-image-text-gap);
  padding: 0 var(--layout-margin);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.detail-unit.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Image wrapper within unit */
.unit-image-wrapper {
  position: relative;
  width: var(--epsilon-content-width);
  max-width: 45vw;
  /* Ensure image doesn't dominate on wide screens */
  height: auto;
  /* Let image determine height */
  min-height: 0;
  flex-shrink: 0;
  display: block;
  /* Simplified alignment */
}

.unit-image-wrapper .detail-image {
  width: 100%;
  max-width: var(--epsilon-content-width);
  height: auto;
  aspect-ratio: 2524 / 2052;
  max-height: calc(var(--locked-vh) * 45);
  /* Reasonable max to prevent overflow */
  object-fit: contain;
  object-position: top right;
}

/* Text wrapper within unit */
.unit-text-wrapper {
  width: var(--epsilon-content-width);
  height: auto;
  /* Let text determine height */
  min-height: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: visible;
}

/* Detail titles - responsive scaling */
#epsilon-section .detail-title {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: clamp(1.5rem, 3.5vw, 3rem);
  /* Fluid: min 1.5rem (accessibility floor), preferred 3.5vw, max 3rem */
  font-weight: 300;
  letter-spacing: -0.02em;
  margin-bottom: calc(var(--locked-vh) * 2);
  line-height: 1.1;
  overflow: hidden;
  /* Contain horizontally-sliding line animations */
}

/* Capsize: Trim leading space above capital letters */
#epsilon-section .detail-title::before {
  content: '';
  margin-bottom: calc(-1 * var(--capsize-trim-top));
  display: table;
}

/* Capsize: Trim leading space below baseline */
#epsilon-section .detail-title::after {
  content: '';
  margin-top: calc(-1 * var(--capsize-trim-bottom));
  display: table;
}

/* Detail body text - narrative paragraphs */
#epsilon-section .detail-body {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: clamp(0.9rem, 1.1vw, 1.1rem);
  /* Fluid: min 0.9rem, preferred 1.1vw, max 1.1rem - scales with image width */
  line-height: 1.65;
  max-width: var(--epsilon-content-width);
  color: var(--color-text);
  /* Prevent layout shift when annotation text swaps in */
  min-height: 4em;
  overflow: hidden;
  /* Contain horizontally-sliding line animations */
}

#epsilon-section .detail-body b {
  font-weight: 600;
  color: #000;
}

/* ----------------------------------------
   LINE MASK - Text Reveal Animation
   ---------------------------------------- */
#epsilon-section .line-mask {
  overflow: hidden;
  display: block;
  position: relative;
  /* Required for overflow to contain transformed .line children */
}

/* SplitType generated lines */
#epsilon-section .detail-title .line,
#epsilon-section .detail-body .line {
  display: block;
}

/* ----------------------------------------
   ZONE B: Section Pan (Bottom 35%)
   ---------------------------------------- */
.epsilon-zone-b {
  height: calc(var(--locked-vh) * 35);
  width: 100%;
  overflow: hidden;
  position: relative;
  background-color: #f5f5f5;
}

/* Pan track - holds all section images in a row */
.section-pan-track {
  display: flex;
  height: 100%;
  width: max-content;
  will-change: transform;
}

.section-image {
  height: 100%;
  width: auto;
  aspect-ratio: 3643 / 1440;
  object-fit: contain;
  flex-shrink: 0;
}

/* ----------------------------------------
   EPSILON SECTION - DETAIL HIGHLIGHT OVERLAY
   ---------------------------------------- */

/* Wrapper so the overlay tracks with epsilon_section02 image inside the pan strip */
.epsilon-section02-wrapper {
  position: relative;
  height: 100%;
  display: flex;
  align-items: stretch;
}

.epsilon-section02-image {
  height: 100%;
  width: auto;
  aspect-ratio: 3212 / 1440;
  display: block;
}

/* Third pan frame uses its own aspect ratio to keep intrinsic space */
.section-pan-track>img.section-image:last-of-type {
  aspect-ratio: 3433 / 1440;
}

/* Overlay layer that sits directly above epsilon_section02, using its aspect ratio */
.epsilon-hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* baseline: let individual hotspots handle interaction */
}

/* Base hotspot rectangles: very subtle, always-on hint of the four detail zones */
.epsilon-hotspot {
  position: absolute;
  border: none;
  background-color: transparent;
  padding: 0;
  margin: 0;
  outline: none;
  pointer-events: auto;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.epsilon-hotspot:focus-visible {
  outline: 1px solid rgba(0, 0, 0, 0.6);
  outline-offset: 2px;
}

/* Active and hover states are controlled entirely via SVG rects in JS */

/* Hotspot positioning: mapped from 3212 x 1440 epsilon_section02.webp to percentages */

/* D.01 Wall / Roof Junction: coords 619,447,760,583 */
.epsilon-hotspot[data-detail="1"] {
  left: 19.3%;
  top: 31.0%;
  width: 4.4%;
  height: 9.4%;
}

/* D.02 Window to Floor Junction: coords 619,683,760,825 */
.epsilon-hotspot[data-detail="2"] {
  left: 19.3%;
  top: 47.4%;
  width: 4.4%;
  height: 9.9%;
}

/* D.03 Balcony Structure: coords 1720,713,1842,841 */
.epsilon-hotspot[data-detail="3"] {
  left: 53.6%;
  top: 49.5%;
  width: 3.8%;
  height: 8.9%;
}

/* D.04 Balcony Slab Junction: coords 1832,1179,1969,1316 */
.epsilon-hotspot[data-detail="4"] {
  left: 57.0%;
  top: 81.9%;
  width: 4.3%;
  height: 9.5%;
}

/* SVG outline that traces the perimeter of each hotspot */
.epsilon-hotspot-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Baseline rect: always visible, lightest stroke for idle hint */
.epsilon-hotspot-svg .baseline-rect {
  fill: transparent;
  stroke: rgba(0, 0, 0, 0.28);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* Animated rect: hidden initially, draws on hover/active with darker stroke */
.epsilon-hotspot-svg .animated-rect {
  fill: transparent;
  stroke: rgba(0, 0, 0, 0.9);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* Label that appears above the box once the outline animation completes */
.epsilon-hotspot-label {
  position: absolute;
  left: 0;
  bottom: 100%;
  transform-origin: left bottom;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: clamp(0.55rem, 0.8vw, 0.7rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #000;
  pointer-events: none;
  white-space: nowrap;
}

/* ----------------------------------------
   EPSILON RESPONSIVE (Tablet < 1024px)
   ---------------------------------------- */
@media (max-width: 1024px) {
  #epsilon-section {
    --epsilon-image-text-gap: min(40px, 5vw);
    /* Let min() handle scaling */
    /* --epsilon-content-width uses min() from base - no override needed */
  }

  .detail-unit {
    padding: 0 var(--spacing-base);
  }
}

/* ----------------------------------------
   EPSILON RESPONSIVE (Mobile < 768px)
   ---------------------------------------- */
@media (max-width: 768px) {
  #epsilon-section {
    --epsilon-image-text-gap: 16px;
    --epsilon-scroll-distance: calc(var(--locked-vh) * 300);
  }

  .epsilon-sticky-view {
    flex-direction: column;
    height: calc(var(--locked-vh) * 100);
  }

  /* Stack zones vertically */
  .epsilon-zone-a {
    height: calc(var(--locked-vh) * 80);
  }

  /* Detail unit stacks vertically on mobile */
  /* Keep position: absolute from base styles so units stack on top of each other */
  .detail-unit {
    width: 100%;
    max-width: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--epsilon-image-text-gap);
    padding: 0 var(--epsilon-margin);
    box-sizing: border-box;
    /* Center unit vertically within zone-a */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: auto;
  }

  .unit-image-wrapper {
    order: 1;
    width: 100%;
    max-width: 100%;
    /* Unset the 45vw desktop inheritance */
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .unit-image-wrapper .detail-image {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: calc(var(--locked-vh) * 32);
    /* Mobile: constrain image to ~32vh to leave room for title + body */
    object-fit: contain;
    object-position: center center;
    flex-shrink: 0;
  }

  .unit-text-wrapper {
    order: 2;
    width: 100%;
    max-width: 100%;
    height: auto;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    padding: 0;
  }

  .epsilon-zone-b {
    height: calc(var(--locked-vh) * 20);
  }

  #epsilon-section .detail-title {
    margin-bottom: calc(var(--locked-vh) * 1);
    /* Tighter spacing on mobile */
    text-align: center;
  }

  #epsilon-section .detail-body {
    line-height: 1.6;
    max-width: 100%;
    text-align: center;
  }
}

/* ========================================
   COLOR OVERLAY FONT FIX (Epsilon-specific)
   ======================================== */
/* Override global color-overlay.css to use Hanken Grotesk in epsilon section */
#epsilon-section .hover-color-block p {
  font-family: 'Hanken Grotesk', sans-serif;
}

#epsilon-section .hover-color-block p strong {
  font-family: 'Hanken Grotesk', sans-serif;
}

/* ========================================
   CUSTOM CURSOR - Hide default cursor on clickable images
   ======================================== */
/* Hide default cursor when hovering over interactive elements */
#epsilon-section .porous-light-image-hover:hover,
#epsilon-section .porous-light-image-hover:hover * {
  cursor: none !important;
}

#epsilon-section .stacked-images-container:hover,
#epsilon-section .stacked-images-container:hover * {
  cursor: none !important;
}


/* ========================================
   SECTION 3: EPSILON MEDIUM - THIRDS GRID
   ======================================== */

#project-section {
  min-height: auto;
  padding-top: var(--grid-top-margin);
  padding-bottom: var(--grid-top-margin);
  background-color: #F5F3EE;
  --thirds-margin: clamp(20px, 2.375vw, 60px);
  padding-left: var(--thirds-margin);
  padding-right: var(--thirds-margin);
  --grid-top-margin: clamp(40px, calc(var(--locked-vh) * 5), 80px);
}

.thirds-grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--thirds-margin);
  width: 100%;
}

.thirds-grid-item {
  position: relative;
  width: 100%;
}

/* Stacked images container for desktop click-to-reveal */
.stacked-images-container {
  position: relative;
  cursor: pointer;
}

.stacked-images-container .image-hover-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.stacked-image-2 {
  position: relative !important;
  z-index: 1;
  pointer-events: auto;
}

.stacked-image-3 {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

/* Image cycle dots for stacked images */
.image-cycle-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.cycle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.cycle-dot.active {
  background-color: rgba(0, 0, 0, 0.8);
  transform: scale(1.2);
}

/* Thirds grid whitespace column */
.thirds-grid-whitespace {
  background-color: transparent;
}

/* Ensure images in the thirds grid are responsive */
.thirds-grid-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* Mobile responsive: Switch to slideshow on mobile */
@media (max-width: 767px) {
  #project-section {
    padding-left: 0;
    padding-right: 0;
  }

  .thirds-grid-container {
    display: none;
  }
}

/* ========================================
   SECTION 4: HEAVY SERIES DIPTYCH
   ======================================== */

.section-heavy {
  min-height: auto;
}

#heavy-series {
  padding: 0;
  background-color: #F5F3EE;
}

.heavy-series-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.heavy-series-image-wrapper {
  margin: 0;
}

.heavy-series-image {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 767px) {
  .heavy-series-images {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   SECTION 4: POROUS AND LIGHT
   ======================================== */

.section-porous-light {
  background-color: #F5F3EE;
  padding: 0;
}

.porous-light-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: var(--pl-section-margin);
  min-height: calc(var(--locked-vh) * 100);
  width: 100%;
  box-sizing: border-box;
  gap: var(--pl-gap);
}

.porous-light-image-wrapper {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 0;
  position: relative;
  flex-shrink: 0;
  width: var(--pl-image-width);
}

.porous-light-image-hover {
  display: inline-block;
  position: relative;
  cursor: pointer;
  width: auto;
  height: auto;
}

/* Override hover-color-block positioning for section 4 */
.porous-light-image-hover .hover-color-block {
  bottom: clamp(20px, 2.375vw, 60px);
  right: clamp(20px, 2.375vw, 60px);
  max-width: calc(100% - (clamp(20px, 2.375vw, 60px) * 2));
}

.porous-light-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  display: block;
}

.porous-light-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 0;
  gap: 0;
  text-align: left;
  flex-shrink: 1;
  /* Allow text to shrink if needed */
  width: calc(var(--pl-image-width) * var(--pl-text-width-ratio));
  /* Removed max-width: 55ch to ensure 75% ratio is maintained on large screens */
}

.porous-light-title {
  margin: 0;
  margin-bottom: 1em;
  font-family: var(--font-primary);
  font-style: normal;
  font-size: var(--pl-font-size);
  line-height: 1.45;
  font-weight: 900;
  letter-spacing: normal;
  font-stretch: normal;
}

.porous-light-paragraph {
  margin: 0;
  max-width: 50ch;
  font-family: var(--font-primary);
  font-size: var(--pl-font-size);
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-text);
}

.porous-light-paragraph-mobile {
  display: none;
  margin: 0;
  margin-top: clamp(8px, 2.5vw, 25px);
  max-width: 50ch;
  font-family: var(--font-primary);
  font-size: var(--pl-font-size);
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-text);
}

.porous-light-emphasis {
  font-family: inherit;
  font-size: inherit;
  font-style: normal;
  font-weight: inherit;
  font-stretch: normal;
}

@media (max-width: 1023px) {
  #epsilon-section {
    --pl-section-margin: var(--epsilon-margin);
    /* Reduced margin for mobile */
    --pl-gap: calc(var(--locked-vh) * 2);
    /* Reduced gap for closer image-text relationship */
    --pl-image-size-ratio: 50;
    /* Smaller ratio for mobile portrait */
  }

  .porous-light-grid {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Group elements in center */
    padding: var(--pl-section-margin);
    gap: var(--pl-gap);
    min-height: calc(var(--locked-vh) * 100);
  }

  .porous-light-content {
    width: 100%;
    max-width: 100%;
    order: 2;
    padding: 0;
    align-items: center;
    /* Center text content */
    text-align: center;
    /* Center text alignment */
    gap: 0;
  }

  .porous-light-image-wrapper {
    width: 100%;
    max-width: calc(100vw - var(--pl-section-margin) * 2);
    order: 1;
    margin: 0;
    padding: 0;
    justify-content: center;
  }

  .porous-light-image-hover {
    width: 100%;
    display: block;
  }

  /* Mobile caption block positioning for section 4 */
  .porous-light-image-hover .hover-accent-bar {
    width: 6px;
  }

  .porous-light-image-hover .hover-color-block {
    bottom: 20px;
    right: 20px;
    width: clamp(120px, 50vw, 280px);
    padding: clamp(10px, 3vw, 18px);
    max-width: calc(100% - 40px);
  }

  .porous-light-image-hover .hover-color-block p {
    font-size: var(--color-block-caption-size-mobile);
  }

  .porous-light-image {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  .porous-light-title {
    font-size: var(--pl-font-size);
    font-weight: 600;
    /* Reduced from 900 for better mobile balance */
  }

  .porous-light-paragraph {
    display: none;
    /* Hide existing text on mobile */
  }

  .porous-light-paragraph-mobile {
    display: block;
    /* Show epsilon description on mobile */
    max-width: 100%;
    font-size: calc(var(--font-size-body) * 1.2);
    /* 20% larger for better mobile readability */
    font-weight: 300;
    margin-top: 0;
  }
}