/* =====================================================================
   buddies.css - the guide dock + first-entry guided tour
   The companions live in a reserved strip just above the bottom nav
   (body.dock-open pads the content to match, so the guide never covers
   the page). One mascot speaks at a time; the bubble carries a speaker
   chip and crossfades between lines. All colours from theme.css.
   ===================================================================== */

#buddies { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
#buddies > * { pointer-events: auto; }

/* soft white zone behind the dock: solid at the bottom, fading upward and
   ending just above the bubble, so the guide gets its own breathing room
   instead of colliding with whatever scrolls behind it */
#buddies .dock-veil {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--nav-height) + var(--dock-h) + 56px);
    display: none;
    pointer-events: none;
    z-index: 60;             /* under the dock (80) and the nav (90) */
    background: linear-gradient(to top,
        var(--paper) 0,
        var(--paper) calc(var(--nav-height) + 20px),
        color-mix(in srgb, var(--paper) 75%, transparent) calc(var(--nav-height) + var(--dock-h) + 8px),
        transparent 100%);
}
body.dock-open #buddies .dock-veil { display: block; }

/* ---- the guide dock ---------------------------------------------- */
.guide-dock {
    position: fixed;
    bottom: calc(var(--nav-height) + 18px);
    left: 50%; transform: translateX(-50%);
    width: calc(100% - 2 * var(--page-pad));
    max-width: calc(var(--content-max) - 2 * var(--page-pad));
    display: flex; align-items: flex-end; gap: 8px;
    z-index: 80;                /* under the nav (90) and every overlay */
}
.guide-dock[hidden] { display: none; }

.gd-sprite {
    flex: none;
    background: none; border: 0; padding: 0; cursor: pointer;
    line-height: 0;
    filter: drop-shadow(0 5px 7px rgba(91,70,54,.25));
    animation: bdyBob var(--bob-dur) ease-in-out infinite;
}
@keyframes bdyBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.gd-bubble {
    position: relative; flex: 1; min-width: 0;
    background: var(--card);
    border: var(--bw) solid var(--frame-ink);
    border-radius: 14px 14px 14px 4px;   /* chat corner toward the sprite */
    box-shadow: var(--pop-shadow);
    padding: 10px 32px 8px 12px;
    cursor: pointer;
    text-align: left;
}
.gd-name {
    position: absolute; top: -9px; left: 10px;
    font-family: var(--pixel-tight); font-weight: 700; font-size: var(--px-xs);
    letter-spacing: .05em; text-transform: uppercase; line-height: 1.25;
    color: #fff; background: var(--accent-deep);
    border: var(--bw) solid var(--frame-ink);
    border-radius: 6px; padding: 2px 8px;
    box-shadow: 0 2px 5px -2px rgba(122,97,73,.3);
    white-space: nowrap;
}
.gd-name--vio  { background: var(--vio-deep); }
.gd-name--mush { background: var(--mush-deep); }
.gd-text {
    margin: 2px 0 0;
    font-family: var(--sans); font-size: var(--text-sm); line-height: 1.4;
    color: var(--ink);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(1.4em * 2);    /* two lines reserved: the dock never resizes */
}
.gd-hide {
    position: absolute; top: 6px; right: 6px;
    width: 22px; height: 22px; border-radius: 50%;
    border: var(--bw) solid var(--line);
    background: var(--paper-2); color: var(--ink-soft);
    font-size: 12px; line-height: 1; cursor: pointer;
    display: grid; place-items: center;
    opacity: .75;
}

/* line/speaker crossfade (JS toggles .swap for 150ms) */
.gd-name, .gd-text, .gd-sprite { transition: opacity .15s ease; }
.guide-dock.swap .gd-name,
.guide-dock.swap .gd-text,
.guide-dock.swap .gd-sprite { opacity: 0; }

/* hidden-state summon tab */
.gd-summon {
    position: fixed;
    bottom: calc(var(--nav-height) + 18px);
    right: var(--page-pad);
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--card);
    border: var(--bw) solid var(--frame-ink);
    box-shadow: var(--pop-shadow);
    cursor: pointer;
    z-index: 80;
}
.gd-summon[hidden] { display: none; }

/* the tour owns the screen; the dock steps aside */
#buddies.touring .guide-dock, #buddies.touring .gd-summon { display: none; }

/* ---- guided tour ------------------------------------------------ */
#buddies.touring { z-index: 115; }

.tour-scrim {
    position: fixed; inset: 0; z-index: 100;   /* sibling of #app-content; blocks page taps */
    pointer-events: auto; background: transparent;
    transition: background var(--ease);
}
.tour-scrim.dim { background: rgba(34,24,18,.5); }
.tour-scrim[hidden] { display: none; }

/* spotlight: a box-shadow hole rings the highlighted element */
.tour-spot {
    position: relative; z-index: 1;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 100vmax rgba(34,24,18,.5), 0 0 0 4px var(--accent), var(--pop-shadow);
    transition: box-shadow var(--ease);
}

.tour-coach {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--nav-height) + 28px);
    width: min(92vw, 380px); z-index: 116;
    pointer-events: auto;
}
.tour-coach[hidden] { display: none; }
/* the coach is a real dialogue box (portrait + name tag + typed text) */
.tour-coach .dlg { animation: dlgIn .25s ease both; }
.tour-coach .dlg-portrait { width: 60px; height: 60px; }
.tour-coach .dlg-panel { box-shadow: 0 18px 40px -12px rgba(34,24,18,.4); }
.tc-text { margin: 0 0 10px; min-height: calc(1.55em * 2); }
.tc-switch { font-size: var(--text-xs); color: var(--ink-soft); margin-bottom: 10px; }
.tc-switch-btn { background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--accent-deep); font: inherit; text-decoration: underline; }
.tc-row { display: flex; align-items: center; gap: 10px; }
.tc-skip { background: none; border: 0; padding: 4px 2px; cursor: pointer;
    font-family: var(--sans); font-size: var(--text-sm); color: var(--ink-soft); }
.tc-dots { margin-left: auto; font-family: var(--pixel-tight); font-weight: 600; font-size: var(--px-xs);
    letter-spacing: .05em; color: var(--ink-mute); }
.tc-next { flex: none; }

/* subtle text button (profile "Show me around" replay) */
.btn-text {
    background: none; border: 0; cursor: pointer; padding: 8px;
    font-family: var(--sans); font-size: var(--text-sm); color: var(--ink-soft);
    text-decoration: underline; text-underline-offset: 2px;
}
.btn-text:hover { color: var(--accent-deep); }

/* ---- reduced motion --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .gd-sprite { animation: none; }
    .gd-name, .gd-text, .gd-sprite { transition: none; }
    .tour-coach .dlg { animation: none; }
}
