/*
 * River timeline (home page) – leaves floating on the Wuhle.
 * Structure is built by assets/js/river-timeline.js.
 */
.river-section {
  --water-1: #6fb7d6;
  --water-2: #2f8fbf;
  --water-3: #1f6f9c;
  --bank: #9fc46a;
  --meadow-1: #eef6df;
  --meadow-2: #dcedc4;
  --spring: #9ccc3c;
  --summer: #3f8f2f;
  --autumn: #e07b24;
  --winter: #8a5a35;
  padding: clamp(2rem, 4vw, 3rem) 0 1.5rem;
  background: linear-gradient(180deg, var(--white) 0, var(--meadow-1) 25%, var(--meadow-2) 100%);
}
/* desktop: the section fills the window below the sticky header (65px),
   so neither the hero video nor the next section peeks in */
@media (min-width: 720px) and (min-height: 640px) {
  .river-section { min-height: calc(100vh - 65px); display: flex; flex-direction: column; justify-content: center; }
}
.river-section__intro { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 1rem; }

.river { position: relative; overflow: hidden; }
.river--vertical .river__canvas { overflow: hidden; }
.river__scroller { position: relative; }
/* no visible scrollbar: scroll via the arrow buttons, mouse drag, touch swipe or shift+wheel */
.river--horizontal .river__scroller { overflow-x: auto; overflow-y: hidden; cursor: grab; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.river--horizontal .river__scroller::-webkit-scrollbar { display: none; }
.river--horizontal .river__scroller.is-dragging { cursor: grabbing; user-select: none; }
.river__canvas { position: relative; }

/* ---- water ---- */
.river__water { position: absolute; inset: 0; overflow: visible; }
.river__water path { fill: none; stroke-linecap: butt; stroke-linejoin: round; }
.river__bank { stroke: var(--bank); opacity: .55; }
.river__bed { stroke: var(--water-2); }
.river__deep { stroke: var(--water-3); opacity: .45; }
.river__ripple { stroke: rgba(255, 255, 255, .32); stroke-linecap: round !important; stroke-dasharray: 34 110; animation: river-flow 7s linear infinite; }
.river__ripple--2 { stroke-dasharray: 10 90; animation-duration: 9s; opacity: .7; }
.river__ripple--3 { stroke-dasharray: 26 120; animation-duration: 11s; opacity: .5; }
@keyframes river-flow { to { stroke-dashoffset: -820; } }

/* ---- bridge "Heute" ---- */
.river__bridge { position: absolute; z-index: 3; width: 0; height: 0; pointer-events: none; }
.river__bridge-deck {
  position: absolute; left: 0; top: 0; width: var(--span); height: 30px;
  transform: translate(-50%, -50%) rotate(var(--angle));
  background:
    repeating-linear-gradient(90deg, #8b5e34 0 12px, #a8743f 12px 14px),
    #8b5e34;
  border-top: 4px solid #5c3d20; border-bottom: 4px solid #5c3d20; border-radius: 4px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, .25);
}
/* signpost: "Heute" in the middle, arms pointing upstream (future) and downstream (past);
   1fr columns keep "Heute" centred on the bridge although the arms differ in length */
.river__bridge-label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  width: max-content; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; white-space: nowrap;
}
.river__bridge-today {
  position: relative; z-index: 1; padding: .25rem .9rem; border-radius: 999px; background: var(--white); color: var(--green);
  font: 400 1.2rem var(--font-head); box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.river__bridge-arm {
  padding: .15rem .7rem; background: rgba(255, 255, 255, .85); color: var(--muted);
  font-size: .8rem; font-weight: 700;
}
.river__bridge-arm--future { justify-self: end; margin-right: -.5rem; padding-right: 1rem; clip-path: polygon(.6rem 0, 100% 0, 100% 100%, .6rem 100%, 0 50%); padding-left: 1rem; }
.river__bridge-arm--past { justify-self: start; margin-left: -.5rem; padding-left: 1rem; clip-path: polygon(0 0, calc(100% - .6rem) 0, 100% 50%, calc(100% - .6rem) 100%, 0 100%); padding-right: 1rem; }
/* narrow screens: the river flows top -> bottom, left/right arms would be misleading */
.river--vertical .river__bridge-arm { visibility: hidden; }

/* ---- year stones on the bank ---- */
.river__stone {
  position: absolute; z-index: 2; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: .3rem .6rem; border-radius: 45% 55% 50% 50%; background: #b9b5ad; color: #3d3a35;
  font: 700 .75rem/1.1 var(--font-body); box-shadow: inset -3px -4px 0 rgba(0, 0, 0, .12), 0 2px 4px rgba(0, 0, 0, .2);
}
.river__stone span:first-child { opacity: .6; font-weight: 400; }

/* ---- leaves ---- */
.leaf {
  --size: 76px;
  --color: var(--summer);
  position: absolute; z-index: 4; width: var(--size); height: var(--size);
  transform: translate(-50%, -50%); text-decoration: none; color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.leaf--spring { --color: var(--spring); }
.leaf--summer { --color: var(--summer); }
.leaf--autumn { --color: var(--autumn); }
.leaf--winter { --color: var(--winter); }
.leaf__body {
  position: absolute; inset: 0; transform: rotate(var(--rot));
  animation: leaf-bob var(--dur, 6s) ease-in-out var(--delay, 0s) infinite;
  filter: drop-shadow(2px 5px 4px rgba(10, 50, 70, .35));
  transition: transform .25s;
}
.leaf__shape { width: 100%; height: 100%; display: block; overflow: visible; }
.leaf__blade { fill: var(--color); stroke: rgba(0, 0, 0, .18); stroke-width: 1.5; }
.leaf__vein { stroke: rgba(255, 255, 255, .45); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.leaf__photo {
  position: absolute; left: 50%; top: 48%; width: 60%; height: 60%; transform: translate(-50%, -50%) rotate(calc(var(--rot) * -1));
  border-radius: 50%; object-fit: cover; border: 3px solid var(--white); box-shadow: 0 2px 6px rgba(0, 0, 0, .3); background: var(--white);
}
.leaf--past .leaf__body { opacity: .92; }
@keyframes leaf-bob {
  0%, 100% { transform: rotate(var(--rot)) translate(0, 0); }
  30% { transform: rotate(calc(var(--rot) + 7deg)) translate(2px, -3px); }
  65% { transform: rotate(calc(var(--rot) - 5deg)) translate(-2px, 2px); }
}

/* next upcoming event: ripple ring */
.leaf.is-next::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 130%; height: 130%; border-radius: 50%;
  transform: translate(-50%, -50%); border: 3px solid rgba(255, 255, 255, .85);
  animation: leaf-ripple 2.4s ease-out infinite;
}
@keyframes leaf-ripple { from { opacity: .9; transform: translate(-50%, -50%) scale(.7); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } }

.leaf:hover .leaf__body, .leaf:focus-visible .leaf__body { transform: rotate(0deg) scale(1.18); animation-play-state: paused; }
.leaf:focus-visible { outline: none; }
.leaf:focus-visible .leaf__body { filter: drop-shadow(0 0 0 var(--white)) drop-shadow(0 0 6px var(--blue)); }

.leaf__label {
  position: absolute; z-index: 5; width: max-content; max-width: 170px; padding: .25rem .55rem;
  background: rgba(255, 255, 255, .94); border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  font-size: .78rem; line-height: 1.25; text-align: center;
  /* part of the leaf link: tapping the label opens the event too (larger touch target) */
}
.leaf__title { display: block; font-weight: 700; color: var(--blue); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.leaf__date { display: block; color: var(--muted); font-size: .72rem; }
.leaf--label-bottom .leaf__label { left: 50%; top: calc(100% + 4px); transform: translateX(-50%); }
.leaf--label-top .leaf__label { left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); }
.leaf--label-right .leaf__label { left: calc(100% + 6px); top: 50%; transform: translateY(-50%); text-align: left; }
.leaf--label-left .leaf__label { right: calc(100% + 6px); top: 50%; transform: translateY(-50%); text-align: right; }
.leaf:hover .leaf__label, .leaf:focus-visible .leaf__label { background: var(--white); box-shadow: 0 4px 12px rgba(0, 0, 0, .25); z-index: 6; }
.river--vertical .leaf__label { max-width: calc(50vw - 70px); }

/* ---- scroll buttons (horizontal) ---- */
.river__nav {
  position: absolute; top: 50%; z-index: 7; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .9); color: var(--blue); font-size: 1.8rem; line-height: 1; box-shadow: var(--shadow);
}
.river__nav--prev { left: .5rem; }
.river__nav--next { right: .5rem; }
.river--vertical .river__nav { display: none; }

/* ---- pop-out ---- */
.river-dialog {
  --color: var(--summer);
  border: 0; padding: 0; background: transparent; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: visible;
}
.river-dialog--spring { --color: #9ccc3c; }
.river-dialog--summer { --color: #3f8f2f; }
.river-dialog--autumn { --color: #e07b24; }
.river-dialog--winter { --color: #8a5a35; }
.river-dialog::backdrop { background: rgba(8, 40, 60, .6); backdrop-filter: blur(2px); }
.river-dialog[open] .river-dialog__card { animation: leaf-grow .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes leaf-grow { from { opacity: 0; transform: scale(.4) rotate(-12deg); border-radius: 50% 0 50% 0; } to { opacity: 1; transform: none; } }
.river-dialog__card {
  position: relative; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--white);
  border-radius: 28px 4px 28px 4px; border-top: 8px solid var(--color); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.river-dialog__close {
  position: absolute; top: .5rem; right: .5rem; z-index: 2; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .9); font-size: 1.6rem; cursor: pointer; color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.river-dialog__cover { width: 100%; max-height: 260px; object-fit: cover; }
.river-dialog__body { padding: 1rem 1.4rem 1.2rem; }
.river-dialog__badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; color: var(--white); background: var(--color); }
.river-dialog__title { margin: .5rem 0 .4rem; font-size: 1.4rem; }
.river-dialog__facts { margin: 0 0 .6rem; color: var(--text); }
.river-dialog__location { color: var(--muted); }
.river-dialog__text { margin: 0 0 .8rem; }
.river-dialog__thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-bottom: .9rem; }
.river-dialog__thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.river-dialog__more { font-weight: 700; }
.river-dialog__nav { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; border-top: 1px solid var(--line); background: var(--mist); }
.river-dialog__nav button { border: 0; background: none; color: var(--blue); font: 700 .95rem var(--font-body); cursor: pointer; padding: .4rem .6rem; border-radius: 6px; }
.river-dialog__nav button:disabled { color: var(--line); cursor: default; }
.river-dialog__pos { color: var(--muted); font-size: .85rem; }

/* set by river-timeline.js while the section is scrolled out of view */
.river-section.is-offscreen .leaf__body,
.river-section.is-offscreen .river__ripple,
.river-section.is-offscreen .leaf.is-next::before { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .leaf__body, .river__ripple, .leaf.is-next::before { animation: none; }
  .river-dialog[open] .river-dialog__card { animation: none; }
}
