/**
 * Highlights (slider) and the news list
 * One of the stylesheets of the website, loaded in a fixed order by php/include/header.php
 * (list and order: AGENTS.md, "Stylesheets").
 */

/**
 * @section Highlights
 */

/* The slider: a row that scrolls sideways and snaps to each slide, endless through copies at both ends
   (script in php/include/php/news.php). Each slide: the background (picture whole on the left, a blurred
   copy of it behind the whole slide) and above it a layer with the text field on the right on almost opaque
   white. While turning, the background moves with the row; the text field stands still and only its text
   moves through it (section "Turning" below). */
.highlights {
  background-color: var(--color-white);
  border-radius: 8px;
  box-shadow: var(--shadow);
  container-type: inline-size;
  overflow: hidden;
  position: relative;
}
/* the white field behind the text: one for all slides, standing still above all pictures (z-index 1)
   and below all texts (2) */
.highlights::before {
  background-color: rgb(255, 255, 255, 0.9);
  bottom: 0;
  content: "";
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
  width: calc(100% / 2.55);
  z-index: 1;
}
.highlights-track {
  display: grid;
  grid-auto-columns: 100%;
  grid-auto-flow: column;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  position: relative;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.highlights-track::-webkit-scrollbar {
  display: none;
}
.highlight {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 330px;
  position: relative;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  view-timeline: --highlight inline;
}
.highlight-background,
.highlight-layer {
  grid-area: 1 / 1;
  position: relative;
}
.highlight-background {
  overflow: hidden;
  z-index: 0;
}
/* the text layers of all slides lie above the backgrounds of all slides and the white field */
.highlight-layer {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  pointer-events: none;
  z-index: 2;
}
.highlight-backdrop {
  filter: blur(22px) saturate(1.1);
  height: 100%;
  inset: 0;
  object-fit: cover;
  position: absolute;
  transform: scale(1.2);
  width: 100%;
}
.highlight-picture {
  bottom: 0;
  left: 0;
  position: absolute;
  top: 0;
  width: calc(100% * 1.55 / 2.55);
}
.highlight-picture img {
  height: 100%;
  inset: 0;
  object-fit: contain;
  position: absolute;
  width: 100%;
}
/* opens the picture in the lightbox (news.php); not in the preview of the internal area (no lightbox there) */
.highlight-zoom {
  align-items: center;
  background-color: var(--color-white);
  border: 1px solid var(--color-darkblue-transparent-light);
  border-radius: 50%;
  bottom: 12px;
  color: var(--color-darkblue);
  cursor: zoom-in;
  display: flex;
  height: 32px;
  justify-content: center;
  left: 12px;
  opacity: 0.85;
  padding: 0;
  position: absolute;
  width: 32px;
}
.highlight-zoom:hover,
.highlight-zoom:focus-visible {
  border-color: var(--color-darkblue);
  opacity: 1;
}
.admin-preview .highlight-zoom {
  display: none;
}
/* one text block: label (kind of the target), the title only bold, the text, the link. The slider has a
   fixed height: a long text scrolls in the field (the link stays below it) and fades out at the bottom as
   long as there is more of it */
.highlight-text {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  grid-column: 2;
  min-height: 0;
  overflow: hidden;
  padding: 24px 24px 72px;
  pointer-events: auto;
}
@property --highlight-fade {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
.highlight-content {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 0.6em;
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--highlight-fade)), transparent);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}
.highlight-text p {
  margin: 0;
}
.highlight-text p:empty {
  display: none;
}
.highlight-text strong {
  display: block;
  font-size: 1.15em;
  line-height: 1.3;
}
/* label: a pill (css/base.css) in dark blue */
.highlight-text .highlight-chip {
  color: var(--color-darkblue);
  display: inline-block;
  margin: 0 0 0.4em;
}
.highlight-description {
  color: var(--color-gray-text);
}
.highlight-more {
  align-self: flex-start;
}
.highlight-more::after {
  content: "\00a0→";
}

/* counter, bar and arrows at the bottom of the text */
.highlights-nav {
  align-items: center;
  bottom: 0;
  box-sizing: border-box;
  display: flex;
  gap: 10px;
  padding: 0 24px 22px;
  position: absolute;
  right: 0;
  width: calc(100% / 2.55);
  z-index: 3;
}
.highlights-count {
  color: var(--color-darkblue);
  font-size: 0.95em;
  font-variant-numeric: tabular-nums;
  font-weight: bold;
  white-space: nowrap;
}
.highlights-bar {
  background-color: var(--color-darkblue-transparent-light);
  flex: 1;
  height: 2px;
  overflow: hidden;
  position: relative;
}
.highlights-fill {
  background-color: var(--color-darkblue);
  inset: 0;
  position: absolute;
  transform: scaleX(0);
  transform-origin: left;
}
.highlights-bar.running .highlights-fill {
  animation: highlights-fill 6s linear forwards;
}
/* stops while the pointer is on the slider or the keyboard focus is in it; a button clicked with the
   mouse keeps its focus, but that is no :focus-visible, so the bar goes on when the pointer leaves.
   Also stops (.reading, news.php) after the visitor scrolled a text, until the slide changes. */
.highlights:hover .highlights-fill,
.highlights:has(:focus-visible) .highlights-fill,
.highlights.reading .highlights-fill {
  animation-play-state: paused;
}
@keyframes highlights-fill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.highlights-step {
  background: var(--color-white) url(/img/icons/chevron-left.svg) center / 20px no-repeat;
  border: 1px solid var(--color-darkblue-transparent-light);
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  height: 32px;
  padding: 0;
  width: 32px;
}
.highlights-step.next {
  background-image: url(/img/icons/chevron-right.svg);
}
.highlights-step:hover,
.highlights-step:focus-visible {
  border-color: var(--color-darkblue);
}

/* Turning: the text layer of a slide is moved against the row by as much as the row scrolls, so its
   field stands still on the white field; the text inside moves half as fast as the row and is cut off at
   the edges of the field. The fields of the neighbouring slides lie on the same spot and are hidden while
   at rest. Without scroll-driven animations (or with less motion) the whole slide simply moves along. */
@supports (animation-timeline: view()) {
  .highlight-layer,
  .highlight-text,
  .highlight-text > * {
    animation-timeline: --highlight;
    animation-fill-mode: both;
    animation-timing-function: linear;
  }
  .highlight-layer {
    animation-name: highlight-hold;
  }
  .highlight-text {
    animation-name: highlight-field;
  }
  .highlight-text > * {
    animation-name: highlight-text;
  }
  /* the fade only while the text can scroll (otherwise the scroll timeline is inactive), gone at its end */
  .highlight-content {
    animation-name: highlight-text, highlight-fade;
    animation-timeline: --highlight, scroll(self);
  }
  @keyframes highlight-fade {
    0%, 85% { --highlight-fade: 2em; }
    100% { --highlight-fade: 0px; }
  }
  @keyframes highlight-hold {
    from { translate: -100cqw 0; }
    to { translate: 100cqw 0; }
  }
  /* hidden while at rest, else the fields of the neighbours would take the clicks and the scrolling */
  @keyframes highlight-field {
    0%, 10%, 90%, 100% { visibility: hidden; }
    50% { visibility: visible; }
  }
  @keyframes highlight-text {
    0% { opacity: 0; translate: 50cqw 0; }
    50% { opacity: 1; translate: 0 0; }
    100% { opacity: 0; translate: -50cqw 0; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .highlights-fill,
  .highlight-layer,
  .highlight-text,
  .highlight-text > * {
    animation: none !important;
  }
}

/**
  * @section Vereinsmitteilungen
  */

section.news h3 {
  clear: left;
}
section.news ul.categories {
  float: right;
}
.pill.verein,
.admin-row-badge.verein {
  background-color: var(--color-category-yellow);
  color: var(--color-category-yellow-text);
}
.pill.wettkampf,
.admin-row-badge.wettkampf {
  background-color: var(--color-category-darkblue);
  color: var(--color-category-darkblue-text);
}
.pill.training,
.admin-row-badge.training {
  background-color: var(--color-category-purple);
  color: var(--color-category-purple-text);
}
.pill.erfolg,
.admin-row-badge.erfolg {
  background-color: var(--color-category-cyan);
  color: var(--color-category-cyan-text);
}
.pill.jugend,
.admin-row-badge.jugend {
  background-color: var(--color-category-pink);
  color: var(--color-category-pink-text);
}
.pill.galerie,
.admin-row-badge.galerie {
  background-color: var(--color-category-teal);
  color: var(--color-category-teal-text);
}
/* press articles */
.pill.laufen,
.admin-row-badge.laufen {
  background-color: var(--color-category-orange);
  color: var(--color-category-orange-text);
}
.pill.freizeitsport,
.admin-row-badge.freizeitsport {
  background-color: var(--color-category-green);
  /* white on this light green is hard to read */
  color: var(--color-black);
}
.pill.ehrungen,
.admin-row-badge.ehrungen {
  background-color: var(--color-category-brown);
  color: var(--color-category-brown-text);
}

/* phones: the picture upright (4:5), the text below it; turned by swiping, no arrows */
@media (max-width: 640px) {
  .highlight {
    height: auto;
  }
  .highlight-picture {
    aspect-ratio: 4 / 5;
    bottom: auto;
    width: 100%;
  }
  .highlight-layer {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .highlight-layer::before {
    aspect-ratio: 4 / 5;
    content: "";
  }
  .highlight-text {
    box-sizing: border-box;
    grid-column: 1;
    height: 300px;
    padding: 16px 16px 64px;
  }
  .highlights::before {
    height: 300px;
    left: 0;
    top: auto;
    width: auto;
  }
  .highlights-nav {
    left: 0;
    padding: 0 16px 16px;
    width: auto;
  }
  .highlights-step {
    display: none;
  }
}
