/* ==========================================================================
   Комментарии-мессенджер
   ========================================================================== */

.mg-cmt {
	margin: clamp(2rem, 4vw, 3rem) 0 0;
	padding-top: clamp(1.6rem, 3vw, 2.4rem);
	border-top: 1px solid var(--mg-line);
}

.mg-cmt__head { margin-bottom: 1.2rem; }

.mg-cmt__title {
	display: flex;
	align-items: center;
	gap: .6rem;
	margin: 0 0 .35rem;
	font-family: var(--mg-serif);
	font-weight: 400;
	font-size: clamp(1.35rem, 2.4vw, 1.75rem);
	color: var(--mg-cream);
}

.mg-cmt__count {
	display: inline-grid;
	place-items: center;
	min-width: 1.6rem;
	height: 1.6rem;
	padding: 0 .4rem;
	background: rgba(212, 162, 78, .14);
	border: 1px solid var(--mg-line-gold);
	border-radius: 999px;
	font-family: var(--mg-sans);
	font-size: .72rem;
	letter-spacing: .04em;
	color: var(--mg-gold-soft);
}

.mg-cmt__sub {
	margin: 0;
	font-family: var(--mg-sans);
	font-size: .8rem;
	color: var(--mg-muted);
}

/* ---------- замок для гостей ---------- */

.mg-cmt__locked {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .5rem;
	padding: 2.2rem 1.4rem;
	border: 1px solid var(--mg-line);
	border-radius: 2px;
	background:
		radial-gradient(70% 120% at 50% 0%, rgba(212, 162, 78, .07), transparent 70%),
		rgba(16, 13, 10, .5);
	text-align: center;
}

.mg-cmt__locked-icon .mg-lock {
	width: 22px;
	height: 22px;
	color: var(--mg-gold);
}

.mg-cmt__locked-title {
	margin: 0;
	font-family: var(--mg-serif);
	font-size: 1.2rem;
	color: var(--mg-cream);
}

.mg-cmt__locked-text {
	max-width: 44ch;
	margin: 0 0 .7rem;
	font-size: .9rem;
	line-height: 1.6;
	color: var(--mg-muted);
}

/* ---------- лента сообщений ---------- */

.mg-cmt__thread {
	max-height: 560px;
	overflow-y: auto;
	padding: .4rem .2rem 1rem;
	scrollbar-width: thin;
}

.mg-cmt__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: .9rem;
}

.mg-cmt__empty {
	margin: 0;
	padding: .6rem 0;
	font-family: var(--mg-serif);
	font-size: 1rem;
	color: var(--mg-muted);
	text-align: center;
}

/* ---------- сообщение ---------- */

.mg-msg {
	display: grid;
	grid-template-columns: 34px minmax(0, 1fr);
	gap: .7rem;
	align-items: start;
	max-width: 92%;
}

.mg-msg__avatar {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--mg-surface-2);
	border: 1px solid var(--mg-line);
	font-family: var(--mg-serif);
	font-size: .95rem;
	color: var(--mg-gold-soft);
	text-transform: uppercase;
}

.mg-msg__body {
	min-width: 0;
	justify-self: start;
	padding: .65rem .85rem .7rem;
	border: 1px solid var(--mg-line);
	border-radius: 2px 12px 12px 12px;
	background: rgba(20, 17, 13, .62);
}

.mg-msg__top {
	display: flex;
	align-items: baseline;
	gap: .5rem;
	margin-bottom: .25rem;
}

.mg-msg__name {
	font-family: var(--mg-sans);
	font-size: .74rem;
	letter-spacing: .05em;
	color: var(--mg-cream);
}

.mg-msg__time {
	font-family: var(--mg-sans);
	font-size: .64rem;
	color: var(--mg-muted);
	font-variant-numeric: tabular-nums;
}

.mg-msg__text {
	font-size: .93rem;
	line-height: 1.55;
	color: var(--mg-text);
	overflow-wrap: anywhere;
}

.mg-msg__text p { margin: 0 0 .5rem; }
.mg-msg__text p:last-child { margin-bottom: 0; }

/* своё сообщение — справа */

.mg-msg--me {
	grid-template-columns: minmax(0, 1fr) 34px;
	margin-left: auto;
	text-align: left;
}

.mg-msg--me .mg-msg__avatar { order: 2; }

.mg-msg--me .mg-msg__body {
	order: 1;
	justify-self: end;
	border-color: var(--mg-line-gold);
	border-radius: 12px 2px 12px 12px;
	background: linear-gradient(180deg, rgba(212, 162, 78, .12), rgba(20, 17, 13, .6));
}

/* вложения */

.mg-msg__images {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	margin-top: .5rem;
}

.mg-msg__image {
	display: block;
	width: 128px;
	height: 96px;
	overflow: hidden;
	border-radius: 2px;
	border: 1px solid var(--mg-line);
}

.mg-msg__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.mg-msg__audio {
	display: flex;
	align-items: center;
	gap: .7rem;
	margin-top: .55rem;
	padding: .4rem .5rem;
	border: 1px solid var(--mg-line);
	border-radius: 2px;
	background: rgba(10, 8, 6, .35);
}

/* ---------- форма ---------- */

.mg-composer {
	position: relative;
	margin-top: .6rem;
	padding: .5rem .6rem .6rem;
	border: 1px solid var(--mg-line);
	border-radius: 16px;
	background: rgba(20, 17, 13, .7);
	transition: border-color .2s ease;
}

.mg-composer:focus-within { border-color: var(--mg-line-gold); }

.mg-composer.is-sending { opacity: .7; pointer-events: none; }

.mg-composer__row {
	display: flex;
	align-items: flex-end;
	gap: .35rem;
}

.mg-composer__icon {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	flex: none;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 50%;
	color: var(--mg-muted);
	cursor: pointer;
	transition: color .18s ease, background .18s ease;
}

.mg-composer__icon:hover { color: var(--mg-gold-soft); background: rgba(212, 162, 78, .1); }
.mg-composer__icon svg { width: 19px; height: 19px; }
.mg-composer__icon.is-recording { color: #e2705f; }

.mg-composer__text {
	flex: 1;
	min-height: 34px;
	max-height: 180px;
	padding: .45rem .2rem;
	background: none;
	border: 0;
	color: var(--mg-cream);
	font-family: var(--mg-sans);
	font-size: .93rem;
	line-height: 1.45;
	resize: none;
}

.mg-composer__text:focus { outline: none; }
.mg-composer__text::placeholder { color: rgba(138, 129, 117, .85); }

.mg-composer__send {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	flex: none;
	padding: 0;
	background: var(--mg-gold);
	border: 0;
	border-radius: 50%;
	color: #1a1208;
	cursor: pointer;
	transition: background .2s ease, transform .15s ease;
}

.mg-composer__send:hover { background: var(--mg-gold-soft); }
.mg-composer__send:active { transform: scale(.95); }
.mg-composer__send:disabled { opacity: .5; cursor: default; }
.mg-composer__send svg { width: 18px; height: 18px; }

.mg-composer__attachments {
	display: flex;
	flex-wrap: wrap;
	gap: .45rem;
	padding: .3rem .2rem .55rem;
}

.mg-composer__attachments[hidden] { display: none; }

.mg-attach {
	position: relative;
	display: flex;
	align-items: center;
	gap: .45rem;
	height: 56px;
	padding: 0 .5rem;
	border: 1px solid var(--mg-line);
	border-radius: 8px;
	background: var(--mg-surface);
	font-family: var(--mg-sans);
	font-size: .72rem;
	color: var(--mg-muted);
}

.mg-attach img {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 6px 0 0 6px;
	margin-left: -.5rem;
}

.mg-attach__remove {
	position: absolute;
	top: -6px;
	right: -6px;
	display: grid;
	place-items: center;
	width: 18px;
	height: 18px;
	padding: 0;
	background: var(--mg-ink);
	border: 1px solid var(--mg-line-gold);
	border-radius: 50%;
	color: var(--mg-cream);
	cursor: pointer;
}

.mg-attach__remove svg { width: 7px; height: 7px; }

.mg-attach__wave {
	display: block;
	width: 26px;
	height: 14px;
	background:
		linear-gradient(to right, var(--mg-gold) 2px, transparent 2px) 0 50% / 6px 8px repeat-x;
	opacity: .8;
}

/* смайлики */

.mg-emoji {
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	gap: .15rem;
	margin-top: .5rem;
	padding: .5rem;
	border: 1px solid var(--mg-line);
	border-radius: 10px;
	background: var(--mg-surface);
}

.mg-emoji[hidden] { display: none; }

.mg-emoji__item {
	padding: .3rem 0;
	background: none;
	border: 0;
	border-radius: 6px;
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease;
}

.mg-emoji__item:hover { background: rgba(212, 162, 78, .12); }

/* запись голоса */

.mg-rec {
	display: flex;
	align-items: center;
	gap: .6rem;
	margin-top: .5rem;
	padding: .55rem .7rem;
	border: 1px solid rgba(226, 112, 95, .45);
	border-radius: 10px;
	background: rgba(226, 112, 95, .08);
	font-family: var(--mg-sans);
	font-size: .78rem;
	color: var(--mg-cream);
}

.mg-rec[hidden] { display: none; }

.mg-rec__dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #e2705f;
	animation: mg-rec-pulse 1.1s ease-in-out infinite;
}

@keyframes mg-rec-pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: .35; transform: scale(.8); }
}

.mg-rec__time { font-variant-numeric: tabular-nums; }

.mg-rec__hint { color: var(--mg-muted); }

.mg-rec__actions { margin-left: auto; display: flex; gap: .5rem; }

.mg-rec__cancel,
.mg-rec__stop {
	padding: .28rem .6rem;
	border-radius: 6px;
	font-family: var(--mg-sans);
	font-size: .72rem;
	cursor: pointer;
}

.mg-rec__cancel {
	background: none;
	border: 1px solid var(--mg-line);
	color: var(--mg-muted);
}

.mg-rec__stop {
	background: #e2705f;
	border: 1px solid #e2705f;
	color: #1a1208;
	font-weight: 600;
}

.mg-composer__status {
	min-height: 1.1em;
	margin: .45rem .35rem 0;
	font-family: var(--mg-sans);
	font-size: .72rem;
	color: var(--mg-muted);
}

.mg-composer__status.is-error { color: #e2705f; }

@media (max-width: 560px) {
	.mg-emoji { grid-template-columns: repeat(6, 1fr); }
	.mg-msg { max-width: 100%; }
	.mg-msg__image { width: 104px; height: 78px; }
}
