/* =========================================
   Base
========================================= */

:root {
    --bg: #f6f7f8;
    --surface: #ffffff;
    --surface-soft: #f1f3f5;

    --text: #202124;
    --text-soft: #68707c;

    --border: #e2e6ea;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;

    --header: #121820;
    --header-soft: #1c2530;

    --success-bg: #ecfdf3;
    --success-text: #166534;

    --danger-bg: #fef2f2;
    --danger-text: #991b1b;

    --radius: 14px;
    --radius-small: 9px;

    --shadow:
        0 4px 20px rgba(15, 23, 42, 0.07);

    --container: 1280px;
}


*,
*::before,
*::after {
    box-sizing: border-box;
}


html {
    scroll-behavior: smooth;
}


body {
    margin: 0;

    min-height: 100vh;

    display: flex;
    flex-direction: column;

    background: var(--bg);

    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    font-size: 16px;
    line-height: 1.6;
}


img {
    display: block;
    max-width: 100%;
}


a {
    color: var(--accent);
    text-decoration: none;

    transition:
        color 0.15s ease,
        opacity 0.15s ease;
}


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


button,
input,
textarea,
select {
    font: inherit;
}


.container {
    width: min(
        calc(100% - 40px),
        var(--container)
    );

    margin-inline: auto;
}


/* =========================================
   Header
========================================= */

.site-header {
    background: var(--header);
    color: #fff;
}


.header-inner {
    min-height: 72px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 32px;
}


.brand {
    display: inline-flex;
    align-items: center;

    gap: 11px;

    color: #fff;

    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
}


.brand:hover {
    color: #fff;
    opacity: 0.88;
}


.brand-logo {
    width: 44px;
    height: 44px;

    object-fit: contain;
}


.main-nav {
    display: flex;
    align-items: center;

    gap: 28px;

    flex-wrap: wrap;
}


.main-nav a {
    color: #dce2e9;

    font-size: 15px;
    font-weight: 500;
}


.main-nav a:hover {
    color: #fff;
}


.main-nav .admin-link {
    padding: 8px 13px;

    border: 1px solid #455364;
    border-radius: 8px;

    color: #fff;
}


/* =========================================
   Search
========================================= */

.search-bar {
    padding: 15px 0;

    background: var(--header-soft);
}


.search-form {
    max-width: 720px;

    margin-inline: auto;
}


.search-field {
    position: relative;

    display: flex;
    align-items: center;

    gap: 8px;
}


.search-icon {
    position: absolute;

    left: 15px;

    color: #7d8997;

    font-size: 22px;

    pointer-events: none;
}


.search-field input {
    width: 100%;
    height: 46px;

    padding:
        0
        110px
        0
        46px;

    background: #fff;

    border: 1px solid transparent;
    border-radius: 10px;

    color: var(--text);

    outline: none;

    font-size: 15px;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


.search-field input::placeholder {
    color: #8b95a1;
}


.search-field input:focus {
    border-color: #7aa2eb;

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.17);
}


.search-button {
    position: absolute;

    right: 5px;

    height: 36px;

    padding: 0 16px;

    background: var(--accent);

    border: 0;
    border-radius: 7px;

    color: #fff;

    cursor: pointer;

    font-weight: 700;
}


.search-button:hover {
    background: var(--accent-hover);
}


.search-clear {
    position: absolute;

    right: 82px;

    display: grid;
    place-items: center;

    width: 28px;
    height: 28px;

    color: #7c8794;

    font-size: 22px;
    line-height: 1;
}


.search-clear:hover {
    color: var(--text);
}


.search-empty strong {
    display: block;

    margin-bottom: 5px;

    color: var(--text);

    font-size: 19px;
}


.search-empty p {
    margin: 0 0 20px;
}

/* =========================================
   Categories
========================================= */

.category-bar {
    background: var(--surface);

    border-bottom: 1px solid var(--border);
}


.category-nav {
    overflow-x: auto;

    scrollbar-width: thin;
}


.category-list {
    min-height: 54px;

    margin: 0;
    padding: 0;

    display: flex;
    align-items: center;

    gap: 8px;

    list-style: none;

    white-space: nowrap;
}


.category-list li {
    margin: 0;
}


.category-list a,
.category-list span {
    display: inline-flex;

    padding: 7px 13px;

    border-radius: 999px;

    color: #4b5563;

    font-size: 14px;
    font-weight: 500;
}


.category-list a:hover {
    background: var(--surface-soft);

    color: var(--text);
}


.category-list .selected a,
.category-list .selected span {
    background: var(--header);

    color: #fff;
}


/* =========================================
   Main
========================================= */

.site-main {
    flex: 1;

    padding: 52px 0 72px;
}


.page-intro {
    max-width: 760px;

    margin-bottom: 36px;
}


.eyebrow {
    margin: 0 0 7px;

    color: var(--accent);

    font-size: 13px;
    font-weight: 700;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}


.page-intro h1,
.post-header h1,
.section-heading h2,
.comment-form-intro h2 {
    margin-top: 0;

    letter-spacing: -0.035em;

    line-height: 1.15;
}


.page-intro h1 {
    margin-bottom: 14px;

    font-size: clamp(32px, 5vw, 48px);
}


.page-intro-text {
    margin: 0;

    color: var(--text-soft);

    font-size: 18px;
}


/* =========================================
   Photo grid
========================================= */

.photo-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 26px;
}


.photo-card {
    min-width: 0;

    overflow: hidden;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}


.photo-card:hover {
    transform: translateY(-3px);

    box-shadow:
        0 12px 32px rgba(15, 23, 42, 0.11);
}


.photo-card-image-link {
    display: block;

    aspect-ratio: 16 / 10;

    overflow: hidden;

    background: #dfe3e7;
}


.photo-card-image {
    width: 100%;
    height: 100%;

    object-fit: cover;

    transition: transform 0.35s ease;
}


.photo-card:hover .photo-card-image {
    transform: scale(1.025);
}


.photo-placeholder {
    width: 100%;
    height: 100%;

    display: grid;
    place-items: center;

    color: var(--text-soft);
}


.photo-card-body {
    padding: 20px;
}


.photo-card-meta {
    margin-bottom: 12px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    color: var(--text-soft);

    font-size: 13px;
}


.category-badge {
    display: inline-flex;

    padding: 5px 9px;

    background: #eef4ff;

    border-radius: 999px;

    color: #315ca8;

    font-size: 12px;
    font-weight: 700;
}


.photo-card-title {
    margin: 0 0 10px;

    font-size: 22px;
    line-height: 1.25;
}


.photo-card-title a {
    color: var(--text);
}


.photo-card-title a:hover {
    color: var(--accent);
}


.photo-card-description {
    min-height: 76px;

    color: var(--text-soft);

    font-size: 15px;
}


.read-more {
    margin-top: 18px;

    display: inline-flex;
    align-items: center;

    gap: 7px;

    font-size: 14px;
    font-weight: 700;
}


/* =========================================
   Pagination
========================================= */

.pagination {
    margin-top: 48px;

    display: flex;
    justify-content: center;

    gap: 7px;
}


.pagination-item {
    width: 40px;
    height: 40px;

    display: grid;
    place-items: center;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 8px;

    color: var(--text);
}


.pagination-item:hover {
    background: var(--surface-soft);

    color: var(--text);
}


.pagination-item.active {
    background: var(--header);

    border-color: var(--header);

    color: #fff;
}


/* =========================================
   Breadcrumbs
========================================= */

.breadcrumbs {
    margin-bottom: 24px;

    display: flex;
    align-items: center;

    gap: 9px;

    color: var(--text-soft);

    font-size: 14px;
}


/* =========================================
   Post
========================================= */

.post {
    max-width: 980px;

    margin-inline: auto;
}


.post-header {
    max-width: 820px;

    margin: 0 auto 30px;

    text-align: center;
}


.post-header h1 {
    margin: 18px 0 14px;

    font-size: clamp(34px, 5vw, 54px);
}


.post-meta {
    display: flex;
    justify-content: center;

    gap: 18px;

    color: var(--text-soft);

    font-size: 14px;
}


.post-figure {
    margin: 0 0 40px;
}

.post-image {
    width: 100%;

    max-height: 720px;

    object-fit: contain;

    background: #111;

    border-radius: var(--radius);

    box-shadow: var(--shadow);
}

/* Текст публикации */
.post-content {
    max-width: 800px;

    margin-inline: auto;

    color: #30343a;

    font-size: 18px;
    line-height: 1.6;
}

/* Отступы между абзацами */
.post-content p {
    margin: 0 0 0.9em;
}

/* Убираем лишний отступ после последнего абзаца */
.post-content p:last-child {
    margin-bottom: 0;
}

.post-tags {
    max-width: 800px;

    margin: 36px auto 0;

    display: flex;
    flex-wrap: wrap;
    align-items: center;

    gap: 8px;
}


.post-tags-title {
    margin-right: 4px;

    color: var(--text-soft);

    font-size: 14px;
}


.tag {
    padding: 6px 11px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 999px;

    color: #4b5563;

    font-size: 13px;
}


.tag:hover {
    background: var(--surface-soft);

    color: var(--text);
}


/* =========================================
   Post navigation
========================================= */

.post-navigation {
    max-width: 800px;

    margin: 48px auto 0;

    padding-top: 28px;

    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 18px;

    border-top: 1px solid var(--border);
}


.post-navigation-item {
    min-width: 0;
}


.post-navigation-next {
    text-align: right;
}


.post-navigation-link {
    height: 100%;

    display: flex;
    flex-direction: column;

    gap: 5px;

    padding: 18px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    color: var(--text);

    transition:
        border-color 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}


.post-navigation-link:hover {
    border-color: #cbd2da;

    color: var(--text);

    transform: translateY(-2px);

    box-shadow: var(--shadow);
}


.post-navigation-direction {
    color: var(--text-soft);

    font-size: 12px;
    font-weight: 600;

    letter-spacing: 0.03em;
    text-transform: uppercase;
}


.post-navigation-link strong {
    font-size: 16px;
    line-height: 1.35;
}


/* =========================================
   Related posts
========================================= */

.related-posts {
    max-width: 980px;

    margin: 72px auto 0;
}


.related-posts-heading {
    margin-bottom: 22px;
}


.related-posts-heading h2 {
    margin: 0;

    font-size: 30px;

    letter-spacing: -0.03em;
}


.related-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 20px;
}


.related-card {
    overflow: hidden;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}


.related-card-image-link {
    display: block;

    aspect-ratio: 16 / 10;

    overflow: hidden;

    background: #dfe3e7;
}


.related-card-image {
    width: 100%;
    height: 100%;

    object-fit: cover;

    transition: transform 0.3s ease;
}


.related-card:hover .related-card-image {
    transform: scale(1.035);
}


.related-card-body {
    padding: 15px;
}


.related-card-date {
    color: var(--text-soft);

    font-size: 12px;
}


.related-card h3 {
    margin: 5px 0 0;

    font-size: 17px;
    line-height: 1.35;
}


.related-card h3 a {
    color: var(--text);
}


.related-card h3 a:hover {
    color: var(--accent);
}


/* =========================================
   Comments
========================================= */

.comments-section {
    max-width: 800px;

    margin: 76px auto 0;
}


.section-heading {
    padding-bottom: 18px;

    border-bottom: 1px solid var(--border);
}


.section-heading h2 {
    margin-bottom: 0;

    font-size: 30px;
}


.comment-count {
    display: inline-grid;
    place-items: center;

    min-width: 30px;
    height: 30px;

    margin-left: 6px;

    background: var(--surface-soft);

    border-radius: 999px;

    color: var(--text-soft);

    font-size: 14px;
}


.comments-list {
    margin-top: 24px;

    display: grid;

    gap: 14px;
}


.comment {
    padding: 20px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}


.comment-header {
    margin-bottom: 14px;

    display: flex;
    align-items: center;

    gap: 12px;
}


.comment-avatar {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    display: grid;
    place-items: center;

    background: var(--header);

    border-radius: 50%;

    color: #fff;

    font-size: 16px;
    font-weight: 700;
}


.comment-author {
    display: block;

    color: var(--text);
}


.comment-date {
    display: block;

    color: var(--text-soft);

    font-size: 12px;
}


.comment-content {
    color: #3f4650;
}


.comment-content p {
    margin: 0;
}


.empty-comments,
.empty-state {
    padding: 28px;

    background: var(--surface);

    border: 1px dashed #cbd1d8;
    border-radius: var(--radius-small);

    color: var(--text-soft);

    text-align: center;
}


/* =========================================
   Comment form
========================================= */

.comment-form-wrapper {
    margin-top: 48px;

    padding: 30px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}


.comment-form-intro h2 {
    margin-bottom: 10px;

    font-size: 30px;
}


.comment-form-intro > p:last-child {
    margin-bottom: 28px;

    color: var(--text-soft);
}


.comment-form p {
    margin: 0 0 20px;
}


.comment-form label {
    margin-bottom: 7px;

    display: block;

    color: #343a40;

    font-size: 14px;
    font-weight: 600;
}


.comment-form input,
.comment-form textarea,
.comment-form select {
    width: 100%;

    padding: 11px 13px;

    background: #fff;

    border: 1px solid #cdd3da;
    border-radius: 8px;

    color: var(--text);

    outline: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


.comment-form textarea {
    min-height: 150px;

    resize: vertical;
}


.comment-form input:focus,
.comment-form textarea:focus,
.comment-form select:focus {
    border-color: var(--accent);

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.12);
}


.comment-form .errorlist {
    margin: 0 0 8px;
    padding: 0;

    list-style: none;

    color: var(--danger-text);

    font-size: 13px;
}


.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 44px;

    padding: 10px 18px;

    border: 0;
    border-radius: 9px;

    cursor: pointer;

    font-weight: 700;
}


.button-primary {
    background: var(--accent);

    color: #fff;
}


.button-primary:hover {
    background: var(--accent-hover);
}


/* =========================================
   Generic forms
========================================= */

form input,
form textarea,
form select {
    max-width: 100%;
}


/* =========================================
   Messages
========================================= */

.messages {
    margin-bottom: 28px;
}


.message {
    padding: 13px 16px;

    border-radius: 9px;
}


.message.success {
    background: var(--success-bg);

    color: var(--success-text);
}


.message.error {
    background: var(--danger-bg);

    color: var(--danger-text);
}


/* =========================================
   Footer
========================================= */

.site-footer {
    margin-top: auto;

    padding: 46px 0;

    background: var(--header);

    color: #aeb8c4;
}


.footer-inner {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        auto;

    gap: 26px;
}


.footer-title {
    margin: 0 0 7px;

    color: #fff;

    font-size: 17px;
    font-weight: 700;
}


.footer-description {
    max-width: 520px;

    margin: 0;

    font-size: 14px;
}


.footer-links {
    display: flex;
    flex-direction: column;

    gap: 8px;
}


.footer-links a {
    color: #dce2e9;

    font-size: 14px;
}


.footer-links a:hover {
    color: #fff;
}


.copyright {
    grid-column: 1 / -1;

    margin: 12px 0 0;

    padding-top: 20px;

    border-top: 1px solid #2b3541;

    color: #778392;

    font-size: 13px;
}


/* =========================================
   Text pages
========================================= */

.site-main h1 {
    color: var(--text);
}


.site-main hr {
    margin: 42px 0;

    border: 0;
    border-top: 1px solid var(--border);
}


/* =========================================
   Lightbox
========================================= */

.post-image-button {
    width: 100%;

    display: block;

    margin: 0;
    padding: 0;

    background: transparent;

    border: 0;
    border-radius: var(--radius);

    cursor: zoom-in;
}


.post-image-button:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.45);
    outline-offset: 4px;
}


.post-image-caption {
    margin-top: 10px;

    color: var(--text-soft);

    font-size: 13px;
    text-align: center;
}


body.lightbox-open {
    overflow: hidden;
}


.lightbox[hidden] {
    display: none;
}


.lightbox {
    position: fixed;
    inset: 0;

    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 32px;

    background: rgba(5, 8, 12, 0.94);

    cursor: zoom-out;
}


.lightbox-image {
    max-width: min(95vw, 1800px);
    max-height: 92vh;

    width: auto;
    height: auto;

    object-fit: contain;

    border-radius: 8px;

    cursor: default;

    box-shadow:
        0 24px 70px rgba(0, 0, 0, 0.45);
}


.lightbox-close {
    position: fixed;

    top: 20px;
    right: 24px;

    z-index: 1001;

    width: 46px;
    height: 46px;

    display: grid;
    place-items: center;

    padding: 0;

    background: rgba(255, 255, 255, 0.12);

    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;

    color: #fff;

    cursor: pointer;

    font-size: 32px;
    font-weight: 300;
    line-height: 1;

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}


.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);

    transform: scale(1.04);
}


.lightbox-close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

/* =========================================
   Responsive
========================================= */

@media (max-width: 960px) {

    .photo-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .related-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 720px) {

    .container {
        width: min(
            calc(100% - 28px),
            var(--container)
        );
    }


    .header-inner {
        padding: 14px 0;

        align-items: flex-start;
        flex-direction: column;

        gap: 14px;
    }


    .main-nav {
        width: 100%;

        gap: 16px;
    }


    .site-main {
        padding-top: 36px;
    }


    .photo-grid {
        grid-template-columns: 1fr;

        gap: 20px;
    }


    .photo-card-description {
        min-height: 0;
    }


    .post-meta {
        flex-direction: column;

        gap: 3px;
    }


    .comment-form-wrapper {
        padding: 22px;
    }


    .footer-inner {
        grid-template-columns: 1fr;
    }


    .copyright {
        grid-column: 1;
    }

        .lightbox {
        padding: 14px;
    }


    .lightbox-close {
        top: 12px;
        right: 12px;
    }


    .lightbox-image {
        max-width: 100%;
        max-height: 88vh;
    }

    .post-navigation {
        grid-template-columns: 1fr;
    }

    .post-navigation-next {
        text-align: left;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }

        .search-field input {
        padding-right: 94px;
    }


    .search-button {
        padding-inline: 13px;
    }

    .search-clear {
        display: none;
    }
}

@media (max-width: 420px) {

    .brand-text {
        font-size: 17px;
    }


    .page-intro h1 {
        font-size: 32px;
    }


    .post-header h1 {
        font-size: 34px;
    }


    .photo-card-body {
        padding: 17px;
    }

}

    .like-form {
        display: flex;
        justify-content: center;
        margin: 18px 0 28px;
    }

    .like-button {
        display: inline-flex;
        align-items: center;
        gap: 8px;

        padding: 10px 16px;

        border: 1px solid #d7dce3;
        border-radius: 999px;

        background: #fff;
        color: #333;

        font: inherit;
        cursor: pointer;

        transition:
            transform 0.15s ease,
            border-color 0.15s ease,
            background-color 0.15s ease;
    }

    .like-button:hover {
        transform: translateY(-1px);
    }

    .like-button:disabled {
        opacity: 0.65;
        cursor: wait;
    }

    .like-icon {
        font-size: 1.4rem;
        line-height: 1;
    }

    .like-button.is-liked {
        border-color: #d94b5b;
        color: #c82f43;
        background: #fff6f7;
    }

    .like-count {
        min-width: 1.2em;
        font-weight: 600;
    }

    .photo-card-likes {
        display: inline-flex;
        align-items: center;
        gap: 5px;

        margin: 12px 0 4px;

        color: #c82f43;
        font-size: 14px;
        font-weight: 600;
  }
