/* ================================
   undo.sh — Terracotta Workshop Theme
   Fonts: Space Mono, Caveat
   Colors: #f5efe6, #8b6f47, #5e7a52, #c4956a, #2c2c2c, #3b2f2f, #e8d5b7, #bf4a3a
   ================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Mono', monospace;
    font-size: 18px;
    line-height: 1.7;
    color: #3b2f2f;
    background-color: #f5efe6;
    overflow-x: hidden;
    position: relative;
}

/* Paper grain texture overlay */
#paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
}

/* Eraser particles container */
#eraser-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.eraser-particle {
    position: absolute;
    border-radius: 50%;
    background-color: #c4956a;
    opacity: 0.6;
    pointer-events: none;
    animation: floatUp 2s ease-out forwards;
}

@keyframes floatUp {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(var(--drift-x, 10px), -120px) scale(0.3);
        opacity: 0;
    }
}

/* Main narrative */
#narrative {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* ================================
   Chapter sections
   ================================ */
.chapter {
    padding: 80px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.chapter.visible {
    opacity: 1;
    transform: translateY(0);
}

.chapter.visible .chapter-content > * {
    opacity: 0;
    transform: translateY(12px);
    animation: staggerIn 500ms ease-out forwards;
}

.chapter.visible .chapter-content > *:nth-child(1) { animation-delay: 0ms; }
.chapter.visible .chapter-content > *:nth-child(2) { animation-delay: 100ms; }
.chapter.visible .chapter-content > *:nth-child(3) { animation-delay: 200ms; }
.chapter.visible .chapter-content > *:nth-child(4) { animation-delay: 300ms; }
.chapter.visible .chapter-content > *:nth-child(5) { animation-delay: 400ms; }
.chapter.visible .chapter-content > *:nth-child(6) { animation-delay: 500ms; }
.chapter.visible .chapter-content > *:nth-child(7) { animation-delay: 600ms; }
.chapter.visible .chapter-content > *:nth-child(8) { animation-delay: 700ms; }

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

.chapter-content {
    position: relative;
}

/* ================================
   Hero section
   ================================ */
#hero {
    padding-top: 120px;
    padding-bottom: 60px;
    text-align: center;
}

.hero-tagline {
    font-family: 'Caveat', cursive;
    font-size: 48px;
    font-weight: 700;
    line-height: 1.2;
    color: #3b2f2f;
    margin-bottom: 40px;
}

.hero-illustration {
    max-width: 600px;
    margin: 0 auto 30px;
}

.hero-illustration svg {
    width: 100%;
    height: auto;
}

.hero-sub {
    font-family: 'Caveat', cursive;
    font-size: 22px;
    color: #8b6f47;
}

/* Blinking cursor */
.blink-cursor {
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ================================
   Typography
   ================================ */
.section-heading {
    font-family: 'Space Mono', monospace;
    font-size: 32px;
    line-height: 1.2;
    color: #3b2f2f;
    margin-bottom: 24px;
}

.terminal-output {
    margin-bottom: 24px;
}

.terminal-output p {
    font-family: 'Space Mono', monospace;
    font-size: 18px;
    line-height: 1.7;
    color: #3b2f2f;
}

.annotation {
    font-family: 'Caveat', cursive;
    font-size: 22px;
    color: #8b6f47;
}

.annotation-text {
    opacity: 0.85;
}

.margin-note {
    font-family: 'Caveat', cursive;
    font-size: 18px;
    color: #c4956a;
    margin-bottom: 8px;
    text-transform: lowercase;
}

.margin-note-right {
    font-family: 'Caveat', cursive;
    font-size: 18px;
    color: #c4956a;
    text-align: right;
    margin-top: 16px;
}

/* ================================
   Code blocks
   ================================ */
.code-block {
    background-color: #2c2c2c;
    color: #c4956a;
    font-family: 'Space Mono', monospace;
    font-size: 15px;
    line-height: 1.6;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #8b6f47;
    margin: 24px 0;
    overflow-x: auto;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.code-block code {
    font-family: inherit;
}

.kiln-red {
    color: #bf4a3a;
    font-weight: 700;
}

.moss-green {
    color: #5e7a52;
}

.leather-text {
    color: #8b6f47;
}

.caveat-text {
    font-family: 'Caveat', cursive;
    font-size: 18px;
}

/* ================================
   Sketch illustrations
   ================================ */
.sketch-illustration {
    margin: 32px auto;
    max-width: 500px;
}

.sketch-illustration svg {
    width: 100%;
    height: auto;
}

/* SVG path drawing animation */
.draw-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1.5s ease-out;
}

.svg-visible .draw-path {
    stroke-dashoffset: 0;
}

.svg-visible .draw-path.delay-1 {
    transition-delay: 0.3s;
}

.svg-visible .draw-path.delay-2 {
    transition-delay: 0.6s;
}

.svg-visible .draw-path.delay-3 {
    transition-delay: 0.9s;
}

/* ================================
   Dividers
   ================================ */
.divider {
    padding: 20px 0;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.divider-svg {
    width: 100%;
    height: auto;
}

/* ================================
   Philosophy quote
   ================================ */
.philosophy-quote {
    font-family: 'Caveat', cursive;
    font-size: 26px;
    color: #8b6f47;
    text-align: center;
    padding: 32px 24px;
    margin: 32px 0;
    border-left: 3px solid #c4956a;
    background-color: #e8d5b7;
    border-radius: 0 8px 8px 0;
}

/* ================================
   Time gear animation (counter-clockwise)
   ================================ */
.time-gear {
    transform-origin: 200px 100px;
    animation: spinCCW 12s linear infinite;
}

@keyframes spinCCW {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

/* ================================
   Floating rewind button
   ================================ */
#rewind-btn {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 56px;
    height: 56px;
    background: #f5efe6;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(59, 47, 47, 0.15);
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 300ms ease;
    padding: 0;
}

#rewind-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(59, 47, 47, 0.25);
}

#rewind-btn svg {
    display: block;
}

/* Magnetic element base */
.magnetic-element {
    will-change: transform;
}

/* ================================
   Footer
   ================================ */
#footer {
    padding: 40px 0 80px;
    text-align: center;
}

.footer-text {
    font-family: 'Space Mono', monospace;
    font-size: 20px;
    color: #3b2f2f;
    margin-bottom: 8px;
}

.footer-text .annotation {
    font-size: 18px;
}

.footer-sub {
    font-family: 'Caveat', cursive;
    font-size: 20px;
    color: #c4956a;
    margin-bottom: 24px;
}

.footer-doodles {
    max-width: 200px;
    margin: 0 auto;
}

.footer-doodles svg {
    width: 100%;
    height: auto;
}

/* ================================
   Links (right-to-left underline)
   ================================ */
a {
    color: #5e7a52;
    text-decoration: none;
    position: relative;
    display: inline-block;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: 0;
    width: 0;
    height: 2px;
    background-color: #5e7a52;
    transition: width 400ms ease-out;
}

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

/* ================================
   Selection
   ================================ */
::selection {
    background-color: #c4956a;
    color: #f5efe6;
}

/* ================================
   Responsive
   ================================ */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .hero-tagline {
        font-size: 36px;
    }

    .section-heading {
        font-size: 26px;
    }

    #narrative {
        padding: 0 16px;
    }

    .chapter {
        padding: 60px 0;
    }

    #hero {
        padding-top: 80px;
    }

    .code-block {
        font-size: 13px;
        padding: 16px;
        border-radius: 8px;
    }

    .philosophy-quote {
        font-size: 22px;
        padding: 24px 16px;
    }

    #rewind-btn {
        bottom: 20px;
        right: 20px;
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 480px) {
    .hero-tagline {
        font-size: 28px;
    }

    .section-heading {
        font-size: 22px;
    }

    .annotation {
        font-size: 19px;
    }
}

/* ================================
   Install block highlight
   ================================ */
.install-block {
    border-color: #5e7a52;
    border-width: 2px;
}
