:root {
  --bg: #ffffff;
  --ink: #0a0a0a;
  --muted: #86868b;
  --hairline: rgba(0, 0, 0, 0.08);
  --tile-bg: #ffffff;
  --tile-soon-bg: #f4f4f5;
  --blue: #0044ff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0c;
    --ink: #f2f2f2;
    --muted: #8e8e93;
    --hairline: rgba(255, 255, 255, 0.14);
    --tile-soon-bg: #1a1a1a;
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  min-height: 100svh;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
}

/* ---------- Hero / Logo ---------- */

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46svh;
  padding: clamp(3rem, 8vh, 6rem) 1.5rem 0;
}

.logo {
  width: min(78vw, 30rem);
  line-height: 0;
}

.logo-svg {
  width: 100%;
  height: auto;
  color: var(--ink);
  /* Der Cursor startet links außerhalb der viewBox (vor dem „u") */
  overflow: visible;
}

/* ---------- Aufbau-Animation ----------
   Choreografie (à la LoveFrom): Cursor erscheint links, blinkt einmal
   wartend → „use" wird getippt, der Cursor wandert dabei hinter jedem
   Buchstaben mit → Cursor bleibt stehen, „tkm" steigt ein → App-Icons
   bauen sich nacheinander auf → About & Footer blenden ein.
   Danach blinkt der Cursor dauerhaft.

   Der Cursor-Rect steht im SVG auf seiner End-Position (x=510.6);
   caretMove verschiebt ihn in User-Units dorthin zurück, wo die noch
   nicht getippten Buchstaben stehen (vor u / nach u / nach s). */

.logo-bar {
  animation:
    caret-intro 1.5s ease-out both 0.3s,
    caret-move 2.3s linear both,
    caret 1.6s ease-in-out infinite 6.4s;
}

.letter {
  animation: fadeIn 0.06s ease-out both;
}

.l-u { animation-delay: 1.8s; }
.l-s { animation-delay: 2.05s; }
.l-e { animation-delay: 2.3s; }

/* tkm-Geist: deutet die Gefäßform an, bevor die Flüssigkeit steigt */
.tkm-ghost {
  opacity: 0.07;
  animation: ghost-in 0.5s ease-out both 2.55s;
}

/* Gieß-Strahl: fällt beschleunigt ins t, hält während des Füllens,
   am Ende reißt er ab und der Schweif fällt in die Flüssigkeit nach */
.tkm-pour {
  transform: translateY(-360px);
  animation: pour 3.1s both 2.9s;
}

/* Die Flüssigkeit sammelt sich erst flach am Boden (während sie sich
   ausbreitet) und steigt dann gedämpft bis über die Oberlängen */
.tkm-water {
  transform: translateY(-30px);
  animation: water-rise 3.05s both 3.15s;
}

/* Ausbreitung vom t-Fuß aus zu k und m (kommunizierende Gefäße) */
.tkm-spread-rect {
  animation: spread 1.1s cubic-bezier(0.2, 0, 0.3, 1) both 3.15s;
}

/* Zwei gegenläufige Oberflächenwellen; enden nahtlos, sobald gefüllt ist */
.tkm-wave-front {
  animation: wave-front 1.7s linear 4;
}

.tkm-wave-back {
  animation: wave-back 2.9s linear 3;
}

.app-grid li {
  animation: tileIn 0.5s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}

.app-grid li:nth-child(1) { animation-delay: 5.9s; }
.app-grid li:nth-child(2) { animation-delay: 5.99s; }
.app-grid li:nth-child(3) { animation-delay: 6.08s; }
.app-grid li:nth-child(4) { animation-delay: 6.17s; }
.app-grid li:nth-child(5) { animation-delay: 6.26s; }
.app-grid li:nth-child(6) { animation-delay: 6.35s; }

.about,
footer {
  animation: fadeIn 0.7s ease-out both 6.5s;
}

/* Erscheinen + zwei wartende Blinzler, bevor getippt wird (0.3s–1.8s) */
@keyframes caret-intro {
  0% { opacity: 0; }
  6%, 30% { opacity: 1; }
  33%, 43% { opacity: 0; }
  46%, 73% { opacity: 1; }
  76%, 86% { opacity: 0; }
  89%, 100% { opacity: 1; }
}

/* Sprünge hinter den zuletzt getippten Buchstaben (0s–2.3s):
   vor u → nach u (1.8s) → nach s (2.05s) → Endposition (2.3s) */
@keyframes caret-move {
  0%, 78.1% { transform: translateX(-525px); }
  78.4%, 89% { transform: translateX(-313px); }
  89.3%, 99.8% { transform: translateX(-171px); }
  100% { transform: translateX(0); }
}

@keyframes ghost-in {
  from { opacity: 0; }
  to { opacity: 0.07; }
}

/* Fallen (Gravitation) → Halten → Abreißen und Nachfallen */
@keyframes pour {
  0% {
    transform: translateY(-360px);
    animation-timing-function: cubic-bezier(0.5, 0, 1, 1);
  }
  11.3%, 87% { transform: translateY(0); }
  87.1% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0.5, 0, 1, 1);
  }
  100% { transform: translateY(380px); }
}

/* Erst flaches Sammeln am Boden (0–16%), dann gedämpfter Anstieg */
@keyframes water-rise {
  0% {
    transform: translateY(318px);
    animation-timing-function: cubic-bezier(0.3, 0, 0.7, 1);
  }
  16% {
    transform: translateY(299px);
    animation-timing-function: cubic-bezier(0.33, 0, 0.15, 1);
  }
  100% { transform: translateY(-30px); }
}

/* Pfütze unterm t (±50 Units um den Stamm) → volle Breite, Mitte bleibt am t */
@keyframes spread {
  from {
    x: 13.65px;
    width: 100px;
  }
  to {
    x: -971.35px;
    width: 2070px;
  }
}

/* Verschiebung um exakt 2 Wellenlängen (2 × 206) → nahtlose Schleife */
@keyframes wave-front {
  from { transform: translateX(0); }
  to { transform: translateX(-412px); }
}

@keyframes wave-back {
  from { transform: translateX(0); }
  to { transform: translateX(412px); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tileIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes caret {
  0%, 60% { opacity: 1; }
  70%, 90% { opacity: 0; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-bar,
  .letter,
  .tkm-ghost,
  .tkm-pour,
  .tkm-water,
  .tkm-spread-rect,
  .tkm-wave-front,
  .tkm-wave-back,
  .app-grid li,
  .about,
  footer {
    animation: none;
  }
}

/* ---------- App-Grid ---------- */

.apps {
  padding: clamp(3.5rem, 9vh, 7rem) 1.5rem 0;
}

.app-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(2.5rem, 6vw, 4rem) clamp(1rem, 4vw, 3rem);
  max-width: 42rem;
  margin: 0 auto;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
}

.tile {
  position: relative;
  width: clamp(4.75rem, 16vw, 6.5rem);
  aspect-ratio: 1;
  border-radius: 22.37%;
  overflow: hidden;
  background: var(--tile-bg);
  transition: transform 0.35s cubic-bezier(0.2, 0.6, 0.2, 1), box-shadow 0.35s cubic-bezier(0.2, 0.6, 0.2, 1);
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--hairline);
  pointer-events: none;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

a.app:hover .tile,
a.app:focus-visible .tile {
  transform: translateY(-0.3rem);
  box-shadow: 0 1.2rem 2rem -1rem rgba(0, 0, 0, 0.35);
}

a.app:focus-visible {
  outline: none;
}

a.app:focus-visible .tile::after {
  box-shadow: inset 0 0 0 2px var(--blue);
}

.app-name {
  margin-top: 0.9rem;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.app-tagline {
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Coming soon */

.app-soon {
  cursor: default;
}

.tile-soon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tile-soon-bg);
  color: var(--muted);
  font-size: 2rem;
  font-weight: 500;
  overflow: hidden;
}

.app-soon .app-name {
  color: var(--muted);
}

/* ---------- About ---------- */

.about {
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(4rem, 12vh, 8rem) 1.5rem;
  text-align: center;
}

.about p {
  color: var(--ink);
  font-size: 1.0625rem;
}

.about p + p {
  margin-top: 1.1rem;
  color: var(--muted);
}

/* ---------- Footer ---------- */

footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 2.5rem 1.5rem 3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

footer nav {
  display: flex;
  gap: 0.6rem;
}

footer a {
  color: inherit;
  text-decoration: none;
}

footer a:hover {
  color: var(--ink);
}

/* ---------- Rechtliches (Impressum / Datenschutz) ---------- */

.legal {
  max-width: 38rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.homelink {
  display: inline-block;
  color: var(--ink);
}

.homelink svg {
  display: block;
  height: 1.5rem;
  width: auto;
}

.legal h1 {
  margin-top: 2.5rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.legal .stand {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.legal h2 {
  margin-top: 2.2rem;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.legal p,
.legal ul {
  margin-top: 0.7rem;
  font-size: 0.95rem;
  color: var(--ink);
}

.legal ul {
  padding-left: 1.2rem;
}

.legal a {
  color: var(--blue);
  text-decoration: none;
}

.legal a:hover {
  text-decoration: underline;
}

.legal .homelink {
  color: var(--ink);
}

.legal .homelink:hover {
  text-decoration: none;
}

.legal .back {
  margin-top: 3.5rem;
}

.legal .back a {
  color: var(--muted);
}

.legal .back a:hover {
  color: var(--ink);
  text-decoration: none;
}

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 22rem;
  }

  .tile {
    width: clamp(5rem, 24vw, 6rem);
  }

  .hero {
    min-height: 38svh;
  }
}
