/* ============================================================================
   Kino-Intro (Splash) — beim App-Start und nach jedem Update.

   Reines CSS/HTML: liegt im Dokument, BEVOR app.js läuft. Damit deckt das
   Overlay den schwarzen Startbildschirm ab und übergibt erst, wenn die App
   wirklich gezeichnet hat (siehe Inline-Steuerung in public/index.php).

   Ablauf (≈ 4,8 s Animation, danach weiches Ausblenden):
     0.00 – 0.15  Letterbox-Balken fahren rein, Filmkorn, Projektor-Scheinwerfer
     0.12 – 1.00  SchweizChat: Logo fokussiert aus dem Unschärfe-Kegel
     0.34 – 1.35  Schriftzug «SchweizChat» mit Glanz-Sweep
     0.85 – 1.45  Software-Version blendet unter dem Schriftzug ein
     1.48 – 2.35  Überblendung (Licht-Sweep quer über die Bühne)
     2.17 – 2.95  «von» · Lindic.net · 4313 Möhlin, Schweiz
     2.95 – 4.80  Halten auf Lindic.net (Idle-Puls, ruhige Endkarte)
     4.00 +       Ladepunkte, falls die App noch länger braucht
   ========================================================================== */

.cine-splash {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 0;
  background: #04060c;
  color: #eef2ff;
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  opacity: 1;
  /* Ohne JavaScript trotzdem ausblenden (Notfall-Fallback). */
  animation: cine-nojs-out 0.7s ease 5.4s forwards;
  will-change: opacity, transform;
  touch-action: none;
}

/* —— Himmel / Bühnenlicht ————————————————————————————————————— */
.cine-splash__sky {
  position: absolute;
  inset: -12%;
  z-index: 0;
  background:
    radial-gradient(58% 42% at 50% 46%, rgba(94, 122, 255, 0.28) 0%, transparent 64%),
    radial-gradient(44% 34% at 16% 90%, rgba(87, 197, 182, 0.16) 0%, transparent 72%),
    radial-gradient(48% 36% at 86% 10%, rgba(232, 104, 58, 0.13) 0%, transparent 72%),
    linear-gradient(180deg, #080b15 0%, #04060c 56%, #010203 100%);
  animation: cine-sky 7s ease-in-out 0s infinite alternate;
}

/* Zwei Projektor-Kegel von unten links / rechts */
.cine-splash__beam {
  position: absolute;
  bottom: -28%;
  z-index: 1;
  width: 46vw;
  height: 125vh;
  transform-origin: bottom center;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    to top,
    rgba(158, 186, 255, 0.22) 0%,
    rgba(158, 186, 255, 0.09) 38%,
    rgba(158, 186, 255, 0.03) 62%,
    transparent 80%
  );
  mix-blend-mode: screen;
}
.cine-splash__beam--l {
  left: 4%;
  animation: cine-beam-l 3.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.08s both;
}
.cine-splash__beam--r {
  right: 4%;
  animation: cine-beam-r 3.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.3s both;
}

/* Anamorpher Lens-Flare (waagrechter Lichtstrich hinter dem Logo) */
.cine-splash__flare {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: min(150vw, 88rem);
  height: clamp(2px, 0.45vw, 4px);
  margin: 0;
  transform: translate(-50%, -50%) scaleX(0);
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(124, 140, 255, 0) 8%,
    rgba(150, 180, 255, 0.5) 34%,
    #ffffff 50%,
    rgba(150, 180, 255, 0.5) 66%,
    rgba(124, 140, 255, 0) 92%,
    transparent 100%
  );
  box-shadow: 0 0 26px 7px rgba(110, 140, 255, 0.38);
  animation: cine-flare 2.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.22s both;
}

/* —— Bühne —————————————————————————————————————————————————————— */
.cine-splash__stage {
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: min(94vw, 42rem);
  padding: 0 1rem;
  box-sizing: border-box;
  text-align: center;
}

/* Beide Marken liegen übereinander (grid-area) und werden überblendet. */
.cine-brand {
  grid-area: 1 / 1;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(0.6rem, 2.4vw, 1.05rem);
  width: 100%;
  will-change: opacity, transform, filter;
}

.cine-brand--chat {
  gap: clamp(0.5rem, 2vw, 0.85rem);
  animation: cine-brand-out 0.5s cubic-bezier(0.4, 0, 0.6, 1) 1.95s both;
}

.cine-brand--lindic {
  opacity: 0;
  animation:
    cine-brand-in 0.55s cubic-bezier(0.16, 0.84, 0.24, 1) 2.17s both,
    /* Puls-Takt so gewählt, dass der Schein während der verlängerten
       Standzeit (~3,0–4,8 s) einmal aufleuchtet und nicht erst danach. */
    cine-idle 2.8s ease-in-out 2.95s infinite;
}
.cine-brand--lindic > * {
  animation: cine-line-in 0.6s cubic-bezier(0.16, 0.84, 0.24, 1) both;
}
.cine-brand--lindic > :nth-child(1) { animation-delay: 2.21s; }
.cine-brand--lindic > :nth-child(2) { animation-delay: 2.33s; }
.cine-brand--lindic > :nth-child(3) { animation-delay: 2.45s; }

/* —— SchweizChat-Logo ——————————————————————————————————————— */
.cine-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(4.4rem, 15vw, 7rem);
  aspect-ratio: 1;
  animation: cine-mark-in 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.12s both;
}

.cine-mark__rays {
  position: absolute;
  inset: -85%;
  z-index: 0;
  pointer-events: none;
  background: conic-gradient(
    from 0deg,
    transparent 0deg 14deg,
    rgba(170, 196, 255, 0.16) 17deg 19deg,
    transparent 22deg 40deg,
    rgba(170, 196, 255, 0.12) 43deg 45deg,
    transparent 48deg 66deg,
    rgba(170, 196, 255, 0.16) 69deg 71deg,
    transparent 74deg 92deg,
    rgba(170, 196, 255, 0.11) 95deg 97deg,
    transparent 100deg 360deg
  );
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 26%, #000 44%, transparent 68%);
  mask-image: radial-gradient(circle at 50% 50%, transparent 26%, #000 44%, transparent 68%);
  opacity: 0;
  animation: cine-rays-in 1.6s ease 0.5s both, cine-rays-turn 22s linear 0.5s infinite;
}

.cine-mark__glow {
  position: absolute;
  inset: -58%;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle,
    rgba(124, 140, 255, 0.5) 0%,
    rgba(87, 197, 182, 0.2) 44%,
    rgba(124, 140, 255, 0) 68%
  );
  animation: cine-glow 2.8s ease-in-out 0.35s infinite;
}

.cine-mark__tile {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 28%;
  overflow: hidden;
  filter: drop-shadow(0 16px 32px rgba(94, 122, 255, 0.42));
}

.cine-mark__tile img {
  display: block;
  width: 100%;
  height: 100%;
}

.cine-mark__sheen {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    114deg,
    transparent 30%,
    rgba(255, 255, 255, 0.12) 40%,
    rgba(255, 255, 255, 0.78) 50%,
    rgba(255, 255, 255, 0.12) 60%,
    transparent 70%
  );
  background-size: 260% 260%;
  background-position: 130% 130%;
  mix-blend-mode: screen;
  animation: cine-sheen 2.6s cubic-bezier(0.3, 0, 0.3, 1) 0.55s infinite;
}

/* —— Schriftzug SchweizChat ————————————————————————————————— */
.cine-word {
  margin: 0;
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  font-size: clamp(1.85rem, 8vw, 3.3rem);
  line-height: 1.02;
  letter-spacing: 0.005em;
  background-image: linear-gradient(
    100deg,
    #ffffff 0%,
    #e2e9ff 26%,
    #ffffff 44%,
    #bac9ff 58%,
    #ffffff 76%,
    #ffffff 100%
  );
  background-size: 230% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 24px rgba(110, 140, 255, 0.35));
  animation:
    cine-word-in 1s cubic-bezier(0.16, 0.9, 0.24, 1) 0.34s both,
    cine-word-shine 3.2s ease-in-out 1.15s infinite;
}

/* —— Software-Version (unter dem Schriftzug) ———————————————— */
.cine-version {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5em;
  margin: -0.1rem 0 0;
  padding: 0.34em 0.9em 0.36em;
  border: 1px solid rgba(158, 186, 255, 0.26);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(120, 148, 255, 0.18) 0%, rgba(74, 96, 190, 0.1) 100%);
  box-shadow:
    0 0 26px rgba(94, 122, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: clamp(0.72rem, 2.9vw, 0.8rem);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  animation: cine-version-in 0.6s cubic-bezier(0.16, 0.9, 0.24, 1) 0.85s both;
}
.cine-version__tag {
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-transform: uppercase;
  font-size: 0.86em;
  font-weight: 600;
  color: rgba(200, 216, 255, 0.66);
}
.cine-version__num {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: #ffffff;
  text-shadow: 0 0 16px rgba(150, 180, 255, 0.62);
}

/* —— Lindic.net —————————————————————————————————————————————— */
.cine-von {
  margin: 0;
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(0.82rem, 3.4vw, 1.05rem);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: rgba(224, 232, 255, 0.6);
}

.cine-lindic {
  display: block;
  width: clamp(10.5rem, 44vw, 14.5rem);
  height: auto;
  filter: drop-shadow(0 10px 28px rgba(232, 104, 58, 0.22));
}

.cine-place {
  margin: 0;
  font-size: clamp(0.72rem, 3.1vw, 0.92rem);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-transform: uppercase;
  color: rgba(214, 224, 255, 0.7);
}

/* —— Ladepunkte (nur wenn die App länger als ~5,0 s braucht) ————
   Absolut unter der Endkarte: beeinflusst die Bühnenhöhe nicht, damit die
   Marken exakt in der Bildmitte bleiben. Erst nach der Kino-Mindestdauer
   (4,8 s), damit die Endkarte nicht kurz vor dem Ausblenden noch blinkt. */
.cine-dots {
  position: absolute;
  left: 50%;
  bottom: -2.1rem;
  display: flex;
  gap: 0.42rem;
  margin: 0;
  transform: translateX(-50%);
  opacity: 0;
  animation: cine-dots-in 0.5s ease 5.0s both;
}
.cine-dots i {
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 50%;
  background: rgba(200, 212, 255, 0.75);
  animation: cine-dot 1.3s ease-in-out infinite;
}
.cine-dots i:nth-child(2) { animation-delay: 0.18s; }
.cine-dots i:nth-child(3) { animation-delay: 0.36s; }

/* —— Glanz-Sweep über die ganze Bühne ——————————————————————— */
.cine-splash__sweep {
  position: absolute;
  inset: -25%;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(
    104deg,
    transparent 36%,
    rgba(255, 255, 255, 0.05) 45%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0.05) 55%,
    transparent 64%
  );
  mix-blend-mode: screen;
  transform: translateX(-62%);
  opacity: 0;
  animation: cine-sweep 1.9s cubic-bezier(0.3, 0, 0.3, 1) 0.9s both;
}

/* —— Letterbox-Balken ——————————————————————————————————————— */
.cine-splash__bars {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
.cine-splash__bars i {
  position: absolute;
  left: 0;
  right: 0;
  height: clamp(12px, 3.4vh, 30px);
  background: #000;
}
.cine-splash__bars i:nth-child(1) {
  top: 0;
  animation: cine-bar-top 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) 0.04s both;
}
.cine-splash__bars i:nth-child(2) {
  bottom: 0;
  animation: cine-bar-bottom 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) 0.04s both;
}

/* —— Vignette + Filmkorn ——————————————————————————————————— */
.cine-splash__vignette {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background: radial-gradient(
    122% 92% at 50% 48%,
    transparent 38%,
    rgba(0, 0, 0, 0.5) 76%,
    #000000 100%
  );
}

.cine-splash__grain {
  position: absolute;
  inset: -60%;
  z-index: 8;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='0.6'/></svg>");
  mix-blend-mode: overlay;
  animation: cine-grain 0.9s steps(3) infinite;
}

/* —— Ausblenden (Klasse setzt das Inline-Script) ————————————— */
.cine-splash.is-out {
  animation: none;
  opacity: 0;
  transform: scale(1.045);
  transition: opacity 0.62s cubic-bezier(0.3, 0, 0.4, 1), transform 0.62s cubic-bezier(0.3, 0, 0.4, 1);
  pointer-events: none;
}
.cine-splash.is-out .cine-splash__sweep,
.cine-splash.is-out .cine-splash__flare {
  animation: none;
  opacity: 0;
}
.cine-splash.is-out .cine-splash__stage {
  filter: blur(2px);
  transition: filter 0.5s ease;
}

/* ============================================================================
   Keyframes
   ========================================================================== */
@keyframes cine-sky {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to   { transform: scale(1.06) translate3d(0, -1.5%, 0); }
}

@keyframes cine-beam-l {
  0%   { opacity: 0; transform: rotate(15deg) scaleY(0.22); }
  26%  { opacity: 0.9; transform: rotate(15deg) scaleY(1); }
  100% { opacity: 0.3; transform: rotate(19deg) scaleY(1); }
}
@keyframes cine-beam-r {
  0%   { opacity: 0; transform: rotate(-15deg) scaleY(0.22); }
  26%  { opacity: 0.8; transform: rotate(-15deg) scaleY(1); }
  100% { opacity: 0.26; transform: rotate(-19deg) scaleY(1); }
}

@keyframes cine-flare {
  0%   { opacity: 0; transform: translate(-50%, -50%) scaleX(0.05); }
  30%  { opacity: 0.95; transform: translate(-50%, -50%) scaleX(1); }
  62%  { opacity: 0.55; transform: translate(-50%, -50%) scaleX(1); }
  100% { opacity: 0.18; transform: translate(-50%, -50%) scaleX(0.86); }
}

@keyframes cine-mark-in {
  0%   { opacity: 0; transform: perspective(700px) translateY(14px) scale(0.72) rotateX(16deg); filter: blur(16px); }
  55%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: perspective(700px) translateY(0) scale(1) rotateX(0deg); filter: blur(0); }
}

@keyframes cine-rays-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cine-rays-turn {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes cine-glow {
  0%, 100% { opacity: 0.65; transform: scale(0.97); }
  50%      { opacity: 1; transform: scale(1.05); }
}

@keyframes cine-sheen {
  0%   { background-position: 135% 135%; }
  55%  { background-position: -35% -35%; }
  100% { background-position: -35% -35%; }
}

@keyframes cine-word-in {
  0%   { opacity: 0; transform: translateY(18px) scale(0.96); filter: blur(10px) drop-shadow(0 8px 24px rgba(110, 140, 255, 0.35)); }
  60%  { opacity: 1; filter: blur(0) drop-shadow(0 8px 24px rgba(110, 140, 255, 0.35)); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0) drop-shadow(0 8px 24px rgba(110, 140, 255, 0.35)); }
}
@keyframes cine-word-shine {
  0%   { background-position: 0% 50%; }
  60%  { background-position: 100% 50%; }
  100% { background-position: 100% 50%; }
}

@keyframes cine-brand-out {
  from { opacity: 1; transform: scale(1); filter: blur(0); }
  to   { opacity: 0; transform: scale(1.07); filter: blur(7px); }
}
@keyframes cine-version-in {
  0%   { opacity: 0; transform: translateY(9px) scale(0.94); filter: blur(6px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes cine-brand-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cine-line-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(5px); }
  to   { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes cine-idle {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(232, 104, 58, 0)); }
  50%      { filter: drop-shadow(0 0 26px rgba(232, 104, 58, 0.16)); }
}

@keyframes cine-dots-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cine-dot {
  0%, 100% { opacity: 0.28; transform: translateY(0); }
  50%      { opacity: 1;    transform: translateY(-2px); }
}

@keyframes cine-sweep {
  0%   { opacity: 0; transform: translateX(-62%); }
  18%  { opacity: 0.85; }
  62%  { opacity: 0.5; }
  100% { opacity: 0; transform: translateX(62%); }
}

@keyframes cine-bar-top {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}
@keyframes cine-bar-bottom {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes cine-grain {
  0%   { transform: translate3d(-2%, 1%, 0); }
  33%  { transform: translate3d(1%, -2%, 0); }
  66%  { transform: translate3d(2%, 2%, 0); }
  100% { transform: translate3d(-1%, -1%, 0); }
}

@keyframes cine-nojs-out {
  from { opacity: 1; }
  to   { opacity: 0; visibility: hidden; }
}

/* ============================================================================
   Reduzierte Bewegung: ruhige Endkarte (beide Marken untereinander), keine FX
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .cine-splash * {
    animation: none !important;
    transition: none !important;
  }
  .cine-splash__beam,
  .cine-splash__flare,
  .cine-splash__sweep,
  .cine-splash__grain,
  .cine-mark__rays,
  .cine-mark__sheen,
  .cine-dots {
    display: none !important;
  }
  .cine-splash__sky {
    animation: none !important;
    transform: none;
  }
  .cine-splash__stage {
    gap: clamp(1.15rem, 5vw, 1.9rem);
  }
  .cine-brand {
    grid-area: auto;
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  .cine-brand--chat {
    opacity: 1 !important;
  }
  .cine-brand--lindic {
    padding-top: clamp(0.7rem, 3vw, 1.1rem);
    border-top: 1px solid rgba(200, 214, 255, 0.16);
    opacity: 1 !important;
  }
  .cine-splash.is-out {
    transition: opacity 0.4s ease !important;
    transform: none;
    animation: none;
  }
}

/* Sehr kleine Geräte: etwas kompakter halten */
@media (max-height: 420px) {
  .cine-splash__stage {
    gap: 0.4rem;
  }
  .cine-mark {
    width: clamp(3.2rem, 11vh, 4.4rem);
  }
  .cine-word {
    font-size: clamp(1.4rem, 6.4vh, 2.1rem);
  }
  .cine-lindic {
    width: clamp(8rem, 30vh, 11rem);
  }
  .cine-version {
    font-size: 0.7rem;
    padding: 0.28em 0.72em 0.3em;
  }
}
