/* Обсуждения под переводом и главами (views/discussion/_thread.php). Только переменные темы из nb.css.
 * Префикс .nb-d- — чтобы не пересекаться со старыми .comment/.comments из v3.css. */

.nb-discussion { scroll-margin-top: 84px; min-width: 0; }
.nb-discussion [hidden] { display: none !important; }

/* ------------------------------------------------------------ шапка */
.nb-d-head {
	display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
	padding-bottom: 12px; margin-bottom: 18px; border-bottom: 1px solid var(--border);
}
.nb-d-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 19px; letter-spacing: -0.02em; }
.nb-d-title::before { content: ""; width: 3px; height: 17px; border-radius: 2px; background: var(--primary); }
.nb-d-count { color: var(--muted-foreground); font-weight: 450; font-size: 15px; font-variant-numeric: tabular-nums; }

.nb-d-sorts { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.nb-d-sorts a {
	padding: 5px 11px; font-size: 12.5px; font-weight: 550; color: var(--muted-foreground);
	transition: background .15s, color .15s;
}
.nb-d-sorts a + a { border-left: 1px solid var(--border); }
.nb-d-sorts a:hover { background: var(--muted); color: var(--foreground); text-decoration: none; }
.nb-d-sorts a.on { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }

/* ------------------------------------------------------------ форма */
.nb-d-composer { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 26px; }
.nb-d-composer > .nb-d-form { flex: 1; min-width: 0; }
.nb-d-form { margin: 0; }
.nb-d-box {
	border: 1px solid var(--input); border-radius: var(--radius); background: var(--card-solid);
	overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.nb-d-box:focus-within { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 18%, transparent); }
.nb-d-box textarea, .nb-d-box textarea:focus {
	display: block; width: 100%; max-width: none; min-height: 76px; margin: 0; box-sizing: border-box;
	border: 0 !important; border-radius: 0; box-shadow: none !important; outline: none !important;
	background: transparent; color: var(--foreground); padding: 10px 12px; resize: vertical;
	font: 400 14.5px/1.6 var(--font-sans);
}
.nb-d-form[data-mode="reply"] .nb-d-box textarea, .nb-d-form[data-mode="edit"] .nb-d-box textarea { min-height: 60px; }
/* редактор NbEditor внутри нашей рамки — без второй рамки */
.nb-d-box .nbed { border: 0; border-radius: 0; box-shadow: none !important; background: transparent; }
.nb-d-box .nbed-bar { border-radius: 0; }

.nb-d-bar {
	display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap;
	padding: 6px 8px 6px 12px; border-top: 1px solid var(--border); background: var(--muted);
}
.nb-d-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; font-weight: 550; color: var(--foreground); cursor: pointer; user-select: none; }
.nb-d-check input { margin: 0; width: 14px; height: 14px; accent-color: var(--primary); }
.nb-d-hint { font-size: 11.5px; color: var(--muted-foreground); }
.nb-d-box:has(.nbed) .nb-d-hint-submit { display: none; } /* редактор показывает свою подсказку про Ctrl+Enter */
.nb-d-counter { font-size: 11.5px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.nb-d-counter.is-over { color: var(--destructive); font-weight: 650; }
.nb-d-form.is-busy { opacity: .7; pointer-events: none; }
@media (max-width: 640px) { .nb-d-hint { display: none; } }

.nb-d-quote-pending { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 8px; }
.nb-d-quote-pending .nb-d-quote { flex: 1; margin: 0; }
.nb-d-quote-pending .nb-icon-btn { width: 30px; height: 30px; }

.nb-d-gate {
	display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; text-align: center;
	margin: 0 0 26px; padding: 18px 16px; border: 1px dashed var(--border); border-radius: var(--radius-lg);
	color: var(--muted-foreground); font-size: 13.5px;
}
.nb-d-gate a { font-weight: 600; }

/* ------------------------------------------------------------ комментарий */
.nb-d { position: relative; min-width: 0; scroll-margin-top: 96px; }
.nb-d-list > .nb-d, .nb-d-list > .nb-d-linked { padding: 16px 0; }
.nb-d-list > .nb-d:first-child, .nb-d-list > .nb-d-linked:first-child { padding-top: 0; }
.nb-d-list > .nb-d + .nb-d, .nb-d-list > .nb-d-linked + .nb-d { border-top: 1px solid var(--border); }

.nb-d-main { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--radius-lg); transition: background-color .6s; }
.nb-d-ava { flex: none; display: block; line-height: 0; }
.nb-d-ava:hover { text-decoration: none; }
.nb-d-ava .nb-avatar { width: 34px; height: 34px; font-size: 13.5px; }
.nb-d-replies .nb-d-ava .nb-avatar { width: 28px; height: 28px; font-size: 12px; }
.nb-d-composer .nb-d-ava .nb-avatar { width: 34px; height: 34px; }
.nb-d-content { flex: 1; min-width: 0; }

.nb-d-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; font-size: 12px; color: var(--muted-foreground); line-height: 1.5; }
.nb-d-user { font-size: 13.5px; font-weight: 650; color: var(--foreground); }
.nb-d-user:hover { color: var(--foreground); }
.nb-d-user.is-gone { color: var(--muted-foreground); font-weight: 500; font-style: italic; }
.nb-d-badge { font-size: 10.5px; padding: 0 7px; line-height: 1.7; }
.nb-d-time, .nb-d-edited { color: var(--muted-foreground); font-size: 12px; }
.nb-d-time:hover { color: var(--foreground); }
.nb-d-replyto { display: inline-flex; align-items: center; gap: 4px; }
.nb-d-replyto a { color: var(--muted-foreground); font-weight: 600; }
.nb-d-replyto a:hover { color: var(--foreground); }
.nb-d-newchip {
	font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1.8;
	padding: 0 7px; border-radius: var(--radius-pill); color: var(--success); background: color-mix(in oklab, var(--success) 15%, transparent);
}

/* новые с прошлого визита и ссылка на комментарий */
.nb-d.is-new > .nb-d-main { box-shadow: inset 3px 0 0 color-mix(in oklab, var(--success) 70%, transparent); padding-left: 10px; }
.nb-d.is-target > .nb-d-main, .nb-d.is-fresh > .nb-d-main { animation: nb-d-flash 2.6s ease-out 1; }
@keyframes nb-d-flash {
	0%, 35% { background: color-mix(in oklab, var(--primary) 9%, transparent); box-shadow: 0 0 0 6px color-mix(in oklab, var(--primary) 9%, transparent); }
	100% { background: transparent; box-shadow: 0 0 0 6px transparent; }
}
.nb-d.is-new.is-target > .nb-d-main { box-shadow: inset 3px 0 0 color-mix(in oklab, var(--success) 70%, transparent); }

/* цитата из главы */
.nb-d-quote {
	margin: 6px 0 8px; padding: 8px 12px; border: 0; border-left: 3px solid color-mix(in oklab, var(--primary) 55%, transparent);
	border-radius: 0 var(--radius) var(--radius) 0; background: var(--muted); color: var(--foreground);
	font: italic 400 14px/1.6 var(--font-serif);
}
.nb-d-quote-lbl {
	display: block; margin-bottom: 2px; font: 700 10px/1.6 var(--font-sans); font-style: normal;
	letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground);
}

/* текст */
.nb-d-body { position: relative; margin-top: 3px; }
.nb-d-text { font-size: 14.5px; line-height: 1.62; color: var(--foreground); overflow-wrap: anywhere; }
.nb-d-text p { margin: 0 0 8px; font-size: inherit; line-height: inherit; }
.nb-d-text > :last-child { margin-bottom: 0; }
.nb-d-text blockquote {
	margin: 4px 0 8px; padding: 1px 0 1px 12px; border-left: 3px solid var(--border);
	color: var(--muted-foreground); font-size: inherit; line-height: inherit;
}
.nb-d-text blockquote p { font-size: inherit; line-height: inherit; font-weight: inherit; margin: 0; }
.nb-d-text a { color: var(--link); }

/* ||спойлер|| внутри текста */
.nb-d-sp {
	background: var(--foreground); color: transparent; border-radius: var(--radius-sm); padding: 0 2px;
	cursor: pointer; transition: background .2s, color .2s; box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.nb-d-sp a { color: transparent; pointer-events: none; }
.nb-d-sp:hover { background: color-mix(in oklab, var(--foreground) 82%, transparent); }
.nb-d-sp.on { background: var(--secondary); color: inherit; cursor: text; }
.nb-d-sp.on a { color: var(--link); pointer-events: auto; }

/* весь комментарий — спойлер */
.nb-d-body.is-spoiler { min-height: 44px; }
.nb-d-body.is-spoiler .nb-d-text { filter: blur(7px); user-select: none; pointer-events: none; max-height: 6.5em; overflow: hidden; opacity: .75; }
.nb-d-spoiler-cover {
	position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
	width: 100%; padding: 6px 12px; border: 1px dashed color-mix(in oklab, var(--foreground) 22%, transparent); border-radius: var(--radius);
	background: color-mix(in oklab, var(--card-solid) 45%, transparent); color: var(--foreground);
	font: 600 12.5px/1.3 var(--font-sans); cursor: pointer;
}
.nb-d-spoiler-cover:hover { background: color-mix(in oklab, var(--card-solid) 25%, transparent); }
.nb-d-body.is-spoiler.is-revealed .nb-d-text { filter: none; user-select: auto; pointer-events: auto; max-height: none; opacity: 1; }
.nb-d-body.is-spoiler.is-revealed .nb-d-spoiler-cover { display: none; }

/* действия */
.nb-d-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 6px 0 0 -7px; }
.nb-d-act {
	display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; box-sizing: border-box;
	border: 0; border-radius: var(--radius); background: transparent; box-shadow: none; color: var(--muted-foreground);
	font: 550 12px/1 var(--font-sans); cursor: pointer; transition: background .15s, color .15s;
}
.nb-d-act:hover { background: var(--muted); color: var(--foreground); }
.nb-d-act svg { flex: none; }
.nb-d-act b { font-weight: 650; font-variant-numeric: tabular-nums; }
.nb-d-act b:empty { display: none; }
.nb-d-act.is-danger:hover { color: var(--destructive); }
.nb-d-act[disabled] { cursor: default; }
.nb-d-act[disabled]:hover { background: transparent; color: var(--muted-foreground); }
.nb-d-like.on { color: var(--destructive); }
.nb-d-like.on svg { fill: currentColor; }
.nb-d-like.on:hover { color: var(--destructive); }
.nb-d-like.is-pop svg { animation: nb-d-pop .35s ease-out; }
@keyframes nb-d-pop { 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
.nb-d-report { margin-left: auto; display: inline-flex; opacity: 0; transition: opacity .15s; }
.nb-d-main:hover .nb-d-report, .nb-d-report:focus-within { opacity: 1; }
@media (hover: none) { .nb-d-report { opacity: 1; } }
.nb-d-report .nb-report-link { height: 28px; font-size: 12px; }
@media (max-width: 520px) { .nb-d-act .lbl { display: none; } .nb-d-like .lbl { display: none; } }

/* ответы */
.nb-d-replies {
	display: grid; gap: 14px; margin-top: 12px; padding-left: 18px;
	border-left: 2px solid var(--border); margin-left: 16px;
}
@media (max-width: 640px) { .nb-d-replies { padding-left: 10px; margin-left: 4px; } }
.nb-d-inline { margin-top: 10px; }
.nb-d-inline .nb-d-replying { font-size: 12px; color: var(--muted-foreground); margin: 0 0 5px; }

/* удалённый */
.nb-d.is-deleted > .nb-d-main { display: block; }
.nb-d-tomb {
	display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 12px;
	border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted-foreground); font-size: 12.5px; font-style: italic;
}

/* пусто, «ещё», ссылка на комментарий */
.nb-d-empty { text-align: center; padding: 34px 16px 18px; color: var(--muted-foreground); }
.nb-d-empty svg { opacity: .3; }
.nb-d-empty p { margin: 8px 0 0; font-size: 13.5px; }
.nb-d-more-wrap { text-align: center; margin-top: 20px; }
.nb-d-more.is-loading { opacity: .6; pointer-events: none; }
.nb-d-first { text-align: center; margin: 12px 0 0; font-size: 13px; }
.nb-d-first a { display: inline-flex; align-items: center; gap: 5px; color: var(--muted-foreground); }
.nb-d-linked { margin-bottom: 16px; padding: 12px 14px 14px !important; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.nb-d-linked-label { margin: 0 0 10px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-foreground); }
.nb-d-error { color: var(--destructive); text-align: center; font-size: 13px; }

/* цитирование выделением в тексте главы */
.nb-d-quote-btn {
	position: absolute; z-index: 1050; display: inline-flex; align-items: center; gap: 6px;
	padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-pill);
	background: var(--popover); color: var(--foreground); box-shadow: var(--elev-2);
	font: 600 12.5px/1 var(--font-sans); cursor: pointer; transform: translate(-50%, -100%);
}
.nb-d-quote-btn:hover { background: var(--card-solid); }
.nb-d-quote-btn[hidden] { display: none; }

/* _count.php */
.nb-d-countlink { gap: 5px; font-weight: 550; }
.nb-d-countlink:hover { text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
	.nb-d.is-target > .nb-d-main, .nb-d.is-fresh > .nb-d-main, .nb-d-like.is-pop svg { animation: none; }
}

/* guests (imported WordPress comments without an account) and deleted accounts: neutral letter avatar, no profile link */
.nb-d-ava .nb-avatar.is-guest { background: var(--muted); color: var(--muted-foreground); box-shadow: inset 0 0 0 1px var(--border); }
.nb-d-ava .nb-avatar.is-gone { background: var(--muted); color: var(--muted-foreground); }
.nb-d-user.is-guest { font-weight: 600; }
.nb-d-guest { background: var(--muted); color: var(--muted-foreground); }

/* ------------------------------------------------------------ touch screens and phones
   Sort tabs and Like / Reply / Edit / Delete were 28-29 px tall: on touch they grow to 38 / 36 px (desktop keeps
   the compact size). The icon of the first action still lines up with the text above it (negative left margin). */
@media (max-width: 760px), (pointer: coarse) {
	.nb-d-sorts a { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; box-sizing: border-box; }
	.nb-d-actions { gap: 0 2px; margin: 4px 0 -4px -10px; }
	.nb-d-act { height: 36px; min-width: 36px; padding: 0 10px; justify-content: center; }
	.nb-d-report .nb-report-link { height: 36px; padding: 0 8px; }
	.nb-d-quote-pending .nb-icon-btn { width: 36px; height: 36px; }
	.nb-d-check { min-height: 36px; }
	.nb-d-check input { width: 18px; height: 18px; }
	.nb-d-bar .nb-btn-sm { height: 36px; }
	.nb-d-first a { padding: 8px 4px; }
	.nb-d-spoiler-cover { min-height: 44px; }
}
