/* romateka.ru Design System & 3D CSS Book Engine */
:root {
  --color-paper: #FAF8F5;
  --color-sand: #F2ECE1;
  --color-sand-dark: #E5DCce;
  --color-graphite: #1F1D1A;
  --color-graphite-light: #4A4640;
  --color-graphite-muted: #736E66;
  --color-burgundy: #7C1D26;
  --color-burgundy-hover: #962530;
  --color-burgundy-light: #FBF1F2;
  --color-pine: #1E3A34;
  --color-pine-light: #2A4E46;
  --color-gold: #C5A059;
  --color-gold-light: #E9D7A5;
}

body {
  background-color: var(--color-paper);
  color: var(--color-graphite);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.font-cormorant {
  font-family: 'Cormorant Garamond', Georgia, serif;
}

.font-literata {
  font-family: 'Literata', Georgia, serif;
}

.font-manrope {
  font-family: 'Manrope', sans-serif;
}

.font-montserrat {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 3D Realistic CSS Book Engine */
.book-stage {
  perspective: 1400px;
  perspective-origin: 50% 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.book-3d {
  position: relative;
  width: 270px;
  height: 385px;
  transform-style: preserve-3d;
  transform: rotateY(-20deg) rotateX(8deg);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 3px 12px 12px 3px;
  box-shadow: 
    26px 34px 50px -8px rgba(22, 19, 16, 0.44), 
    8px 16px 28px -4px rgba(22, 19, 16, 0.22),
    -3px 0 10px rgba(0, 0, 0, 0.2);
}

.book-3d:hover {
  transform: rotateY(-8deg) rotateX(3deg) translateY(-10px);
  box-shadow: 
    32px 44px 64px -6px rgba(22, 19, 16, 0.5), 
    12px 22px 36px -4px rgba(22, 19, 16, 0.28),
    -4px 0 12px rgba(0, 0, 0, 0.25);
}

/* Front Cover */
.book-cover-front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 3px 12px 12px 3px;
  overflow: hidden;
  background-color: #121A17;
  border: 1px solid rgba(197, 160, 89, 0.25);
  transform: translateZ(12px);
}

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

/* Realistic Spine Hinge Crease & Lighting Overlays */
.book-spine-crease {
  position: absolute;
  top: 0;
  left: 20px;
  width: 6px;
  height: 100%;
  background: linear-gradient(90deg, 
    rgba(0, 0, 0, 0.35) 0%, 
    rgba(255, 255, 255, 0.2) 40%, 
    rgba(0, 0, 0, 0.25) 100%);
  pointer-events: none;
  z-index: 10;
}

.book-sheen-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, 
    rgba(255, 255, 255, 0.22) 0%, 
    rgba(255, 255, 255, 0.05) 18%, 
    transparent 36%, 
    rgba(0, 0, 0, 0.15) 75%, 
    rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
  z-index: 11;
}

/* 3D Pages Thickness (Right Edge) */
.book-pages-side {
  position: absolute;
  top: 3px;
  right: -23px;
  width: 24px;
  height: calc(100% - 6px);
  background: repeating-linear-gradient(
    90deg,
    #FAF8F5 0px,
    #EFE7DA 1.5px,
    #E2D5C3 3px
  );
  transform: rotateY(90deg);
  transform-origin: left center;
  box-shadow: inset -2px 0 6px rgba(0, 0, 0, 0.25), inset 2px 0 4px rgba(255, 255, 255, 0.4);
  border-radius: 0 2px 2px 0;
}

/* 3D Pages Bottom Edge */
.book-pages-bottom {
  position: absolute;
  bottom: -23px;
  left: 3px;
  width: calc(100% - 6px);
  height: 24px;
  background: repeating-linear-gradient(
    0deg,
    #FAF8F5 0px,
    #EFE7DA 1.5px,
    #E2D5C3 3px
  );
  transform: rotateX(-90deg);
  transform-origin: top center;
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.3);
}

/* 3D Card Miniature Preview in Catalog */
.card-book-3d {
  position: relative;
  display: block;
  border-radius: 2px 8px 8px 2px;
  overflow: hidden;
  box-shadow: 
    10px 14px 22px -4px rgba(22, 19, 16, 0.28),
    2px 4px 10px rgba(22, 19, 16, 0.12);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.card-book-3d:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 
    14px 20px 28px -4px rgba(22, 19, 16, 0.36),
    3px 6px 14px rgba(22, 19, 16, 0.18);
}

.card-book-3d::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 100%;
  background: linear-gradient(90deg, 
    rgba(0,0,0,0.28) 0%, 
    rgba(255,255,255,0.2) 50%, 
    rgba(0,0,0,0.18) 100%);
  z-index: 5;
  pointer-events: none;
}

/* Custom Reading Theme Styles */
.theme-day {
  background-color: #FAF8F5 !important;
  color: #1F1D1A !important;
}

.theme-sepia {
  background-color: #F4ECD8 !important;
  color: #433422 !important;
  border-color: #DECDB3 !important;
}

.theme-sepia h1,
.theme-sepia h2,
.theme-sepia h3,
.theme-sepia h4,
.theme-sepia .text-graphite {
  color: #2C1F10 !important;
}

.theme-sepia .text-burgundy,
.theme-sepia span.text-burgundy {
  color: #7A281E !important;
}

.theme-sepia .text-graphite-muted,
.theme-sepia .text-graphite-light {
  color: #705D47 !important;
}

.theme-sepia .border-sand-dark,
.theme-sepia .border-sand-dark\/60 {
  border-color: #D4C39E !important;
}

.theme-sepia .chapter-body {
  color: #433422 !important;
}

.theme-sepia .chapter-body p {
  color: #433422 !important;
  line-height: 1.95;
}

.theme-sepia .lawyer-box {
  background-color: #EDE2C7 !important;
  border-color: #D4C39E !important;
  color: #433422 !important;
}

.theme-sepia-toolbar {
  background-color: rgba(237, 226, 199, 0.96) !important;
  border-color: #D4C39E !important;
}

/* ========================================================
   Refined Night Reading Theme (Typography & Contrast Engine)
   ======================================================== */
.theme-night {
  background-color: #161514 !important;
  color: #E2DDD5 !important;
  border-color: #2D2A26 !important;
}

/* Headings in Night Mode: bright, warm off-white (solves invisible black text) */
.theme-night h1,
.theme-night h2,
.theme-night h3,
.theme-night h4,
.theme-night h2.font-cormorant,
.theme-night h3.font-cormorant,
.theme-night .text-graphite {
  color: #F8F5EE !important;
  text-rendering: optimizeLegibility;
}

/* Overlines & Status Badges: rich warm gold (solves low-contrast dark red) */
.theme-night .text-burgundy,
.theme-night span.text-burgundy,
.theme-night div.text-burgundy {
  color: #D4AF37 !important;
}

/* Metadata & Reading Time: clean, legible warm silver */
.theme-night .text-graphite-muted,
.theme-night .text-graphite-light,
.theme-night .font-manrope {
  color: #A39E93 !important;
}

/* Dividers & horizontal lines in Night Mode */
.theme-night .border-sand-dark,
.theme-night .border-sand-dark\/60,
.theme-night .border-sand-dark\/40,
.theme-night .border-\[\#EADBCA\],
.theme-night .border-\[\#E5DAC8\],
.theme-night div.border-b,
.theme-night div.border-t {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Paragraphs & Chapter Body in Night Mode */
.theme-night .chapter-body {
  color: #E2DDD5 !important;
}

.theme-night .chapter-body p {
  color: #E2DDD5 !important;
  line-height: 1.95;
  margin-bottom: 1.4em;
  letter-spacing: 0.012em;
}

/* Emphasized Quotes and Climax Statements in Chapter */
.theme-night .chapter-body p.font-bold,
.theme-night .chapter-body .font-bold,
.theme-night .chapter-body p.text-burgundy,
.theme-night .chapter-body .text-burgundy {
  color: #E9D7A5 !important; /* Luminous soft gold for dramatic quotes */
  font-weight: 700;
}

.theme-night .lawyer-box {
  background-color: #242220 !important;
  border-color: #3D3934 !important;
  color: #D1CCC2 !important;
}

/* Night Mode Toolbar & Control Bar Adaptation */
.theme-night-toolbar {
  background-color: rgba(28, 26, 24, 0.96) !important;
  border-color: #35312C !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45) !important;
}

/* Dropcap for book chapters */
.chapter-body > p:first-of-type::first-letter {
  float: left;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 3.8em;
  line-height: 0.82;
  padding-right: 0.15em;
  padding-top: 0.08em;
  color: var(--color-burgundy);
  font-weight: 700;
}

.theme-night .chapter-body > p:first-of-type::first-letter {
  color: #D4AF37 !important;
  text-shadow: 0 2px 12px rgba(212, 175, 55, 0.25);
}

.theme-sepia .chapter-body > p:first-of-type::first-letter {
  color: #8C2D19 !important;
}
