/* ============================================================
   TALER — стылі галоўнай старонкі
   Фон: цёмна-бардовы #320308
   Шрыфт: Inter. Кнопкі — эфект шкла.
   ============================================================ */

:root {
    --bg: #320308;
    --bg-deep: #1d0104;
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.55);
    --glass: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.16);
    --stroke: rgba(255, 255, 255, 0.22);
    --stroke-strong: rgba(255, 255, 255, 0.4);
    --cream: #f0d9c3;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 90% 60% at 50% -10%, #4d0710 0%, rgba(77, 7, 16, 0) 70%),
        radial-gradient(ellipse 70% 50% at 50% 110%, #250106 0%, rgba(37, 1, 6, 0) 70%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 56px 20px 120px;
}

/* ---------- Загаловак з лагатыпам ---------- */

.header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 64px;
}

/* ============================================================
   Адаптивная шапка и SVG логотип
   ============================================================ */

.header {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
    box-sizing: border-box;
}

/* 1. Десктопы и планшеты */
.logo {
    display: block;
    width: 100%;
    max-width: 520px; /* Фиксированная максимальная ширина для больших экранов */
    height: auto;
    margin: 0 auto;
    transition: transform 0.2s ease, max-width 0.2s ease;
}

/* 2. Мобильные (вертикальный режим / Portrait) */
@media screen and (max-width: 600px) and (orientation: portrait) {
    .header {
        padding: 16px 12px; /* Минимальные боковые поля */
    }

    .logo {
        max-width: 100%; /* Вписывается строго в ширину экрана */
        width: 100%;
        height: auto;
    }
}

/* 3. Мобильные (горизонтальный режим / Landscape) */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 12px 20%; /* Свободные боковые отступы по 20% для аккуратного центрирования */
    }

    .logo {
        max-width: 320px; /* Уменьшаем SVG, чтобы он не перекрывал контент по высоте */
        width: auto;
        height: auto;
    }
}

    .logo {
        /* Фиксируем или ограничиваем максимальную ширину, 
           чтобы SVG не растягивался на весь широкий экран */
        max-width: 400px; 
        width: auto;
        height: auto;
        margin: 0 auto;
    }
}

/* Запасны тэкставы загаловак, калі SVG не знойдзены */
.title {
    font-size: clamp(52px, 9vw, 108px);
    font-weight: 500;
    letter-spacing: 0.14em;
    line-height: 1;
    padding-left: 0.14em;
    color: #fff;
    background: linear-gradient(180deg, #ffffff 0%, #f4e2d2 55%, #d9b394 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------- Паліца ---------- */

.bookshelf-wrapper {
    perspective: 1600px;
}

.bookshelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 56px 36px;
    padding: 24px 8px;
}

.magazine-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.magazine-item:hover {
    transform: translateY(-8px);
}

.magazine-cover {
    width: 100%;
    max-width: 260px;
    aspect-ratio: 0.707;
    cursor: pointer;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.08);
    transition: box-shadow 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.magazine-cover:hover {
    transform: scale(1.02);
    box-shadow:
        0 34px 70px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.22);
}

.magazine-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---------- Кнопкі: шкло, белы тэкст, тонкая іконка ---------- */

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 11px 26px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.03em;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    box-shadow:
        0 8px 26px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
}

.download-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.17);
    border-color: rgba(255, 255, 255, 0.42);
    transform: translateY(-2px);
}

.download-btn:active:not(:disabled) {
    transform: translateY(0);
}

.download-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.download-btn svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

/* Круцілка ўнутры кнопкі падчас спампоўкі */
.download-btn.is-loading svg {
    animation: spin 1s linear infinite;
}

/* ---------- Секцыя сувязі з аўтарам ---------- */

.contact-section {
    display: flex;
    justify-content: center;
    margin-top: 72px;
    padding-top: 56px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.contact-btn {
    font-size: 15px;
    padding: 13px 34px;
    gap: 11px;
}

.contact-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- Выдаленне (толькі адмін) ---------- */

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.25s ease;
    z-index: 10;
}

.magazine-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn svg {
    width: 15px;
    height: 15px;
}

.delete-btn:hover {
    background: rgba(220, 38, 38, 0.55);
    border-color: rgba(255, 255, 255, 0.45);
}

/* ---------- Кнопка адміністратара (замок) ---------- */

.admin-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 100;
}

.admin-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: scale(1.05);
}

.admin-btn svg {
    width: 19px;
    height: 19px;
}

/* ---------- Кнопка дадання часопіса ---------- */

.add-magazine-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    z-index: 100;
}

.add-magazine-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.07);
}

.add-magazine-btn svg {
    width: 21px;
    height: 21px;
}

/* ---------- Статус адміністратара ---------- */

.admin-status {
    position: fixed;
    top: 22px;
    right: 22px;
    display: none;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    padding: 8px 8px 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.admin-badge {
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.03em;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7ee2b8;
    box-shadow: 0 0 8px rgba(126, 226, 184, 0.8);
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.logout-btn {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

/* ---------- Мадальнае акно ---------- */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(20, 1, 4, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-y: auto;
}

.modal-content {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    margin: 8vh auto;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.close {
    color: rgba(255, 255, 255, 0.5);
    float: right;
    font-size: 26px;
    line-height: 1;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: #fff;
}

.modal-content h2 {
    margin-bottom: 26px;
    font-size: 22px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s, background 0.2s;
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.form-group input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.1);
}

.form-group small {
    display: block;
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
}

input[type="file"] {
    padding: 10px 12px;
    font-size: 13px;
}

input[type="file"]::file-selector-button {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 7px 14px;
    margin-right: 12px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
    background: rgba(255, 255, 255, 0.18);
}

.progress-bar {
    margin: 22px 0;
    height: 38px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.5));
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 400;
    color: #fff;
    z-index: 10;
}

.submit-btn {
    width: 100%;
    padding: 13px 24px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 0.03em;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: all 0.25s;
}

.submit-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.5);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Загрузка ---------- */

.loading-magazines {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
    font-weight: 300;
    letter-spacing: 0.03em;
}

.spinner {
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-top-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    animation: spin 1s linear infinite;
    margin: 0 auto 18px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Мабільныя ---------- */

@media (max-width: 768px) {
    .container {
        padding: 40px 16px 110px;
    }

    .header {
        margin-bottom: 44px;
    }

    .logo {
        width: 96%;
    }

    .bookshelf {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 40px 18px;
    }

    .magazine-cover {
        max-width: 100%;
    }

    .download-btn {
        padding: 10px 20px;
        font-size: 13px;
        gap: 8px;
    }

    .contact-section {
        margin-top: 52px;
        padding-top: 40px;
    }

    .contact-btn {
        font-size: 14px;
        padding: 12px 26px;
    }

    .add-magazine-btn {
        bottom: 22px;
        right: 22px;
        width: 48px;
        height: 48px;
    }

    .admin-btn {
        bottom: 22px;
        left: 22px;
        width: 42px;
        height: 42px;
    }

    .admin-status {
        top: 14px;
        right: 14px;
        padding: 6px 6px 6px 12px;
    }

    .admin-badge {
        font-size: 12px;
    }

    .delete-btn {
        opacity: 1;
    }
}