/* =========================================================
   Mobile / tablet enhancements (shared by index.php & index2.php)
   - hamburger drawer navigation
   - theme colours as a dropdown on one side
   - animated header (marquee strip, shrink on scroll)
   - animated cover showcase in the hero
   - tighter, more app-like content layout
   ========================================================= */

/* Controls injected by mobile.js are hidden on desktop */
.wm-actions, .wm-backdrop, .wm-drawer-head, .wm-totop { display: none; }

/* ---------- Header + navigation : <= 1024px ---------- */
@media (max-width: 1024px) {
  /* Theme bar no longer occupies the top row */
  html body header, html body.themebar-collapsed header { top: 0 !important; }
  html body .page, html body.themebar-collapsed .page { padding-top: var(--wm-hdr, 96px) !important; }
  .theme-toggle { display: none !important; }

  /* backdrop-filter would trap the fixed drawer inside the header */
  header { backdrop-filter: none; -webkit-backdrop-filter: none; background: #fff; }

  /* Animated top strip (marquee) that collapses once the page is scrolled */
  .header-top {
    white-space: nowrap;
    overflow: hidden;
    font-size: 12px;
    padding: 5px 0;
    max-height: 30px;
    transition: max-height .3s ease, padding .3s ease;
  }
  .header-top .wm-marquee {
    display: inline-block;
    padding-left: 100%;
    animation: wm-marquee 22s linear infinite;
  }
  @keyframes wm-marquee { to { transform: translateX(-100%); } }
  header.wm-scrolled .header-top { max-height: 0; padding: 0; }
  header.wm-scrolled { box-shadow: 0 6px 24px rgba(var(--primary-rgb), .22); }

  .nav-wrap { padding: 8px 14px; gap: 10px; }
  .logo-area { gap: 10px; min-width: 0; flex: 1; }
  .logo-area img { height: 44px; transition: height .3s ease; }
  header.wm-scrolled .logo-area img { height: 36px; }
  .logo-text { min-width: 0; }
  .logo-text h1 { font-size: 16px; line-height: 1.15; }
  .logo-text span { font-size: 9px; letter-spacing: .8px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Right-side action buttons */
  .wm-actions { display: flex; align-items: center; gap: 8px; flex: none; }
  .wm-icon-btn {
    width: 42px; height: 42px;
    border-radius: 12px;
    border: none;
    display: grid; place-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
  }
  .wm-icon-btn:active { transform: scale(.92); }
  .wm-theme-btn { background: rgba(var(--primary-rgb), .1); position: relative; }
  .wm-theme-btn .wm-dot {
    width: 22px; height: 22px; border-radius: 50%;
    background: conic-gradient(var(--primary), var(--primary-light), var(--gold), var(--primary));
    box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgba(var(--primary-rgb), .35);
    animation: wm-spin 6s linear infinite;
  }
  @keyframes wm-spin { to { transform: rotate(360deg); } }
  body.wm-theme-open .wm-theme-btn { background: rgba(var(--primary-rgb), .2); }

  .wm-burger { background: linear-gradient(135deg, var(--primary), var(--primary-light)); box-shadow: 0 4px 14px rgba(var(--primary-rgb), .35); }
  .wm-burger span { position: relative; width: 20px; height: 2px; border-radius: 2px; background: #fff; transition: background .2s; }
  .wm-burger span::before, .wm-burger span::after {
    content: ''; position: absolute; left: 0; width: 20px; height: 2px; border-radius: 2px; background: #fff;
    transition: transform .3s ease, top .3s ease;
  }
  .wm-burger span::before { top: -6px; }
  .wm-burger span::after { top: 6px; }
  body.wm-nav-open .wm-burger span { background: transparent; }
  body.wm-nav-open .wm-burger span::before { top: 0; transform: rotate(45deg); }
  body.wm-nav-open .wm-burger span::after { top: 0; transform: rotate(-45deg); }

  /* Drawer navigation */
  header nav {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(84vw, 340px);
    background: #fff;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 0 18px 24px;
    box-shadow: -12px 0 40px rgba(0,0,0,.18);
    transform: translateX(105%);
    transition: transform .35s cubic-bezier(.2,.8,.2,1);
    z-index: 2300;
    overflow-y: auto;
  }
  body.wm-nav-open header nav { transform: translateX(0); }

  html body header nav a:not(.nav-cta) { display: flex; }
  header nav a {
    align-items: center;
    gap: 14px;
    font-size: 16px;
    padding: 14px 14px;
    border-radius: 12px;
    opacity: 0;
    transform: translateX(24px);
    transition: opacity .3s ease, transform .3s ease, background .2s, color .2s;
  }
  header nav a::before {
    content: attr(data-icon);
    width: 36px; height: 36px; flex: none;
    display: grid; place-items: center;
    border-radius: 10px;
    background: rgba(var(--primary-rgb), .1);
    font-size: 18px;
  }
  header nav a.nav-cta::before { display: none; }
  body.wm-nav-open header nav a { opacity: 1; transform: none; }
  body.wm-nav-open header nav a:nth-of-type(1) { transition-delay: .08s; }
  body.wm-nav-open header nav a:nth-of-type(2) { transition-delay: .12s; }
  body.wm-nav-open header nav a:nth-of-type(3) { transition-delay: .16s; }
  body.wm-nav-open header nav a:nth-of-type(4) { transition-delay: .20s; }
  body.wm-nav-open header nav a:nth-of-type(5) { transition-delay: .24s; }
  body.wm-nav-open header nav a:nth-of-type(6) { transition-delay: .28s; }
  header nav a:hover { transform: none; }
  header nav a.wm-active { background: rgba(var(--primary-rgb), .12); color: var(--primary-dark); }
  header nav a.wm-active::before { background: var(--primary); }
  header nav .nav-cta { justify-content: center; margin-top: 14px; padding: 15px 20px !important; font-size: 16px; }

  .wm-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 -18px 12px;
    padding: 20px 18px 18px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
  }
  .wm-drawer-head strong { font-family: 'Playfair Display', serif; font-size: 18px; line-height: 1.2; }
  .wm-drawer-head small { display: block; font-size: 11px; opacity: .8; letter-spacing: 1px; text-transform: uppercase; margin-top: 4px; }
  .wm-drawer-close { width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; flex: none; }

  .wm-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(10, 20, 40, .45);
    opacity: 0; pointer-events: none;
    transition: opacity .3s ease;
    z-index: 2200;
  }
  body.wm-nav-open .wm-backdrop, body.wm-theme-open .wm-backdrop { opacity: 1; pointer-events: auto; }
  body.wm-theme-open .wm-backdrop { background: rgba(10, 20, 40, .15); }
  body.wm-nav-open { overflow: hidden; }
  /* the drawer lives inside header's stacking context, so lift the header above the backdrop */
  body.wm-nav-open header { z-index: 2250; }

  /* Theme colours: dropdown panel anchored to the right side */
  html body .theme-bar, html body .theme-bar.collapsed {
    position: fixed;
    top: calc(var(--wm-hdr-now, 96px) - 4px);
    left: auto; right: 12px;
    width: 236px; height: auto;
    padding: 14px;
    border-radius: 16px;
    background: #1a1a2e;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    justify-items: center;
    gap: 24px 8px;
    padding-bottom: 16px;
    box-shadow: 0 18px 48px rgba(0,0,0,.35);
    z-index: 2400;
    opacity: 0;
    transform: translateY(-10px) scale(.96);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity .2s ease, transform .25s ease;
  }
  html body.wm-theme-open .theme-bar { opacity: 1; transform: none; pointer-events: auto; }
  .theme-bar::before {
    content: ''; position: absolute; top: -6px; right: 66px;
    width: 12px; height: 12px; background: #1a1a2e; transform: rotate(45deg); border-radius: 2px;
  }
  .theme-bar-label { grid-column: 1 / -1; justify-self: start; margin: 0; }
  .theme-swatch { width: 34px; height: 34px; }
  .theme-swatch::after { opacity: 1; bottom: -16px; }
  .theme-swatch:hover, .theme-swatch.active { transform: scale(1.1); }
  .theme-divider { grid-column: 1 / -1; width: 100%; height: 1px; margin: 6px 0 0; }
  .theme-custom-wrap { grid-column: 1 / -1; justify-self: stretch; justify-content: space-between; }
  .theme-color-input { width: 34px; height: 34px; }

  /* Back-to-top button */
  .wm-totop {
    display: grid; place-items: center;
    position: fixed; right: 16px; bottom: 18px;
    width: 46px; height: 46px; border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; font-size: 20px; font-weight: 900;
    box-shadow: 0 8px 22px rgba(var(--primary-rgb), .45);
    opacity: 0; transform: translateY(20px) scale(.8);
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
    z-index: 1500;
    cursor: pointer;
  }
  body.wm-show-top .wm-totop { opacity: 1; transform: none; pointer-events: auto; }
}

/* ---------- Content : <= 768px ---------- */
@media (max-width: 768px) {
  /* Hero */
  .hero { padding: 34px 18px 28px; }
  .hero-inner { gap: 12px; text-align: center; }
  .hero-text h2 { font-size: 34px; margin-bottom: 12px; }
  .hero-text p { font-size: 15px; line-height: 1.65; margin-bottom: 22px; }
  .hero-btns { justify-content: center; gap: 10px; flex-wrap: nowrap; }
  .hero-btns .btn { flex: 1; justify-content: center; padding: 13px 10px; font-size: 14px; white-space: nowrap; }

  /* Rotating covers, fanned out under the hero text */
  html body .book-showcase { display: block; width: 300px; height: 210px; margin: 6px auto 0; }
  .book-showcase .book-card { width: 112px; height: 158px; border-radius: 10px; padding: 0;
    animation: wm-float 4s ease-in-out infinite; box-shadow: 0 14px 34px rgba(0,0,0,.35); }
  .book-showcase .book-card.b1 { left: 0;     top: 40px; --r: -12deg; z-index: 1; }
  .book-showcase .book-card.b2 { left: 60px;  top: 14px; --r: -4deg;  z-index: 3; animation-duration: 5s; }
  .book-showcase .book-card.b3 { left: 128px; top: 14px; --r: 4deg;   z-index: 2; animation-duration: 4.5s; }
  .book-showcase .book-card.b4 { left: 188px; top: 40px; --r: 12deg;  z-index: 1; animation-duration: 3.6s; }
  @keyframes wm-float {
    0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); }
    50%      { transform: translateY(-9px) rotate(var(--r, 0deg)); }
  }
  .hero::after { width: 200px; height: 200px; }

  /* Stats as a compact 2 x 2 grid */
  .stats-strip { padding: 30px 16px; }
  html body .stats-inner { grid-template-columns: 1fr 1fr; gap: 14px; }
  .stat-item { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 16px 8px; }
  .stat-num { font-size: 26px; white-space: nowrap; }
  .stat-label { font-size: 12.5px; }

  /* Section rhythm */
  .series-section { padding: 48px 16px; }
  .section-header { margin-bottom: 28px; }
  .section-header h2 { font-size: 27px; line-height: 1.2; }
  .section-header p { font-size: 15px; }
  .section-tag { font-size: 10.5px; letter-spacing: 1.5px; padding: 5px 12px; margin-bottom: 12px; }
  .page-banner { padding: 40px 18px !important; }
  .page-banner h2 { font-size: 30px !important; }
  .page-banner p { font-size: 15px !important; }

  /* Cards feel tappable */
  .series-card, .feature-card, .book-card-item, .category-card, .testimonial-card, .contact-card, .vmv-card {
    border-radius: 18px;
  }
  .btn { -webkit-tap-highlight-color: transparent; }
  .btn:active { transform: scale(.97); }

  /* Book filters: one swipeable row per group instead of a wall of chips */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 24px; }
  .filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-right: -24px;
    padding: 2px 24px 6px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .filter-group::-webkit-scrollbar { display: none; }
  .filter-btn { flex: none; scroll-snap-align: start; }

  /* Horizontal carousels snap nicely */
  .category-track, .testimonial-track { scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .category-card, .testimonial-card { scroll-snap-align: start; }
}

@media (max-width: 380px) {
  .logo-text h1 { font-size: 14px; }
  .logo-text span { display: none; }
  .hero-text h2 { font-size: 30px; }
  html body .book-showcase { transform: scale(.9); transform-origin: top center; margin-bottom: -20px; }
}

@media (prefers-reduced-motion: reduce) {
  .header-top .wm-marquee, .wm-theme-btn .wm-dot, .book-showcase .book-card { animation: none !important; }
}
