/* =====================
   Bosansko Blago - Fresh Design
   Child-friendly, illustration-focused
   ===================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #FAFAF8;
  /* Subtle ćilim-inspired diamond pattern */
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c4a574' fill-opacity='0.06'%3E%3Cpath d='M30 0l30 30-30 30L0 30z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  color: #3d3d3d;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Header */
header {
  position: relative;
  padding: 1.25rem 1rem;
  text-align: center;
  flex-shrink: 0;
}

header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 200%;
  z-index: -1;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  -webkit-mask-image: linear-gradient(to bottom,
    black 0%,
    rgba(0, 0, 0, 0.6) 30%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 100%);
  mask-image: linear-gradient(to bottom,
    black 0%,
    rgba(0, 0, 0, 0.6) 30%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 100%);
}

header h1 {
  position: relative;
  font-size: 1.75rem;
  font-weight: 700;
  color: #5a4a3a;
  letter-spacing: 0.02em;
}

/* Main Content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  overflow: hidden;
}

/* Swiper Container */
.swiper {
  width: 100%;
  max-width: 320px;
  height: 440px;
  padding: 1rem 0;
  opacity: 0;
}

.swiper.loaded {
  animation: cardEntrance 0.5s ease-out forwards;
}

/* Hide Swiper shadows */
.swiper-slide-shadow,
.swiper-slide-shadow-left,
.swiper-slide-shadow-right {
  display: none !important;
}

.swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cards - Full bleed images */
.card {
  position: relative;
  width: 280px;
  height: 380px;
  border-radius: 1.5rem;
  box-shadow: -4px 0 4px rgba(0, 0, 0, 0.15), 4px 0 4px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.3s ease;
  will-change: transform;
}

.card-image {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  border-radius: 1.5rem;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Title overlay at bottom */
.card-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem 1.25rem 1.5rem;
  border-radius: 0 0 1.5rem 1.5rem;
  background: linear-gradient(to top,
    rgba(0, 0, 0, 0.35) 0%,
    rgba(0, 0, 0, 0.2) 30%,
    rgba(0, 0, 0, 0.08) 60%,
    transparent 100%);
}

.card-title::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 0 0 1.5rem 1.5rem;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to top,
    black 0%,
    rgba(0, 0, 0, 0.6) 30%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 100%);
  mask-image: linear-gradient(to top,
    black 0%,
    rgba(0, 0, 0, 0.6) 30%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 100%);
}

.card-title h2 {
  position: relative;
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  text-align: center;
}

/* Swiper Pagination */
.swiper-pagination {
  position: relative;
  margin-top: 0.75rem;
}

.swiper-pagination-bullet {
  width: 8px;
  height: 8px;
  background: rgba(90, 74, 58, 0.3);
  opacity: 1;
  transition: all 0.3s ease;
}

.swiper-pagination-bullet-active {
  background: #5a4a3a;
  width: 24px;
  border-radius: 4px;
}

/* Footer */
footer {
  position: relative;
  padding: 0.75rem 1rem;
  text-align: center;
  flex-shrink: 0;
}

footer::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 200%;
  z-index: -1;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  -webkit-mask-image: linear-gradient(to top,
    black 0%,
    rgba(0, 0, 0, 0.6) 30%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 100%);
  mask-image: linear-gradient(to top,
    black 0%,
    rgba(0, 0, 0, 0.6) 30%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 100%);
}

footer p {
  position: relative;
  font-size: 0.875rem;
  color: rgba(90, 74, 58, 0.7);
}

footer .heart {
  color: #e85a5a;
  display: inline-block;
  animation: heartbeat 1.5s ease-in-out infinite;
}

footer .authors {
  color: #5a4a3a;
  font-weight: 500;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Entrance animation */
@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Deep link animation */
@keyframes deepLinkPulse {
  0% { box-shadow: -4px 0 4px rgba(0, 0, 0, 0.15), 4px 0 4px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(90, 74, 58, 0.4); }
  50% { box-shadow: -4px 0 4px rgba(0, 0, 0, 0.15), 4px 0 4px rgba(0, 0, 0, 0.15), 0 0 0 12px rgba(90, 74, 58, 0); }
  100% { box-shadow: -4px 0 4px rgba(0, 0, 0, 0.15), 4px 0 4px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(90, 74, 58, 0); }
}

.card.deep-linked {
  animation: deepLinkPulse 0.8s ease-out;
}

.card.pulsing {
  animation: deepLinkPulse 1.8s ease-out infinite;
}

/* No scroll when overlay is open */
body.no-scroll {
  overflow: hidden;
}

/* =====================
   Expanded Card Overlay
   ===================== */
.card-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  visibility: hidden;
  pointer-events: none;
}

.card-overlay.active {
  visibility: visible;
  pointer-events: auto;
}


.expanded-card {
  position: absolute;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 1.5rem;
  transform-origin: center center;
  will-change: transform, width, height, top, left, border-radius;
}

/* Animation state - expand/collapse */
.card-overlay.animating .expanded-card {
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              width 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              height 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              top 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              left 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              border-radius 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Compact animation when dragging */
.expanded-card.swipe-start {
  transition: transform 0.2s ease-out, border-radius 0.2s ease-out;
}

/* Swiping state - no transition for immediate response */
.expanded-card.swiping {
  transition: none !important;
}

/* Content fade (text and close button) */
.expanded-content,
.expanded-card .close-btn {
  transition: opacity 0.3s ease;
}

.expanded-card.content-hidden .expanded-content,
.expanded-card.content-hidden .close-btn {
  opacity: 0 !important;
  pointer-events: none;
  transition: none; /* Immediate hide */
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #5a4a3a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.close-btn:hover {
  background: #ffffff;
  transform: scale(1.1);
}

.close-btn:active {
  transform: scale(0.95);
}

.expanded-image {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.expanded-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Expanded content at bottom */
.expanded-content {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

/* Dark gradient for readability */
.expanded-content::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 250%;
  z-index: -2;
  background: linear-gradient(to top,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.5) 20%,
    rgba(0, 0, 0, 0.35) 40%,
    rgba(0, 0, 0, 0.15) 60%,
    transparent 80%);
  pointer-events: none;
}

/* Blur layer */
.expanded-content::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 250%;
  z-index: -1;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  -webkit-mask-image: linear-gradient(to top,
    black 0%,
    rgba(0, 0, 0, 0.8) 20%,
    rgba(0, 0, 0, 0.5) 40%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 80%);
  mask-image: linear-gradient(to top,
    black 0%,
    rgba(0, 0, 0, 0.8) 20%,
    rgba(0, 0, 0, 0.5) 40%,
    rgba(0, 0, 0, 0.2) 60%,
    transparent 80%);
}

.expanded-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  margin: 0 0 0.5rem 0;
}

.expanded-content p {
  font-size: 1rem;
  line-height: 1.7;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  margin: 0;
}

/* Responsive adjustments */
@media (min-width: 480px) {
  header h1 {
    font-size: 2rem;
  }

  .swiper {
    max-width: 360px;
    height: 500px;
  }

  .card {
    width: 320px;
    height: 420px;
  }

  .card-title h2 {
    font-size: 1.75rem;
  }
}

@media (min-width: 768px) {
  header h1 {
    font-size: 2.25rem;
  }

  .swiper {
    max-width: 420px;
    height: 560px;
  }

  .card {
    width: 360px;
    height: 480px;
  }

  .expanded-content {
    padding: 2rem;
  }

  .expanded-content h2 {
    font-size: 2rem;
  }

  .expanded-content p {
    font-size: 1.1rem;
  }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 0.5rem 1rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  .swiper {
    height: 280px;
    padding: 0.5rem 0;
  }

  .card {
    width: 220px;
    height: 220px;
  }

  .card-title {
    padding: 1rem;
  }

  .card-title h2 {
    font-size: 1.25rem;
  }

  footer {
    padding: 0.5rem;
  }

  footer p {
    font-size: 0.75rem;
  }

  .expanded-content {
    padding: 1rem;
  }

  .expanded-content h2 {
    font-size: 1.25rem;
  }

  .expanded-content p {
    font-size: 0.95rem;
    line-height: 1.5;
  }
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}
