/* Design System Tokens */
:root {
    /* Day Theme Palette */
    --color-bg-start: #dbeafe;
    --color-bg-end: #f3f4f6;
    --color-text: #1f2937;
    --color-text-muted: #4b5563;
    
    --color-badge-bg: rgba(59, 130, 246, 0.1);
    --color-badge-text: #2563eb;
    
    /* Landscape Colors - Day */
    --color-sky-bg: linear-gradient(to bottom, #93c5fd 0%, #dbeafe 60%, #eff6ff 100%);
    --color-mountain-back: #a0aec0;
    --color-mountain-front: #718096;
    --color-hill-back: #48bb78;
    --color-hill-mid: #38a169;
    --color-grass-top: #34d399;
    --color-grass-bottom: #059669;
    
    --color-river: #38bdf8;
    --color-path-start: #fbbf24;
    --color-path-end: #fef08a;
    
    /* Cottage Colors - Day */
    --color-house-walls: #f3f4f6;
    --color-house-walls-dark: #cbd5e1;
    --color-house-roof: #ef4444;
    --color-house-roof-light: #f87171;
    --color-house-roof-dark: #b91c1c;
    --color-door: #b45309;
    --color-window-frame: #475569;
    --color-window-glow: #fef08a;
    
    /* Cloud Fill */
    --color-cloud: rgba(255, 255, 255, 0.85);

    /* UI Elements */
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: rgba(31, 38, 135, 0.08);
    
    --btn-primary-bg: #2563eb;
    --btn-primary-hover: #1d4ed8;
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: rgba(255, 255, 255, 0.6);
    --btn-secondary-hover: rgba(255, 255, 255, 0.8);
    --btn-secondary-text: #1f2937;
}

/* Dark Theme Palette Override */
body.dark-theme {
    --color-bg-start: #070a13;
    --color-bg-end: #0f172a;
    --color-text: #f8fafc;
    --color-text-muted: #94a3b8;
    
    --color-badge-bg: rgba(139, 92, 246, 0.15);
    --color-badge-text: #a78bfa;
    
    /* Landscape Colors - Dark */
    --color-sky-bg: linear-gradient(to bottom, #020617 0%, #070a13 50%, #0f172a 100%);
    --color-mountain-back: #0f172a;
    --color-mountain-front: #1e1b4b;
    --color-hill-back: #115e59;
    --color-hill-mid: #0f766e;
    --color-grass-top: #064e3b;
    --color-grass-bottom: #022c22;
    
    --color-river: #06b6d4;
    --color-path-start: #701a75;
    --color-path-end: #a21caf;
    
    /* Cottage Colors - Dark */
    --color-house-walls: #312e81;
    --color-house-walls-dark: #1e1b4b;
    --color-house-roof: #581c87;
    --color-house-roof-light: #7c3aed;
    --color-house-roof-dark: #3b0764;
    --color-door: #0f172a;
    --color-window-frame: #334155;
    --color-window-glow: #f59e0b;
    
    /* Cloud Fill */
    --color-cloud: rgba(30, 41, 59, 0.6);

    /* UI Elements */
    --glass-bg: rgba(15, 23, 42, 0.45);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: rgba(0, 0, 0, 0.3);
    
    --btn-primary-bg: #7c3aed;
    --btn-primary-hover: #6d28d9;
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: rgba(30, 41, 59, 0.6);
    --btn-secondary-hover: rgba(30, 41, 59, 0.85);
    --btn-secondary-text: #f8fafc;
}

/* Reset and Layout */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--color-text);
    background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
    min-height: 100vh;
    overflow: hidden; /* Prevent default scrolling */
    position: relative;
    transition: background 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-container {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    z-index: 10;
    position: relative;
}

/* Day/Night Stars Sky Overlays */
.stars-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background-image: 
        radial-gradient(1.5px 1.5px at 20px 30px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 160px 120px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 260px 80px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 310px 170px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 450px 60px, #fff, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 580px 150px, #fff, rgba(0,0,0,0)),
        radial-gradient(2.5px 2.5px at 700px 90px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 820px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 950px 140px, #fff, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 1080px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 1200px 190px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 1320px 110px, #fff, rgba(0,0,0,0));
    background-repeat: repeat;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
    z-index: 1;
}

body.dark-theme .stars-overlay {
    opacity: 0.35;
}

/* Shooting Stars */
.shooting-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.shooting-star {
    position: absolute;
    left: var(--star-left);
    top: var(--star-top);
    width: 100px;
    height: 2px;
    background: linear-gradient(to right, #5b53ff, rgba(0, 0, 255, 0));
    filter: drop-shadow(0 0 6px #695cfb);
    animation: tail 3s ease-in-out infinite, shooting 3s ease-in-out infinite;
}

@keyframes tail {
    0% { width: 0; }
    30% { width: 100px; }
    100% { width: 0; }
}

@keyframes shooting {
    0% { transform: translate(0, 0) rotate(-45deg); }
    100% { transform: translate(-300px, 300px) rotate(-45deg); }
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 30px;
    right: 30px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    z-index: 100;
    transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle .moon-icon {
    display: none;
}

body.dark-theme .theme-toggle .sun-icon {
    display: none;
}

body.dark-theme .theme-toggle .moon-icon {
    display: block;
    color: #e9d5ff;
}

/* Header Content Styling */
.error-header {
    text-align: center;
    max-width: 650px;
    margin: 5vh auto 0 auto;
    padding: 24px;
    z-index: 50;
    position: relative;
    pointer-events: auto; /* Allow interaction with buttons */
}

.badge {
    display: inline-block;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    background: var(--color-badge-bg);
    color: var(--color-badge-text);
    margin-bottom: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    animation: fadeInDown 0.6s ease;
}

.headline {
    font-family: 'Outfit', sans-serif;
    font-size: 3rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.15;
    margin-bottom: 16px;
    letter-spacing: -1px;
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.description {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--color-text-muted);
    margin-bottom: 30px;
    animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Glassmorphic Call-to-Actions */
.cta-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    animation: fadeInUp 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 12px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    border-color: var(--glass-border);
    color: var(--btn-secondary-text);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.btn-secondary:hover {
    background: var(--btn-secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 36px 0 var(--glass-shadow);
}

.btn:active {
    transform: translateY(1px);
}

/* ================================================================= */
/* PARALLAX VIEWPORT & LANDSCAPE LAYERS */
/* ================================================================= */

.parallax-viewport {
    position: relative;
    width: 100%;
    height: 48vh;
    min-height: 320px;
    overflow: hidden;
    margin-top: auto;
    z-index: 5;
    pointer-events: none; /* Let clicks pass to container, handle target hitboxes in JS/CSS */
}

.parallax-layer {
    position: absolute;
    bottom: -10px;
    left: -5%;
    width: 110%;
    height: 105%;
    will-change: transform;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Layer factors via inline-styles in HTML or JS dynamically */
.layer-sky {
    z-index: 10;
}

.layer-mountains {
    z-index: 20;
}

.layer-midground {
    z-index: 30;
}

.layer-foreground {
    z-index: 40;
    pointer-events: auto; /* Activate interactions in foreground */
}

/* SVG scaling to fit viewport */
.landscape-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Layer Colors & Transitions */
.sky-elements {
    width: 100%;
    height: 100%;
    background: var(--color-sky-bg);
    position: relative;
    transition: background 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.celestial-body {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    top: 15%;
    left: 20%;
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Day: Sun */
body:not(.dark-theme) .celestial-body {
    background: radial-gradient(circle, #fef08a 0%, #f59e0b 60%, #d97706 100%);
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.4), 0 0 80px rgba(245, 158, 11, 0.2);
    transform: translateY(0);
}

/* Night: Moon */
body.dark-theme .celestial-body {
    background: radial-gradient(circle, #f8fafc 0%, #e2e8f0 70%, #cbd5e1 100%);
    box-shadow: 0 0 20px rgba(248, 250, 252, 0.3), 0 0 40px rgba(248, 250, 252, 0.1);
    transform: translateY(20px);
}

/* Clouds styling */
.cloud {
    position: absolute;
    color: var(--color-cloud);
    transition: color 0.8s ease;
}

.cloud-a {
    top: 25%;
    left: 10%;
    animation: floatCloud 45s linear infinite;
}

.cloud-b {
    top: 15%;
    right: 15%;
    animation: floatCloud 60s linear infinite reverse;
}

@keyframes floatCloud {
    0% { transform: translateX(-10%); }
    50% { transform: translateX(30%); }
    100% { transform: translateX(-10%); }
}

/* Landscape elements color mapping */
.mountain-back {
    fill: var(--color-mountain-back);
    transition: fill 0.8s ease;
}

.mountain-front {
    fill: var(--color-mountain-front);
    transition: fill 0.8s ease;
}

.hill-back {
    fill: var(--color-hill-back);
    transition: fill 0.8s ease;
}

.network-river {
    fill: var(--color-river);
    transition: fill 0.8s ease;
}

.hill-front {
    transition: fill 0.8s ease;
}

.ethernet-path {
    transition: fill 0.8s ease;
}

/* ================================================================= */
/* MASCOT / ANIMAL INTERACTIVE STYLING */
/* ================================================================= */

.character-container {
    position: absolute;
    cursor: pointer;
    pointer-events: auto;
    z-index: 100;
}

.char-svg {
    display: block;
    overflow: visible;
}

/* 1. Labot Mascot Animations */
.labot-wrapper {
    transition: transform 0.2s ease;
}

.labot-wrapper:hover {
    transform: scale(1.05) translateY(-5px);
}

.labot-head {
    transform-origin: 30px 36px;
    transition: transform 0.3s ease;
}

.labot-wrapper:hover .labot-head {
    animation: headWiggle 1.5s ease-in-out infinite;
}

.labot-arm-left {
    transform-origin: 15px 32px;
}

.labot-arm-right {
    transform-origin: 45px 32px;
}

.labot-wrapper:hover .labot-arm-left {
    animation: armWaveLeft 1s ease-in-out infinite alternate;
}

.labot-wrapper:hover .labot-arm-right {
    animation: armWaveRight 1s ease-in-out infinite alternate;
}

/* Special Interactive states (applied by JS) */
.labot-jump {
    animation: bounceEffect 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.labot-dizzy .labot-head {
    animation: dizzySpin 0.5s ease-in-out infinite;
}

/* Speech bubble for Labot */
.speech-bubble {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--color-text);
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 200;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--glass-bg) transparent transparent transparent;
}

.labot-wrapper:hover .speech-bubble,
.labot-wrapper.active .speech-bubble {
    transform: translateX(-50%) scale(1);
}

/* 2. Pig Flip Animations */
.pig-wrapper {
    transition: transform 0.2s ease;
    transform-origin: 25px 20px;
}

.pig-wrapper:hover {
    transform: scale(1.05);
}

.pig-head {
    transform-origin: 18px 18px;
}

.pig-wrapper:hover .pig-head {
    animation: headNod 1s ease-in-out infinite alternate;
}

.pig-flip {
    animation: flipEffect 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* 3. Chicken peck Animations */
.chicken-wrapper {
    transition: transform 0.2s ease;
    transform-origin: 17.5px 25px;
}

.chicken-wrapper:hover {
    transform: scale(1.08);
}

.chicken-head-group {
    transform-origin: 18px 18px;
    transition: transform 0.2s ease;
}

.chicken-peck {
    animation: peckEffect 0.5s ease-in-out forwards;
}

/* Keyframe animations for characters */
@keyframes headWiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

@keyframes armWaveLeft {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-25deg); }
}

@keyframes armWaveRight {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(25deg); }
}

@keyframes headNod {
    0% { transform: translateY(0); }
    100% { transform: translateY(2px); }
}

@keyframes bounceEffect {
    0%, 100% { transform: scale(1) translateY(0); }
    40% { transform: scale(0.9, 1.1) translateY(-25px); }
    70% { transform: scale(1.05, 0.95) translateY(2px); }
}

@keyframes dizzySpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes flipEffect {
    0% { transform: scale(1) translateY(0) rotate(0deg); }
    40% { transform: scale(0.8, 1.2) translateY(-40px) rotate(-180deg); }
    80% { transform: scale(1.1, 0.9) translateY(0) rotate(-360deg); }
    100% { transform: scale(1) translateY(0) rotate(-360deg); }
}

@keyframes peckEffect {
    0% { transform: rotate(0); }
    30% { transform: rotate(40deg) translateY(2px); }
    60% { transform: rotate(-10deg); }
    100% { transform: rotate(0); }
}

/* ================================================================= */
/* STATUS LED & ACTIVE COMPONENT SHINES */
/* ================================================================= */

.led {
    transition: filter 0.3s ease;
}

.blink-fast {
    animation: ledBlink 0.4s infinite alternate;
}

.blink-normal {
    animation: ledBlink 0.8s infinite alternate;
}

.blink-slow {
    animation: ledBlink 1.4s infinite alternate;
}

@keyframes ledBlink {
    0% { opacity: 0.3; filter: brightness(0.6) drop-shadow(0 0 1px currentColor); }
    100% { opacity: 1; filter: brightness(1.2) drop-shadow(0 0 3px currentColor); }
}

/* Cottage window glowing effect */
.house-window {
    transition: fill 0.8s ease;
}

body.dark-theme .house-window {
    filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.6));
}

/* Embedded Server Vines Wind animation */
.vine-cable {
    transform-origin: bottom center;
    animation: windSway 6s ease-in-out infinite alternate;
}

@keyframes windSway {
    0% { transform: rotate(-1deg); }
    100% { transform: rotate(1deg); }
}

/* Chimney Smoke Ring elements styling */
.smoke-ring {
    position: absolute;
    width: 8px;
    height: 6px;
    background: rgba(200, 200, 200, 0.4);
    border-radius: 50%;
    pointer-events: none;
    z-index: 39;
    will-change: transform, opacity;
    animation: floatSmoke 3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

body.dark-theme .smoke-ring {
    background: rgba(229, 231, 235, 0.2);
}

@keyframes floatSmoke {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-40px, -90px) scale(3.5);
        opacity: 0;
    }
}

/* Standard Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .headline {
        font-size: 2.2rem;
    }
    .description {
        font-size: 0.95rem;
    }
    .theme-toggle {
        top: 20px;
        right: 20px;
    }
    .celestial-body {
        width: 60px;
        height: 60px;
    }
    .server-vine-rack {
        transform: translate(820px, 190);
    }
    .rack-mound {
        cx: 855px;
    }
}
