/* ============================================================
 * Chronos for Elementor — frontend styles
 * Vanilla CSS, BEM, custom properties.
 * ============================================================ */

:root {
	--chronos-bg:           transparent;
	--chronos-fg:           #1f2937;
	--chronos-muted:        #64748b;
	--chronos-accent:       #3b82f6;
	--chronos-card-bg:      #ffffff;
	--chronos-card-border:  #e5e7eb;
	--chronos-card-radius:  12px;
	--chronos-thread:       #cbd5e1;
	--chronos-marker-size:  14px;
	--chronos-anim-dur:     600ms;
}

@media (prefers-color-scheme: dark) {
	:root {
		--chronos-fg:          #e5e7eb;
		--chronos-muted:       #94a3b8;
		--chronos-card-bg:     #1f2937;
		--chronos-card-border: #374151;
		--chronos-thread:      #475569;
	}
}

/* ----- Wrapper ----- */
.chronos {
	position: relative;
	color: var(--chronos-fg);
	box-sizing: border-box;
}
.chronos *, .chronos *::before, .chronos *::after { box-sizing: inherit; }

.chronos--breakout-break-out {
	width: 100vw;
	margin-left: calc(50% - 50vw);
}
.chronos--breakout-full-bleed {
	width: 100vw;
	margin-left: calc(50% - 50vw);
	padding-inline: 6vw;
}

/* ----- Viewport (the scrollable area) ----- */
.chronos__viewport {
	position: relative;
	overflow: hidden;
}

/* ----- Track (the flex container holding the cards) ----- */
.chronos__track {
	position: relative;
	display: flex;
	gap: 24px;
	padding: 32px 0;
	background: var(--chronos-bg);
}

.chronos--orient-horizontal .chronos__track {
	flex-direction: row;
	/* Stretch all cards to the row's tallest height so the central thread
	 * passes through every card's midpoint and markers stay aligned. */
	align-items: stretch;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
	scroll-behavior: smooth;
}
.chronos--orient-horizontal .chronos__track::-webkit-scrollbar { display: none; }

/* Internal flex column on horizontal cards so the body fills the stretched
 * height naturally (no awkward empty space when one card has much more text). */
.chronos--orient-horizontal .chronos__card {
	display: flex;
	flex-direction: column;
}
.chronos--orient-horizontal .chronos__body { flex: 1 1 auto; }

.chronos--orient-vertical .chronos__track {
	flex-direction: column;
	align-items: stretch;
}

.chronos--hmode-uniform .chronos__track {
	align-items: stretch;
}

/* ----- The thread (line) -----
 * Horizontal: sits inside the reserved top strip (chronos-strip-height),
 *   so all markers and period bars line up regardless of card heights.
 * Vertical:   runs floor-to-ceiling, centered or to-axis depending on style.
 */
.chronos__thread {
	position: absolute;
	background: var(--chronos-thread);
	pointer-events: none;
}
.chronos--orient-horizontal .chronos__thread {
	left: 0; right: 0;
	top: 50%;
	height: 2px;
	transform: translateY(-50%);
}
.chronos--orient-vertical .chronos__thread {
	top: 0; bottom: 0;
	left: 50%;
	width: 2px;
	transform: translateX(-50%);
}
.chronos--vstyle-axis-left .chronos__thread   { left: 32px; transform: none; }
.chronos--vstyle-axis-right .chronos__thread  { left: auto; right: 32px; transform: none; }

.chronos--thread-dotted .chronos__thread { background: transparent; border-top: 2px dotted var(--chronos-thread); }
.chronos--thread-dashed .chronos__thread { background: transparent; border-top: 2px dashed var(--chronos-thread); }
.chronos--orient-vertical.chronos--thread-dotted .chronos__thread { border-top: none; border-left: 2px dotted var(--chronos-thread); background: transparent; }
.chronos--orient-vertical.chronos--thread-dashed .chronos__thread { border-top: none; border-left: 2px dashed var(--chronos-thread); background: transparent; }
.chronos--thread-gradient .chronos__thread {
	background: linear-gradient(90deg, var(--chronos-accent), transparent);
}

/* ----- Card ----- */
.chronos__card {
	position: relative;
	flex: 0 0 320px;
	min-width: 320px;
	background: var(--chronos-card-bg);
	border: 1px solid var(--chronos-card-border);
	border-radius: var(--chronos-card-radius);
	padding: 20px;
	transition: transform 200ms ease, box-shadow 200ms ease;
}

.chronos--orient-vertical .chronos__card {
	flex: 0 0 auto;
	max-width: min(720px, 100%);
}

.chronos__card--clickable { cursor: pointer; }
.chronos__card--clickable:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.chronos__card--featured { box-shadow: 0 12px 32px rgba(0,0,0,.12); }
.chronos__card--compact .chronos__content,
.chronos__card--compact .chronos__gallery { display: none; }

.chronos__card-link {
	position: absolute; inset: 0;
	z-index: 1;
	text-indent: -9999px;
	overflow: hidden;
}

/* Vertical zigzag — :nth-of-type(article) so the .chronos__thread <div>
   sibling does not shift the parity count. Cards constrained to ~half-width
   to leave room for the centered thread between left and right columns. */
.chronos--orient-vertical.chronos--vstyle-alternating .chronos__card {
	width: calc(50% - 24px);
	max-width: calc(50% - 24px);
}
.chronos--orient-vertical.chronos--vstyle-alternating .chronos__card:nth-of-type(odd)  { align-self: flex-start; }
.chronos--orient-vertical.chronos--vstyle-alternating .chronos__card:nth-of-type(even) { align-self: flex-end;   }

/* In alternating mode, position the marker on the inner edge so it visually
   touches the central thread (offset = half marker + small visual gap). */
.chronos--orient-vertical.chronos--vstyle-alternating .chronos__card:nth-of-type(odd)  .chronos__marker { right: calc(-1 * (var(--chronos-marker-size) / 2 + 12px)); left: auto; }
.chronos--orient-vertical.chronos--vstyle-alternating .chronos__card:nth-of-type(even) .chronos__marker { left:  calc(-1 * (var(--chronos-marker-size) / 2 + 12px)); right: auto; }

/* Pull each row back so the n+1 card visually starts above the previous one
   (classic biographical zigzag where adjacent items are time-staggered). */
.chronos--orient-vertical.chronos--vstyle-alternating .chronos__card + .chronos__card {
	margin-top: -16px;
}

/* ----- Marker on the thread ----- */
.chronos__marker {
	position: absolute;
	width: var(--chronos-marker-size);
	height: var(--chronos-marker-size);
	background: var(--chronos-item-accent, var(--chronos-accent));
	border: 2px solid var(--chronos-card-bg);
	border-radius: 50%;
	z-index: 2;
}
.chronos--marker-square  .chronos__marker { border-radius: 2px; }
.chronos--marker-diamond .chronos__marker { border-radius: 0; transform: rotate(45deg); }
.chronos--marker-icon    .chronos__marker { border-radius: 0; background: transparent; border: 0; color: var(--chronos-item-accent, var(--chronos-accent)); }

/* Horizontal: marker sits at the card's midpoint. Because the track uses
 * align-items:stretch, every card has the same height — so every card's
 * midpoint is on the same Y, and so is the central thread. Aligned. */
.chronos--orient-horizontal .chronos__marker { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.chronos--orient-horizontal.chronos--marker-diamond .chronos__marker { transform: translate(-50%, -50%) rotate(45deg); }
.chronos--orient-vertical .chronos__marker { top: 24px; }

/* Default vertical position: marker on inner side of card. Each vstyle overrides below. */
.chronos--orient-vertical.chronos--vstyle-axis-left  .chronos__card .chronos__marker { left:  calc(-1 * (var(--chronos-marker-size) / 2 + 8px)); }
.chronos--orient-vertical.chronos--vstyle-axis-right .chronos__card .chronos__marker { right: calc(-1 * (var(--chronos-marker-size) / 2 + 8px)); }
.chronos--orient-vertical.chronos--vstyle-centered   .chronos__card .chronos__marker { left: 50%; top: -8px; transform: translateX(-50%); }
.chronos--orient-vertical.chronos--vstyle-centered.chronos--marker-diamond .chronos__card .chronos__marker { transform: translateX(-50%) rotate(45deg); }

/* ----- Image ----- */
.chronos__image {
	margin: -20px -20px 16px;
	overflow: hidden;
	border-top-left-radius: var(--chronos-card-radius);
	border-top-right-radius: var(--chronos-card-radius);
}
.chronos__image img { display: block; width: 100%; height: auto; }
.chronos--imgpos-left  .chronos__card { display: grid; grid-template-columns: 40% 1fr; gap: 16px; padding: 0; }
.chronos--imgpos-left  .chronos__image { margin: 0; border-radius: var(--chronos-card-radius) 0 0 var(--chronos-card-radius); }
.chronos--imgpos-right .chronos__card { display: grid; grid-template-columns: 1fr 40%; gap: 16px; padding: 0; }
.chronos--imgpos-right .chronos__image { order: 2; margin: 0; border-radius: 0 var(--chronos-card-radius) var(--chronos-card-radius) 0; }

/* ----- Body parts ----- */
.chronos__date     { display: block; font-size: 0.85rem; color: var(--chronos-muted); letter-spacing: .04em; text-transform: uppercase; }
.chronos__tag      { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--chronos-accent); color: #fff; font-size: 0.75rem; }
.chronos__title    { margin: 8px 0 4px; font-size: 1.25rem; line-height: 1.3; }
.chronos__title a  { color: inherit; text-decoration: none; }
.chronos__subtitle { margin: 0 0 12px; color: var(--chronos-muted); font-size: 0.95rem; }
.chronos__content  { font-size: 0.95rem; line-height: 1.55; }

.chronos__cta {
	display: inline-block;
	margin-top: 12px;
	padding: 8px 16px;
	border-radius: 8px;
	background: var(--chronos-item-accent, var(--chronos-accent));
	color: #fff;
	text-decoration: none;
	font-weight: 600;
	position: relative; z-index: 2;
}

/* ----- Gallery ----- */
.chronos__gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
	gap: 6px;
	margin-top: 12px;
}
.chronos__gallery-item img { display: block; width: 100%; height: 80px; object-fit: cover; border-radius: 6px; }

/* ----- Periods -----
 * The .chronos__periods container is sibling to the cards and stretches the
 * full track via inset:0. The JS runtime (positionPeriodBars) places each bar
 * in absolute coordinates spanning from the first to the last member card.
 * Bars start hidden (zero size) so they don't flash before the JS runs.
 */
.chronos__periods {
	position: absolute;
	pointer-events: none;
	inset: 0;
}
.chronos__period-bar {
	position: absolute;
	background: var(--chronos-period-color, var(--chronos-accent));
	border-radius: 4px;
	opacity: 0.7;
	transition: opacity 200ms ease;
}
.chronos--orient-horizontal .chronos__period-bar { top: calc(50% - 18px); height: 4px; width: 0; }
.chronos--orient-vertical   .chronos__period-bar { left: calc(50% - 18px); width: 4px; height: 0; }

.chronos__period-label {
	position: absolute;
	font-size: 0.75rem;
	color: var(--chronos-period-color, var(--chronos-accent));
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	background: var(--chronos-card-bg);
	padding: 2px 8px;
	border-radius: 4px;
	white-space: nowrap;
	box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ----- Nav buttons ----- */
.chronos__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	width: 40px; height: 40px;
	border-radius: 50%;
	background: var(--chronos-card-bg);
	border: 1px solid var(--chronos-card-border);
	color: var(--chronos-fg);
	font-size: 1.25rem;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.chronos__nav--prev { left: 8px; }
.chronos__nav--next { right: 8px; }
.chronos__nav:disabled { opacity: 0.35; cursor: default; }

/* ----- Filters ----- */
.chronos__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;
}
.chronos__filter {
	padding: 6px 14px;
	border-radius: 999px;
	background: transparent;
	border: 1px solid var(--chronos-card-border);
	cursor: pointer;
	font: inherit;
	color: inherit;
}
.chronos__filter.is-active {
	background: var(--chronos-accent);
	color: #fff;
	border-color: transparent;
}

/* ----- Empty + a11y ----- */
.chronos__empty {
	padding: 40px;
	text-align: center;
	color: var(--chronos-muted);
}
.chronos__card:focus-within { outline: 2px solid var(--chronos-accent); outline-offset: 4px; }

/* ----- Animations ----- */
.chronos__card[data-anim] {
	opacity: 0;
	transition: opacity var(--chronos-anim-dur), transform var(--chronos-anim-dur);
}
.chronos__card[data-anim="fade"]            { opacity: 0; }
.chronos__card[data-anim="slide-up"]        { transform: translateY(24px); }
.chronos__card[data-anim="slide-from-side"] { transform: translateX(24px); }
.chronos__card[data-anim="zoom-in"]         { transform: scale(.95); }
.chronos__card[data-anim="flip"]            { transform: rotateX(20deg); transform-origin: top center; }
.chronos__card.is-in-view {
	opacity: 1;
	transform: none;
}
@media (prefers-reduced-motion: reduce) {
	.chronos__card[data-anim] { opacity: 1; transform: none; transition: none; }
}
