/* =============================================
   Эхо забытых снов — Global Styles
   ============================================= */

/* --- Stars background --- */
.stars {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1px 1px at 10% 20%, rgba(196, 181, 253, 0.4) 50%, transparent 100%),
        radial-gradient(1px 1px at 30% 65%, rgba(196, 181, 253, 0.3) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at 50% 10%, rgba(196, 181, 253, 0.5) 50%, transparent 100%),
        radial-gradient(1px 1px at 70% 40%, rgba(196, 181, 253, 0.35) 50%, transparent 100%),
        radial-gradient(1px 1px at 90% 75%, rgba(196, 181, 253, 0.4) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at 15% 85%, rgba(167, 139, 250, 0.3) 50%, transparent 100%),
        radial-gradient(1px 1px at 45% 50%, rgba(167, 139, 250, 0.45) 50%, transparent 100%),
        radial-gradient(1px 1px at 80% 15%, rgba(196, 181, 253, 0.3) 50%, transparent 100%),
        radial-gradient(1px 1px at 60% 90%, rgba(167, 139, 250, 0.35) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at 25% 35%, rgba(196, 181, 253, 0.5) 50%, transparent 100%),
        radial-gradient(1px 1px at 5% 55%, rgba(167, 139, 250, 0.4) 50%, transparent 100%),
        radial-gradient(1px 1px at 95% 5%, rgba(196, 181, 253, 0.3) 50%, transparent 100%),
        radial-gradient(1px 1px at 40% 78%, rgba(196, 181, 253, 0.35) 50%, transparent 100%),
        radial-gradient(1.5px 1.5px at 75% 62%, rgba(167, 139, 250, 0.4) 50%, transparent 100%),
        radial-gradient(1px 1px at 55% 30%, rgba(196, 181, 253, 0.3) 50%, transparent 100%);
    animation: twinkle 8s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* --- Glass navigation --- */
.glass-nav {
    background: rgba(7, 0, 23, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulseGlow { 0%, 100% { box-shadow: 0 0 4px 1px rgba(107, 47, 255, 0.4); } 50% { box-shadow: 0 0 12px 4px rgba(107, 47, 255, 0.7); } }
@keyframes scrollDot { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(8px); opacity: 0; } }

.animate-fade-in { animation: fadeIn 1s ease-out forwards; }
.animate-fade-in-up { opacity: 0; animation: fadeInUp 1s ease-out forwards; }
.animate-pulse-glow { animation: pulseGlow 2s ease-in-out infinite; }
.animate-scroll-dot { animation: scrollDot 1.5s ease-in-out infinite; }

/* --- Cover card (index) --- */
.cover-card { transition: box-shadow 0.5s ease, transform 0.5s ease; }
.cover-card:hover { box-shadow: 0 0 40px 10px rgba(107, 47, 255, 0.2); }

/* --- Description card (index) --- */
.description-card { transition: border-color 0.4s ease, box-shadow 0.4s ease; }
.description-card:hover { border-color: rgba(107, 47, 255, 0.2); box-shadow: 0 0 30px rgba(107, 47, 255, 0.08); }

/* --- Tag chips (index) --- */
.tag-chip {
    display: inline-flex; align-items: center; padding: 0.4rem 1rem; border-radius: 9999px;
    background: rgba(107, 47, 255, 0.1); border: 1px solid rgba(107, 47, 255, 0.15);
    color: #c4b5fd; font-size: 0.8rem; font-weight: 500; letter-spacing: 0.025em;
    transition: all 0.3s ease;
}
.tag-chip:hover { background: rgba(107, 47, 255, 0.2); border-color: rgba(107, 47, 255, 0.3); color: #ddd6fe; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(107, 47, 255, 0.15); }

/* --- Chapter links (index) --- */
.chapter-link {
    display: flex; align-items: center; gap: 1rem; padding: 0.85rem 1.25rem; border-radius: 12px;
    background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(255, 255, 255, 0.04);
    text-decoration: none; color: #d1d5db; transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; overflow: hidden;
}
.chapter-link::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(107, 47, 255, 0.08), transparent); opacity: 0; transition: opacity 0.35s ease; }
.chapter-link:hover::before { opacity: 1; }
.chapter-link:hover { border-color: rgba(107, 47, 255, 0.2); color: #fff; transform: translateX(4px); box-shadow: 0 2px 16px rgba(107, 47, 255, 0.08); }
.chapter-number { font-family: 'Inter', sans-serif; font-size: 0.75rem; font-weight: 600; color: #7c3aed; min-width: 2rem; opacity: 0.7; transition: opacity 0.3s ease; }
.chapter-link:hover .chapter-number { opacity: 1; }
.chapter-title { font-family: 'Cormorant Garamond', serif; font-size: 1.15rem; font-weight: 600; flex: 1; transition: color 0.3s ease; }
.chapter-link:hover .chapter-title { color: #e9d5ff; }
.chapter-epilogue { font-size: 0.7rem; color: #7c3aed; opacity: 0.6; margin-left: auto; white-space: nowrap; }
.chapter-arrow { font-size: 1.1rem; color: #7c3aed; opacity: 0; transform: translateX(-8px); transition: all 0.35s ease; }
.chapter-link:hover .chapter-arrow { opacity: 1; transform: translateX(0); }

@media (max-width: 640px) {
    .chapter-link { padding: 0.7rem 1rem; gap: 0.75rem; }
    .chapter-title { font-size: 1rem; }
    .chapter-epilogue { display: none; }
    .chapter-arrow { opacity: 0.5; transform: translateX(0); }
}

/* =============================================
   Чтение главы (Reading Layout)
   ============================================= */

/* Drop Cap */
.drop-cap::first-letter {
    float: left;
    font-family: 'Cormorant Garamond', serif;
    font-size: 3.5rem;
    line-height: 0.75;
    padding-right: 0.4rem;
    padding-top: 0.15rem;
    color: #8b5cf6;
    font-weight: 700;
}

@media (max-width: 640px) {
    .drop-cap::first-letter { font-size: 2.5rem; }
}

/* Dialogue / Quote Styling */
.dialogue {
    padding-left: 1.25rem;
    border-left: 3px solid rgba(107, 47, 255, 0.25);
    font-style: italic;
    color: #c4b5fd;
    position: relative;
}
.dialogue::before {
    content: '\201C';
    position: absolute;
    left: -1.5rem;
    top: -0.5rem;
    font-size: 2rem;
    color: rgba(107, 47, 255, 0.15);
    font-family: 'Cormorant Garamond', serif;
}

/* Scroll Reveal for Reading */
.scroll-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   Global UI Tweaks
   ============================================= */
html { scroll-behavior: smooth; }

::selection { background: rgba(107, 47, 255, 0.35); color: #ede9fe; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #070017; }
::-webkit-scrollbar-thumb { background: rgba(107, 47, 255, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(107, 47, 255, 0.5); }

/* Print Optimization */
@media print {
    .stars, .glass-nav, #progress-bar, footer { display: none !important; }
    body { background: #fff; color: #111; }
    main { padding-top: 0; }
    .drop-cap::first-letter { color: #111; }
    .dialogue { border-left-color: #ccc; }
}
