/* ============================================================================
   Dead Brush Comments — стилизация под палитру блога (light + dark)
   ----------------------------------------------------------------------------
   Подключается mu-plugin'ом deadbrush-comments.php после main.css темы и
   ux-polish.css. Использует те же CSS-переменные, что и ux-polish (--db-*).
   ============================================================================ */

.db-comments {
    margin: 48px 0 16px;
    padding: 28px 28px 24px;
    background: var(--db-bg-card, #ffffff);
    border: 1px solid var(--db-border, #e5e7eb);
    border-radius: 12px;
    font-family: inherit;
    color: var(--db-text, #1a1a1a);
    line-height: 1.55;
}

@media (max-width: 767px) {
    .db-comments {
        margin: 32px -8px 8px;
        padding: 20px 18px 18px;
        border-radius: 10px;
    }
}

.db-comments-title {
    margin: 0 0 20px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--db-text, #1a1a1a);
    letter-spacing: -0.01em;
}

@media (max-width: 767px) {
    .db-comments-title {
        font-size: 1.25rem;
        margin-bottom: 16px;
    }
}

/* ── Список комментариев ─────────────────────────────────────────────────── */

.db-comment-list,
.db-comment-list .children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.db-comment-list {
    margin: 0 0 28px;
}

.db-comment {
    display: block;
    padding: 0;
    margin: 0;
    border-bottom: none;
}

.db-comment-inner {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--db-border, #e5e7eb);
}

.db-comment-list > .db-comment:last-child > .db-comment-inner,
.db-comment-list > .db-comment:last-child .children > .db-comment:last-child > .db-comment-inner {
    border-bottom: none;
}

.db-comment .children {
    position: relative;
    margin-left: 24px;
    padding-left: 20px;
    border-left: 2px solid var(--db-border, #e5e7eb);
}

@media (max-width: 540px) {
    .db-comment .children {
        margin-left: 12px;
        padding-left: 14px;
    }
}

.db-comment-avatar {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
}

.db-comment-avatar img,
.db-comment-avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: block;
    background: var(--db-bg-soft, #f3f4f6);
    object-fit: cover;
}

.db-comment-avatar-img--shop {
    box-shadow: 0 0 0 2px rgba(255, 102, 0, 0.55);
}

.db-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.125rem;
    line-height: 1;
    user-select: none;
    overflow: hidden;
}

.db-avatar-initial {
    display: block;
    transform: translateY(-1px);
}

@media (max-width: 480px) {
    .db-comment-avatar,
    .db-comment-avatar img {
        width: 40px;
        height: 40px;
    }
    .db-avatar-fallback {
        font-size: 1rem;
    }
}

.db-comment-body {
    flex: 1;
    min-width: 0;
}

.db-comment-actions {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.8125rem;
}

.db-comment-actions .comment-reply-link {
    color: var(--db-text-muted, #555a63);
    text-decoration: none;
    font-weight: 600;
    transition: color .15s ease;
}

.db-comment-actions .comment-reply-link:hover {
    color: var(--db-accent, #ff6600);
}

:root[data-theme="dark"] .db-comment-inner {
    border-bottom-color: var(--db-border);
}

:root[data-theme="dark"] .db-comment .children {
    border-left-color: var(--db-border);
}

.db-comment-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 0.875rem;
}

.db-comment-author {
    font-weight: 700;
    color: var(--db-text, #1a1a1a);
}

.db-comment-date {
    color: var(--db-text-muted, #555a63);
    font-size: 0.8125rem;
}

.db-comment-text {
    color: var(--db-text, #1a1a1a);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.db-comment-text p {
    margin: 0 0 8px;
}

.db-comment-text p:last-child {
    margin-bottom: 0;
}

.db-comment-text a {
    color: var(--db-accent, #ff6600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.db-comment-text a:hover {
    color: var(--db-accent-hover, #ff7700);
}

.db-comment-pending {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px;
    background: rgba(255, 102, 0, 0.12);
    color: var(--db-accent, #ff6600);
    font-size: 0.8125rem;
    font-style: normal;
    border-radius: 4px;
}

.db-comment-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.db-comment-badge--customer {
    background: rgba(255, 102, 0, 0.12);
    color: var(--db-accent, #ff6600);
}

.db-comment-badge--customer::before {
    content: "🛍";
    font-size: 0.85em;
}

.db-comment-badge--customer:hover {
    background: rgba(255, 102, 0, 0.2);
    color: var(--db-accent, #ff6600);
}

:root[data-theme="dark"] .db-comment-badge--customer {
    background: rgba(255, 102, 0, 0.2);
}

/* ── Форма ───────────────────────────────────────────────────────────────── */

.db-comment-form-wrap {
    padding-top: 8px;
    border-top: 1px solid var(--db-border, #e5e7eb);
}

#comments .comment-respond {
    padding-top: 16px;
}

#comments .comment-reply-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 14px;
    color: var(--db-text, #1a1a1a);
}

#comments .comment-reply-title small {
    margin-left: 8px;
    font-size: 0.8125rem;
    font-weight: 400;
}

#comments .comment-reply-title small a {
    color: var(--db-accent, #ff6600);
    text-decoration: underline;
}

.db-comment-notes {
    margin: 0 0 18px;
    font-size: 0.8125rem;
    color: var(--db-text-muted, #555a63);
    line-height: 1.45;
}

.db-comment-form__inner {
    display: block;
}

#comments .comment-form-author,
#comments .comment-form-email,
.db-comment-field {
    margin: 0 0 14px;
}

#comments .comment-form-author,
#comments .comment-form-email {
    display: inline-block;
    width: calc(50% - 6px);
    vertical-align: top;
}

#comments .comment-form-author {
    margin-right: 10px;
}

@media (max-width: 540px) {
    #comments .comment-form-author,
    #comments .comment-form-email {
        display: block;
        width: 100%;
        margin-right: 0;
    }
}

#comments .comment-form label,
.db-comment-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--db-text, #1a1a1a);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#comments .comment-form input[type="text"],
#comments .comment-form input[type="email"],
#comments .comment-form textarea,
.db-comment-form__inner input[type="text"],
.db-comment-form__inner input[type="email"],
.db-comment-form__inner textarea,
form#commentform input[type="text"],
form#commentform input[type="email"],
form#commentform textarea {
    width: 100% !important;
    padding: 11px 14px !important;
    background: #ffffff !important;
    border: 1px solid #c5cbd3 !important;
    border-radius: 8px !important;
    font-family: inherit !important;
    font-size: 0.9375rem !important;
    color: var(--db-text, #1a1a1a) !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04) !important;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease !important;
    display: block !important;
    height: auto !important;
    outline: 0;
}

#comments .comment-form input[type="text"]:hover,
#comments .comment-form input[type="email"]:hover,
#comments .comment-form textarea:hover,
.db-comment-form__inner input[type="text"]:hover,
.db-comment-form__inner input[type="email"]:hover,
.db-comment-form__inner textarea:hover {
    border-color: #9aa3af !important;
}

#comments .comment-form input[type="text"]:focus,
#comments .comment-form input[type="email"]:focus,
#comments .comment-form textarea:focus,
.db-comment-form__inner input[type="text"]:focus,
.db-comment-form__inner input[type="email"]:focus,
.db-comment-form__inner textarea:focus {
    outline: none !important;
    border-color: var(--db-accent, #ff6600) !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.18) !important;
}

#comments .comment-form input[type="text"]::placeholder,
#comments .comment-form input[type="email"]::placeholder,
#comments .comment-form textarea::placeholder {
    color: #9aa3af;
}

#comments .comment-form textarea {
    resize: vertical;
    min-height: 120px;
}

.db-required {
    color: var(--db-accent, #ff6600);
}

#comments .form-submit {
    margin: 4px 0 0;
}

.db-comment-submit,
#comments .submit {
    display: inline-block;
    padding: 12px 28px;
    background: var(--db-accent, #ff6600);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}

.db-comment-submit:hover,
#comments .submit:hover {
    background: var(--db-accent-hover, #ff7700);
}

.db-comment-submit:active,
#comments .submit:active {
    transform: translateY(1px);
}

.db-comment-submit:focus-visible,
#comments .submit:focus-visible {
    outline: 2px solid var(--db-accent, #ff6600);
    outline-offset: 3px;
}

/* ── Honeypot — гарантированно невидимый ─────────────────────────────────── */

.db-honeypot,
.db-honeypot * {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── Закрытые комменты ───────────────────────────────────────────────────── */

.db-comments-closed {
    margin: 12px 0 0;
    padding: 16px 18px;
    background: var(--db-bg-soft, #f3f4f6);
    border-radius: 8px;
    font-size: 0.9375rem;
    color: var(--db-text-muted, #555a63);
    text-align: center;
}

/* ── Dark theme override ─────────────────────────────────────────────────── */

:root[data-theme="dark"] .db-comments {
    background: var(--db-bg-card);
    border-color: var(--db-border);
}

:root[data-theme="dark"] .db-comment-pending {
    background: rgba(255, 102, 0, 0.18);
}

:root[data-theme="dark"] #comments .comment-form input[type="text"],
:root[data-theme="dark"] #comments .comment-form input[type="email"],
:root[data-theme="dark"] #comments .comment-form textarea {
    background: #1a1f2a !important;
    border-color: #3a4150 !important;
    color: var(--db-text) !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25) !important;
}

:root[data-theme="dark"] #comments .comment-form input[type="text"]:hover,
:root[data-theme="dark"] #comments .comment-form input[type="email"]:hover,
:root[data-theme="dark"] #comments .comment-form textarea:hover {
    border-color: #525a6b;
}

:root[data-theme="dark"] #comments .comment-form input[type="text"]:focus,
:root[data-theme="dark"] #comments .comment-form input[type="email"]:focus,
:root[data-theme="dark"] #comments .comment-form textarea:focus {
    background: #1f2532;
    border-color: var(--db-accent, #ff6600);
    box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.25);
}

:root[data-theme="dark"] #comments .comment-form input[type="text"]::placeholder,
:root[data-theme="dark"] #comments .comment-form input[type="email"]::placeholder,
:root[data-theme="dark"] #comments .comment-form textarea::placeholder {
    color: #6b7280;
}

:root[data-theme="dark"] .db-comment-avatar img {
    background: var(--db-bg);
}
