/* ===================== CATALOGUE FLIPBOOK ===================== */

.catalogue-overlay {
  position: fixed;
  inset: 0;
  z-index: 7000;
  background:
    radial-gradient(ellipse at center, rgba(40,38,34,.98) 0%, rgba(10,10,8,.99) 75%);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px 20px;
  overflow: hidden;
}

.catalogue-overlay.open {
  display: flex;
}

.catalogue-topbar {
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 5;
}

.catalogue-title {
  font-family: var(--font-head);
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  letter-spacing: .05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

.catalogue-title .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
}

.catalogue-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .25s ease, transform .25s ease;
}

.catalogue-close:hover {
  background: var(--orange);
  transform: rotate(90deg);
}

.book-viewport {
  perspective: 2600px;
  perspective-origin: center;
  width: min(78vw, 380px);
  aspect-ratio: 774 / 1095;
  position: relative;
  touch-action: pan-y;
  overflow: visible;
}

.book {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;

  /* Centering control */
  --book-shift: 0%;
  transform: translateX(var(--book-shift));
  transition: transform .65s cubic-bezier(.22,.61,.36,1);

  box-shadow:
    0 50px 90px -25px rgba(0,0,0,.7),
    0 0 0 1px rgba(255,255,255,.04);
  border-radius: 3px 6px 6px 3px;
  will-change: transform;
}

/* After first page turn, the full open spread comes into center */
.book.spread-centered {
  --book-shift: 50%;
}

.book-spine {
  position: absolute;
  left: -3px;
  top: 2%;
  width: 8px;
  height: 96%;
  background: linear-gradient(90deg, rgba(0,0,0,.5), rgba(0,0,0,0));
  border-radius: 3px 0 0 3px;
  z-index: 1;
}

.leaf {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform .95s cubic-bezier(.645,.045,.355,1);
  cursor: pointer;
  pointer-events: none;
  will-change: transform;
}

.leaf.is-active {
  pointer-events: auto;
}

.leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 3px 6px 6px 3px;
  overflow: hidden;
  background: var(--white);
}

.leaf-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

.leaf-face.front {
  z-index: 2;
}

.leaf-face.front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,.16), transparent 7%);
  pointer-events: none;
}

.leaf-face.back {
  transform: rotateY(180deg);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaf-face.back .back-mark {
  width: 100%;
  opacity: 0.28;
  filter: grayscale(1);
}

.leaf-face.back::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, rgba(0,0,0,.14), transparent 7%);
  pointer-events: none;
}

.leaf.flipped {
  transform: rotateY(-180deg);
}

.leaf.dragging {
  transition: none;
}

.catalogue-controls {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 70px;
  z-index: 5;
}

.cat-nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .25s ease, transform .2s ease;
}

.hide-on-last{
  opacity: 0;
}

.cat-nav-btn:hover:not(:disabled) {
  background: var(--orange);
  transform: scale(1.08);
}

.cat-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.catalogue-count {
  font-family: var(--font-head);
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  letter-spacing: .04em;
  min-width: 64px;
  text-align: center;
}

.catalogue-hint {
  margin-top: 14px;
  font-size: 12.5px;
  color: rgba(255,255,255,0.35);
  font-family: var(--font-head);
  letter-spacing: .03em;
  text-align: center;
}

.catalogue-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(20,20,15,.4);
  border-radius: 3px 6px 6px 3px;
}

.cat-loading-ring {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid rgba(255,120,12,0.18);
  border-top-color: var(--orange);
  animation: catLoadingSpin 0.9s linear infinite;
}

@keyframes catLoadingSpin {
  to {
    transform: rotate(360deg);
  }
}

.catalogue-actions {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
  z-index: 5;
}

.cat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .3s ease;
  border: 1px solid rgba(255,255,255,.2);
  text-decoration: none;
}

.cat-action-btn svg {
  width: 16px;
  height: 16px;
}

.cat-action-btn.download {
  background: var(--orange);
  color: var(--white);
  border-color: var(--orange);
}

.cat-action-btn.download:hover {
  background: var(--orange-dark);
  transform: translateY(-2px);
}

.cat-action-btn.whatsapp {
  background: rgba(34,197,94,.14);
  color: #22c55e;
  border-color: rgba(34,197,94,.4);
}

.cat-action-btn.whatsapp:hover {
  background: #22c55e;
  color: var(--white);
  transform: translateY(-2px);
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 640px) {
  .catalogue-overlay {
    padding: 72px 14px 24px;
  }

  /* Single centered page on mobile */
  .book-viewport {
    top:20px;
    width: min(82vw, 340px);
    overflow: visible;
  }

  .book {
    --book-shift: 0% !important;
    transform: translateX(0) !important;
    border-radius: 6px;
  }

  .book.spread-centered {
    --book-shift: 0% !important;
  }

  /* Remove left side logo/reverse spread on mobile */
  .final-left-logo,
  .book-spine,
  .leaf-face.back {
    display: none !important;
  }

  /* Show only active page on mobile */
  .leaf {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: none !important;
    transition: opacity .25s ease;
  }

  .leaf.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none !important;
  }

  .leaf.hide-on-last {
    opacity: 0 !important;
    visibility: hidden !important;
  }

  .leaf-face {
    border-radius: 6px;
  }

  .leaf-face.front {
    transform: none !important;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
  }

  .catalogue-topbar {
    top: 16px;
    padding: 0 18px;
  }

  .catalogue-title {
    font-size: 11px;
    letter-spacing: .04em;
    max-width: calc(100% - 60px);
    line-height: 1.3;
  }

  .catalogue-close {
    width: 40px;
    height: 40px;
  }

  .catalogue-controls {
    gap: 14px;
    margin-top: 32px;
  }

  .cat-nav-btn {
    width: 34px;
    height: 34px;
  }

  .catalogue-actions {
    margin-top: 10px;
    gap: 10px;
  }

  .cat-action-btn {
    font-size: 12px;
    padding: 8px 12px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .book-viewport{
    top:60px;
    width: min(82vw,480px);
  }

  .catalogue-actions {
    position: absolute;
    top: 22px;
    right: 92px;
    z-index: 8;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .cat-action-btn {
    padding: 10px 16px;
    font-size: 12.5px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .cat-action-btn svg {
    width: 15px;
    height: 15px;
  }
}

/* Tablet fine adjustment */
@media (min-width: 641px) and (max-width: 768px) {
  .book-viewport{
    top:60px;
    width: min(72vw,320px);
  }
  .catalogue-actions {
    flex-direction: row;
    top: 25px;
    right: 100px;
  }

  .cat-action-btn {
    padding: 9px 14px;
    font-size: 12px;
  }
}

/* ===================== BIGGER CATALOGUE PAGE ON DESKTOP ONLY ===================== */

@media (min-width: 1025px) {
  .book-viewport {
    top: 50px;
    width: min(82vw, 400px);
  }

  .catalogue-actions {
    position: absolute;
    top: 22px;
    right: 92px;
    z-index: 8;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .cat-action-btn {
    padding: 10px 16px;
    font-size: 12.5px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .cat-action-btn svg {
    width: 15px;
    height: 15px;
  }
  
}