/* FDL Ausbildung: geführte Einführung (tour.js) mit Fritz.
   Abdunkeln mit einem Ausschnitt um das erklärte Element, Sprechblase mit Fritz daneben. */

/* ------------------------------------------------------------ Knopf oben */
.tourbtn .ic { font-size: 16px; color: var(--accent); }
.tourbtn.hint { animation: tourHint 1.6s var(--ease) 2; }
@keyframes tourHint {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
  30% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), .35); background: rgba(var(--accent-rgb), .18); color: var(--text); }
}
@media (max-width: 380px) { .tourbtn span { display: none; } }

/* ------------------------------------------------------------ Ebene über allem */
.tour { position: fixed; inset: 0; z-index: 120; display: none; padding-bottom: env(safe-area-inset-bottom, 0px); pointer-events: auto; }
.tour.on { display: block; animation: fade .35s; }
.tour.closing { animation: tourOut .3s forwards; }
@keyframes tourOut { to { opacity: 0; } }
body.touring .toasts { z-index: 130; }

/* Der Ausschnitt: ein Kasten mit riesigem Schatten, der den Rest abdunkelt. */
.tour-hole {
  position: fixed; left: 0; top: 0; width: 0; height: 0; border-radius: 16px; pointer-events: none;
  box-shadow: 0 0 0 200vmax rgba(5, 6, 9, .74);
  transition: transform .6s var(--ease), width .6s var(--ease), height .6s var(--ease), border-radius .6s var(--ease), box-shadow .5s;
}
.tour-hole.off { box-shadow: 0 0 0 200vmax rgba(5, 6, 9, .8); }
.tour-ring {
  position: absolute; inset: -2px; border-radius: inherit; border: 2px solid rgba(var(--accent-rgb), .95);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), .55), inset 0 0 14px rgba(var(--accent-rgb), .25);
  animation: tourRing 2.2s ease-in-out infinite;
}
.tour-hole.off .tour-ring { opacity: 0; animation: none; }
.tour-ring::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid rgba(var(--accent-rgb), .7);
  opacity: 0;
}
.tour-hole.land .tour-ring::after { animation: tourWave .9s .35s var(--ease); }
@keyframes tourRing { 50% { box-shadow: 0 0 30px rgba(var(--accent-rgb), .8), inset 0 0 18px rgba(var(--accent-rgb), .35); } }
@keyframes tourWave { 0% { opacity: .9; inset: -2px; } 100% { opacity: 0; inset: -22px; } }

/* ------------------------------------------------------------ Sprechblase mit Fritz */
.tour-card {
  position: fixed; left: 0; top: 0; width: min(530px, calc(100vw - 32px));
  transition: transform .6s var(--ease);
  will-change: transform;
}
.tour-card.enter { animation: tourEnter .55s cubic-bezier(.2, 1.3, .3, 1); }
@keyframes tourEnter { from { opacity: 0; } }
.tour-card.nudge .tour-bubble { animation: qShake .45s; }
.tour-inner { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: end; gap: 2px; }

.tour-fritz { width: 150px; margin-bottom: -4px; transform-origin: 50% 100%; position: relative; z-index: 1; }
.tour-fritz.hop { animation: tourHop .6s cubic-bezier(.3, 1.6, .4, 1); }
@keyframes tourHop {
  0% { transform: translateY(14px) scale(.92, 1.06); opacity: .4; }
  45% { transform: translateY(-8px) scale(1.03, .97); opacity: 1; }
  70% { transform: translateY(1px) scale(.98, 1.02); }
}

.tour-bubble {
  position: relative; padding: 18px 20px 14px; border-radius: 18px;
  background: var(--solid-dialog); border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: inset 0 1px 0 var(--edge-top), 0 26px 60px -18px #000, 0 0 0 1px rgba(var(--accent-rgb), .12);
  margin-bottom: 26px;
}
/* Zipfel zur Mund-Seite von Fritz */
.tour-bubble::before {
  content: ""; position: absolute; left: -9px; bottom: 34px; width: 18px; height: 18px;
  background: var(--solid-dialog); border-left: 1px solid rgba(255, 255, 255, .12); border-bottom: 1px solid rgba(255, 255, 255, .12);
  transform: rotate(45deg); border-bottom-left-radius: 4px;
}
.tour-bubble.pop { animation: tourPop .5s cubic-bezier(.2, 1.4, .3, 1); }
@keyframes tourPop { from { opacity: 0; transform: scale(.92) translateY(8px); } }
.tour-title { margin: 0 30px 6px 0; font: 600 19px/1.2 var(--display); color: var(--text); }
.tour-text { display: grid; margin: 0; color: var(--dim); font-size: 14px; line-height: 1.5; position: relative; }
.tour-text > .ghost, .tour-text > .live { grid-area: 1 / 1; }
.tour-text > .ghost { visibility: hidden; }
.tour-text > .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tour-x {
  position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--faint); display: grid; place-items: center; font-size: 16px; transition: background .2s, color .2s;
}
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.tour-prog { display: flex; align-items: center; gap: 10px; min-width: 90px; flex: 1; }
.tour-bar { position: relative; flex: 1; max-width: 120px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.tour-bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width .6s var(--ease); }
.tour-count { color: var(--faint); font-size: 12px; white-space: nowrap; }
.tour-btns { display: flex; gap: 8px; margin-left: auto; }
.tour-btns .btn { min-width: 0; }

/* Ohne Element (Begrüßung, Schluss): größer in der Mitte */
.tour-card.center { width: min(600px, calc(100vw - 32px)); }
.tour-card.center .tour-inner { grid-template-columns: 210px minmax(0, 1fr); }
.tour-card.center .tour-fritz { width: 210px; }
.tour-card.center .tour-title { font-size: 22px; }

@media (hover: hover) {
  .tour-x:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
}

/* ------------------------------------------------------------ Fritz (fritz.js): Bild je Gefühl, hüpft und atmet */
.fritz { position: relative; width: 100%; aspect-ratio: var(--fz-ratio, 1.09); }
.fz-flip { position: absolute; inset: 0; transform-origin: 50% 100%; transition: transform .45s cubic-bezier(.3, 1.5, .4, 1); }
.fritz.flip .fz-flip { transform: scaleX(-1); }
.fz-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%;
  opacity: 0; transition: opacity .22s; user-select: none; -webkit-user-drag: none;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .45));
}
.fz-img.on { opacity: 1; }
/* Ruhe: atmen. Wechsel: kurz stauchen und hochfedern. Sprechen: leichtes Nicken. */
.fritz { animation: fzBreathe 3.400s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes fzBreathe { 50% { transform: translateY(-2px) scale(1.012, .992); } }
.fritz.react { animation: fzReact .6s cubic-bezier(.3, 1.6, .4, 1), fzBreathe 3.400s .6s ease-in-out infinite; }
@keyframes fzReact { 0% { transform: scale(1); } 25% { transform: scale(1.07, .9) translateY(2px); } 55% { transform: scale(.96, 1.06) translateY(-6px); } 80% { transform: scale(1.01, .99); } }
.fritz.talk .fz-flip > .fz-img.on { animation: fzNod .5s ease-in-out infinite alternate; transform-origin: 50% 90%; }
@keyframes fzNod { from { transform: rotate(-1.200deg) translateY(0); } to { transform: rotate(1.200deg) translateY(-1.500px); } }
.fritz.f-jubeln.react { animation: fzJump .55s cubic-bezier(.3, 1.6, .4, 1) 3, fzBreathe 3.400s 1.700s ease-in-out infinite; }
@keyframes fzJump { 40% { transform: translateY(-14px) scale(.98, 1.03); } }
.fritz.f-lachen .fz-flip > .fz-img.on { animation: fzLaugh .3s ease-in-out 6 alternate; }
@keyframes fzLaugh { to { transform: translateY(-3px) rotate(-1.500deg); } }
.fritz.f-nervoes .fz-flip > .fz-img.on { animation: fzShiver 2.600s ease-in-out infinite; }
@keyframes fzShiver { 0%, 60%, 100% { transform: translateX(0); } 64%, 72%, 80% { transform: translateX(-1.500px); } 68%, 76% { transform: translateX(1.500px); } }
.fritz.f-nachdenken .fz-flip > .fz-img.on { animation: fzThink 3s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes fzThink { 50% { transform: rotate(-2.500deg); } }
/* Funken beim Freuen und Staunen */
.fz-fx { position: absolute; inset: 0; pointer-events: none; }
.fz-fx > i {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; background: #ffd45a;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 6px rgba(255, 212, 90, .8)); opacity: 0;
  animation: fzSpark 1.100s ease-out forwards;
}
.fz-fx > i:nth-child(2n) { background: #fff; width: 10px; height: 10px; margin: -5px 0 0 -5px; }
@keyframes fzSpark { 0% { opacity: 0; transform: scale(.2) rotate(0); } 30% { opacity: 1; transform: scale(1.15) rotate(40deg); } 100% { opacity: 0; transform: scale(.6) rotate(90deg) translateY(-8px); } }

/* ------------------------------------------------------------ Konfetti */
.tour-confetti { position: fixed; width: 0; height: 0; pointer-events: none; }
.tour-confetti > i {
  position: absolute; left: 0; top: 0; width: 7px; height: 12px; border-radius: 2px;
  animation: tourConfetti var(--d) cubic-bezier(.15, .7, .4, 1) forwards;
}
.tour-confetti > i.dot { width: 8px; height: 8px; border-radius: 50%; }
@keyframes tourConfetti {
  0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 160px)) rotate(var(--r)) scale(1); opacity: 0; }
}

/* ------------------------------------------------------------ Handy: Blase über die ganze Breite */
@media (max-width: 640px) {
  .tour-card, .tour-card.center { width: calc(100vw - 20px); }
  .tour-inner, .tour-card.center .tour-inner { grid-template-columns: 98px minmax(0, 1fr); gap: 0; }
  .tour-fritz, .tour-card.center .tour-fritz { width: 98px; }
  .tour-card.center .tour-inner { grid-template-columns: 124px minmax(0, 1fr); }
  .tour-card.center .tour-fritz { width: 124px; }
  .tour-bubble { padding: 14px 14px 12px; margin-bottom: 18px; }
  .tour-bubble::before { bottom: 24px; }
  .tour-title { font-size: 17px; }
  .tour-card.center .tour-title { font-size: 19px; }
  .tour-text { font-size: 13.5px; }
  .tour-foot { margin-top: 12px; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .tour-hole, .tour-card { transition: none; }
}
