/* Grav Chronology Plugin
 * Everything is controlled through CSS variables. The values come from the plugin configuration
 * (set inline on the element); the defaults are defined here. */

.chr {
  --chr-accent: #2f6fed;
  --chr-line: #cbd3e1;
  --chr-line-width: 4px;
  --chr-bg: transparent;
  --chr-surface: #ffffff;
  --chr-text: #1d2433;
  --chr-muted: #667085;
  --chr-font: inherit;
  --chr-radius: 16px;
  --chr-logo: 88px;
  --chr-col: 150px;
  --chr-card-w: 300px;
  --chr-card-h: 340px;
  --chr-speed: 400ms;

  /* Category color, overridden per entry */
  --chr-cat: var(--chr-accent);
  /* Card width, narrower on small screens */
  --chr-cw: min(var(--chr-card-w), calc(100vw - 4rem));
  /* Margin around the card so its shadow is not cut off */
  --chr-pad: 22px;
  /* Height needed by the tallest card. The script measures it; until then the upper limit applies. */
  --chr-need: calc(var(--chr-card-h) + 44px);
  --chr-ease: cubic-bezier(.3, .8, .3, 1);

  position: relative;
  box-sizing: border-box;
  background: var(--chr-bg);
  color: var(--chr-text);
  font-family: var(--chr-font);
  line-height: 1.5;
}
.chr *, .chr *::before, .chr *::after { box-sizing: border-box; }

.chr__frame { position: relative; }
.chr--arrows.is-scrollable .chr__frame { padding-inline: 52px; }

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

.chr__viewport {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  cursor: grab;
  scrollbar-width: none;
  outline: none;
}
.chr__viewport::-webkit-scrollbar { display: none; }
.chr--scrollbar .chr__viewport { scrollbar-width: thin; padding-bottom: 6px; }
.chr--scrollbar .chr__viewport::-webkit-scrollbar { display: block; height: 8px; }
.chr--scrollbar .chr__viewport::-webkit-scrollbar-thumb { background: var(--chr-line); border-radius: 4px; }
.chr__viewport:focus-visible { outline: 2px solid var(--chr-accent); outline-offset: 2px; }
.chr.is-dragging .chr__viewport { cursor: grabbing; user-select: none; }
.chr.is-dragging .chr__logo, .chr.is-dragging .chr__panel { pointer-events: none; }

.chr__track {
  display: flex;
  width: max-content;
  min-width: 100%;
  margin: 0;
  /* room left and right so the cards of the first and last entry are fully visible */
  padding: 12px max(.5rem, calc((var(--chr-cw) + var(--chr-pad) * 2 - var(--chr-col)) / 2)) 0;
  list-style: none;
}

/* ---------- Entry ---------- */

.chr__item {
  position: relative;
  flex: 0 0 var(--chr-col);
  width: var(--chr-col);
  margin: 0;
  padding: 0;
  animation: chr-in .6s var(--chr-ease) both;
  animation-delay: calc(min(var(--i, 0), 12) * 45ms);
}
.chr__item.is-open { z-index: 5; }

@keyframes chr-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* Room for the logo plus the opened card. The content sits at the bottom, above the timeline. */
.chr__slot {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: calc(var(--chr-logo) + var(--chr-need) + 24px);
}

/* The "tab": logo on top, card below. When the card grows it pushes the logo upwards. */
.chr__flap {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: calc(var(--chr-cw) + var(--chr-pad) * 2);
  margin-bottom: 12px;
  pointer-events: none; /* wider than the column, must not block neighboring logos */
}

.chr__logo {
  flex: none;
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: var(--chr-logo);
  height: var(--chr-logo);
  margin: 0 0 -3px;               /* overlaps the card border: the "tab" */
  padding: calc(var(--chr-logo) * .14);
  border: 3px solid var(--chr-line);
  border-radius: var(--chr-radius);
  background: var(--chr-surface);
  color: var(--chr-text);
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(16, 24, 40, .10);
  transition: transform var(--chr-speed) var(--chr-ease), border-color var(--chr-speed), box-shadow var(--chr-speed);
  -webkit-tap-highlight-color: transparent;
}
.chr__logo img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.chr__initials {
  font-weight: 700;
  font-size: calc(var(--chr-logo) * .32);
  letter-spacing: .02em;
  color: var(--chr-cat);
}
.chr__logo:hover { transform: scale(1.06); }
.chr__logo:focus-visible { outline: 3px solid var(--chr-accent); outline-offset: 3px; }
.chr__item.is-open .chr__logo {
  border-color: var(--chr-cat);
  border-bottom-width: 0;                         /* without a bottom border the tab merges with the card */
  padding-bottom: calc(var(--chr-logo) * .14 + 3px);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: none;
  transform: none;
}
.chr__sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Card ---------- */

.chr__panel {
  display: grid;
  grid-template-rows: 0fr;
  width: 100%;
  visibility: hidden;
  pointer-events: none;
  transition: grid-template-rows var(--chr-speed) var(--chr-ease), visibility 0s linear var(--chr-speed);
}
.chr__item.is-open .chr__panel {
  grid-template-rows: 1fr;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.chr__clip { min-height: 0; overflow: hidden; }
/* The margin around the card (only for the shadow) must not catch clicks meant for neighboring logos */
.chr__wrap { padding: 0 var(--chr-pad) 32px; pointer-events: none; }

.chr__card {
  max-height: var(--chr-card-h);
  overflow-y: auto;
  padding: 1.5rem 1.25rem 1.25rem;
  border: 3px solid var(--chr-cat);
  border-radius: var(--chr-radius);
  background: var(--chr-surface);
  color: var(--chr-text);
  text-align: left;
  box-shadow: 0 12px 26px -8px rgba(16, 24, 40, .40);
  cursor: auto;
  pointer-events: auto;
  scrollbar-width: thin;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--chr-speed) var(--chr-ease), transform var(--chr-speed) var(--chr-ease);
}
.chr__item.is-open .chr__card { opacity: 1; transform: none; }

.chr__card.has-more::after {
  content: "";
  position: sticky;
  bottom: -1.25rem;
  display: block;
  height: 36px;
  margin: -36px -1.25rem -1.25rem;
  background: linear-gradient(to bottom, transparent, var(--chr-surface) 85%);
  pointer-events: none;
}

.chr__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem;
  margin: 0 0 .5rem; font-size: .78rem; color: var(--chr-muted);
}
.chr__badge {
  padding: .1rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chr-cat) 14%, transparent);
  color: var(--chr-cat);
  font-weight: 600;
}
.chr__title { margin: 0; font-size: 1.15rem; line-height: 1.25; color: inherit; }
.chr__subtitle { margin: .15rem 0 0; font-size: .9rem; color: var(--chr-muted); }
.chr__body { margin-top: .7rem; font-size: .92rem; }
.chr__body > :first-child { margin-top: 0; }
.chr__body > :last-child { margin-bottom: 0; }
.chr__body img { max-width: 100%; height: auto; border-radius: calc(var(--chr-radius) / 2); }
.chr__body a { color: var(--chr-cat); }

.chr__details {
  display: grid; grid-template-columns: max-content 1fr; gap: .2rem .8rem;
  margin: .8rem 0 0; font-size: .85rem;
}
.chr__details dt { color: var(--chr-muted); }
.chr__details dd { margin: 0; grid-column: 2; }
.chr__details dt + dd { grid-column: 2; }
.chr__details dd:only-child, .chr__details dt ~ dd:not(dt + dd) { grid-column: 1 / -1; }

.chr__tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .8rem 0 0; padding: 0; list-style: none; }
.chr__tags li {
  margin: 0; padding: .1rem .6rem; border: 1px solid var(--chr-line);
  border-radius: 999px; font-size: .76rem; color: var(--chr-muted);
}

.chr__link {
  display: inline-block; margin-top: .9rem; padding: .45rem .95rem;
  border-radius: 999px; background: var(--chr-cat); color: #fff;
  font-size: .85rem; font-weight: 600; text-decoration: none;
  transition: filter .2s, transform .2s;
}
.chr__link:hover { filter: brightness(1.1); transform: translateY(-1px); }
.chr__link:focus-visible { outline: 3px solid var(--chr-accent); outline-offset: 2px; }

/* ---------- Timeline axis ---------- */

.chr__rail { position: relative; height: 28px; }
.chr__rail::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%;
  height: var(--chr-line-width);
  transform: translateY(-50%);
  background: var(--chr-line);
}
.chr__item:first-child .chr__rail::before { left: 50%; border-top-left-radius: 99px; border-bottom-left-radius: 99px; }
.chr__item:last-child  .chr__rail::before { right: 50%; border-top-right-radius: 99px; border-bottom-right-radius: 99px; }
.chr__rail::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 18px; height: 18px;
  transform: translate(-50%, -50%);
  border: 4px solid var(--chr-surface);
  border-radius: 50%;
  background: var(--chr-cat);
  box-shadow: 0 0 0 2px var(--chr-line);
  transition: transform var(--chr-speed) var(--chr-ease), box-shadow var(--chr-speed);
}
.chr__item.is-open .chr__rail::after {
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 0 0 3px var(--chr-cat);
}

.chr__label { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .25rem .4rem 1rem; text-align: center; }
.chr__year { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.chr__name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: .78rem; line-height: 1.3; color: var(--chr-muted);
}

/* ---------- Arrows ---------- */

.chr__arrow {
  position: absolute; z-index: 10; top: 50%;
  display: grid; place-items: center;
  width: 42px; height: 42px; margin: -21px 0 0; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--chr-surface); color: var(--chr-text);
  box-shadow: 0 2px 10px rgba(16, 24, 40, .22);
  font-size: 1.7rem; line-height: 1; cursor: pointer;
  transition: opacity .25s, transform .25s, background .2s;
}
.chr__arrow--prev { left: 6px; }
.chr__arrow--next { right: 6px; }
.chr__arrow:hover:not(:disabled) { transform: scale(1.08); }
.chr__arrow:focus-visible { outline: 3px solid var(--chr-accent); outline-offset: 2px; }
.chr__arrow:disabled { opacity: 0; pointer-events: none; }
.chr:not(.is-scrollable) .chr__arrow { display: none; }

@media (max-width: 700px) {
  .chr--arrows.is-scrollable .chr__frame { padding-inline: 0; }
  .chr__arrow { width: 36px; height: 36px; margin-top: -18px; font-size: 1.4rem; }
  .chr__arrow--prev { left: 2px; }
  .chr__arrow--next { right: 2px; }
}

.chr-empty { color: #667085; font-style: italic; }

/* ---------- Subtle: no animations when reduced motion is requested ---------- */

@media (prefers-reduced-motion: reduce) {
  .chr__item { animation: none; }
  .chr__logo, .chr__panel, .chr__card, .chr__rail::after, .chr__arrow, .chr__link {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}
