/* Light theme variables */
:root {
    --bg-color: #fae8cc;
    --text-color: #222;
    --bounce-light: #f4d198;
    --grid-color: rgba(0, 0, 0, 0.02);
    --border-color: rgba(0, 0, 0, 0.1);
    --link-border: rgba(0, 0, 0, 0.2);
    --link-hover: rgba(0, 0, 0, 0.05);
    --timing-fn: cubic-bezier(.455, .19, 0, .985);
}

/* Dark theme variables */
[data-theme="dark"] {
    --bg-color: #0f1420;
    --text-color: #e4e4e4;
    --bounce-light: #384359;
    --grid-color: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.1);
    --link-border: rgba(255, 255, 255, 0.2);
    --link-hover: rgba(255, 255, 255, 0.05);
}

body {
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}

body.page-transition-out {
    opacity: 0;
}

#dappled-light {
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#light-overlay {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at center,
        var(--bounce-light) 0%,
        transparent 70%
    );
    opacity: 0.5;
    animation: lightShift 10s var(--timing-fn) infinite;
    transition: 0.3s ease;
}

[data-theme="dark"] #light-overlay {
    opacity: 0.15;
}

@keyframes lightShift {
    0% { transform: translate(-25%, -25%) rotate(0deg); }
    50% { transform: translate(-15%, -15%) rotate(5deg); }
    100% { transform: translate(-25%, -25%) rotate(0deg); }
}

main {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 1s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    font-size: 2.0rem;
    font-weight: normal;
    margin-bottom: 2.3rem;
    letter-spacing: -0.6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s ease;
    color: var(--text-color);
}

.theme-toggle:hover {
    background: var(--link-hover);
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
    position: absolute;
    transition: opacity 0.3s ease, transform 0.5s ease;
}

.theme-toggle .sun-icon {
    opacity: 1;
}

.theme-toggle .moon-icon {
    opacity: 0;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    opacity: 0;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    opacity: 1;
}

.grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: -1;
    transition: background-image 0.3s ease;
}

.corner {
    position: fixed;
    width: 10px;
    height: 10px;
    border: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.corner-tl { top: 20px; left: 20px; border-right: none; border-bottom: none; }
.corner-tr { top: 20px; right: 20px; border-left: none; border-bottom: none; }
.corner-bl { bottom: 20px; left: 20px; border-right: none; border-top: none; }
.corner-br { bottom: 20px; right: 20px; border-left: none; border-top: none; }

/* Writing page specific styles */
.writing-list {
    margin-top: 3rem;
}

.writing-item {
    margin-bottom: 2rem;
    display: block;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: none;
    transition: transform 0.2s ease;
    padding: 0.5rem;
    border: 1px solid transparent;
}

.writing-item:hover {
    transform: translateX(5px);
    border: 1px solid var(--border-color);
    background: var(--link-hover);
}

.writing-title {
    font-size: 1.3rem;
    font-weight: normal;
    margin: 0;
}

#stars {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

[data-theme="dark"] #stars {
    display: block;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background-color: #ffffff;
    border-radius: 50%;
    animation: starTwinkle 3s infinite;
}

@keyframes starTwinkle {
    0% { opacity: 0.3; }
    50% { opacity: 0.8; }
    100% { opacity: 0.3; }
}

.back-link {
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid var(--link-border);
    padding-bottom: 1px;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    margin-top: 3rem;
    display: inline-block;
}

.back-link:hover {
    border-bottom-color: var(--text-color);
    background: var(--link-hover);
}

/* Graph Navigation */
.graph-nav {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 4rem auto 2rem;
}

.graph-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.graph-node {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--text-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.graph-node::before {
    content: attr(data-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.graph-node:hover {
    transform: scale(1.5);
}

.graph-node:hover::before {
    opacity: 1;
}

.graph-node.active {
    background: var(--bounce-light);
    transform: scale(1.5);
}

/* Dark mode specific styling for graph nodes */
[data-theme="dark"] .graph-node {
    background: var(--bounce-light);
}

[data-theme="dark"] .graph-node.active {
    background: var(--text-color);
}

.graph-edge {
    position: absolute;
    height: 1px;
    background: var(--border-color);
    transform-origin: left center;
    pointer-events: none;
    transition: background-color 0.3s ease;
}

.graph-edge.active {
    background: var(--bounce-light) !important;
    height: 2px !important;
}

/* Dark mode specific styling for graph edges */
[data-theme="dark"] .graph-edge.active {
    background: rgba(255, 255, 255, 0.6) !important;
    height: 2px !important;
}

/* Page transition animations */
body {
    transition: opacity 0.3s ease;
}

body.page-transition-out {
    opacity: 0;
}

main {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 1s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}