/* ============================================
   🫀 DIGITAL PULSE — Cyber-Medical Fusion Design
   Sebastian F. Nestler | Portfolio
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --cursor-x: 0.5;
    --cursor-y: 0.5;
    --accent-hue: 188;
    --accent-sat: 100%;
    --accent-light: 50%;
    --accent: hsl(var(--accent-hue), var(--accent-sat), var(--accent-light));
    --crimson: #ff3355;
    --amber: #ffb347;
    --obsidian: #080c14;
    --obsidian-light: #0d1220;
    --glass-bg: rgba(8, 12, 20, 0.7);
    --glass-border: rgba(255, 255, 255, 0.06);
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
    --font-sans: 'Inter', 'SF Pro Display', system-ui, sans-serif;
}

/* --- Scroll Progress Bar --- */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    z-index: 100;
    background: linear-gradient(90deg, var(--crimson), var(--accent), #7b2fff);
    width: 0%;
    transition: width 0.1s linear;
    will-change: width;
}

/* --- Neural Particle Canvas --- */
#particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* --- Background Grid (subtle, under particles) --- */
#grid-bg {
    background-image: 
        linear-gradient(rgba(0, 242, 254, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 242, 254, 0.08) 1px, transparent 1px);
    background-size: 100px 100px;
    transform: translate(
        calc((var(--cursor-x) - 0.5) * 30px),
        calc((var(--cursor-y) - 0.5) * 30px)
    );
    will-change: transform;
}

/* --- Glitch Text Animation --- */
@keyframes glitch-shift {
    0%, 90%, 100% { transform: translate(0); }
    91% { transform: translate(-2px, 1px); }
    92% { transform: translate(2px, -1px); }
    93% { transform: translate(-1px, 0); }
    94% { transform: translate(1px, 0); }
    95% { transform: translate(0); }
}
.glitch-text {
    animation: glitch-shift 4s infinite ease-in-out;
}
.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, #00F2FE, #4FACFE);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
}
.glitch-text::before {
    animation: glitch-before 4s infinite ease-in-out;
    clip-path: inset(0 0 70% 0);
}
.glitch-text::after {
    animation: glitch-after 4s infinite ease-in-out;
    clip-path: inset(70% 0 0 0);
}
@keyframes glitch-before {
    0%, 90%, 100% { opacity: 0; transform: translate(0); }
    91% { opacity: 0.3; transform: translate(-3px, 0); }
    94% { opacity: 0; transform: translate(0); }
}
@keyframes glitch-after {
    0%, 92%, 100% { opacity: 0; transform: translate(0); }
    93% { opacity: 0.2; transform: translate(3px, 0); }
    96% { opacity: 0; transform: translate(0); }
}

/* --- ECG Waveform SVG --- */
#ecg-waveform {
    width: 100%;
    max-width: 500px;
    height: 60px;
    margin: 0 auto 1.5rem;
    display: block;
}
#ecg-path {
    stroke: var(--accent);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: ecg-draw 2s ease forwards 0.5s;
    filter: drop-shadow(0 0 8px var(--accent));
}
@keyframes ecg-draw {
    to { stroke-dashoffset: 0; }
}
.ecg-pulse-point {
    animation: ecg-blink 1.5s infinite ease-in-out;
}
@keyframes ecg-blink {
    0%, 100% { opacity: 1; r: 4; }
    50% { opacity: 0.3; r: 6; }
}

/* --- 3D Tilt Cards --- */
.tilt-container {
    perspective: 1000px;
    transform-style: preserve-3d;
}
.tilt-card {
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
    transform-style: preserve-3d;
    position: relative;
}
.tilt-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        circle at var(--glare-x, 50%) var(--glare-y, 50%),
        rgba(255, 255, 255, 0.08) 0%,
        transparent 60%
    );
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.tilt-card:hover::after {
    opacity: 1;
}

/* --- Magnetic Buttons --- */
.magnetic-btn {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

/* --- Card Glow with Breathing --- */
.card-glow {
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
    animation: breathe-glow 4s infinite ease-in-out;
}
@keyframes breathe-glow {
    0%, 100% { box-shadow: 0 0 15px rgba(0, 242, 254, 0.05); }
    50% { box-shadow: 0 0 35px rgba(0, 242, 254, 0.15), 0 0 60px rgba(0, 242, 254, 0.05); }
}
.card-glow:hover {
    animation: none;
    box-shadow: 0 0 40px rgba(0, 242, 254, 0.25), 0 0 80px rgba(0, 242, 254, 0.1);
    border-color: rgba(0, 242, 254, 0.5);
}

/* --- Orbital Rings Animation --- */
.orbital-ring {
    position: absolute;
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 50%;
    animation: orbit-spin 12s linear infinite;
    pointer-events: none;
}
.orbital-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
}
@keyframes orbit-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Tags for Tech Stack --- */
.tag {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    color: #cbd5e1;
    transition: all 0.3s ease;
    cursor: default;
}
.tag:hover {
    background: rgba(0, 242, 254, 0.12);
    border-color: rgba(0, 242, 254, 0.4);
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.15);
    transform: translateY(-2px);
}

/* --- Timeline Heartbeat Nodes --- */
.timeline-item {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.timeline-item.revealed {
    opacity: 1;
    transform: translateY(0);
}
.timeline-dot {
    animation: heartbeat 1.2s infinite ease-in-out;
}
.timeline-dot::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    animation: heartbeat-echo 1.2s infinite ease-in-out;
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.3); }
    30% { transform: scale(1); }
    45% { transform: scale(1.25); }
    60% { transform: scale(1); }
}
@keyframes heartbeat-echo {
    0% { opacity: 0.6; transform: scale(1); }
    100% { opacity: 0; transform: scale(2.5); }
}

/* --- Fade-in Animation --- */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s ease forwards;
}
@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.fade-in:nth-child(1) { animation-delay: 0.05s; }
.fade-in:nth-child(2) { animation-delay: 0.15s; }
.fade-in:nth-child(3) { animation-delay: 0.25s; }
.fade-in:nth-child(4) { animation-delay: 0.35s; }
.fade-in:nth-child(5) { animation-delay: 0.45s; }

/* --- Fancy Title Gradient --- */
.fancy-title {
    background: linear-gradient(135deg, var(--accent), #7b2fff, var(--crimson));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
    animation: gradient-shift 8s ease infinite;
}
@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* --- Scroll-Driven Animations --- */
@supports (animation-timeline: view()) {
    .timeline-item {
        animation: reveal linear both;
        animation-timeline: view();
        animation-range: entry 5% cover 25%;
    }
}
@keyframes reveal {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- CRT Terminal Overlay --- */
.crt-scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 45;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
}
.crt-flicker {
    animation: crt-flicker 0.15s infinite;
}
@keyframes crt-flicker {
    0%, 100% { opacity: 0.97; }
    50% { opacity: 1; }
    51% { opacity: 0.98; }
    52% { opacity: 1; }
}
#terminal-mode {
    background: radial-gradient(ellipse at center, #0a1a0a 0%, #050a05 70%, #010301 100%);
    font-family: 'VT323', 'Courier New', monospace;
}
#terminal-input {
    caret-color: #33ff33;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    #ecg-waveform {
        max-width: 320px;
        height: 40px;
    }
    .orbital-ring {
        display: none;
    }
    .tilt-container {
        perspective: 600px;
    }
}