/* ==========================================================
   Hi BodyMate — Mate Zone
   ========================================================== */

/* ----------------------------------------------------------
   Zone wrapper
   ---------------------------------------------------------- */
.mate-zone {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
  align-self: start;
}

/* ----------------------------------------------------------
   Character area
   ---------------------------------------------------------- */
.mate-character {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  position: relative;
}

.mate-img-wrapper {
  width: 360px;
  height: 440px;
  flex-shrink: 0;
  transition: transform var(--transition-slow);
}

.mate-img-wrapper.mate-bounce {
  animation: mateBounce 0.5s ease;
}

.mate-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ----------------------------------------------------------
   Speech bubble
   ---------------------------------------------------------- */
.mate-bubble {
  position: relative;
  background-color: var(--color-bg2);
  border: 2px solid var(--color-brand-teal);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  width: 100%;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-normal);
}

/* Tail pointing up toward Mate */
.mate-bubble::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-bottom-color: var(--color-brand-teal);
}

.mate-bubble::after {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--color-bg2);
}

.mate-bubble p {
  font-size: var(--text-sm);
  color: var(--color-h3);
  line-height: 1.6;
  margin: 0;
}

.mate-bubble.is-updating {
  animation: bubblePop 0.35s ease;
}

/* Bubble accent colors per result type */
.mate-bubble.accent-good     { border-color: var(--color-brand-teal); }
.mate-bubble.accent-good::before { border-bottom-color: var(--color-brand-teal); }

.mate-bubble.accent-warning  { border-color: var(--color-brand-orange); }
.mate-bubble.accent-warning::before { border-bottom-color: var(--color-brand-orange); }

.mate-bubble.accent-alert    { border-color: var(--color-brand-pink); }
.mate-bubble.accent-alert::before { border-bottom-color: var(--color-brand-pink); }

/* ----------------------------------------------------------
   Result Slots
   ---------------------------------------------------------- */
.mate-results {
  background-color: var(--color-bg2);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.mate-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.mate-results-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-h4);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0;
}

.results-reset-btn {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-h4);
  background: none;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: var(--radius-full);
  padding: 3px var(--space-3);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
  white-space: nowrap;
}

.results-reset-btn:hover {
  color: #ef4444;
  border-color: #ef4444;
  background-color: #fff1f2;
}

.result-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
}

.result-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2);
  background-color: var(--color-bg1);
  border-radius: var(--radius-md);
  border-top: 3px solid rgba(0,0,0,0.08);
  border-left: none;
  text-align: center;
  min-height: 72px;
  transition: border-color var(--transition-normal), background-color var(--transition-normal);
}

.result-slot.is-done {
  border-top-color: var(--color-brand-teal);
  border-left: none !important;
}

.result-slot.is-done {
  border-top-color: var(--color-brand-teal);
  animation: slotFill 0.4s ease;
}

.slot-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-h4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.slot-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.slot-empty {
  font-size: 9px;
  color: rgba(0,0,0,0.22);
  font-style: italic;
  line-height: 1.3;
}

.slot-value {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-h2);
  display: none;
  line-height: 1;
}

.slot-category {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  display: none;
}

.result-slot.is-done .slot-empty    { display: none; }
.result-slot.is-done .slot-value    { display: block; }
.result-slot.is-done .slot-category { display: inline-block; }

/* ----------------------------------------------------------
   Animations
   ---------------------------------------------------------- */
@keyframes mateBounce {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(-12px); }
  60%  { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}

@keyframes bubblePop {
  0%   { opacity: 0.5; transform: scale(0.97); }
  60%  { transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slotFill {
  from { opacity: 0.4; transform: translateY(6px); }
  to   { opacity: 1;   transform: translateY(0); }
}

@media (max-width: 480px) {
  .result-slots { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 340px) {
  .result-slots { grid-template-columns: repeat(2, 1fr); }
}

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .mate-zone {
    position: static;
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .mate-character { flex: 1; min-width: 220px; }
  .mate-results   { flex: 1; min-width: 220px; }
}

@media (max-width: 640px) {
  .mate-zone { flex-direction: column; }
  .mate-img-wrapper { width: 280px; height: 340px; }
}

/* ----------------------------------------------------------
   Mate Spotlight
   ---------------------------------------------------------- */
#mate-spotlight-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

#mate-spotlight-overlay.is-visible {
  display: block;
  animation: spotlightFadeIn 0.3s ease;
}

@keyframes spotlightFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#spotlight-close {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 160;
  width: 48px;
  height: 48px;
  display: none;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  color: var(--color-h2);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  line-height: 1;
}

#mate-spotlight-overlay.is-visible + * #spotlight-close,
.spotlight-open #spotlight-close {
  display: flex;
}

#spotlight-close:hover {
  background-color: #fee2e2;
  color: #ef4444;
}

/* Elements elevated above overlay */
.spotlight-active {
  position: relative;
  z-index: 155;
}

/* Column container must also be elevated so child z-index is not trapped */
.recent-posts-col.spotlight-active {
  z-index: 155;
}

/* Non-highlighted cards: visually dimmed to blend with the overlay */
.recent-post-card.spotlight-dimmed {
  opacity: 0.18;
  pointer-events: none;
}

/* Highlighted post cards */
.recent-post-card.spotlight-active {
  background: var(--color-bg2);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 3px var(--color-brand-teal), var(--shadow-md);
  animation: spotlightPulse 1.8s ease-in-out infinite alternate;
}

@keyframes spotlightPulse {
  from { box-shadow: 0 0 0 3px var(--color-brand-teal), var(--shadow-md); }
  to   { box-shadow: 0 0 0 7px rgba(0, 173, 145, 0.35), var(--shadow-lg); }
}

/* Links and inline button inside mate bubble (spotlight message) */
#mate-message a {
  color: var(--color-brand-teal);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#mate-message a:hover {
  color: var(--color-h2);
}

/* ----------------------------------------------------------
   Export CTA
   ---------------------------------------------------------- */
.export-cta {
  display: none;
  margin-top: var(--space-4);
  padding: var(--space-5);
  background: linear-gradient(135deg, #f0fdf4 0%, var(--color-input-bg) 100%);
  border-radius: var(--radius-xl);
  border: 1.5px solid rgba(0, 173, 145, 0.2);
}

.export-cta.is-visible {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.export-cta-text {
  flex: 1;
}

.export-cta-text h3 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-h2);
  margin-bottom: var(--space-1);
}

.export-cta-text p {
  font-size: var(--text-xs);
  color: var(--color-h3);
  line-height: 1.5;
}

.export-cta-btn {
  flex-shrink: 0;
  background-color: var(--color-brand-teal);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  white-space: nowrap;
}

.export-cta-btn:hover {
  opacity: 0.88;
}
