:root {
    --bg-color: #0c0b0a;
    --card-bg: rgba(255, 255, 255, 0.03);
    --accent-gold: #d4af37;
    --text-white: #f5f5f5;
    --text-dim: rgba(245, 245, 245, 0.6);
    --paper-white: #fdfaf0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-white);
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
    line-height: 1.6;
}

.grain-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: 0.05;
    z-index: 1; /* Was 9999, reduced to fix caret issues */
    background-image: url("https://www.transparenttextures.com/patterns/paper-fibers.png");
}

/* Unified Premium Navbar */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 15px 0;
    z-index: 1000;
    backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    background: rgba(12, 11, 10, 0.8);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    text-decoration: none;
    color: var(--text-white);
    font-weight: 700;
    letter-spacing: 1px;
}

.logo span {
    color: var(--accent-gold);
}

.nav-links {
    display: flex;
    gap: 25px;
    align-items: center;
}

.nav-item {
    text-decoration: none;
    color: var(--text-dim);
    font-size: 15px;
    font-weight: 600;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover, .nav-item.active {
    color: var(--accent-gold);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(212, 175, 55, 0.2);
}

/* Profile Dropdown Component */
.user-profile-nav {
    position: relative;
}

.profile-trigger {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(212, 175, 55, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--accent-gold);
    transition: 0.3s;
    padding: 0;
}

.profile-trigger:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--accent-gold);
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 200px;
    background: #151311;
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1100;
    animation: authFadeIn 0.3s ease-out;
}

.nav-dropdown.show {
    display: flex;
}

#logged-in-menu {
    display: flex;
    align-items: center;
    gap: 25px;
}

.dropdown-user-info {
    padding: 15px 20px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 13px;
    color: var(--accent-gold);
    font-weight: 600;
}

.dropdown-link {
    padding: 12px 20px;
    color: var(--text-dim) !important;
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

.dropdown-link:hover {
    background: rgba(212, 175, 55, 0.05);
    color: #fff !important;
}

.dropdown-link.logout {
    color: #ff6464 !important;
    border-top: 1px solid rgba(255,255,255,0.05);
}

@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 4px;
    border-radius: 30px;
    border: 1px solid rgba(212, 175, 55, 0.1);
    margin-right: 15px;
}

.lang-btn {
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.3s;
    text-transform: uppercase;
}

.lang-btn:hover {
    color: var(--accent-gold);
}

.lang-btn.active {
    background: var(--accent-gold);
    color: #000;
}

@media (max-width: 768px) {
    .nav-container { padding: 0 20px; }
    .nav-item span { display: none; } /* Hide text on mobile icons if needed */
}

/* Hero */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 40px 0 40px;
    gap: 60px;
}

.hero-content {
    flex: 1;
}

.hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: 64px;
    line-height: 1.1;
    margin-bottom: 25px;
}

.hero h1 .italic {
    font-style: italic;
    color: var(--accent-gold);
}

.hero p {
    font-size: 18px;
    color: var(--text-dim);
    margin-bottom: 40px;
    max-width: 500px;
}

.hero-btns {
    display: flex;
    gap: 20px;
}

.btn-hero {
    background: var(--accent-gold);
    color: #000;
    padding: 18px 40px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    transition: 0.3s;
}

.btn-hero:hover {
    background: #fff;
    transform: scale(1.05);
}

.btn-outline {
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 18px 40px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: 0.3s;
}

.btn-outline:hover {
    background: rgba(255,255,255,0.05);
}

.hero-visual {
    flex: 1;
    display: flex;
    justify-content: center;
}

.image-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.image-wrapper img {
    width: 100%;
    border-radius: 20px;
    box-shadow: 0 40px 100px rgba(0,0,0,0.8);
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}

.floating-stat {
    position: absolute;
    bottom: 40px;
    right: -20px;
    background: var(--accent-gold);
    color: #000;
    padding: 20px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    animation: floating 3s ease-in-out infinite;
}

.stat-num {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
}

.stat-txt {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Discover / Published Books */
.discover-page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 120px 40px 60px;
}
.discover-page-container .discover-section {
    padding: 0; 
}
.discover-header {
    text-align: center;
    margin-bottom: 50px;
}
.discover-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 48px;
    margin-bottom: 10px;
    background: linear-gradient(to right, #fff, var(--accent-gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.discover-header p {
    color: rgba(255,255,255,0.6);
    font-size: 18px;
}

/* Category Grouping styles */
.category-group {
    margin-bottom: 60px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.category-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    color: var(--accent-gold);
    white-space: nowrap;
}

.category-line {
    height: 1px;
    flex-grow: 1;
    background: linear-gradient(to right, rgba(212, 175, 55, 0.3), transparent);
}

/* Responsive Slider/Grid Logic */
.slider-container {
    position: relative;
    width: 100%;
    margin: 40px 0;
}

.slider-wrapper {
    width: 100%;
    overflow: hidden; /* Clips the inner content */
    padding: 20px 0;
}

.discover-grid.slider-mode {
    display: flex;
    gap: 30px;
    width: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.slider-mode .discover-card {
    flex: 0 0 calc((100% - 90px) / 4); /* 4 items on desktop */
    min-width: 220px;
}

@media (max-width: 1024px) {
    .slider-mode .discover-card {
        flex: 0 0 calc((100% - 30px) / 2); /* 2 items on tablet */
    }
}

@media (max-width: 600px) {
    .slider-mode .discover-card {
        flex: 0 0 100%; /* 1 item on mobile */
    }
}

/* Base Slider Buttons */
.slider-btn {
    background: rgba(212, 175, 55, 0.15);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--accent-gold);
    width: 54px;
    height: 54px;
    border-radius: 50%;
    cursor: pointer;
    display: flex !important; /* Always show if JS doesn't hide */
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.slider-btn.prev { left: -70px; }
.slider-btn.next { right: -70px; }

@media (max-width: 1350px) {
    .slider-btn.prev { left: 10px; }
    .slider-btn.next { right: 10px; }
}

.slider-btn:hover {
    background: var(--accent-gold);
    color: #000;
    transform: translateY(-50%) scale(1.1);
}

/* Mobile Slider Overrides - Removed previous display:none mode */
@media (max-width: 1024px) {
    .discover-section .slider-container {
        padding: 0;
        overflow: visible; /* Allow buttons to float better */
    }
}

@keyframes sliderFade {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.slider-btn.prev:hover { transform: scale(1.15) rotate(-5deg); }

.slider-btn:active {
    transform: scale(0.95);
}

.discover-section {
    padding: 60px 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.discover-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: 0.4s;
    cursor: pointer;
}

.discover-card:hover {
    transform: translateY(-10px);
    border-color: var(--accent-gold);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.discover-card-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    overflow: hidden;
    border-radius: 15px;
}

.discover-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.5s;
    opacity: 0.7;
}

.discover-card:hover .discover-cover {
    opacity: 0.9;
    transform: scale(1.05);
}

.discover-info {
    position: absolute;
    bottom: 0; 
    left: 0; 
    width: 100%;
    padding: 40px 20px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 50%, transparent 100%);
    z-index: 2;
    transition: 0.3s;
}

.discover-card:hover .discover-info {
    padding-bottom: 30px;
    background: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0.7) 60%, transparent 100%);
}

.discover-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.view-count-badge {
    color: var(--accent-gold);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0.8;
}

.discover-category {
    background: var(--accent-gold);
    color: #000;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    display: inline-block;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.3);
}

.discover-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.discover-author {
    font-size: 13px;
    color: var(--accent-gold);
    opacity: 0.9;
}

/* Features */
.features {
    padding: 60px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    margin-bottom: 80px;
}

.section-title h2 {
    font-family: 'Playfair Display', serif;
    font-size: 42px;
    margin-bottom: 20px;
}

.title-line {
    width: 80px;
    height: 3px;
    background: var(--accent-gold);
    margin: 0 auto;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.feature-card {
    background: var(--card-bg);
    padding: 50px 40px;
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: 0.4s;
    text-align: center;
}

.feature-card:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-10px);
    border-color: var(--accent-gold);
}

.feature-icon {
    font-size: 40px;
    margin-bottom: 25px;
    display: block;
}

.feature-card h3 {
    font-size: 22px;
    margin-bottom: 15px;
}

.feature-card p {
    color: var(--text-dim);
    font-size: 15px;
}

/* CTA */
.cta-section {
    padding: 100px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.cta-box {
    background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
    padding: 80px 40px;
    border-radius: 40px;
    text-align: center;
    color: #000;
}

.cta-box h2 {
    font-family: 'Playfair Display', serif;
    font-size: 48px;
    margin-bottom: 20px;
}

.cta-box p {
    font-size: 18px;
    margin-bottom: 40px;
    opacity: 0.8;
}

.btn-hero.large {
    background: #000;
    color: var(--accent-gold);
}

.btn-hero.large:hover {
    background: #222;
    color: #fff;
}

/* Footer */
footer {
    padding: 60px 0;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.05);
    color: var(--text-dim);
    font-size: 14px;
}

/* Animations */
@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.fade-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 1s forwards;
}

.fade-in {
    opacity: 0;
    animation: fadeIn 1.5s forwards;
}

@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* Page Transition Overlay */
#page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#page-transition.active {
    opacity: 1;
    pointer-events: all;
}

#page-transition.hidden {
    opacity: 0;
}

.transition-logo {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    color: var(--accent-gold);
    transform: scale(0.8);
    opacity: 0;
    transition: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#page-transition.active .transition-logo {
    transform: scale(1);
    opacity: 1;
}

@keyframes contentFadeOut {
    to { opacity: 0; transform: scale(1.05); filter: blur(10px); }
}

.page-exit {
    animation: contentFadeOut 0.6s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile Menu Button */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background: var(--text-white);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile */
@media (max-width: 900px) {
    .menu-toggle {
        display: flex;
    }

    .nav-container {
        padding: 0 20px;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        background: #0c0b0a;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 35px;
        transform: translateX(100%);
        transition: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        backdrop-filter: blur(20px);
        background: rgba(12, 11, 10, 0.98);
    }

    .nav-links.active {
        transform: translateX(0);
    }

    /* Menu Open State (X Icon) */
    .menu-toggle.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
        background: var(--accent-gold);
    }
    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .menu-toggle.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
        background: var(--accent-gold);
    }

    .nav-item {
        font-size: 18px;
    }

    .nav-item span {
        display: inline; /* Show text on mobile menu */
    }

    #logged-in-menu {
        flex-direction: column !important;
        width: 100%;
        align-items: center;
        gap: 30px;
    }

    .user-profile-nav {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        position: relative;
    }

    .nav-dropdown {
        position: static;
        margin-top: 15px;
        width: 240px;
        max-width: 90vw;
        border-radius: 14px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
        border: 1px solid rgba(212, 175, 55, 0.25);
    }

    .hero {
        flex-direction: column;
        padding-top: 140px;
        text-align: center;
        gap: 40px;
    }

    .hero h1 {
        font-size: 38px;
        margin-bottom: 20px;
    }

    .hero p {
        font-size: 16px;
        margin: 0 auto 30px;
        padding: 0 20px;
    }

    .hero-btns {
        flex-direction: column;
        gap: 15px;
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .btn-hero, .btn-outline {
        width: 100%;
        padding: 15px 30px;
        font-size: 15px;
    }

    .image-wrapper {
        max-width: 100%;
    }

    .floating-stat {
        bottom: 20px;
        right: 10px;
        padding: 12px;
    }

    .stat-num { font-size: 24px; }

    .discover-section { padding: 60px 20px; }
    .section-title h2 { font-size: 32px; }
    .feature-grid { grid-template-columns: 1fr; gap: 20px; }
    .feature-card { padding: 35px 25px; }
    .cta-section { padding: 40px 20px; }
    .cta-box { padding: 50px 25px; border-radius: 30px; }
    .cta-box h2 { font-size: 30px; }
    .cta-box p { font-size: 15px; }

    .modal-content {
        padding: 40px 25px;
        width: 95%;
        border-radius: 20px;
    }

    .auth-tabs { gap: 15px; margin-bottom: 25px; }
    .tab-btn { font-size: 16px; }

    .discover-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
    
    .discover-card-inner {
        border-radius: 12px;
    }
    
    .discover-title {
        font-size: 15px;
    }
    
    .category-header { gap: 10px; margin-bottom: 20px; }
    .category-header h3 { font-size: 20px; }
    .category-group { margin-bottom: 40px; }
    
    .nav-container { height: 60px; }
    .logo { font-size: 20px; }
}

/* Modal Styling Improvements */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
}

.modal.open {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: #121110;
    width: 100%;
    max-width: 450px;
    padding: 50px 40px;
    border-radius: 30px;
    border: 1px solid rgba(212, 175, 55, 0.15);
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
}

.modal.open .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 20px; right: 20px;
    background: rgba(255,255,255,0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: normal;
}

.modal-close:hover { 
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-gold); 
}

.auth-tabs {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tab-btn {
    background: none; border: none;
    color: var(--text-dim);
    font-size: 18px;
    font-weight: 600;
    padding-bottom: 15px;
    cursor: pointer;
    position: relative;
    transition: 0.3s;
}

.tab-btn.active { color: var(--accent-gold); }
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0;
    width: 100%; height: 2px;
    background: var(--accent-gold);
}

.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.4s forwards; }

.input-group { margin-bottom: 25px; text-align: left; }
.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group input, .input-group select {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15px 20px;
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    transition: 0.3s;
    appearance: none;
    -webkit-appearance: none;
}

.input-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
}

.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.1);
}

.full-width { width: 100%; }
@media (max-width: 500px) {
    .modal-content {
        height: 100%;
        max-width: none;
        border-radius: 0;
        padding-top: 100px;
    }

    .modal-close {
        top: 40px;
        right: 20px;
    }
}
