/* ==============================================
   undo.sh - Command-Line Time Machine
   Palette: Analogous Amber on Near-Black
   ============================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --void-black: #0F0E0D;
    --console-dark: #1C1A17;
    --amber-terminal: #D4813A;
    --golden-rewind: #E8A84C;
    --patina-copper: #A65C28;
    --parchment-light: #F5E6D0;
    --walnut-panel: #7A5C3A;
}

html {
    scroll-behavior: auto;
}

body {
    background-color: var(--void-black);
    color: var(--parchment-light);
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.75;
    font-weight: 400;
    overflow-x: hidden;
}

/* --- Scan Lines Overlay --- */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        rgba(15, 14, 13, 0.08) 0px,
        rgba(15, 14, 13, 0.08) 1px,
        transparent 1px,
        transparent 2px
    );
}

/* --- Terminal Bar (Fixed Header) --- */
#terminal-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--console-dark);
    border-bottom: 1px solid var(--patina-copper);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 24px;
    z-index: 1000;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.terminal-prompt {
    color: var(--amber-terminal);
}

.terminal-depth {
    color: var(--walnut-panel);
}

#depth-counter {
    color: var(--golden-rewind);
    font-variant-numeric: tabular-nums;
}

/* --- Blinking Cursor --- */
.cursor-blink {
    display: inline-block;
    width: 2px;
    height: 20px;
    background-color: var(--amber-terminal);
    animation: cursorBlink 1s steps(2) infinite;
    vertical-align: middle;
}

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

/* --- Boot Screen --- */
#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--void-black);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 800ms ease;
}

#boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#boot-screen.hidden {
    display: none;
}

#boot-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--amber-terminal);
    max-width: 600px;
    padding: 32px;
}

.boot-line {
    min-height: 1.75em;
    white-space: pre-wrap;
    margin-bottom: 0.5em;
}

#boot-cursor {
    margin-left: 4px;
}

/* --- Main Content --- */
#main-content {
    padding-top: 96px;
    opacity: 0;
    transition: opacity 600ms ease;
}

#main-content.visible {
    opacity: 1;
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--parchment-light);
    text-shadow: 1px 1px 0 var(--amber-terminal);
    text-align: center;
    margin-bottom: 48px;
}

/* --- Content Sections --- */
.content-section {
    padding: 64px 32px;
}

/* --- Timeline Scrubber --- */
.timeline-scrubber {
    width: 100%;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 48px;
    padding: 0 4px;
}

.scrubber-track {
    flex: 1;
    height: 4px;
    background-color: var(--patina-copper);
    border-radius: 2px;
    position: relative;
}

.scrubber-playhead {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background-color: var(--golden-rewind);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(232, 168, 76, 0.4);
    transition: left 100ms linear;
}

.scrubber-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--walnut-panel);
    white-space: nowrap;
}

/* --- Card Grid --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Command Card --- */
.command-card {
    background-color: var(--console-dark);
    border: 2px solid var(--amber-terminal);
    box-shadow: inset 4px 0 0 var(--patina-copper);
    aspect-ratio: 4 / 3;
    display: flex;
    flex-direction: column;
    position: relative;
    opacity: 0;
    transform: translateY(24px);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.command-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.command-card.pulse-active {
    animation: pulseAttention 3s ease-in-out infinite;
}

.command-card:hover {
    transform: translateY(-4px);
    box-shadow: inset 4px 0 0 var(--patina-copper), 0 8px 32px rgba(212, 129, 58, 0.15);
}

.command-card.visible:hover {
    transform: translateY(-4px);
}

/* Every third card rotated */
.rotate-card {
    transform: rotate(-0.8deg) translateY(24px);
}

.rotate-card.visible {
    transform: rotate(-0.8deg) translateY(0);
}

.rotate-card:hover,
.rotate-card.visible:hover {
    transform: rotate(-0.8deg) translateY(-4px);
    box-shadow: inset 4px 0 0 var(--patina-copper), 0 8px 32px rgba(212, 129, 58, 0.15);
}

@keyframes pulseAttention {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

/* Punch Card Holes */
.punch-holes {
    height: 12px;
    flex-shrink: 0;
    background: repeating-radial-gradient(
        circle at 6px center,
        var(--patina-copper) 0,
        var(--patina-copper) 3px,
        transparent 3px,
        transparent 12px
    );
    opacity: 0.3;
    background-size: 12px 12px;
    background-position: 6px center;
}

.punch-holes-top {
    background: radial-gradient(circle 3px at 6px 6px, rgba(166, 92, 40, 0.3) 100%, transparent 100%);
    background-size: 12px 12px;
}

.punch-holes-bottom {
    background: radial-gradient(circle 3px at 6px 6px, rgba(166, 92, 40, 0.3) 100%, transparent 100%);
    background-size: 12px 12px;
}

/* Card Content */
.card-content {
    flex: 1;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--walnut-panel);
    margin-bottom: 8px;
}

.card-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--parchment-light);
    text-shadow: 1px 1px 0 var(--amber-terminal);
    margin-bottom: 12px;
}

.card-body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.8rem, 0.95vw, 0.95rem);
    line-height: 1.65;
    color: var(--parchment-light);
    flex: 1;
}

/* --- Undo Arrow Motif --- */
.undo-arrow-motif {
    width: 32px;
    height: 32px;
    margin-top: auto;
    border: 2px solid var(--amber-terminal);
    border-radius: 50%;
    position: relative;
    align-self: flex-end;
    animation: rotateArrow 20s linear infinite;
}

.undo-arrow-motif::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 7px solid var(--amber-terminal);
    transform: rotate(-45deg);
}

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

/* --- Rewind Cards (warmer shift) --- */
.rewind-card {
    border-color: var(--golden-rewind);
}

.rewind-card .card-title {
    text-shadow: 1px 1px 0 var(--golden-rewind);
}

.rewind-card .undo-arrow-motif {
    border-color: var(--golden-rewind);
}

.rewind-card .undo-arrow-motif::after {
    border-bottom-color: var(--golden-rewind);
}

#the-rewind {
    background-color: rgba(28, 26, 23, 0.5);
}

#the-rewind .section-heading {
    text-shadow: 1px 1px 0 var(--golden-rewind);
    color: var(--golden-rewind);
}

/* --- Tape Reel Divider --- */
.tape-reel-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 48px 32px;
    opacity: 0.4;
}

.tape-reel {
    flex-shrink: 0;
}

.tape-reel-left {
    animation: rotateTapeLeft 12s linear infinite;
}

.tape-reel-right {
    animation: rotateTapeRight 12s linear infinite;
}

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

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

.tape-line {
    width: 120px;
    height: 1px;
    background-color: var(--walnut-panel);
}

/* --- The Origin Section --- */
.origin-backdrop {
    position: relative;
    width: 100%;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--console-dark);
    overflow: hidden;
    margin-bottom: 64px;
}

.origin-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, var(--void-black) 100%);
    z-index: 1;
}

/* Simulated vintage photograph via CSS grain + vignette */
.origin-backdrop::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(212, 129, 58, 0.02) 0px,
            transparent 1px,
            transparent 3px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(212, 129, 58, 0.015) 0px,
            transparent 1px,
            transparent 4px
        );
    z-index: 0;
}

/* CRT-like amber glow lines */
.origin-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(166, 92, 40, 0.04) 3px,
        rgba(166, 92, 40, 0.04) 4px
    );
    z-index: 0;
}

.origin-text {
    position: relative;
    z-index: 2;
    text-align: center;
}

.origin-headline {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(3.5rem, 10vw, 8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-terminal);
    text-shadow:
        0 0 40px rgba(212, 129, 58, 0.3),
        2px 2px 0 var(--patina-copper);
    line-height: 1.1;
}

#origin-cursor {
    display: inline-block;
    vertical-align: baseline;
    margin-left: 8px;
    height: 0.7em;
}

/* Origin Cards - centered row */
.origin-cards {
    max-width: 1000px;
    margin: 0 auto;
    justify-content: center;
}

.origin-card {
    border-color: var(--patina-copper);
    background-color: rgba(15, 14, 13, 0.8);
}

.origin-card .card-title {
    text-shadow: 1px 1px 0 var(--patina-copper);
}

/* --- Keyboard Navigation --- */
#keyboard-nav {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 1001;
}

.key-button {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--parchment-light);
    background-color: var(--console-dark);
    border: 2px solid var(--walnut-panel);
    border-bottom-width: 4px;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 150ms ease;
    user-select: none;
}

.key-button:hover {
    border-color: var(--amber-terminal);
    color: var(--amber-terminal);
}

.key-button:active {
    border-bottom-width: 2px;
    transform: translateY(2px);
    background-color: var(--void-black);
}

/* --- Card Entry Animation --- */
@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardEnterRotate {
    from {
        opacity: 0;
        transform: rotate(-0.8deg) translateY(24px);
    }
    to {
        opacity: 1;
        transform: rotate(-0.8deg) translateY(0);
    }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .content-section {
        padding: 48px 16px;
    }

    #terminal-bar {
        padding: 0 16px;
        gap: 12px;
        font-size: 0.7rem;
    }

    .command-card {
        aspect-ratio: auto;
    }

    #keyboard-nav {
        bottom: 12px;
        gap: 4px;
    }

    .key-button {
        padding: 6px 10px;
        font-size: 0.65rem;
    }

    .origin-headline {
        font-size: clamp(2.5rem, 8vw, 5rem);
    }
}
