/* ============================================================
   Welcome Mascot - Core Styles
   Main container, mascot center, speech bubble, base layout
   ============================================================ */

/* ─── CSS Custom Properties ─── */
:root {
    --mascot-container-size: min(90vw, 600px);
    --mascot-center-size: 40%;
    --mascot-button-radius: 45%;
    --mascot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --mascot-font: 'Poppins', 'Segoe UI', system-ui, sans-serif;
    --mascot-z-base: 100;
    --mascot-z-center: 110;
    --mascot-z-speech: 120;
    --mascot-z-overlay: 200;
    --mascot-primary: #4a90d9;
    --mascot-bg: #ffffff;
    --mascot-text: #333333;
    --mascot-shadow: rgba(0, 0, 0, 0.1);
    --mascot-shadow-hover: rgba(74, 144, 217, 0.3);
}

/* ─── Main Container ─── */
.mascot-container {
    position: relative;
    width: var(--mascot-container-size);
    height: var(--mascot-container-size);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    overflow: visible;
    z-index: var(--mascot-z-base);
    flex-shrink: 0;
}

/* ─── Mascot Center (SVG holder) ─── */
.mascot-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--mascot-center-size);
    height: var(--mascot-center-size);
    z-index: var(--mascot-z-center);
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.mascot-center .mascot-body-svg,
.mascot-center .mascot-head-svg,
.mascot-center .mascot-emotion-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.mascot-center .mascot-head-svg {
    /* Head sits above body — extra negative top for ears */
    width: 55%;
    height: 55%;
    top: -12%;
    left: 22.5%;
    z-index: 2;
    overflow: visible;
}

.mascot-center .mascot-emotion-svg {
    /* Emotion overlays on head */
    width: 55%;
    height: 55%;
    top: -12%;
    left: 22.5%;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: visible;
}

.mascot-center .mascot-emotion-svg.active {
    opacity: 1;
}

/* ─── Speech Bubble ─── */
.speech-bubble {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: 320px;
    min-width: 160px;
    padding: 14px 20px;
    background: var(--mascot-bg);
    border: 2px solid var(--mascot-primary);
    border-radius: 18px;
    font-family: var(--mascot-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--mascot-text);
    box-shadow: 0 4px 20px var(--mascot-shadow);
    z-index: var(--mascot-z-speech);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    text-align: center;
}

.speech-bubble.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Speech bubble position variants */
.speech-bubble[data-position="above"] {
    bottom: calc(50% + var(--mascot-center-size) / 2 + 20px);
    transform: translateX(-50%) translateY(10px);
}

.speech-bubble[data-position="above"].visible {
    transform: translateX(-50%) translateY(0);
}

.speech-bubble[data-position="below"] {
    top: calc(50% + var(--mascot-center-size) / 2 + 20px);
    transform: translateX(-50%) translateY(-10px);
}

.speech-bubble[data-position="below"].visible {
    transform: translateX(-50%) translateY(0);
}

/* Speech bubble tail */
.speech-bubble[data-position="above"]::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid var(--mascot-bg);
}

.speech-bubble[data-position="above"]::before {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid var(--mascot-primary);
}

.speech-bubble[data-position="below"]::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid var(--mascot-bg);
}

.speech-bubble[data-position="below"]::before {
    content: '';
    position: absolute;
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 12px solid var(--mascot-primary);
}

/* ─── Typing cursor animation ─── */
.speech-bubble .typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--mascot-primary);
    margin-left: 2px;
    animation: mascot-blink 0.7s infinite;
    vertical-align: text-bottom;
}

@keyframes mascot-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ─── Audio Toggle Button ─── */
/* Hidden by default to prevent flash — JS shows it after checking config */
.mascot-audio-toggle {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px var(--mascot-shadow);
    cursor: pointer;
    z-index: var(--mascot-z-center);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--mascot-transition);
}

.mascot-audio-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--mascot-shadow-hover);
}

.mascot-audio-toggle.muted {
    opacity: 0.5;
}

/* ─── Loading State ─── */
.mascot-container.loading .mascot-center {
    animation: mascot-pulse 1.5s infinite;
}

@keyframes mascot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ─── Accessibility ─── */
@media (prefers-reduced-motion: reduce) {
    .mascot-container,
    .mascot-container * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* ─── Hidden utility ─── */
.mascot-hidden {
    display: none !important;
}

.mascot-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
