/* ==========================================================================
   ConsultDevin 2026 Holiday Wish Book — Native <dialog> Spread Viewer
   - Desktop (>= 900px): Crisp 2-page book spreads (Cover, 2-3, 4-5, 6-7, Back)
   - Mobile  (<  900px): 1-page swipeable reader with unobstructed bottom controls
   - True CSS 3D double-sided page-turn leaf animation (default ON, toggleable)
   ========================================================================== */

dialog.cd-catalog-dialog {
  width: min(96vw, 1380px);
  max-width: 1380px;
  height: min(94vh, 920px);
  max-height: 94vh;
  margin: auto;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 20px;
  background: linear-gradient(165deg, #0b192c 0%, #070f1a 100%);
  color: #f8fafc;
  box-shadow: 0 32px 90px -12px rgba(0, 0, 0, 0.78), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  overflow: hidden;
  font-family: 'Inter', 'Open Sans', system-ui, 'Segoe UI', Roboto, sans-serif;
}

dialog.cd-catalog-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: cd-dialog-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

dialog.cd-catalog-dialog::backdrop {
  background: rgba(5, 10, 18, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@keyframes cd-dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header bar */
.cd-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(12, 35, 64, 0.78);
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  flex-shrink: 0;
}

.cd-cat-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cd-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cd-cat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.cd-cat-title-short {
  display: none;
}

.cd-cat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cd-cat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 120ms ease;
  white-space: nowrap;
}

.cd-cat-btn:hover:not(:disabled) {
  background: rgba(30, 58, 138, 0.55);
  border-color: rgba(125, 211, 252, 0.45);
  color: #ffffff;
}

.cd-cat-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.cd-cat-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cd-cat-btn[aria-pressed="true"] {
  background: rgba(14, 165, 233, 0.24);
  border-color: rgba(56, 189, 248, 0.65);
  color: #bae6fd;
}

.cd-cat-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
}

/* Section Jump Bar */
.cd-cat-sections {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: rgba(7, 15, 26, 0.72);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.cd-cat-sections::-webkit-scrollbar {
  display: none;
}

.cd-cat-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 140ms ease;
}

.cd-cat-chip:hover {
  border-color: rgba(251, 191, 36, 0.5);
  color: #fef3c7;
}

.cd-cat-chip.is-active {
  background: #f59e0b;
  border-color: #fbbf24;
  color: #0c192c;
  font-weight: 700;
}

/* Main Stage */
.cd-cat-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 64px;
  overflow: hidden;
  perspective: 2200px;
  touch-action: pan-y;
  user-select: none;
}

.cd-cat-stage.is-zoomed {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 20px;
  cursor: zoom-out;
}

/* Book Spread Container */
.cd-cat-book {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  perspective: 2200px;
  transform-style: preserve-3d;
}

.cd-cat-stage.is-zoomed .cd-cat-book {
  max-width: none;
  max-height: none;
  margin: auto;
}

.cd-cat-spread {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 4px 14px rgba(0, 0, 0, 0.4);
  background: #0b192c;
  transform-style: preserve-3d;
  position: relative;
}

.cd-cat-page {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b192c;
  overflow: hidden;
  cursor: zoom-in;
}

.cd-cat-stage.is-zoomed .cd-cat-page {
  cursor: zoom-out;
}

.cd-cat-page img {
  display: block;
  width: auto;
  height: auto;
  max-height: calc(94vh - 190px);
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* 2-page desktop spread sizing */
.cd-cat-spread.is-double .cd-cat-page {
  flex: 0 1 50%;
}

.cd-cat-spread.is-double .cd-cat-page img {
  max-width: min(44vw, 610px);
}

.cd-cat-stage.is-zoomed .cd-cat-page img {
  max-height: none;
  max-width: none;
  width: min(1100px, 145vw);
}

.cd-cat-stage.is-zoomed .cd-cat-spread.is-double .cd-cat-page img {
  width: 860px;
}

/* Realistic book spine gutter shadows on 2-page spreads */
.cd-cat-spread.is-double .cd-cat-page-left {
  border-radius: 6px 0 0 6px;
}

.cd-cat-spread.is-double .cd-cat-page-right {
  border-radius: 0 6px 6px 0;
}

.cd-cat-spread.is-double .cd-cat-page-left::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 34px;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.36) 0%, rgba(0, 0, 0, 0.12) 38%, transparent 100%);
  pointer-events: none;
}

.cd-cat-spread.is-double .cd-cat-page-right::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 34px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.08) 38%, transparent 100%);
  pointer-events: none;
}

.cd-cat-spread.is-single .cd-cat-page {
  border-radius: 8px;
}

/* ==========================================================================
   TRUE CSS 3D BOOK PAGE-TURN ANIMATIONS (Default ON, user-toggleable)
   ========================================================================== */

/* Double-sided 3D turning leaf overlaid on 2-page desktop spreads */
.cd-cat-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 8;
  transform-style: preserve-3d;
  pointer-events: none;
  will-change: transform;
}

.cd-cat-leaf.is-next {
  left: 50%;
  transform-origin: left center;
  animation: cd-leaf-turn-next 540ms cubic-bezier(0.42, 0, 0.22, 1) forwards;
}

.cd-cat-leaf.is-prev {
  left: 0;
  transform-origin: right center;
  animation: cd-leaf-turn-prev 540ms cubic-bezier(0.42, 0, 0.22, 1) forwards;
}

.cd-cat-leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: #0b192c;
}

.cd-cat-leaf-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cd-cat-leaf.is-next .cd-cat-leaf-front {
  border-radius: 0 6px 6px 0;
  box-shadow: -8px 0 26px rgba(0, 0, 0, 0.45);
}

.cd-cat-leaf.is-next .cd-cat-leaf-back {
  transform: rotateY(180deg);
  border-radius: 6px 0 0 6px;
  box-shadow: 8px 0 26px rgba(0, 0, 0, 0.45);
}

.cd-cat-leaf.is-prev .cd-cat-leaf-front {
  border-radius: 6px 0 0 6px;
  box-shadow: 8px 0 26px rgba(0, 0, 0, 0.45);
}

.cd-cat-leaf.is-prev .cd-cat-leaf-back {
  transform: rotateY(180deg);
  border-radius: 0 6px 6px 0;
  box-shadow: -8px 0 26px rgba(0, 0, 0, 0.45);
}

@keyframes cd-leaf-turn-next {
  0% {
    transform: rotateY(0deg);
    filter: brightness(1);
  }
  48% {
    filter: brightness(0.86);
  }
  100% {
    transform: rotateY(-180deg);
    filter: brightness(1);
  }
}

@keyframes cd-leaf-turn-prev {
  0% {
    transform: rotateY(0deg);
    filter: brightness(1);
  }
  48% {
    filter: brightness(0.86);
  }
  100% {
    transform: rotateY(180deg);
    filter: brightness(1);
  }
}

/* Hinged 3D spine flip for Cover / Back Cover / Mobile 1-page turns */
.cd-cat-spread.cd-hinge-next {
  transform-origin: left center;
  animation: cd-hinge-turn-next 460ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cd-cat-spread.cd-hinge-prev {
  transform-origin: right center;
  animation: cd-hinge-turn-prev 460ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cd-hinge-turn-next {
  0% {
    opacity: 0.35;
    transform: rotateY(-76deg) scale(0.96);
    filter: brightness(0.8);
  }
  100% {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
    filter: brightness(1);
  }
}

@keyframes cd-hinge-turn-prev {
  0% {
    opacity: 0.35;
    transform: rotateY(76deg) scale(0.96);
    filter: brightness(0.8);
  }
  100% {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
    filter: brightness(1);
  }
}

/* Clean fade when 3D Flip is toggled OFF */
.cd-cat-spread.cd-fade-turn {
  animation: cd-page-fade 180ms ease-out;
}

@keyframes cd-page-fade {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

/* Side Navigation Arrows (Desktop) */
.cd-cat-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(12, 35, 64, 0.88);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: background 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.cd-cat-arrow:hover:not(:disabled) {
  background: #0284c7;
  border-color: #7dd3fc;
  transform: translateY(-50%) scale(1.06);
}

.cd-cat-arrow:disabled {
  opacity: 0.22;
  cursor: not-allowed;
}

.cd-cat-arrow-prev { left: 12px; }
.cd-cat-arrow-next { right: 12px; }

/* Mobile-only unobstructed nav row below the page card */
.cd-cat-mobile-nav {
  display: none;
}

/* Footer Bar */
.cd-cat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(12, 35, 64, 0.82);
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cd-cat-status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: #cbd5e1;
}

.cd-cat-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cd-cat-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.38);
  cursor: pointer;
  transition: width 160ms ease, background 160ms ease;
}

.cd-cat-dot.is-active {
  width: 22px;
  background: #fbbf24;
}

.cd-cat-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  background: #f59e0b;
  color: #0c192c;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: background 150ms ease, transform 120ms ease;
  white-space: nowrap;
}

.cd-cat-cta:hover {
  background: #fbbf24;
  transform: translateY(-1px);
}

/* Mobile Layout (< 900px) — Unobstructed Page + Dedicated Nav Row */
@media (max-width: 899px) {
  dialog.cd-catalog-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .cd-cat-header {
    padding: 10px 12px;
  }

  .cd-cat-badge {
    display: none;
  }

  .cd-cat-stage {
    padding: 12px 12px 8px;
    gap: 14px;
  }

  .cd-cat-page img {
    max-height: calc(100dvh - 255px);
    max-width: calc(100vw - 24px);
  }

  /* Hide floating side arrows so they NEVER overlap page artwork on mobile */
  .cd-cat-arrow {
    display: none;
  }

  /* Show clean dedicated Prev / Hint / Next bar below the page card */
  .cd-cat-mobile-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    max-width: 420px;
  }

  .cd-cat-mobile-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(12, 35, 64, 0.9);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 150ms ease, opacity 150ms ease;
  }

  .cd-cat-mobile-nav-btn:hover:not(:disabled) {
    background: #0284c7;
    border-color: #7dd3fc;
  }

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

  .cd-cat-mobile-hint {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    line-height: 1.3;
  }

  .cd-cat-stage.is-zoomed .cd-cat-mobile-nav {
    display: none;
  }

  .cd-cat-footer {
    padding: 10px 12px;
  }
}

@media (max-width: 639px) {
  .cd-cat-title-full {
    display: none;
  }

  .cd-cat-title-short {
    display: inline;
  }
}
