@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    /* Warm paper base — editorial / reading-room palette (not flat white) */
    --bg-color: #f4f1ea;
    --bg-paper-mid: #ebe6dc;
    --bg-elevated: rgba(255, 254, 250, 0.92);
    --ink-color: #1A1A1A;
    --muted-color: #525252;
    --accent-color: #5A5A40;
    --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
    --font-serif: "Playfair Display", serif;
}

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

body {
    color: var(--ink-color);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Stack (first = top): paper grain + vignettes over a soft wash, over classical library art */
    background-color: var(--bg-color);
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(58, 52, 40, 0.014) 2px,
            rgba(58, 52, 40, 0.014) 3px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(58, 52, 40, 0.01) 2px,
            rgba(58, 52, 40, 0.01) 4px
        ),
        radial-gradient(ellipse 140% 90% at 50% -25%, rgba(90, 90, 64, 0.03), transparent 58%),
        radial-gradient(ellipse 85% 70% at 110% 85%, rgba(120, 98, 72, 0.02), transparent 52%),
        radial-gradient(ellipse 75% 60% at -15% 90%, rgba(160, 140, 108, 0.015), transparent 48%),
        linear-gradient(180deg, rgba(255, 252, 245, 0.14) 0%, transparent 42%, rgba(235, 228, 214, 0.09) 100%),
        linear-gradient(
            180deg,
            rgba(244, 241, 234, 0.25) 0%,
            rgba(244, 241, 234, 0.1) 40%,
            rgba(244, 241, 234, 0.07) 68%,
            rgba(244, 241, 234, 0.16) 100%
        ),
        url("/assets/images/library-reading-room-bg.webp");
    background-repeat: repeat, repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
    background-size: auto, auto, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, cover;
    background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, center bottom;
    background-attachment: scroll, scroll, scroll, scroll, scroll, scroll, scroll, fixed;
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll, scroll, scroll, scroll, scroll, scroll, scroll, scroll;
    }
}

@media (prefers-reduced-motion: reduce) {
    body {
        background-attachment: scroll, scroll, scroll, scroll, scroll, scroll, scroll, scroll;
    }
}

h1, h2, h3, h4 {
    font-family: var(--font-serif);
}

.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- NAVBAR (Glass Effect) — only the top bar; do not style <header> inside <main> (e.g. catalog sections) --- */
header.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(244, 241, 234, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(90, 90, 64, 0.1);
    padding: 16px 0;
}

header.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 700;
    color: var(--ink-color);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Language dropdown (compact; opens on hover, focus-within, or tap) */
.lang-menu {
    position: relative;
    flex-shrink: 0;
}

.lang-menu__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-color);
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(90, 90, 64, 0.18);
    border-radius: 999px;
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.lang-menu__trigger:hover,
.lang-menu:focus-within .lang-menu__trigger,
.lang-menu.lang-menu--open .lang-menu__trigger {
    background: rgba(255, 254, 250, 0.92);
    border-color: rgba(90, 90, 64, 0.28);
}

.lang-menu__trigger-flag,
.lang-menu__opt-flag {
    font-size: 1.05em;
    line-height: 1;
}

.lang-menu__chevron {
    flex-shrink: 0;
    opacity: 0.65;
    transition: transform 0.2s ease;
}

.lang-menu:hover .lang-menu__chevron,
.lang-menu:focus-within .lang-menu__chevron,
.lang-menu.lang-menu--open .lang-menu__chevron {
    transform: rotate(180deg);
}

.lang-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 6px;
    list-style: none;
    min-width: 12.5rem;
    background: var(--bg-elevated);
    border: 1px solid rgba(90, 90, 64, 0.14);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(26, 26, 26, 0.12);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.lang-menu:hover .lang-menu__panel,
.lang-menu:focus-within .lang-menu__panel,
.lang-menu.lang-menu--open .lang-menu__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-menu__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink-color);
    font-size: 13px;
    transition: background 0.12s ease;
}

.lang-menu__option:hover,
.lang-menu__option:focus-visible {
    background: rgba(90, 90, 64, 0.08);
    outline: none;
}

.lang-menu__option.is-active {
    background: rgba(26, 26, 26, 0.06);
    font-weight: 600;
}

@media (max-width: 980px) {
    .lang-menu__trigger-label {
        max-width: 7.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--ink-color);
    color: var(--bg-color);
}
.btn-primary:hover {
    opacity: 0.9;
}

.btn-outline {
    border-color: var(--ink-color);
    color: var(--ink-color);
    background: transparent;
}
.btn-outline:hover {
    background-color: var(--ink-color);
    color: var(--bg-color);
}

.btn-ghost {
    background: transparent;
    color: var(--ink-color);
    padding: 8px 12px;
}
.btn-ghost:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.btn-danger {
    color: #ef4444;
}
.btn-danger:hover {
    background-color: #fef2f2;
}

/* --- PAGE LAYOUT --- */
main {
    flex-grow: 1;
    padding: 40px 0;
}

.page-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

/* --- CATALOG (index): full-width search, then filters --- */
.catalog-search-panel {
    margin-bottom: 1.75rem;
}

/* Small caps line above search — text only, no panel / white block */
.catalog-search-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-color);
    margin-bottom: 10px;
    background: none;
    border: none;
    padding: 0;
}

.catalog-page .catalog-search-field {
    position: relative;
    width: 100%;
    max-width: none;
}

.catalog-page .catalog-search-field input {
    width: 100%;
    border-radius: 12px;
    /* No filled “card”: outline only so the library background painting stays visible */
    border: 1px solid rgba(90, 90, 64, 0.32);
    background: transparent;
    padding: 14px 18px 14px 48px;
    font-size: 15px;
    line-height: 1.35;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    font-family: var(--font-sans);
    box-shadow: none;
}

.catalog-page .catalog-search-field input::placeholder {
    color: rgba(82, 82, 82, 0.88);
}

.catalog-page .catalog-search-field input:hover {
    border-color: rgba(90, 90, 64, 0.22);
}

.catalog-page .catalog-search-field input:focus {
    border-color: var(--accent-color);
    background: rgba(255, 254, 250, 0.14);
    box-shadow: none;
}

.catalog-page .catalog-search-field .search-icon {
    left: 16px;
    opacity: 0.85;
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
}

.page-title h1 {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.page-title p {
    color: var(--muted-color);
    font-size: 18px;
}

/* --- INPUTS & FORMS --- */
.form-group {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-color);
}

.form-input, .form-textarea {
    width: 100%;
    border-radius: 6px;
    border: 1px solid rgba(26, 26, 26, 0.2);
    padding: 12px 16px;
    font-size: 14px;
    font-family: var(--font-sans);
    outline: none;
    background: var(--bg-elevated);
    transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus {
    border-color: var(--ink-color);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

select.form-input.book-category-select[size] {
    height: auto;
    min-height: 2.75rem;
    padding: 8px 12px;
    line-height: 1.35;
}

.error-text {
    color: #ef4444;
    font-size: 13px;
    margin-top: 4px;
}

/* --- GRID & CARDS --- */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    column-gap: 24px;
    row-gap: 40px;
}

@media (min-width: 768px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

button.card-link {
    width: 100%;
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.card-image-wrap {
    aspect-ratio: 2 / 3;
    background-color: rgba(232, 226, 214, 0.9);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-link:hover .card-image-wrap {
    transform: translateY(-8px);
}

.card-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 4px;
}
.card-link:hover .card-title {
    text-decoration: underline;
}

.card-subtitle {
    font-size: 14px;
    color: var(--muted-color);
}

/* --- AUTH PAGE --- */
.auth-wrapper {
    display: flex;
    min-height: calc(100vh - 80px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-form {
    width: 100%;
    max-width: 400px;
}

/* --- SEARCH CONTAINER --- */
.search-container {
    position: relative;
    width: 100%;
    max-width: 256px;
}

.search-container input {
    width: 100%;
    border-radius: 9999px;
    border: 1px solid rgba(90, 90, 64, 0.14);
    background-color: var(--bg-elevated);
    padding: 10px 16px 10px 40px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font-sans);
}

.search-container input:focus {
    border-color: rgba(26, 26, 26, 0.3);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-color);
}

/* --- FOOTER --- */
.site-footer {
    margin-top: auto;
    border-top: 1px solid rgba(90, 90, 64, 0.12);
    background: linear-gradient(180deg, rgba(235, 228, 214, 0.35), rgba(244, 241, 234, 0.65));
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.5);
}

.site-footer__main {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) repeat(3, minmax(0, 0.85fr)) minmax(0, 1.2fr);
    gap: 2rem 1.75rem;
    padding: 3rem 20px 2.25rem;
    align-items: start;
}

@media (max-width: 960px) {
    .site-footer__main {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .site-footer__main {
        grid-template-columns: 1fr;
        padding: 2.25rem 20px 1.75rem;
        gap: 1.75rem;
    }
}

.site-footer__brand {
    padding-right: 0.5rem;
}

.site-footer__logo {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink-color);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.site-footer__logo:hover {
    color: var(--accent-color);
}

.site-footer__tagline {
    margin-top: 0.65rem;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--muted-color);
    max-width: 22rem;
}

.site-footer__made {
    margin-top: 0.85rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--muted-color);
    opacity: 0.92;
    max-width: 22rem;
}

.site-footer__heading {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink-color);
    margin-bottom: 0.75rem;
    letter-spacing: 0.01em;
}

.site-footer__links,
.site-footer__checks {
    list-style: none;
}

.site-footer__links li + li,
.site-footer__checks li + li {
    margin-top: 0.45rem;
}

.site-footer__links a {
    color: var(--muted-color);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.15s ease;
}

.site-footer__links a:hover {
    color: var(--accent-color);
}

.site-footer__checks li {
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--muted-color);
    padding-left: 0.85rem;
    position: relative;
}

.site-footer__checks li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.45em;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-color);
    opacity: 0.65;
}

.site-footer__blurb {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--muted-color);
    max-width: 28rem;
}

.site-footer__col--wide {
    min-width: 0;
}

.site-footer__bottom {
    border-top: 1px solid rgba(90, 90, 64, 0.08);
    background: rgba(255, 254, 250, 0.45);
    padding: 1rem 0;
}

.site-footer__copyright {
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted-color);
}
