/* =========================
   PAGE BACKGROUND
========================= */
body {
  background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 50%, #1a1a1a 100%) !important;
  background-attachment: fixed !important;
}


/* =========================
   PROJECTS PAGE
========================= */

.gallery {
  text-align: center;
  padding: 140px 40px 50px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  animation: fadeInUp 0.8s ease forwards;
  animation-delay: 0.2s;
  box-sizing: border-box;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gallery h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2.3rem;
  margin-bottom: 10px;
  position: relative;
  display: inline-block;
  opacity: 0;
  animation: fadeInDown 0.6s ease forwards;
  animation-delay: 0.1s;
  color: #f5f5f5 !important;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* =========================
   IMAGE ENTRANCE ANIMATION
========================= */

@keyframes imageReveal {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.modal-img.entering {
  animation: imageReveal 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.gallery h2::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #d4a574, #c08552);
  animation: expandWidth 0.6s ease forwards;
  animation-delay: 0.5s;
}

@keyframes expandWidth {
  from { width: 0; }
  to   { width: 60px; }
}


/* =========================
   CARD GRID
========================= */

.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: auto auto;
  gap: 16px;
  margin-top: 25px;
  width: 100%;
  max-width: 1300px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 40px;
  flex: 1;
  align-content: center;
  box-sizing: border-box;
}

.card {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 75%;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  opacity: 1;                /* no animation on mobile */
  will-change: transform, opacity;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:nth-child(1) { grid-column: span 2; }
.card:nth-child(2) { grid-column: span 2; }
.card:nth-child(3) { grid-column: span 2; }
.card:nth-child(4) { grid-column: span 2; }
.card:nth-child(5) { grid-column: span 2; }
.card:nth-child(6) { grid-column: span 2; }

@media (min-width: 993px) {
  .card {
    opacity: 0;
    animation: cardFadeInDesktop 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
  .card:nth-child(1) { animation-delay: 0.3s; }
  .card:nth-child(2) { animation-delay: 0.45s; }
  .card:nth-child(3) { animation-delay: 0.6s; }
  .card:nth-child(4) { animation-delay: 0.75s; }
  .card:nth-child(5) { animation-delay: 0.9s; }
  .card:nth-child(6) { animation-delay: 1.05s; }
}

@keyframes cardFadeInDesktop {
  0%   { opacity: 0; transform: translateY(40px) scale(0.92); }
  60%  { opacity: 1; transform: translateY(-5px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.1) 0%,
    rgba(0,0,0,0.4) 60%,
    rgba(0,0,0,0.8) 100%);
  transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.card::after {
  content: attr(data-title);
  position: absolute;
  bottom: 30px;
  left: 30px;
  right: 30px;
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: #fff;
  text-align: left;
  z-index: 2;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card .card-desc {
  position: absolute;
  bottom: 30px;
  left: 30px;
  right: 30px;
  font-size: 0.9rem;
  color: #f0e1c6;
  opacity: 0;
  transform: translateY(15px);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  text-align: left;
  line-height: 1.5;
}

/* Desktop hover only */
@media (hover: hover) {
  .card:hover::before {
    background: linear-gradient(180deg,
      rgba(0,0,0,0.3) 0%,
      rgba(0,0,0,0.6) 50%,
      rgba(0,0,0,0.9) 100%);
  }
  .card:hover {
    transform: translateY(-10px);
    box-shadow: 0 24px 48px rgba(0,0,0,0.3);
  }
  .card:hover::after {
    bottom: 60px;
    /* font-size removed — no zoom */
  }
  .card:hover .card-desc {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s;
  }
}

.card.touch-active::before {
  background: linear-gradient(180deg,
    rgba(0,0,0,0.3) 0%,
    rgba(0,0,0,0.6) 50%,
    rgba(0,0,0,0.9) 100%);
}
.card.touch-active {
  transform: translateY(-10px);
  box-shadow: 0 24px 48px rgba(0,0,0,0.3);
}
.card.touch-active::after {
  bottom: 60px;
  /* font-size removed — no zoom */
}
.card.touch-active .card-desc {
  opacity: 1;
  transform: translateY(0);
}



/* =========================
   MODAL BASE
========================= */

.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  inset: 0;
  overflow: hidden;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: background 0.4s ease, backdrop-filter 0.4s ease;
}

.modal.show {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.95);
  backdrop-filter: blur(10px);
}


/* =========================
   MODAL HEADER
========================= */

.modal-header {
  position: absolute;
  top: 30px;
  left: 40px;
  right: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
}

.modal.show .modal-header {
  opacity: 1;
  pointer-events: all;
  animation: fadeInDown 0.5s ease forwards;
}

.modal-header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

#modal-search {
  padding: 8px 14px;
  width: 280px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(10,10,10,0.7);
  color: #f5f5f5;
  font-size: 0.85rem;
  outline: none;
  backdrop-filter: blur(6px);
  transition: all 0.25s ease;
}

#modal-search::placeholder { color: #aaaaaa; }

#modal-search:focus {
  border-color: #c6b08a;
  box-shadow: 0 0 0 2px rgba(198,176,138,0.35);
}

.modal-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  color: #f0e1c6;
  font-weight: 500;
  white-space: nowrap;
}

.close {
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
  margin-left: auto;
}

.close:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.4);
  transform: rotate(90deg) scale(1.1);
}


/* =========================
   MODAL CONTAINER
========================= */

.modal-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1400px;
  height: 100vh;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9) translateY(30px);
  transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding-top: 90px;
  box-sizing: border-box;
}

.modal.show .modal-container {
  opacity: 1;
  transform: scale(1) translateY(0);
}


/* =========================
   MODAL IMAGE
========================= */

.modal-image-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.modal-img {
  max-width: 90%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  cursor: default;
  filter: none;
  image-rendering: auto;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.modal-img.changing {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* =========================
   MODAL INFO
========================= */

.modal-info {
  margin-top: 20px;
  width: 100%;
  max-width: 800px;
  text-align: center;
  padding-bottom: 20px;
  flex-shrink: 0;
}

.modal-info p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: #d4a574;
  margin: 0 0 10px 0;
  font-weight: 500;
}

.modal-counter {
  font-size: 0.85rem;
  color: #999;
  letter-spacing: 1px;
}


/* =========================
   NAVIGATION ARROWS
========================= */

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 3rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
}

.modal.show .modal-nav {
  opacity: 1;
  pointer-events: all;
}

.modal-nav:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
  transform: translateY(-50%) scale(1.1);
}

.modal-nav:active {
  transform: translateY(-50%) scale(0.95);
}

.prev-btn { left: 40px; }
.next-btn { right: 40px; }

.modal-nav:disabled {
  opacity: 0.3 !important;
  cursor: not-allowed;
  pointer-events: all;
}

.modal-nav:disabled:hover {
  transform: translateY(-50%) scale(1);
  background: rgba(255,255,255,0.1);
}


/* =========================
   BUNGALOW CLIENT GRID
========================= */

.bungalow-client-grid {
  width: 100%;
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 10px 20px 30px;
  align-content: start;
  box-sizing: border-box;
  scroll-behavior: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.bungalow-client-grid::-webkit-scrollbar { display: none; }

.bungalow-client-card-wrapper {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 75%;
  opacity: 0;
  animation: bungalowCardIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.bungalow-client-card {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Desktop hover only */
@media (hover: hover) {
  .bungalow-client-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 24px 48px rgba(0,0,0,0.4);
  }
  .bungalow-client-card:hover .bungalow-client-overlay {
    background: linear-gradient(180deg,
      rgba(0,0,0,0.3) 0%,
      rgba(0,0,0,0.6) 50%,
      rgba(0,0,0,0.9) 100%);
  }
  .bungalow-client-card:hover .bungalow-client-name {
    transform: translateY(-28px);
  }
  .bungalow-client-card:hover .bungalow-client-location {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.05s;
  }
  .bungalow-client-card:hover .bungalow-client-count {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.08s;
  }
}

/* Touch active state for client cards */
.bungalow-client-card.touch-active {
  transform: translateY(-10px);
  box-shadow: 0 24px 48px rgba(0,0,0,0.4);
}
.bungalow-client-card.touch-active .bungalow-client-overlay {
  background: linear-gradient(180deg,
    rgba(0,0,0,0.3) 0%,
    rgba(0,0,0,0.6) 50%,
    rgba(0,0,0,0.9) 100%);
}
.bungalow-client-card.touch-active .bungalow-client-name {
  transform: translateY(-28px);
}
.bungalow-client-card.touch-active .bungalow-client-location {
  opacity: 1;
  transform: translateY(0);
}
.bungalow-client-card.touch-active .bungalow-client-count {
  opacity: 1;
  transform: translateY(0);
}

.bungalow-client-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.1) 0%,
    rgba(0,0,0,0.4) 60%,
    rgba(0,0,0,0.8) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px 24px;
  transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.bungalow-client-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.bungalow-client-location {
  font-size: 0.88rem;
  color: #f0e1c6;
  margin-top: 4px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}

.bungalow-client-count {
  font-size: 0.82rem;
  color: #d4a574;
  margin-top: 5px;
  letter-spacing: 0.5px;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}


/* =========================
   BUNGALOW CARD ENTRANCE ANIMATION
========================= */

@keyframes bungalowCardIn {
  0%   { opacity: 0; transform: translateY(30px) scale(0.92); }
  60%  { opacity: 1; transform: translateY(-4px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}


/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1400px) {
  .grid { max-width: 1100px; }
  .bungalow-client-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1200px) {
  .gallery h2 { font-size: 2.1rem; }
  .grid { gap: 14px; margin-top: 20px; max-width: 1000px; }
  .gallery { padding: 85px 30px 45px; }
  .bungalow-client-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
  .gallery { padding: 100px 20px 20px; min-height: auto; max-height: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 20px; padding: 0 20px; }
  .card { padding-bottom: 75%; grid-column: span 1 !important; }
  .card:nth-child(4), .card:nth-child(5) { grid-column: span 1 !important; }
  .bungalow-client-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .bungalow-client-card-wrapper { padding-bottom: 75%; }
  .bungalow-client-name { font-size: 1.3rem; }
}

@media (max-width: 768px) {
  .gallery { padding: 120px 20px 40px; }
  .gallery h2 { font-size: 2rem; }
  .grid { grid-template-columns: 1fr; margin-top: 30px; }
  .card { padding-bottom: 75%; }
  .card::after { font-size: 1.4rem; bottom: 20px; left: 20px; right: 20px; }
  .card .card-desc { bottom: 20px; left: 20px; right: 20px; font-size: 0.85rem; }

  .modal-header {
    top: 16px;
    left: 16px;
    right: 16px;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .modal-title {
    position: static;
    transform: none;
    font-size: 1.3rem;
    text-align: center;
    order: -1;
    white-space: normal;
    width: 100%;
    padding: 0 44px;
    box-sizing: border-box;
  }

  .modal-header-left {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }

  #modal-search {
    width: auto;
    flex: 1;
    max-width: 260px;
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1rem;
    width: 38px;
    height: 38px;
  }

  .modal-container {
    padding-top: 100px;
    height: 100vh;
    overflow: hidden;
    justify-content: center;
  }

  .modal-image-wrapper {
    flex: none;
    width: 100%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .modal-image-wrapper.zoomed {
  overflow: visible;
  }
  /* Hide UI when zoomed on mobile */
  .modal.img-zoomed .modal-header,
  .modal.img-zoomed .modal-info,
  .modal.img-zoomed .modal-nav {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  /* 1. Smooth fade-back transition */
  .modal-header,
  .modal-info,
  .modal-nav {
    transition: opacity 0.2s ease;
  }

  /* 2. Keep close button always tappable */
  .modal.img-zoomed .close {
    opacity: 1;
    pointer-events: auto;
  }
  
  .modal-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .modal-info { margin-top: 14px; padding-bottom: 12px; }
  .modal-info p { font-size: 0.9rem; }
  .modal-counter { font-size: 0.8rem; }

  .modal-nav { width: 46px; height: 46px; font-size: 2rem; }
  .prev-btn { left: 6px; }
  .next-btn { right: 6px; }

  .bungalow-client-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 10px 10px 20px;
  }
  .bungalow-client-card-wrapper { padding-bottom: 75%; }
  .bungalow-client-name { font-size: 1.1rem; }
  .bungalow-client-location { font-size: 0.78rem; }
}

@media (max-width: 480px) {
  .card::after { font-size: 1.2rem; }

  .modal-header { top: 12px; left: 12px; right: 12px; }
  .modal-title { font-size: 1.1rem; padding: 0 38px; }
  #modal-search { font-size: 0.75rem; max-width: 150px; }
  .close { top: 10px; right: 12px; width: 34px; height: 34px; font-size: 0.9rem; }

  .modal-container { padding-top: 90px; justify-content: center; }

  .modal-image-wrapper { flex: none; width: 100%; padding: 0; }

  .modal-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .modal-info { margin-top: 10px; padding-bottom: 10px; }
  .modal-info p { font-size: 0.82rem; }
  .modal-counter { font-size: 0.75rem; }

  .modal-nav { width: 38px; height: 38px; font-size: 1.5rem; }
  .prev-btn { left: 2px; }
  .next-btn { right: 2px; }

  .bungalow-client-grid { grid-template-columns: repeat(1, 1fr); gap: 10px; }
  .bungalow-client-card-wrapper { padding-bottom: 75%; }
  .bungalow-client-name { font-size: 1rem; }
  .bungalow-client-location { font-size: 0.7rem; }
  .bungalow-client-count { font-size: 0.7rem; }
}


/* ========================
   GROUP CARD BADGE
======================== */

.is-group-card::after {
  content: '›';
  position: absolute;
  top: 16px;
  right: 18px;
  font-size: 1.8rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1;
  pointer-events: none;
  z-index: 3;
}
