/* Atlas Arcadia - Timeline blocks (aa/timeline, aa/timeline-event). Handle aa-blog-timeline.
   Registered as the blocks' `style`, so it loads wherever a timeline renders: the front end
   and the editor iframe. Tokens come from aa-design-tokens; the comp's semantic tokens
   (--border-default, --text-muted) do not exist there, so they are literals behind local
   variables.

   STATES
   - Complete (the default): no JS, reduced motion, motion "none", and the block editor.
     Everything shown, spine solid, discs lit.
   - Enhanced (.is-enhanced, added by view.js): events hidden until .is-in, discs unlit
     until .is-lit, spine filled to --aa-tl-progress.
   Hidden states live ONLY under .is-enhanced. Motion is transform and opacity only, plus
   colour on the disc. */

.aa-timeline {
	--tl-track: var(--aa-timeline-track, #e8ddc4);
	--tl-muted: var(--aa-timeline-muted, #8a7a63);
	--tl-brown: var(--aa-brown, #6a3306);
	--tl-orange: var(--aa-orange, #db680b);
	--tl-cream: var(--aa-cream, #fdf6e8);
	--tl-yellow: var(--aa-yellow, #fae905);
	--tl-ease: cubic-bezier(.2, .7, .2, 1);
	position: relative;
	box-sizing: border-box;
	padding: 8px 0;
	container-type: inline-size;
	container-name: aa-timeline;
	color: var(--aa-text-color, #2a1d12);
	font-family: var(--aa-text, 'Poppins', ui-sans-serif, system-ui, sans-serif);
}

/* ---- Spine ------------------------------------------------------------------ */
.aa-timeline .aa-timeline__spine {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	z-index: 0;
	width: 4px;
	margin-left: -2px;
	border-radius: 2px;
	background: var(--tl-track);
	overflow: hidden;
}
.aa-timeline .aa-timeline__fill {
	position: absolute;
	inset: 0;
	border-radius: 2px;
	background: var(--tl-brown);
	transform-origin: 50% 0;
	transform: scaleY(1);
}
.aa-timeline.is-enhanced:not(.aa-timeline--no-fill) .aa-timeline__fill {
	transform: scaleY(var(--aa-tl-progress, 0));
}

/* ---- Event ------------------------------------------------------------------ */
.aa-timeline .aa-timeline__events {
	position: relative;
	z-index: 1;
}
.aa-timeline .aa-timeline__event {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
	margin: 0 0 56px;
	padding: 0;
	align-items: start;
}
.aa-timeline .aa-timeline__event:last-child { margin-bottom: 0; }
/* The editor appends a block appender after the last event; the last event is then not :last-child. */
.aa-timeline .aa-timeline__events > .aa-timeline__event:nth-last-child(2):has(+ .aa-timeline__appender) { margin-bottom: 0; }

.aa-timeline .aa-timeline__when   { grid-column: 1; grid-row: 1; text-align: right; padding: 14px 24px 0 0; min-width: 0; }
.aa-timeline .aa-timeline__marker { grid-column: 2; grid-row: 1; }
.aa-timeline .aa-timeline__card   { grid-column: 3; grid-row: 1; }
.aa-timeline .aa-timeline__event:nth-child(even) .aa-timeline__when { grid-column: 3; text-align: left; padding: 14px 0 0 24px; }
.aa-timeline .aa-timeline__event:nth-child(even) .aa-timeline__card { grid-column: 1; }

/* ---- When block ------------------------------------------------------------- */
.aa-timeline .aa-timeline__date {
	display: block;
	font-family: var(--aa-display, 'Cartridge', ui-sans-serif, system-ui, sans-serif);
	font-size: 2rem;
	font-weight: 400;
	line-height: 1;
	letter-spacing: normal;
	color: var(--tl-orange);
	overflow-wrap: anywhere;
}
.aa-timeline .aa-timeline__label {
	display: block;
	margin-top: 6px;
	font-family: 'Righteous', var(--aa-display, 'Cartridge', ui-sans-serif, system-ui, sans-serif);
	font-size: 14px;
	line-height: 1.35;
	color: var(--tl-muted);
}

/* ---- Marker (the disc on the spine) -------------------------------------------- */
.aa-timeline .aa-timeline__marker {
	position: relative;
	z-index: 1;
	display: grid;
	place-items: center;
	justify-self: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	margin-top: 8px;
	border-radius: 50%;
	font-size: 18px;
	line-height: 1;
	background: var(--tl-orange);
	color: #fff;
	box-shadow: 0 0 0 5px var(--tl-cream), 0 0 0 7px var(--tl-yellow);
	transform: scale(1.08);
}
.aa-timeline .aa-timeline__marker i { font-size: 18px; line-height: 1; color: inherit; }
.aa-timeline .aa-timeline__dot { display: block; width: 12px; height: 12px; border-radius: 50%; background: currentColor; }

/* ---- Card ------------------------------------------------------------------- */
.aa-timeline .aa-timeline__card {
	position: relative;
	box-sizing: border-box;
	min-width: 0;
	padding: 22px 24px 24px;
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 6px 20px rgba(74, 36, 4, .18);
}
/* The notch: a 9px white triangle pointing at the spine. */
.aa-timeline .aa-timeline__card::before {
	content: '';
	position: absolute;
	top: 22px;
	left: -9px;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 9px 9px 9px 0;
	border-color: transparent #fff transparent transparent;
}
.aa-timeline .aa-timeline__event:nth-child(even) .aa-timeline__card::before {
	left: auto;
	right: -9px;
	border-width: 9px 0 9px 9px;
	border-color: transparent transparent transparent #fff;
}

.aa-timeline .aa-timeline__title {
	margin: 0 0 14px;
	padding: 0;
	font-family: var(--aa-display, 'Cartridge', ui-sans-serif, system-ui, sans-serif);
	font-size: 1.45rem;
	font-weight: 400;
	line-height: 1.15;
	letter-spacing: normal;
	text-transform: none;
	color: var(--tl-brown);
	text-wrap: balance;
}
.aa-timeline .aa-timeline__figure {
	margin: 0 0 14px;
	padding: 0;
}
.aa-timeline .aa-timeline__frame {
	overflow: hidden;
	border-radius: 4px;
	background: var(--tl-cream);
}
.aa-timeline .aa-timeline__frame img,
.aa-timeline .aa-timeline__img {
	display: block;
	width: 100%;
	height: auto;
	max-height: 520px;
	object-fit: contain;
	margin: 0;
	border-radius: 0;
}
/* Opt-in 4:3 cover crop (the event's "Crop photo to 4:3" toggle). */
.aa-timeline .aa-timeline__figure--crop .aa-timeline__img,
.aa-timeline .aa-timeline__figure--crop .aa-timeline__frame img {
	max-height: none;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}
.aa-timeline .aa-timeline__figure .aa-credit {
	margin: 6px 0 0;
	padding: 0;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.45;
	letter-spacing: .01em;
	color: var(--aa-muted, #7d6f5a);
}
.aa-timeline .aa-timeline__figure .aa-credit a { color: var(--aa-ink, #8a4a12); }

.aa-timeline .aa-timeline__excerpt {
	font-size: 1rem;
	line-height: 1.7;
	min-width: 0;
}
.aa-timeline .aa-timeline__excerpt > * { margin-top: 0; margin-bottom: .85em; font-size: 1rem; line-height: 1.7; }
.aa-timeline .aa-timeline__excerpt > :last-child { margin-bottom: 0; }

/* ---- Narrow: the spine moves to the left edge --------------------------------- */
@container aa-timeline (max-width: 719px) {
	.aa-timeline .aa-timeline__spine { left: 22px; }
	.aa-timeline .aa-timeline__event,
	.aa-timeline .aa-timeline__event:nth-child(even) {
		grid-template-columns: 44px minmax(0, 1fr);
		column-gap: 14px;
		margin-bottom: 32px;
	}
	.aa-timeline .aa-timeline__event:last-child { margin-bottom: 0; }
	.aa-timeline .aa-timeline__marker,
	.aa-timeline .aa-timeline__event:nth-child(even) .aa-timeline__marker { grid-column: 1; grid-row: 1 / span 2; margin-top: 0; align-self: start; }
	.aa-timeline .aa-timeline__when,
	.aa-timeline .aa-timeline__event:nth-child(even) .aa-timeline__when { grid-column: 2; grid-row: 1; text-align: left; padding: 4px 0 10px; }
	.aa-timeline .aa-timeline__card,
	.aa-timeline .aa-timeline__event:nth-child(even) .aa-timeline__card { grid-column: 2; grid-row: 2; padding: 18px; }
	.aa-timeline .aa-timeline__card::before,
	.aa-timeline .aa-timeline__event:nth-child(even) .aa-timeline__card::before { display: none; }
	.aa-timeline .aa-timeline__date { font-size: 1.6rem; }
	.aa-timeline .aa-timeline__title { font-size: 1.25rem; }
}

/* ---- Enhanced: the scroll-built animation ------------------------------------- */
/* Offsets per motion mode, as custom properties: card and when-block. */
.aa-timeline--fly-up { --tl-card-x: 0px; --tl-card-y: 40px; --tl-when-x: 0px; --tl-when-y: 40px; }
.aa-timeline--slide-in { --tl-card-x: 48px; --tl-card-y: 0px; --tl-when-x: -48px; --tl-when-y: 0px; }
.aa-timeline--slide-in .aa-timeline__event:nth-child(even) { --tl-card-x: -48px; --tl-when-x: 48px; }
@container aa-timeline (max-width: 719px) {
	.aa-timeline--slide-in { --tl-card-x: 32px; --tl-when-x: -32px; }
	.aa-timeline--slide-in .aa-timeline__event:nth-child(even) { --tl-card-x: -32px; --tl-when-x: 32px; }
}

.aa-timeline.is-enhanced .aa-timeline__card {
	opacity: 1;
	transform: none;
	transition: opacity 600ms ease-out, transform 700ms var(--tl-ease);
}
.aa-timeline.is-enhanced .aa-timeline__when {
	opacity: 1;
	transform: none;
	transition: opacity 600ms ease-out 120ms, transform 700ms var(--tl-ease) 120ms;
}
.aa-timeline.is-enhanced .aa-timeline__img {
	transform: none;
	transition: transform 1400ms var(--tl-ease) 150ms;
}
.aa-timeline.is-enhanced .aa-timeline__marker {
	transition: background-color 300ms ease-out, color 300ms ease-out, box-shadow 300ms ease-out, transform 500ms var(--tl-ease), opacity 300ms ease-out;
}

.aa-timeline.is-enhanced .aa-timeline__event:not(.is-in) .aa-timeline__card { opacity: 0; transform: translate(var(--tl-card-x), var(--tl-card-y)); }
.aa-timeline.is-enhanced .aa-timeline__event:not(.is-in) .aa-timeline__when { opacity: 0; transform: translate(var(--tl-when-x), var(--tl-when-y)); }
.aa-timeline.is-enhanced .aa-timeline__event:not(.is-in) .aa-timeline__img  { transform: scale(1.12); }
.aa-timeline.is-enhanced .aa-timeline__event:not(.is-in) .aa-timeline__marker { opacity: 0; transform: scale(.4); }

/* Unlit discs (the reading line has not reached them). Spine fill off keeps every disc lit. */
.aa-timeline.is-enhanced:not(.aa-timeline--no-fill) .aa-timeline__event.is-in:not(.is-lit) .aa-timeline__marker {
	background: var(--tl-cream);
	color: var(--tl-brown);
	box-shadow: 0 0 0 5px var(--tl-cream), 0 0 0 7px var(--tl-track);
	transform: scale(1);
}

/* ---- Reduced motion: the complete state, whatever the setting says -------------- */
@media (prefers-reduced-motion: reduce) {
	.aa-timeline .aa-timeline__card,
	.aa-timeline .aa-timeline__when,
	.aa-timeline .aa-timeline__img { opacity: 1 !important; transform: none !important; transition: none !important; }
	.aa-timeline .aa-timeline__marker {
		opacity: 1 !important;
		background: var(--tl-orange) !important;
		color: #fff !important;
		box-shadow: 0 0 0 5px var(--tl-cream), 0 0 0 7px var(--tl-yellow) !important;
		transform: scale(1.08) !important;
		transition: none !important;
	}
	.aa-timeline .aa-timeline__fill { transform: scaleY(1) !important; }
}

/* ---- Editor only ------------------------------------------------------------- */
.aa-timeline .aa-timeline__appender { position: relative; z-index: 2; width: max-content; max-width: 100%; margin: 32px auto 0; }
.aa-timeline-event-edit .aa-timeline__date,
.aa-timeline-event-edit .aa-timeline__label { min-height: 1em; }
.aa-timeline-event-edit .aa-timeline__date:empty::before,
.aa-timeline-event-edit .aa-timeline__label:empty::before { content: attr(data-placeholder); opacity: .5; }
.aa-timeline-event-edit .aa-timeline__add-photo { margin: 0 0 14px; }
.aa-timeline-event-edit .aa-timeline__credit-note { margin: 6px 0 0; font-size: 12px; color: var(--aa-muted, #7d6f5a); font-style: italic; }
.aa-timeline-icon-picker { padding: 12px; width: 312px; max-width: 100%; box-sizing: border-box; }
.aa-timeline-icon-picker .aa-timeline-icon-search { margin: 0 0 10px; }
.aa-timeline-icon-none { margin: 4px 0 0; font-size: 12px; color: #757575; }
.aa-timeline-icon-grid { display: grid; grid-template-columns: repeat(6, 40px); gap: 6px; max-height: 232px; overflow-y: auto; }
.aa-timeline-icon-grid .components-button { width: 40px; height: 40px; justify-content: center; padding: 0; font-size: 16px; }
.aa-timeline-icon-grid .components-button.is-pressed { background: #db680b; color: #fff; }
.aa-timeline-icon-grid .aa-timeline__dot { width: 10px; height: 10px; }
