/* undo.quest - Minimalist Pixel-Art Nostalgia Quest */
/* Colors: #f5f0e8, #1a1a2e, #6c757d, #e8b84b, #4a90d9 */
/* Fonts: Space Grotesk, Inter */

:root {
    --warm-white: #f5f0e8;
    --deep-base: #1a1a2e;
    --muted-gray: #6c757d;
    --accent-gold: #e8b84b;
    --primary-blue: #4a90d9;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--warm-white);
    color: var(--deep-base);
    font-family: var(--font-body);
    overflow-x: hidden;
    position: relative;
}

/* Grid Canvas Background */
#gridCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.06;
}

/* Header */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 48px;
    background: rgba(245, 240, 232, 0.9);
    backdrop-filter: blur(8px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-pixel {
    display: block;
    width: 8px;
    height: 8px;
    background: var(--deep-base);
}

.logo-pixel:nth-child(2) {
    background: var(--accent-gold);
    width: 6px;
    height: 6px;
}

.logo-pixel:nth-child(3) {
    background: var(--primary-blue);
    width: 4px;
    height: 4px;
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    color: var(--deep-base);
}

.quest-nav {
    display: flex;
    gap: 32px;
}

.nav-link {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--muted-gray);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: color 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: inline-block;
}

.nav-link:hover {
    color: var(--deep-base);
}

/* Sections - Ma Negative Space */
.section {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 48px;
}

.section-inner {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* Hero Section */
.section-hero {
    padding-top: 160px;
}

.hero-content {
    text-align: center;
    position: relative;
}

/* Pixel Art Scene */
.pixel-scene-hero {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 64px;
}

.pixel-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.px {
    display: block;
    width: 24px;
    height: 24px;
    background: var(--deep-base);
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.px.visible {
    opacity: 1;
}

/* Pixel undo arrow pattern */
.px-1 { background: transparent; }
.px-2 { background: transparent; }
.px-3 { background: var(--accent-gold); }
.px-4 { background: transparent; }
.px-5 { background: transparent; }
.px-6 { background: transparent; }
.px-7 { background: var(--accent-gold); }
.px-8 { background: transparent; }
.px-9 { background: transparent; }
.px-10 { background: transparent; }
.px-11 { background: var(--accent-gold); }
.px-12 { background: var(--accent-gold); }
.px-13 { background: var(--accent-gold); }
.px-14 { background: var(--accent-gold); }
.px-15 { background: var(--accent-gold); }
.px-16 { background: transparent; }
.px-17 { background: var(--accent-gold); }
.px-18 { background: transparent; }
.px-19 { background: transparent; }
.px-20 { background: transparent; }
.px-21 { background: transparent; }
.px-22 { background: transparent; }
.px-23 { background: var(--accent-gold); }
.px-24 { background: transparent; }
.px-25 { background: transparent; }

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 300;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 24px;
}

.title-line {
    display: block;
}

.title-accent {
    color: var(--accent-gold);
    font-weight: 600;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--muted-gray);
    font-weight: 300;
    letter-spacing: 0.01em;
    max-width: 400px;
    margin: 0 auto;
}

/* Hand-drawn annotations */
.hand-drawn-annotation {
    position: relative;
    display: inline-block;
    margin-top: 24px;
}

.annotation-svg {
    width: 120px;
    height: auto;
}

.annotation-text {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--muted-gray);
    font-style: italic;
    display: block;
    margin-top: 4px;
}

.annotation-hero {
    position: absolute;
    right: -60px;
    bottom: -20px;
}

/* Explore Section - Quest Cards */
.section-explore .section-inner {
    display: flex;
    gap: 48px;
    justify-content: center;
    flex-wrap: wrap;
}

.quest-card {
    background: rgba(26, 26, 46, 0.03);
    border: 1px solid rgba(26, 26, 46, 0.08);
    padding: 48px 36px;
    max-width: 300px;
    text-align: center;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.quest-card:hover {
    box-shadow: 0 8px 32px rgba(26, 26, 46, 0.08);
}

.card-pixel-art {
    margin-bottom: 24px;
}

.pixel-icon {
    display: inline-grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    width: 48px;
    height: 48px;
}

.pxl {
    display: block;
    background: rgba(26, 26, 46, 0.1);
    transition: background 0.3s ease;
}

.pxl.filled {
    background: var(--deep-base);
}

.pxl.accent {
    background: var(--accent-gold);
}

.quest-card:hover .pxl.filled {
    background: var(--primary-blue);
}

.quest-card:hover .pxl.accent {
    background: var(--accent-gold);
}

.card-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.card-desc {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--muted-gray);
    line-height: 1.6;
    font-weight: 300;
}

.annotation-explore {
    margin-top: 16px;
}

/* Rewind Section */
.section-rewind {
    background: var(--deep-base);
    color: var(--warm-white);
}

.rewind-scene {
    display: flex;
    gap: 80px;
    align-items: flex-start;
}

.timeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    position: relative;
    min-width: 120px;
}

.timeline-track {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: rgba(245, 240, 232, 0.15);
    transform: translateX(-50%);
}

.timeline-marker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 0;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.marker-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(245, 240, 232, 0.2);
    border: 2px solid rgba(245, 240, 232, 0.4);
    transition: all 0.3s ease;
}

.timeline-marker.active .marker-dot {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    box-shadow: 0 0 16px rgba(232, 184, 75, 0.4);
}

.marker-label {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: rgba(245, 240, 232, 0.5);
    letter-spacing: 0.05em;
    transition: color 0.3s ease;
}

.timeline-marker.active .marker-label {
    color: var(--accent-gold);
}

.rewind-display {
    flex: 1;
}

.pixel-scene-rewind {
    position: relative;
    min-height: 200px;
}

.scene-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    pointer-events: none;
}

.scene-state.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    position: relative;
}

.scene-pixels {
    width: 100%;
    height: 120px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.scene-complete {
    background: linear-gradient(135deg,
        var(--accent-gold) 0%, var(--accent-gold) 20%,
        var(--primary-blue) 20%, var(--primary-blue) 40%,
        var(--accent-gold) 40%, var(--accent-gold) 60%,
        var(--primary-blue) 60%, var(--primary-blue) 80%,
        var(--accent-gold) 80%, var(--accent-gold) 100%);
    background-size: 24px 24px;
    image-rendering: pixelated;
}

.scene-partial {
    background: linear-gradient(135deg,
        var(--accent-gold) 0%, var(--accent-gold) 20%,
        transparent 20%, transparent 40%,
        var(--primary-blue) 40%, var(--primary-blue) 60%,
        transparent 60%, transparent 80%,
        var(--accent-gold) 80%, var(--accent-gold) 100%);
    background-size: 24px 24px;
    image-rendering: pixelated;
}

.scene-early {
    background: repeating-linear-gradient(
        90deg,
        rgba(232, 184, 75, 0.3) 0px,
        rgba(232, 184, 75, 0.3) 24px,
        transparent 24px,
        transparent 48px
    );
    background-size: 48px 24px;
}

.scene-origin {
    background: rgba(245, 240, 232, 0.05);
    border: 1px dashed rgba(245, 240, 232, 0.15);
}

.scene-caption {
    font-family: var(--font-body);
    font-size: 1rem;
    color: rgba(245, 240, 232, 0.7);
    font-weight: 300;
    line-height: 1.6;
}

.annotation-rewind {
    margin-top: 32px;
}

.annotation-rewind .annotation-text {
    color: rgba(245, 240, 232, 0.4);
}

/* Restore Section */
.section-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 300;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    text-align: center;
}

.section-subtitle {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--muted-gray);
    font-weight: 300;
    text-align: center;
    margin-bottom: 64px;
}

.restore-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}

.restore-item {
    background: rgba(26, 26, 46, 0.02);
    border: 1px solid rgba(26, 26, 46, 0.06);
    padding: 32px;
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    cursor: pointer;
}

.restore-item:hover {
    box-shadow: 0 4px 24px rgba(26, 26, 46, 0.06);
}

.fragment-pixel {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    position: relative;
}

.fragment-art {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.fragment-art-1 {
    background: linear-gradient(45deg, var(--accent-gold) 25%, transparent 25%, transparent 75%, var(--accent-gold) 75%);
    background-size: 16px 16px;
}

.fragment-art-2 {
    background: repeating-linear-gradient(0deg, var(--muted-gray) 0px, var(--muted-gray) 8px, transparent 8px, transparent 16px);
    opacity: 0.3;
}

.fragment-art-3 {
    background: linear-gradient(90deg, var(--primary-blue) 50%, transparent 50%);
    background-size: 16px 16px;
    animation: fragmentRecover 2s ease-in-out infinite;
}

.fragment-art-4 {
    background: linear-gradient(135deg, var(--primary-blue) 25%, var(--accent-gold) 25%, var(--accent-gold) 50%, var(--primary-blue) 50%, var(--primary-blue) 75%, var(--accent-gold) 75%);
    background-size: 16px 16px;
}

.fragment-art-5 {
    background: repeating-conic-gradient(var(--muted-gray) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
    opacity: 0.2;
}

.fragment-art-6 {
    background: radial-gradient(circle at center, var(--accent-gold) 4px, transparent 4px);
    background-size: 16px 16px;
}

@keyframes fragmentRecover {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.fragment-label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.fragment-status {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.status-recovered { color: var(--primary-blue); }
.status-lost { color: var(--muted-gray); opacity: 0.5; }
.status-recovering { color: var(--accent-gold); }
.status-unknown { color: var(--muted-gray); }

/* Begin Section */
.section-begin {
    background: var(--deep-base);
    color: var(--warm-white);
}

.begin-prompt {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.pixel-scene-begin {
    width: 80px;
    height: 80px;
    margin: 0 auto 48px;
    border: 2px solid rgba(245, 240, 232, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.cursor-blink {
    width: 3px;
    height: 24px;
    background: var(--accent-gold);
    animation: cursorBlink 1s step-end infinite;
}

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

.begin-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 300;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.begin-text {
    font-family: var(--font-body);
    font-size: 1rem;
    color: rgba(245, 240, 232, 0.6);
    line-height: 1.8;
    font-weight: 300;
    margin-bottom: 48px;
}

.undo-counter {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.counter-label {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: rgba(245, 240, 232, 0.4);
    font-weight: 300;
}

.counter-value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-gold);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.counter-value.bump {
    transform: scale(1.3);
}

.undo-button {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px 40px;
    background: transparent;
    border: 2px solid var(--accent-gold);
    color: var(--accent-gold);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    letter-spacing: 0.02em;
}

.undo-button:hover {
    background: var(--accent-gold);
    color: var(--deep-base);
    transform: scale(1.05);
}

.undo-button:active {
    transform: scale(0.95);
}

.btn-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.annotation-begin {
    display: inline-block;
    margin-top: 24px;
}

.annotation-begin .annotation-text {
    color: rgba(245, 240, 232, 0.35);
}

/* Footer */
.site-footer {
    position: relative;
    z-index: 1;
    padding: 48px;
    text-align: center;
    border-top: 1px solid rgba(26, 26, 46, 0.06);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.footer-pixel {
    width: 6px;
    height: 6px;
    background: var(--muted-gray);
    opacity: 0.4;
}

.footer-text {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--muted-gray);
    font-weight: 300;
    letter-spacing: 0.02em;
}

/* Elastic spring animation class */
.elastic-target {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.elastic-target:hover {
    transform: scale(1.03);
}

.elastic-target.elastic-press {
    transform: scale(0.95);
}

.elastic-target.elastic-release {
    transform: scale(1.08);
}

/* Fade-in animations */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .site-header {
        padding: 16px 24px;
    }

    .quest-nav {
        gap: 16px;
    }

    .nav-link {
        font-size: 0.8rem;
    }

    .section {
        padding: 80px 24px;
    }

    .section-explore .section-inner {
        flex-direction: column;
        align-items: center;
    }

    .restore-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .rewind-scene {
        flex-direction: column;
        gap: 40px;
    }

    .timeline {
        flex-direction: row;
        min-width: auto;
    }

    .timeline-track {
        top: 50%;
        left: 0;
        right: 0;
        bottom: auto;
        width: auto;
        height: 2px;
        transform: translateY(-50%);
    }

    .timeline-marker {
        padding: 0 12px;
    }

    .annotation-hero {
        position: relative;
        right: auto;
        bottom: auto;
    }
}

@media (max-width: 480px) {
    .restore-grid {
        grid-template-columns: 1fr;
    }

    .quest-nav {
        gap: 12px;
    }
}