/* @svelte-lean/styles — timeline (Tier 0, <ol> of dated events).
 * Markup: <ol role="list" data-slean="timeline" aria-label="…"> <li data-color="success">
 * <time datetime="2026-09-28T09:12">…</time> <p data-slean-part="title">…</p>
 * <p data-slean-part="description">…</p> </li> … </ol>. The dot is li::before, the line to the
 * next event li::after. Colors on an <li>: data-color="primary|secondary|info|success|warning|
 * error" tint the dot only (neutral, the default, is the strong border tone); the text says
 * what happened. An event that has not happened yet contains the pending part (visible text);
 * through :has() its dot is hollow and the line into and out of it is dashed. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.components {
	:where([data-slean='timeline']) {
		margin: 0;
		padding: 0;
		list-style: none;
		color: var(--slean-fg);
		font-size: var(--slean-text-sm);
		line-height: 1.25rem;
	}

	:where([data-slean='timeline'] > li) {
		position: relative;
		padding-block-end: var(--slean-space-5);
		padding-inline-start: 1.75rem;
		overflow-wrap: anywhere;
	}

	:where([data-slean='timeline'] > li:last-child) {
		padding-block-end: 0;
	}

	:where([data-slean='timeline'] > li > time),
	:where([data-slean='timeline'] > li > [data-slean-part]) {
		margin: 0;
	}

	/* Dot: centred on the first 1.25rem line of the event. */
	:where([data-slean='timeline'] > li)::before {
		content: '';
		position: absolute;
		inset-block-start: 0.3125rem;
		inset-inline-start: 0.1875rem;
		inline-size: 0.625rem;
		block-size: 0.625rem;
		border: 2px solid var(--slean-border-strong);
		border-radius: 50%;
		background: var(--slean-border-strong);
	}

	/* Line: from below this dot to above the next one. */
	:where([data-slean='timeline'] > li:not(:last-child))::after {
		content: '';
		position: absolute;
		inset-block-start: calc(0.9375rem + var(--slean-space-1));
		inset-block-end: calc(var(--slean-space-1) - 0.3125rem);
		inset-inline-start: calc(0.5rem - 1px);
		border-inline-start: 2px solid var(--slean-border);
	}

	:where([data-slean='timeline'] time) {
		display: block;
		color: var(--slean-fg-muted);
		font-size: var(--slean-text-xs);
		font-variant-numeric: tabular-nums;
	}

	:where([data-slean='timeline'] [data-slean-part='title']) {
		font-weight: var(--slean-font-weight-medium);
	}

	:where([data-slean='timeline'] [data-slean-part='description']) {
		color: var(--slean-fg-muted);
	}

	:where([data-slean='timeline'] [data-slean-part='pending']) {
		display: inline-block;
		margin-block-start: var(--slean-space-1);
		padding-inline: var(--slean-space-2);
		border: 1px dashed var(--slean-border-strong);
		border-radius: var(--slean-radius-full);
		color: var(--slean-fg-muted);
		font-size: var(--slean-text-xs);
	}

	/* A color tints the dot; the event's text carries the meaning. */
	:where([data-slean='timeline'] > li[data-color]:not([data-color='neutral']))::before {
		border-color: var(--slean-color-main);
		background: var(--slean-color-main);
	}

	/* Pending: a hollow dot, and a dashed line into it and out of it. */
	:where([data-slean='timeline'] > li:has([data-slean-part='pending']))::before {
		background: transparent;
	}

	:where([data-slean='timeline'] > li:has([data-slean-part='pending']))::after,
	:where([data-slean='timeline'] > li:has(+ li [data-slean-part='pending']))::after {
		border-inline-start-style: dashed;
	}

	/* Forced colors drop background colors: the dots keep a visible fill in the text color and
	 * the pending ones stay hollow. */
	@media (forced-colors: active) {
		:where([data-slean='timeline'] > li)::before {
			forced-color-adjust: none;
			border-color: CanvasText;
			background: CanvasText;
		}

		:where([data-slean='timeline'] > li:has([data-slean-part='pending']))::before {
			background: Canvas;
		}

		:where([data-slean='timeline'] > li:not(:last-child))::after {
			border-color: CanvasText;
		}
	}
}
