/* ============================================================================
   SHARED TIMELINE COMPONENT
   ============================================================================
   Semantic CSS classes for alternating timeline layout.
   Used across multiple pages (home, employment detail).

   Design Spec: spectr/changes/refactor-shared-timeline-semantic-css/design.md
   ========================================================================= */

/* Container for the alternating timeline */
.timeline-alternating {
	position: relative;
	width: 100%;
}

/* Centered vertical spine with gradient */
.timeline-spine {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	width: 2px;
	height: 100%;
	background: linear-gradient(to bottom,
			var(--color-accent),
			var(--color-border) 50%,
			transparent);
	z-index: 0;
}

/* CSS Grid layout for timeline rows (3-column structure) */
.timeline-row {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 2rem;
	position: relative;
	margin-bottom: 3rem;
	align-items: start;
}

/* Centered dot on the spine - outer ring */
.timeline-dot-center {
	width: 20px;
	height: 20px;
	background-color: var(--color-bg-primary);
	border-radius: 50%;
	border: 3px solid var(--color-accent);
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Inner dot circle - centered within outer dot */
.timeline-dot-inner {
	width: 6px;
	height: 6px;
	background-color: var(--color-accent);
	border-radius: 50%;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

/* Current/top timeline dot pulse animation */
.timeline-dot-current {
	animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
	0%, 100% {
		box-shadow: 0 0 0 0 rgba(var(--color-accent-rgb, 96, 165, 250), 0.7);
	}
	50% {
		box-shadow: 0 0 0 10px rgba(var(--color-accent-rgb, 96, 165, 250), 0);
	}
}

/* Base timeline card styles */
.timeline-card {
	position: relative;
	background-color: var(--color-bg-secondary);
	border: 1px solid var(--color-border);
	border-radius: 0.75rem;
	overflow: hidden;
	transition: all 0.2s ease;
	display: block;
}

/* Card positioned on left side */
.timeline-card-left {
	grid-column: 1;
	justify-self: end;
	text-align: right;
}

/* Card positioned on right side */
.timeline-card-right {
	grid-column: 3;
	justify-self: start;
	text-align: left;
}

/* Connector line base styles */
.timeline-connector {
	position: absolute;
	top: 1.5rem;
	height: 2px;
	background-color: var(--color-border);
}

/* Connector line from left card to center dot */
.timeline-connector-left {
	position: absolute;
	right: -2rem;
	top: 1.5rem;
	width: 2rem;
	height: 2px;
	background: linear-gradient(to right, transparent, var(--color-border));
}

/* Connector line from center dot to right card */
.timeline-connector-right {
	position: absolute;
	left: -2rem;
	top: 1.5rem;
	width: 2rem;
	height: 2px;
	background: linear-gradient(to left, transparent, var(--color-border));
}

/* Card gradient line - top border highlight on hover */
.timeline-card-gradient {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: linear-gradient(to right, var(--color-accent), transparent);
	opacity: 0;
	transition: opacity 0.2s ease;
}

/* Card content padding area */
.timeline-card-body {
	padding: 1.5rem;
}

/* Card header section */
.timeline-card-header {
	margin-bottom: 1rem;
}

/* Date display styling */
.timeline-date {
	font-family: var(--font-mono);
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--color-accent);
	letter-spacing: 0.025em;
	margin-bottom: 0.75rem;
}

/* Entry title typography */
.timeline-title {
	font-family: var(--font-display);
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--color-text-primary);
	line-height: 1.3;
	margin-bottom: 0.5rem;
	transition: color 0.2s ease;
}

/* Entry description with line-clamp */
.timeline-desc {
	font-family: var(--font-body);
	font-size: 0.875rem;
	color: var(--color-text-secondary);
	line-height: 1.7;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Location map container spacing */
.timeline-location {
	margin-top: 1rem;
}

/* ============================================================================
   HOVER AND FOCUS STATES
   ========================================================================= */

/* Card hover effects */
.timeline-card:hover {
	border-color: var(--color-accent);
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Title color change on card hover */
.timeline-card:hover .timeline-title {
	color: var(--color-accent);
}

/* Gradient line fade-in on card hover */
.timeline-card:hover .timeline-card-gradient {
	opacity: 1;
}

/* Focus states for accessibility */
.timeline-card:focus {
	outline: 2px solid var(--color-accent);
	outline-offset: 4px;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================= */

/* Tablet: 768px - 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
	/* Maintain 3-column layout, reduce gaps */
	.timeline-row {
		gap: 1.75rem;
	}

	/* Tablet dot size */
	.timeline-dot-center {
		width: 18px;
		height: 18px;
	}

	.timeline-dot-inner {
		width: 5px;
		height: 5px;
	}

	/* Tablet card padding */
	.timeline-card-body {
		padding: 1.25rem;
	}

	/* Tablet connector widths match grid gap */
	.timeline-connector-left,
	.timeline-connector-right {
		width: 1.75rem;
	}

	.timeline-connector-left {
		right: -1.75rem;
	}

	.timeline-connector-right {
		left: -1.75rem;
	}
}

/* Mobile: < 768px */
@media (max-width: 767px) {
	/* Hide the centered spine on mobile */
	.timeline-alternating .timeline-spine {
		display: none;
	}

	/* Single column layout on mobile */
	.timeline-row {
		grid-template-columns: 1fr;
		gap: 1.5rem;
		margin-bottom: 1.5rem;
	}

	/* Reset card positions for mobile */
	.timeline-card-left,
	.timeline-card-right {
		grid-column: 1;
		justify-self: start;
		text-align: left;
	}

	/* Hide connector lines on mobile */
	.timeline-connector-left,
	.timeline-connector-right {
		display: none;
	}

	/* Hide centered dot on mobile */
	.timeline-dot-center {
		display: none;
	}

	/* Add left padding for timeline spine and dots */
	.timeline-alternating {
		padding-left: 1.5rem;
		position: relative;
	}

	/* Show left-aligned spine for mobile */
	.timeline-alternating::before {
		content: "";
		position: absolute;
		left: 0.5rem;
		top: 0;
		width: 2px;
		height: 100%;
		background: linear-gradient(to bottom,
				var(--color-accent),
				var(--color-border) 50%,
				transparent);
	}

	/* Add left margin for mobile cards */
	.timeline-card-left,
	.timeline-card-right {
		margin-left: 0.25rem;
	}

	/* Show dots on timeline-row instead (not clipped by card overflow) */
	.timeline-row::before {
		content: "";
		position: absolute;
		left: -1rem;
		top: 1rem;
		width: 16px;
		height: 16px;
		border-radius: 50%;
		background-color: var(--color-bg-primary);
		border: 3px solid var(--color-accent);
		z-index: 2;
		transform: translateX(-50%);
		display: flex;
		align-items: center;
		justify-content: center;
	}

	/* Mobile inner dot (pseudo-pseudo-element workaround using box-shadow) */
	.timeline-row::before {
		box-shadow: inset 0 0 0 4px var(--color-bg-primary),
		            inset 0 0 0 8px var(--color-accent);
	}

	/* Mobile dot size */
	.timeline-dot-center {
		width: 16px;
		height: 16px;
	}

	.timeline-dot-inner {
		width: 4px;
		height: 4px;
	}

	/* Mobile card padding */
	.timeline-card-body {
		padding: 1rem;
	}

	/* Mobile title size */
	.timeline-title {
		font-size: 1.25rem;
	}

	/* Mobile description size */
	.timeline-desc {
		font-size: 0.875rem;
	}
}

/* Desktop: ≥ 1024px (default styles above) */
@media (min-width: 1024px) {
	/* Desktop uses base styles defined above */
	/* Explicitly set desktop sizes for clarity */
	.timeline-row {
		gap: 2rem;
	}

	.timeline-dot-center {
		width: 20px;
		height: 20px;
	}

	.timeline-dot-inner {
		width: 6px;
		height: 6px;
	}

	.timeline-card-body {
		padding: 1.5rem;
	}

	.timeline-title {
		font-size: 1.5rem;
	}

	.timeline-desc {
		font-size: 1rem;
	}
}

/* ============================================================================
   ACCESSIBILITY - REDUCED MOTION SUPPORT
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
	.timeline-card,
	.timeline-dot-center,
	.timeline-dot-inner,
	.timeline-connector,
	.timeline-connector-left,
	.timeline-connector-right,
	.timeline-card-gradient,
	.timeline-title {
		transition: none;
	}

	.timeline-card:hover {
		transform: none;
	}

	.timeline-dot-current {
		animation: none;
	}
}
