:root {
    --bg-color: #FFD8C2;
    --accent-color: #5C2E5C;
    --button-color: #8C95FF;
    --button-hover: #6B74E0;
    --text-color: #000000;
    --card-bg: rgba(255, 255, 255, 0.65);
    --card-hover: rgba(255, 255, 255, 0.85);
    --poem-bg: rgba(255, 216, 194, 0.5);

    --font-heading: 'Playfair Display', serif;
    --font-body: 'PT Serif', serif;
    --font-poem: 'Lora', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
    font-family: var(--font-body);
    background: linear-gradient(180deg, #FFE5D4 0%, #FFD8C2 50%, #F5C4A8 100%);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ШАПКА */
.hero {
    position: relative;
    width: 100%;
    height: 400px;
    background-image: url('img/Главная.png');
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(92, 46, 92, 0.5);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 0 20px;
    max-width: 900px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 700;
    color: #FFF8E7;
    letter-spacing: 1px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
    line-height: 1.2;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.3rem;
    color: #FFD8C2;
    font-style: italic;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}

/* ТОЛСТАЯ ЦВЕТНАЯ ПОЛОСА ПОД ШАПКОЙ */
.hero-border {
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, 
        #5C2E5C 0%, 
        #8C95FF 25%, 
        #5C2E5C 50%, 
        #8C95FF 75%, 
        #5C2E5C 100%);
    box-shadow: 0 4px 12px rgba(92, 46, 92, 0.3);
    position: relative;
    z-index: 2;
}

/* ДЕКОРАТИВНЫЙ РАЗДЕЛИТЕЛЬ С ОРНАМЕНТОМ */
.divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    max-width: 600px;
    margin: 20px auto 30px auto;
    padding: 0 20px;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--button-color) 50%, transparent 100%);
}

.divider-icon {
    font-size: 1.8rem;
    color: var(--button-color);
    line-height: 1;
    animation: dividerPulse 3s ease-in-out infinite;
}

@keyframes dividerPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ПЕРЕКЛЮЧАТЕЛЬ ЯЗЫКОВ */
.lang-switcher {
    position: absolute;
    top: 20px;
    right: 25px;
    z-index: 3;
    display: flex;
    gap: 8px;
}

.lang-btn {
    background: rgba(255, 216, 194, 0.85);
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-btn:hover, .lang-btn.active {
    background: var(--accent-color);
    color: #FFD8C2;
}

.lang-btn.active { box-shadow: 0 0 10px rgba(92, 46, 92, 0.6); }

/* КНОПКА ВОЗВРАТА НА САЙТ БИБЛИОТЕКИ (шапка) */
.back-to-library {
    position: absolute;
    top: 20px;
    left: 25px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 216, 194, 0.9);
    border: 1.5px solid var(--accent-color);
    color: var(--accent-color);
    padding: 5px 10px;
    border-radius: 20px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-body);
    max-width: 200px;
}

.back-to-library:hover {
    background: var(--accent-color);
    color: #FFD8C2;
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(92, 46, 92, 0.35);
}

.back-to-library .home-icon {
    font-size: 0.95rem;
    line-height: 1;
    filter: brightness(0) invert(1);
}

.back-to-library:hover .home-icon {
    filter: brightness(0) saturate(100%) invert(18%) sepia(60%) saturate(2000%) hue-rotate(320deg) brightness(80%) contrast(95%);
}

.back-to-library .home-label {
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
    text-align: left;
}

/* ПОИСК */
.search-section {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 30px 20px 0 20px;
}

.search-box {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

#searchInput {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.85);
    border: 3px solid var(--button-color);
    border-radius: 40px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(140, 149, 255, 0.25);
}

#searchInput:focus {
    border-color: var(--accent-color);
    box-shadow: 0 6px 20px rgba(92, 46, 92, 0.3);
}

#searchInput::placeholder { color: #888; font-style: italic; }

.clear-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--button-color);
    color: #FFFFFF;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.3s ease;
}

.clear-btn:hover { background: var(--accent-color); transform: translateY(-50%) scale(1.1); }
.clear-btn.visible { display: flex; }

.search-hint {
    text-align: center;
    margin-top: 12px;
    font-size: 0.95rem;
    color: var(--accent-color);
    font-style: italic;
    min-height: 1.2em;
}

/* ГЛАВНАЯ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 40px 20px;
    flex: 1;
    width: 100%;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 10px;
    position: relative;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 30px;
}

/* КАРТОЧКА */
.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 25px 20px;
    text-align: center;
    box-shadow: 0 6px 18px rgba(92, 46, 92, 0.15);
    border: 2px solid var(--button-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: cardAppear 0.4s ease;
    cursor: pointer;
}

@keyframes cardAppear {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 14px 30px rgba(92, 46, 92, 0.25);
    background: var(--card-hover);
}

.card img {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent-color);
    background: #D9C9A8;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(92, 46, 92, 0.2);
    pointer-events: none;
}

.card .name {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 5px;
    pointer-events: none;
}

.card .years {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-color);
    font-style: italic;
    margin-bottom: 15px;
    pointer-events: none;
}

.btn {
    background: var(--button-color);
    color: #FFFFFF;
    border: none;
    padding: 10px 28px;
    border-radius: 30px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(140, 149, 255, 0.5);
    margin-top: auto;
    pointer-events: none;
}

.card:hover .btn {
    background: var(--button-hover);
    box-shadow: 0 6px 18px rgba(140, 149, 255, 0.7);
}

.no-results {
    text-align: center;
    font-size: 1.2rem;
    color: var(--accent-color);
    font-style: italic;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    border: 2px dashed var(--button-color);
    margin-top: 20px;
}

/* СТРАНИЦА АВТОРА */
.author-page { display: none; animation: fadeIn 0.5s ease; }
.author-page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.back-btn {
    background: var(--button-color);
    color: #FFFFFF;
    border: none;
    padding: 10px 24px;
    border-radius: 30px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(140, 149, 255, 0.5);
    margin-bottom: 30px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-btn:hover { background: var(--button-hover); transform: scale(1.05); }

.author-header {
    display: flex;
    gap: 35px;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 35px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--button-color);
}

.author-header img {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid var(--accent-color);
    background: #D9C9A8;
    box-shadow: 0 6px 20px rgba(92, 46, 92, 0.25);
}

.author-info h2 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--accent-color);
    margin-bottom: 8px;
}

.author-info .years {
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--text-color);
    font-style: italic;
    margin-bottom: 15px;
}

.author-info .bio {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-color);
    max-width: 700px;
    text-align: justify;
}

.author-info .bio p {
    text-indent: 30px;
    margin-bottom: 15px;
    margin-top: 0;
}

.author-info .bio p:first-child { margin-top: 0; }
.author-info .bio p:last-child { margin-bottom: 0; }

.books-section { margin: 35px 0; }
.books-section h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}

.books-flex {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.book-item {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.5);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid var(--button-color);
    text-align: left;
}

.book-item img {
    width: 116px;
    height: 163px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(92, 46, 92, 0.25);
    background: #D9C9A8;
    border: 2px solid var(--button-color);
    flex-shrink: 0;
}

.book-item .book-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-top: 5px;
}

.book-item .title {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 8px;
    color: var(--text-color);
}

.book-item .year {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--accent-color);
}

.book-item .book-description {
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: var(--text-color);
    line-height: 1.7;
    font-style: italic;
    padding: 12px 16px;
    background: rgba(140, 149, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--button-color);
}

.poems-section { margin-top: 35px; }
.poems-section h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}

.poem-block {
    background: var(--poem-bg);
    padding: 20px 25px;
    border-radius: 15px;
    margin-bottom: 18px;
    border-left: 6px solid var(--accent-color);
    box-shadow: 0 2px 8px rgba(92, 46, 92, 0.08);
}

.poem-block .poem-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-bottom: 8px;
}

.poem-block .lines {
    font-family: var(--font-poem);
    font-style: italic;
    color: var(--text-color);
    line-height: 1.9;
    white-space: pre-line;
    font-size: 1.05rem;
}

.library-link {
    margin-top: 30px;
    padding: 20px 25px;
    background: rgba(140, 149, 255, 0.15);
    border-radius: 15px;
    border: 2px dashed var(--accent-color);
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.6;
}

.library-link strong { color: var(--accent-color); }

/* ПОДВАЛ */
.site-footer {
    background: var(--accent-color);
    color: #FFD8C2;
    text-align: center;
    padding: 25px 20px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    margin-top: auto;
    position: relative;
}

/* ТОЛСТАЯ ЦВЕТНАЯ ПОЛОСА СВЕРХУ ПОДВАЛА */
.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(90deg, 
        #5C2E5C 0%, 
        #8C95FF 25%, 
        #5C2E5C 50%, 
        #8C95FF 75%, 
        #5C2E5C 100%);
    box-shadow: 0 -4px 12px rgba(92, 46, 92, 0.3);
}

.site-footer a { color: #8C95FF; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* КНОПКА ВОЗВРАТА НА САЙТ БИБЛИОТЕКИ (подвал) */
.footer-home-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 12px;
    color: #FFD8C2;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 6px 14px;
    border-radius: 20px;
    font-family: var(--font-body);
}

.footer-home-link:hover {
    color: #FFFFFF;
    background: rgba(255, 216, 194, 0.15);
    transform: translateY(-2px);
}

.footer-home-link .footer-home-icon {
    font-size: 1rem;
    line-height: 1;
    filter: brightness(0) invert(1);
}

.footer-home-link:hover .footer-home-icon {
    filter: brightness(0) saturate(100%) invert(18%) sepia(60%) saturate(2000%) hue-rotate(320deg) brightness(80%) contrast(95%);
}

.footer-home-link .footer-home-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* КНОПКА «НАВЕРХ» */
#scrollToTopBtn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #FFD8C2;
    border: none;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(92, 46, 92, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#scrollToTopBtn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scrollToTopBtn:hover {
    background: var(--button-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(140, 149, 255, 0.5);
}

/* АДАПТИВНОСТЬ */
@media (max-width: 768px) {
    .hero { height: 300px; }
    .hero-title { font-size: 2rem; }
    .hero-subtitle { font-size: 1rem; }
    .lang-switcher { top: 10px; right: 10px; }
    .lang-btn { padding: 5px 10px; font-size: 0.85rem; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
    .author-header { flex-direction: column; align-items: center; text-align: center; }
    .author-info h2 { font-size: 1.7rem; }
    .author-header img { width: 160px; height: 160px; }
    .book-item { flex-direction: column; align-items: center; text-align: center; }
    .book-item .book-info { align-items: center; text-align: center; }
    .books-flex { justify-content: center; }
    .section-title { font-size: 1.5rem; }
    #searchInput { font-size: 0.95rem; padding: 12px 45px 12px 15px; }
    #scrollToTopBtn { bottom: 20px; right: 20px; width: 46px; height: 46px; font-size: 20px; }

    .back-to-library {
        top: 10px;
        left: 10px;
        padding: 4px 8px;
        max-width: 150px;
    }
    .back-to-library .home-icon { font-size: 0.85rem; }
    .back-to-library .home-label { font-size: 0.6rem; }

    .footer-home-link .footer-home-icon { font-size: 0.9rem; }
    .footer-home-link .footer-home-label { font-size: 0.7rem; }
}