/*
 * RAYAN LOGISTICS — Mobile & Tablet Portrait Single-Page Engine Styles
 * Completely separates 2D reading/scrolling from 3D turn animations.
 * Eliminates WebKit 3D compositor culling and white-screen bugs forever.
 */

@media (max-width: 899px), (orientation: portrait) and (max-width: 1024px) {
  .rayan-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding-top: max(44px, calc(env(safe-area-inset-top) + 38px));
    padding-bottom: max(48px, calc(env(safe-area-inset-bottom) + 42px));
    overflow: hidden;
  }

  /* Ambient ground shadow beneath mobile card */
  .rayan-stage::after {
    content: "";
    position: absolute;
    bottom: calc(50% - min(calc(100dvh - 100px), 660px) / 2 - 14px);
    width: min(calc(100vw - 30px), 400px);
    height: 22px;
    background: radial-gradient(ellipse at 50% 50%, rgba(24, 44, 62, 0.22) 0%, rgba(24, 44, 62, 0.05) 50%, transparent 75%);
    filter: blur(8px);
    z-index: 1;
    pointer-events: none;
  }

  /* Main Mobile Card Host */
  .rayan-mobile-card {
    position: relative;
    width: min(calc(100vw - 20px), 440px);
    height: min(calc(100dvh - 100px), 660px);
    background: var(--color-paper-white, #FFFFFF);
    border-radius: 6px;
    box-shadow: 
      0 16px 36px -8px rgba(24, 44, 62, 0.26),
      0 4px 14px rgba(24, 44, 62, 0.1),
      0 0 0 1px rgba(24, 44, 62, 0.06);
    overflow: hidden;
    z-index: 10;
    touch-action: pan-y;
  }

  /* Visual binding spine */
  .mobile-spine-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    z-index: 25;
    pointer-events: none;
  }

  .spine-indicator-ltr {
    left: 0;
    background: linear-gradient(to right, rgba(24, 44, 62, 0.3) 0%, rgba(24, 44, 62, 0.06) 80%, transparent 100%);
    box-shadow: inset 1px 0 2px rgba(255, 255, 255, 0.35);
  }

  .spine-indicator-rtl {
    right: 0;
    background: linear-gradient(to left, rgba(24, 44, 62, 0.3) 0%, rgba(24, 44, 62, 0.06) 80%, transparent 100%);
    box-shadow: inset -1px 0 2px rgba(255, 255, 255, 0.35);
  }

  /*
   * PURE 2D READING CONTAINER
   * ZERO 3D transforms, ZERO perspective, ZERO preserve-3d!
   * Guarantees 100% native smooth momentum scrolling in WebKit & Blink!
   */
  .mobile-reading-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 16px 14px 28px 14px;
    background: var(--color-paper-white, #FFFFFF);
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    display: flex;
    flex-direction: column;
    z-index: 10;
  }

  /* Elegant thin scrollbar */
  .mobile-reading-container::-webkit-scrollbar {
    width: 3px;
  }

  .mobile-reading-container::-webkit-scrollbar-track {
    background: transparent;
  }

  .mobile-reading-container::-webkit-scrollbar-thumb {
    background: rgba(24, 44, 62, 0.22);
    border-radius: 3px;
  }

  /* Sticky Page Header: stays fixed at top of card while reading */
  .rayan-mobile-card .page-header {
    position: sticky;
    top: -16px;
    background: var(--color-paper-white, #FFFFFF);
    z-index: 15;
    padding-top: 10px;
    padding-bottom: 8px;
    margin-top: -10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--color-divider-grey);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Page Footer: sits at bottom of content */
  .rayan-mobile-card .page-footer {
    margin-top: 24px;
    padding-top: 10px;
    border-top: 1px solid var(--color-divider-grey);
    font-size: 0.72rem;
    color: var(--color-slate-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
  }

  /* Body expands naturally inside scroll container */
  .rayan-mobile-card .page-content-body {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
  }

  /* Mobile Cover & Back Cover */
  .rayan-mobile-card .page-cover,
  .rayan-mobile-card .page-backcover {
    min-height: 100%;
    padding: 16px 12px !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* Responsive layout adjustments for mobile editorial */
  .rayan-mobile-card .about-grid,
  .rayan-mobile-card .purpose-pillars,
  .rayan-mobile-card .modalities-container,
  .rayan-mobile-card .customs-intro-split,
  .rayan-mobile-card .industries-editorial-split,
  .rayan-mobile-card .services-editorial-grid,
  .rayan-mobile-card .values-editorial-grid,
  .rayan-mobile-card .warehouse-pillars-grid,
  .rayan-mobile-card .process-pipeline,
  .rayan-mobile-card .principles-editorial-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .rayan-mobile-card .editorial-title {
    font-size: 1.25rem;
    line-height: 1.26;
    margin: 0 0 10px 0;
  }

  .rayan-mobile-card .editorial-lead {
    font-size: 0.88rem;
    line-height: 1.55;
    margin-bottom: 12px;
  }

  .rayan-mobile-card .editorial-p {
    font-size: 0.82rem;
    line-height: 1.58;
    margin: 0 0 10px 0;
  }

  .rayan-mobile-card .cover-hero-visual {
    height: 180px;
    margin: 12px 0;
  }

  .rayan-mobile-card .about-photo-wrapper,
  .rayan-mobile-card .freight-hero-photo,
  .rayan-mobile-card .warehouse-visual-photo,
  .rayan-mobile-card .industries-showcase-photo {
    height: 150px;
  }

  .rayan-mobile-card .customs-photo-preview {
    height: 130px;
  }

  /*
   * DEDICATED 3D TRANSITION FLIPPER
   * Mounted ONLY during the 500ms page-turn animation!
   * Unmounted immediately when the flip completes.
   */
  .mobile-flip-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    perspective: 1600px;
    -webkit-perspective: 1600px;
    z-index: 30;
    pointer-events: none;
  }

  .mobile-flip-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-paper-white, #FFFFFF);
    padding: 16px 14px 28px 14px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
  }

  .mobile-flip-leaf {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transform-origin: left center;
    z-index: 5;
    will-change: transform;
  }

  [dir="rtl"] .mobile-flip-leaf {
    transform-origin: right center;
  }

  .mobile-flip-front,
  .mobile-flip-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: var(--color-paper-white, #FFFFFF);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
  }

  .mobile-flip-front {
    padding: 16px 14px 28px 14px;
    display: flex;
    flex-direction: column;
    z-index: 2;
  }

  .mobile-flip-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #F7F6F1 0%, #FFFFFF 50%, #ECEDE9 100%);
    box-shadow: inset 0 0 30px rgba(24, 44, 62, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
  }

  .mobile-flip-back-watermark {
    opacity: 0.15;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  .mobile-flip-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
  }
}
