/* ==================== GLOBAL ==================== */
html,
body {
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  max-width: 100vw;
}
*,
*::before,
*::after {
  box-sizing: inherit;
}
/* Remove default tap highlight */
button,
a,
input,
select,
textarea,
*[role="button"],
.project-back-btn,
.filter-btn,
.dropdown-trigger,
.lightbox-close,
.lightbox-prev,
.lightbox-next,
.lightbox-dot {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}
/* ==================== MASONRY GRID ==================== */
.masonry-grid {
  position: relative;
  z-index: 10;
  width: calc(100% - 120px);
  max-width: 1400px;
  margin: 40px auto 80px;
  overflow-x: hidden;
}
@media (max-width: 1024px) {
  .masonry-grid {
    width: calc(100% - 80px);
  }
}
@media (max-width: 768px) {
  .masonry-grid {
    width: 100%;
    max-width: calc(100% - 32px);
    margin: 32px auto 64px;
  }
}
.masonry-grid-item {
  position: absolute;
  width: 100%;
  left: 0;
  right: 0;
  box-shadow: var(--shadow-black);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.3s ease, box-shadow 0.4s ease;
  /* removed will-change here to prevent issues */
}
.masonry-grid-item img,
.masonry-grid-item video {
  width: 100%;
  height: auto;
  display: block;
}
@media (hover: hover) and (pointer: fine) {
  .hover-wrapper {
    transition: transform 0.3s ease, box-shadow 0.4s ease;
  }
  .masonry-grid-item:hover .hover-wrapper {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
  }
  .masonry-grid-item.no-hover:hover .hover-wrapper {
    transform: none;
    box-shadow: none;
  }
}
/* NEW: hidden state for filters */
.masonry-grid-item.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.masonry-grid-item.is-visible {
  opacity: 1;
  transform: translateY(0);
  will-change: transform, opacity; /* moved will-change here */
}
/* ==================== RESPONSIVE COLUMNS ==================== */
:root {
  --columns-projects: 6;
  --columns-category: 5;
}
@media (max-width: 1024px) {
  :root {
    --columns-projects: 4;
    --columns-category: 3;
  }
}
@media (max-width: 768px) {
  :root {
    --columns-projects: 2;
    --columns-category: 2;
  }
}
/* ==================== FILTER HEADER ==================== */
#filter-title-container {
  text-align: center;
  margin: 0 16px 24px;
}
#filter-title {
  font-family: "Playfair Display", serif;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--cyan);
  margin: 0;
  line-height: 1.1;
}
#filter-subtext {
  font-size: 1rem;
  color: white;
  margin-top: 0.5rem;
  opacity: 0.9;
}
/* ==================== FILTER BUTTONS ==================== */
.portfolio-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto 64px;
  padding: 0 5%;
}
.filter-btn {
  background: transparent;
  border: 2px solid var(--magenta);
  color: var(--text-light);
  padding: 11px 29px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 300;
  line-height: 1;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.filter-btn.active {
  background: var(--magenta);
  color: white;
  transform: none;
  box-shadow: none;
}
@media (hover: hover) and (pointer: fine) {
  .filter-btn:hover {
    background: var(--magenta);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 0, 170, 0.2);
  }
}
@media (hover: none), (pointer: coarse) {
  .filter-btn {
    transform: none !important;
    box-shadow: none !important;
  }
  .filter-btn:hover {
    background: transparent;
    color: var(--text-light);
  }
  .filter-btn:active {
    background: rgba(255, 0, 170, 0.15);
  }
}
/* ==================== MOBILE DROPDOWN ==================== */
.filter-dropdown-container {
  display: none;
  margin: 0 auto 3rem;
  padding: 0 16px;
  max-width: 420px;
  width: 100%;
}
.custom-dropdown {
  position: relative;
  width: 100%;
}
.dropdown-trigger {
  width: 100%;
  padding: 14px 52px 14px 24px;
  font-size: 1.1rem;
  font-family: "Inter", sans-serif;
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--magenta);
  border-radius: 9999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.25s ease;
}
@media (hover: hover) and (pointer: fine) {
  .dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: #ff4db3;
    transform: translateY(-1px);
  }
}
.dropdown-trigger:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(0, 255, 255, 0.2);
}
.dropdown-arrow {
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: transform 0.3s ease, opacity 0.2s ease;
  opacity: 0.9;
}
.dropdown-trigger[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(180deg);
}
.dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: #111;
  border: 1px solid rgba(255, 0, 170, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  list-style: none;
  padding: 8px 0;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}
.dropdown-list.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-item {
  padding: 12px 24px;
  font-size: 1rem;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s ease;
}
.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(255, 0, 170, 0.15);
  color: white;
}
.dropdown-item[aria-selected="true"] {
  background: var(--magenta);
  color: white;
  font-weight: 500;
}
/* Show dropdown + hide buttons on mobile */
@media (max-width: 768px) {
  .portfolio-filters {
    display: none !important;
  }
  .filter-dropdown-container {
    display: block !important;
  }
  #filter-title {
    font-size: 2.6rem;
  }
}
/* ==================== BACK BUTTON ==================== */
.project-back-btn {
  background: transparent;
  border: 2px solid var(--magenta);
  color: var(--text-light);
  margin: 80px auto;
  padding: 11px 29px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 300;
  display: block;
  transition: background 0.3s ease, transform 0.3s ease;
}
@media (hover: hover) and (pointer: fine) {
  .project-back-btn:hover {
    background: var(--magenta);
    color: var(--text-light);
    transform: translateY(-2px);
  }
}
.project-back-btn:active,
.project-back-btn:focus {
  background: transparent !important;
  transform: none !important;
  box-shadow: none !important;
  outline: none !important;
}
/* ==================== LIGHTBOX ==================== */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
}
.lightbox.active {
  display: flex;
}
.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
  z-index: 1;
}
.lightbox-content {
  position: relative;
  max-width: 1200px;
  max-height: 675px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: auto;
}
.lightbox-frame {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}
.lightbox-img,
.lightbox-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: var(--shadow-strong);
}
.lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.5);
  color: var(--cyan);
  font-size: 2rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  z-index: 20;
}
@media (hover: hover) and (pointer: fine) {
  .lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
    color: var(--magenta);
  }
}
.lightbox-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  gap: 12px;
  z-index: 15;
}
.lightbox-prev,
.lightbox-next {
  background: transparent;
  border: none;
  color: var(--cyan);
  font-size: 2rem;
  cursor: pointer;
  padding: 0 12px;
  transition: color 0.2s;
  z-index: 15;
  touch-action: manipulation;
}
@media (hover: hover) and (pointer: fine) {
  .lightbox-prev:hover,
  .lightbox-next:hover {
    color: var(--magenta);
  }
}
.lightbox-prev:active,
.lightbox-next:active,
.lightbox-prev:focus,
.lightbox-next:focus {
  color: var(--cyan);
  outline: none;
}
.lightbox-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 90vw;
  margin-top: 12px;
  z-index: 15;
}
.lightbox-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background: var(--white-alpha-12);
  cursor: pointer;
  transition: background 0.3s;
}
.lightbox-dot.active {
  background: var(--cyan);
}
@media (max-width: 1024px) {
  .lightbox-frame {
    max-width: 90%;
    max-height: 50vh;
  }
  .lightbox-prev,
  .lightbox-next {
    font-size: 1.5rem;
  }
}
@media (max-width: 640px) {
  .lightbox-frame {
    max-height: 82vh;
    max-width: 100%;
  }
  .lightbox-controls {
    margin-top: 8px;
    margin-bottom: env(safe-area-inset-bottom, 8px);
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}