/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Arial', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.4;
    color: #000;
    background: #fff;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #f0f0f0;
    padding: 1rem 0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 3rem;
}

.site-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #000;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.site-title:hover {
    opacity: 0.7;
}

.main-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    font-size: 0.9rem;
    color: #000;
    text-decoration: none;
    font-weight: 400;
    letter-spacing: -0.01em;
    transition: opacity 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    opacity: 1;
    border-bottom: 1px solid #000;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.search-box {
    position: relative;
}

.search-input {
    border: none;
    background: transparent;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    width: 120px;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    color: #000;
}

.search-input:focus {
    outline: none;
    border-bottom-color: #000;
    width: 180px;
}

.search-input::placeholder {
    color: #666;
    font-weight: 400;
}

/* Страница фильтров */
.filters-container {
    max-width: 800px;
    margin: 100px auto;
    padding: 0 20px;
}

.filters-container h1 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 2rem;
    letter-spacing: -0.01em;
}

.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-tag {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #f0f0f0;
    color: #333;
    text-decoration: none;
    border-radius: 3px;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.filter-tag:hover {
    background: #e0e0e0;
}

/* Main content */
main {
    margin-top: 80px;
    min-height: calc(100vh - 160px);
}

/* Gallery — masonry сетка с фиксированной шириной колонок */
.gallery {
    column-count: 4;
    /* количество колонок */
    column-gap: 1rem;
    /* расстояние между колонками */
    margin: 0 auto;
    padding: 1rem;
}

.gallery-item {
    display: inline-block;
    /* важно для работы multi-column */
    width: 100%;
    /* занимает всю ширину колонки */
    margin-bottom: 2rem;
    /* отступ между элементами по вертикали */
    background: #ffffff;
    position: relative;
    transition: opacity 0.3s ease;
    break-inside: avoid;
    /* предотвращает разрыв элемента между колонками */
}

.gallery-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.4s ease;
}

.gallery-item:hover img {
    transform: scale(1.02);
}

.gallery-item video {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.4s ease;
}

.gallery-item:hover video {
    transform: scale(1.02);
}

/* Информация при наведении */
.post-info {
    margin-top: 0.75rem;
    padding: 0;
    background: transparent;
    color: #333;
    line-height: 1.4;
}

.gallery-item:hover .post-info {
    opacity: 1;
}

.post-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
    color: #000;
}

.post-description {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
    line-height: 1.4;
    max-width: 100%;
    word-wrap: break-word;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #666;
}

.tag {
    font-weight: 400;
}

.post-date {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

/* Видео-блоки (используются на странице поста) */
.post-video {
    max-width: 800px;
    margin: 0 auto 20px;
}

.post-video video {
    width: 100%;
    display: block;
}

.post-video .embed-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
}

.post-video .embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Состояния загрузки и ошибок */
.loading,
.error,
.no-works {
    text-align: center;
    padding: 4rem 2rem;
    font-size: 0.9rem;
    color: #666;
    grid-column: 1 / -1;
    font-weight: 400;
}

.error h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: #000;
}

.error p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.error ul,
.error ol {
    text-align: left;
    display: inline-block;
    margin: 1rem 0;
}

.error li {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.retry-button {
    background: #000;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
    margin-top: 1rem;
}

.retry-button:hover {
    opacity: 0.8;
}

/* Footer */
footer {
    border-top: 1px solid #f0f0f0;
    padding: 2rem 0;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #666;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-link {
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: #000;
}

/* Адаптивность */
@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
        gap: 1rem;
    }

    .main-nav {
        gap: 1.5rem;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .search-input {
        width: 100%;
        text-align: center;
    }

    .search-input:focus {
        width: 100%;
    }

    main {
        margin-top: 120px;
    }

    .gallery {
        column-count: 2;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-links {
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .gallery-item {
        flex-basis: 100%;
        /* на самых узких экранах карточка на всю ширину */
    }

    .gallery {
        column-count: 1;
    }

    .main-nav {
        gap: 1rem;
    }

    .nav-link {
        font-size: 0.85rem;
    }

    .header-left {
        flex-direction: column;
        gap: 0.5rem;
    }

    main {
        margin-top: 140px;
    }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.gallery-item {
    animation: fadeIn 0.5s ease forwards;
}

/* Утилиты */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}