/* ============================================================
   POETRY ARCHIVE — Lokta Paper & 3D Book Experience
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,600&family=IM+Fell+English:ital@0;1&family=Special+Elite&family=Yatra+One&display=swap');

/* ===== CUSTOM PROPERTIES ===== */
:root {
  --mahogany:        #2B1206;
  --mahogany-mid:    #3D1A0A;
  --mahogany-dark:   #120803;
  --rust:            #8B3A1A;
  --rust-glow:       rgba(139, 58, 26, 0.4);
  --gold:            #D4AF37; 
  --gold-dim:        #AA8822;
  
  --cream:           #Fdf8eb; 
  --parchment:       #f5eed2;
  --parchment-dark:  #e0d3b1;
  
  --ink:             #1C1410;
  --ink-blue:        #0d162a; 
  --sepia:           #967954;
  --sepia-light:     #d7bd96; 
  
  --shadow:          rgba(10, 5, 2, 0.9);
  --ease-page:       cubic-bezier(0.4, 0.0, 0.2, 1); 
  --ease-smooth:     cubic-bezier(0.25, 0.46, 0.45, 0.94);
  
  --font-nepali:     'Yatra One', serif;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* Update base and typography tokens */
/* Update base and typography tokens */
body {
  background-color: #d6bf9c; /* Warmer, less bright lokta base */
  background-image: radial-gradient(ellipse at center, #ead4b4 0%, #bd9f7a 100%);
  color: #1c100a;
  font-family: 'Lora', serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.poetry-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.poetry-bg canvas { display: block; opacity: 0.8; }
body::after {
  content: ''; position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(60, 40, 20, 0.25) 150%);
  z-index: -1; pointer-events: none;
}

/* ===== NAVIGATION ===== */
.poetry-nav { position: absolute; top: 0; left: 0; right: 0; z-index: 100; display: flex; align-items: center; justify-content: space-between; padding: 1.5rem 2rem; }
.poetry-nav__brand { font-family: 'Cormorant Garamond', serif; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.2em; color: #3a2214; text-decoration: none; transition: color 0.3s ease; }
.poetry-nav__brand span { color: #8b3a1a; }
.poetry-nav__back { display: inline-flex; align-items: center; gap: 0.5rem; color: #3a2214; text-decoration: none; font-family: 'Lora', serif; font-size: 0.8rem; letter-spacing: 0.2em; text-transform: uppercase; transition: all 0.3s ease; padding: 0.4rem 0.8rem; border: 1px solid rgba(58, 34, 20, 0.3); background: rgba(240, 230, 214, 0.5); backdrop-filter: blur(4px); }
.poetry-nav__back:hover { color: #8b3a1a; border-color: #8b3a1a; background: rgba(220, 180, 150, 0.4); }
.poetry-nav__back svg { width: 14px; height: 14px; }

/* ===== HEADER ===== */
.archive-header { text-align: center; padding: 6rem 2rem 3rem; position: relative; max-width: 800px; margin: 0 auto; }
.archive-label { font-family: 'Lora', serif; font-size: 0.8rem; letter-spacing: 0.4em; text-transform: uppercase; color: #422918; opacity: 0.9; margin-bottom: 1.5rem; font-weight: bold; }
.archive-title { font-family: 'Cormorant Garamond', serif; font-size: clamp(3.5rem, 8vw, 5.5rem); font-weight: 700; color: #0f0502; line-height: 1.1; letter-spacing: -0.02em; text-shadow: 2px 2px 0px rgba(255,255,255,0.4); }
.archive-title span { color: #6b220d; font-style: italic; }
.archive-title-nepali { font-family: var(--font-nepali); font-size: clamp(1.8rem, 4vw, 2.4rem); color: #6b220d; letter-spacing: 0.15em; margin-top: 1rem; font-weight: 700; text-shadow: 1px 1px 0px rgba(255,255,255,0.4); }
.archive-author { font-family: 'Cormorant Garamond', serif; font-style: italic; font-weight: 700; font-size: 1.5rem; color: #1f1007; margin-bottom: 0.8rem; letter-spacing: 0.05em; }
.archive-description { font-style: italic; font-size: 1.1rem; color: #2e1d13; opacity: 0.9; letter-spacing: 0.05em; font-weight: 500; }

/* ===== THUMBNAIL GRID ===== */
.gallery-grid { max-width: 1200px; margin: 2rem auto 6rem; padding: 0 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2.5rem; }
.polaroid-card { position: relative; cursor: pointer; outline: none; transform-origin: center bottom; transition: transform 0.4s var(--ease-smooth); z-index: 50; }
.polaroid-card:hover, .polaroid-card:focus-visible { transform: translateY(-8px) rotate(-1deg); z-index: 55; }

.polaroid-paper {
  background-color: var(--parchment);
  background-image: radial-gradient(ellipse at 30% 25%, #fff 0%, var(--parchment) 50%, #D9C49A 100%);
  padding: 1rem 1rem 1.8rem;
  border: 1px solid rgba(139, 111, 71, 0.4);
  clip-path: polygon(0% 1%, 2% 0%, 5% 0.5%, 10% 0%, 15% 1%, 25% 0%, 35% 0.8%, 45% 0%, 55% 1%, 65% 0%, 75% 0.5%, 85% 0%, 95% 1%, 98% 0%, 100% 1.5%, 99% 25%, 100% 50%, 99% 75%, 100% 98.5%, 98% 100%, 90% 99%, 80% 100%, 70% 99.5%, 60% 100%, 50% 99%, 40% 100%, 30% 99%, 20% 100%, 10% 99.5%, 2% 100%, 0% 98.5%, 1% 75%, 0% 50%, 1% 25%);
  box-shadow: 8px 15px 35px rgba(0,0,0,0.6), inset 0 0 20px rgba(139, 111, 71, 0.2); display: flex; flex-direction: column; transition: box-shadow 0.4s ease;
}
.polaroid-card:hover .polaroid-paper { box-shadow: 12px 22px 45px rgba(0,0,0,0.8), inset 0 0 25px rgba(139, 111, 71, 0.3); }
.polaroid-image-frame { position: relative; width: 100%; aspect-ratio: 4 / 5; background: var(--mahogany-dark); border: 1px solid rgba(139, 111, 71, 0.3); margin-bottom: 1.2rem; overflow: hidden; }
.polaroid-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s ease, filter 0.6s ease; }
.polaroid-card:hover .polaroid-img { transform: scale(1.05); filter: contrast(1.1); }
.img-overlay { position: absolute; inset: 0; box-shadow: inset 0 0 40px rgba(28, 20, 16, 0.6); pointer-events: none; }
.polaroid-meta-top { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.micro-meta { font-family: 'Special Elite', monospace; font-size: 0.6rem; letter-spacing: 0.1em; color: var(--rust); opacity: 0.8; }
.polaroid-title { font-family: 'Playfair Display', serif; font-style: italic; font-weight: 700; font-size: 1.6rem; color: var(--ink); line-height: 1.2; margin-bottom: 0.8rem; text-align: center; }
.polaroid-title.nepali { font-family: var(--font-nepali); font-style: normal; font-weight: 400; font-size: 1.4rem; padding: 0 0.5rem; letter-spacing: 0.05em; }
.polaroid-meta-bottom { display: flex; justify-content: center; gap: 0.8rem; }
.micro-tag { font-family: 'Special Elite', monospace; font-size: 0.55rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--sepia); border-bottom: 1px dashed var(--sepia-light); padding-bottom: 2px; }

/* ===== FOOTER ===== */
.poetry-footer { text-align: center; padding: 2rem 1rem 3rem; font-family: 'Special Elite', monospace; font-size: 0.62rem; letter-spacing: 0.25em; color: var(--sepia); opacity: 0.6; text-transform: uppercase; }


/* ============================================================
   3D BOOK READER OVERLAY (PAGINATED ENGINE)
   ============================================================ */

.book-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity 0.5s ease; perspective: 2500px; overflow: hidden; }
.book-overlay.active { opacity: 1; visibility: visible; }
.book-scrim { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(30, 20, 15, 0.8) 0%, rgba(10, 5, 2, 0.95) 100%); backdrop-filter: blur(5px); }

.book-close-btn { position: absolute; top: 1.5rem; right: 2rem; z-index: 1010; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(184, 146, 42, 0.4); background: rgba(18, 8, 3, 0.8); color: var(--sepia-light); font-size: 1.2rem; cursor: pointer; transition: all 0.3s ease; }
.book-close-btn:hover { background: rgba(184, 146, 42, 0.3); color: var(--gold); border-color: var(--gold); }

/* THE 3D BOOK ENGINE */
.scene { position: relative; width: 860px; height: 580px; max-width: 95vw; max-height: 85vh; z-index: 1005; perspective: 2500px; }

.book-wrapper { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateX(8deg) translateY(10px); transition: transform 0.6s var(--ease-page); }
.book-overlay.active .book-wrapper { transform: rotateX(1deg) translateY(0); }

.book-wrapper.closed-front { transform: rotateX(1deg) translateX(-25%) !important; }
.book-wrapper.closed-back { transform: rotateX(1deg) translateX(25%) !important; }

/* Faster transition to prevent left stack glitch visually */
.book-page-flip { position: absolute; top: 0; right: 0; width: 50%; height: 100%; transform-style: preserve-3d; transform-origin: left center; transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1); }
.book-page-flip.flipped { transform: rotateY(-180deg); }

/* Nepali Lokta Paper Surface */
.page-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background-color: #fcebd1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.05' numOctaves='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.55  0 0 0 0 0.42  0 0 0 0 0.27  0 0 0 0.25 0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23f)'/%3E%3C/svg%3E"), radial-gradient(ellipse at center, rgba(255,255,255,0.7) 0%, rgba(200,165,115,0.3) 100%);
  padding: 3rem 2.5rem; border: none;
}
.page-face.no-padding { padding: 0 !important; }

.page-front { border-radius: 4px 16px 16px 4px; box-shadow: inset 10px 0 20px rgba(0,0,0,0.05), inset -2px 0 5px rgba(255,255,255,0.4), 2px 0 5px rgba(0,0,0,0.1); }
.page-back { transform: rotateY(180deg); border-radius: 16px 4px 4px 16px; box-shadow: inset -10px 0 20px rgba(0,0,0,0.05), inset 2px 0 5px rgba(255,255,255,0.4), -2px 0 5px rgba(0,0,0,0.1); }

/* Pointer triggers for clicks */
.book-page-flip:not(.flipped) .page-front { cursor: pointer; }
.book-page-flip.flipped .page-back { cursor: pointer; }

.spine-shadow-left { position: absolute; right: 0; top: 0; bottom: 0; width: 40px; background: linear-gradient(to right, transparent, rgba(0,0,0,0.12)); pointer-events: none; z-index: 10; border-radius: 0; }
.spine-shadow-right { position: absolute; left: 0; top: 0; bottom: 0; width: 40px; background: linear-gradient(to left, transparent, rgba(0,0,0,0.12)); pointer-events: none; z-index: 10; border-radius: 0; }

/* PAGE CONTENT TEXT Formatting */
.reader-title-page { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; text-align: center; }
.reader-poem-title { font-family: 'Playfair Display', serif; font-weight: 700; font-style: italic; font-size: clamp(2rem, 3.5vw, 2.6rem); color: var(--ink); line-height: 1.1; margin-bottom: 1rem; padding: 0 1rem; }
.reader-poem-title.nepali { font-family: var(--font-nepali); font-style: normal; font-weight: 400; font-size: clamp(1.8rem, 3vw, 2.2rem); letter-spacing: 0.05em; line-height: 1.3; margin-bottom: 0.5rem; text-shadow: 1px 1px 0 rgba(255,255,255,0.5); }
.reader-poem-author { font-family: 'IM Fell English', serif; font-style: italic; font-size: 1.1rem; color: var(--rust); margin-bottom: 0.5rem;}
.reader-poem-rule { width: 50px; height: 1px; background: var(--sepia); margin: 1.5rem auto; opacity: 0.5; }
.reader-poem-meta { font-family: 'Special Elite', monospace; font-size: 0.7rem; color: var(--sepia); letter-spacing: 0.1em; }

/* Stanzas without scrolling */
.reader-text-page { font-family: 'Special Elite', monospace; font-size: 0.95rem; line-height: 2; color: var(--ink-blue); white-space: pre-line; display: flex; flex-direction: column; justify-content: center; height: 100%; overflow: hidden; }
.reader-text-page.nepali { font-family: var(--font-nepali); font-size: 1.05rem; line-height: 2.3; letter-spacing: 0.01em; padding: 0 1rem;}
.stanza { margin-bottom: 1.5rem; }

.red-stanza { color: #8b251a; text-shadow: 0 0 1px rgba(139, 37, 26, 0.2); }
.blue-stanza { color: #1a3c6b; text-shadow: 0 0 1px rgba(26, 60, 107, 0.2); }

.faded-img-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.7; filter: sepia(0.6) blur(0.5px) contrast(1.1); pointer-events: none; border-radius: 16px 4px 4px 16px;}

/* Book Cover - Raw Leather Without Full Width Image */
.book-cover {
  background-color: var(--mahogany-dark) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22400%22 height=%22400%22%3E%3Cfilter id=%22n%22%3E%3CfeTurbulence type=%22fractalNoise%22 baseFrequency=%220.8%22 numOctaves=%224%22 stitchTiles=%22stitch%22/%3E%3CfeColorMatrix type=%22saturate%22 values=%220%22/%3E%3C/filter%3E%3Crect width=%22400%22 height=%22400%22 filter=%22url(%23n)%22 opacity=%220.2%22/%3E%3C/svg%3E"), linear-gradient(135deg, #270d02 0%, #120803 100%) !important;
  width: 100%; height: 100%; position: relative; overflow: hidden;
}
.cover-border { position:absolute; inset: 1.5rem; border:2px solid rgba(212,175,55,0.4); z-index:2; pointer-events:none; }
.cover-photo-wrapper { position:absolute; top:8%; right:8%; width:70%; aspect-ratio:4/5; border:4px solid #140804; box-shadow:0 15px 30px rgba(0,0,0,0.8); z-index:3; }
.cover-photo { width:100%; height:100%; object-fit:cover; filter:sepia(0.6) brightness(0.7) contrast(1.1); }
.cover-title-wrapper { position:absolute; bottom: 18%; left: 8%; z-index:4; max-width: 75%; }
.cover-title-main { color:#ffffff !important; -webkit-text-stroke: 1px rgba(30,10,5,0.8); text-shadow: 2px 4px 12px rgba(0,0,0,1), 0 0 30px rgba(0,0,0,0.8), 0 0 50px rgba(0,0,0,0.9) !important; margin:0; padding:0; text-align:left; font-size: clamp(1.6rem, 5vw, 2.2rem) !important; line-height: 1.3 !important; }
.cover-author-wrapper { position:absolute; bottom: 8%; right: 10%; z-index:4; }
.cover-author-main { font-family:'Yatra One', serif; color:#e09c48; -webkit-text-stroke: 0.5px rgba(0,0,0,0.8); font-size: clamp(1.1rem, 4vw, 1.45rem); letter-spacing:0.05em; text-shadow: 2px 3px 8px rgba(0,0,0,1), 0 0 20px rgba(0,0,0,0.8); margin: 0; padding: 0; }

.page-front.no-padding { border-radius: 4px 12px 12px 4px; box-shadow: inset 10px 0 20px rgba(0,0,0,0.6), 4px 0 10px rgba(0,0,0,0.5); border-right: 4px solid #140804; }
.page-back.no-padding { border-radius: 12px 4px 4px 12px; box-shadow: inset -10px 0 20px rgba(0,0,0,0.6), -4px 0 10px rgba(0,0,0,0.5); border-left: 4px solid #140804; }

@media (min-width: 851px) {
  /* Inject heavy SVG paper textures only for desktop processors */
  body {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.05' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.55  0 0 0 0 0.42  0 0 0 0 0.3  0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23f)'/%3E%3C/svg%3E"), radial-gradient(ellipse at center, #ead4b4 0%, #bd9f7a 100%);
  }
  .polaroid-paper {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.9,0.03' numOctaves='3' seed='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.55  0 0 0 0 0.42  0 0 0 0 0.27  0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23f)'/%3E%3C/svg%3E"), radial-gradient(ellipse at 30% 25%, #fff 0%, var(--parchment) 50%, #D9C49A 100%);
  }
  .page-face {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.55  0 0 0 0 0.42  0 0 0 0 0.27  0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23f)' opacity='0.5'/%3E%3C/svg%3E"), radial-gradient(ellipse at center, rgba(255,255,255,0.7) 0%, rgba(200,165,115,0.3) 100%);
  }
}

@media (max-width: 850px) {
  body {
    background-color: #efe2c8;
    background-image: radial-gradient(ellipse at center, #fbf4e3 0%, #ead8b8 100%);
  }

  body::after {
    background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(60, 40, 20, 0.1) 140%);
  }

  .poetry-bg {
    display: none;
  }

  /* Mobile structural overrides */
  .scene { width: 95vw; height: 85vh; perspective: 2500px; }
  .book-wrapper { transform-origin: center; }
  .book-page-flip { width: 100%; height: 100%; top: 0; left: 0; right: auto; transform-origin: center center; transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.35s ease !important; }
  /* Silky smooth mobile swipe: slide out, shrink, and fade away natively */
  .book-page-flip.flipped { transform: translateX(-40%) scale(0.9); opacity: 0; pointer-events: none; }
  .page-face { padding: 1.5rem 1rem; }
  .book-wrapper.closed-front { transform: translateX(0) !important; }
  .book-wrapper.closed-back { transform: translateX(0) !important; }
  
  .reader-poem-title { font-size: 1.8rem; text-align: center; }
  .reader-poem-title.nepali { font-size: 1.6rem; text-align: center; }
  .reader-poem-meta, .reader-poem-author { text-align: center; }
  .reader-text-page { font-size: 0.85rem; line-height: 1.8; text-align: center; }
  .reader-text-page.nepali { font-size: 1.05rem; line-height: 2.1; padding: 0 0.5rem; text-align: left; }
}
@media (max-width: 600px) {
  .archive-header { padding: 4rem 1rem 2rem; }
  .archive-title { font-size: 2.5rem; }
  .archive-title-nepali { font-size: 1.6rem; }
  .gallery-grid { grid-template-columns: 1fr; gap: 3rem; }
}
