/* =============================================
   ppuzzl.com - Brutalist Retro-Futurism
   ============================================= */

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

:root {
    --deep-bg: #1a1a2e;
    --surface: #16213e;
    --shadow: #2a2a4e;
    --accent-orange: #ff6b35;
    --accent-amber: #e2a642;
    --accent-teal: #0f9b8e;
    --text-primary: #f0ece2;
    --text-secondary: #8d8d9b;
    --alert: #e63462;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-bg);
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
}

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

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* =============================================
   Startup Sequence
   ============================================= */
.startup-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--deep-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.startup-screen.done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.startup-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    background: var(--accent-orange);
    opacity: 0;
    filter: blur(80px);
    border-radius: 50%;
    transition: opacity 1s ease;
}

.startup-screen.glowing .startup-glow {
    opacity: 0.15;
}

.startup-title {
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(3rem, 10vw, 6rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.startup-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateX(0);
}

.startup-title .letter.visible {
    opacity: 1;
    animation: letterShake 0.2s ease-out;
}

@keyframes letterShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.startup-subtitle {
    font-family: 'Archivo Black', sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    margin-top: 1rem;
    min-height: 1.5em;
    position: relative;
    z-index: 1;
}

.startup-subtitle::after {
    content: '|';
    animation: blink 0.6s step-end infinite;
    color: var(--accent-orange);
}

.startup-subtitle.done::after {
    display: none;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* =============================================
   Navigation Control Strip
   ============================================= */
.control-strip {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    z-index: 500;
    background: var(--surface);
    border-right: 2px solid var(--shadow);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.control-strip.visible {
    opacity: 1;
}

.nav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 2px;
    transition: background-color 0.2s ease;
}

.nav-toggle:hover {
    background-color: var(--shadow);
    animation: shake 0.4s ease;
}

.nav-label {
    position: absolute;
    left: 56px;
    background: var(--surface);
    border: 2px solid var(--accent-orange);
    color: var(--accent-orange);
    font-family: 'Archivo Black', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 4px 10px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.nav-toggle:hover .nav-label {
    opacity: 1;
    transform: translateX(0);
}

/* =============================================
   Shake Animation (Signature)
   ============================================= */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
    20%, 40%, 60%, 80% { transform: translateX(3px); }
}

@keyframes shakeSmall {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* =============================================
   Timeline Container
   ============================================= */
.timeline-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 120vh 60px 100px 60px;
    min-height: 100vh;
}

.timeline-spine {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.spine-path {
    stroke-dasharray: 5000;
    stroke-dashoffset: 5000;
    transition: stroke-dashoffset 2s ease-out;
}

.spine-path.drawn {
    stroke-dashoffset: 0;
}

/* Crystalline Background */
.crystalline-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* =============================================
   Timeline Nodes
   ============================================= */
.timeline-node {
    position: relative;
    z-index: 2;
    margin-bottom: 100px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.timeline-node.visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-node.shake-enter {
    animation: shakeSmall 0.2s ease-out;
}

.timeline-node.left {
    width: clamp(280px, 50vw, 520px);
    margin-right: auto;
    padding-right: 40px;
}

.timeline-node.right {
    width: clamp(280px, 50vw, 520px);
    margin-left: auto;
    padding-left: 40px;
}

/* Connector Lines */
.connector-line {
    position: absolute;
    top: 40px;
    height: 4px;
    width: 60px;
}

.timeline-node.left .connector-line {
    right: -30px;
}

.timeline-node.right .connector-line {
    left: -30px;
}

.connector-svg {
    width: 100%;
    height: 100%;
}

.connector-draw {
    transition: stroke-dashoffset 0.4s ease-out;
}

.timeline-node.visible .connector-draw {
    stroke-dashoffset: 0;
}

/* Node Blocks */
.node-block {
    background: var(--surface);
    border: 3px solid var(--deep-bg);
    padding: 30px;
    position: relative;
    box-shadow: 6px 6px 0 var(--shadow);
}

.timeline-node[data-rotate] .node-block {
    transform: rotate(var(--rotation, 0deg));
}

.tab-label {
    position: absolute;
    top: -14px;
    left: 12px;
    background: var(--accent-orange);
    color: var(--deep-bg);
    font-family: 'Permanent Marker', cursive;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 2px 12px;
    transform: rotate(-3deg);
}

.node-title {
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.2;
}

.node-body {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.7;
    max-width: 42ch;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Node Decorations */
.node-decoration {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.deco-led {
    width: 12px;
    height: 12px;
}

.led-glow {
    animation: ledPulse 3s ease-in-out infinite;
}

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

.deco-counter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.deco-toggle {
    width: 24px;
    height: 14px;
}

.deco-dial {
    width: 28px;
    height: 28px;
}

.dial-needle {
    transform-origin: 20px 20px;
    animation: dialSweep 8s ease-in-out infinite;
}

@keyframes dialSweep {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(270deg); }
    100% { transform: rotate(360deg); }
}

/* =============================================
   Puzzle Dividers
   ============================================= */
.puzzle-divider {
    position: relative;
    z-index: 2;
    margin: 40px 0;
    opacity: 0;
    transition: opacity 0.6s ease;
    overflow: hidden;
    height: 40px;
}

.puzzle-divider.visible {
    opacity: 1;
}

.puzzle-divider.visible .puzzle-piece-svg {
    animation: slideInPiece 0.6s ease-out forwards;
}

@keyframes slideInPiece {
    from { transform: translateX(-120px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.puzzle-row {
    width: 100%;
    height: 40px;
}

/* =============================================
   Project Grid
   ============================================= */
.project-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 16px 0;
}

.project-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--shadow);
    transition: border-color 0.3s ease;
}

.project-item:hover {
    border-color: var(--accent-orange);
}

.project-item:hover .project-icon {
    animation: shake 0.4s ease;
}

.project-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.project-item h3 {
    font-family: 'Archivo Black', sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-amber);
    margin-bottom: 4px;
}

.project-item p {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* =============================================
   Process Steps
   ============================================= */
.process-steps {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 16px 0;
}

.process-step {
    padding-left: 60px;
    position: relative;
}

.step-number {
    position: absolute;
    left: 0;
    top: 0;
    font-family: 'Archivo Black', sans-serif;
    font-size: 2rem;
    color: var(--shadow);
    line-height: 1;
}

.process-step h3 {
    font-family: 'Archivo Black', sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-teal);
    margin-bottom: 6px;
}

.process-step p {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.6;
    max-width: 42ch;
}

/* =============================================
   Tangram Puzzle
   ============================================= */
.tangram-container {
    margin: 20px 0;
    position: relative;
}

.tangram-svg {
    width: 100%;
    max-width: 300px;
    height: 300px;
    background: var(--deep-bg);
    border: 2px solid var(--shadow);
    cursor: grab;
}

.tangram-svg:active {
    cursor: grabbing;
}

.tangram-piece {
    cursor: grab;
    transition: filter 0.2s ease;
}

.tangram-piece:hover {
    filter: brightness(1.3);
}

.tangram-piece.placed {
    opacity: 1 !important;
    filter: drop-shadow(0 0 6px var(--accent-orange));
    animation: snapPulse 0.3s ease-out;
}

@keyframes snapPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.tangram-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: 12px;
    letter-spacing: 0.05em;
}

/* =============================================
   Contact Form
   ============================================= */
.contact-form {
    margin-top: 16px;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-family: 'Archivo Black', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-field input,
.form-field textarea {
    width: 100%;
    background: var(--deep-bg);
    border: 2px solid var(--shadow);
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    padding: 10px 14px;
    transition: border-color 0.3s ease;
    outline: none;
}

.form-field input:focus,
.form-field textarea:focus {
    border-color: var(--accent-orange);
}

.form-field textarea {
    resize: vertical;
    min-height: 80px;
}

.form-field input.error,
.form-field textarea.error {
    border-color: var(--alert);
    animation: shake 0.4s ease;
}

.contact-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: 2px solid var(--shadow);
    padding: 10px 20px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.contact-toggle:hover {
    border-color: var(--accent-orange);
    animation: shake 0.4s ease;
}

.toggle-switch-svg {
    width: 60px;
    height: 28px;
}

.toggle-knob {
    transition: cx 0.3s ease;
}

.contact-toggle.active .toggle-knob {
    cx: 58;
}

.contact-toggle.active rect {
    stroke: var(--accent-orange);
}

.toggle-label {
    font-family: 'Archivo Black', sans-serif;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-orange);
}

/* =============================================
   Footer
   ============================================= */
.timeline-footer {
    position: relative;
    z-index: 2;
    margin-top: 80px;
    padding: 40px 0;
    border-top: 2px solid var(--shadow);
}

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

.footer-logo {
    width: 120px;
    height: 30px;
}

.footer-text {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.footer-counters {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-led {
    width: 12px;
    height: 12px;
}

/* =============================================
   Crystalline Patterns (generated by JS)
   ============================================= */
.crystal-cluster {
    position: absolute;
    opacity: 0.08;
    pointer-events: none;
}

.crystal-cluster svg {
    width: 100%;
    height: 100%;
}

/* =============================================
   Mobile Responsive
   ============================================= */
@media (max-width: 768px) {
    .control-strip {
        display: none;
    }

    .timeline-container {
        padding: 120vh 20px 60px 40px;
    }

    .timeline-spine {
        left: 20px;
        transform: none;
    }

    .timeline-node.left,
    .timeline-node.right {
        width: calc(100% - 40px);
        margin-left: 30px;
        margin-right: 0;
        padding-left: 20px;
        padding-right: 0;
    }

    .timeline-node.left .connector-line,
    .timeline-node.right .connector-line {
        left: -30px;
        right: auto;
    }

    .node-block {
        box-shadow: 4px 4px 0 var(--shadow);
    }

    .node-title {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
    }

    .project-item {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .timeline-container {
        padding: 110vh 12px 40px 32px;
    }

    .timeline-node.left,
    .timeline-node.right {
        width: calc(100% - 24px);
        margin-left: 20px;
    }

    .node-block {
        padding: 20px;
    }
}
