/* ===== Tokens: Karner Ingenieure ===== */
:root {
  --brand: #2626b4;
  --brand-dark: #1b1b8a;
  --brand-mid: #3d3dd8;
  --brand-light: #7a7af5;
  --sky: #38bdf8;

  --bg: #f3f4ff;
  --ink: #12123a;
  --muted: #5d5d85;
  --card: rgba(255, 255, 255, .72);
  --card-edge: rgba(255, 255, 255, .85);
  --line: rgba(38, 38, 180, .16);
  --chip: rgba(38, 38, 180, .08);
  --chip-ink: var(--brand);
  --shadow: 0 40px 90px -30px rgba(38, 38, 180, .45), 0 10px 30px -14px rgba(18, 18, 58, .25);
  --danger: #b4410c;
  --danger-bg: rgba(217, 83, 30, .10);

  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a22;
    --ink: #eef0ff;
    --muted: #a6a8d2;
    --card: rgba(22, 22, 60, .68);
    --card-edge: rgba(255, 255, 255, .09);
    --line: rgba(255, 255, 255, .14);
    --chip: rgba(122, 122, 245, .16);
    --chip-ink: #c9c9ff;
    --shadow: 0 40px 90px -30px rgba(0, 0, 0, .8);
    --danger: #ffb08a;
    --danger-bg: rgba(217, 83, 30, .18);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.55 "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ===== Hintergrund: ruhige Farbflächen + feines Punktraster ===== */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; }

.bg::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(var(--line) 1px, transparent 1.2px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .55;
  will-change: transform;
}
.orb-1 { width: 46vmax; height: 46vmax; left: -14vmax; top: -16vmax; background: var(--brand); animation: drift-a 26s ease-in-out infinite alternate; }
.orb-2 { width: 38vmax; height: 38vmax; right: -12vmax; bottom: -14vmax; background: var(--brand-light); animation: drift-b 31s ease-in-out infinite alternate; }
.orb-3 { width: 26vmax; height: 26vmax; right: 12vmax; top: -8vmax; background: var(--sky); opacity: .32; animation: drift-c 36s ease-in-out infinite alternate; }

@keyframes drift-a { to { transform: translate3d(10vmax, 8vmax, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-9vmax, -7vmax, 0) scale(1.1); } }
@keyframes drift-c { to { transform: translate3d(-6vmax, 10vmax, 0) scale(.9); } }

/* ===== Karte ===== */
.stage {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
}

.card {
  width: min(100%, 25rem);
  min-height: 22rem;
  padding: 2.25rem 2rem 2rem;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 24px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  animation: card-in .9s var(--ease) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
}

.logo {
  display: block;
  height: 3rem;
  width: auto;
  max-width: 100%;
  margin: 0 auto 2.25rem;
  border-radius: 4px;
  animation: rise .8s var(--ease) .1s both;
}

/* Inhalte einer Ansicht erscheinen nacheinander, sobald sie sichtbar wird */
.view[hidden] { display: none; }
.view:not([hidden]) > * { animation: rise .75s var(--ease) both; }
.view:not([hidden]) > :nth-child(1) { animation-delay: .20s; }
.view:not([hidden]) > :nth-child(2) { animation-delay: .30s; }
.view:not([hidden]) > :nth-child(3) { animation-delay: .40s; }
.view:not([hidden]) > :nth-child(4) { animation-delay: .50s; }
.view:not([hidden]) > :nth-child(5) { animation-delay: .60s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}

/* ===== Typografie ===== */
h1 {
  margin: 0 0 .4rem;
  font-size: clamp(1.8rem, 5vw, 2.15rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.lead { margin: 0 0 1.75rem; color: var(--muted); }

/* ===== Buttons ===== */
.btn {
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  width: 100%;
  min-height: 3.2rem;
  padding: 0 1.25rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  border: 0; border-radius: 14px;
  box-shadow: 0 14px 28px -12px rgba(38, 38, 180, .75);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.btn::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .3) 50%, transparent 70%);
  transform: translateX(-130%);
  transition: transform .8s var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 20px 34px -12px rgba(38, 38, 180, .85); }
.btn:hover::after { transform: translateX(130%); }
.btn:active { transform: translateY(0) scale(.985); box-shadow: 0 8px 18px -10px rgba(38, 38, 180, .8); }
.btn:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 3px; }

.ms {
  display: grid; place-items: center;
  width: 1.9rem; height: 1.9rem;
  background: #fff; border-radius: 8px;
}

.btn-ghost {
  color: var(--ink);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn-ghost:hover { background: var(--chip); box-shadow: inset 0 0 0 1px var(--brand-light); }

/* ===== Angemeldet ===== */
.avatar {
  position: relative;
  display: grid; place-items: center;
  width: 4.25rem; height: 4.25rem;
  margin-bottom: 1.1rem;
  color: #fff; font-size: 1.45rem; font-weight: 700; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius: 50%;
}
.avatar::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--brand-light);
  animation: ring 1.4s var(--ease) .7s 1 both;
}
@keyframes ring {
  from { opacity: .9; transform: scale(1); }
  to   { opacity: 0;  transform: scale(1.65); }
}

.roles { list-style: none; margin: 0 0 1.75rem; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.roles li {
  padding: .35rem .85rem;
  color: var(--chip-ink);
  background: var(--chip);
  border-radius: 999px;
  font-size: .92rem; font-weight: 600;
}

/* ===== Fehler ===== */
.error {
  margin: 0 0 1.25rem;
  padding: .8rem 1rem;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 12px;
  font-size: .95rem;
  animation: shake .5s var(--ease) .35s both;
}
.error[hidden] { display: none; }
@keyframes shake {
  20% { transform: translateX(-5px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
}

@media (max-width: 26rem) {
  .card { padding: 1.9rem 1.5rem 1.6rem; border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Alles in der Karte zentriert ===== */
.card { text-align: center; }
.lead { margin-left: auto; margin-right: auto; }
.avatar { margin-left: auto; margin-right: auto; }
.roles { justify-content: center; }

/* ===== Rollenwechsel ===== */
.view:not([hidden]) > :nth-child(6) { animation-delay: .70s; }
.caption { margin: 0 0 .6rem; color: var(--muted); font-size: .9rem; }
.roles li.switch { padding: 0; background: none; }
.role-btn {
  min-height: 2.5rem;
  padding: 0 1.1rem;
  font: inherit; font-size: .92rem; font-weight: 600;
  color: var(--chip-ink);
  background: var(--chip);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background .25s var(--ease), color .25s var(--ease), transform .25s var(--ease), border-color .25s var(--ease);
}
.role-btn:hover { transform: translateY(-1px); border-color: var(--brand-light); }
.role-btn[aria-pressed="true"] { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-mid)); }
.role-btn:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 2px; }
