/* ==========================================================================
   ئۇيغۇر تېبابىتى كىتابخانىسى · Kitap Uyghur Medicine
   Royal Emerald & Parchment Gold Design System · Mobile-First Responsive
   ========================================================================== */

@font-face {
  font-family: 'UKIJ Tuz';
  src: url('../assets/fonts/ukij-tuz.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'UKIJ Tor';
  src: url('../assets/fonts/ukij-tor.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-primary: #06110c;
  --bg-surface: #0a1b14;
  --bg-card: #0f261c;
  --bg-card-hover: #153527;
  --gold-primary: #d4af37;
  --gold-light: #f7e289;
  --gold-glow: rgba(212, 175, 55, 0.25);
  --emerald-border: #1d4633;
  --text-main: #f0f7f3;
  --text-muted: #a6c2b3;
  --text-gold: #e2ba49;
  --font-base: 'UKIJ Tuz', 'Microsoft Uighur', 'Alpida Unicode System', Arial, sans-serif;
  --font-title: 'UKIJ Tor', 'UKIJ Tuz', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Security: Block text selection and dragging across the app */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-primary);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.7;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Hard Print Blocker */
@media print {
  body {
    display: none !important;
  }
}

/* Header */
.site-header {
  background: rgba(10, 27, 20, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--emerald-border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.25rem;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  font-size: 2rem;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold-primary);
  box-shadow: 0 0 15px var(--gold-glow);
}

.logo-text h1 {
  font-family: var(--font-title);
  font-size: 1.35rem;
  color: var(--gold-light);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-nav-btn {
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--emerald-border);
  transition: var(--transition);
}

.header-nav-btn:hover,
.header-nav-btn.active {
  background: var(--gold-glow);
  border-color: var(--gold-primary);
  color: var(--gold-light);
}

/* Hero Section */
.hero-section {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  background: radial-gradient(circle at 50% 10%, rgba(21, 53, 39, 0.6) 0%, transparent 70%);
}

.hero-content {
  max-width: 820px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  padding: 0.35rem 1.1rem;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--gold-primary);
  border-radius: 50px;
  color: var(--gold-light);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
}

.hero-title {
  font-family: var(--font-title);
  font-size: 2rem;
  line-height: 1.4;
  color: var(--gold-light);
  margin-bottom: 1rem;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 2rem;
}

/* Search Box */
.search-box {
  position: relative;
  max-width: 580px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--gold-primary);
}

.search-box input {
  width: 100%;
  padding: 0.9rem 3rem 0.9rem 1.2rem;
  background: var(--bg-surface);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-base);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.search-box input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 16px var(--gold-glow);
}

/* Category Pills */
.category-section {
  max-width: 1200px;
  margin: 0 auto 2rem;
  padding: 0 1.25rem;
}

.category-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.cat-pill {
  padding: 0.6rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--emerald-border);
  border-radius: 50px;
  color: var(--text-muted);
  font-family: var(--font-base);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.cat-pill:hover,
.cat-pill.active {
  background: var(--gold-glow);
  border-color: var(--gold-primary);
  color: var(--gold-light);
  box-shadow: 0 0 12px var(--gold-glow);
  transform: translateY(-1px);
}

/* Books Grid */
.books-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.75rem;
}

/* Book Card */
.book-card {
  background: var(--bg-card);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.book-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--gold-primary), transparent);
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-primary);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 15px var(--gold-glow);
  background: var(--bg-card-hover);
}

.book-cover-mock {
  height: 180px;
  background: radial-gradient(circle at 50% 30%, #1a4231 0%, #0d241a 100%);
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  margin-bottom: 1.25rem;
  position: relative;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.35);
}

.book-cover-mock .cover-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.book-cover-mock .cover-title {
  font-family: var(--font-title);
  color: var(--gold-light);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.book-cover-mock .cover-stamp {
  font-size: 0.7rem;
  color: var(--gold-primary);
  margin-top: 0.4rem;
  border-top: 1px dashed rgba(212, 175, 55, 0.4);
  padding-top: 0.3rem;
  width: 80%;
}

.book-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.book-era-tag {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 4px;
  color: var(--gold-primary);
}

.book-type-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.book-card-title {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--gold-light);
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.book-card-author {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.book-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
  flex: 1;
}

.book-read-btn {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, #18422e 0%, #0d2b1e 100%);
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-sm);
  color: var(--gold-light);
  font-family: var(--font-base);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  transition: var(--transition);
}

.book-read-btn:hover {
  background: linear-gradient(135deg, var(--gold-primary) 0%, #b89726 100%);
  color: #05100b;
  box-shadow: 0 4px 15px var(--gold-glow);
}

/* ==========================================================================
   Secure In-Browser Reader Modal (Watermark & Anti-Download Protected)
   ========================================================================== */
.reader-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 11, 7, 0.94);
  backdrop-filter: blur(16px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.reader-modal-overlay.active {
  display: flex;
}

.reader-modal-window {
  width: min(920px, calc(100vw - 24px));
  max-height: calc(100vh - 30px);
  background: #091c13;
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 25px var(--gold-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Reader Header */
.reader-header {
  padding: 0.9rem 1.25rem;
  background: #0d261b;
  border-bottom: 1px solid var(--emerald-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.reader-title-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.reader-title-info h3 {
  font-family: var(--font-title);
  color: var(--gold-light);
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--gold-primary);
  border-radius: 4px;
  color: var(--gold-light);
}

.reader-author {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reader-btn,
.reader-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--emerald-border);
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.reader-close-btn:hover {
  background: #c0392b;
  border-color: #e74c3c;
  color: #fff;
}

.reader-btn:hover {
  border-color: var(--gold-primary);
  color: var(--gold-light);
}

/* Watermark Ribbon */
.reader-watermark-ribbon {
  background: rgba(212, 175, 55, 0.12);
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
  padding: 0.35rem 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--gold-light);
}

/* Viewport / Page Canvas */
.reader-viewport {
  flex: 1;
  overflow-y: auto;
  position: relative;
  background: #050d09;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  min-height: 480px;
}

/* Diagonal Watermark Pattern across the reading area */
.watermark-pattern-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  opacity: 0.14;
  transform: rotate(-25deg) scale(1.1);
  overflow: hidden;
}

.watermark-text {
  font-family: var(--font-title);
  font-size: 1.8rem;
  color: var(--gold-primary);
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
}

/* PDF Canvas */
.pdf-page-canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
  background: #fff;
}

/* Formatted Text View */
.reader-text-content {
  width: 100%;
  max-width: 680px;
  background: #0c2016;
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-sm);
  padding: 1.75rem;
  line-height: 1.9;
  font-size: 1rem;
  color: var(--text-main);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.reader-text-content h4 {
  font-family: var(--font-title);
  color: var(--gold-light);
  font-size: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--emerald-border);
  padding-bottom: 0.5rem;
}

/* Security Shield (prevents right-click and image-save) */
.reader-security-shield {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: transparent;
  pointer-events: auto;
}

/* Footer / Page Navigation */
.reader-footer {
  padding: 0.85rem 1.25rem;
  background: #0d261b;
  border-top: 1px solid var(--emerald-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-page-btn {
  padding: 0.55rem 1.1rem;
  background: var(--bg-surface);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-base);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.nav-page-btn:hover:not(:disabled) {
  background: var(--gold-glow);
  border-color: var(--gold-primary);
  color: var(--gold-light);
}

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

.page-indicator {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.current-num {
  font-weight: 700;
  color: var(--gold-light);
}

/* Footer */
.site-footer {
  background: #040c08;
  border-top: 1px solid var(--emerald-border);
  padding: 2.5rem 1.25rem 2rem;
  text-align: center;
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
}

.footer-brand .footer-logo {
  font-family: var(--font-title);
  color: var(--gold-light);
  font-size: 1.15rem;
  display: block;
  margin-bottom: 0.5rem;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.footer-copy {
  font-size: 0.75rem;
  color: #6a8c7b;
  border-top: 1px solid rgba(29, 70, 51, 0.4);
  padding-top: 1rem;
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
  .site-header {
    padding: 0.75rem 1rem;
  }

  .header-container {
    justify-content: center;
  }

  .logo-text h1 {
    font-size: 1.15rem;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .hero-desc {
    font-size: 0.9rem;
  }

  .books-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .reader-modal-window {
    width: calc(100vw - 12px) !important;
    max-height: calc(100vh - 16px) !important;
  }

  .reader-header {
    padding: 0.75rem 0.85rem;
  }

  .reader-viewport {
    padding: 1rem 0.5rem;
    min-height: 380px;
  }

  .watermark-text {
    font-size: 1.25rem;
  }
}
