/**
 * MWS Timeline Widget — Frontend Styles
 *
 * Responsive, accessible Elementor timeline widget.
 * No jQuery required. Uses CSS Custom Properties for full theming.
 *
 * @package MWS_Timeline
 * @version 1.0.3
 */

/* =============================================================================
   CSS Custom Properties (defaults — overridden by Elementor selectors)
   ============================================================================= */

.mws-timeline {
	--mws-marker-size:  50px;
	--mws-marker-bg:    #f5a623;
	--mws-marker-color: #ffffff;

	--mws-line-color:  #f5a623;
	--mws-line-weight: 2px;
	--mws-line-style:  solid;

	--mws-title-color:    #1a1a1a;
	--mws-subtitle-color: #555555;

	--mws-content-gap: 12px;
	--mws-steps-gap:   32px;
}

/* =============================================================================
   Steps list — horizontal flex layout (desktop)
   ============================================================================= */

.mws-timeline__steps {
	display:         flex;
	flex-direction:  row;
	align-items:     flex-start;
	list-style:      none;
	margin:          0;
	padding:         0;
}

/* =============================================================================
   Individual step
   ============================================================================= */

.mws-timeline__step {
	flex:            1 1 0;
	min-width:       0; /* prevent flex overflow with long text */
	display:         flex;
	flex-direction:  column;
	align-items:     center;
	position:        relative;
	padding:         0 0.5rem;
}

/* =============================================================================
   Horizontal connector line
   Each step (except last) draws a line from its center to the next step center.
   Line passes behind the markers (marker-wrap has z-index: 1).
   ============================================================================= */

.mws-timeline__step:not(:last-child)::after {
	content:    '';
	position:   absolute;

	/*
	 * Vertical center of the line = vertical center of the marker.
	 * border-top renders from (top) downward to (top + line-weight).
	 * Center of border = top + line-weight/2.
	 * Setting top = marker-size/2 - line-weight/2 centres the border
	 * exactly on the marker's vertical midpoint.
	 */
	top:        calc(
		var(--mws-marker-size) / 2 - var(--mws-line-weight) / 2
	);

	/* Start at the horizontal center of the current step */
	left:       50%;
	/* Span the full width of the current step so it reaches the next center */
	width:      100%;

	height:     0;
	border-top: var(--mws-line-weight) var(--mws-line-style) var(--mws-line-color);
}

/* =============================================================================
   Marker wrapper — sits above the connector line
   ============================================================================= */

.mws-timeline__marker-wrap {
	position:      relative;
	z-index:       1;
	flex-shrink:   0;
	margin-bottom: var(--mws-content-gap);
}

/* =============================================================================
   Marker circle
   ============================================================================= */

.mws-timeline__marker {
	width:            var(--mws-marker-size);
	height:           var(--mws-marker-size);
	border-radius:    50%;
	background-color: var(--mws-marker-bg);
	color:            var(--mws-marker-color);
	display:          flex;
	align-items:      center;
	justify-content:  center;
	font-weight:      700;
	line-height:      1;
	/* Prevents text selection on repeated clicks */
	user-select:      none;
}

.mws-timeline__marker-number,
.mws-timeline__marker-text {
	color:       inherit;
	line-height: 1;
}

/* Icon support (Font Awesome / SVG) */
.mws-timeline__marker i,
.mws-timeline__marker svg {
	color:       var(--mws-marker-color);
	fill:        var(--mws-marker-color);
	font-size:   calc(var(--mws-marker-size) * 0.4);
	width:       calc(var(--mws-marker-size) * 0.4);
	height:      calc(var(--mws-marker-size) * 0.4);
}

/* =============================================================================
   Content (title + subtitle)
   ============================================================================= */

.mws-timeline__content {
	text-align: center;
	width:      100%;
}

.mws-timeline__title {
	color:       var(--mws-title-color);
	font-weight: 700;
	margin:      0 0 0.375em;
	line-height: 1.3;
}

.mws-timeline__subtitle {
	color:       var(--mws-subtitle-color);
	margin:      0;
	line-height: 1.5;
}

/* =============================================================================
   Responsive — Vertical layout (mobile ≤ 767 px)

   Steps stack vertically.  Each step shows marker on the left, content
   on the right.  A continuous vertical line runs behind all markers.
   ============================================================================= */

@media (max-width: 767px) {

	/* Switch the list to a vertical column */
	.mws-timeline__steps {
		flex-direction: column;
		position:       relative;
		gap:            var(--mws-steps-gap);
	}

	/*
	 * Continuous vertical connector line.
	 * Runs from the center of the first marker to the center of the last,
	 * positioned at the horizontal center of the markers (left side of layout).
	 */
	.mws-timeline__steps::before {
		content:     '';
		position:    absolute;
		top:         calc(var(--mws-marker-size) / 2);
		bottom:      calc(var(--mws-marker-size) / 2);

		/*
		 * Align with the horizontal center of the marker.
		 * border-left renders from (left) rightward to (left + line-weight).
		 * Center of border = left + line-weight/2.
		 * Setting left = marker-size/2 - line-weight/2 centres the border
		 * exactly on the marker's horizontal midpoint.
		 */
		left:        calc(
			var(--mws-marker-size) / 2 - var(--mws-line-weight) / 2
		);
		width:       0;
		border-left: var(--mws-line-weight) var(--mws-line-style) var(--mws-line-color);

		/* Stay behind markers */
		z-index:     0;
	}

	/* Hide the horizontal connector on mobile */
	.mws-timeline__step:not(:last-child)::after {
		display: none;
	}

	/* Each step becomes a horizontal row: [marker] [content] */
	.mws-timeline__step {
		flex-direction: row;
		align-items:    flex-start;
		gap:            1rem;
		flex:           unset;
		width:          100%;
		padding:        0;
	}

	/* Marker stays on the left; no bottom margin needed */
	.mws-timeline__marker-wrap {
		margin-bottom: 0;
	}

	/* Content aligns to the left and is vertically centred with the marker top */
	.mws-timeline__content {
		text-align:  left;
		padding-top: calc((var(--mws-marker-size) - 1.5em) / 2);
	}
}

/* =============================================================================
   Accessibility: high-contrast mode (Windows forced-colors)
   ============================================================================= */

@media (forced-colors: active) {
	.mws-timeline__marker {
		border:            2px solid ButtonText;
		forced-color-adjust: none;
	}

	.mws-timeline__step:not(:last-child)::after {
		border-top-color: ButtonText;
	}

	.mws-timeline__steps::before {
		border-left-color: ButtonText;
	}
}

/* =============================================================================
   Accessibility: reduced motion
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
	.mws-timeline,
	.mws-timeline * {
		animation-duration:        0.01ms !important;
		animation-iteration-count: 1      !important;
		transition-duration:       0.01ms !important;
	}
}
