/**
 * InfoAsphalt — public event timeline.
 *
 * Everything is scoped under `.ia-timeline` so the shortcode can drop into any
 * theme without leaking styles.
 */

.ia-timeline {
	--ia-tl-bg: #510066;
	--ia-tl-bg-2: #1c002f;
	--ia-tl-text: #ffffff;
	--ia-tl-muted: #a397bf;
	--ia-tl-grid: rgba( 255, 255, 255, .15 );
	--ia-tl-grid-week: rgba( 255, 255, 255, .45 );
	--ia-tl-primary: #b53ee4;
	--ia-tl-secondary: #73008f;
	--ia-tl-season-end: #dc84ff;
	--ia-tl-hover: #ff7a1a;
	--ia-tl-card-margin: 3px;

	/* Sin `font-family`: la tipografía se hereda del tema. Declararla aquí, aun
	   como `inherit`, no hacía nada y sólo invitaba a que alguien la fijase. */
	color: var( --ia-tl-text );
}

.ia-timeline *,
.ia-timeline *::before,
.ia-timeline *::after {
	box-sizing: border-box;
}

.ia-timeline__header {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}

.ia-timeline__title {
	margin: 0;
	font-size: 1.4rem;
	text-transform: uppercase;
	letter-spacing: 1px;
	color:white;
}

.ia-timeline__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

/* The header sits outside `.ia-timeline__wrapper`, so this button lands on the
   theme's own background rather than the dark timeline. It therefore states its
   own colours instead of inheriting `currentColor`. */
.ia-timeline__today {
	padding: 10px 16px;
	border: 1px solid var( --ia-tl-primary );
	border-radius: 100px;
	background: none;
	color: var( --ia-tl-primary );
	cursor: pointer;
	font: inherit;
	font-weight: 700;
	transition: border-color .2s, color .2s;
}

.ia-timeline__today:hover,
.ia-timeline__today:focus-visible {
	border-color: var( --ia-tl-hover );
	background: none;
	color: var( --ia-tl-hover );
}

/* Type filters ------------------------------------------------------------ */

.ia-timeline__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 12px;
	align-items: center;
	margin-bottom: 16px;
}

/* `display` beats the `hidden` attribute on specificity alone, and the row is
   printed hidden on purpose: without JavaScript the chips filter nothing. */
.ia-timeline__filters[hidden] {
	display: none;
}

.ia-timeline__filters-title {
	font-size: .8rem;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	opacity: .7;
}

/* Desplegable de tipo de evento ---------------------------------------------
   El control lo pinta y lo gobierna `type-select.css`, en el plugin base: es el
   mismo que usa la sección de eventos de la plantilla de temporada. Aquí sólo
   va su paleta, que es todo lo que esa hoja pide para vestirse, y como el resto
   de esta fila vive fuera del panel —sobre el fondo que ponga el tema— la
   declara en vez de heredarla.

   Sobre `.ia-timeline`, que envuelve al control: la hoja compartida lleva sus
   valores neutros como reserva de cada `var()` justamente para que vestirlo
   desde un ancestro funcione. */
.ia-timeline {
	--ia-select-edge: var( --ia-tl-primary );
	--ia-select-edge-hover: var( --ia-tl-hover );
	--ia-select-bg: var( --ia-tl-bg-2 );
	--ia-select-ink: var( --ia-tl-text );
	--ia-select-apagado: var( --ia-tl-muted );
}

/* Barra de desplazamiento ---------------------------------------------------
   Fina y rosa sobre pista transparente, en todo lo que desplace dentro del
   bloque. `scrollbar-width` y `scrollbar-color` se heredan, así que declararlas
   en la raíz alcanza a lo que hay hoy y a lo que se añada mañana; los
   pseudoelementos de WebKit no heredan y hay que nombrarlos aparte, y siguen
   haciendo falta mientras haya Safari sin las propiedades estándar. */
.ia-timeline {
	scrollbar-width: thin;
	scrollbar-color: var( --ia-scroll, #DC84FF ) transparent;
}

.ia-timeline::-webkit-scrollbar,
.ia-timeline *::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

.ia-timeline::-webkit-scrollbar-track,
.ia-timeline *::-webkit-scrollbar-track {
	background: transparent;
}

.ia-timeline::-webkit-scrollbar-thumb,
.ia-timeline *::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: var( --ia-scroll, #DC84FF );
}

/* Scroll area ------------------------------------------------------------- */

/* Always at least 80vh tall so the timeline reads as a full panel even on a
   quiet week; taller content scrolls inside it, vertically and horizontally. */
/* En columna para que el carril de dentro llene el alto del panel. Con
   `align-items: flex-start` porque el carril mide lo que midan sus días y es él
   quien decide su ancho: estirado al del panel perdería el desplazamiento
   horizontal. */
.ia-timeline__wrapper {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-height: 80vh;
	max-height: 85vh;
	overflow: auto;
	border-radius: 12px;
	background: var( --ia-tl-bg-2 );
	overscroll-behavior-x: contain;
}

/* El carril llena el panel aunque no haya eventos que lo llenen —una semana
   tranquila, o un filtro de tipo que deja dos— y crece con ellos cuando los hay.
   Las separaciones de día cuelgan de aquí con `inset: 0`, así que es esta altura
   la que decide hasta dónde llegan.

   `flex-grow` y no `min-height: 100%`: el envoltorio no tiene altura definida
   —es `auto` acotada por su `min-height` y su `max-height`—, así que un
   porcentaje ahí dentro no resuelve contra nada y se quedaba en cero. Las líneas
   se cortaban bajo la última fila y el resto del panel quedaba vacío.
   `flex-shrink: 0` es lo que impide lo contrario: que un calendario más alto que
   el panel se comprima hasta él y las líneas se cortaran al desplazarse. */
.ia-timeline__container {
	position: relative;
	flex: 1 0 auto;
	width: max-content;
	min-width: 100%;
}

.ia-timeline__lines {
	position: absolute;
	inset: 0;
	display: flex;
	pointer-events: none;
	z-index: 10;
}

.ia-timeline__line {
	flex-shrink: 0;
	height: 100%;
	border-left: 1px dashed var( --ia-tl-grid );
	position: relative;
}

.ia-timeline__line.is-week-start::before {
	content: '';
	position: absolute;
	left: 50%;
	top: 0;
	bottom: 0;
	width: 1px;
	background: var( --ia-tl-grid-week );
	z-index: 20;
}

.ia-timeline__line.is-season-end::after {
	content: '';
	position: absolute;
	left: 50%;
	top: 0;
	bottom: 0;
	width: 3px;
	border-radius: 10px;
	background: var( --ia-tl-season-end );
	opacity: .8;
	transform: translateX( -50% );
	z-index: 35;
}

.ia-timeline__line.is-today {
	background: rgba( 255, 217, 0, .1 );
	z-index: 15;
}

.ia-timeline__grid {
	display: grid;
	gap: 0;
	padding-bottom: 20px;
	position: relative;
	z-index: 2;
}

/* Sticky headers ---------------------------------------------------------- */

.ia-timeline__season {
	grid-row: 1;
	position: sticky;
	top: 0;
	z-index: 30;
	display: flex;
	align-items: center;
	height: 36px;
	margin: 0 var( --ia-tl-card-margin );
	border: 1px solid #5d33a5;
	border-radius: 8px 8px 0 0;
	background: linear-gradient( 135deg, var( --ia-tl-secondary ), var( --ia-tl-bg ) );
	box-shadow: 0 4px 10px rgba( 0, 0, 0, .4 );
	font-size: .85rem;
	font-weight: 800;
	letter-spacing: 1px;
	text-transform: uppercase;
	overflow: hidden;
}

.ia-timeline__week {
	grid-row: 2;
	position: sticky;
	top: 36px;
	z-index: 28;
	display: flex;
	align-items: center;
	height: 28px;
	border-bottom: 1px solid rgba( 255, 255, 255, .1 );
	background: var( --ia-tl-bg-2 );
	color: #bfa1f3;
	font-size: .75rem;
	font-weight: 700;
	letter-spacing: .8px;
	text-transform: uppercase;
	overflow: hidden;
}

.ia-timeline__day {
	grid-row: 3;
	position: sticky;
	top: 64px;
	z-index: 25;
	padding: 8px 5px;
	margin-bottom: 8px;
	border-bottom: 2px solid rgba( 255, 255, 255, .1 );
	background: var( --ia-tl-bg-2 );
	color: var( --ia-tl-muted );
	font-size: .8rem;
	text-align: center;
	text-transform: uppercase;
	user-select: none;
}

.ia-timeline__day.is-past {
	background: #080312;
}

.ia-timeline__day.is-today {
	color: var( --ia-tl-primary );
	border-bottom-color: var( --ia-tl-primary );
	font-weight: 700;
}

.ia-timeline__day strong {
	display: block;
	margin-top: 2px;
	color: var( --ia-tl-text );
	font-size: .8rem;
}

/* Sticky label that slides along a wide bar ------------------------------- */

.ia-timeline__sticky {
	position: relative;
	padding: 0 12px;
	white-space: nowrap;
	will-change: transform;
}

/* Event cards ------------------------------------------------------------- */

.ia-timeline__event {
	position: relative;
	z-index: 4;
	display: flex;
	align-items: center;
	margin: 6px var( --ia-tl-card-margin );
	padding: 10px 0;
	border-radius: 12px;
	box-shadow: 0 4px 12px rgba( 0, 0, 0, .3 );
	overflow: hidden;
	/* La tinta del tipo de evento, que el script pone en la propia tarjeta.
	   Sin ella —un tipo que no ha elegido ninguna— manda la de la línea. */
	color: var( --ia-tl-event-ink, var( --ia-tl-text ) );
}

.ia-timeline__past {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	border-radius: 12px;
	background: rgba( 0, 0, 0, .15 );
	pointer-events: none;
	z-index: 1;
}

.ia-timeline__content {
	position: relative;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	padding: 0 16px;
	white-space: nowrap;
	will-change: transform;
}

.ia-timeline__row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ia-timeline__icon {
	width: auto;
	height: 20px;
	object-fit: contain;
	filter: drop-shadow( 0 2px 4px rgba( 0, 0, 0, .4 ) );
}

.ia-timeline__name {
	font-size: .95rem;
	font-weight: 700;
	letter-spacing: .5px;
	text-transform: uppercase;
}

.ia-timeline__dates {
	margin-left: 8px;
	font-size: .75rem;
	font-weight: 400;
	opacity: .85;
}

.ia-timeline__cta {
	display: inline-block;
	margin-top: 4px;
	padding: 6px 28px;
	border: 1.5px solid currentColor;
	border-radius: 50px;
	background: transparent;
	color: inherit;
	font-size: .8rem;
	font-weight: 700;
	text-decoration: none;
	transition: background-color .2s, color .2s, transform .2s;
}

/* Al pasar por encima el botón se da la vuelta: la tinta pasa a fondo y el
   fondo de la tarjeta, a texto. Con las dos variables del tipo de evento en vez
   de con `currentColor`, que aquí resolvería al color que declara esta misma
   regla y dejaría el rótulo del color de su propio fondo. */
.ia-timeline__cta:hover {
	background: var( --ia-tl-event-ink, var( --ia-tl-text ) );
	color: var( --ia-tl-event-bg, var( --ia-tl-bg ) );
	transform: translateY( -1px );
}

/* Tooltip for the titles that do not fit --------------------------------- */

/* A card that runs from Tuesday to Wednesday has no room for its name, and the
   name is clipped rather than wrapped — the bar has to stay one line tall. The
   tooltip is what gives it back, and only the cards that are actually clipped
   get one: `is-clipped` is set by measuring, not guessed from the length.

   Fixed rather than absolute so the panel's own `overflow: hidden` cannot cut
   it, which is exactly what would happen inside the card. */
.ia-timeline__tooltip {
	position: fixed;
	z-index: 100;
	display: flex;
	flex-direction: column;
	gap: 2px;
	max-width: min( 320px, calc( 100vw - 32px ) );
	padding: 8px 12px;
	border: 1px solid var( --ia-tl-primary );
	border-radius: 8px;
	background: var( --ia-tl-bg-2 );
	box-shadow: 0 8px 20px rgba( 0, 0, 0, .45 );
	color: var( --ia-tl-text );
	pointer-events: none;
}

.ia-timeline__tooltip[hidden] {
	display: none;
}

.ia-timeline__tooltip-name {
	font-size: .85rem;
	font-weight: 700;
	letter-spacing: .5px;
	text-transform: uppercase;
}

.ia-timeline__tooltip-dates {
	font-size: .75rem;
	opacity: .75;
}

.ia-timeline__event.is-clipped {
	cursor: help;
}

/* The card only becomes focusable once its title is clipped, so this outline
   is the one the keyboard needs to find the tooltip. */
.ia-timeline__event.is-clipped:focus-visible {
	outline: 2px solid var( --ia-tl-hover );
	outline-offset: 2px;
}

/* Nothing left to draw ---------------------------------------------------- */

/* Sticky rather than centred: the container is as wide as the whole window of
   days, so a note left at its own position would sit off screen. */
.ia-timeline__empty {
	position: sticky;
	left: 0;
	z-index: 40;
	width: fit-content;
	max-width: 100%;
	margin: 24px 20px;
	padding: 0;
	color: var( --ia-tl-muted );
}

.ia-timeline__empty[hidden] {
	display: none;
}

/* Server-rendered fallback, replaced once the script runs ----------------- */

.ia-timeline__fallback {
	margin: 0;
	padding: 16px 20px;
	list-style: none;
}

.ia-timeline__fallback li {
	padding: 6px 0;
	border-bottom: 1px solid var( --ia-tl-grid );
}

.ia-timeline__fallback li:last-child {
	border-bottom: 0;
}

@media ( prefers-reduced-motion: reduce ) {
	.ia-timeline__cta,
	.ia-timeline__today {
		transition: none;
	}
}
