/* ============================================================
   ETW – Timeline Widget for Elementor
   assets/css/timeline.css
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────── */
.etw-timeline {
	--etw-accent:       #6366f1;
	--etw-line-color:   #e0e0e0;
	--etw-line-width:   3px;
	--etw-marker-size:  50px;
	--etw-card-bg:      #ffffff;
	--etw-gap:          40px;
	--etw-center-col:   60px; /* space reserved for line + marker */
}

/* ── Base Reset ─────────────────────────────────────────── */
.etw-timeline *,
.etw-timeline *::before,
.etw-timeline *::after {
	box-sizing: border-box;
}

/* ── Wrapper ────────────────────────────────────────────── */
.etw-timeline {
	position: relative;
	width: 100%;
}

/* ── Line ───────────────────────────────────────────────── */
.etw-line-wrapper {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	width: var(--etw-line-width);
	height: 100%;
	z-index: 0;
}

.etw-line,
.etw-line-progress {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	border-radius: 99px;
}

.etw-line {
	height: 100%;
	background-color: var(--etw-line-color);
}

.etw-line-progress {
	height: 0%;
	background-color: var(--etw-accent);
	transition: height 0.4s ease;
}

/* Connector style overrides */
.etw-connector-dashed .etw-line {
	background: repeating-linear-gradient(
		to bottom,
		var(--etw-line-color) 0px,
		var(--etw-line-color) 10px,
		transparent 10px,
		transparent 20px
	);
}
.etw-connector-dotted .etw-line {
	background: repeating-linear-gradient(
		to bottom,
		var(--etw-line-color) 0px,
		var(--etw-line-color) 4px,
		transparent 4px,
		transparent 14px
	);
}
.etw-connector-double .etw-line-wrapper {
	width: calc(var(--etw-line-width) * 3);
	background: var(--etw-line-color);
}
.etw-connector-double .etw-line {
	width: var(--etw-line-width);
	left: 0;
}
.etw-connector-double .etw-line-progress {
	width: var(--etw-line-width);
	right: 0;
	left: auto;
}

/* ── Items Container ────────────────────────────────────── */
.etw-items {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
}

/* ── Single Item ────────────────────────────────────────── */
.etw-item {
	display: grid;
	align-items: center;
	margin-bottom: var(--etw-gap);
	position: relative;
}

/* ─────────────────────────────────────────────────────────
   LAYOUT: VERTICAL ALTERNADO
   ───────────────────────────────────────────────────────── */
.etw-layout-vertical-alternated .etw-item {
	grid-template-columns: 1fr var(--etw-center-col) 1fr;
	grid-template-areas: "card-left marker card-right";
}

/* Odd items: card on the left */
.etw-layout-vertical-alternated .etw-item:nth-child(odd) .etw-card-wrapper {
	grid-area: card-left;
	text-align: right;
}
.etw-layout-vertical-alternated .etw-item:nth-child(odd) .etw-marker-wrapper {
	grid-area: marker;
}
/* Placeholder empty on the right */
.etw-layout-vertical-alternated .etw-item:nth-child(odd)::after {
	content: "";
	grid-area: card-right;
}

/* Even items: card on the right */
.etw-layout-vertical-alternated .etw-item:nth-child(even) .etw-card-wrapper {
	grid-area: card-right;
}
.etw-layout-vertical-alternated .etw-item:nth-child(even) .etw-marker-wrapper {
	grid-area: marker;
}
.etw-layout-vertical-alternated .etw-item:nth-child(even)::before {
	content: "";
	grid-area: card-left;
}

/* Arrows */
.etw-layout-vertical-alternated .etw-item:nth-child(odd) .etw-card-arrow {
	right: -10px;
	left: auto;
	border-left-width: 10px;
	border-right-width: 0;
}
.etw-layout-vertical-alternated .etw-item:nth-child(even) .etw-card-arrow {
	left: -10px;
}

/* ─────────────────────────────────────────────────────────
   LAYOUT: VERTICAL FIXO ESQUERDA
   ───────────────────────────────────────────────────────── */
.etw-layout-vertical-left .etw-line-wrapper {
	left: calc(var(--etw-center-col) / 2);
	transform: none;
}

.etw-layout-vertical-left .etw-item {
	grid-template-columns: var(--etw-center-col) 1fr;
	grid-template-areas: "marker card-right";
}

.etw-layout-vertical-left .etw-marker-wrapper { grid-area: marker; }
.etw-layout-vertical-left .etw-card-wrapper   { grid-area: card-right; }
.etw-layout-vertical-left .etw-card-arrow     { left: -10px; }

/* ─────────────────────────────────────────────────────────
   LAYOUT: VERTICAL FIXO DIREITA
   ───────────────────────────────────────────────────────── */
.etw-layout-vertical-right .etw-line-wrapper {
	left: auto;
	right: calc(var(--etw-center-col) / 2);
	transform: none;
}

.etw-layout-vertical-right .etw-item {
	grid-template-columns: 1fr var(--etw-center-col);
	grid-template-areas: "card-left marker";
}

.etw-layout-vertical-right .etw-card-wrapper   { grid-area: card-left; text-align: right; }
.etw-layout-vertical-right .etw-marker-wrapper { grid-area: marker; }
.etw-layout-vertical-right .etw-card-arrow     { right: -10px; left: auto; border-left-width: 10px; border-right-width: 0; }

/* ─────────────────────────────────────────────────────────
   LAYOUT: HORIZONTAL
   ───────────────────────────────────────────────────────── */
.etw-layout-horizontal .etw-line-wrapper {
	top: 50%;
	left: 0;
	transform: translateY(-50%);
	width: 100%;
	height: var(--etw-line-width);
}

.etw-layout-horizontal .etw-line,
.etw-layout-horizontal .etw-line-progress {
	height: 100%;
	width: 100%;
}

.etw-layout-horizontal .etw-line-progress {
	width: 0%;
	height: 100%;
	top: 0;
}

.etw-layout-horizontal .etw-items {
	flex-direction: row;
	align-items: flex-start;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scroll-snap-type: x mandatory;
	gap: 16px;
	padding: 0 0 16px;
}

.etw-layout-horizontal .etw-item {
	grid-template-columns: auto;
	grid-template-rows: 1fr var(--etw-center-col) 1fr;
	grid-template-areas:
		"card-top"
		"marker"
		"card-bottom";
	flex: 0 0 240px;
	margin-bottom: 0;
	scroll-snap-align: start;
}

.etw-layout-horizontal .etw-marker-wrapper { grid-area: marker; }
.etw-layout-horizontal .etw-card-wrapper   { grid-area: card-bottom; }

.etw-layout-horizontal .etw-item:nth-child(even) .etw-card-wrapper {
	grid-area: card-top;
}
.etw-layout-horizontal .etw-item:nth-child(even)::before {
	content: "";
	grid-area: card-bottom;
}

.etw-layout-horizontal .etw-card-arrow {
	display: none;
}

/* ── Marker ─────────────────────────────────────────────── */
.etw-marker-wrapper {
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 2;
}

.etw-marker {
	display: flex;
	justify-content: center;
	align-items: center;
	width: var(--etw-marker-size);
	height: var(--etw-marker-size);
	background-color: var(--etw-accent);
	border-radius: 50%;
	color: #fff;
	font-size: 20px;
	flex-shrink: 0;
	position: relative;
	z-index: 2;
	transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.etw-marker i,
.etw-marker svg {
	color: inherit;
	fill: currentColor;
	font-size: inherit;
}

.etw-marker-number,
.etw-marker-date {
	font-size: 0.75em;
	font-weight: 700;
	color: inherit;
	text-align: center;
	line-height: 1.2;
}

.etw-marker-dot {
	display: block;
	width: 40%;
	height: 40%;
	background: currentColor;
	border-radius: 50%;
}

.etw-item:hover .etw-marker,
.etw-item.is-active .etw-marker {
	transform: scale(1.15);
}

/* ── Card ───────────────────────────────────────────────── */
.etw-card-wrapper {
	padding: 0 16px;
}

.etw-card {
	position: relative;
	background: var(--etw-card-bg);
	border-radius: 12px;
	padding: 24px;
	box-shadow: 0 4px 24px rgba(0,0,0,0.08);
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	overflow: hidden;
}

.etw-card:hover {
	transform: translateY(-4px);
}

/* Arrow connector */
.etw-card-arrow {
	position: absolute;
	top: 50%;
	left: -10px;
	transform: translateY(-50%);
	width: 0;
	height: 0;
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent;
	border-right: 10px solid var(--etw-card-bg);
}

/* ── Card Body ──────────────────────────────────────────── */
.etw-item-image {
	margin: -24px -24px 20px;
	overflow: hidden;
	border-radius: 12px 12px 0 0;
}

.etw-item-image img {
	width: 100%;
	height: 200px;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.etw-card:hover .etw-item-image img {
	transform: scale(1.04);
}

.etw-item-date {
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--etw-accent);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	margin-bottom: 8px;
}

.etw-item-title {
	margin: 0 0 10px;
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.35;
	color: #1a1a2e;
}

.etw-item-description {
	font-size: 0.92rem;
	line-height: 1.65;
	color: #555;
}

.etw-item-description p:last-child { margin-bottom: 0; }

/* ── Button ─────────────────────────────────────────────── */
.etw-btn {
	display: inline-block;
	margin-top: 16px;
	padding: 10px 20px;
	background-color: var(--etw-accent);
	color: #fff;
	font-size: 0.88rem;
	font-weight: 600;
	text-decoration: none;
	border-radius: 6px;
	border: none;
	cursor: pointer;
	transition: background-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
	line-height: 1;
}

.etw-btn:hover {
	filter: brightness(1.1);
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(99,102,241,0.35);
}

/* ─────────────────────────────────────────────────────────
   ANIMATIONS
   ───────────────────────────────────────────────────────── */

/* Base hidden state */
.etw-timeline[data-anim]:not([data-anim="none"]) .etw-item {
	opacity: 0;
	will-change: opacity, transform;
}

/* Fade In */
.etw-timeline[data-anim="fade"] .etw-item             { opacity: 0; }
.etw-timeline[data-anim="fade"] .etw-item.is-visible  { opacity: 1; }

/* Fade + Slide */
.etw-timeline[data-anim="fade-slide"] .etw-item { opacity: 0; transform: translateY(30px); }
.etw-timeline[data-anim="fade-slide"] .etw-item.is-visible { opacity: 1; transform: translateY(0); }

/* Zoom */
.etw-timeline[data-anim="zoom"] .etw-item { opacity: 0; transform: scale(0.85); }
.etw-timeline[data-anim="zoom"] .etw-item.is-visible { opacity: 1; transform: scale(1); }

/* Flip */
.etw-timeline[data-anim="flip"] .etw-item { opacity: 0; transform: perspective(600px) rotateX(-20deg); }
.etw-timeline[data-anim="flip"] .etw-item.is-visible { opacity: 1; transform: perspective(600px) rotateX(0deg); }

/* Slide from sides (alternated layout) */
.etw-layout-vertical-alternated[data-anim="fade-slide"] .etw-item:nth-child(odd) {
	transform: translateX(-40px);
	opacity: 0;
}
.etw-layout-vertical-alternated[data-anim="fade-slide"] .etw-item:nth-child(even) {
	transform: translateX(40px);
	opacity: 0;
}
.etw-layout-vertical-alternated[data-anim="fade-slide"] .etw-item.is-visible {
	transform: translateX(0);
	opacity: 1;
}

/* ─────────────────────────────────────────────────────────
   POPUP OVERLAY
   ───────────────────────────────────────────────────────── */
.etw-popup-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.7);
	z-index: 99999;
	display: flex !important;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.etw-popup-overlay.is-open {
	opacity: 1;
	pointer-events: all;
}

.etw-popup-inner {
	position: relative;
	background: #fff;
	border-radius: 16px;
	padding: 40px;
	max-width: 680px;
	width: 100%;
	max-height: 85vh;
	overflow-y: auto;
	transform: scale(0.9) translateY(20px);
	transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
	box-shadow: 0 25px 80px rgba(0,0,0,0.25);
}

.etw-popup-overlay.is-open .etw-popup-inner {
	transform: scale(1) translateY(0);
}

.etw-popup-close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 36px;
	height: 36px;
	background: #f0f0f5;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	color: #333;
}

.etw-popup-close:hover { background: #e0e0eb; }
.etw-popup-close svg { width: 18px; height: 18px; }

/* ─────────────────────────────────────────────────────────
   CURSOR (has-popup cards)
   ───────────────────────────────────────────────────────── */
.etw-has-popup { cursor: pointer; }

/* ─────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────── */
@media screen and (max-width: 1024px) {
	/* Horizontal → vertical */
	.etw-layout-horizontal .etw-line-wrapper {
		left: 50%;
		top: 0;
		transform: translateX(-50%);
		width: var(--etw-line-width);
		height: 100%;
	}
	.etw-layout-horizontal .etw-items {
		flex-direction: column;
		overflow-x: visible;
	}
	.etw-layout-horizontal .etw-item {
		grid-template-columns: var(--etw-center-col) 1fr;
		grid-template-rows: auto;
		grid-template-areas: "marker card-right";
		flex: none;
		margin-bottom: var(--etw-gap);
	}
	.etw-layout-horizontal .etw-item:nth-child(even) .etw-card-wrapper {
		grid-area: card-right;
	}
	.etw-layout-horizontal .etw-card-arrow {
		display: block;
	}
}

@media screen and (max-width: 768px) {
	/* All vertical layouts → single column on right */
	.etw-layout-vertical-alternated .etw-item,
	.etw-layout-vertical-right .etw-item {
		grid-template-columns: var(--etw-center-col) 1fr;
		grid-template-areas: "marker card-right";
	}

	.etw-layout-vertical-alternated .etw-item:nth-child(odd) .etw-card-wrapper,
	.etw-layout-vertical-alternated .etw-item:nth-child(even) .etw-card-wrapper,
	.etw-layout-vertical-right .etw-card-wrapper {
		grid-area: card-right;
		text-align: left;
	}

	.etw-layout-vertical-alternated .etw-item:nth-child(odd) .etw-card-arrow,
	.etw-layout-vertical-alternated .etw-item:nth-child(even) .etw-card-arrow,
	.etw-layout-vertical-right .etw-card-arrow {
		left: -10px;
		right: auto;
		border-right-width: 10px;
		border-left-width: 0;
	}

	/* Move line to the left */
	.etw-layout-vertical-alternated .etw-line-wrapper,
	.etw-layout-vertical-right .etw-line-wrapper {
		left: calc(var(--etw-center-col) / 2);
		transform: none;
	}

	.etw-card {
		padding: 18px;
	}

	.etw-popup-inner {
		padding: 28px 20px;
	}
}

@media screen and (max-width: 480px) {
	:root {
		--etw-marker-size: 38px;
		--etw-center-col: 50px;
	}

	.etw-item-title { font-size: 1rem; }
	.etw-item-description { font-size: 0.88rem; }
}

/* ─────────────────────────────────────────────────────────
   ELEMENTOR EDITOR adjustments
   ───────────────────────────────────────────────────────── */
.elementor-editor-active .etw-item {
	opacity: 1 !important;
	transform: none !important;
}
