/* =========================================
   PROJECT POPUP - APPLE STYLE
   Fullscreen Overlay with Cinematic Design
========================================= */

/* Variables */
:root {
  --popup-font-display: 'Outfit', sans-serif;
  --popup-font-body: 'Inter', sans-serif;
  --popup-bg: rgba(10, 10, 15, 0.98);
  --popup-text: #ffffff;
  --popup-text-muted: rgba(255, 255, 255, 0.6);
  --popup-accent: rgba(138, 43, 226, 0.6);
  --popup-border: rgba(255, 255, 255, 0.1);
  --popup-transition: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* =========================================
   Fullscreen Overlay
========================================= */
.project-sheet {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--popup-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10000;

  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity var(--popup-transition),
    visibility var(--popup-transition),
    transform var(--popup-transition);
}

.project-sheet.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* =========================================
   Header - Sticky with Close Button
========================================= */
.sheet-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--popup-bg);

  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 48px;
  border-bottom: 1px solid var(--popup-border);
}

#sheetTitle {
  font-family: var(--popup-font-display);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 200;
  letter-spacing: -0.02em;
  color: var(--popup-text);
  margin: 0;
}

#sheetCloseBtn {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--popup-border);
  border-radius: 50%;
  color: var(--popup-text);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

#sheetCloseBtn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(90deg);
}

/* =========================================
   Content Container
========================================= */
.sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 48px;

  /* Scroll behavior */
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* =========================================
   Meta Info - Tech Stack & Description (Luxury Edition)
========================================= */
.sheet-case-study {
  max-width: 1100px;
  margin: 0 auto 28px;
  padding: 28px;
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: 24px;
  background:
    radial-gradient(circle at 8% 0%, rgba(139, 92, 246, 0.16), transparent 36%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
}

.sheet-case-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.sheet-case-heading span,
.sheet-case-grid article span,
.sheet-highlight-title {
  font-family: var(--popup-font-body);
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(185, 131, 255, 0.92);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.sheet-case-heading h4 {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--popup-font-display);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 300;
}

.sheet-case-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.sheet-case-grid article {
  min-height: 190px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(10, 10, 15, 0.42);
}

.sheet-case-grid article p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-family: var(--popup-font-body);
  font-size: 0.94rem;
  line-height: 1.62;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.sheet-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  color: rgba(255, 255, 255, 0.86);
  font-family: var(--popup-font-body);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  transition:
    transform 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease,
    box-shadow 0.22s ease;
}

.sheet-action:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.075);
}

.sheet-action:focus-visible {
  outline: 2px solid rgba(216, 180, 254, 0.95);
  outline-offset: 3px;
}

.sheet-action-primary {
  color: #14071f;
  border-color: rgba(255, 255, 255, 0.82);
  background: linear-gradient(135deg, #ffffff, #eee1ff 52%, #b983ff);
}

.sheet-action-case-study {
  min-height: 48px;
  padding: 0 22px;
  color: #12071d;
  border-color: rgba(255, 255, 255, 0.88);
  background:
    linear-gradient(135deg, #ffffff 0%, #efe3ff 46%, #c99dff 100%);
  box-shadow:
    0 16px 38px rgba(139, 92, 246, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.sheet-action-case-study:hover {
  color: #0b0412;
  border-color: rgba(255, 255, 255, 1);
  background:
    linear-gradient(135deg, #ffffff 0%, #f5edff 40%, #d8b4fe 100%);
  box-shadow:
    0 20px 48px rgba(185, 131, 255, 0.34),
    0 0 30px rgba(185, 131, 255, 0.16);
}

.sheet-action-arrow {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: rgba(18, 7, 29, 0.1);
  transition: transform 0.22s ease, background 0.22s ease;
}

.sheet-action-case-study:hover .sheet-action-arrow {
  transform: translateX(3px);
  background: rgba(18, 7, 29, 0.16);
}

.sheet-action-disabled {
  color: rgba(255, 255, 255, 0.52);
  border-style: dashed;
  cursor: default;
}

.sheet-action-disabled:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.sheet-highlight-title {
  display: inline-block;
  margin-top: 24px !important;
}

.sheet-highlights {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.sheet-highlights li {
  position: relative;
  padding-left: 20px;
  color: rgba(255, 255, 255, 0.76);
  font-family: var(--popup-font-body);
  font-size: 0.92rem;
  line-height: 1.5;
}

.sheet-highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(185, 131, 255, 0.95);
}

.sheet-meta {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 48px;
  max-width: 1000px;
  margin: 0 auto 64px;
  padding: 32px 40px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(20, 20, 30, 0.6) 50%, rgba(139, 92, 246, 0.05) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 24px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 80px rgba(139, 92, 246, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}

/* Subtle gradient shimmer effect */
.sheet-meta::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(139, 92, 246, 0.03) 25%,
      rgba(255, 255, 255, 0.05) 50%,
      rgba(139, 92, 246, 0.03) 75%,
      transparent 100%);
  animation: shimmer 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmer {

  0%,
  100% {
    transform: translateX(-50%);
  }

  50% {
    transform: translateX(50%);
  }
}

.vertical-separator {
  background: linear-gradient(180deg, transparent 0%, rgba(139, 92, 246, 0.4) 20%, rgba(139, 92, 246, 0.4) 80%, transparent 100%);
  min-height: 100px;
}

.stack-col,
.desc-col {
  position: relative;
  z-index: 1;
}

.stack-col h4,
.desc-col h4 {
  font-family: var(--popup-font-body);
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(139, 92, 246, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
  display: inline-block;
}

.stack-col p,
.desc-col p {
  font-family: var(--popup-font-display);
  font-size: 1.05rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.8;
  margin: 0;
  letter-spacing: 0.01em;
}

/* Tech Chips Container */
.tech-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Individual Tech Chip - Luxury Edition */
.tech-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-family: var(--popup-font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

/* Subtle glow on hover */
.tech-chip::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.tech-chip:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-color: rgba(139, 92, 246, 0.4);
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 8px 24px rgba(139, 92, 246, 0.25),
    0 4px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.tech-chip:hover::after {
  opacity: 1;
}

.tech-icon {
  font-size: 1rem;
  line-height: 1;
}

.tech-icon-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.tech-icon-fallback {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.tech-icon-emoji {
  font-size: 1rem;
  line-height: 1;
}

.tech-name {
  white-space: nowrap;
}

/* =========================================
   Image Gallery - Premium Bento Grid
========================================= */
.sheet-carousel {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-flow: dense;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Bento sizing for images - Simple 12-column system */
/* First image: hero (8 cols) */
.sheet-slide:nth-child(1) {
  grid-column: span 8;
}

/* Second image: side (4 cols) */
.sheet-slide:nth-child(2) {
  grid-column: span 4;
}

/* Images 3-4: half width */
.sheet-slide:nth-child(3),
.sheet-slide:nth-child(4) {
  grid-column: span 6;
}

/* Image 5+: thirds */
.sheet-slide:nth-child(n+5) {
  grid-column: span 4;
}

/* Handle odd numbers of images at the end - make last image expand */
/* If only 3 images, make 3rd full width */
.sheet-slide:nth-child(3):nth-last-child(1) {
  grid-column: span 12;
}

/* If 5 images, make 5th full width */
.sheet-slide:nth-child(5):nth-last-child(1) {
  grid-column: span 12;
}

/* If 7 images, make last one take 2/3 */
.sheet-slide:nth-child(7):nth-last-child(1) {
  grid-column: span 8;
}

/* If 8 images, last one fills remaining space */
.sheet-slide:nth-child(8):nth-last-child(1) {
  grid-column: span 4;
}

/* If 10 images (like filmabend), last one fills remaining */
.sheet-slide:nth-child(10):nth-last-child(1) {
  grid-column: span 4;
}

/* Make first two slides span 2 rows for consistent height */
.sheet-slide:nth-child(1),
.sheet-slide:nth-child(2) {
  grid-row: span 2;
}

/* Make the aspect-ratio-box fill its parent completely */
.sheet-slide {
  min-height: 0;
}

.aspect-ratio-box {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 200px;
  aspect-ratio: 16 / 10;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(20, 20, 30, 0.8), rgba(10, 10, 15, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* For rows 1-2 (hero images), remove aspect ratio and fill height */
.sheet-slide:nth-child(1) .aspect-ratio-box,
.sheet-slide:nth-child(2) .aspect-ratio-box {
  aspect-ratio: unset;
  height: 100%;
}

.aspect-ratio-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.1), transparent 50%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 1;
}

.aspect-ratio-box:hover {
  border-color: rgba(138, 43, 226, 0.3);
  box-shadow:
    0 8px 40px rgba(138, 43, 226, 0.15),
    0 4px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-4px);
}

.aspect-ratio-box:hover::before {
  opacity: 1;
}

.aspect-ratio-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.aspect-ratio-box:hover img {
  transform: scale(1.05);
}

/* =========================================
   Body Scroll Lock
========================================= */
body.no-scroll {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* =========================================
   Mobile Styles
========================================= */
@media (max-width: 768px) {
  .sheet-header {
    padding: 16px 24px;
  }

  #sheetTitle {
    font-size: 1.4rem;
    font-weight: 300;
  }

  #sheetCloseBtn {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
  }

  .sheet-content {
    padding: 32px 24px;
  }

  .sheet-meta {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 40px;
  }

  .vertical-separator {
    display: none;
  }

  .sheet-case-study {
    padding: 20px;
  }

  .sheet-case-grid {
    grid-template-columns: 1fr;
  }

  .sheet-case-grid article {
    min-height: 0;
  }

  .sheet-action-case-study {
    width: 100%;
    min-height: 52px;
  }

  .sheet-carousel {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .sheet-slide {
    width: 100%;
    grid-column: unset !important;
    grid-row: unset !important;
  }

  .sheet-slide .aspect-ratio-box {
    aspect-ratio: 16 / 10;
    height: auto;
    min-height: unset;
    border-radius: 12px;
  }

  .aspect-ratio-box:hover img {
    transform: none;
  }
}

/* iPhone Safe Area */
@supports (padding: max(0px)) {
  .project-sheet {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}
