/* ==========================================================================
   Visuell Roman & Escape Room Motor - Stilark og Animasjoner
   ========================================================================== */

/* Subtilt filmisk teksturoverlay */
body::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.04"/></svg>');
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: overlay;
}

/* --------------------------------------------------------------------------
   Skjermeffekter (Risting, Blits/Gassalarm)
   -------------------------------------------------------------------------- */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-8px, -6px) rotate(-0.4deg); }
    30% { transform: translate(7px, 5px) rotate(0.4deg); }
    45% { transform: translate(-6px, 4px); }
    60% { transform: translate(5px, -4px); }
    75% { transform: translate(-3px, 2px); }
    90% { transform: translate(2px, -1px); }
}
body.effect-shake #parallax-container,
body.effect-shake {
    animation: screenShake 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes screenFlash {
    0% { filter: brightness(2.8) contrast(1.4); }
    25% { filter: brightness(1.9) hue-rotate(50deg); }
    100% { filter: none; }
}
body.effect-flash {
    animation: screenFlash 0.85s ease-out both;
}

/* --------------------------------------------------------------------------
   Parallax Bakgrunn & Hotspots (Point & Click soner)
   -------------------------------------------------------------------------- */
#parallax-container {
    perspective: 1000px;
    background-color: #080808;
}

.parallax-layer {
    transition: transform 0.12s ease-out;
    width: 110%;
    height: 110%;
    left: -5%;
    top: -5%;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

/* Klikkbare soner på bakgrunnsbildet */
.bg-hotspot {
    position: absolute;
    cursor: pointer;
    border: 2px dashed rgba(239, 68, 68, 0.4);
    background-color: rgba(239, 68, 68, 0.08);
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 30;
}

.bg-hotspot:hover {
    border-color: rgba(255, 255, 255, 0.9);
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.03);
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.6);
}

.bg-hotspot-label {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bg-hotspot:hover .bg-hotspot-label {
    opacity: 1;
}

@keyframes hotspotPulse {
    0%, 100% { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
    50% { border-color: rgba(239, 68, 68, 0.8); box-shadow: 0 0 15px rgba(239, 68, 68, 0.3); }
}
.hotspot-pulse {
    animation: hotspotPulse 2.2s infinite ease-in-out;
}

/* --------------------------------------------------------------------------
   Karakter-sprites & Animasjoner
   -------------------------------------------------------------------------- */
.char-enter-left {
    transform: translateX(-140%);
    opacity: 0;
}

.char-enter-right {
    transform: translateX(140%);
    opacity: 0;
}

.char-active {
    transform: translateX(0);
    opacity: 1;
}

.char-exit-left {
    transform: translateX(-140%) !important;
    opacity: 0 !important;
}

.char-exit-right {
    transform: translateX(140%) !important;
    opacity: 0 !important;
}

/* Idle & Flytende Animasjoner */
@keyframes breathing {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.006); }
}
.char-breathing {
    animation: breathing 3.8s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes charFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-7px) rotate(0.4deg); }
    66% { transform: translateY(-3px) rotate(-0.4deg); }
}
.char-float {
    animation: charFloat 4.2s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes sway {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(0.6deg) translateY(-2px); }
}
.char-sway {
    animation: sway 4.5s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
    60% { transform: translateY(0); }
}
.char-bounce {
    animation: bounce 0.6s ease-out;
    transform-origin: bottom center;
}

/* Følelsesreaksjoner (Sinne, Risting, Nikk) */
@keyframes angrySnap {
    0% { transform: scale(1) translateY(0) rotate(0deg); }
    12% { transform: scale(1.05) translateY(-18px) rotate(-2deg); filter: brightness(1.1); }
    25% { transform: scale(1.09) translateY(8px) rotate(2.5deg); filter: brightness(1.15) contrast(1.05); }
    38% { transform: scale(1.06) translateY(-8px) rotate(-2deg); }
    52% { transform: scale(1.03) translateY(4px) rotate(1deg); }
    68% { transform: scale(1.01) translateY(-3px) rotate(-0.5deg); }
    84% { transform: scale(1.005) translateY(1px) rotate(0.2deg); }
    100% { transform: scale(1) translateY(0) rotate(0deg); filter: none; }
}
.char-angry {
    animation: angrySnap 0.85s cubic-bezier(0.25, 1, 0.5, 1) both;
    transform-origin: bottom center;
}

@keyframes trembleEffect {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, -1px); }
    20% { transform: translate(2px, 1px); }
    30% { transform: translate(-2px, 2px); }
    40% { transform: translate(2px, -1px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(2px, -2px); }
    70% { transform: translate(-2px, -1px); }
    80% { transform: translate(1px, 2px); }
    90% { transform: translate(-2px, 1px); }
}
.char-tremble {
    animation: trembleEffect 0.14s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes nodEffect {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    35% { transform: translateY(10px) rotate(-1deg); }
    65% { transform: translateY(-4px) rotate(0.5deg); }
    85% { transform: translateY(2px) rotate(0deg); }
}
.char-nod {
    animation: nodEffect 0.8s ease-out both;
    transform-origin: bottom center;
}

.white-outline {
    filter: drop-shadow(0px 0px 5px rgba(255, 255, 255, 0.5));
}

/* --------------------------------------------------------------------------
   Skjerm- og VFX-effekter
   -------------------------------------------------------------------------- */
@keyframes screenShake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-2px, -3px) rotate(-1deg); }
    20% { transform: translate(-4px, 0px) rotate(1deg); }
    30% { transform: translate(4px, 3px) rotate(0deg); }
    40% { transform: translate(2px, -1px) rotate(1deg); }
    50% { transform: translate(-2px, 3px) rotate(-1deg); }
    60% { transform: translate(-4px, 1px) rotate(0deg); }
    70% { transform: translate(4px, 1px) rotate(-1deg); }
    80% { transform: translate(-2px, -2px) rotate(1deg); }
    90% { transform: translate(2px, 3px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(0deg); }
}
.effect-shake {
    animation: screenShake 0.45s ease-in-out 2;
}

@keyframes drunkWobble {
    0% { filter: blur(0px) contrast(1); transform: rotate(0deg) scale(1); }
    25% { filter: blur(2px) contrast(1.15) saturate(1.3); transform: rotate(0.8deg) scale(1.02); }
    50% { filter: blur(1px) contrast(0.9); transform: rotate(-0.8deg) scale(1.01); }
    75% { filter: blur(3px) contrast(1.2); transform: rotate(0.4deg) scale(1.03); }
    100% { filter: blur(0px) contrast(1); transform: rotate(0deg) scale(1); }
}
.effect-drunk {
    animation: drunkWobble 6s ease-in-out infinite;
}

@keyframes glitchAnim {
    0% { transform: translate(0); }
    20% { transform: translate(-3px, 3px); filter: invert(0.15) hue-rotate(90deg); }
    40% { transform: translate(-2px, -2px); filter: none; }
    60% { transform: translate(3px, 2px); filter: contrast(1.4); }
    80% { transform: translate(2px, -3px); filter: none; }
    100% { transform: translate(0); }
}
.effect-glitch {
    animation: glitchAnim 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2;
}

/* --------------------------------------------------------------------------
   Dialogboks og Valgknapper
   -------------------------------------------------------------------------- */
#dialog-box {
    border-top: 3px solid rgba(220, 38, 38, 0.8);
    transition: all 0.3s ease;
}

.speech-bubble-tail::before {
    content: '';
    position: absolute;
    bottom: 25px;
    left: -12px;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 12px solid rgba(24, 24, 27, 0.9);
}

@media (max-width: 768px) {
    .speech-bubble-tail::before {
        display: none;
    }
}

.choice-btn {
    background: linear-gradient(135deg, rgba(30, 30, 34, 0.92), rgba(18, 18, 20, 0.96));
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-left: 5px solid #dc2626;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

.choice-btn:hover:not(.locked) {
    background: linear-gradient(135deg, rgba(45, 45, 52, 0.96), rgba(28, 28, 32, 0.98));
    border-left: 5px solid #ef4444;
    border-color: rgba(156, 163, 175, 0.6);
    transform: translateX(-8px);
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.25);
}

.choice-btn:active:not(.locked) {
    transform: translateX(-4px) scale(0.99);
}

.choice-btn.locked {
    opacity: 0.55;
    cursor: not-allowed;
    border-left: 5px solid #52525b;
    background: rgba(24, 24, 27, 0.8);
}
.choice-btn.locked:hover {
    border-color: rgba(239, 68, 68, 0.5);
}

.continue-btn {
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.95), rgba(127, 29, 29, 0.98));
    border: 1px solid rgba(252, 211, 77, 0.6);
    border-left: 6px solid #fbbf24;
    box-shadow: 0 10px 25px rgba(185, 28, 28, 0.45), 0 0 15px rgba(251, 191, 36, 0.2);
    transition: all 0.2s ease;
    cursor: pointer;
}

.continue-btn:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 1), rgba(153, 27, 27, 1));
    border-color: #fbbf24;
    border-left: 6px solid #fff;
    transform: translateX(-6px) scale(1.02);
    box-shadow: 0 12px 30px rgba(220, 38, 38, 0.6), 0 0 20px rgba(251, 191, 36, 0.4);
}

@keyframes choiceHighlightPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(251, 191, 36, 0); }
    50% { transform: scale(1.04) translateX(-6px); box-shadow: 0 0 25px rgba(251, 191, 36, 0.8); border-color: #fbbf24; }
}
.choice-highlight-pulse {
    animation: choiceHighlightPulse 0.4s ease-in-out 2;
}

@keyframes hotspotFlash {
    0%, 100% { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
    50% { border-color: #fbbf24; box-shadow: 0 0 30px rgba(251, 191, 36, 0.9); background-color: rgba(251, 191, 36, 0.25); }
}
.hotspot-flash {
    animation: hotspotFlash 0.5s ease-in-out 2;
}

.btn-toggle-active {
    background-color: rgba(220, 38, 38, 0.4) !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.5) !important;
}

@keyframes timerPulse {
    0%, 100% { color: #ef4444; transform: scale(1); }
    50% { color: #ff8888; transform: scale(1.08); }
}
.timer-urgent {
    animation: timerPulse 1s infinite ease-in-out;
    border-color: #ef4444 !important;
}

/* Utskrifts-stil for seiersdiplom */
@media print {
    body * {
        visibility: hidden;
    }
    #victory-modal, #victory-modal * {
        visibility: visible;
    }
    #victory-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white !important;
        color: black !important;
    }
}
