/**
 * Threaded marginalia, notification drawer, and public comment wall.
 */

/* ---------- Comment drawer thread ---------- */

.br-thread-loading {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 32px 0;
}

.br-thread-loading span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--br-brass);
    animation: br-dot-bounce 0.9s infinite ease-in-out;
}

.br-thread-loading span:nth-child(2) {
    animation-delay: 0.12s;
}

.br-thread-loading span:nth-child(3) {
    animation-delay: 0.24s;
}

@keyframes br-dot-bounce {
    0%,
    80%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

.br-thread {
    position: relative;
    padding: 14px 0;
    border-bottom: 1px solid var(--br-paper-line);
}

.br-thread:first-child {
    padding-top: 2px;
}

.br-thread:last-child {
    border-bottom: 0;
}

.br-thread-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 8px;
}

.br-thread-head .br-avatar {
    width: 30px;
    height: 30px;
}

.br-thread-meta {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.br-thread-meta strong {
    overflow: hidden;
    color: var(--br-ink);
    font-size: 0.82rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.br-thread-meta span {
    color: var(--br-muted);
    font-size: 0.68rem;
}

.br-thread-status {
    flex: 0 0 auto;
}

.br-thread-content {
    margin: 0 0 8px;
    color: var(--br-ink-soft);
    font-size: 0.87rem;
    line-height: 1.75;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.br-thread-content .br-mention {
    color: var(--br-verdigris);
    font-weight: 700;
}

.br-thread-note {
    margin: 0 0 8px;
    padding: 6px 9px;
    border-radius: 6px;
    background: rgba(176, 138, 79, 0.1);
    color: #8b642a;
    font-size: 0.7rem;
    line-height: 1.6;
}

.br-thread-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.br-thread-actions .br-text-btn {
    font-size: 0.72rem;
}

.br-thread-replies {
    margin: 10px 0 0 18px;
    padding-left: 13px;
    border-left: 1px solid var(--br-paper-line-strong);
}

.br-thread-reply {
    padding: 9px 0;
    border-bottom: 1px dashed var(--br-paper-line);
}

.br-thread-reply:last-child {
    border-bottom: 0;
}

.br-thread-reply .br-thread-content {
    margin-bottom: 5px;
    font-size: 0.82rem;
}

.br-thread-reply .br-thread-head {
    margin-bottom: 5px;
}

.br-thread-reply .br-thread-head .br-avatar {
    width: 24px;
    height: 24px;
}

.br-thread-reply .br-thread-meta strong {
    font-size: 0.76rem;
}

.br-thread-empty {
    margin: 0;
    padding: 30px 12px;
    color: var(--br-muted);
    font-size: 0.82rem;
    line-height: 1.7;
    text-align: center;
}

.br-thread-error {
    padding: 24px 12px;
    color: var(--br-danger);
    font-size: 0.8rem;
    text-align: center;
}

.br-thread-more .br-text-btn {
    color: var(--br-verdigris);
    font-weight: 700;
}

/* Inline editing */

.br-inline-edit {
    margin-top: 8px;
}

.br-inline-edit textarea {
    width: 100%;
    min-height: 76px;
    padding: 9px 11px;
    border: 1px solid var(--br-paper-line-strong);
    border-radius: 8px;
    background: #fffdf8;
    color: var(--br-ink);
    font-family: var(--br-ui);
    font-size: 0.82rem;
    line-height: 1.65;
    resize: vertical;
}

.br-inline-edit textarea:focus {
    border-color: var(--br-verdigris);
    outline: none;
}

.br-inline-edit-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 7px;
}

.br-inline-edit-actions .br-text-btn {
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(92, 76, 54, 0.07);
}

.br-inline-edit-actions .br-save-btn {
    background: var(--br-verdigris);
    color: #fff;
}

/* Compose */

.br-comment-form-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.br-comment-form-user img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.br-comment-form-user strong {
    color: var(--br-ink);
    font-size: 0.78rem;
}

.br-pending-hint {
    margin-left: auto;
    color: var(--br-muted);
    font-size: 0.65rem;
}

.br-reply-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
    padding: 5px 9px;
    border-radius: 6px;
    background: rgba(47, 107, 95, 0.08);
    color: var(--br-verdigris);
    font-size: 0.7rem;
}

.br-reply-chip button {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(47, 107, 95, 0.12);
    color: var(--br-verdigris);
    cursor: pointer;
    line-height: 1;
}

.br-comment-form textarea {
    display: block;
    width: 100%;
    min-height: 62px;
    max-height: 180px;
    padding: 10px 12px;
    border: 1px solid var(--br-paper-line-strong);
    border-radius: 10px;
    background: #fffdf8;
    color: var(--br-ink);
    font-family: var(--br-ui);
    font-size: 0.84rem;
    line-height: 1.65;
    resize: vertical;
}

.br-comment-form textarea:focus {
    border-color: var(--br-verdigris);
    box-shadow: 0 0 0 3px rgba(47, 107, 95, 0.09);
    outline: none;
}

.br-comment-form-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}

.br-comment-form-foot .br-submit-btn {
    min-height: 33px;
    padding: 6px 16px;
    font-size: 0.78rem;
}

.br-char-count.is-near {
    color: var(--br-brass);
}

.br-char-count.is-over {
    color: var(--br-danger);
    font-weight: 700;
}

.br-login-cta {
    padding: 18px;
    border: 1px dashed var(--br-paper-line-strong);
    border-radius: 12px;
    background: rgba(255, 253, 248, 0.56);
    text-align: center;
}

.br-login-cta p {
    margin: 0 0 12px;
    color: var(--br-ink-soft);
    font-size: 0.8rem;
    line-height: 1.7;
}

.br-login-cta > div {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.br-login-cta .br-primary-link {
    min-height: 34px;
    padding: 6px 18px;
    font-size: 0.8rem;
}

/* ---------- Notification drawer ---------- */

.br-notif-actions {
    flex: 0 0 auto;
    padding: 9px 24px;
    border-bottom: 1px solid var(--br-paper-line);
    text-align: right;
}

.br-notif-actions .br-text-btn {
    color: var(--br-verdigris);
    font-size: 0.72rem;
    font-weight: 700;
}

.br-notif-list {
    flex: 1 1 auto;
    overflow: hidden auto;
}

.br-notif-item {
    position: relative;
    display: block;
    padding: 14px 24px 14px 34px;
    border-bottom: 1px solid var(--br-paper-line);
    color: var(--br-ink-soft);
    font-size: 0.8rem;
    line-height: 1.65;
    text-decoration: none;
    transition: background 0.16s var(--br-ease);
}

.br-notif-item:hover {
    background: rgba(47, 107, 95, 0.05);
}

.br-notif-item.is-unread {
    background: rgba(176, 138, 79, 0.07);
}

.br-notif-item.is-unread::before {
    position: absolute;
    top: 21px;
    left: 17px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--br-danger);
    content: "";
}

.br-notif-message {
    display: block;
    margin-bottom: 4px;
    color: var(--br-ink);
}

.br-notif-time {
    display: block;
    color: var(--br-muted);
    font-size: 0.68rem;
}

.br-notif-empty {
    padding: 46px 24px;
    color: var(--br-muted);
    font-size: 0.82rem;
    text-align: center;
}

.br-notif-loading {
    padding: 40px 24px;
    color: var(--br-muted);
    font-size: 0.78rem;
    text-align: center;
}

/* ---------- Public wall ---------- */

.br-wall {
    max-width: 1180px;
    margin: 0 auto;
    padding: 46px 20px 70px;
}

.br-wall-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--br-paper-line-strong);
}

.br-wall-head h1 {
    margin: 0 0 8px;
    color: var(--br-ink);
    font-family: var(--br-serif);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.15;
}

.br-wall-head p:last-child {
    margin: 0;
    color: var(--br-muted);
    font-size: 0.85rem;
}

.br-wall-head > .br-text-link {
    flex: 0 0 auto;
    padding-bottom: 3px;
    font-weight: 700;
}

.br-wall-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 24px;
}

.br-wall-filters label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 160px;
}

.br-wall-filters label > span {
    color: var(--br-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.br-wall-filters select {
    min-width: 170px;
    height: 38px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--br-paper-line-strong);
    border-radius: 8px;
    background: #fffdf8;
    color: var(--br-ink);
    cursor: pointer;
    font-size: 0.82rem;
}

.br-wall-filters select:focus {
    border-color: var(--br-verdigris);
    outline: none;
}

.br-wall-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.br-wall-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 18px 18px 15px;
    border: 1px solid var(--br-paper-line);
    border-radius: 13px;
    background:
        linear-gradient(180deg, rgba(255, 253, 248, 0.92), rgba(249, 243, 232, 0.9));
    box-shadow: var(--br-shadow-sm);
    transition: transform 0.22s var(--br-ease), box-shadow 0.22s var(--br-ease), border-color 0.22s var(--br-ease);
}

.br-wall-card::before {
    position: absolute;
    top: 0;
    left: 18px;
    width: 28px;
    height: 2px;
    background: var(--br-brass);
    content: "";
}

.br-wall-card:hover {
    border-color: rgba(176, 138, 79, 0.42);
    box-shadow: var(--br-shadow-md);
    transform: translateY(-3px);
}

.br-wall-card-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 11px;
}

.br-wall-card-head .br-avatar {
    width: 34px;
    height: 34px;
}

.br-wall-meta {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.br-wall-meta strong {
    overflow: hidden;
    color: var(--br-ink);
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.br-wall-meta span {
    color: var(--br-muted);
    font-size: 0.66rem;
}

.br-wall-book {
    max-width: 40%;
    overflow: hidden;
    color: var(--br-verdigris);
    font-size: 0.68rem;
    font-weight: 700;
    text-overflow: ellipsis;
    text-decoration: none;
    white-space: nowrap;
}

.br-wall-book:hover {
    text-decoration: underline;
}

.br-wall-quote {
    margin: 0 0 10px;
    padding: 7px 10px;
    border-left: 2px solid var(--br-brass);
    background: rgba(176, 138, 79, 0.07);
    color: var(--br-muted);
    font-family: var(--br-serif);
    font-size: 0.74rem;
    line-height: 1.65;
}

.br-wall-content {
    flex: 1 1 auto;
    margin: 0 0 14px;
    color: var(--br-ink-soft);
    font-family: var(--br-serif);
    font-size: 0.9rem;
    line-height: 1.8;
    overflow-wrap: break-word;
}

.br-wall-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--br-paper-line);
    color: var(--br-muted);
    font-size: 0.66rem;
}

.br-wall-foot a {
    margin-left: auto;
    color: var(--br-verdigris);
    font-weight: 700;
    text-decoration: none;
}

.br-wall-foot a:hover {
    text-decoration: underline;
}

.br-wall-replies {
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(47, 107, 95, 0.08);
    color: var(--br-verdigris);
    font-size: 0.62rem;
}

.br-wall > .br-empty-state {
    grid-column: 1 / -1;
}

.br-wall .br-load-more {
    min-width: 180px;
}

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
    .br-wall-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .br-wall {
        padding: 28px 14px 52px;
    }

    .br-wall-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .br-wall-head h1 {
        font-size: 2rem;
    }

    .br-wall-grid {
        grid-template-columns: 1fr;
    }

    .br-wall-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .br-wall-filters label,
    .br-wall-filters select {
        min-width: 0;
        width: 100%;
    }

    .br-drawer-head {
        padding-right: 18px;
        padding-left: 18px;
    }

    .br-thread-replies {
        margin-left: 10px;
        padding-left: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .br-thread-loading span,
    .br-wall-card {
        animation: none !important;
        transition: none !important;
    }
}

/* 短评墙页面：短代码自带 h1，隐藏主题重复的页面标题。 */
body.br-comments-wall-page h1.wp-block-post-title,
body.br-comments-wall-page .entry-title {
    display: none;
}
