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

html {
    overflow-x: hidden;
}

body {
    background: #f5f0e8;
    color: #2a2a2a;
    font-family: 'Noto Serif JP', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.05rem);
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* Paper texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* Notebook edge - left gutter */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 40px;
    height: 100%;
    box-shadow: inset 4px 0 8px rgba(0, 0, 0, 0.04);
    pointer-events: none;
    z-index: 10;
}

/* Notebook right edge */
.notebook-edge-right {
    position: fixed;
    top: 0;
    right: 5vw;
    width: 1px;
    height: 100%;
    background: #e0dcd4;
    pointer-events: none;
    z-index: 10;
}

/* Cover Section */
.cover {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f0e8;
    position: relative;
    z-index: 2;
}

.cover-content {
    text-align: center;
}

.cover-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4rem);
    color: #2a2a2a;
    letter-spacing: 0.02em;
    opacity: 0;
    animation: fadeInTitle 1.5s ease-out 0.8s forwards;
}

.cover-japanese {
    font-family: 'Noto Serif JP', serif;
    font-weight: 400;
    font-size: 1.5rem;
    color: #6a6a6a;
    margin-top: 12px;
    opacity: 0;
    animation: fadeInTitle 1s ease-out 2s forwards;
}

.cover-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1rem;
    color: #8a8a8a;
    margin-top: 24px;
    opacity: 0;
    animation: fadeInTitle 1s ease-out 2.5s forwards;
}

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

/* Timeline Container */
.timeline-container {
    position: relative;
    padding: 60px 0 120px;
    z-index: 2;
}

/* Timeline Spine */
.timeline-spine {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    transform: translateX(-50%);
    z-index: 1;
}

.spine-line {
    stroke: #3a3a3a;
    stroke-width: 1;
}

/* Timeline Sections with different backgrounds */
.timeline-section {
    position: relative;
    padding: 40px 0;
}

.section-kraft {
    background: #f5f0e8;
}

.section-linen {
    background: #f0f0ec;
}

.section-cream {
    background: #faf8f2;
}

/* Timeline Node */
.timeline-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding: 40px 0;
    width: 100%;
}

/* Node Dot */
.node-dot {
    position: absolute;
    left: 50%;
    top: 50px;
    width: 8px;
    height: 8px;
    background: #3a3a3a;
    border-radius: 50%;
    transform: translate(-50%, 0) scale(0);
    transition: transform 0.2s ease-out;
    z-index: 5;
    cursor: pointer;
}

.node-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border: 1px solid #3a3a3a;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: width 0.3s ease-out, height 0.3s ease-out, opacity 0.3s ease-out;
}

.node-dot:hover::after {
    width: 16px;
    height: 16px;
    opacity: 1;
}

.timeline-node.revealed .node-dot {
    transform: translate(-50%, 0) scale(1);
}

/* Node Connector */
.node-connector {
    position: absolute;
    top: 54px;
    width: 0;
    height: 1px;
    background: #3a3a3a;
    transition: width 0.3s ease-out 0.2s;
    z-index: 3;
}

.node-connector.dashed {
    background: none;
    border-top: 1px dashed #3a3a3a;
}

.timeline-node.left .node-connector {
    right: 50%;
    margin-right: 8px;
}

.timeline-node.right .node-connector {
    left: 50%;
    margin-left: 8px;
}

.timeline-node.revealed .node-connector {
    width: 40px;
}

/* Node Content */
.node-content {
    max-width: 380px;
    opacity: 0;
    transition: opacity 0.4s ease-out 0.5s, transform 0.4s ease-out 0.5s;
    position: relative;
}

.timeline-node.left .node-content {
    margin-right: auto;
    margin-left: 5%;
    text-align: right;
    transform: translateX(20px);
}

.timeline-node.right .node-content {
    margin-left: auto;
    margin-right: 5%;
    text-align: left;
    transform: translateX(-20px);
}

.timeline-node.revealed .node-content {
    opacity: 1;
    transform: translateX(0);
}

/* Enlightenment section wider content */
.section-linen .node-content {
    max-width: 420px;
}

/* Ink Drop */
.ink-drop {
    position: absolute;
    top: 8px;
    width: 3px;
    height: 3px;
    background: #2a2a2a;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

.timeline-node.left .ink-drop {
    right: 0;
}

.timeline-node.right .ink-drop {
    left: 0;
}

.timeline-node.revealed .ink-drop {
    animation: inkDrop 0.6s ease-out 0.5s forwards;
}

@keyframes inkDrop {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(2);
    }
}

/* Node Heading */
.node-heading {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    color: #2a2a2a;
    line-height: 1.2;
    margin-bottom: 12px;
}

/* Node Body */
.node-body {
    font-family: 'Noto Serif JP', serif;
    font-weight: 400;
    color: #2a2a2a;
    margin-bottom: 16px;
}

/* Handwritten Diagrams */
.node-diagram {
    margin-top: 12px;
}

.hand-diagram {
    width: 120px;
    height: auto;
}

.timeline-node.left .hand-diagram {
    float: right;
}

.diagram-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.timeline-node.revealed .diagram-path {
    stroke-dashoffset: 0;
}

/* Margin Annotations */
.margin-annotation {
    position: absolute;
    top: 50px;
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 0.8rem;
    color: #8a8a8a;
    transform: rotate(var(--rotation, 0deg));
    opacity: 0;
    transition: opacity 0.5s ease-out 0.8s;
    white-space: nowrap;
}

.timeline-node.left .margin-annotation {
    right: 52%;
    margin-right: 60px;
}

.timeline-node.right .margin-annotation {
    left: 52%;
    margin-left: 60px;
}

.timeline-node.revealed .margin-annotation {
    opacity: 1;
}

/* Speculative Nodes */
.speculative .spine-line {
    stroke-dasharray: 4 4;
}

.speculative-node .node-content {
    opacity: 0;
}

.speculative-node.revealed .node-content {
    opacity: 0.7;
}

/* Final Empty Node */
.final-node {
    display: flex;
    justify-content: center;
    padding: 60px 0;
}

.final-node .node-dot {
    position: relative;
    left: auto;
    top: auto;
    transform: scale(0);
}

.final-node.revealed .node-dot {
    transform: scale(1);
}

/* Mobile */
@media (max-width: 768px) {
    .timeline-spine {
        left: 30%;
    }

    .node-dot {
        left: 30%;
    }

    .timeline-node.left .node-connector,
    .timeline-node.right .node-connector {
        left: 30%;
        right: auto;
        margin-left: 8px;
        margin-right: 0;
    }

    .timeline-node.left .node-content,
    .timeline-node.right .node-content {
        margin-left: calc(30% + 60px);
        margin-right: 5%;
        text-align: left;
        transform: translateX(-10px);
    }

    .timeline-node.left .ink-drop,
    .timeline-node.right .ink-drop {
        left: 0;
        right: auto;
    }

    .timeline-node.left .hand-diagram {
        float: none;
    }

    .margin-annotation {
        position: static;
        display: block;
        margin-top: 8px;
        font-style: italic;
    }

    .timeline-node.left .margin-annotation,
    .timeline-node.right .margin-annotation {
        left: auto;
        right: auto;
        margin-left: 0;
        margin-right: 0;
    }

    .notebook-edge-right {
        display: none;
    }

    body::after {
        display: none;
    }
}

/* A0A0A0 used for reference -- dotted lines */
.node-connector.dashed {
    border-color: #a0a0a0;
}
