/* ═══════════════════════════════════════════════
   NSS TSEC — Magazine Section & Book Viewer
   FIXED: Centered book, smooth flips, proper states
   ═══════════════════════════════════════════════ */

/* ── Section Layout ── */
.magazine-section {
  padding: var(--s-12) 0;
  background: #ffffff;
}

.magazine-header {
  text-align: center;
  margin-bottom: var(--s-8);
}

.magazine-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: #000000;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-2);
}

.magazine-title .letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
}

.magazine-subtitle {
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 400;
  max-width: 500px;
  margin: 0 auto;
}

/* ── Cover Cards Grid ── */
.magazine-covers {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}

.magazine-card {
  width: 280px;
  height: 400px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
              box-shadow 0.5s ease;
  transform-style: preserve-3d;
  perspective: 1000px;
}

.magazine-card:hover {
  transform: rotateY(-5deg) rotateX(3deg) scale(1.04);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7),
              -10px 10px 30px rgba(100, 100, 255, 0.08);
}

.magazine-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.magazine-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.85) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px;
  transition: background 0.4s ease;
}

.magazine-card:hover .magazine-card-overlay {
  background: linear-gradient(180deg, transparent 20%, rgba(0,0,0,0.9) 100%);
}

.magazine-card-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.magazine-card-edition {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  margin-top: 6px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.magazine-card-cta {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 20px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 24px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all 0.3s ease;
  width: fit-content;
}

.magazine-card:hover .magazine-card-cta {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.5);
}

/* ═══════════════════════════════
   FULLSCREEN BOOK VIEWER
   ═══════════════════════════════ */
.book-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.book-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Close button */
.book-close {
  position: absolute;
  top: 24px;
  right: 32px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 2.8rem;
  font-weight: 200;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 100;
}

.book-close:hover {
  color: #fff;
  transform: rotate(90deg) scale(1.1);
}

/* ═══════════════════════════════
   BOOK WRAPPER — Handles centering
   ═══════════════════════════════ */
.book-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  perspective: 2500px;
}

/* ── Book Container ── */
.book-container {
  position: relative;
  height: 560px;
  max-height: 75vh;
  transform-style: preserve-3d;
  transition: width 0.7s ease-in-out;
}

/* CLOSED state: only cover visible, single-page width */
.book-container.state-closed {
  width: 410px;
  max-width: 47vw;
}

/* OPEN state: two pages visible, full width */
.book-container.state-open {
  width: 820px;
  max-width: 94vw;
}

/* BACK state: only back cover visible, single-page width */
.book-container.state-back {
  width: 410px;
  max-width: 47vw;
}

/* ── Spine Shadow (only visible when open) ── */
.book-spine-glow {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  transform: translateX(-50%);
  width: 40px;
  background: linear-gradient(90deg,
    rgba(0,0,0,0.1) 0%,
    rgba(0,0,0,0.25) 45%,
    rgba(0,0,0,0.3) 50%,
    rgba(0,0,0,0.25) 55%,
    rgba(0,0,0,0.1) 100%);
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.book-container.state-open .book-spine-glow {
  opacity: 1;
}

/* ── Left page area ── */
.book-page-left {
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  height: 100%;
  background: #fdfaf5;
  border-radius: 8px 0 0 8px;
  box-shadow: inset -10px 0 30px rgba(0,0,0,0.06);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease 0.2s;
}

.book-container.state-open .book-page-left {
  opacity: 1;
  pointer-events: auto;
}

/* ── Right page area ── */
.book-page-right-area {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  transform-style: preserve-3d;
  background: transparent;
  transition: width 0.7s ease-in-out;
}

/* When closed: takes full width (the cover IS the book) */
.book-container.state-closed .book-page-right-area {
  width: 100%;
}

/* When open: takes right half */
.book-container.state-open .book-page-right-area {
  width: 50%;
}

/* When at back cover: left area takes full */
.book-container.state-back .book-page-right-area {
  width: 0;
  overflow: hidden;
}

/* ── Each flippable page ── */
.book-page {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.7s ease-in-out;
  cursor: pointer;
  z-index: 1;
}

.book-page.flipped {
  transform: rotateY(-180deg);
}

.book-page.dragging {
  transition: transform 0.08s linear;
}

/* ── Page Faces ── */
.page-front, .page-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  overflow: hidden;
  background: #fdfaf5;
  border-radius: 0 8px 8px 0;
  box-shadow: inset 8px 0 24px rgba(0,0,0,0.04);
}

.page-back {
  transform: rotateY(180deg);
  border-radius: 8px 0 0 8px;
  box-shadow: inset -8px 0 24px rgba(0,0,0,0.04);
}

/* Paper texture */
.page-front::before, .page-back::before, .book-page-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 10;
}

/* ── Page Content ── */
.page-content {
  padding: 40px 32px;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.page-number {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  color: #aaa;
  text-align: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ── Front Cover Design ── */
.page-cover-front {
  background: linear-gradient(135deg, #111133 0%, #222255 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  /* When closed, the cover has its own rounded corners */
  border-radius: 8px;
}

/* When book is open, only round right side */
.book-container.state-open .page-cover-front {
  border-radius: 0 8px 8px 0;
}

.page-cover-front img.cover-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.35;
  mix-blend-mode: luminosity;
}

.page-cover-front .cover-content {
  position: relative;
  z-index: 5;
}

.page-cover-front .cover-logo {
  width: 120px;
  height: 120px;
  clip-path: circle(50%);
  margin-bottom: 24px;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
}

.page-cover-front h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: #fff;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ══════════════════════════════════
   BACK COVER — BLUE bg, RED text
   ══════════════════════════════════ */
.back-cover-panel {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a1a6b 0%, #0d2280 40%, #0e1a5e 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.book-container.state-back .back-cover-panel {
  opacity: 1;
  pointer-events: auto;
}

.back-cover-panel .hind-text {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  color: #e53935;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  text-shadow: 0 4px 20px rgba(229, 57, 53, 0.3);
}

/* Also style the page-back version (back face of last page) */
.page-back-hind {
  background: linear-gradient(135deg, #0a1a6b 0%, #0d2280 40%, #0e1a5e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.page-back-hind .hind-text {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  color: #e53935;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  text-shadow: 0 4px 20px rgba(229, 57, 53, 0.3);
}

/* ── Interior elements ── */
.page-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

.page-desc {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  color: #444;
  line-height: 1.7;
}

/* ── Navigation Controls ── */
.book-nav {
  display: flex;
  align-items: center;
  gap: 40px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}

.book-nav.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.book-nav-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.book-nav-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

.book-nav-btn:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .book-container.state-open { width: 94vw; }
  .book-container.state-closed,
  .book-container.state-back { width: 47vw; }
  .book-container { height: 500px; }
}

@media (max-width: 600px) {
  .magazine-card { width: 240px; height: 340px; }
  .book-container.state-closed,
  .book-container.state-back { width: 85vw; }
  .book-container.state-open { width: 96vw; }
  .book-container { height: 420px; }
  .page-content { padding: 20px 16px; }
  .page-img { height: 140px; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .book-page, .book-container, .book-nav { transition: none; }
  .magazine-card { transition: none; }
}
