/* texs comment format — rich comment box + emoji picker.
   Every rule is scoped under #comments on purpose: Twenty Twenty-One paints any
   bare button dark via button:not(:hover):not(:active):not(.has-background)
   (specificity 0,3,1) and styles input[type=search] with a 3px border; the id
   is the cheapest thing that beats both without touching shared stylesheets.
   Colours are theme-neutral (currentColor + translucent greys) so the same
   rules work in light mode and TT1's dark mode. */

#comments .tx-rte-src { display: none !important; }

#comments .tx-rte {
	position: relative;
	margin: 0 0 1em;
	border: 1px solid rgba(128, 128, 128, .38);
	border-radius: 12px;
	background: rgba(128, 128, 128, .08);
	transition: border-color .15s, box-shadow .15s;
}
#comments .tx-rte:focus-within {
	border-color: rgba(128, 128, 128, .75);
	box-shadow: 0 0 0 3px rgba(128, 128, 128, .15);
}
#comments .tx-rte-box {
	position: relative;
	min-height: 7.5em;
	padding: 14px 18px 8px;
	outline: none;
	font-size: 1.05rem;
	line-height: 1.55;
	color: inherit;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	cursor: text;
}
#comments .tx-rte-box.is-empty::before {
	content: attr(data-placeholder);
	position: absolute;
	top: 14px;
	left: 18px;
	right: 18px;
	opacity: .5;
	pointer-events: none;
}
#comments .tx-rte-box.is-invalid { animation: tx-rte-nudge .25s; }
#comments .tx-rte:has(.is-invalid) { border-color: #d33; }
@keyframes tx-rte-nudge {
	25% { transform: translateX(-3px); }
	75% { transform: translateX(3px); }
}
#comments .tx-rte-box p { margin: 0 0 .6em; }
#comments .tx-rte-box p:last-child { margin-bottom: 0; }
#comments .tx-rte-box blockquote {
	margin: .4em 0 .8em;
	padding: .1em 0 .1em 1em;
	border-left: 3px solid rgba(128, 128, 128, .5);
	/* no font-style here: queryCommandState('italic') reads computed style, so an italic quote would report ⌘I as "on" and toggle it the wrong way */
}
/* TT1 styles blockquotes bold with a big “ before them; inside the editor keep them plain. */
#comments .tx-rte-box blockquote::before { content: none; }
#comments .tx-rte-box blockquote,
#comments .tx-rte-box blockquote p { font-weight: inherit; font-size: inherit; line-height: inherit; }
#comments .tx-rte-box blockquote p:last-child { margin-bottom: 0; }
#comments .tx-rte-box code {
	font-family: ui-monospace, Menlo, Consolas, monospace;
	font-size: .9em;
	padding: .1em .35em;
	border-radius: 4px;
	background: rgba(128, 128, 128, .18);
}
#comments .tx-rte-box a { color: inherit; }

/* ----- toolbar (inside the box, along the bottom) ----- */

#comments .tx-fmt {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px;
	margin: 0;
	padding: 6px 8px;
	border-top: 1px solid rgba(128, 128, 128, .22);
}
#comments .tx-fmt .tx-fmt-b {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	background: transparent;
	color: inherit;
	border: 0;
	border-radius: 8px;
	box-shadow: none;
	line-height: 1;
	opacity: .62;
	cursor: pointer;
	transition: opacity .12s, background-color .12s;
}
#comments .tx-fmt .tx-fmt-b svg { display: block; }
#comments .tx-fmt .tx-fmt-b:hover,
#comments .tx-fmt .tx-fmt-b:focus-visible {
	opacity: 1;
	color: inherit;
	background: rgba(128, 128, 128, .18);
}
#comments .tx-fmt .tx-fmt-b[aria-pressed="true"] {
	opacity: 1;
	color: inherit;
	background: rgba(128, 128, 128, .28);
}
#comments .tx-fmt .tx-fmt-quote { margin-left: 4px; }
#comments .tx-fmt .tx-fmt-emoji { margin-left: auto; }

/* ----- picker ----- */

#comments .tx-emo {
	position: absolute;
	top: 100%;
	right: 0;
	z-index: 20;
	width: min(340px, 100%);
	box-sizing: border-box;
	margin-top: 6px;
	padding: 8px;
	background: var(--global--color-background, #fff);
	color: inherit;
	border: 1px solid rgba(128, 128, 128, .35);
	border-radius: 10px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
	font-size: 1rem;
	font-style: normal;
	text-align: left;
}
#comments .tx-emo .tx-emo-search {
	display: block;
	width: 100%;
	box-sizing: border-box;
	margin: 0 0 6px;
	padding: .4em .7em;
	font-family: inherit;
	font-size: .9rem;
	line-height: 1.4;
	background: rgba(128, 128, 128, .1);
	color: inherit;
	border: 1px solid rgba(128, 128, 128, .3);
	border-radius: 8px;
	box-shadow: none;
}
#comments .tx-emo .tx-emo-search:focus {
	outline: none;
	border-color: rgba(128, 128, 128, .7);
}
#comments .tx-emo .tx-emo-tabs {
	display: flex;
	gap: 2px;
	margin: 0 0 4px;
}
#comments .tx-emo .tx-emo-tabs button {
	flex: 1;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 5px 0;
	background: transparent;
	color: inherit;
	border: 0;
	border-radius: 6px;
	box-shadow: none;
	font-size: 1.05rem;
	line-height: 1;
	opacity: .6;
	cursor: pointer;
	font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
#comments .tx-emo .tx-emo-tabs button:hover,
#comments .tx-emo .tx-emo-tabs button:focus-visible {
	opacity: 1;
	background: rgba(128, 128, 128, .18);
	color: inherit;
}
#comments .tx-emo .tx-emo-body {
	position: relative;
	height: 260px;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}
#comments .tx-emo .tx-emo-h {
	position: sticky;
	top: 0;
	margin: 0;
	padding: 6px 4px 2px;
	background: var(--global--color-background, #fff);
	font-family: var(--global--font-secondary, sans-serif);
	font-size: .68rem;
	font-weight: 600;
	letter-spacing: .08em;
	text-transform: uppercase;
	opacity: .55;
}
#comments .tx-emo .tx-emo-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
}
#comments .tx-emo .tx-emo-e {
	min-width: 0;
	min-height: 0;
	height: 36px;
	margin: 0;
	padding: 0;
	background: transparent;
	color: inherit;
	border: 0;
	border-radius: 6px;
	box-shadow: none;
	font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
	font-size: 1.45rem;
	line-height: 36px;
	text-align: center;
	cursor: pointer;
}
#comments .tx-emo .tx-emo-e:hover,
#comments .tx-emo .tx-emo-e:focus-visible {
	background: rgba(128, 128, 128, .18);
	color: inherit;
}
