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

:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-hover: #252525;
    --text: #e4e4e4;
    --text-muted: #888;
    --accent: #6c9fff;
    --border: #2a2a2a;
    --radius: 8px;
    --nav-height: 56px;
    --content-max: 1200px;

    color-scheme: dark;
}

html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
}

/* ---- View Transitions ---- */
@view-transition {
    navigation: auto;
}

::view-transition-old(content) {
    animation: fade-out 150ms ease;
}
::view-transition-new(content) {
    animation: fade-in 150ms ease;
}

@keyframes fade-out {
    to { opacity: 0; }
}
@keyframes fade-in {
    from { opacity: 0; }
}

/* ---- Nav ---- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--nav-height);
    padding: 0 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.nav-brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.nav-link {
    padding: 0.375rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: color 150ms, background 150ms;
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* ---- Content ---- */
.content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 1.5rem 1rem;
    view-transition-name: content;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ---- Search ---- */
.search-input {
    width: 100%;
    max-width: 280px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 150ms;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-muted);
}

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

@media (min-width: 640px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1.25rem;
    }
}

/* ---- Book Card ---- */
.book-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    transition: transform 150ms, box-shadow 150ms;
}

.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.book-cover {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    background: var(--bg-hover);
}

.book-cover--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-muted);
}

.book-info {
    padding: 0.5rem 0.625rem;
}

.book-title {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.book-lang {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: rgba(108, 159, 255, 0.1);
    border-radius: 4px;
}

/* ---- Empty State ---- */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* ---- Button ---- */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bg);
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
    transition: opacity 150ms;
}

.btn:hover {
    opacity: 0.85;
}

/* ---- HTMX indicator ---- */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
