/**
 * Stats CSS
 * Styling für Reaktionen-Seite (Likes und Kommentare)
 * Angelehnt an Feed-Layout: 560px Breite, 300px Versetzung
 */

/* Stats Container - Skeleton 3|6|3 wie Article/Feed */
.stats-container {
	max-width: 1100px;
	margin: 2rem auto 0;
	padding: 0 20px;
	padding-bottom: 30px;
}

.stats-container .feed-item {
	display: block;
	grid-template-columns: none;
	margin: 0;
	padding: 0;
}

.stats-article {
	margin-left: 0;
	margin-right: 0;
}

.stats {
	width: 100%;
	margin: 0;
	padding: 0;
}

/* stats-main overflow: visible damit Titel nach rechts ausbrechen kann */
.stats-container .feed-main,
.stats-container .six.columns {
	overflow: visible;
}

.stats-header {
	margin-bottom: 2rem;
	width: 150%; /* Breite bis in rechte Spalte (6+3 Spalten) */
	max-width: 150%;
	margin-left: 0;
	overflow: visible;
}

.stats-header .feed-page-title {
	width: 100%;
	max-width: 100%;
	margin-left: 0;
}

.stats-header-photo {
	margin-bottom: 2rem;
	width: 100%;
	margin-left: 0;
}

.stats-photo {
	margin: 0;
	width: 100%;
}

.stats-photo img {
	width: 100%;
	height: auto;
	display: block;
}

.stats-photo figcaption {
	margin-top: 0.5rem;
	font-size: 16px;
	color: var(--clr-black);
	text-align: left;
	line-height: 1.6;
}

/* Deaktiviere ::before für feed-page-title in stats.php */
.stats .feed-page-title::before,
.stats-header .feed-page-title::before {
	content: "" !important; /* Kein Slash mehr, da jetzt in den Links */
}

.stats-title-link {
	color: var(--clr-text);
	text-decoration: none;
	margin-right: 0; /* /Titel/Stats ohne Abstand */
	transition: color 0.2s ease;
	font-size: inherit; /* Gleich wie Artikel-Titel (feed-page-title: 4.2rem, responsive 2.8rem/2.2rem) */
	font-weight: 700;
	letter-spacing: -.001em;
}

.stats-title-link:hover {
	color: var(--clr-primary); /* Grün beim Mouseover (inkl. Slash) */
	text-decoration: none;
}

.stats-title-current {
	color: var(--clr-text);
	font-size: inherit;
	font-weight: inherit;
}

.stats-intro {
	margin-bottom: 1.5rem;
}

.stats-intro p {
	margin: 0;
	line-height: 1.6;
	font-size: 1rem;
	color: var(--clr-text);
}

.stats-intro .stats-syndication-link {
	color: var(--clr-primary);
	text-decoration: underline;
	text-underline-offset: 0.12em;
}

.stats-intro .stats-syndication-link:hover {
	color: var(--clr-primary);
	text-decoration: none;
}

.stats-section {
	padding-bottom: 1rem;
	width: 100%;
	margin-left: 0;
	text-align: left;
}

.stats-section h2 {
	font-size: 16px;
	font-weight: 400;
	margin-bottom: 1rem;
	color: var(--clr-black);
	text-align: left;
}

.stats-section p {
	margin-bottom: 0.75rem;
	line-height: 1.6;
	color: var(--clr-black);
	font-size: 16px;
	text-align: left;
}

.stats-section .exif-separator {
	margin-left: 0.5rem;
	margin-right: 0.5rem;
}

.stats-section a {
	/* Verwendet .lnk-tag Basis-Klasse */
}

.stats-updated {
	margin-top: 1rem;
	font-size: 16px;
	color: var(--clr-black);
}

/* Likes Section */
.stats-likes {
	padding-bottom: 1rem;
	width: 100%;
	margin-left: 0;
	text-align: left;
	display: flex;
	align-items: center;
	gap: 12px; /* 12px Abstand zwischen Mastodon und Bluesky */
}

.stats-likes-count {
	cursor: help;
	text-decoration: underline;
	text-decoration-style: dotted;
	text-underline-offset: 2px;
}

.stats-likes-platform {
	font-size: 16px;
	font-weight: 400;
	margin: 0;
	color: var(--clr-black);
	text-align: left;
	display: flex;
	align-items: center;
	gap: 5px; /* 5px Abstand zwischen Icon und Zahl */
}

.stats-comments h2 {
	font-size: 16px;
	font-weight: 400;
	margin-bottom: 1rem;
	color: var(--clr-black);
	text-align: left;
}

.stats-icon {
	width: 16px;
	height: 16px;
	filter: brightness(0) saturate(100%) invert(28%) sepia(100%) saturate(1000%) hue-rotate(90deg) brightness(0.6);
	display: block;
}

.stats-likes-list {
	list-style: none;
	padding: 0;
	margin: 0;
	text-align: left;
}

.stats-like-item {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1rem;
	padding: 0.75rem;
	background: rgba(27, 27, 27, 0.05);
	border-radius: 3px;
	text-align: left;
}

.stats-like-item .stats-avatar {
	width: 32px;
	height: 32px;
	min-width: 32px;
	min-height: 32px;
}

.stats-avatar {
	border-radius: 50%;
	flex-shrink: 0;
	object-fit: cover;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	display: block;
}

.stats-like-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	text-align: left;
}

.stats-like-info strong {
	font-weight: 400;
	color: var(--clr-black);
	font-size: 16px;
}

.stats-username {
	font-size: 16px;
	color: var(--clr-black);
}

.stats-link {
	font-size: 16px;
	color: var(--clr-text);
	text-decoration: none;
}

.stats-link:hover {
	text-decoration: underline;
}

/* Comments Section */
.stats-comments {
	margin-bottom: 1.5rem;
	width: 100%;
	margin-left: 0;
	text-align: left;
}

.stats-comments h2 {
	font-size: 16px;
	font-weight: 400;
	margin-bottom: 1.5rem;
	color: var(--clr-black);
	text-align: left;
}

.stats-comments-list {
	list-style: none;
	padding: 0;
	margin: 0;
	text-align: left;
}

.stats-comment-item,
.stats-reaction-item {
	margin-bottom: 15px;
	padding: 0;
	text-align: left;
}

.stats-reaction-item {
	position: relative;
	border-radius: var(--radius-md, 6px);
	padding: 0.35rem 0.55rem;
	margin-left: -0.55rem;
	margin-right: -0.55rem;
	transition: background-color 0.22s ease;
}

.stats-reaction-item::after {
	content: attr(data-stats-reaction-kind);
	position: absolute;
	right: 0.45rem;
	bottom: 0.35rem;
	max-width: min(100%, 14rem);
	font-size: 0.625rem;
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	font-variant-numeric: tabular-nums;
	color: color-mix(in srgb, var(--clr-background, rgb(250, 250, 247)) 70%, var(--clr-black, #1b1b1b) 30%);
	opacity: 0;
	pointer-events: none;
	z-index: 2;
	transition: opacity 0.2s ease;
	text-align: right;
}

.stats-reaction-item:hover {
	background-color: #fff;
}

.stats-reaction-item:hover::after {
	opacity: 1;
}

.stats-reaction-item:last-child {
	margin-bottom: 0;
}

/* Einheitliche Timeline: Likes + Kommentare (Mastodon/Bluesky gemischt) */
.stats-reactions {
	margin-bottom: 1.5rem;
	width: 100%;
	margin-left: 0;
	text-align: left;
}

/* Unter den Charts, vor dem Breadcrumb */
.stats-reactions-after-charts {
	margin-top: 2rem;
	margin-bottom: 2rem;
}

.stats-reactions-list {
	list-style: none;
	padding: 0;
	margin: 0;
	text-align: left;
}

.stats-reaction-author {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
	text-decoration: none;
	color: inherit;
}

.stats-reaction-author:hover {
	opacity: 0.85;
}

.stats-reaction-item:hover .stats-reaction-author {
	opacity: 1;
}

.stats-reaction-item--like .stats-reaction-author,
.stats-reaction-item--repost .stats-reaction-author {
	margin-bottom: 0;
}

.stats-reaction-item--like .stats-reaction-author:hover,
.stats-reaction-item--repost .stats-reaction-author:hover {
	opacity: 1;
}

.stats-reaction-item--like .stats-reaction-handle,
.stats-reaction-item--repost .stats-reaction-handle {
	font-size: 16px;
	color: var(--clr-black);
	opacity: 0.88;
	line-height: 1.35;
}

.stats-reaction-item .stats-avatar {
	width: 48px;
	height: 48px;
	min-width: 48px;
	min-height: 48px;
	border-radius: 50%;
	object-fit: cover;
}

.stats-reaction-author-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	text-align: left;
	min-width: 0;
}

.stats-reaction-author-info strong {
	font-weight: 400;
	color: var(--clr-black);
	font-size: 16px;
}

.stats-reaction-network {
	font-size: 16px;
	color: var(--clr-black);
	opacity: 0.88;
	line-height: 1.35;
}

.stats-reaction-sep {
	margin: 0 0.2em;
	opacity: 0.7;
}

/* Reaktions-Zeit: Bluesky-Likes (indexedAt); Kommentare (createdAt). Mastodon-Likes/Reposts: API ohne Zeit pro Eintrag. */
.stats-reaction-time {
	font-size: 0.875rem;
	font-weight: 300;
	line-height: 1.35;
	color: var(--clr-black);
	opacity: 0.72;
	margin-top: 0.25rem;
	margin-left: calc(48px + 1rem);
	padding-left: 0.05em;
	display: block;
	text-align: left;
	letter-spacing: 0.01em;
}

.stats-reaction-item--comment .stats-comment-author {
	margin-bottom: 0.5rem;
}

.stats-comment-author {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
	margin-bottom: 0.5rem;
	text-decoration: none;
	color: inherit;
}

.stats-comment-author:hover {
	opacity: 0.8;
}

.stats-reaction-item--comment:hover .stats-comment-author {
	opacity: 1;
}

/* Reaktions-Kommentar: Link ohne Unterstreichung, Hover = nur Grün (kein opacity-Dimmen) */
.stats-reaction-item--comment a.stats-comment-author {
	text-decoration: none;
}
.stats-reaction-item--comment a.stats-comment-author:hover {
	opacity: 1;
	text-decoration: none;
	color: var(--clr-primary);
}
.stats-reaction-item--comment a.stats-comment-author:hover strong,
.stats-reaction-item--comment a.stats-comment-author:hover .stats-reaction-handle {
	color: var(--clr-primary);
}

.stats-comment-author .stats-avatar {
	width: 48px;
	height: 48px;
	min-width: 48px;
	min-height: 48px;
}

.stats-comment-author-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	text-align: left;
}

.stats-comment-author strong {
	font-weight: 400;
	color: var(--clr-black);
	font-size: 16px;
}

.stats-comment-time {
	font-size: 16px;
	font-weight: 300;
	color: var(--clr-black);
	margin-top: 0.5rem;
	text-align: left;
	margin-left: calc(48px + 1rem); /* Avatar width + gap, same as .stats-comment-content */
}

.stats-comment-content {
	line-height: 1.6;
	color: var(--clr-black);
	margin-left: calc(48px + 1rem); /* Avatar width + gap */
	margin-bottom: 0.5rem;
	font-size: 16px;
	text-align: left;
}

/* Empty State */
.stats-empty {
	padding: 2rem;
	text-align: left;
	color: var(--clr-black);
	width: 100%;
	margin-left: 0;
	font-size: 16px;
}

.stats-empty a {
	color: var(--clr-text);
	text-decoration: none;
}

.stats-empty a:hover {
	text-decoration: underline;
}

/* Navigation */
.stats-nav {
	margin-top: 3rem;
	padding-top: 2rem;
	border-top: 1px solid rgba(27, 27, 27, 0.2);
	width: 100%;
	margin-left: 0;
	text-align: left;
}

.stats-back {
	display: inline-block;
	color: var(--clr-text);
	text-decoration: none;
	font-weight: 400;
	font-size: 16px;
}

.stats-back:hover {
	text-decoration: underline;
}

/* Feed Link */
.feed-stats-link {
	display: inline-block;
	font-size: 16px;
	color: var(--clr-text);
	text-decoration: none;
	margin-left: 1rem;
	padding: 0.25rem 0.5rem;
	border-radius: 3px;
	background: rgba(27, 27, 27, 0.1);
}

.feed-stats-link:hover {
	background: rgba(27, 27, 27, 0.2);
	text-decoration: underline;
}

/* Responsive */
/* Tablets - 3-Spalten-Layout bleibt erhalten bis 768px */
@media (max-width: 1280px) {
	.stats-container {
		padding: 2rem 1rem;
	}
	
	/* 3-Spalten-Layout bleibt erhalten, nur Container-Anpassungen */
}

/* Mobile - Ab hier 1-Spalten-Layout */
@media (max-width: 768px) {
	.stats-container {
		padding: 1rem;
	}
	
	.stats-empty,
	.stats-left,
	.stats-main,
	.stats-right {
		width: 100%;
		margin-bottom: 1.5rem;
	}
	
	.stats-empty:last-child,
	.stats-left:last-child,
	.stats-main:last-child,
	.stats-right:last-child {
		margin-bottom: 0;
	}
	
	.stats-header,
	.stats-section,
	.stats-likes,
	.stats-comments,
	.stats-reactions,
	.stats-nav {
		width: 100%;
		margin-left: 0;
	}
	
	.feed-headline {
		font-size: 2.8rem;
		width: 100%; /* Volle Breite auf Mobile */
		max-width: 100%;
	}
	
	.stats-comment-content {
		margin-left: 0;
		margin-top: 0.5rem;
	}
	
	.stats-comment-header {
		flex-wrap: wrap;
	}
	
	.stats-comment-time,
	.stats-reaction-time {
		margin-left: 0;
		width: 100%;
	}
}

@media (max-width: 480px) {
	.feed-headline {
		font-size: 2.2rem;
		width: 100%; /* Volle Breite auf Small Mobile */
		max-width: 100%;
	}
}

/* Charts Section */
.stats-charts {
	width: 100%;
	margin-left: 0;
	margin-top: 2rem;
	margin-bottom: 2rem;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 20px;
	position: relative;
	z-index: 1;
	overflow: visible;
}

.stats-chart-container {
	width: 100%;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 0;
	display: flex;
	flex-direction: column;
	position: relative;
	z-index: 1;
	overflow: visible; /* Tooltips dürfen über den Container hinausragen */
}

.stats-chart-title {
	font-size: 16px;
	font-weight: 400;
	margin-bottom: 0.25rem;
	color: var(--clr-black);
	text-align: left;
}

.stats-chart-title-hidden {
	visibility: hidden;
	opacity: 0;
	height: auto;
	margin-bottom: 0.25rem;
	padding: 0;
	line-height: 1.6;
}

.stats-chart-subtitle {
	font-size: 14px;
	font-weight: 400;
	margin-bottom: 1rem;
	color: var(--clr-black);
	text-align: left;
	opacity: 0.8;
}

.stats-chart-value {
	font-size: 16px;
	font-weight: 400;
	margin-bottom: 1rem;
	color: var(--clr-black);
	text-align: left;
	margin-top: 0;
}

/* Erste Zeile: 2 Kreisdiagramme */
.stats-chart-circle {
	grid-column: span 1;
	min-height: 200px;
}

.stats-chart-circle canvas {
	width: 150px !important;
	height: 150px !important;
	max-width: 150px;
	max-height: 150px;
	margin: 0 auto;
}

/* Zweites Donut-Chart (Anteil am Tag) 10px nach oben verschieben */
#dayChart {
	margin-top: -10px !important;
}

/* Zweite Zeile: 3 Liniendiagramme */
.stats-chart-line {
	grid-column: span 1;
	min-height: 220px;
}

.stats-chart-line canvas {
	width: 100% !important;
	height: auto !important;
	aspect-ratio: 4 / 3;
	max-width: 100%;
}

/* Aufrufe & Reaktionen Chart: 24px höher */
#engagementChart {
	height: calc(200px + 24px) !important;
}

/* Zeichen-Chart: wie andere Balken — Canvas-Fläche --clr-background, Balkenrand in JS: noblack (COLORS.primary) */
.stats-chart-char canvas#charCountChart {
	background: var(--clr-background);
	border-radius: var(--radius-sm);
	box-sizing: border-box;
}

/* Säulendiagramme: Beide gleich hoch 180px */
#charCountChart {
	height: 180px !important;
}

#engagementChart {
	height: 180px !important;
}

/* Gantt-Chart: HTML/CSS ohne Chart.js – Max 530px, 12 Linien, links + rechts maskiert */
.stats-chart-gantt {
	grid-column: span 2;
	width: 100%;
	max-width: 530px; /* Chart wird nie breiter als 530px */
	min-height: 120px;
	height: auto;
	padding-bottom: 42px;
	position: relative;
	z-index: 1;
	overflow: hidden; /* Balken links + rechts maskieren (überstehend wird abgeschnitten) */
	clear: both;
}

.gantt-timeline {
	position: relative;
	width: 100%;
	min-height: 120px;
	overflow: hidden; /* Balken links + rechts abschneiden */
}

/* 12 vertikale Striche für 12 Monate (hinter den Balken) */
.gantt-month-lines {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	margin-top: 16px;
}

.gantt-month-line {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 1px;
	background: rgba(0, 0, 0, 0.12);
	transform: translateX(-50%);
}

.gantt-timeline-inner {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.gantt-row {
	position: relative;
	height: 8px;
	width: 100%;
}

.gantt-bar {
	position: absolute;
	top: 0;
	height: 7px;
	min-width: 32px; /* Mindestbreite für Sichtbarkeit */
	margin-top: 2px;
	display: block;
	background: rgba(0, 0, 0, 0.5);
	border-radius: 2px;
	text-decoration: none;
	transition: background 0.15s;
}

.gantt-bar:hover {
	background: var(--clr-green, #2d5a27);
}

.gantt-bar.is-current {
	background: var(--clr-black, #111);
}

.gantt-bar.is-current:hover {
	background: var(--clr-green, #2d5a27);
}

/* Gantt Tooltip */
.gantt-tooltip {
	position: fixed;
	background: rgba(0, 0, 0, 0.92);
	color: #fff;
	padding: 8px 12px;
	border-radius: 4px;
	font-size: 12px;
	pointer-events: none;
	z-index: 10002;
	opacity: 0;
	transition: opacity 0.15s;
	max-width: 320px;
	line-height: 1.4;
	display: none;
}

.gantt-tooltip.is-visible {
	display: block;
	opacity: 1;
}

/* Chart.js Tooltip-Elemente - alle möglichen Selektoren */
canvas[data-chartjs-tooltip] + div,
.stats-chart-container canvas + div,
.stats-charts div[style*="position"] {
	z-index: 100 !important;
}

/* Sicherstellen, dass Tooltips über Charts liegen */
.stats-charts > * {
	position: relative;
	z-index: 1;
}

/* Tag-Statistiken Section */
.stats-tags-section {
	width: 100%;
	margin-left: 0;
	margin-top: 2rem; /* Normaler Abstand statt Hack */
	margin-bottom: 2rem;
	position: relative;
	z-index: 0;
	display: block;
}

.stats-tags-text {
	font-size: 16px;
	line-height: 1.6;
	color: var(--clr-black);
	text-align: left;
	margin: 0;
}

.stats-tag-link {
	/* Verwendet .lnk-tag Basis-Klasse */
}

.stats-tag-link::first-letter {
	text-transform: uppercase;
}

/* Responsive Charts */
@media (max-width: 1280px) {
	.stats-charts {
		width: 100%;
		margin-left: 0;
	}
	
	.stats-chart-gantt {
		max-width: 100%;
	}
	
	.stats-tags-section {
		width: 100%;
		margin-left: 0;
	}
}
