/* ═══════════════════════════════════════════════════════════════════════════
   Auto & Style Magazine Viewer  —  magazine.css
   Tech-dark aesthetic · Red & Black palette
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --asm-red:       #e81c1c;
  --asm-red-dim:   #9b1212;
  --asm-red-glow:  rgba(232, 28, 28, 0.55);
  --asm-red-faint: rgba(232, 28, 28, 0.12);
  --asm-black:     #0a0a0a;
  --asm-dark:      #111111;
  --asm-dark2:     #1a1a1a;
  --asm-dark3:     #242424;
  --asm-text:      #f0f0f0;
  --asm-muted:     #888888;
  --asm-border:    rgba(232, 28, 28, 0.3);
  --asm-font-head: 'Rajdhani', 'Bebas Neue', 'Impact', sans-serif;
  --asm-font-body: 'Exo 2', 'Segoe UI', sans-serif;
  --asm-radius:    4px;
  --asm-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;700&family=Exo+2:wght@300;400;600&display=swap');

/* ── Reset wrapper ──────────────────────────────────────────────────────────── */
#asm-wrapper * { box-sizing: border-box; }
#asm-wrapper { font-family: var(--asm-font-body); }

/* ══════════════════════════════════════════════════════════════════════════════
   COVER
══════════════════════════════════════════════════════════════════════════════ */
.asm-cover-container {
  position: relative;
  display: inline-block;
  max-width: 420px;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--asm-border), 0 8px 40px rgba(0,0,0,0.8);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}
.asm-cover-container:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 0 0 1px var(--asm-red), 0 20px 60px rgba(232, 28, 28, 0.4);
}

/* Animated red glow pulse */
.asm-cover-glow {
  position: absolute; inset: -20px;
  background: radial-gradient(ellipse at 50% 50%, var(--asm-red-glow) 0%, transparent 70%);
  animation: asm-glow-pulse 3s ease-in-out infinite;
  pointer-events: none; z-index: 1;
}
@keyframes asm-glow-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50%       { opacity: 1;   transform: scale(1.05); }
}

/* CRT scanlines effect */
.asm-scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.07) 3px,
    rgba(0,0,0,0.07) 4px
  );
  pointer-events: none; z-index: 3;
}

.asm-cover-container img {
  display: block; width: 100%; height: auto;
  transition: filter 0.4s ease;
}
.asm-cover-container:hover img {
  filter: brightness(0.55);
}

/* Overlay shown on hover */
.asm-cover-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 5;
}
.asm-cover-container:hover .asm-cover-overlay { opacity: 1; }

.asm-cover-brand {
  display: flex; flex-direction: column; align-items: center;
}
.asm-cover-label {
  font-family: var(--asm-font-body);
  font-size: 11px; letter-spacing: 4px;
  color: var(--asm-red); font-weight: 600;
  text-transform: uppercase;
}
.asm-cover-title {
  font-family: var(--asm-font-head);
  font-size: 38px; font-weight: 700; letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 20px var(--asm-red-glow), 0 0 60px rgba(232,28,28,0.3);
  line-height: 1;
}

/* Open button */
.asm-open-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 28px;
  background: var(--asm-red);
  border: none; border-radius: var(--asm-radius);
  color: #fff;
  font-family: var(--asm-font-head);
  font-size: 16px; font-weight: 700; letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 20px var(--asm-red-glow), 0 4px 16px rgba(0,0,0,0.6);
  transition: all 0.2s ease;
  text-transform: uppercase;
}
.asm-open-btn:hover {
  background: #ff2a2a;
  box-shadow: 0 0 35px var(--asm-red-glow), 0 6px 20px rgba(0,0,0,0.7);
  transform: scale(1.05);
}
.asm-btn-icon { font-size: 13px; }

.asm-cover-pages {
  font-size: 11px; letter-spacing: 4px;
  color: var(--asm-muted);
  font-family: var(--asm-font-body);
}

/* Tech corners decoration */
.asm-corner {
  position: absolute; width: 22px; height: 22px;
  border-color: var(--asm-red);
  border-style: solid;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 6;
}
.asm-cover-container:hover .asm-corner { opacity: 1; }
.asm-corner-tl { top: 10px; left: 10px;  border-width: 2px 0 0 2px; }
.asm-corner-tr { top: 10px; right: 10px; border-width: 2px 2px 0 0; }
.asm-corner-bl { bottom: 10px; left: 10px;  border-width: 0 0 2px 2px; }
.asm-corner-br { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }


/* ══════════════════════════════════════════════════════════════════════════════
   FULL-SCREEN READER
══════════════════════════════════════════════════════════════════════════════ */
.asm-reader {
  position: fixed; inset: 0; z-index: 999999;
  background: var(--asm-black);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transform: scale(0.96);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.asm-reader.asm-reader--open {
  opacity: 1; pointer-events: all; transform: scale(1);
}

/* Particle canvas – behind everything */
.asm-particles {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: 0.35;
}

/* ── HUD top bar ─────────────────────────────────────────────────────────── */
.asm-hud-bar {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: linear-gradient(180deg, rgba(10,10,10,0.98) 0%, rgba(10,10,10,0.85) 100%);
  border-bottom: 1px solid var(--asm-border);
  flex-shrink: 0;
}
.asm-hud-logo {
  font-family: var(--asm-font-head);
  font-size: 20px; font-weight: 700; letter-spacing: 5px;
  color: var(--asm-red);
  text-shadow: 0 0 12px var(--asm-red-glow);
}
.asm-page-indicator {
  font-family: var(--asm-font-body);
  font-size: 13px; letter-spacing: 3px;
  color: var(--asm-muted);
  transition: color 0.3s;
}
.asm-hud-right { display: flex; gap: 8px; }
.asm-hud-btn {
  width: 36px; height: 36px;
  background: var(--asm-dark2);
  border: 1px solid var(--asm-border);
  border-radius: var(--asm-radius);
  color: var(--asm-muted);
  font-size: 16px; cursor: pointer;
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
}
.asm-hud-btn:hover {
  background: var(--asm-red); color: #fff;
  border-color: var(--asm-red);
  box-shadow: 0 0 12px var(--asm-red-glow);
}
.asm-close-btn { font-size: 18px; font-weight: 700; }

/* ── Stage (the book area) ───────────────────────────────────────────────── */
.asm-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative; z-index: 2;
  overflow: hidden;
  padding: 16px 80px;
  /* stage fills remaining space between HUD and thumbs */
  min-height: 0;
}

/* ── Book ───────────────────────────────────────────────────────────────── */
/*
  KEY PRINCIPLE: we let the IMAGE define the height.
  The book has no fixed height – images use height:auto so they
  never get cropped. max-height on the book prevents overflow.
*/
.asm-book {
  position: relative;
  display: flex;
  align-items: stretch;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 30px 80px rgba(0,0,0,0.9),
    0 0 60px rgba(232,28,28,0.1);
  border-radius: 2px;
  /* max height = viewport minus HUD (52px) + thumbs (58px) + padding (40px) */
  max-height: calc(100vh - 150px);
  transition: box-shadow 0.5s ease;
}

/* Spine glow line */
.asm-book::after {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 3px; transform: translateX(-50%);
  background: linear-gradient(180deg, transparent 0%, var(--asm-red) 20%, var(--asm-red) 80%, transparent 100%);
  box-shadow: 0 0 12px var(--asm-red-glow);
  z-index: 10;
  transition: opacity 0.3s;
}
.asm-book.asm-single::after { opacity: 0; }

/* ── Pages ── */
.asm-page {
  position: relative;
  flex: 1;                /* each page takes equal width in spread */
  overflow: hidden;
  background: #111;
  display: flex;
}
.asm-page img {
  display: block;
  width: 100%;
  height: auto;           /* CRITICAL: never crop vertically */
  max-height: calc(100vh - 150px);
  object-fit: contain;    /* show full image, no crop */
  user-select: none;
  -webkit-user-drag: none;
}

.asm-page-left  { border-radius: 2px 0 0 2px; }
.asm-page-right { border-radius: 0 2px 2px 0; }

/* ── Single page mode (cover, mobile, last odd page) ── */
.asm-book.asm-single .asm-page-left  { display: none !important; }
.asm-book.asm-single .asm-page-right {
  border-radius: 2px;
}
.asm-book.asm-single .asm-page-right img {
  /* center horizontally when single */
  margin: 0 auto;
}

/* Inner page shadows */
.asm-page-shadow {
  position: absolute; top: 0; bottom: 0;
  width: 40px; pointer-events: none;
}
.asm-page-shadow-left {
  right: 0;
  background: linear-gradient(270deg, rgba(0,0,0,0.4) 0%, transparent 100%);
}
.asm-page-shadow-right {
  left: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.4) 0%, transparent 100%);
}

/* ── Flip panel (3D CSS flip) ───────────────────────────────────────────── */
.asm-flip-panel {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  perspective: 2000px;
  z-index: 20;
  pointer-events: none;
  display: none;
}
.asm-flip-panel.asm-flipping-forward {
  display: block;
  animation: asm-flip-forward 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.asm-flip-panel.asm-flipping-back {
  display: block;
  width: 50%;
  right: unset; left: 0;
  transform-origin: right center;
  animation: asm-flip-backward 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes asm-flip-forward {
  0%   { transform: rotateY(0deg);    }
  100% { transform: rotateY(-180deg); }
}
@keyframes asm-flip-backward {
  0%   { transform: rotateY(0deg);    }
  100% { transform: rotateY(180deg);  }
}

.asm-flip-front,
.asm-flip-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: #111;
}
.asm-flip-front img,
.asm-flip-back  img {
  display: block; width: 100%;
  height: auto;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  user-select: none; -webkit-user-drag: none;
}
.asm-flip-back {
  transform: rotateY(180deg);
}

/* ── Navigation arrows ───────────────────────────────────────────────────── */
.asm-nav-btn {
  position: absolute; top: 50%; z-index: 10;
  width: 50px; height: 70px;
  transform: translateY(-50%);
  background: linear-gradient(180deg, rgba(20,20,20,0.9) 0%, rgba(10,10,10,0.95) 100%);
  border: 1px solid var(--asm-border);
  color: var(--asm-muted);
  font-size: 22px; cursor: pointer;
  transition: all 0.25s ease;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--asm-radius);
}
.asm-nav-prev { left: 12px; }
.asm-nav-next { right: 12px; }
.asm-nav-btn:hover {
  background: var(--asm-red);
  color: #fff; border-color: var(--asm-red);
  box-shadow: 0 0 20px var(--asm-red-glow);
  transform: translateY(-50%) scale(1.07);
}
.asm-nav-btn:disabled {
  opacity: 0.2; cursor: not-allowed;
  pointer-events: none;
}

/* ── Progress bar ───────────────────────────────────────────────────────── */
.asm-progress-track {
  position: absolute; bottom: 56px; left: 80px; right: 80px;
  height: 2px; background: var(--asm-dark3); z-index: 10;
  border-radius: 2px; overflow: hidden;
}
.asm-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--asm-red-dim), var(--asm-red));
  box-shadow: 0 0 8px var(--asm-red-glow);
  transition: width 0.4s ease;
}

/* ── Thumbnails strip ───────────────────────────────────────────────────── */
.asm-thumbs-bar {
  position: relative; z-index: 10;
  height: 58px;
  background: rgba(10,10,10,0.95);
  border-top: 1px solid var(--asm-border);
  overflow: hidden;
  flex-shrink: 0;
}
.asm-thumbs-inner {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  height: 100%;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--asm-red-dim) transparent;
}
.asm-thumbs-inner::-webkit-scrollbar { height: 3px; }
.asm-thumbs-inner::-webkit-scrollbar-track { background: transparent; }
.asm-thumbs-inner::-webkit-scrollbar-thumb { background: var(--asm-red-dim); border-radius: 2px; }

.asm-thumb {
  flex-shrink: 0;
  width: 33px; height: 44px;
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  opacity: 0.5;
}
.asm-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.asm-thumb:hover { opacity: 0.85; border-color: var(--asm-red-dim); }
.asm-thumb.asm-thumb--active {
  opacity: 1;
  border-color: var(--asm-red);
  box-shadow: 0 0 8px var(--asm-red-glow);
  transform: scaleY(1.08);
}

/* ══════════════════════════════════════════════════════════════════════════════
   SINGLE-PAGE MODE (mobile / narrow) – show 1 page at a time
══════════════════════════════════════════════════════════════════════════════ */
/* single mode handled by .asm-single class above */

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .asm-stage { padding: 12px 52px; }
  .asm-nav-btn { width: 36px; height: 52px; font-size: 16px; }
  .asm-nav-prev { left: 4px; }
  .asm-nav-next { right: 4px; }
  .asm-hud-logo { font-size: 15px; letter-spacing: 3px; }
  .asm-progress-track { left: 52px; right: 52px; }
}

@media (max-width: 480px) {
  .asm-cover-container { max-width: 100%; }
  .asm-cover-title { font-size: 26px; }
  .asm-thumbs-bar { height: 50px; }
  .asm-thumb { width: 26px; height: 36px; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   BODY LOCK when reader is open
══════════════════════════════════════════════════════════════════════════════ */
body.asm-locked { overflow: hidden; }

/* ══════════════════════════════════════════════════════════════════════════════
   LOADING SPINNER (while images preload)
══════════════════════════════════════════════════════════════════════════════ */
.asm-loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--asm-black);
  z-index: 30;
  opacity: 1; transition: opacity 0.4s ease;
}
.asm-loader.asm-loader--hidden { opacity: 0; pointer-events: none; }
.asm-loader-ring {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid var(--asm-dark3);
  border-top-color: var(--asm-red);
  animation: asm-spin 0.8s linear infinite;
  box-shadow: 0 0 16px var(--asm-red-glow);
}
@keyframes asm-spin { to { transform: rotate(360deg); } }
.asm-loader-text {
  margin-top: 16px;
  font-family: var(--asm-font-body);
  font-size: 11px; letter-spacing: 4px;
  color: var(--asm-muted);
  text-transform: uppercase;
}


.asm-page,
.asm-flip-panel,
.asm-book,
.asm-page img{
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

@media (max-width: 768px) {

    .asm-book {
        width: 100vw !important;
        height: auto !important;
    }

    .asm-page {
        width: 100% !important;
        left: 0 !important;
        box-shadow:none !important;
    }

    .asm-page.right {
        display: none !important;
    }

    .asm-page img {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    .asm-flip-panel{
        width:100% !important;
    }

}


@media (max-width: 768px) {

    .asm-viewer,
    .asm-book-wrap,
    .asm-book {
        width: 100vw !important;
        height: 100vh !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden;
    }

    .asm-book {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .asm-page {
        width: 96vw !important;
        height: auto !important;
        left: 0 !important;
        margin: auto !important;
        box-shadow: none !important;
    }
}

.asm-book.last-page-single {
    justify-content: center !important;
}
