/* ===== FONTS ===== */
@font-face {
  font-family: "Helvetica-Neue";
  src: url("/assets/fonts/HelveticaNeue-Medium.otf");
  font-display: swap;
  font-weight: 500;
  font-style: normal;
}

/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  letter-spacing: 0.25px;
}

body {
  font-family: Helvetica-Neue, Arial, sans-serif;
  font-size: clamp(16px, 1vw, 22px);
}

/* ===== TYPOGRAPHY & LINKS ===== */
a {
  color: black;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.3s;
}

a:hover {
  text-decoration-color: rgb(0, 0, 0, 1);
}

.button {
  cursor: pointer;
  transition: text-decoration-color 0.3s;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  display: inline-block;
  width: fit-content;
}

.button:hover {
  text-decoration-color: rgb(0, 0, 0, 1);
}

.button.active {
  opacity: 1;
}

/* ===== HEADER ===== */
header {
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  position: fixed;
  width: 100vw;
  z-index: 1001;
  transition: opacity 0.3s ease;
}

.header-title {
  flex: 1 1 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.desktop-about-button {
  font-size: clamp(16px, 1vw, 22px);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.3s;
  align-self: flex-start;
  font-weight: normal;
  margin: 0;
  line-height: 1;
}

.desktop-about-button:hover {
  text-decoration-color: rgb(0, 0, 0, 1);
}

.desktop-about-button.active {
  text-decoration-color: rgb(0, 0, 0, 1);
}

/* Active state for mobile About button */
body.about-open .header-filters-mobile .button {
  text-decoration-color: rgb(0, 0, 0, 1) !important;
}

.header-caption {
  position: fixed;
  top: 20px;
  left: 0;
  right: 0;
  text-align: center;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 20px;
  z-index: 10; /* Reduced z-index to not block header interactions */
  line-height: 1;
  pointer-events: none; /* Allow clicks to pass through */
}

/* Ensure clean text rendering for the project name */
.header-caption span {
  transform: translateZ(0);
  visibility: hidden;
  opacity: 0;
}

.header-right {
  flex: 1 1 0;
  text-align: right;
}

/* Mobile filters - hidden on desktop */
.header-filters-mobile {
  display: none;
}

/* ===== FILTERS ===== */
.filter {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.3s;
  cursor: pointer;
}

.filter:hover {
  text-decoration-color: rgb(0, 0, 0, 1);
}

.filter.active {
  text-decoration-color: rgb(0, 0, 0, 1);
}

/* ===== GALLERY ===== */
.gallery {
  padding: 85px 20px;
  display: grid;
  gap: 3px;
  transition: opacity 0.3s ease;
}

/* Responsive grid */
@media (min-width: 0px) {
  .gallery {
    grid-template-columns: repeat(1, 1fr);
  }
}

@media (min-width: 768px) {
  .gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1280px) {
  .gallery {
    grid-template-columns: repeat(5, 1fr);
  }
}

.gallery img {
  width: 100%;
  height: auto;
  transition: opacity 0.3s ease-in-out;
  position: relative;
}

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.lightbox.active {
  display: flex;
}

.lightbox.active ~ .gallery {
  opacity: 1;
}

.lightbox.active ~ .gallery img {
  opacity: 0.05;
}

.lightbox.active ~ .gallery img.current {
  opacity: 1;
}

/* When lightbox is active, hide specific header elements including project name */
.lightbox.active ~ header .header-title,
.lightbox.active ~ header .header-filters-mobile,
.lightbox.active ~ header .header-right,
.lightbox.active ~ header .header-caption {
  opacity: 0;
  pointer-events: none;
}

.lightbox-content {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.lightbox-image-container {
  position: relative;
  display: inline-block;
}

.lightbox-left,
.lightbox-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  height: 100%;
  z-index: 101;
  outline: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  appearance: none;
}

/* Add specific cursor styles for lightbox navigation */
.lightbox-left {
  cursor: w-resize !important;
  left: 0;
}

.lightbox-right {
  cursor: e-resize !important;
  right: 0;
}

.lightbox #lightbox-img {
  display: block;
  max-width: 85vw;
  max-height: 85vh;
  object-fit: contain;
  z-index: 100;
  margin: 0 auto;
}

.project-caption {
  text-align: center;
  font-size: clamp(16px, 1vw, 36px);
}

.lightbox .project-caption {
  position: absolute;
  left: 30%;
  width: 40%;
  cursor: pointer;
  top: 20px;
  line-height: 1;
}

/* ===== ABOUT ===== */
.about {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: none;
  padding: 40px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.9);
}

.about.visible {
  display: block !important;
}

/* Desktop About: start at top, transparent background */
@media (min-width: 768px) {
  body.about-open .about {
    padding-top: 20.5px !important;
    background: rgba(255, 255, 255, 0) !important;
  }
}

/* Mobile About: keep header space, more opaque background */
@media (max-width: 767px) {
  body.about-open .about {
    padding-top: 140px !important;
    background: rgba(255, 255, 255, 0.9) !important;
  }
}

/* Safari-friendly approach: Use body class instead of sibling selectors */

/* Alternative approach: target body class */
body.about-open .header-filters-mobile {
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  display: flex !important;
  z-index: 1003 !important;
  margin-top: 0 !important;
}

/* Hide header completely on desktop when About is open */
@media (min-width: 768px) {
  body.about-open header {
    display: none !important;
  }
}

/* Ensure entire header stays above About section on mobile */
@media (max-width: 767px) {
  body.about-open header {
    z-index: 1001 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    padding: 20px !important;
    margin: 0 !important;
  }
}

/* Remove gaps between header elements when About is open */
body.about-open .header-title {
  gap: 0 !important;
  margin-bottom: 0 !important;
}

/* Ensure mobile filters are always above About */
body.about-open .header-filters-mobile {
  z-index: 1003 !important;
  position: static !important;
}

/* Hide mobile navigation on desktop when About is open */
@media (min-width: 768px) {
  body.about-open .header-filters-mobile {
    display: none !important;
  }
}

.about-container {
  display: flex;
  gap: 40px;
  margin: 0 auto;
}

.left-column,
.right-column {
  flex: 1;
}

.name,
.roles,
.mail,
.instagram,
.bio {
  font-size: clamp(16px, 1vw, 36px);
  line-height: 1;
  width: 100%;
  margin: 0px;
}

.instagram {
  margin-bottom: 2rem;
}

.links-container {
  display: flex;
  gap: 20px;
  margin-left: 0;
}

.links-column {
  flex: 1;
  width: 50%;
}

h3 {
  margin-bottom: 2rem !important;
}

.links-container h3,
.link-item {
  font-size: clamp(16px, 1vw, 36px);
  line-height: 1;
  font-weight: normal;
  margin: 0;
}

.link-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 40px;
}

.link-item span {
  white-space: pre-line;
}

.link-item a {
  text-decoration: none;
  color: inherit;
}

.link-item a:hover {
  text-decoration: underline;
}

.credits {
  position: fixed;
  bottom: 20px;
  left: 40px;
  font-size: 10px;
  color: rgb(0, 0, 0, 0.25);
}

.credits a {
  color: rgb(0, 0, 0, 0.25);
  text-decoration: none;
}

.credits a:hover {
  text-decoration: underline;
}

/* ===== MOBILE NAVIGATION ===== */
.mobile-nav-overlay {
  display: none;
}

.mobile-nav {
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-nav img {
  width: 20px;
  height: 20px;
}

.mobile-nav.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.project-name-display {
  display: flex;
  justify-content: center;
  align-items: center;
}

.project-name-container {
  text-align: center;
}

/* ===== UTILITY CLASSES ===== */
.masked {
  opacity: 0;
  pointer-events: none;
}

.header.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 767px) {
  /* Header mobile layout */
  header {
    padding: 20px;
    flex-direction: column;
    align-items: center;
  }

  .header-title {
    flex: 0 0 auto;
    width: 100%;
    text-align: center;
    margin-bottom: 0px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .header-title p {
    width: 100%;
    text-align: center;
  }

  .desktop-about-button {
    display: none;
  }

  .header-filters-mobile {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
    z-index: 1002; /* Ensure it's above the About overlay */
    min-height: 35px; /* Consistent height to prevent layout shifts */
  }

  .header-caption {
    display: none;
  }

  .header-right {
    display: none;
  }

  /* Gallery mobile layout */
  .gallery {
    padding: 200px 10px 70px 10px;
    gap: 10px;
    grid-template-columns: 1fr;
    min-height: 100vh;
    align-content: center;
  }

  .gallery img {
    opacity: 0.05;
    position: relative;
  }

  .gallery img.current {
    grid-column: 1 / -1;
    opacity: 1;
    align-self: center;
    position: relative;
  }

  /* Mobile navigation - now replaced by carousel system */
  .mobile-nav-overlay {
    display: none; /* Hidden - replaced by carousel click areas */
  }

  /* Mobile carousel container */
  .mobile-carousel-container {
    display: none; /* Hidden by default, shown only on mobile */
    padding-top: 200px; /* Add top spacing for first row */
  }

  /* Smooth transitions for carousel rows */
  .carousel-row img {
    transition: opacity 0.2s ease;
  }

  /* Dynamic height management for carousel rows */
  .carousel-row {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
  }

  @media (max-width: 767px) {
    .mobile-carousel-container {
      display: block;
    }

    /* Project name display at bottom of screen - mobile only */
    #project-name-mobile {
      position: fixed;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%);
      color: black;
      font-size: 16px;
      z-index: 1000;
      opacity: 0;
      transition: opacity 0.3s ease;
      pointer-events: none;
      text-align: center;
    }

    #project-name-mobile.visible {
      opacity: 1;
    }
  }

  .project-name-display {
    position: relative;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .project-name-display.visible {
    opacity: 1;
  }

  /* Disable hover effects on mobile */
  .button:hover,
  .filter:hover,
  a:hover,
  .link-item a:hover,
  .header .about-button:hover {
    text-decoration-color: transparent;
    cursor: default;
  }

  .button.active,
  .filter.active {
    text-decoration-color: rgb(0, 0, 0, 1);
  }

  /* About mobile layout */
  .about {
    padding: 20px;
    -webkit-overflow-scrolling: touch;
  }

  .about-container {
    flex-direction: column;
    gap: 20px;
  }

  .left-column,
  .right-column {
    width: 100%;
    flex: none;
  }

  .links-container {
    width: 100%;
    flex-direction: column;
  }

  .links-column {
    width: 100%;
    margin-bottom: 20px;
  }

  .credits {
    position: static;
    margin-top: 20px;
    left: auto;
    bottom: auto;
  }

  /* Hide lightbox on mobile */
  .lightbox {
    display: none !important;
  }

  /* Hide old gallery grid on mobile - show only carousel rows */
  .gallery {
    display: none !important;
  }

  .lightbox-left,
  .lightbox-right {
    display: none;
  }
}

/* ===== DESKTOP SPECIFIC ===== */
@media (min-width: 768px) {
  .lightbox-left,
  .lightbox-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    cursor: pointer;
    z-index: 1001;
  }

  .mobile-nav-overlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Ensure mobile project name display is completely hidden on desktop */
  .project-name-display {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* Global scroll behavior fixes */
html {
  scroll-behavior: smooth;
}

/* Safari-specific scroll behavior control */
@supports (-webkit-overflow-scrolling: touch) {
  html {
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Custom smooth scroll for Safari */
  .smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
  }
}

/* Safari mobile specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Ensure header stays visible on Safari mobile */
  body.about-open header {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  /* Force hardware acceleration for mobile filters */
  body.about-open .header-filters-mobile {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
}

/* Additional Safari mobile fixes */
@media (max-width: 767px) and (-webkit-touch-callout: none) {
  body.about-open header {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  body.about-open .header-filters-mobile {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

/* Mobile scroll improvements */
@media (max-width: 767px) {
  html {
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Faster scroll for mobile */
  .carousel-row {
    scroll-snap-align: center;
  }

  .mobile-carousel-container {
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
  }

  /* Ensure About section displays properly on mobile */
  .about {
    z-index: 1000;
    padding: 20px;
  }

  .about.visible {
    display: block !important;
  }

  /* Safari-friendly: Use body class instead of sibling selectors */
}
