/* ===== V4 Modern & Concise Design ===== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&family=Fraunces:opsz,wght@9..144,300;9..144,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Gray Palette (Tailwind-like) */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --gray-950: #030712;
    /* Deepest black */

    /* Pink Palette (Flow Studio Inspiration) */
    --pink-400: #f472b6;
    --pink-500: #ec4899;
    --pink-500-20: rgba(236, 72, 153, 0.2);
    --pink-glow: rgba(236, 72, 153, 0.15);

    /* Semantic */
    --bg-main: var(--gray-950);
    --bg-card: rgba(255, 255, 255, 0.03);
    /* Extremely subtle */
    --bg-pill: rgba(17, 24, 39, 0.7);
    /* Floating Pill BG */

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-highlight: rgba(255, 255, 255, 0.12);

    --text-primary: var(--gray-50);
    --text-secondary: var(--gray-400);
    --text-muted: var(--gray-600);

    --font-display: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-serif: 'Fraunces', serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-pill: 9999px;
    --radius-lg: 16px;
    --radius-md: 12px;

    --transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
    /* Fast out, slow in */
}

:root[data-theme="light"] {
    --bg-main: #ffffff;
    --bg-card: rgba(0, 0, 0, 0.02);
    --bg-pill: rgba(255, 255, 255, 0.8);

    --border-subtle: #e5e7eb;
    /* Gray 200 */
    --border-highlight: #d1d5db;
    /* Gray 300 */

    --text-primary: #111827;
    /* Gray 900 */
    --text-secondary: #4b5563;
    /* Gray 600 */
    --text-muted: #9ca3af;
    /* Gray 400 */

    --pink-500-20: rgba(236, 72, 153, 0.1);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Floating Pill Navbar ===== */
.navbar-pill {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-pill);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-pill);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 90vw;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--pink-400);
    background: rgba(236, 72, 153, 0.1);
}

.nav-item svg {
    stroke-width: 2px;
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 4px;
}

/* ===== Spotlight Effect ===== */
.spotlight-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.spotlight-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(800px circle at var(--mouse-x, 0px) var(--mouse-y, 0px),
            rgba(255, 255, 255, 0.06),
            transparent 40%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 2;
}

.spotlight-card:hover::before {
    opacity: 1;
}

.spotlight-card:hover {
    border-color: var(--border-highlight);
}

/* ===== Layout ===== */
.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 140px 24px 60px;
}

.section-header {
    margin-bottom: 40px;
    animation: slideUp 0.6s ease backwards;
}

.section-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    background: linear-gradient(to right, #fff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ===== Search Overlay (Command Palette Style) ===== */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.search-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.search-box {
    width: 600px;
    max-width: 90vw;
    background: var(--gray-900);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.search-overlay.visible .search-box {
    transform: scale(1);
}

.search-input-wrap {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.search-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-body);
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.1s;
}

.search-item:hover,
.search-item.focus {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* ===== Book Grid ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.book-card {
    height: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    text-decoration: none;
}

.book-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.4;
}

.book-author {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: auto;
}

.book-meta {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.count-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ===== Detail Page ===== */
.detail-container {
    max-width: 680px;
    /* Reading optimal width */
    margin: 0 auto;
    padding: 140px 24px 100px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 32px;
    transition: color 0.2s;
}

.back-btn:hover {
    color: var(--pink-400);
}

.detail-header {
    text-align: center;
    margin-bottom: 60px;
    animation: slideUp 0.6s ease;
}

.detail-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 12px;
    background: linear-gradient(to bottom, #fff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.detail-meta {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    gap: 20px;
}

.note-item {
    position: relative;
    margin-bottom: 40px;
    padding-left: 24px;
    border-left: 2px solid var(--border-subtle);
    transition: all 0.3s;
    animation: slideUp 0.5s ease backwards;
}

.note-item:hover {
    border-left-color: var(--pink-400);
}

.note-content {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--gray-200);
    margin-bottom: 12px;
}

.note-user {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--gray-400);
    margin-top: 12px;
    font-family: var(--font-body);
    display: block;
}

.note-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    /* Align date to right */
}

mark {
    background: var(--pink-500-20);
    color: var(--pink-400);
    border-radius: 2px;
    padding: 0 2px;
}

/* Animations & Utils */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-800);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-700);
}

/* Sort Btn */
.sort-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

@media (max-width: 768px) {
    .navbar-pill {
        bottom: 24px;
        top: auto;
        max-width: 95vw;
    }

    /* Bottom nav on mobile */
    .container {
        padding-top: 60px;
    }

    .detail-container {
        padding-top: 60px;
    }
}