/* ================================================
   UceBooks — Global Styles
   books.uceconsult.com
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,500;1,8..60,300&family=JetBrains+Mono:wght@400;500&display=swap');

/* ------------------------------------------------
   CSS Variables
   ------------------------------------------------ */
:root {
    --bg-primary:      #0F0E0C;
    --bg-secondary:    #161410;
    --bg-card:         #1C1A16;
    --bg-card-hover:   #222018;
    --bg-elevated:     #252218;

    --text-primary:    #E8E0D0;
    --text-secondary:  #A89880;
    --text-muted:      #6B5F50;
    --text-accent:     #D4A853;

    --accent-gold:     #D4A853;
    --accent-gold-dim: #8B6E35;
    --accent-green:    #4A7C59;
    --accent-red:      #8B3A3A;

    --border:          #2E2A22;
    --border-light:    #3A3528;

    --font-display:    'Playfair Display', Georgia, serif;
    --font-body:       'Source Serif 4', Georgia, serif;
    --font-mono:       'JetBrains Mono', monospace;

    --radius-sm:       4px;
    --radius-md:       8px;
    --radius-lg:       12px;

    --shadow-card:     0 4px 24px rgba(0,0,0,0.4);
    --shadow-elevated: 0 8px 40px rgba(0,0,0,0.6);

    --transition:      0.2s ease;
}

/* Light mode */
.theme-light {
    --bg-primary:      #F4F0E8;
    --bg-secondary:    #EDE8DE;
    --bg-card:         #FFFFFF;
    --bg-card-hover:   #F9F6EF;
    --bg-elevated:     #FFFFFF;
    --text-primary:    #1A1612;
    --text-secondary:  #5A4E3C;
    --text-muted:      #9A8870;
    --border:          #DDD5C4;
    --border-light:    #E8E0D0;
    --shadow-card:     0 2px 16px rgba(0,0,0,0.08);
}

/* Sepia mode */
.theme-sepia {
    --bg-primary:      #2A1F10;
    --bg-secondary:    #231A0D;
    --bg-card:         #2E2414;
    --bg-card-hover:   #342A18;
    --text-primary:    #E8D8B8;
    --text-secondary:  #B09870;
    --text-muted:      #7A6040;
    --border:          #3E3020;
}

/* ------------------------------------------------
   Reset & Base
   ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--accent-gold); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-body); }

/* ------------------------------------------------
   Layout
   ------------------------------------------------ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ------------------------------------------------
   Header / Navbar
   ------------------------------------------------ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 14, 12, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0;
}

.theme-light .site-header { background: rgba(244, 240, 232, 0.94); }

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 24px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-mark {
    width: 36px;
    height: 36px;
    background: var(--accent-gold);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: #0F0E0C;
    letter-spacing: -0.5px;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.logo-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-family: var(--font-mono);
    display: block;
    margin-top: -2px;
}

.header-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.header-search input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 8px 16px 8px 40px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    outline: none;
    transition: border-color var(--transition);
}

.header-search input:focus { border-color: var(--accent-gold-dim); }
.header-search input::placeholder { color: var(--text-muted); }

.header-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* ------------------------------------------------
   Hero / Page Title
   ------------------------------------------------ */
.page-hero {
    padding: 56px 0 40px;
    border-bottom: 1px solid var(--border);
}

.page-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

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

.page-hero p {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 480px;
}

/* ------------------------------------------------
   Filter Bar
   ------------------------------------------------ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 0;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}

.filter-label {
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-right: 4px;
}

.filter-pill {
    padding: 5px 14px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font-body);
    transition: all var(--transition);
    white-space: nowrap;
}

.filter-pill:hover, .filter-pill.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #0F0E0C;
}

/* ------------------------------------------------
   Section Title
   ------------------------------------------------ */
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 32px 0 20px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-title::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent-gold);
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
}

.section-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
}

/* ------------------------------------------------
   Book Grid
   ------------------------------------------------ */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding-bottom: 48px;
}

.book-card {
    cursor: pointer;
    group: true;
}

.book-cover-wrap {
    position: relative;
    aspect-ratio: 2/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book-card:hover .book-cover-wrap {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-elevated);
}

.book-cover-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity var(--transition);
}

.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
}

.book-cover-placeholder .book-initial {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-gold);
    line-height: 1;
}

.book-cover-placeholder .book-spine {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.4;
}

.book-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.book-card:hover .book-overlay { opacity: 1; }

.btn-read {
    background: var(--accent-gold);
    color: #0F0E0C;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all var(--transition);
}

.fav-btn.active, .fav-btn:hover { color: #E8563A; }

.book-info {
    padding: 10px 2px 0;
}

.book-info .book-title {
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-info .book-author {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.book-info .book-category-badge {
    display: inline-block;
    margin-top: 5px;
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* ------------------------------------------------
   Reading Progress Bar (in card)
   ------------------------------------------------ */
.reading-progress-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.reading-progress-fill {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* ------------------------------------------------
   Empty State
   ------------------------------------------------ */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state small { font-size: 0.85rem; }

/* ------------------------------------------------
   Footer
   ------------------------------------------------ */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
}

.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent-gold); }

/* ------------------------------------------------
   Responsive
   ------------------------------------------------ */
@media (max-width: 768px) {
    .header-search { display: none; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
    .page-hero { padding: 32px 0 24px; }
}

@media (max-width: 480px) {
    .container { padding: 0 16px; }
    .book-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}

/* ------------------------------------------------
   Loading Skeleton
   ------------------------------------------------ */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ------------------------------------------------
   Notification Toast
   ------------------------------------------------ */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: var(--shadow-elevated);
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
    max-width: 320px;
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

#toast.toast-success { border-left: 3px solid var(--accent-green); }
#toast.toast-error { border-left: 3px solid var(--accent-red); }
