:root {
    --primary-color: rgb(65,112,213);
    --primary-hover: rgb(50,86,162);
    --text-primary: #24292e;
    --text-secondary: #586069;
    --border-color: #e1e4e8;
    --bg-light: #f6f8fa;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --animation-duration: 0.8s;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Helvetica, Arial, sans-serif;
    background-color: #fff;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

ul {
    list-style-type: disc;
    margin-left: 1.5rem;
}

.header {
    background-color: var(--bg-light);
    padding: 3rem 2rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    opacity: 0;
    animation: fadeIn var(--animation-duration) ease-in-out forwards;
}

.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml,<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><rect width="20" height="20" fill="none"/><circle cx="3" cy="3" r="1" fill="rgba(255,255,255,0.2)"/></svg>') repeat;
    opacity: 0.3;
}

h1, .subtitle {
    text-align: center;
    position: relative;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.content {
    max-width: min(1200px, 95%);
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

.calculator-section {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2.5rem;
    margin: 2rem auto;
    opacity: 0;
    animation: fadeIn var(--animation-duration) ease-in-out forwards;
    animation-delay: 0.8s;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.calculator-section:hover {
    box-shadow: var(--shadow-md);
}

h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
    font-weight: 600;
}

.calculator {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #fff;
}

.calculator:hover {
    box-shadow: var(--shadow-sm);
}

iframe {
    border: none;
    background-color: #fff;
    margin-top: -47px;
    height: calc(100% + 47px) !important;
    width: 100%;
}

.about, .projection-algorithm {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2.5rem;
    margin: 2rem auto;
    line-height: 1.7;
    opacity: 0;
    animation: fadeIn var(--animation-duration) ease-in-out forwards;
    box-shadow: var(--shadow-sm);
}

.about p, .calculator-section p, .projection-algorithm p {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
}

.about p:last-child, .calculator-section p:last-child, .projection-algorithm p:last-child {
    margin-bottom: 0;
}

.about {
    animation-delay: 0.4s;
}

.projection-algorithm {
    animation-delay: 1s;
}

.footer {
    background-color: var(--bg-light);
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    margin-top: auto;
    opacity: 0;
    animation: fadeIn var(--animation-duration) ease-in-out forwards;
    animation-delay: 1.2s;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0.5rem 0;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.menu, .project-menu {
    text-align: center;
    opacity: 0;
    animation: fadeIn var(--animation-duration) ease-in-out forwards;
}

.menu {
    background-color: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    animation-delay: 0.2s;
}

.project-menu {
    padding: 1.25rem 0;
    animation-delay: 0.6s;
    margin: 0;
}

.menu a, .project-menu button {
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    margin: 0 0.75rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.menu a {
    text-decoration: none;
    display: inline-block;
}

.project-menu button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
}

.menu a:hover, .project-menu button:hover {
    background-color: var(--bg-light);
    transform: translateY(-2px);
}

.menu a.active, .project-menu button.active {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 8px rgba(65,112,213,0.3);
}

.menu a.active:hover, .project-menu button.active:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(65,112,213,0.3);
}

.project-section {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project-section.active {
    display: block;
    opacity: 1;
}

.toggle-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(65,112,213,0.2);
    font-family: inherit;
}

.toggle-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(65,112,213,0.3);
}

.graph-box {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    transition: all 0.3s ease;
}

.graph-box:hover {
    box-shadow: var(--shadow-sm);
}

.graph-box h3 {
    color: var(--text-primary);
    margin: 0 0 1rem;
    font-size: 1.4rem;
    font-weight: 600;
}

.graph-description {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 0.9;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .content {
        padding: 1.5rem;
    }

    .calculator-section,
    .about {
        padding: 1.5rem;
    }

    .menu a,
    .project-menu button {
        padding: 0.5rem 1rem;
        margin: 0 0.25rem;
        font-size: 0.9rem;
    }

    .graph-box {
        padding: 1.5rem;
    }

    h1 {
        font-size: clamp(1.75rem, 4vw, 2.5rem);
    }

    .subtitle {
        font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    }
}

body.initial-load .calculator-section { 
    animation: fadeIn var(--animation-duration) ease-in-out forwards;
    animation-delay: 0.8s; 
}

body:not(.initial-load) .project-section.active .calculator-section {
    animation: fadeIn var(--animation-duration) ease-in-out forwards !important;
    animation-delay: 0s !important;
}

.about h3 {
    color: var(--text-primary);
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    font-weight: 600;
}

.equation-container {
    margin: 1.5rem 0;
    overflow-x: auto;
    text-align: center;
}

.equation-container img,
.equation-container object {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.emoji-container {
    text-align: center;
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.emoji-container img {
    max-width: 150px;
    height: auto;
    transition: transform 0.3s ease;
}

.bouncing-icon {
    position: fixed;
    width: 150px;
    height: 150px;
    opacity: 1;
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
    .bouncing-icon {
        display: none;
    }

    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
