:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --accent-color: #007acc;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --code-font: 'Courier Prime', 'Courier New', Courier, monospace;
    --body-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --section-bg: rgba(0, 0, 0, 0.02);
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --accent-color: #64b5f6;
    --nav-bg: rgba(26, 26, 26, 0.95);
    --section-bg: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--body-font);
    line-height: 1.6;
    font-size: 16px;
}

/* Tree Mode */
#tree-canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    /* Above everything else */
    background-color: #1a2b3c;
    /* Match fog color */
}

#position-display {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    z-index: 210;
    backdrop-filter: blur(5px);
}

#position-display h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
}

#position-display p {
    margin: 0 0 10px 0;
    opacity: 0.7;
}

#position-coords {
    line-height: 1.6;
}

#tree-controls {
    position: absolute;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 210;
}

#tree-controls button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tree-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

#tree-controls button:active {
    transform: scale(0.95);
}

#intro-message {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-family: var(--body-font);
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
    z-index: 220;
    pointer-events: none;
    animation: pulse 2s infinite;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Kirigami Thread */
#kirigami-container {
    position: fixed;
    top: 0;
    left: 20px;
    /* Position to the left */
    width: 50px;
    height: 100vh;
    z-index: 50;
    pointer-events: none;
    /* Let clicks pass through */
}

#kirigami-thread {
    width: 100%;
    height: 100%;
}

#kirigami-thread path {
    fill: none;
    stroke: var(--text-color);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.3;
    transition: stroke 0.3s ease;
}

body.dark-mode #kirigami-thread path {
    stroke: var(--text-color);
    opacity: 0.4;
}

/* Navigation */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    padding: 1rem 0;
    text-align: center;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 300;
    /* Above Tree Mode */
}

body.dark-mode nav {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

nav a {
    margin: 0 15px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    position: relative;
    font-size: 0.95rem;
}

nav a:hover {
    color: var(--accent-color);
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--accent-color);
    transition: width 0.3s;
}

nav a:hover::after {
    width: 100%;
}

#dark-mode-toggle,
#tree-mode-toggle,
nav a.nav-button {
    background: none;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.85rem;
    margin-right: 10px;
    transition: all 0.3s ease;
}

nav a.nav-button {
    text-decoration: none;
    display: inline-block;
    line-height: 1.2;
    vertical-align: middle;
    box-sizing: border-box;
    font-weight: 400;
    margin: 0;
    margin-right: 10px;
    font-size: 0.85rem;
}

nav a.nav-button::after {
    display: none;
}

#dark-mode-toggle,
#tree-mode-toggle {
    line-height: 1.2;
    vertical-align: middle;
}

#dark-mode-toggle:hover,
#tree-mode-toggle:hover,
nav a.nav-button:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Main Content */
article {
    max-width: 680px;
    margin: 100px auto 60px;
    padding: 0 20px;
}

h1,
h4 {
    margin-top: 0;
    font-weight: 700;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

#typing-text {
    font-family: var(--body-font);
    font-size: 1.1rem;
    margin-bottom: 3rem;
    color: var(--text-color);
}

section {
    margin-bottom: 2.5rem;
    padding: 2rem;
    border-radius: 12px;
    background: var(--section-bg);
}

section:hover {
    transform: translateY(-2px);
    transition: transform 0.3s ease;
}

ul {
    padding-left: 20px;
}

li {
    margin-bottom: 0.5rem;
}

/* Procedural Message */
.procedural-message {
    text-align: center;
    margin-top: 4rem;
    padding: 2rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.procedural-message:hover {
    opacity: 0.9;
}

.procedural-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.procedural-text {
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Mobile Adjustment */
@media (max-width: 800px) {
    #kirigami-container {
        display: none;
    }

    /* Tree Mode Mobile Styles */
    #tree-controls {
        bottom: 30px;
        right: 20px;
    }

    #tree-controls button {
        width: 60px;
        height: 60px;
        font-size: 1.4rem;
    }

    #intro-message {
        font-size: 1rem;
        bottom: 80px;
        padding: 0 20px;
        text-align: center;
    }

    #position-display {
        display: none !important;
    }
}

@media (max-width: 480px) {
    #tree-controls button {
        width: 56px;
        height: 56px;
    }

    #intro-message {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }
}