/* 
 * Gårdsguiden CSS - Clippy-inspirerad guide
 * En modern, minimal men ändå användarvänlig design med rundare bubbla
 */

/* Gårdsguiden – flytande karaktär med animationer */
.guide-container {
    position: fixed;
    bottom: 1.5rem; /* default-läge */
    right: 1.5rem;  /* default-läge */
    z-index: 9999; /* Höjd z-index för att alltid vara ovanpå allt annat */
    display: flex;
    flex-direction: column;
  align-items: flex-end;
    font-family: var(--font-family);
    /* 3D Perspective context */
 perspective: 1000px;
    perspective-origin: 50% 50%;
}

/* === MOBILANPASSNING === */
@media (max-width: 768px) {
    .guide-container {
        /* FAST POSITION i nederkanten på mobil */
  bottom: 1rem !important;
        right: 1rem !important;
    left: auto !important;
        top: auto !important;
     /* Förhindra att användaren flyttar på mobil */
        pointer-events: auto;
    }
    
    /* Mindre storlek på mobil för att inte ta för mycket plats */
    .guide-character {
      width: 3rem !important;
        height: 3rem !important;
    }
    
    /* Pratbubblan anpassas för mobil */
    .guide-bubble {
        /* Alltid visa ovanför på mobil */
        bottom: calc(100% + 10px) !important;
      top: auto !important;
 left: auto !important;
     right: 0 !important;

        /* Mindre bredd på mobil */
        min-width: 240px;
 max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 200px);
    }
    
    /* Ta bort molneffekten på mobil (kan störa) */
    .guide-character::after {
    display: none;
    }
    
    /* Mindre skugga på mobil */
    .guide-container::before {
        display: none;
  }
    
    /* Disable dragging på mobil */
    .guide-character {
        cursor: pointer !important;
        user-select: none;
        -webkit-user-select: none;
  -moz-user-select: none;
        touch-action: none;
    }

    /* Mindre font i bubblan på mobil */
    .guide-message {
        font-size: 0.9rem;
    }
    
    .guide-title {
        font-size: 0.95rem;
    }
    
    .guide-suggestion {
        font-size: 0.85rem;
        padding: 0.65rem 0.85rem;
    }
}

/* Extra small mobiler (iPhone SE etc) */
@media (max-width: 375px) {
    .guide-container {
        bottom: 0.75rem !important;
        right: 0.75rem !important;
 }
    
    .guide-character {
width: 2.75rem !important;
        height: 2.75rem !important;
    }
    
    .guide-bubble {
        min-width: 220px;
        padding: 0.85rem;
    }
}

/* 3D PROJICERAD SKUGGA på underlaget */
.guide-container::before {
 content: "";
  position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
width: 45px;
    height: 8px;
    background: radial-gradient(ellipse at center,
 rgba(0, 0, 0, 0.3) 0%,
 rgba(0, 0, 0, 0.15) 40%,
        transparent 70%);
    border-radius: 50%;
    filter: blur(3px);
    z-index: -2;
    animation: shadowFloat 3s ease-in-out infinite;
}

@keyframes shadowFloat {
  0%, 100% { 
     transform: translateX(-50%) scale(1);
      opacity: 0.4;
    }
    50% { 
  transform: translateX(-50%) scale(0.8);
        opacity: 0.2;
    }
}

.guide-character {
width: 3.5rem;
    height: 3.5rem;
  border-radius: 50%;
    /* 3D GRADIENT - Sfärisk effekt */
    background: radial-gradient(circle at 30% 30%, 
        var(--color-primary-light),
   var(--color-primary) 50%,
        var(--color-primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    /* 3D SHADOW - Flera lager för djup */
    box-shadow: 
        0 2px 4px rgba(0,0,0,.1),
        0 4px 8px rgba(0,0,0,.15),
        0 8px 16px rgba(0,0,0,.2),
inset 0 -2px 4px rgba(0,0,0,.1),
        inset 0 2px 4px rgba(255,255,255,.2);
    transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease;
    position: relative;
    overflow: visible; /* Ändrat från hidden för att visa molnet */
    z-index: 10000;
    /* 3D Transform perspective */
    transform-style: preserve-3d;
    transform: translateZ(0);
}

/* 3D HOVER-effekt */
.guide-character:hover {
    transform: translateZ(10px) scale(1.05);
    box-shadow: 
        0 4px 8px rgba(0,0,0,.12),
        0 8px 16px rgba(0,0,0,.18),
      0 16px 32px rgba(0,0,0,.25),
        inset 0 -2px 6px rgba(0,0,0,.15),
        inset 0 3px 6px rgba(255,255,255,.3);
}

/* LAKITU MOLN-BAS - 3D effekt */
.guide-character::after {
    content: "";
    position: absolute;
    bottom: -12px; /* Under karaktären */
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 20px;
    background: radial-gradient(ellipse at center, 
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.7) 40%,
        rgba(255, 255, 255, 0.3) 70%,
        transparent 100%);
    border-radius: 50%;
    filter: blur(2px);
    z-index: -1;
    opacity: 0.8;
    animation: cloudFloat 3s ease-in-out infinite;
    pointer-events: none; /* Viktigt: molnet ska inte blockera klick */
}

@keyframes cloudFloat {
    0%, 100% { 
        transform: translateX(-50%) scale(1);
opacity: 0.8;
    }
    50% { 
        transform: translateX(-50%) scale(1.1);
opacity: 0.6;
    }
}

/* Face elements */
.guide-face {
    width: 100%;
    height: 100%;
    position: relative;
display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* 3D Transform för ansikte */
 transform-style: preserve-3d;
    transform: translateZ(5px);
}

.guide-eyes {
    display: flex;
  justify-content: space-around;
    width: 65%;
    margin-bottom: 0.2rem;
position: relative;
    top: -2px;
    transform-style: preserve-3d;
}

.guide-eye {
    width: 8px;
 height: 8px;
  /* 3D GRADIENT - Sfäriska ögon */
    background: radial-gradient(circle at 35% 35%,
    #ffffff 0%,
        #f0f0f0 40%,
      #e0e0e0 100%);
    border-radius: 50%;
    position: relative;
    transition: transform 0.1s ease;
    /* 3D Shadow för djup */
    box-shadow: 
     inset 0 -1px 2px rgba(0,0,0,.2),
     0 1px 2px rgba(255,255,255,.5);
    transform: translateZ(8px);
}

/* Pupill - extra 3D-effekt */
.guide-eye::before {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
 background: radial-gradient(circle at 30% 30%,
        #2d3436 0%,
    #000000 100%);
    border-radius: 50%;
    /* FIXAT: Centrera pupillen så hen tittar rakt fram */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 2px rgba(0,0,0,.5);
}

/* Glare/highlight på ögat */
.guide-eye::after {
    content: "";
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    /* FIXAT: Justera highlight position */
    top: 30%;
    left: 35%;
    filter: blur(0.5px);
}

.guide-eye.blinking {
    animation: eyeBlink 0.3s ease;
}

@keyframes eyeBlink {
    0% { transform: scaleY(1) translateZ(8px); }
    50% { transform: scaleY(0.1) translateZ(8px); }
    100% { transform: scaleY(1) translateZ(8px); }
}

.guide-mouth {
    width: 14px;
    height: 6px;
    /* 3D GRADIENT - Djup i munnen */
    background: radial-gradient(ellipse at center top,
        #ffffff 0%,
     #f5f5f5 50%,
        #e8e8e8 100%);
border-radius: 20px;
    margin-top: 2px;
  transition: all 0.3s ease;
    /* 3D Shadow */
    box-shadow: 
        inset 0 1px 2px rgba(0,0,0,.15),
      0 1px 1px rgba(255,255,255,.3);
    transform: translateZ(6px);
    position: relative;
}

/* Inre mun-skugga för djup */
.guide-mouth::before {
 content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center,
        transparent 30%,
        rgba(0,0,0,.05) 100%);
    border-radius: inherit;
  top: 0;
    left: 0;
}

.guide-mouth.talking {
    animation: talking 0.5s infinite alternate;
}

.guide-mouth.thinking {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.guide-mouth.happy {
    width: 16px;
    height: 8px;
    border-radius: 0 0 8px 8px;
    background: radial-gradient(ellipse at center top,
  #ffffff 0%,
        #f5f5f5 50%,
#e8e8e8 100%);
}

.guide-mouth.sad {
    width: 16px;
    height: 8px;
    border-radius: 8px 8px 0 0;
    background: radial-gradient(ellipse at center bottom,
        #ffffff 0%,
  #f5f5f5 50%,
        #e8e8e8 100%);
    transform: translateY(4px) translateZ(6px);
}

@keyframes talking {
    0% { 
  height: 3px; 
        width: 14px;
  transform: translateZ(6px);
    }
    100% { 
  height: 8px; 
   width: 16px;
    transform: translateZ(6px);
    }
}

/* Idle animation - gentle floating */
.guide-character.guide-animate {
    animation: guideFloat3d 3s ease-in-out infinite;
}

@keyframes guideFloat3d {
 0%, 100% { 
        transform: translateY(0px) translateZ(0px) rotateX(0deg);
        box-shadow: 
      0 2px 4px rgba(0,0,0,.1),
            0 4px 8px rgba(0,0,0,.15),
 0 8px 16px rgba(0,0,0,.2);
  }
    25% {
    transform: translateY(-2px) translateZ(5px) rotateX(2deg);
   box-shadow: 
      0 3px 6px rgba(0,0,0,.12),
  0 6px 12px rgba(0,0,0,.17),
         0 10px 20px rgba(0,0,0,.22);
    }
    50% { 
        transform: translateY(-3px) translateZ(8px) rotateX(0deg);
   box-shadow: 
         0 4px 8px rgba(0,0,0,.13),
         0 8px 16px rgba(0,0,0,.18),
      0 12px 24px rgba(0,0,0,.23);
    }
    75% {
 transform: translateY(-2px) translateZ(5px) rotateX(-2deg);
   box-shadow: 
            0 3px 6px rgba(0,0,0,.12),
  0 6px 12px rgba(0,0,0,.17),
       0 10px 20px rgba(0,0,0,.22);
    }
}

/* Pulsering ring */
.guide-character::before {
    content: "";
    position: absolute; 
    inset: -8px; 
 border-radius: 50%;
    /* 3D GRADIENT GLOW */
    background: radial-gradient(circle at center, 
   rgba(74, 138, 78, 0.4) 0%,
      rgba(46, 110, 50, 0.2) 30%,
        transparent 70%);
    opacity: 0; 
    z-index: -1; 
    animation: guidePulse3d 2.5s infinite ease-in-out;
    /* 3D Transform */
    transform-style: preserve-3d;
    filter: blur(4px);
}

@keyframes guidePulse3d { 
    0%, 100% { 
transform: scale(1) translateZ(-10px); 
 opacity: 0;
        filter: blur(4px);
    } 
    50% { 
transform: scale(1.3) translateZ(-5px); 
        opacity: 0.5;
      filter: blur(6px);
    } 
}

/* Extra effekt när meddelande visas */
.guide-character.has-message {
    animation: guideBounce 0.8s ease-out;
}

@keyframes guideBounce {
    0% { transform: translateY(0); }
    25% { transform: translateY(-8px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-4px); }
    100% { transform: translateY(0); }
}

/* Glitter-effekt när tips visas */
.guide-character.showing-tip::after {
    content: "??";
    position: absolute;
    top: -10px;
    right: -5px;
    font-size: 0.8rem;
    animation: sparkle 1.2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 0; transform: rotate(0deg) scale(0.8); }
    50% { opacity: 1; transform: rotate(180deg) scale(1.2); }
}

/* Breathing effect när inaktiv */
.guide-character.idle {
    animation: guideBreathe 4s ease-in-out infinite;
}

@keyframes guideBreathe {
    0%, 100% { transform: scale(1); box-shadow: 0 3px 10px rgba(0,0,0,.2); }
    50% { transform: scale(1.02); box-shadow: 0 4px 15px rgba(0,0,0,.25); }
}

/* Ny rundare pratbubbla med bättre padding */
.guide-bubble {
    position: absolute;
 min-width: 260px; 
    max-width: 300px; 
  max-height: 420px;
    background: #fff; 
    border-radius: 24px; 
    padding: 1rem;
    overflow-y: auto; 
    box-shadow: 0 8px 26px rgba(0,0,0,.15);
    transition: opacity .3s ease, transform .3s ease; 
    will-change: transform, opacity;
    border: 2px solid var(--color-primary-light);
    z-index: 10001;
    /* VIKTIGT: Isolera från parent's 3D transform */
    transform-style: flat;
    transform: translateZ(0);
    opacity: 0;
  transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    pointer-events: none;

    /* IMPROVED: Keep bubble within viewport with better constraints */
    max-width: min(300px, calc(100vw - 80px));
    max-height: min(420px, calc(100vh - 140px));
}

/* Bubble header */
.guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.guide-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-primary);
}

.guide-close {
    background: transparent;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.guide-close:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Bubble message */
.guide-message {
    color: var(--color-text);
  line-height: 1.6;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.guide-message strong {
    color: var(--color-primary);
    font-weight: 600;
}

/* Follow-up prompt */
.guide-follow-up {
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-style: italic;
    margin-bottom: 0.75rem;
}

/* Suggestions */
.guide-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.guide-suggestion {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
  width: 100%;
}

.guide-suggestion:hover {
    background: var(--color-primary-light);
    transform: translateX(4px);
}

.guide-suggestion:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mini contextual tip bubble */
.guide-mini-bubble {
    position: absolute;
  bottom: calc(100% + 15px);
    right: 0;
    background: white;
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--color-text);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 240px;
    cursor: pointer;
    animation: tipSlideIn 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 10000;
}

.guide-mini-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
  border-top: 8px solid white;
    filter: drop-shadow(0 2px 1px rgba(0,0,0,0.1));
}

.guide-mini-bubble.fading {
    animation: tipSlideOut 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

@keyframes tipSlideIn {
    from {
      opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tipSlideOut {
    from {
 opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* Context indicator on character */
.guide-character.has-context-tip::after {
    content: "💡";
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 1.2rem;
    animation: tipPulse 2s ease-in-out infinite;
}

@keyframes tipPulse {
  0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
 50% { 
    transform: scale(1.2);
     opacity: 0.7;
    }
}

/* Reactivate animation for Lakitu */
@keyframes lakituReactivate {
    0% {
transform: translateZ(0);
    }
    50% {
        transform: translateZ(15px) scale(1.1);
 }
    100% {
   transform: translateZ(0);
    }
}

.guide-bubble.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.guide-bubble:not(.hidden) {
    opacity: 1;
  transform: scale(1);
    pointer-events: auto;
}

/* Position: Left of character */
.guide-bubble.left {
  right: calc(100% + 20px);
    left: auto;
}

/* Position: Right of character */
.guide-bubble.right {
    left: calc(100% + 20px);
    right: auto;
}

/* Position: Above character */
.guide-bubble.above {
 bottom: calc(100% + 10px);
    top: auto;
    
    /* Safety: Don't go above viewport */
 max-height: min(420px, calc(100vh - 150px));
}

/* Position: Below character */
.guide-bubble.below {
    top: calc(100% + 10px);
  bottom: auto;

    /* Safety: Don't go below viewport */
    max-height: min(420px, calc(100vh - 150px));
}

/* Bubble tail (arrow pointing to character) */
.guide-bubble::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 10px solid transparent;
}

/* Tail: Above + Left */
.guide-bubble.above.left::before {
  bottom: -10px;
right: 20px;
    border-top-color: #fff;
  border-bottom: none;
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.1));
}

/* Tail: Above + Right */
.guide-bubble.above.right::before {
    bottom: -10px;
    left: 20px;
    border-top-color: #fff;
    border-bottom: none;
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.1));
}

/* Tail: Below + Left */
.guide-bubble.below.left::before {
    top: -10px;
    right: 20px;
  border-bottom-color: #fff;
  border-top: none;
    filter: drop-shadow(0 -3px 2px rgba(0,0,0,0.1));
}

/* Tail: Below + Right */
.guide-bubble.below.right::before {
    top: -10px;
  left: 20px;
    border-bottom-color: #fff;
    border-top: none;
    filter: drop-shadow(0 -3px 2px rgba(0,0,0,0.1));
}
