/* ── Mascot Greeting Overlay ────────────────────────── */
/* Horse image: english-quiz-app/ngua_2026.webp */
/* Dark class: body.dark */

/* ── Tokens ─────────────────────────────────────────── */
:root {
  --mc-overlay:    rgba(6, 8, 20, 0.88);
  --mc-bubble-bg:  #FFFFFF;
  --mc-bubble-txt: #0F172A;
  --mc-bubble-sub: #64748B;
  --mc-accent:     #F59E0B;
  --mc-btn-bg:     #F8FAFF;
}
body.dark {
  --mc-bubble-bg:  #1E2235;
  --mc-bubble-txt: #F1F5F9;
  --mc-bubble-sub: #94A3B8;
  --mc-btn-bg:     #252840;
}

/* ── Overlay ─────────────────────────────────────────── */
.mascot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--mc-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 2rem;
  animation: mcFadeIn 0.3s ease;
}
.mascot-overlay.mascot-hidden { display: none; }
.mascot-overlay.mascot-hiding {
  animation: mcFadeOut 0.35s ease forwards;
  pointer-events: none;
}

/* ── Stage: horse + bubble side by side at bottom ───── */
.mascot-stage {
  display: flex;
  align-items: flex-end;
  gap: 2.5rem;
  max-width: 980px;
  width: 100%;
}

/* ── Speech bubble ───────────────────────────────────── */
.mascot-bubble {
  flex: 1;
  position: relative;
  margin-bottom: 5.5rem;
  margin-right: 28px;
  filter: drop-shadow(0 8px 28px rgba(0,0,0,0.35));
  animation: mcBubbleIn 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) 0.45s both;
  overflow: visible;
}

/* Rounded rectangle body */
.bubble-body {
  background: var(--mc-bubble-bg);
  border-radius: 1.5rem;
}

/* Tail → pointing right toward horse */
.bubble-tail {
  position: absolute;
  right: -28px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-left: 28px solid var(--mc-bubble-bg);
}

.bubble-inner {
  padding: 2.25rem 2.25rem 2rem;
}

.mascot-greeting {
  font-size: 1.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mc-accent);
  margin-bottom: 0.35rem;
}

.mascot-question {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--mc-bubble-txt);
  line-height: 1.25;
  text-wrap: balance;
  margin-bottom: 1.25rem;
}

/* ── Language buttons ────────────────────────────────── */
.mascot-langs {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: mcBtnsIn 0.4s ease 0.8s both;
}

/* Per-language accent colors */
.mascot-lang[data-lang="en"] { --lang-accent: #3B82F6; --lang-bg: #EFF6FF; }
.mascot-lang[data-lang="zh"] { --lang-accent: #EF4444; --lang-bg: #FEF2F2; }
.mascot-lang[data-lang="ko"] { --lang-accent: #8B5CF6; --lang-bg: #F5F3FF; }
body.dark .mascot-lang[data-lang="en"] { --lang-bg: rgba(59,130,246,0.13); }
body.dark .mascot-lang[data-lang="zh"] { --lang-bg: rgba(239,68,68,0.13); }
body.dark .mascot-lang[data-lang="ko"] { --lang-bg: rgba(139,92,246,0.13); }

.mascot-lang {
  display: grid;
  grid-template-columns: 48px 1fr 20px;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 0.9rem 0.85rem 0.85rem;
  border-radius: 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: var(--lang-bg, var(--mc-btn-bg));
  border: 1.5px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.mascot-lang:hover {
  border-color: var(--lang-accent, var(--mc-accent));
  transform: translateX(4px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.1);
}
.mascot-lang:active { transform: translateX(4px) scale(0.99); }

/* Chevron — grid column 3 */
.mascot-lang::after {
  content: '›';
  font-size: 1.5rem;
  line-height: 1;
  color: var(--lang-accent, #94A3B8);
  opacity: 0.4;
  justify-self: center;
  transition: opacity 0.15s, transform 0.15s;
}
.mascot-lang:hover::after { opacity: 1; transform: translateX(3px); }

/* Flag badge — colored circle with inline SVG flag */
.mascot-lang-flag {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--lang-accent, var(--mc-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.mascot-lang-flag svg {
  display: block;
  width: 38px;
  height: 25px;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.mascot-lang-info { display: flex; flex-direction: column; }
.mascot-lang-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--mc-bubble-txt);
}
.mascot-lang-sub {
  font-size: 0.72rem;
  color: var(--mc-bubble-sub);
  margin-top: 0.1rem;
}

/* ── Horse image ─────────────────────────────────────── */
.mascot-horse {
  flex-shrink: 0;
  width: 400px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: mcHorseUp 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

.mascot-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.5));
}

/* Fallback khi chưa có file ảnh */
.mascot-fallback {
  display: none;
  font-size: 110px;
  line-height: 1;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.4));
  text-align: center;
  padding-bottom: 0.25rem;
}
.mascot-img[data-failed="1"] { display: none; }
.mascot-img[data-failed="1"] ~ .mascot-fallback { display: block; }

/* ── Animations ──────────────────────────────────────── */
@keyframes mcFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes mcFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes mcHorseUp {
  from { transform: translateY(80px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes mcBubbleIn {
  from { transform: translateX(-30px) scale(0.92); opacity: 0; }
  to   { transform: translateX(0)     scale(1);    opacity: 1; }
}
@keyframes mcBtnsIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 620px) {
  .mascot-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .mascot-stage {
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 100%;
  }

  /* Mobile: bubble trên, ngựa dưới */
  .mascot-bubble {
    order: 1;
    margin: 0 0.75rem;
    width: calc(100% - 1.5rem);
    margin-bottom: 0;
    margin-right: 0.75rem; /* reset desktop margin */
  }

  /* Mobile tail: chỉ xuống → phía ngựa */
  .bubble-tail {
    right: auto;
    top: auto;
    left: 50%;
    bottom: -24px;
    transform: translateX(-50%);
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-top: 24px solid var(--mc-bubble-bg);
    border-bottom: none;
  }

  .mascot-horse {
    order: 2;
    width: 255px;
    animation: mcHorseUp 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
  }

  .mascot-question { font-size: 1.25rem; }

  .mascot-langs { flex-direction: row; flex-wrap: wrap; gap: 0.45rem; }

  .mascot-lang {
    flex: 1;
    min-width: 0;
    grid-template-columns: auto;
    grid-template-rows: auto auto;
    justify-items: center;
    gap: 0.35rem;
    padding: 0.7rem 0.4rem;
  }
  .mascot-lang::after { display: none; }
  .mascot-lang:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.12); }
  .mascot-lang-flag { width: 38px; height: 38px; font-size: 1.2rem; }
  .mascot-lang-info { text-align: center; }
  .mascot-lang-name { font-size: 0.8rem; }
  .mascot-lang-sub  { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mascot-overlay,
  .mascot-bubble,
  .mascot-horse,
  .mascot-langs { animation: none; opacity: 1; transform: none; }
}
