/*
 * RAYAN LOGISTICS — Desktop 2-Page Spread 3D Flipbook Styles
 * Activated on desktop and tablet landscape viewports
 */

@media (min-width: 900px) and (orientation: landscape), (min-width: 1025px) {
  .rayan-stage {
    perspective: 2600px;
  }

  /* Ambient wood/desk shadow underneath book */
  .rayan-stage::after {
    content: "";
    position: absolute;
    bottom: calc(50% - (var(--page-height) / 2) - 24px);
    width: calc(var(--page-width) * 2 + 60px);
    height: 40px;
    background: radial-gradient(ellipse at 50% 50%, rgba(24, 44, 62, 0.24) 0%, rgba(24, 44, 62, 0.05) 50%, transparent 75%);
    filter: blur(12px);
    z-index: 1;
    pointer-events: none;
    transition: transform 0.65s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .rayan-stage:has(.rayan-book.is-cover-view)::after {
    transform: translateX(-25%);
    width: calc(var(--page-width) + 60px);
  }

  .rayan-stage:has(.rayan-book.is-back-cover-view)::after {
    transform: translateX(25%);
    width: calc(var(--page-width) + 60px);
  }

  /* Main 3D Book Container */
  .rayan-book {
    position: relative;
    width: calc(var(--page-width) * 2);
    height: var(--page-height);
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 10;
  }

  .rayan-book.is-cover-view {
    transform: translateX(-25%);
  }

  .rayan-book.is-back-cover-view {
    transform: translateX(25%);
  }

  .rayan-book.is-spread-view {
    transform: translateX(0);
  }

  /* Central Spine Structure */
  .rayan-spine {
    position: absolute;
    left: calc(50% - 4px);
    top: -2px;
    width: 8px;
    height: calc(100% + 4px);
    background: linear-gradient(
      to right,
      rgba(24, 44, 62, 0.25) 0%,
      rgba(255, 255, 255, 0.4) 45%,
      rgba(24, 44, 62, 0.3) 55%,
      rgba(24, 44, 62, 0.15) 100%
    );
    box-shadow: 
      0 0 10px rgba(24, 44, 62, 0.35),
      inset 0 0 2px rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    z-index: 50;
    pointer-events: none;
  }

  .spine-crease {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(24, 44, 62, 0.4);
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.7);
  }

  /* Green Silk Bookmark Ribbon */
  .spine-ribbon {
    position: absolute;
    top: -12px;
    left: calc(50% - 7px);
    width: 14px;
    height: calc(100% + 45px);
    background: linear-gradient(
      to right,
      #4B6E6A 0%,
      #648C87 40%,
      #7FA39E 60%,
      #4B6E6A 100%
    );
    box-shadow: 
      2px 4px 10px rgba(24, 44, 62, 0.28),
      inset 0 1px 2px rgba(255, 255, 255, 0.35);
    z-index: 55;
    pointer-events: none;
    border-radius: 1px 1px 0 0;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), 50% 100%, 0 calc(100% - 12px));
    transform-origin: top center;
    transition: transform 0.5s ease;
  }

  /* Outer Paper Stack Depth Indicators */
  .book-stack {
    position: absolute;
    top: 2px;
    height: calc(100% - 4px);
    background: repeating-linear-gradient(
      to bottom,
      #FFFFFF 0px,
      #FFFFFF 2px,
      #DADDD8 2px,
      #DADDD8 3px
    );
    box-shadow: inset 0 0 4px rgba(24, 44, 62, 0.2);
    z-index: 2;
    pointer-events: none;
    transition: width 0.3s ease, opacity 0.3s ease;
  }

  .stack-left {
    left: 0;
    border-radius: 3px 0 0 3px;
    transform: translateX(-100%);
  }

  .stack-right {
    right: 0;
    border-radius: 0 3px 3px 0;
    transform: translateX(100%);
  }

  /* 3D Leaves Container */
  .rayan-leaves-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
  }

  /* 3D Turning Leaf */
  .rayan-leaf {
    position: absolute;
    top: 0;
    left: 50%;
    width: var(--page-width);
    height: var(--page-height);
    transform-origin: left center;
    transform-style: preserve-3d;
    will-change: transform;
    cursor: pointer;
  }

  [dir="rtl"] .rayan-leaf {
    left: auto;
    right: 50%;
    transform-origin: right center;
  }

  .rayan-leaf-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: var(--color-paper-white);
    border-radius: 0 var(--edge-radius) var(--edge-radius) 0;
    overflow: hidden;
    box-shadow: 
      inset 0 0 14px rgba(24, 44, 62, 0.04),
      0 4px 18px rgba(24, 44, 62, 0.08);
  }

  .rayan-leaf-back {
    transform: rotateY(180deg);
    border-radius: var(--edge-radius) 0 0 var(--edge-radius);
  }

  [dir="rtl"] .rayan-leaf-face {
    border-radius: var(--edge-radius) 0 0 var(--edge-radius);
  }

  [dir="rtl"] .rayan-leaf-back {
    border-radius: 0 var(--edge-radius) var(--edge-radius) 0;
  }

  .desktop-page-wrapper {
    width: 100%;
    height: 100%;
    padding: 30px 28px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
  }

  /* Specular lighting gradient on flipping sheet */
  .rayan-leaf-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 40;
    transition: background 0.1s linear;
  }
}
