/* ═══════════════════════════════════════
   ABFALL 2000 — CSS
   Film Credits Blog, User-Scroll
═══════════════════════════════════════ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --black: #000000;
  --white: #ffffff;
  --mid-grey: #888888;
  --light-grey: #d0d0d0;
  --hair-grey: #ececec;
  --wash-grey: #f6f6f6;

  /* SF Pro-like: system-ui uses SF Pro on macOS/iOS natively */
  --font-ui: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue',
             Arial, sans-serif;

  /* wird von main.js an die tatsächliche Header-Höhe angeglichen */
  --header-height: 218px;
}

/* ── Reset & Base ───────────────────────── */

html {
  scroll-behavior: smooth;
  /* verhindert das Aufblähen von Text im iOS-Querformat */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Nur hier, nicht zusätzlich auf dem body: overflow-x auf dem body würde
     dessen overflow-y rechnerisch auf `auto` setzen und ihn damit zu einem
     eigenen Scroll-Container machen. */
  overflow-x: hidden;
}

/* Bewusst KEIN height:100% + overflow-y:auto auf dem body: das macht den Body
   zu einem eigenen Scroll-Container und bricht in iOS-Safari Momentum-Scrolling
   und position:fixed. Gescrollt wird das Dokument selbst. */
html, body {
  min-height: 100%;
  background: var(--white);
  color: var(--black);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Header ─────────────────────────────── */

#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  /* deckend als Basis — ohne backdrop-filter würde Text durchscheinen */
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-bottom: 1px solid var(--light-grey);
}

@supports ((-webkit-backdrop-filter: blur(12px)) or (backdrop-filter: blur(12px))) {
  #site-header {
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}

/* Fade mask below header */
#site-header::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.9) 0%, transparent 100%);
  pointer-events: none;
}

#header-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px 20px 0;
}

#site-title {
  font-family: var(--font-ui);
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--black);
}

/* Der Titel ist ein Button (zurück nach oben) — soll aber wie Text aussehen. */
#home-button {
  display: inline-block;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  line-height: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.18s ease;
}

#home-button:hover {
  opacity: 0.55;
}

#home-button:focus {
  outline: none;
}

#home-button:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 4px;
}

#entry-counter {
  font-family: var(--font-ui);
  font-size: clamp(0.68rem, 1.8vw, 0.8rem);
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mid-grey);
}

#counter-number {
  color: var(--black);
  font-weight: 600;
}

/* ── Controls: Suche + Jahresfilter ─────── */

#controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 20px 16px;
}

#search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  max-width: 380px;
}

#search-icon {
  position: absolute;
  left: 12px;
  width: 13px;
  height: 13px;
  color: var(--mid-grey);
  pointer-events: none;
}

#search-input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--black);
  background: var(--wash-grey);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 34px 9px 33px;
  line-height: 1.2;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}

#search-input::placeholder {
  color: var(--mid-grey);
  letter-spacing: 0.04em;
}

#search-input:focus {
  background: var(--white);
  border-color: var(--black);
}

/* native Clear-Buttons unterdrücken — wir haben einen eigenen */
#search-input::-webkit-search-decoration,
#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
}

#search-clear {
  position: absolute;
  right: 9px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--light-grey);
  color: var(--white);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 1px;
  transition: background 0.15s ease;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

#search-clear:hover {
  background: var(--mid-grey);
}

/* [hidden] muss das display:flex oben schlagen */
#search-clear[hidden] {
  display: none;
}

#year-wrap {
  display: flex;
  flex: 0 0 auto;   /* darf nicht schrumpfen, sonst wird der Text beschnitten */
}

/* Optik bewusst wie das Suchfeld: graue Pill ohne Rahmen, graue Schrift. */
#year-select {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--mid-grey);
  background-color: var(--wash-grey);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23888' stroke-width='1.2' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 9px 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  /* rechts großzügig: der Pfeil braucht Platz, sonst schneiden
     Safari/Chrome das letzte Wort ab */
  padding: 9px 36px 9px 16px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
  /* Nicht auf die intrinsische Breite verlassen: Browser messen Text
     unterschiedlich, dadurch wurde das letzte Wort abgeschnitten.
     Feste Untergrenze mit Reserve statt millimetergenauer Passform. */
  min-width: 160px;
  max-width: 100%;
  text-overflow: ellipsis;
  line-height: 1.2;
  height: auto;
}

#year-select:hover {
  color: var(--black);
}

#year-select:focus {
  color: var(--black);
  background-color: var(--white);
  border-color: var(--black);
}

/* ── Ticker ─────────────────────────────── */

/* Höhe wird von main.js beim Scrollen verkleinert (Ticker schiebt sich weg). */
#ticker-clip {
  overflow: hidden;
}

#ticker {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--hair-grey);
  background: var(--black);
  height: 38px;
  display: flex;
  align-items: center;
  touch-action: pan-x;
  -webkit-tap-highlight-color: transparent;
}

/* Randverlauf als Overlay statt als mask-image: mask-image erzwingt in Safari
   eine zusätzliche Compositing-Ebene und flackert dort zusammen mit dem
   animierten Track. */
#ticker::before,
#ticker::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  z-index: 2;
  pointer-events: none;
}

#ticker::before {
  left: 0;
  background: linear-gradient(to right, rgb(0, 0, 0) 0%, rgba(0, 0, 0, 0) 100%);
}

#ticker::after {
  right: 0;
  background: linear-gradient(to left, rgb(0, 0, 0) 0%, rgba(0, 0, 0, 0) 100%);
}

/* Bewegung kommt aus main.js (rAF), nicht aus einer CSS-Animation —
   nur so friert der Ticker beim Hover exakt an Ort und Stelle ein. */
#ticker-track {
  display: flex;
  align-items: center;
  width: max-content;
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.ticker-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 0 0 auto;
  padding: 0 4px;
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  line-height: 1;
  color: var(--white);
  white-space: nowrap;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;   /* kein 300ms-Tap-Delay */
  -webkit-appearance: none;
  appearance: none;
}

.ticker-item:hover .ticker-text {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ticker-item:focus-visible {
  outline: 1px solid var(--white);
  outline-offset: 2px;
}

.ticker-num {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--mid-grey);
}

.ticker-text {
  letter-spacing: 0.005em;
  color: rgba(255, 255, 255, 0.92);
}

.ticker-sep {
  font-size: 0.42rem;
  color: var(--mid-grey);
  padding: 0 18px;
  transform: translateY(-2px);
}

/* ── Page Content ────────────────────────── */

#page-content {
  padding-top: var(--header-height);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Credits Track ───────────────────────── */

#credits-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ── Individual Entry ────────────────────── */

.entry {
  width: 100%;
  max-width: 640px;
  padding: 56px 40px;
  text-align: left;
  position: relative;
  scroll-margin-top: calc(var(--header-height) + 24px);
}

/* Kurzes Aufblitzen beim Sprung aus dem Ticker.
   Direkt auf dem Element animiert statt über ein ::before mit z-index:-1 —
   negative z-index-Ebenen rendern in Safari unzuverlässig. */
.entry-flash {
  animation: entry-flash 1.6s ease-out;
}

@keyframes entry-flash {
  0%   { background-color: var(--wash-grey); }
  100% { background-color: rgba(246, 246, 246, 0); }
}

/* Meta line: Datum — Nummer */
.entry-meta {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 9px;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.entry-date {
  color: var(--mid-grey);
}

.entry-meta-sep,
.entry-number {
  color: var(--light-grey);
}

.entry-number {
  letter-spacing: 0.2em;
}

/* Main text */
.entry-text {
  font-family: var(--font-ui);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  line-height: 1.5;
  color: var(--black);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.entry-text em {
  font-style: italic;
}

.entry-text strong {
  font-weight: 600;
}

/* Suchtreffer */
.entry mark {
  background: #ffe9a8;
  color: var(--black);
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Empty State ─────────────────────────── */

#no-results {
  width: 100%;
  max-width: 640px;
  padding: 110px 40px;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 2;
  letter-spacing: 0.06em;
  color: var(--mid-grey);
}

#no-results span {
  color: var(--light-grey);
  font-size: 0.8rem;
}

/* ── Footer ──────────────────────────────── */

#site-footer {
  width: 100%;
  max-width: 640px;
  padding: 48px 40px 72px;
  display: flex;
  justify-content: center;
  gap: 10px;
  border-top: 1px solid var(--light-grey);
  margin-top: 20px;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--light-grey);
}

#site-footer a,
#legal-link {
  color: var(--mid-grey);
  text-decoration: none;
  transition: color 0.18s ease;
}

#site-footer a:hover,
#legal-link:hover {
  color: var(--black);
}

/* Immer erreichbar, ohne durch tausende Einträge zu scrollen. */
#header-top {
  position: relative;
}

#legal-link {
  position: absolute;
  top: 12px;
  right: 16px;
  font-family: var(--font-ui);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ── Impressum & Datenschutz (impressum.html) ── */

#legal {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 40px 96px;
  font-family: var(--font-ui);
}

.legal-back {
  display: inline-block;
  margin-bottom: 48px;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mid-grey);
  text-decoration: none;
}

.legal-back:hover {
  color: var(--black);
}

#legal section + section {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--light-grey);
}

#legal h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 24px;
}

#legal h2 {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mid-grey);
  margin: 32px 0 10px;
}

#legal p {
  font-size: 0.9rem;
  line-height: 1.8;
}

#legal p + p {
  margin-top: 16px;
}

#legal a {
  color: inherit;
  text-underline-offset: 3px;
}

#legal .legal-back {
  color: var(--mid-grey);
}

/* ── Responsive ─────────────────────────── */

@media (max-width: 600px) {
  #header-top {
    padding: 14px 16px 0;
  }

  #controls {
    padding: 12px 16px;
    gap: 8px;
  }

  #search-wrap {
    flex: 1 1 100%;
    max-width: none;
  }

  /* Der Jahresfilter tritt auf kleinen Screens zurück: keine volle Zeilenbreite,
     kein Pill-Rahmen — nur ein schlichter, grauer Textschalter unter der Suche. */
  #year-wrap {
    flex: 0 0 auto;
    max-width: 100%;
  }

  /* 16px ist die Schwelle, unter der iOS-Safari beim Fokussieren
     ins Feld hineinzoomt. Pinch-Zoom bleibt erlaubt. */
  #search-input,
  #year-select {
    font-size: 16px;
  }

  #search-input {
    width: 100%;
  }

  #year-select {
    /* font-size bleibt bei 16px (siehe oben) — zurückgenommen wird die Optik:
       keine Pill, kein Rahmen, graue statt schwarzer Schrift. */
    width: auto;
    min-width: 0;
    font-weight: 400;
    color: var(--mid-grey);
    background-color: transparent;
    background-position: right 2px center;
    border-color: transparent;
    border-radius: 0;
    padding: 2px 16px 2px 2px;
    letter-spacing: 0.08em;
  }

  #year-select:hover,
  #year-select:focus {
    border-color: transparent;
    color: var(--black);
  }

  #ticker {
    height: 34px;
  }

  .ticker-item {
    font-size: 0.7rem;
  }

  .entry {
    padding: 42px 24px;
  }

  #site-footer {
    padding: 40px 24px 56px;
  }

  #legal {
    padding: 32px 24px 72px;
  }

  /* über der Titelzeile, damit er schmale Titel nicht überlappt */
  #legal-link {
    top: 4px;
    right: 12px;
  }
}

/* ── Reduced Motion ─────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  /* Ticker steht still (siehe prefersReducedMotion in main.js), lässt sich
     aber von Hand durchschieben. */
  #ticker {
    overflow-x: auto;
  }

  .entry-flash {
    animation: none;
  }
}
