/* =========================================================
   Shreevya Global — Digital Catalogue Viewer
   Palette drawn from the catalogue itself:
   Navy   #0F2143   (cover / header backgrounds)
   Ink    #16294D   (secondary navy)
   Gold   #C79A4B   (accent, ruled lines, foil)
   Cream  #F6F1E9   (page paper)
   Stone  #6B7280   (muted text)
   ========================================================= */

:root{
  --navy: #0f2143;
  --navy-2: #0a1730;
  --ink: #16294d;
  --gold: #c79a4b;
  --gold-soft: #e4c789;
  --cream: #f6f1e9;
  --paper: #fbf8f2;
  --stone: #93a0b8;
  --white: #ffffff;
  --shadow-deep: 0 30px 80px -20px rgba(5, 10, 25, 0.65);
  --radius: 3px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*{ box-sizing: border-box; }
html,body{
  margin:0; padding:0; height:100%;
  background: var(--navy-2);
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--white);
  -webkit-tap-highlight-color: transparent;
}

/* subtle ambient background texture */
body{
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(199,154,75,0.10), transparent 60%),
    radial-gradient(1000px 700px at 100% 110%, rgba(199,154,75,0.08), transparent 55%),
    linear-gradient(180deg, #0a1730 0%, #0d1c3a 50%, #0a1730 100%);
}

button{ font-family: inherit; cursor: pointer; }

/* ---------------- Preloader ---------------- */
#preloader{
  position: fixed; inset: 0; z-index: 999;
  background: var(--navy-2);
  display:flex; align-items:center; justify-content:center;
  transition: opacity .6s var(--ease), visibility .6s var(--ease);
}
#preloader.hidden{ opacity:0; visibility:hidden; pointer-events:none; }
.loader-inner{ text-align:center; }
.loader-mark{
  width:64px; height:64px; margin: 0 auto 18px;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  font-family:'Fraunces', serif; font-size: 22px; letter-spacing: 1px;
  color: var(--gold-soft);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{ box-shadow: 0 0 0 0 rgba(199,154,75,0.25); }
  50%{ box-shadow: 0 0 0 10px rgba(199,154,75,0); }
}
.loader-title{ font-family:'Fraunces', serif; font-size: 19px; letter-spacing:.5px; color:var(--white); }
.loader-sub{ font-size: 12.5px; color: var(--stone); margin-top:6px; letter-spacing:.3px; }
.loader-bar{ width:180px; height:2px; background: rgba(255,255,255,.12); margin: 22px auto 0; overflow:hidden; border-radius: 2px;}
.loader-bar-fill{ height:100%; width:0%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); transition: width .25s ease; }

/* ---------------- Top bar ---------------- */
#topbar{
  position: fixed; top:0; left:0; right:0; height: 64px; z-index: 60;
  display:flex; align-items:center; justify-content:space-between;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(10,20,45,0.92), rgba(10,20,45,0.75));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(199,154,75,0.18);
}
.topbar-left{ display:flex; align-items:center; gap:12px; min-width: 0; }
.brand-mark{
  width:34px; height:34px; flex:none;
  border:1px solid var(--gold);
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-family:'Fraunces', serif; font-size:13px; color: var(--gold-soft);
}
.brand-text{ display:flex; flex-direction:column; line-height:1.2; overflow:hidden; }
.brand-name{ font-family:'Fraunces', serif; font-size: 15.5px; letter-spacing:.3px; white-space:nowrap; }
.brand-tag{ font-size: 10.5px; color: var(--stone); letter-spacing: .8px; text-transform: uppercase; white-space:nowrap; }

.topbar-center{
  display:flex; align-items:center; gap: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 6px 14px; border-radius: 30px;
}
#pageCounter{ font-size: 13px; color: var(--gold-soft); min-width: 52px; text-align:center; letter-spacing:.3px; font-variant-numeric: tabular-nums; }

.topbar-right{ display:flex; align-items:center; gap:6px; }

.icon-btn{
  width: 38px; height:38px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: var(--white);
  display:flex; align-items:center; justify-content:center;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease);
  text-decoration:none;
}
.icon-btn svg{ width:17px; height:17px; }
.icon-btn:hover{ background: rgba(199,154,75,0.18); border-color: var(--gold); transform: translateY(-1px); }
.icon-btn:active{ transform: translateY(0); }
.icon-btn:disabled{ opacity:.3; pointer-events:none; }

/* ---------------- Stage ---------------- */
#stage{
  position: fixed; top:64px; left:0; right:0; bottom:0;
  display:flex; align-items:center; justify-content:center;
  padding: 24px 70px;
}
#viewport{
  width:100%; height:100%;
  display:flex; align-items:center; justify-content:center;
  overflow: auto;
  perspective: 2400px;
}
#book{
  box-shadow: var(--shadow-deep);
  transition: transform .35s var(--ease);
  transform-origin: center center;
  touch-action: pan-y;
}
#book.zoomed{ cursor: grab; }
#book.dragging{ cursor: grabbing; }

.stf__parent{ margin: 0 auto; }

/* page surface */
.stf__item{
  background: var(--paper);
  overflow:hidden;
}
.page-img{
  width:100%; height:100%; object-fit: cover; display:block;
  user-select:none; -webkit-user-drag:none;
}
.page-shadow-edge{
  position:absolute; top:0; bottom:0; width: 14px;
  background: linear-gradient(90deg, rgba(0,0,0,0.10), transparent);
  pointer-events:none;
}

/* edge nav buttons */
.edge-nav{
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: var(--gold-soft);
  display:flex; align-items:center; justify-content:center;
  transition: background .2s var(--ease), transform .15s var(--ease), border-color .2s;
  z-index: 20;
}
.edge-nav svg{ width:20px; height:20px; }
.edge-nav:hover{ background: rgba(199,154,75,0.2); border-color: var(--gold); transform: scale(1.06); }
.edge-nav:disabled{ opacity:.25; pointer-events:none; }

/* hint toast */
#hintToast{
  position:fixed; bottom: 22px; left:50%; transform: translateX(-50%);
  background: rgba(10,20,45,0.85); border:1px solid rgba(199,154,75,0.3);
  padding: 9px 18px; border-radius: 30px; font-size: 12.5px; color: var(--stone);
  letter-spacing:.2px; opacity:1; transition: opacity .6s ease; z-index: 30;
  pointer-events:none; backdrop-filter: blur(6px);
}
#hintToast.hidden{ opacity:0; }

/* ---------------- Thumbnail drawer ---------------- */
#thumbOverlay{
  position: fixed; inset:0; background: rgba(5,10,25,0.6);
  backdrop-filter: blur(2px);
  z-index: 70; opacity:0; visibility:hidden; transition: opacity .3s var(--ease), visibility .3s;
}
#thumbOverlay.open{ opacity:1; visibility:visible; }

#thumbDrawer{
  position: fixed; top:0; right:0; bottom:0; width: 320px; z-index: 80;
  background: var(--navy);
  border-left: 1px solid rgba(199,154,75,0.2);
  transform: translateX(100%);
  transition: transform .38s var(--ease);
  display:flex; flex-direction:column;
}
#thumbDrawer.open{ transform: translateX(0); }
.thumb-drawer-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family:'Fraunces', serif; font-size: 15px; letter-spacing:.4px;
}
.thumb-grid{
  padding: 16px; overflow-y:auto; display:grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.thumb-item{
  cursor:pointer; border-radius: 4px; overflow:hidden;
  border: 1.5px solid transparent;
  transition: border-color .2s var(--ease), transform .15s var(--ease);
  position:relative; background: var(--paper);
}
.thumb-item img{ width:100%; display:block; aspect-ratio: 0.708; object-fit:cover; }
.thumb-item:hover{ transform: translateY(-2px); }
.thumb-item.active{ border-color: var(--gold); }
.thumb-num{
  position:absolute; bottom:4px; right:6px; font-size:10px; color:#fff;
  background: rgba(10,20,45,0.75); padding:1px 6px; border-radius: 10px; letter-spacing:.3px;
}

/* ---------------- Share popover ---------------- */
#sharePopover{
  position: fixed; top: 70px; right: 18px; z-index: 90;
  background: var(--navy); border: 1px solid rgba(199,154,75,0.3);
  border-radius: 8px; padding: 12px; box-shadow: var(--shadow-deep);
  display:none; width: 300px;
}
#sharePopover.open{ display:block; }
.share-row{ display:flex; gap:8px; }
#shareUrlInput{
  flex:1; background: rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.12);
  color:var(--white); padding: 9px 10px; border-radius:5px; font-size:12.5px; outline:none;
}
#copyLinkBtn{
  background: var(--gold); color: var(--navy-2); border:none; border-radius:5px;
  padding: 0 14px; font-size:12.5px; font-weight:600; transition: background .2s;
}
#copyLinkBtn:hover{ background: var(--gold-soft); }
#copyLinkBtn.copied{ background: #6fbf73; color:#0a1730; }

/* ---------------- Scrollbar (thumb grid) ---------------- */
.thumb-grid::-webkit-scrollbar{ width:6px; }
.thumb-grid::-webkit-scrollbar-thumb{ background: rgba(199,154,75,0.4); border-radius:6px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px){
  #stage{ padding: 12px 8px; }
  .edge-nav{ width:38px; height:38px; }
  .topbar-left .brand-tag{ display:none; }
  .topbar-center{ gap:8px; padding: 5px 10px; }
  #topbar{ padding: 0 10px; gap: 6px; }
  .icon-btn{ width:34px; height:34px; }
  .icon-btn svg{ width:15px; height:15px; }
  #thumbDrawer{ width: 82vw; }
  #sharePopover{ width: calc(100vw - 36px); right: 18px; }
  #hintToast{ font-size: 11px; padding: 7px 14px; bottom: 14px; }
}

@media (max-width: 560px){
  .topbar-right #zoomOutBtn, .topbar-right #zoomInBtn{ display:none; }
  .edge-nav{ display:none; }
}

/* fullscreen mode tweaks */
:fullscreen #topbar{ background: rgba(10,20,45,0.96); }
::backdrop{ background: var(--navy-2); }
