/* =============================================================================
   Geosys History Timeline — history-timeline.css  v1.4.6
   Uses CI Custom Properties from Geosys Child Theme (style.css)
   BEM: .geosys-tl
   v1.2.0: Scroll indicators + drag cursor styles
   v1.3.0: Gallery/masonry, nav beside strip, 50/50 layout, smaller headline
   v1.3.1: True masonry with CSS columns (no image cropping)
   v1.4.0: Lightbox for gallery images
   v1.4.3: Lightbox white backdrop like Team Grid
   v1.4.5: Lightbox moved to body via JS — z-index 999999 (matches Team Grid)
   v1.4.6: Korrektur Primärfarbe #005186 → #005187
   v1.4.7: Gallery: CSS Grid statt Columns, bottom-flush mit object-fit: cover
   ============================================================================= */

/* -----------------------------------------------------------------------------
   0. TOKENS
   ----------------------------------------------------------------------------- */

.geosys-tl {
  --tl-blue:        var(--geosys-blue, #005187);
  --tl-orange:      var(--geosys-orange, #f9af00);
  --tl-grey:        var(--geosys-grey, #878786);
  --tl-blue-grey:   var(--geosys-blue-grey, #34434b);
  --tl-bg:          var(--white, #ffffff);
  --tl-line:        #d0d5da;
  --tl-radius:      4px;
  --tl-transition:  0.35s ease;
  --tl-dot-size:    14px;
  --tl-dot-border:  2px;
  --tl-gap:         var(--gridstrength, 24px);
  width: 100%;
}


/* -----------------------------------------------------------------------------
   1. HORIZONTAL — stage (content area)
   ----------------------------------------------------------------------------- */

.geosys-tl--horizontal .geosys-tl__stage {
  position: relative;
  width: 100%;
}

.geosys-tl__panels {
  position: relative;
  width: 100%;
}

.geosys-tl__panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--tl-gap);
}

/* 50/50 layout when media present */
.geosys-tl__panel--with-media {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.geosys-tl__panel--hidden {
  display: none;
}

.geosys-tl__panel-media {
  /* Container for single image or gallery */
}

.geosys-tl__figure {
  margin: 0;
}

.geosys-tl__image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--tl-radius);
}

.geosys-tl__caption {
  color: var(--tl-grey);
  margin-top: 8px;
  font-size: 0.7em;
}

/* 16:9 fit: image inside 16:9 container, no crop, right-aligned */
.geosys-tl__figure--16-9-fit {
  aspect-ratio: 16 / 9;
  border-radius: var(--tl-radius);
  overflow: hidden;
}

.geosys-tl__figure--16-9-fit .geosys-tl__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: right center;
}

.geosys-tl__figure--16-9-fit .geosys-tl__lightbox-trigger {
  width: 100%;
  height: 100%;
}

.geosys-tl__panel-year {
  display: block;
  color: var(--tl-grey);
  margin-bottom: 4px;
}

/* Smaller headline */
.geosys-tl__panel-headline {
  color: var(--tl-blue);
  margin: 0 0 16px;
  font-size: 1.4em;
  line-height: 1.25;
}

.geosys-tl__panel-text {
  color: var(--tl-blue);
}

.geosys-tl__panel-text p { margin: 0 0 1em; }
.geosys-tl__panel-text p:last-child { margin-bottom: 0; }


/* -----------------------------------------------------------------------------
   1b. GALLERY — True Masonry with CSS Columns
   ----------------------------------------------------------------------------- */

.geosys-tl__gallery {
  /* Default fallback */
}

/* True masonry layout using CSS Grid — bottom-flush */
.geosys-tl__gallery--masonry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* 2 images: side by side, same height */
.geosys-tl__gallery--masonry[data-count="2"] {
  grid-template-rows: 1fr;
}

/* 3 images: first spans 2 rows, two stacked right */
.geosys-tl__gallery--masonry[data-count="3"] {
  grid-template-rows: 1fr 1fr;
}
.geosys-tl__gallery--masonry[data-count="3"] .geosys-tl__gallery-item:first-child {
  grid-row: 1 / -1;
}

/* 4 images: 2x2 grid */
.geosys-tl__gallery--masonry[data-count="4"] {
  grid-template-rows: 1fr 1fr;
}

/* 5+ images: first spans 2 rows, rest flow */
.geosys-tl__gallery--masonry[data-count="5"] {
  grid-template-rows: 1fr 1fr 1fr;
}
.geosys-tl__gallery--masonry[data-count="5"] .geosys-tl__gallery-item:first-child {
  grid-row: 1 / 3;
}

.geosys-tl__gallery-item {
  margin: 0;
  overflow: hidden;
  border-radius: var(--tl-radius);
}

/* Image fills cell, crops if needed */
.geosys-tl__gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


/* -----------------------------------------------------------------------------
   1c. LIGHTBOX TRIGGER — clickable images
   ----------------------------------------------------------------------------- */

.geosys-tl__lightbox-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  position: relative;
  overflow: hidden;
  border-radius: var(--tl-radius);
}

/* Gallery: figure + trigger flex chain for object-fit: cover */
.geosys-tl__gallery--masonry .geosys-tl__gallery-item,
.geosys-tl__gallery--row .geosys-tl__gallery-item {
  display: flex;
}

.geosys-tl__gallery--masonry .geosys-tl__gallery-item .geosys-tl__lightbox-trigger,
.geosys-tl__gallery--row .geosys-tl__gallery-item .geosys-tl__lightbox-trigger {
  display: flex !important;
  align-items: stretch;
  flex: 1;
}

.geosys-tl__gallery--masonry .geosys-tl__gallery-image,
.geosys-tl__gallery--row .geosys-tl__gallery-image {
  flex: 1;
  min-height: 0;
}

/* Stacked layout: single column, no crop */
.geosys-tl__gallery--stacked {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.geosys-tl__gallery--stacked .geosys-tl__gallery-item {
  margin: 0;
  overflow: hidden;
  border-radius: var(--tl-radius);
}

.geosys-tl__gallery--stacked .geosys-tl__lightbox-trigger {
  height: auto;
}

.geosys-tl__gallery--stacked .geosys-tl__gallery-image {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* 1 oben + 2 unten: first image full width, rest side by side (equal height, crop) */
.geosys-tl__gallery--top-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.geosys-tl__gallery--top-bottom .geosys-tl__gallery-item:first-child {
  grid-column: 1 / -1;
}

.geosys-tl__gallery--top-bottom .geosys-tl__gallery-item {
  margin: 0;
  overflow: hidden;
  border-radius: var(--tl-radius);
}

/* Top image: no crop */
.geosys-tl__gallery--top-bottom .geosys-tl__gallery-item:first-child .geosys-tl__gallery-image {
  width: 100%;
  height: auto;
  display: block;
}

/* Bottom row: equal height, crop to fit */
.geosys-tl__gallery--top-bottom .geosys-tl__gallery-item:not(:first-child) {
  display: flex;
}

.geosys-tl__gallery--top-bottom .geosys-tl__gallery-item:not(:first-child) .geosys-tl__lightbox-trigger {
  display: flex !important;
  align-items: stretch;
}

.geosys-tl__gallery--top-bottom .geosys-tl__gallery-item:not(:first-child) .geosys-tl__gallery-image {
  width: 100%;
  flex: 1;
  object-fit: cover;
  display: block;
  min-height: 0;
}

/* Nebeneinander: all in one row, same height, crop */
.geosys-tl__gallery--row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
}

.geosys-tl__gallery--row .geosys-tl__gallery-item {
  margin: 0;
  overflow: hidden;
  border-radius: var(--tl-radius);
}

.geosys-tl__gallery--row .geosys-tl__gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.geosys-tl__lightbox-trigger img {
  transition: transform 0.3s ease;
}

.geosys-tl__lightbox-trigger:hover img,
.geosys-tl__lightbox-trigger:focus img {
  transform: scale(1.03);
}

.geosys-tl__lightbox-trigger:focus {
  outline: 2px solid var(--tl-orange);
  outline-offset: 2px;
}

/* Zoom icon hint */
.geosys-tl__lightbox-trigger::after {
  content: '';
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.25s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='6'/%3E%3Cpath d='M21 21l-4-4'/%3E%3Cpath d='M11 8v6M8 11h6'/%3E%3C/svg%3E");
  background-size: 18px 18px;
  background-position: center;
  background-repeat: no-repeat;
}

.geosys-tl__lightbox-trigger:hover::after,
.geosys-tl__lightbox-trigger:focus::after {
  opacity: 1;
}


/* -----------------------------------------------------------------------------
   2. HORIZONTAL — strip-nav wrapper (nav buttons beside strip)
   ----------------------------------------------------------------------------- */

.geosys-tl__strip-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 40px;
}

.geosys-tl__nav {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 2px solid var(--tl-line);
  border-radius: 50%;
  cursor: pointer;
  color: var(--tl-blue-grey);
  transition: border-color var(--tl-transition), background var(--tl-transition), color var(--tl-transition);
  padding: 0;
}

.geosys-tl__nav:hover:not(:disabled),
.geosys-tl__nav:focus-visible:not(:disabled) {
  border-color: var(--tl-blue);
  background: var(--tl-blue);
  color: #ffffff;
  outline: none;
}

.geosys-tl__nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.geosys-tl__nav span {
  display: block;
  width: 10px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  flex-shrink: 0;
}

.geosys-tl__nav--prev span { transform: rotate(-135deg) translateX(-1px); }
.geosys-tl__nav--next span { transform: rotate(45deg) translateX(-1px); }


/* -----------------------------------------------------------------------------
   3. HORIZONTAL — timeline strip wrapper + scroll indicators
   ----------------------------------------------------------------------------- */

.geosys-tl__strip-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* Fade masks to indicate more content */
.geosys-tl__strip-wrapper::before,
.geosys-tl__strip-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 8px;
  width: 48px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.geosys-tl__strip-wrapper::before {
  left: 0;
  background: linear-gradient(to right, var(--tl-bg, #fff) 0%, transparent 100%);
}

.geosys-tl__strip-wrapper::after {
  right: 0;
  background: linear-gradient(to left, var(--tl-bg, #fff) 0%, transparent 100%);
}

.geosys-tl__strip-wrapper--scrollable.geosys-tl__strip-wrapper--scroll-left::before {
  opacity: 1;
}

.geosys-tl__strip-wrapper--scrollable.geosys-tl__strip-wrapper--scroll-right::after {
  opacity: 1;
}


/* -----------------------------------------------------------------------------
   3a. HORIZONTAL — timeline strip
   ----------------------------------------------------------------------------- */

.geosys-tl__strip {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: var(--tl-line) transparent;
  padding-bottom: 8px;
  cursor: grab;
}

.geosys-tl__strip--dragging {
  cursor: grabbing;
  user-select: none;
}

.geosys-tl__strip--dragging * {
  user-select: none;
}

.geosys-tl__strip::-webkit-scrollbar { height: 4px; }
.geosys-tl__strip::-webkit-scrollbar-track { background: transparent; }
.geosys-tl__strip::-webkit-scrollbar-thumb { background: var(--tl-line); border-radius: 2px; }

.geosys-tl__strip-track {
  position: relative;
  min-width: max-content;
  padding: 32px 24px 8px;
}

.geosys-tl__strip-line {
  position: absolute;
  top: calc(32px + var(--tl-dot-size) / 2);
  left: 24px;
  right: 24px;
  height: 1px;
  background: var(--tl-line);
}

.geosys-tl__strip-nodes {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.geosys-tl__node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 28px;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  max-width: 160px;
}

.geosys-tl__node:first-child { padding-left: 0; }
.geosys-tl__node:last-child  { padding-right: 0; }

.geosys-tl__node-dot {
  display: block;
  width: var(--tl-dot-size);
  height: var(--tl-dot-size);
  border-radius: 50%;
  background: var(--tl-bg);
  border: var(--tl-dot-border) solid var(--tl-line);
  transition: border-color var(--tl-transition), background var(--tl-transition), transform var(--tl-transition);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.geosys-tl__node-year {
  color: var(--tl-grey);
  white-space: nowrap;
  transition: color var(--tl-transition);
}

.geosys-tl__node-title {
  color: var(--tl-grey);
  text-align: center;
  white-space: normal;
  font-size: smaller;
  transition: color var(--tl-transition);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.geosys-tl__node:hover .geosys-tl__node-dot {
  border-color: var(--tl-blue);
  transform: scale(1.2);
}
.geosys-tl__node:hover .geosys-tl__node-year,
.geosys-tl__node:hover .geosys-tl__node-title {
  color: var(--tl-blue);
}
.geosys-tl__node:focus-visible {
  outline: 2px solid var(--tl-orange);
  outline-offset: 4px;
  border-radius: 2px;
}

.geosys-tl__node--active .geosys-tl__node-dot {
  background: var(--tl-blue);
  border-color: var(--tl-blue);
  transform: scale(1.3);
}
.geosys-tl__node--active .geosys-tl__node-year {
  color: var(--tl-blue);
  font-weight: 700;
}
.geosys-tl__node--active .geosys-tl__node-title {
  color: var(--tl-blue);
}


/* -----------------------------------------------------------------------------
   3b. HORIZONTAL — strip oben (.geosys-tl--strip-top)
   ----------------------------------------------------------------------------- */

.geosys-tl--strip-top .geosys-tl__strip-nav {
  margin-top: 0;
  margin-bottom: 40px;
}

.geosys-tl--strip-top .geosys-tl__strip-wrapper::before,
.geosys-tl--strip-top .geosys-tl__strip-wrapper::after {
  top: 8px;
  bottom: 0;
}

.geosys-tl--strip-top .geosys-tl__strip {
  padding-bottom: 0;
  padding-top: 8px;
}

.geosys-tl--strip-top .geosys-tl__strip-track {
  padding: 8px 24px 32px;
}

.geosys-tl--strip-top .geosys-tl__strip-line {
  top: auto;
  bottom: calc(32px + var(--tl-dot-size) / 2);
}

.geosys-tl--strip-top .geosys-tl__strip-nodes {
  align-items: flex-end;
}

.geosys-tl--strip-top .geosys-tl__node {
  flex-direction: column-reverse;
  align-items: center;
}


/* -----------------------------------------------------------------------------
   4. VERTICAL layout
   ----------------------------------------------------------------------------- */

.geosys-tl--vertical {
  position: relative;
}

.geosys-tl__vert-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--tl-line);
  transform: translateX(-50%);
}

.geosys-tl__vert-item {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  align-items: start;
  margin-bottom: 60px;
  position: relative;
}

.geosys-tl__vert-item:last-child { margin-bottom: 0; }

.geosys-tl__vert-dot {
  grid-column: 2;
  grid-row: 1;
  width: var(--tl-dot-size);
  height: var(--tl-dot-size);
  border-radius: 50%;
  background: var(--tl-bg);
  border: var(--tl-dot-border) solid var(--tl-blue);
  margin: 4px auto 0;
  position: relative;
  z-index: 1;
}

.geosys-tl__vert-card {
  background: var(--tl-bg);
  border: 1px solid var(--tl-line);
  border-radius: var(--tl-radius);
  padding: 28px 28px 24px;
  position: relative;
  transition: box-shadow var(--tl-transition);
  overflow-wrap: break-word;
  hyphens: auto;
}

.geosys-tl__vert-card:hover {
  box-shadow: 0 4px 20px rgba(0, 81, 135, 0.1);
}

.geosys-tl__vert-item--left .geosys-tl__vert-card {
  grid-column: 1;
  grid-row: 1;
  margin-right: 20px;
  text-align: right;
}

.geosys-tl__vert-item--right .geosys-tl__vert-card {
  grid-column: 3;
  grid-row: 1;
  margin-left: 20px;
  text-align: left;
}

.geosys-tl__vert-card::after {
  content: '';
  position: absolute;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.geosys-tl__vert-item--left .geosys-tl__vert-card::after {
  right: -9px;
  border-left: 9px solid var(--tl-line);
}

.geosys-tl__vert-item--right .geosys-tl__vert-card::after {
  left: -9px;
  border-right: 9px solid var(--tl-line);
}

.geosys-tl--vertical .geosys-tl__figure { margin: 16px 0 0; }
.geosys-tl--vertical .geosys-tl__image  { max-width: 100%; }
.geosys-tl--vertical .geosys-tl__gallery { margin: 16px 0 0; }

/* Vertical: smaller headline too */
.geosys-tl--vertical .geosys-tl__panel-headline {
  font-size: 1.2em;
  line-height: 1.25;
  margin-bottom: 12px;
}


/* -----------------------------------------------------------------------------
   5. EMPTY STATE
   ----------------------------------------------------------------------------- */

.geosys-tl__empty {
  color: var(--tl-grey);
  font-style: italic;
}


/* -----------------------------------------------------------------------------
   6. LIGHTBOX — white transparent backdrop like Team Grid
   Lightbox is moved to body via JS to escape stacking context.
   z-index 999999 matches Team Grid Modal.
   ----------------------------------------------------------------------------- */

.geosys-tl-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.geosys-tl-lightbox[hidden] {
  display: none;
}

/* Overlay — white transparent with blur */
.geosys-tl-lightbox__overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(240, 242, 244, 0.92);
  cursor: pointer;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* Close button — dark on light bg */
.geosys-tl-lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 999999;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tl-line, #d0d5da);
  border: none;
  border-radius: 50%;
  color: var(--tl-blue-grey, #34434b);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}

.geosys-tl-lightbox__close:hover,
.geosys-tl-lightbox__close:focus {
  background: var(--tl-blue, #005187);
  color: #fff;
  outline: none;
}

/* Nav buttons — dark on light bg */
.geosys-tl-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 999999;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 2px solid var(--tl-line, #d0d5da);
  border-radius: 50%;
  color: var(--tl-blue-grey, #34434b);
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease;
}

.geosys-tl-lightbox__nav--prev { left: 20px; }
.geosys-tl-lightbox__nav--next { right: 20px; }

.geosys-tl-lightbox__nav:hover:not(:disabled),
.geosys-tl-lightbox__nav:focus:not(:disabled) {
  border-color: var(--tl-blue, #005187);
  background: var(--tl-blue, #005187);
  color: #fff;
  outline: none;
}

.geosys-tl-lightbox__nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.geosys-tl-lightbox__nav[hidden] {
  display: none;
}

.geosys-tl-lightbox__nav span {
  display: block;
  width: 12px;
  height: 12px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}

.geosys-tl-lightbox__nav--prev span { transform: rotate(-135deg) translateX(-2px); }
.geosys-tl-lightbox__nav--next span { transform: rotate(45deg) translateX(-2px); }

/* Figure */
.geosys-tl-lightbox__figure {
  position: relative;
  z-index: 999999;
  max-width: 90vw;
  max-height: 85vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Image */
.geosys-tl-lightbox__image {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: var(--tl-radius, 4px);
  box-shadow: 0 8px 40px rgba(0, 81, 135, 0.15);
  transition: opacity 0.3s ease;
}

.geosys-tl-lightbox__image--loading {
  opacity: 0.5;
}

/* Caption — dark text on light bg */
.geosys-tl-lightbox__caption {
  color: var(--tl-grey, #878786);
  margin-top: 16px;
  font-size: 0.9em;
  text-align: center;
  max-width: 600px;
}

.geosys-tl-lightbox__caption[hidden] {
  display: none;
}


/* -----------------------------------------------------------------------------
   7. RESPONSIVE
   ----------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .geosys-tl--vertical .geosys-tl__panel-headline {
    font-size: 0.95em;
    line-height: 1.2;
  }
  .geosys-tl--vertical .geosys-tl__panel-text {
    font-size: 0.75em;
    line-height: 1.5;
  }
  .geosys-tl--vertical .geosys-tl__vert-card {
    padding: 20px 20px 18px;
  }

  /* Stack media/content on tablet */
  .geosys-tl__panel--with-media {
    grid-template-columns: 1fr;
  }

  /* Lightbox: smaller nav */
  .geosys-tl-lightbox__nav {
    width: 48px;
    height: 48px;
  }
  .geosys-tl-lightbox__nav--prev { left: 12px; }
  .geosys-tl-lightbox__nav--next { right: 12px; }
}
