/* Variables */
:root {
    --primary: #004b74;
    --secondary: #d01c1c;
    --accent: #ffd800;
    --text: #333;
    --background: #f5f3f0;
    --footer-text: #666;
    --star-color: #f5f3f0;
}

/* Night Mode Variables */
body.night-mode {
    --text: #e0e0e0;
    --background: #252a34;
    --footer-text: #999;
    --primary: #4a90e2;
    --secondary: #e74c3c;
    --star-color: rgba(255, 255, 255, 0.4);
}

/* Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--background);
    padding: 2em 1.5em;
    position: relative;
}


/* Header */
header {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 1rem;
    position: relative;
    padding-top: 1em;
}

.logo {
    max-width: 140px;
    height: auto;
    margin-bottom: 0rem;
    transition: transform 1.618s ease-in-out;
    cursor: pointer;
    z-index: 30;
}

.logo.rotate-y {
    transform: rotateY(360deg);
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--secondary);
    cursor: pointer;
    z-index: 30;
}

#language-selector {
    margin-top: 0;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    z-index: 10;
}

.flag {
    font-size: 1.2em;
    cursor: pointer;
    padding: 2px;
    opacity: 0.6;
    transition: opacity 0.3s;
    z-index: 10;
}

.flag.active {
    opacity: 1;
}

/* Night Mode Toggle */
.night-mode-switch {
    position: absolute;
    top: -20px;
    left: -5px;
    display: flex;
    align-items: center;
    cursor: pointer;
    z-index: 10;
}

.night-mode-switch input {
    display: none;
}

.night-mode-switch .slider {
    width: 30px;
    height: 16px;
    background-color: #ccc;
    border-radius: 8px;
    position: relative;
    transition: background-color 0.3s;
}

.night-mode-switch .slider:before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.night-mode-switch input:checked + .slider {
    background-color: var(--primary);
}

.night-mode-switch input:checked + .slider:before {
    transform: translateX(14px);
}

.night-mode-switch .sun-icon,
.night-mode-switch .moon-icon {
    font-size: 1em;
    margin: 0 4px;
    transition: opacity 0.3s;
}


/* Burger Menu */
.burger-menu {
    position: absolute;
    top: -14px;
    right: 0;
    width: 30px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 40;
}

.burger-menu span {
    width: 100%;
    height: 3px;
    background-color: var(--text);
    transition: all 0.3s ease;
}

.burger-menu.active span:nth-child(1) {
    transform: translateY(8.5px) rotate(45deg);
}

.burger-menu.active span:nth-child(2) {
    opacity: 0;
}

.burger-menu.active span:nth-child(3) {
    transform: translateY(-8.5px) rotate(-45deg);
}

/* Contact Layer */
.contact-layer {
    position: absolute;
    top: -20px;
    right: -110%;
    width: 100%;
    height: 320%;
    background-color: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: right 0.5s ease-in-out, opacity 1.5s ease-in-out;
    opacity: 0;
    z-index: 20;
}

.contact-layer.active {
    right: 0;
    opacity: 1;
    transition: right 0.5s ease-in-out, opacity 0s; /* No delay for opacity on show */
}

.contact-layer p {
    font-size: 1.2rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out 0.2s; /* Delay to sync with slide */
}

.contact-layer.active p {
    opacity: 1;
}

.contact-layer a {
    color: var(--text);
    text-decoration: none;
}

.contact-layer a:hover {
    text-decoration: underline;
}


/* Main */
main {
    max-width: 600px;
    margin: 0 auto;
    z-index: 10;
    opacity: 0; 
    transition: opacity 0.3s ease-in-out;
}

.intro p, .outro p {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    text-align: justify;
}

.intro p:nth-child(2) {
    margin-bottom: 0;
}

/* Contact */
.contact {
    text-align: center;
    margin: 1em 0 1rem;
}

.contact a, .contact a:visited, .contact a:hover {
    color: var(--secondary);
}

.contact a:active {
    color: var(--text);
}

.contact a.btn, .contact a.btn:visited, .contact a.btn:hover, .contact a.btn:active {
    color: var(--background);
}

.contact a:hover {
    text-decoration: none;
}

/* Footer */
footer {
    text-align: center;
    margin: 2rem auto 0;
    font-size: 0.9rem;
    color: var(--footer-text);
    z-index: 10;
    max-width: 600px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Media Queries */
@media (min-width: 768px) {
    body {
        padding: 40px;
    }
    
    .intro, .outro {
        padding: 0 1rem;
    }
    
    .logo {
        max-width: 200px;
    }

    h1 {
        font-size: 2.5rem;
    }

    .intro p, .outro p {
        font-size: 1.1rem;
        margin-bottom: 1.2rem;
    }

    .intro p:nth-child(2) {
        margin-bottom: 0;
    }

    .contact p {
        font-size: 1.1rem;
        margin-top: 1rem;
    }

    .flag {
        font-size: 1.4em;
        padding: 3px;
    }

    .night-mode-switch {
        top: -20px;
        left: 0;
    }

    .night-mode-switch .sun-icon,
    .night-mode-switch .moon-icon {
        font-size: 1.2em;
        margin: 0 5px;
    }
    
    .burger-menu {
        top: -10px;
        right: 20px;
    }

    .contact-layer {
        height: 240%;
    }

    .contact-layer p {
        font-size: 1.4rem;
    }
    
    
    /* Starry Effect */
    @keyframes twinkle {
        0%, 100% { opacity: 0.4; }
        50% { opacity: 1; }
    }
    
    body::before,
    body::after,
    body .star-1,
    body .star-2,
    body .star-3,
    body .star-4 {
        content: '';
        position: absolute;
        width: 4px;
        height: 4px;
        background-color: var(--star-color);
        border-radius: 50%;
        animation: twinkle 2s infinite ease-in-out;
        z-index: 0;
    }
    
    body::before {
        top: 10%;
        left: 5%;
        animation-delay: 0.2s;
    }
    
    body::after {
        top: 20%;
        right: 5%;
        animation-delay: 0.7s;
    }
    
    body .star-1 {
        top: 30%;
        left: 10%;
        animation-delay: 0.4s;
    }
    
    body .star-2 {
        top: 50%;
        right: 10%;
        animation-delay: 1s;
    }
    
    body .star-3 {
        bottom: 20%;
        left: 15%;
        animation-delay: 0.3s;
    }
    
    body .star-4 {
        bottom: 10%;
        right: 15%;
        animation-delay: 0.8s;
    }
}