/**
 * cn-comments — frontend styles
 * v0.2.16
 */

.cn-comments {
	margin: 32px 0;
	/* Pas de font-family imposée : on hérite de la typo du thème (cn-theme).
	   Les contrôles de formulaire suivent via `font: inherit`. (v0.2.16) */
}

.cn-comments-title {
	/* Hérite de la police de titres du thème ; on ne fixe que taille,
	   couleur et marge propres au widget. (v0.2.16) */
	font-size: 22px;
	color: #0F2845;
	margin: 0 0 20px;
}

/* ---------- Formulaire ---------- */

.cn-comments-form {
	background: #FAF7F0;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 16px;
	margin-bottom: 24px;
}

.cn-comments-pseudo {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
	font-size: 13px;
	color: #555;
}

.cn-comments-pseudo-label {
	font-weight: 500;
}

.cn-comments-pseudo-select {
	background: #fff;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 5px 8px;
	font: inherit;
	font-size: 13px;
	color: #0F2845;
	min-width: 200px;
}

.cn-comments-form textarea {
	width: 100%;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 10px;
	font: inherit;
	font-size: 14px;
	resize: vertical;
	min-height: 80px;
	box-sizing: border-box;
}

.cn-comments-form-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 10px;
	flex-wrap: wrap;
}

.cn-comments-submit {
	padding: 8px 20px;
	background: #0F2845;
	color: #FAF7F0;
	border: none;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
.cn-comments-submit:hover { background: #1a3a5e; }
.cn-comments-submit:disabled { opacity: 0.7; cursor: not-allowed; }

.cn-comments-submit-spinner {
	display: none;
	width: 12px;
	height: 12px;
	border: 2px solid rgba(250, 247, 240, 0.3);
	border-top-color: #FAF7F0;
	border-radius: 50%;
	animation: cn-comments-spin 0.7s linear infinite;
}

.cn-comments-submit.is-loading .cn-comments-submit-spinner {
	display: inline-block;
}

@keyframes cn-comments-spin {
	to { transform: rotate(360deg); }
}

/* Zone d'erreur inline dans le form (v0.2.2 — remplace les toasts) */
.cn-comments-form-error {
	display: none;
	margin: 10px 0 0;
	padding: 8px 12px;
	background: #fcf0f0;
	border-left: 3px solid #a83232;
	color: #7a2424;
	font-size: 13px;
	border-radius: 0 4px 4px 0;
}
.cn-comments-form-error.is-visible {
	display: block;
}

.cn-comments-cancel {
	padding: 8px 16px;
	background: transparent;
	color: #555;
	border: 1px solid #ccc;
	border-radius: 4px;
	font-size: 13px;
	cursor: pointer;
}
.cn-comments-cancel:hover { background: #f5f5f5; color: #1a1a1a; }

.cn-comments-hint {
	font-size: 12px;
	color: #666;
	margin: 0;
}

.cn-comments-login-notice {
	background: #f5f5f5;
	border-left: 3px solid #C4A052;
	padding: 12px 16px;
	font-size: 14px;
	color: #555;
	margin-bottom: 20px;
}

.cn-comments-empty {
	color: #999;
	font-style: italic;
	text-align: center;
	padding: 24px;
}

/* ---------- Commentaire ---------- */

.cn-comment {
	background: #fff;
	border: 1px solid #e6e6e6;
	border-radius: 6px;
	padding: 14px 16px;
	margin-bottom: 12px;
}

.cn-comment-own {
	border-left: 3px solid #C4A052;
}

.cn-comment-pending_ai,
.cn-comment-pending_admin,
.cn-comment-absorbed {
	background: #faf9f5;
	opacity: 0.92;
}

.cn-comment-rejected {
	background: #fcf0f0;
	border-color: #f4caca;
}

.cn-comment-meta {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 12px;
	color: #666;
	margin-bottom: 8px;
	flex-wrap: wrap;
}

.cn-comment-author {
	font-weight: 600;
	color: #0F2845;
}

.cn-comment-edited {
	font-size: 11px;
	font-style: italic;
	color: #888;
}

.cn-comment-pending-edit-marker {
	font-size: 11px;
	color: #d97706;
	background: #fff7e6;
	padding: 2px 6px;
	border-radius: 3px;
}

.cn-comment-status {
	font-style: italic;
	color: #C4A052;
}

.cn-comment-date {
	margin-left: auto;
	font-size: 11px;
	color: #888;
}

.cn-comment-body {
	font-size: 14px;
	line-height: 1.5;
	color: #1a1a1a;
}

.cn-comment-body p {
	margin: 0 0 8px;
}
.cn-comment-body p:last-child {
	margin-bottom: 0;
}

/* ---------- Actions (votes + controls) ---------- */

.cn-comment-actions {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px dashed #eaeaea;
	flex-wrap: wrap;
}

.cn-comment-votes {
	display: flex;
	align-items: center;
	gap: 4px;
}

.cn-vote {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: transparent;
	border: 1px solid #d8d8d8;
	border-radius: 4px;
	padding: 4px 9px;
	font-size: 12px;
	color: #555;
	cursor: pointer;
	transition: background 0.12s, border-color 0.12s, color 0.12s;
	font: inherit;
	font-size: 12px;
}

.cn-vote:hover:not(:disabled) {
	background: #fafafa;
	border-color: #aaa;
}

.cn-vote:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.cn-vote-icon {
	font-size: 10px;
	line-height: 1;
}

.cn-vote-up.is-active {
	background: #ecf7ed;
	border-color: #46b450;
	color: #1f7a2a;
}

.cn-vote-down.is-active {
	background: #fdf1f1;
	border-color: #d63638;
	color: #a02324;
}

.cn-vote-count {
	font-variant-numeric: tabular-nums;
	min-width: 12px;
	text-align: right;
}

/* ---------- Edit controls ---------- */

.cn-comment-own-controls {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
	flex-wrap: wrap;
	font-size: 12px;
}

.cn-comment-btn {
	background: transparent;
	border: 1px solid #d8d8d8;
	border-radius: 4px;
	padding: 4px 10px;
	font-size: 12px;
	color: #555;
	cursor: pointer;
}
.cn-comment-btn:hover:not(:disabled) { background: #f5f5f5; color: #1a1a1a; }
.cn-comment-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cn-comment-edit-btn { color: #0F2845; }
.cn-comment-delete-btn { color: #a83232; }
.cn-comment-delete-btn:hover { background: #fdf1f1; }

.cn-comment-edit-info {
	font-size: 11px;
	color: #888;
	font-style: italic;
}

/* ---------- Edit-in-place form ---------- */

.cn-comment-editor {
	margin-top: 8px;
	background: #fff;
	border: 1px solid #C4A052;
	border-radius: 4px;
	padding: 10px;
}

.cn-comment-editor textarea {
	width: 100%;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 8px;
	font: inherit;
	font-size: 13px;
	resize: vertical;
	min-height: 70px;
	box-sizing: border-box;
}

.cn-comment-editor-actions {
	display: flex;
	gap: 8px;
	margin-top: 8px;
	align-items: center;
}

.cn-comment-editor-actions .cn-comments-submit { padding: 6px 14px; font-size: 13px; }
.cn-comment-editor-actions .cn-comments-cancel { padding: 6px 12px; font-size: 13px; }

.cn-comment-editor-error {
	display: none;
	margin: 8px 0 0;
	padding: 6px 10px;
	background: #fcf0f0;
	border-left: 3px solid #a83232;
	color: #7a2424;
	font-size: 12px;
	border-radius: 0 4px 4px 0;
}
.cn-comment-editor-error.is-visible {
	display: block;
}

/* ============================================================ */
/* v0.2.11 — Photo optionnelle de l'auteur sur les commentaires */
/* ============================================================ */

/* ---------- Avatar dans la liste de commentaires ---------- */

.cn-comment-avatar {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	color: #fff;
	user-select: none;
}

.cn-comment-avatar--photo {
	object-fit: cover;
	background: #eee;
}

/* Fallback : icône « utilisateur » générique (pas d'initiale). v0.2.13 */
.cn-comment-avatar--icon {
	background: #E6E1D6;
	color: #8A8475;
}
.cn-comment-avatar-glyph {
	width: 20px;
	height: 20px;
	display: block;
}

/* Le bloc méta est déjà en flex ; l'avatar reste à gauche, le nom suit,
   la date est poussée à droite (margin-left:auto déjà en place). */

/* ---------- Toggle « afficher ma photo » (formulaire + éditeur) ---------- */

.cn-comments-avatar-toggle {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
	font-size: 13px;
	color: #555;
}

.cn-comments-avatar-preview {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	background: #eee;
	border: 1px solid #e0d9c8;
}

/* Switch accessible : vrai checkbox masqué visuellement mais focusable,
   piste + pastille décoratives pilotées par :checked / :focus-visible. */
.cn-comments-switch {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.cn-comments-switch-input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.cn-comments-switch-track {
	position: relative;
	flex: 0 0 auto;
	width: 38px;
	height: 22px;
	border-radius: 11px;
	background: #cfcabd;
	transition: background-color .18s ease;
}

.cn-comments-switch-thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
	transition: transform .18s ease;
}

.cn-comments-switch-input:checked + .cn-comments-switch-track {
	background: #C4A052;
}
.cn-comments-switch-input:checked + .cn-comments-switch-track .cn-comments-switch-thumb {
	transform: translateX(16px);
}

.cn-comments-switch-input:focus-visible + .cn-comments-switch-track {
	outline: 2px solid #0F2845;
	outline-offset: 2px;
}

.cn-comments-switch-text {
	font-weight: 500;
}

/* ============================================================ */
/* v0.2.12 — Toggle photo sur la ligne du sélecteur de nom      */
/* ============================================================ */

/* Ligne « identité » : sélecteur de nom à gauche, toggle photo à droite.
   flex-wrap pour passer le toggle sous le sélecteur sur petits écrans. */
.cn-comments-identity {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
	margin-bottom: 10px;
}

/* Dans la ligne identité, les blocs ne portent plus leur marge propre
   (gérée par .cn-comments-identity). Le toggle suit directement le
   sélecteur de nom (gap de la ligne), il n'est PAS poussé à droite. */
.cn-comments-identity .cn-comments-pseudo,
.cn-comments-identity .cn-comments-avatar-toggle {
	margin-bottom: 0;
}

/* État « sans photo » : aperçu grisé. */
.cn-comments-avatar-toggle.is-photo-off .cn-comments-avatar-preview {
	filter: grayscale(1);
	opacity: 0.45;
}
