/* ================================================================
   AJP MANIFESTO VIEWER — style.css
   आम जनता पार्टी (AJP) | निर्वाचन घोषणा-पत्र, २०८२
   Brand Palette: Bold Red · Black · White · Gold accent
================================================================ */

/* ----------------------------------------------------------------
   1. GOOGLE FONTS — Noto Sans Devanagari for crisp Nepali text
---------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;600;700;800;900&display=swap');

/* ----------------------------------------------------------------
   2. CSS CUSTOM PROPERTIES
---------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --red:          #D40000;
  --dark-red:     #A30000;
  --deeper-red:   #720000;
  --black:        #111111;
  --off-black:    #2A2A2A;
  --white:        #FFFFFF;
  --light-gray:   #F2F2F2;

  /* Gold accent — for election energy */
  --gold:         #FFD000;
  --gold-dim:     #C9A200;
  --gold-glow:    rgba(255, 208, 0, 0.18);

  /* Page / background */
  --page-bg:      #0D0D0D;
  --page-mid:     #181818;

  /* Typography */
  --font-deva: 'Noto Sans Devanagari', 'Arial Unicode MS', Arial, sans-serif;
  --font-ui:   'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Layout */
  --viewer-max: 880px;

  /* Shadows */
  --book-shadow:
    0 2px 4px rgba(0,0,0,0.6),
    0 10px 40px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255,255,255,0.04),
    0 0 60px rgba(212,0,0,0.08);   /* subtle red ambient glow */

  /* Transitions */
  --t-fast:   0.14s ease;
  --t-mid:    0.24s ease;
}

/* ----------------------------------------------------------------
   3. RESET & BASE
---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  background-color: var(--black);
  /* Subtle dark radial glow from center — makes page feel "lit" */
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(180,0,0,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(0,0,0,0.6) 0%, transparent 70%);
  color: var(--white);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overscroll-behavior-y: contain;
}

/* ================================================================
   4. HEADER
================================================================ */
#site-header {
  /* Deep crimson gradient — dark top, rich mid, near-black base */
  background:
    linear-gradient(165deg,
      #5A0000 0%,
      #8B0000 18%,
      #A30000 42%,
      #7A0000 68%,
      #2E0000 100%);
  color: var(--white);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 200;
  /* Glow: warm red halo below the header */
  box-shadow:
    0 1px 0 rgba(255,255,255,0.10) inset,
    0 2px 0 rgba(0,0,0,0.35) inset,
    0 0  30px rgba(200, 0, 0, 0.55),
    0 6px 28px rgba(0,0,0,0.75),
    0 14px 50px rgba(0,0,0,0.50);
}

/* Thin gold line at very top — adds visual prestige */
#site-header::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold-dim) 20%,
    var(--gold) 50%,
    var(--gold-dim) 80%,
    transparent 100%);
}

.header-inner {
  max-width: var(--viewer-max);
  margin: 0 auto;
  padding: 10px 16px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ── Logo image ──────────────────────────────────── */
.header-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  object-position: center;
  /* White circle background so logo reads on any BG */
  background: var(--white);
  border-radius: 50%;
  padding: 4px;
  /* Gold ring border */
  border: 2.5px solid var(--gold);
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, 0.25),
    0 3px 10px rgba(255, 0, 0, 0.5);
  /* Keep sharp on retina */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ── Party name & subtitle ───────────────────────── */
.header-text {
  flex: 1;
  min-width: 0;
}

.party-name {
  font-family: var(--font-deva);
  font-size: clamp(1.05rem, 3.8vw, 1.45rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.15;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  /* Prevent overflow on tiny screens */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-abbr {
  font-size: 0.8em;
  font-weight: 700;
  opacity: 0.88;
}

.party-tagline {
  font-family: var(--font-deva);
  font-size: clamp(0.7rem, 2.4vw, 0.92rem);
  font-weight: 600;
  /* Gold text for the document title line */
  color: var(--gold);
  margin-top: 3px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Third line — the party motto, dimmed white */
.party-motto {
  font-family: var(--font-deva);
  font-size: clamp(0.55rem, 1.6vw, 0.68rem);
  font-weight: 600;
  color: rgb(255, 255, 255);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

/* ── Right slogan pill ───────────────────────────── */
.header-slogan {
  flex-shrink: 0;
  background: rgba(0,0,0,0.32);
  border: 1.5px solid var(--gold-dim);
  border-radius: 24px;
  padding: 6px 14px;
  font-family: var(--font-deva);
  font-size: clamp(0.58rem, 1.8vw, 0.75rem);
  font-weight: 800;
  color: var(--gold);
  white-space: nowrap;
  letter-spacing: 0.03em;
  display: none;     /* shown on ≥600px screens */
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  box-shadow: 0 0 10px rgba(255,208,0,0.20), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: pillGlow 3s ease-in-out infinite;
}

@keyframes pillGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255,208,0,0.20), inset 0 1px 0 rgba(255,255,255,0.06); }
  50%       { box-shadow: 0 0 18px rgba(255,208,0,0.40), inset 0 1px 0 rgba(255,255,255,0.06); }
}

/* ================================================================
   5. SLOGAN TICKER
================================================================ */
#slogan-ticker {
  background: var(--off-black);
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 2px solid var(--red);
  overflow: hidden;
  height: 38px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  /* subtle inner shadow */
  box-shadow: inset 0 -1px 0 rgba(212,0,0,0.3);
  position: relative;
  z-index: 100;
}

/* Fading left/right edges so text "appears" from darkness */
#slogan-ticker::before,
#slogan-ticker::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  z-index: 2;
  pointer-events: none;
}
#slogan-ticker::before {
  left: 0;
  background: linear-gradient(to right, var(--off-black), transparent);
}
#slogan-ticker::after {
  right: 0;
  background: linear-gradient(to left, var(--off-black), transparent);
}

/*
  The track contains items TWICE so translateX(-50%)
  lands exactly back at the start — creating a seamless loop.
*/
.ticker-track {
  display: inline-flex;
  align-items: center;
  gap: 28px;
  white-space: nowrap;
  padding-left: 40px;
  animation: tickerScroll 55s linear infinite;
  /* Pause on hover — lets user read a slogan */
  will-change: transform;
}

#slogan-ticker:hover .ticker-track {
  animation-play-state: paused;
}

@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  font-family: var(--font-deva);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.ticker-sep {
  color: var(--red);
  font-size: 0.6rem;
  flex-shrink: 0;
  opacity: 0.8;
}

/* ================================================================
   6. MAIN CONTENT
================================================================ */
#main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  overflow: hidden;
}

/* ================================================================
   7. PDF VIEWER WRAPPER — the "book" on screen
================================================================ */
#pdf-viewer-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: var(--viewer-max);
  background: var(--white);
  /* Top red accent bar */
  border-top: 4px solid var(--red);
  border-radius: 0 0 6px 6px;
  box-shadow: var(--book-shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The PDF.js canvas — sized by script.js, constrained to container */
#pdf-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;   /* mobile: keep page fitted in viewport */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Desktop: lift the height cap so the canvas can exceed viewer height,
   allowing vertical scroll inside #pdf-viewer-wrap */
@media (min-width: 900px) {
  #pdf-canvas {
    max-height: none;
  }
}

/* ================================================================
   8. LOADING OVERLAY & SPINNER
================================================================ */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 10;
  transition: opacity var(--t-mid);
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Double-ring spinner for visual polish */
.spinner-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 5px solid #EBEBEB;
  border-top-color:  var(--red);
  border-right-color: var(--gold-dim);
  animation: spin 0.8s cubic-bezier(0.4,0,0.2,1) infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-family: var(--font-deva);
  font-size: 0.9rem;
  color: var(--off-black);
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

/* ================================================================
   9. SWIPE HINT OVERLAY
================================================================ */
#swipe-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 24px;
  padding: 6px 18px;
  z-index: 5;
  pointer-events: none;
  animation: swipeHintPulse 2s ease-in-out 2.5s 2, swipeHintFadeIn 0.5s ease 2s both;
  /* Auto-fade after a while */
  transition: opacity 0.6s ease;
}

#swipe-hint.dismissed {
  opacity: 0;
  pointer-events: none;
}

.swipe-arrow {
  font-size: 1rem;
  color: var(--gold);
  font-weight: 700;
  animation: swipeArrowBounce 1.5s ease-in-out 2.5s 4 alternate;
}

.swipe-label {
  font-family: var(--font-deva);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

@keyframes swipeHintFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes swipeHintPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes swipeArrowBounce {
  0%   { transform: translateX(0); }
  100% { transform: translateX(4px); }
}

/* ================================================================
   10. ERROR MESSAGE
================================================================ */
#error-message {
  padding: 36px 24px;
  text-align: center;
  max-width: 480px;
}
#error-message[hidden] { display: none; }

.error-icon   { font-size: 3rem; margin-bottom: 14px; }
.error-title  {
  font-family: var(--font-deva);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 10px;
}
.error-detail {
  font-family: var(--font-deva);
  font-size: 0.88rem;
  color: var(--off-black);
  line-height: 1.65;
  margin-bottom: 12px;
}
.error-hint {
  font-size: 0.8rem;
  color: #555;
  background: var(--light-gray);
  border-left: 3px solid var(--red);
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
  text-align: left;
  line-height: 1.6;
}
.error-hint code {
  font-family: 'Courier New', monospace;
  background: #e0e0e0;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.85em;
  color: var(--deeper-red);
}

/* ================================================================
   11. NAVIGATION CONTROLS BAR
================================================================ */
#pdf-controls {
  background: linear-gradient(180deg, var(--red) 0%, var(--dark-red) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  height: 62px;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 200;
  box-shadow: 0 -3px 16px rgba(0,0,0,0.5);
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* Thin gold separator line at the top of the controls bar */
#pdf-controls::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,208,0,0.5) 30%,
    rgba(255,208,0,0.7) 50%,
    rgba(255,208,0,0.5) 70%,
    transparent 100%);
}

/* ── Prev / Next Buttons ─────────────────────────── */
.nav-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0,0,0,0.22);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 10px;
  padding: 9px 18px;
  font-family: var(--font-deva);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  min-width: 50px;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    transform var(--t-fast),
    box-shadow var(--t-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(0,0,0,0.38);
  border-color: rgba(255,255,255,0.38);
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.94);
  background: rgba(0,0,0,0.50);
}

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

.nav-btn svg { flex-shrink: 0; }

/* ── Page indicator ──────────────────────────────── */
#page-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 6px 16px;
  min-width: 94px;
  justify-content: center;
}

/* "पृष्ठ" prefix label */
.page-label {
  font-family: var(--font-deva);
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.04em;
  margin-right: 2px;
}

#current-page {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--gold);
  min-width: 26px;
  text-align: center;
  text-shadow: 0 0 6px rgba(255,208,0,0.35);
}

.page-divider {
  font-size: 0.8rem;
  opacity: 0.5;
  font-weight: 300;
}

#total-pages {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.8;
  min-width: 26px;
  text-align: center;
}

/* ================================================================
   12. FOOTER
================================================================ */
#site-footer {
  background: var(--off-black);
  border-top: 2px solid var(--red);
  text-align: center;
  padding: 8px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.footer-headline {
  font-family: var(--font-deva);
  font-size: clamp(0.8rem, 2.4vw, 1rem);
  font-weight: 900;
  color: var(--white);
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.footer-org {
  font-family: var(--font-deva);
  font-size: clamp(0.62rem, 1.6vw, 0.72rem);
  color: rgba(255,255,255,0.42);
  letter-spacing: 0.01em;
  line-height: 1.4;
}

/* ================================================================
   13. PAGE TRANSITION ANIMATION
================================================================ */
#pdf-canvas.page-fade {
  animation: pageFade 0.22s ease-out;
}

@keyframes pageFade {
  0%   { opacity: 0.3; transform: scale(0.995); }
  100% { opacity: 1;   transform: scale(1); }
}

/* ================================================================
   14. SCROLL HINT ANIMATIONS (nav button arrows)
================================================================ */
@keyframes bounceLeft  { 0%,100%{transform:translateX(0)} 50%{transform:translateX(-5px)} }
@keyframes bounceRight { 0%,100%{transform:translateX(0)} 50%{transform:translateX(5px)} }

.nav-btn.hint-anim-prev svg { animation: bounceLeft  0.65s ease 1.5s 3; }
.nav-btn.hint-anim-next svg { animation: bounceRight 0.65s ease 1.5s 3; }

/* ================================================================
   15. RESPONSIVE BREAKPOINTS
================================================================ */

/* ── Medium (≥600px tablets) ─────────────────────── */
@media (min-width: 600px) {
  .header-slogan { display: block; }

  .party-name     { white-space: normal; }

  #main-content   { padding: 6px 14px; }

  .nav-btn {
    padding: 10px 22px;
    font-size: 0.93rem;
    min-width: 110px;
  }

  .logo-img { width: 62px; height: 62px; }
}

/* ── Large (≥900px desktop / laptop) ────────────── */
@media (min-width: 900px) {
  #main-content { padding: 8px 20px; }

  #pdf-viewer-wrap {
    border-radius: 0 0 8px 8px;
    /* Scale PDF to fill width; canvas overflows vertically → scroll */
    overflow-y: auto;
    overflow-x: hidden;
    align-items: flex-start;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* Swipe hint is a mobile-only cue — hide on desktop and avoid
     it scrolling with the PDF content */
  #swipe-hint { display: none !important; }

  #pdf-controls {
    height: 68px;
    padding: 0 28px;
  }

  .logo-img { width: 66px; height: 66px; }
}

/* ── Very small phones (≤380px) ─────────────────── */
@media (max-width: 380px) {
  .nav-btn span    { display: none; }
  .nav-btn         { padding: 8px 12px; min-width: 44px; }
  .party-name      { font-size: 0.88rem; }
  .header-slogan   { display: none !important; }
  #slogan-ticker   { height: 32px; }
  .ticker-item     { font-size: 0.72rem; }
}

/* ── Landscape phones ────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  #site-header     { position: relative; }
  #main-content    { padding: 8px 8px 4px; }
  #pdf-controls    { height: 50px; }
  #slogan-ticker   { display: none; }   /* hide ticker in landscape to save vertical space */
}

/* ================================================================
   16. PRINT STYLES
================================================================ */
@media print {
  #site-header, #pdf-controls, #site-footer,
  #loading-overlay, #slogan-ticker, #swipe-hint { display: none !important; }
  #main-content { padding: 0; }
  #pdf-canvas   { width: 100%; box-shadow: none; }
}

/* ================================================================
   17. FOCUS (Accessibility)
================================================================ */
.nav-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ================================================================
   18. SCROLLBAR (Webkit)
================================================================ */
#main-content::-webkit-scrollbar       { width: 5px; }
#main-content::-webkit-scrollbar-track { background: var(--black); }
#main-content::-webkit-scrollbar-thumb { background: var(--red); border-radius: 3px; }

/* Thin red scrollbar inside the PDF viewer on desktop */
#pdf-viewer-wrap::-webkit-scrollbar       { width: 4px; }
#pdf-viewer-wrap::-webkit-scrollbar-track { background: rgba(0,0,0,0.08); }
#pdf-viewer-wrap::-webkit-scrollbar-thumb { background: var(--red); border-radius: 3px; }
