/*! Chronos · (c) 2026 Antichaos — antichaosdata.com. All rights reserved. Proprietary. */
:root {
  --accent: #5b8def;
  --bg: #fbfcfe;
  --card-bg: #ffffff;
  --ink: #151b26;
  --ink-soft: #5d6878;
  --ink-faint: #8b97a8;
  --line: #e7ecf3;
  --line-strong: #d6dee9;
  --radius: 16px;
  --radius-sm: 10px;
  --gap: 46px;
  --shadow-sm: 0 1px 2px rgba(20, 28, 42, .05), 0 2px 6px rgba(20, 28, 42, .05);
  --shadow: 0 4px 14px rgba(20, 28, 42, .08), 0 14px 34px rgba(20, 28, 42, .08);
  --shadow-lg: 0 22px 60px rgba(20, 28, 42, .22);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-ghost: color-mix(in srgb, var(--accent) 7%, transparent);
  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

/* Dark palette: applied explicitly via [data-theme="dark"], or via the OS
   preference only when the user left the theme on "auto". */
:root[data-theme="dark"] {
  --bg: #0e1218;
  --card-bg: #171e29;
  --ink: #eef2f8;
  --ink-soft: #9aa6b6;
  --ink-faint: #6b7888;
  --line: #283039;
  --line-strong: #38424f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 8px 28px rgba(0, 0, 0, .42);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0e1218;
    --card-bg: #171e29;
    --ink: #eef2f8;
    --ink-soft: #9aa6b6;
    --ink-faint: #6b7888;
    --line: #283039;
    --line-strong: #38424f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 8px 28px rgba(0, 0, 0, .42);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { height: 100%; overflow: hidden; }
#state-data { height: 100%; position: relative; }

/* Demo-mode banner — a slim floating pill over the sample timeline, clearly
   marking it as placeholder data with one click to dismiss to the setup card. */
.demo-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 20; display: flex; align-items: center; gap: 9px;
  max-width: calc(100% - 24px);
  padding: 6px 7px 6px 11px; border-radius: 999px;
  background: var(--card-bg); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 12px; color: var(--ink-soft);
}
.demo-tag {
  background: var(--accent); color: #fff; font-weight: 700; font-size: 11px;
  padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; flex: 0 0 auto;
}
.demo-msg { line-height: 1.35; }
.demo-msg strong { color: var(--ink); font-weight: 700; }
.demo-x {
  flex: 0 0 auto; border: 0; background: var(--accent-soft); color: var(--accent);
  font: inherit; font-weight: 600; font-size: 11.5px; padding: 5px 11px;
  border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: filter .15s ease;
}
.demo-x:hover { filter: brightness(.97); }
@media (max-width: 460px) { .demo-msg { display: none; } }

.setup-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.setup-actions .btn { margin-top: 0; }
.btn-ghost {
  background: transparent; color: var(--ink-soft);
  box-shadow: none; border: 1px solid var(--line-strong);
}
.btn-ghost:hover { filter: none; background: var(--accent-ghost); color: var(--ink); }

/* ---------- Empty / loading / error states ---------- */
.state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 6px;
}
.state h2 { margin: 6px 0 2px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.state p { margin: 0; color: var(--ink-soft); max-width: 380px; line-height: 1.6; font-size: 13.5px; }
.state-icon {
  font-size: 30px;
  width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 22px;
  background: var(--accent-soft);
  margin-bottom: 6px;
}

.btn {
  margin-top: 18px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 24px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

/* Antichaos brand lockup on the setup state */
.brand-setup { margin-top: 22px; opacity: .9; }
.brand-setup:hover { opacity: 1; }

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====================================================== */
/*  Timeline — shared                                     */
/* ====================================================== */
.timeline { position: relative; height: 100%; }
.spine { position: absolute; background: var(--line); z-index: 0; }
.track { position: relative; z-index: 1; }

.event { position: relative; opacity: 0; }
.event.in { opacity: 1; }

.node {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card-bg);
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 7px var(--accent-soft);
  z-index: 2;
  transition: box-shadow .2s ease;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow .22s ease, transform .22s ease, border-color .22s ease;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.card .media {
  background: linear-gradient(135deg, var(--line), var(--accent-ghost));
  flex: 0 0 auto;
}
.card .media img {
  display: block; width: 100%; height: var(--img-h, 150px);
  object-fit: var(--img-fit, cover);
  object-position: var(--img-pos, center);
  cursor: zoom-in;
  transition: transform .35s ease;
}
.card:hover .media img { transform: scale(1.03); }
.card .media.broken { display: none; }
:root[data-images="off"] .card .media { display: none; }
.card .body { padding: 15px 17px 17px; flex: 1 1 auto; min-width: 0; }

/* ---- Image placement (top default / bottom / left / right) ---- */
:root[data-imgplace="bottom"] .card { flex-direction: column-reverse; }
:root[data-imgplace="left"] .card { flex-direction: row; align-items: stretch; }
:root[data-imgplace="right"] .card { flex-direction: row-reverse; align-items: stretch; }
/* Side images become a fixed-width column whose picture fills the card height. */
:root[data-imgplace="left"] .card .media,
:root[data-imgplace="right"] .card .media { flex: 0 0 var(--img-w, 124px); }
:root[data-imgplace="left"] .card .media img,
:root[data-imgplace="right"] .card .media img { height: 100%; }
/* Side-image cards always read left-to-right, even on the right (side-a) column. */
:root[data-imgplace="left"] .timeline.vertical .event.side-a .card,
:root[data-imgplace="right"] .timeline.vertical .event.side-a .card { text-align: left; }
:root[data-imgplace="left"] .timeline.vertical .event.side-a .date,
:root[data-imgplace="right"] .timeline.vertical .event.side-a .date { margin-left: 0; }
.card .date {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 7px;
}
.card .date::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); flex: 0 0 auto;
}
.card .title {
  margin: 0 0 7px; font-size: 16px; line-height: 1.32;
  font-weight: 700; letter-spacing: -.01em; color: var(--ink);
}
.card .desc {
  margin: 0; font-size: 13px; line-height: 1.62; color: var(--ink-soft);
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 4; overflow: hidden;
}
.card.expanded .desc { -webkit-line-clamp: unset; }
/* Real "Show more" button (added only when the text is actually clamped) — its
   own click target, so it never competes with a card-level click action. */
.card .more {
  display: inline-block; margin-top: 9px;
  border: 0; background: none; padding: 0;
  font: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--accent); cursor: pointer;
}
.card .more:hover { text-decoration: underline; }

/* Explicit per-card action button (set-parameter-on-click). */
.card .act-btn {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 14px;
  border: 0;
  background: var(--accent); color: #fff;
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .01em;
  padding: 8px 15px; border-radius: 999px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
  max-width: 100%;
}
.card .act-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .act-btn::after {
  content: "→"; font-weight: 700; flex: 0 0 auto;
  transition: transform .15s ease;
}
.card .act-btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: var(--shadow); }
.card .act-btn:hover::after { transform: translateX(2px); }
.card .act-btn:active { transform: translateY(0); }

/* Whole-card click action: pointer + accent ring + hover lift. */
.timeline.card-action .card { cursor: pointer; }
.timeline.card-action .card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.timeline.card-action .card .more,
.timeline.card-action .card .media img { cursor: pointer; }

/* When the lightbox is disabled, images aren't zoomable. */
:root[data-lightbox="off"] .card .media img { cursor: default; }

/* ---------- Date-group divider ---------- */
/* Two-track ("By category") legend — names the two sides and their colours. */
.split-legend {
  display: flex; flex-wrap: wrap; gap: 10px 22px;
  align-items: center; justify-content: center;
  padding: 4px 12px 16px;
}
.split-legend .sl-item {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.split-legend .sl-dot { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }

.divider { position: relative; width: 100%; text-align: center; padding-bottom: var(--gap); }
.divider span {
  display: inline-block;
  background: var(--accent); color: #fff;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 6px 16px; border-radius: 999px;
  box-shadow: 0 4px 14px var(--accent-soft), var(--shadow-sm);
  position: relative; z-index: 3;
}
.timeline.horizontal .divider {
  flex: 0 0 auto; width: auto; padding: 0; margin: 0 16px; align-self: center;
}

/* ====================================================== */
/*  Vertical                                              */
/* ====================================================== */
.timeline.vertical { overflow-y: auto; overflow-x: hidden; padding: 28px 0; }
.timeline.vertical .spine {
  top: 0; bottom: 0; left: 50%;
  width: 2px; transform: translateX(-1px);
  background: linear-gradient(to bottom, transparent, var(--line) 5%, var(--line) 95%, transparent);
}
.timeline.vertical .track {
  position: relative;
  max-width: 960px; margin: 0 auto;
  padding: 0 24px;
}
/* Each event is its own full-width row; the card occupies one half and the
   node sits on the centre line. This keeps a clean zigzag even when cards
   have very different heights (e.g. ones with images). */
.timeline.vertical .event {
  position: relative;
  width: 100%;
  padding-bottom: var(--evgap, var(--gap));
  transform: translateY(24px);
  transition: opacity .5s ease var(--delay), transform .5s ease var(--delay);
}
.timeline.vertical .event.in { transform: translateY(0); }

.timeline.vertical .event .card { width: calc(50% - 40px); }
.timeline.vertical .event.side-a .card { margin-right: auto; text-align: right; }
.timeline.vertical .event.side-b .card { margin-left: auto; text-align: left; }
.timeline.vertical .event.side-a .date { margin-left: auto; }

.timeline.vertical .event .node {
  top: 6px; left: 50%; transform: translateX(-50%);
}
/* Connector stub linking each card to the centre node */
.timeline.vertical .event::before {
  content: ""; position: absolute;
  top: 12px; height: 2px; width: 32px; background: var(--line); z-index: 0;
}
.timeline.vertical .event.side-a::before { left: calc(50% - 40px); }
.timeline.vertical .event.side-b::before { left: calc(50% + 8px); }

/* ---- Swirl: a curved spine (SVG path drawn by chronos.js through the nodes) ----
   Nodes alternate sides of the centre by --amp; the card gives up that room; the leader
   runs from the card's edge to the node; the card is an open bracket, the reference look. */
/* amplitude: a very slight swing by default - the spine leans left and right, it does not snake */
.timeline.vertical.swirl { --amp: 3.5%; }
.timeline.vertical.swirl-medium { --amp: 6%; }
.timeline.vertical.swirl-large { --amp: 10%; }
.timeline.vertical.swirl .spine { display: none; }
.timeline.vertical.swirl .swirl-path { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 0; }
.timeline.vertical.swirl .swirl-path path { fill: none; stroke: var(--line-strong); stroke-width: 1.5; stroke-linecap: round; }
.timeline.vertical.swirl .swirl-path .p2 { transform: translateX(4px); }
.timeline.vertical.swirl.line-single .swirl-path .p2 { display: none; }
.timeline.vertical.swirl .swirl-path path.draw { transition: stroke-dashoffset 1.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .timeline.vertical.swirl .swirl-path path.draw { transition: none; } }
.timeline.vertical.swirl .event.side-a .node { left: calc(50% + var(--amp)); }
.timeline.vertical.swirl .event.side-b .node { left: calc(50% - var(--amp)); }
.timeline.vertical.swirl .event .card { width: calc(50% - var(--amp) - 40px); }
/* The node sits at the card's BOTTOM edge, so the bracket's bottom line, the leader and the dot
   read as one stroke running into the curve (the reference look). --evgap is the row's bottom
   padding (proportional spacing sets it per event). */
.timeline.vertical.swirl .event .node { top: auto; bottom: calc(var(--evgap, var(--gap)) - 7px); }
/* leader: from the card's inner edge (50% ∓ amp ∓ 40px) across the centre to the node (50% ± amp) */
.timeline.vertical.swirl .event::before { top: auto; bottom: calc(var(--evgap, var(--gap)) - 1px); height: 1.5px; width: calc(2 * var(--amp) + 40px); background: var(--line-strong); }
.timeline.vertical.swirl .event.side-a::before { left: calc(50% - var(--amp) - 40px); }
.timeline.vertical.swirl .event.side-b::before { left: calc(50% - var(--amp)); }
.timeline.vertical.swirl .card {
  background: transparent; box-shadow: none; overflow: visible;
  border: 0; border-bottom: 1.5px solid var(--line-strong); border-radius: 0;
  padding-bottom: 12px;
}
/* the bracket's vertical bar is on the far side (away from the curve), rounded at the bottom */
.timeline.vertical.swirl .event.side-a .card { border-left: 1.5px solid var(--line-strong); border-bottom-left-radius: 14px; padding-left: 14px; }
.timeline.vertical.swirl .event.side-b .card { border-right: 1.5px solid var(--line-strong); border-bottom-right-radius: 14px; padding-right: 14px; }
.timeline.vertical.swirl .card:hover { box-shadow: none; border-color: var(--line-strong); }
.timeline.vertical.swirl .card .media { border-radius: 8px; overflow: hidden; }
.timeline.vertical.swirl .card .date { font-size: 22px; letter-spacing: 0; text-transform: none; font-weight: 700; margin-bottom: 8px; }
.timeline.vertical.swirl .card .date::before { display: none; }
.timeline.vertical.swirl .event .node { border-color: var(--bg); }

/* Single (one-sided) column — chosen explicitly via .single, or forced on
   narrow dashboards. Track side-padding is removed so the spine (track-relative)
   and the node (event-relative) share the same origin and stay aligned. */
.timeline.vertical.single .track { padding: 0; }
.timeline.vertical.single .spine { left: 23px; }              /* centre at 24px */
.timeline.vertical.single .event { padding-left: 52px; padding-right: 14px; }
.timeline.vertical.single .event .card {
  width: 100%; margin: 0 !important; text-align: left !important;
}
.timeline.vertical.single .event .node { left: 16.5px; transform: none; } /* centre 24px */
.timeline.vertical.single .event.side-a .date { margin-left: 0; }
.timeline.vertical.single .event::before { display: none; }

@media (max-width: 640px) {
  .timeline.vertical .track { padding: 0; }
  .timeline.vertical .spine { left: 23px; }
  .timeline.vertical .event { padding-left: 52px; padding-right: 14px; }
  .timeline.vertical .event .card {
    width: 100%; margin: 0 !important; text-align: left !important;
  }
  .timeline.vertical .event .node { left: 16.5px; transform: none; }
  .timeline.vertical .event.side-a .date { margin-left: 0; }
  .timeline.vertical .event::before { display: none; }
  /* the swirl collapses to the plain rail: no curve, nodes on the rail, cards full width */
  .timeline.vertical.swirl { --amp: 0%; }
  .timeline.vertical.swirl .swirl-path { display: none; }
  .timeline.vertical.swirl .spine { display: block; }
  .timeline.vertical.swirl .event.side-a .node, .timeline.vertical.swirl .event.side-b .node { left: 16.5px; top: 6px; bottom: auto; }
  .timeline.vertical.swirl .event .card { width: 100%; }
  .timeline.vertical.swirl .event::before { display: none; }
}

/* ====================================================== */
/*  Horizontal                                            */
/* ====================================================== */
.timeline.horizontal {
  overflow-x: auto; overflow-y: hidden; padding: 0 28px;
  scroll-snap-type: x proximity;
  cursor: grab;
}
.timeline.horizontal.dragging { cursor: grabbing; scroll-snap-type: none; }
.timeline.horizontal .event { scroll-snap-align: center; }
.timeline.horizontal .spine {
  left: 0; right: 0; top: 50%;
  height: 2px; transform: translateY(-1px);
  background: linear-gradient(to right, transparent, var(--line) 3%, var(--line) 97%, transparent);
}
.timeline.horizontal .track {
  display: flex;
  align-items: stretch;
  height: 100%;
  gap: 0;
  padding: 0 12px;
  width: max-content;
}
.timeline.horizontal .event {
  flex: 0 0 280px;
  width: 280px;
  height: 100%;
  margin-right: var(--evgap, 28px);
  position: relative;
  transform: translateY(20px);
  transition: opacity .5s ease var(--delay), transform .5s ease var(--delay);
}
.timeline.horizontal .event.in { transform: translateY(0); }

/* The node is pinned to the centre line; each card floats a fixed gap above
   (side-b) or below (side-a) it with a connector bridging the gap. Anchoring
   to the line — not to the card — keeps everything aligned regardless of how
   tall each card is. */
.timeline.horizontal .event .card {
  position: absolute; left: 0; width: 100%; z-index: 1;
}
.timeline.horizontal .event.side-b .card { bottom: calc(50% + 44px); }
.timeline.horizontal .event.side-a .card { top: calc(50% + 44px); }

.timeline.horizontal .event .node {
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.timeline.horizontal .event::after {
  content: "";
  position: absolute;
  left: 50%; width: 2px;
  transform: translateX(-50%);
  background: var(--line);
  z-index: 0;
}
.timeline.horizontal .event.side-b::after { bottom: 50%; height: 44px; }
.timeline.horizontal .event.side-a::after { top: 50%; height: 44px; }

/* One-sided horizontal: line sits near the top and every card hangs below it,
   so each card gets nearly the full height (best for tall images). */
.timeline.horizontal.single .spine { top: 34px; }
.timeline.horizontal.single .event .node { top: 34px; }
.timeline.horizontal.single .event .card { top: 62px; bottom: auto; }
.timeline.horizontal.single .event::after { top: 34px; bottom: auto; height: 28px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(10, 13, 20, .82);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 40px;
  z-index: 50;
  cursor: zoom-out;
  animation: lb-fade .2s ease;
}
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 92%; max-height: 80%; border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.lightbox .cap { color: #f3f5f9; font-size: 13.5px; font-weight: 500; text-align: center; opacity: .9; }

/* Thin, unobtrusive scrollbars */
.timeline { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.timeline::-webkit-scrollbar { width: 10px; height: 10px; }
.timeline::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
}
.timeline::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: padding-box; }
.timeline::-webkit-scrollbar-track { background: transparent; }
