/* Eigene Ebene unter Sprunglink (20) und späteren Dialogen. */
.terrier-mascot {
    --terrier-size: 176px;
    position: fixed;
    right: max(20px, env(safe-area-inset-right, 0px));
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    width: var(--terrier-size);
    height: var(--terrier-size);
    z-index: 6;
    pointer-events: none;
    isolation: isolate;
    contain: layout style;
}

.terrier-mascot__figure,
.terrier-mascot__facing,
.terrier-mascot__sprite,
.terrier-mascot__fallback {
    width: 100%;
    height: 100%;
}

.terrier-mascot__figure { user-select: none; }
.terrier-mascot__facing { transform-origin: 50% 50%; }
.terrier-mascot[data-facing="left"] .terrier-mascot__facing { transform: scaleX(-1); }
.terrier-mascot__sprite { background-repeat: no-repeat; }
.terrier-mascot__fallback { object-fit: contain; }

.terrier-mascot__tooltip {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: 224px;
    max-width: calc(100vw - 32px - env(safe-area-inset-right, 0px));
    padding: 12px 16px;
    border: 1px solid #006eae;
    border-radius: 16px;
    background: #fff;
    color: #006eae;
    box-shadow: 0 4px 16px #0000001f;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    visibility: hidden;
    pointer-events: none;
}

/* Die unsichtbare Brücke hält die Sprechblase beim Überfahren mit der Maus offen. */
.terrier-mascot__tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 12px;
}

.terrier-mascot__tooltip::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: calc(var(--terrier-size) * .4);
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #006eae;
    border-bottom: 1px solid #006eae;
    transform: rotate(45deg);
}

/* Reines Touch-Scrollen darf keinen dauerhaften Hover-Hinweis auslösen. */
@media (hover: hover) and (pointer: fine) {
    .terrier-mascot__figure { pointer-events: auto; }
    .terrier-mascot:not([data-obscured="true"]):not([data-hint-dismissed="true"]):hover .terrier-mascot__tooltip {
        visibility: inherit;
        pointer-events: auto;
    }
}

.terrier-mascot[data-obscured="true"] { visibility: hidden; }
.terrier-mascot [hidden], .terrier-mascot[hidden] { display: none !important; }

/* Auch ohne JavaScript bleiben fokussierte Inhalte frei. */
body:has(input:focus, textarea:focus, select:focus, video:focus, dialog[open]) .terrier-mascot { visibility: hidden; }

@media (max-width: 760px) {
    .terrier-mascot {
        --terrier-size: 112px;
        right: max(8px, env(safe-area-inset-right, 0px));
        bottom: max(8px, env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 359px), (max-height: 420px) {
    .terrier-mascot { --terrier-size: 96px; }
}

@media print {
    .terrier-mascot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .terrier-mascot__sprite { display: none !important; }
    .terrier-mascot .terrier-mascot__fallback { display: block !important; }
}
