:root {
  --card-width: max(36vw, 520px);
  --card-height: 250px;
  --card-gap: 50vh;
  --card-start: -60vh;
  --card-side-margin: clamp(12px, 10vw, 144px);
  --section-height: 100vh;
  --neon-blue: #66d9ef;
  --neon-purple: #b400ff;
  --neon-pink: #ff6ec7;
}

* {
  box-sizing: border-box;
  overscroll-behavior: none;
}

body {
  margin: 0;
  padding: 0;
  min-height: var(--section-height);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow-x: hidden;
  position: relative;
}

/* ===== Fixed background layers ===== */

.bg-layers {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-layers .bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: strict;
}

.city2-layer {
  background-image: url('/img/city2.webp');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center 100%;
  z-index: 2;
}

.no-webp .city2-layer { background-image: url('/img/city2.png'); }

.cloud-layer {
  background-image: url('/img/cloud.webp');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center 100%;
  z-index: 1;
}

.no-webp .cloud-layer { background-image: url('/img/cloud.jpg'); }

.city-layer {
  background-image: url('/img/city.webp');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center 100%;
  z-index: 3;
}

.no-webp .city-layer { background-image: url('/img/city.png'); }

.bottom-layer {
  background-image: url('/img/bottom.webp');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center 100%;
  z-index: 4;
}

.no-webp .bottom-layer { background-image: url('/img/bottom.png'); }

/* Safari compositor hints */
.is-safari .bg-layers .bg {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* ===== Top logo section ===== */

.top-logo-section {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.top-logo-section.top-visible {
  opacity: 1;
  transform: translateY(0);
}

.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  position: relative;
  flex-direction: column;
}

.main-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(32px, 8vw, 120px);
  font-weight: 700;
  letter-spacing: clamp(10px, 1.4vw, 28px);
  text-transform: uppercase;
  color: #ffffff;
  margin: 0;
  text-align: center;
  position: relative;
  z-index: 10;
}

/* ===== Final logo section ===== */

.final-logo-section {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(48px, 12vh, 160px) 5vw;
  text-align: center;
  z-index: 30;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.final-logo-section.final-visible {
  opacity: 1;
  transform: translateY(0);
}

.final-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 4vh, 32px);
}

.final-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(32px, 10vw, 120px);
  font-weight: 700;
  letter-spacing: clamp(10px, 1.4vw, 28px);
  text-transform: uppercase;
  color: #ffffff;
  margin: 0;
  filter: drop-shadow(0 0 18px rgba(102, 217, 239, 0.35));
}

.final-accent {
  width: clamp(200px, 55vw, 600px);
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--neon-purple) 0%, var(--neon-blue) 50%, var(--neon-pink) 100%);
  transform: skew(-12deg);
  box-shadow: 0 0 24px rgba(102, 217, 239, 0.4);
  opacity: 0.85;
}

/* ===== Shar layers — GPU-accelerated via transform ===== */

.shar-layer {
  position: absolute;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.8s ease-out;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  will-change: transform, opacity;
  top: 0;
  left: 0;
}

.shar-layer.visible {
  opacity: 1;
}

.shar1-layer {
  background-image: url('/img/shar.webp');
  width: clamp(200px, 22vw, 360px);
  height: clamp(200px, 22vw, 360px);
  left: 25vw;
  margin-left: calc(clamp(200px, 22vw, 360px) / -2);
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.25));
}

.no-webp .shar1-layer { background-image: url('/img/shar.png'); }

.shar2-layer {
  background-image: url('/img/shar2.webp');
  width: clamp(120px, 15vw, 260px);
  height: clamp(120px, 15vw, 260px);
  left: 74vw;
  margin-left: calc(clamp(120px, 15vw, 260px) / -2);
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.22));
}

.no-webp .shar2-layer { background-image: url('/img/shar2.png'); }

/* ===== Cloud sequence ===== */

.cloud-sequence-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--section-height);
  pointer-events: none;
  z-index: 5;
}

.cloud-sequence-item {
  position: absolute;
  opacity: 0;
  --cloud-x: 0px;
  transform: translate3d(var(--cloud-x), 0, 0);
  transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.8s ease-out;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.18));
  will-change: transform, opacity;
}

.cloud-sequence-item.entered {
  opacity: 1;
}

/* ===== Flying cards with optimized glassmorphism ===== */

.cards-grid {
  position: fixed;
  top: var(--card-start);
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column-reverse;
  gap: 80px;
  z-index: 20;
  pointer-events: none;
  padding: 0 var(--card-side-margin);
  box-sizing: border-box;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.cards-grid .flying-card {
  position: relative;
  pointer-events: none;
}

.cards-grid .flying-card.left { align-self: flex-start; }
.cards-grid .flying-card.right { align-self: flex-end; }

.flying-card {
  position: relative;
  width: var(--card-width);
  padding: 24px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: layout style;
  isolation: isolate;
  transition: none;
  z-index: 20;
  color: #0a0a0b;
  pointer-events: none;
  overflow: visible;
}

.flying-card.card-visible {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  border-color: rgba(255, 255, 255, 0.25);
}

.flying-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0.08) 30%,
    rgba(255, 255, 255, 0.03) 70%,
    rgba(255, 255, 255, 0.01) 100%);
  border-radius: 16px;
  pointer-events: none;
  z-index: -1;
}

.flying-card::after {
  content: '';
  position: absolute;
  top: 1px; left: 1px; right: 1px; bottom: 1px;
  background: linear-gradient(45deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%,
    rgba(255, 255, 255, 0.05) 100%);
  border-radius: 15px;
  pointer-events: none;
  z-index: -1;
}

.card-inner {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  padding: 8px 0;
}

.flying-card h3 {
  margin: 0 0 10px 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #1a1a1a;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.flying-card p {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  color: #2c2c2c;
  line-height: 1.4;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
}

.flying-card .lorem-text {
  margin: 0 0 16px 0;
  font-size: 0.8rem;
  color: #333333;
  line-height: 1.3;
  text-align: justify;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.1);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  font-size: clamp(0.8rem, 1.5vw, 0.95rem);
}

.card-date {
  color: rgba(0, 0, 0, 0.6);
  font-weight: 500;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}

.card-link {
  color: #0066cc;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
  position: relative;
}

.card-link:hover {
  color: #0088ff;
  text-decoration: underline;
}

/* Card overlay decoration */
.card-overlay {
  position: absolute;
  --overlay-w: 150px;
  width: var(--overlay-w);
  aspect-ratio: 320 / 86;
  background-image: url('/img/cardholder_01.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 25;
  pointer-events: none;
  bottom: -15px;
}

.no-webp .card-overlay { background-image: url('/img/cardholder_01.png'); }

.cards-grid .flying-card.left .card-overlay {
  right: -5px;
  left: auto;
  transform: none;
}

.cards-grid .flying-card.right .card-overlay {
  left: -5px;
  right: auto;
  transform: scaleX(-1);
}

/* ===== Reduced motion ===== */

@media (prefers-reduced-motion: reduce) {
  .bg-layers .bg,
  .shar-layer,
  .cloud-sequence-item,
  .cards-grid {
    transform: none !important;
    transition: none !important;
  }
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  :root {
    --card-side-margin: clamp(8px, 6vw, 48px);
  }
  .cards-grid {
    position: relative;
    top: 0;
    height: auto;
    gap: 24px;
    padding: 0 12px;
    transform: none !important;
    will-change: auto;
  }
  .flying-card {
    width: calc(100vw - 24px);
  }
  .flying-card.card-visible {
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
    box-shadow:
      0 6px 24px rgba(0, 0, 0, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.25);
  }
}

@media (max-width: 480px) {
  :root {
    --card-width: calc(100vw - 20px);
    --card-side-margin: 10px;
  }
  .flying-card.card-visible {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow:
      0 4px 16px rgba(0, 0, 0, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

body.parallax-disabled .bg-layers { position: fixed !important; }

@supports not (backdrop-filter: blur(1px)) {
  .flying-card.card-visible {
    background: rgba(255, 255, 255, 0.85);
    box-shadow:
      0 10px 40px rgba(0, 0, 0, 0.15),
      0 3px 12px rgba(0, 0, 0, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.5);
  }
}
