/*
 * Zapechka recipe comments — warm culinary speech bubbles.
 *
 * The comic-style conversation is preserved, but the previous purple palette
 * is replaced with cream, caramel and terracotta accents that fit Zapechka.
 */

.recipe-comments-more[hidden] {
    display: none;
}

.recipe-comments-section {
    --comment-accent: #c65f3d;
    --comment-accent-deep: #9f452a;
    --comment-accent-soft: rgba(198, 95, 61, 0.10);
    --comment-cream: #fffaf3;
    --comment-reply: #fff5e8;
    --comment-border: rgba(112, 73, 48, 0.18);
    --comment-text: #312821;
    --comment-muted: #7e7168;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(160, 103, 66, 0.16);
    background:
        radial-gradient(circle at 96% 5%, rgba(245, 184, 118, 0.18), transparent 27%),
        linear-gradient(180deg, #fffdf9 0%, #fff7ed 100%);
}

.recipe-comments-section::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #d96d45, #e89d62 58%, #efc28d);
}

.recipe-comments-head,
.recipe-comment-form,
.recipe-comments-list,
.recipe-comments-more,
.recipe-comments-guest,
.recipe-comments-empty {
    position: relative;
    z-index: 1;
}

.recipe-comments-title {
    letter-spacing: -0.025em;
}

.recipe-comments-count {
    min-width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0 10px;
    border: 1px solid rgba(198, 95, 61, 0.18);
    border-radius: 999px;
    color: var(--comment-accent-deep);
    background: var(--comment-accent-soft);
    font-weight: 850;
}

.recipe-comments-list {
    display: grid;
    gap: 34px;
}

.recipe-comment {
    position: relative;
    margin: 0;
    padding: 0 0 28px;
    border: 0;
    border-bottom: 1px solid rgba(112, 73, 48, 0.11);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
}

.recipe-comment:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.recipe-comment:hover {
    transform: none;
    border-color: rgba(112, 73, 48, 0.11);
    box-shadow: none;
}

.recipe-comment::before,
.recipe-comment::after {
    content: none;
}

.recipe-comment-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 14px;
    padding: 0 2px;
}

.recipe-comment-identity {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
    flex-wrap: wrap;
}

.recipe-comment-avatar {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 3px solid rgba(255, 255, 255, 0.98);
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #b84d32, #dd7549 58%, #efb36f);
    box-shadow: 0 8px 20px rgba(157, 70, 39, 0.20);
    font-size: 1rem;
    font-weight: 900;
}

.recipe-comment-author,
.recipe-comment-author-link {
    color: var(--comment-text);
    font-weight: 850;
}

.recipe-comment-author-link:hover {
    color: var(--comment-accent-deep);
}

.recipe-comment-author-badge {
    padding: 4px 9px;
    border: 1px solid rgba(185, 121, 42, 0.20);
    border-radius: 999px;
    color: #8b5a16;
    background: #fff1ce;
    font-size: 0.75rem;
    font-weight: 800;
}

.recipe-comment-time {
    margin-left: auto;
    color: var(--comment-muted);
    font-size: 0.84rem;
    white-space: nowrap;
}

.recipe-comment-body,
.recipe-comment-deleted {
    position: relative;
    margin: 0;
    padding: 22px 26px;
    border: 1px solid var(--comment-border);
    border-radius: 16px 16px 16px 6px;
    color: var(--comment-text);
    background: var(--comment-cream);
    box-shadow: 0 9px 24px rgba(83, 55, 37, 0.08);
    font-size: 1rem;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.recipe-comment-body::before,
.recipe-comment-deleted::before {
    content: "";
    position: absolute;
    top: -13px;
    left: 28px;
    width: 0;
    height: 0;
    border-right: 13px solid transparent;
    border-bottom: 13px solid var(--comment-border);
    border-left: 13px solid transparent;
}

.recipe-comment-body::after,
.recipe-comment-deleted::after {
    content: "";
    position: absolute;
    top: -11px;
    left: 29px;
    width: 0;
    height: 0;
    border-right: 12px solid transparent;
    border-bottom: 12px solid var(--comment-cream);
    border-left: 12px solid transparent;
}

.recipe-comment-deleted {
    color: var(--comment-muted);
    font-style: italic;
}

.recipe-comment-actions {
    display: flex;
    gap: 8px;
    margin: 10px 0 0;
    padding: 0 8px;
    border: 0;
}

.recipe-comment-action {
    padding: 7px 12px;
    border-radius: 999px;
    color: var(--comment-accent-deep);
    background: var(--comment-accent-soft);
    font-weight: 760;
}

.recipe-comment-action:hover {
    color: #7e311f;
    background: rgba(198, 95, 61, 0.17);
}

.recipe-comment-delete:hover {
    color: #a93434;
    background: rgba(169, 52, 52, 0.09);
}

.recipe-comment-replies {
    position: relative;
    display: grid;
    gap: 22px;
    margin: 22px 0 0 44px;
    padding-left: 30px;
    border-left: 2px solid rgba(198, 95, 61, 0.18);
}

.recipe-comment-replies::before {
    content: "";
    position: absolute;
    top: 0;
    left: -2px;
    width: 24px;
    height: 2px;
    background: rgba(198, 95, 61, 0.18);
}

.recipe-comment-reply {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.recipe-comment-reply:last-child {
    padding-bottom: 0;
}

.recipe-comment-reply .recipe-comment-header {
    margin-bottom: 12px;
}

.recipe-comment-reply .recipe-comment-avatar {
    width: 38px;
    height: 38px;
    font-size: 0.86rem;
    background: linear-gradient(135deg, #b8793f, #db9a58 58%, #efc48f);
}

.recipe-comment-reply .recipe-comment-body,
.recipe-comment-reply .recipe-comment-deleted {
    padding: 17px 20px;
    border-radius: 14px 14px 14px 6px;
    background: var(--comment-reply);
    box-shadow: 0 6px 18px rgba(83, 55, 37, 0.07);
}

.recipe-comment-reply .recipe-comment-body::before,
.recipe-comment-reply .recipe-comment-deleted::before {
    left: 20px;
}

.recipe-comment-reply .recipe-comment-body::after,
.recipe-comment-reply .recipe-comment-deleted::after {
    left: 21px;
    border-bottom-color: var(--comment-reply);
}

.recipe-comment-form {
    padding: 18px;
    border: 1px solid rgba(198, 95, 61, 0.16);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
}

.recipe-comment-textarea {
    border-radius: 14px;
    background: #fff;
    box-shadow: inset 0 1px 3px rgba(83, 55, 37, 0.05);
}

.recipe-comment-textarea:focus {
    border-color: rgba(198, 95, 61, 0.58);
    box-shadow: 0 0 0 4px rgba(198, 95, 61, 0.11);
}

.recipe-comment-submit,
.recipe-comments-more {
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(157, 70, 39, 0.16);
}

.recipe-comment-moderation-note {
    margin: 10px 0 0;
    padding: 10px 13px;
    border: 1px solid rgba(185, 121, 42, 0.20);
    border-radius: 12px;
    color: #785017;
    background: #fff5d9;
    font-size: 0.84rem;
    line-height: 1.45;
}

@media (max-width: 640px) {
    .recipe-comments-section {
        border-radius: 20px;
    }

    .recipe-comments-list {
        gap: 27px;
    }

    .recipe-comment {
        padding-bottom: 24px;
    }

    .recipe-comment-header {
        align-items: flex-start;
        gap: 10px;
    }

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

    .recipe-comment-time {
        width: 100%;
        margin: 3px 0 0 52px;
        white-space: normal;
    }

    .recipe-comment-body,
    .recipe-comment-deleted {
        padding: 18px 17px;
        border-radius: 14px 14px 14px 5px;
    }

    .recipe-comment-body::before,
    .recipe-comment-deleted::before {
        left: 20px;
    }

    .recipe-comment-body::after,
    .recipe-comment-deleted::after {
        left: 21px;
    }

    .recipe-comment-replies {
        margin-left: 13px;
        padding-left: 20px;
    }

    .recipe-comment-replies::before {
        width: 16px;
    }

    .recipe-comment-reply .recipe-comment-time {
        margin-left: 46px;
    }
}
.recipe-comments-feedback {
    min-height: 1.35em;
    margin: 10px 0 0;
    padding: 0 4px;
    font-size: 14px;
    font-weight: 700;
}
.recipe-comments-feedback:empty { display: none; }
.recipe-comments-feedback.is-pending { color: #8a5a00; }
.recipe-comments-feedback.is-published { color: #25683d; }


/* ==========================================================
   Emoji picker
   ========================================================== */

.recipe-comment-form-footer {
    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    gap:
        12px;

    margin-top:
        10px;
}


.recipe-comment-form-tools {
    display:
        flex;

    align-items:
        center;

    gap:
        10px;

    min-width:
        0;
}


.recipe-comment-emoji {
    position:
        relative;

    flex:
        0 0 auto;
}


.recipe-comment-emoji-toggle {
    display:
        inline-grid;

    place-items:
        center;

    width:
        38px;

    height:
        38px;

    padding:
        0;

    border:
        1px solid rgba(198, 95, 61, .18);

    border-radius:
        12px;

    color:
        #5a4337;

    background:
        #fff8f1;

    cursor:
        pointer;

    font-size:
        20px;

    line-height:
        1;

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


.recipe-comment-emoji-toggle:hover,
.recipe-comment-emoji.is-open
.recipe-comment-emoji-toggle {
    border-color:
        rgba(198, 95, 61, .48);

    background:
        #ffeadf;
}


.recipe-comment-emoji-toggle:active {
    transform:
        scale(.96);
}


.recipe-comment-emoji-panel {
    position:
        absolute;

    left:
        0;

    bottom:
        calc(100% + 9px);

    z-index:
        30;

    display:
        grid;

    grid-template-columns:
        repeat(6, 38px);

    gap:
        5px;

    width:
        max-content;

    max-width:
        min(300px, calc(100vw - 36px));

    padding:
        10px;

    overflow-y:
        auto;

    border:
        1px solid rgba(168, 108, 71, .22);

    border-radius:
        16px;

    background:
        rgba(255, 253, 249, .98);

    box-shadow:
        0 18px 42px rgba(83, 55, 37, .18);

    backdrop-filter:
        blur(12px);
}


.recipe-comment-emoji-panel[hidden] {
    display:
        none;
}


.recipe-comment-emoji-item {
    display:
        grid;

    place-items:
        center;

    width:
        38px;

    height:
        38px;

    padding:
        0;

    border:
        0;

    border-radius:
        10px;

    background:
        transparent;

    cursor:
        pointer;

    font-size:
        21px;

    line-height:
        1;
}


.recipe-comment-emoji-item:hover,
.recipe-comment-emoji-item:focus-visible {
    background:
        #ffeadf;

    outline:
        none;
}


.recipe-comment-form-hint {
    color:
        var(--comment-muted);

    font-size:
        13px;
}


@media (max-width: 640px) {

    .recipe-comment-form-footer {
        align-items:
            stretch;

        flex-direction:
            column;

        gap:
            9px;
    }


    .recipe-comment-form-tools {
        justify-content:
            space-between;
    }


    .recipe-comment-submit {
        width:
            100%;
    }


    .recipe-comment-emoji-panel {
        position:
            fixed;

        left:
            50%;

        right:
            auto;

        bottom:
            max(
                18px,
                env(safe-area-inset-bottom)
            );

        transform:
            translateX(-50%);

        grid-template-columns:
            repeat(6, minmax(36px, 42px));

        justify-content:
            center;

        width:
            calc(100vw - 28px);

        max-width:
            360px;

        max-height:
            48vh;
    }
}

/* ==========================================================
   Recipe owner badge — mobile visibility contract
   ========================================================== */

/*
 * Legacy app.css hides the recipe-author badge on narrow screens.
 * The modern comments module intentionally overrides that behavior:
 *
 *   native recipe      -> "Автор рецепта"
 *   external-source    -> "Опубликовал"
 *
 * This identity marker is meaningful discussion context and should
 * remain visible on phones.
 */
@media (max-width: 520px) {
    .recipe-comments-section .recipe-comment-author-badge {
        display: inline-flex;
        align-items: center;
        flex: 0 0 auto;
    }
}
