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

:root {
    --bg-primary: #08080a;
    --bg-secondary: #0e0e12;
    --bg-card: #131318;
    --bg-card-hover: #1a1a22;
    --text-primary: #f0eff4;
    --text-secondary: #d0cdd8;
    --text-muted: #9894a4;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-warm: #818cf8;
    --accent-warm-light: #a5b4fc;
    --gradient: linear-gradient(135deg, #6366f1, #818cf8);
    --gradient-warm: linear-gradient(135deg, #6366f1, #818cf8);
    --gradient-mixed: linear-gradient(135deg, #6366f1 0%, #818cf8 50%, #a5b4fc 100%);
    --gradient-subtle: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(129, 140, 248, 0.08));
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --font-display: 'Outfit', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --nav-height: 76px;
    --radius: 16px;
    --radius-sm: 10px;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-height);
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Ambient floating particles */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.3;
    background-image:
        radial-gradient(1.5px 1.5px at 20% 30%, rgba(99, 102, 241, 0.8), transparent),
        radial-gradient(1px 1px at 40% 70%, rgba(129, 140, 248, 0.6), transparent),
        radial-gradient(1.5px 1.5px at 60% 15%, rgba(129, 140, 248, 0.7), transparent),
        radial-gradient(1px 1px at 80% 55%, rgba(129, 140, 248, 0.5), transparent),
        radial-gradient(2px 2px at 10% 85%, rgba(99, 102, 241, 0.6), transparent),
        radial-gradient(1px 1px at 70% 45%, rgba(129, 140, 248, 0.4), transparent),
        radial-gradient(1.5px 1.5px at 35% 50%, rgba(129, 140, 248, 0.5), transparent),
        radial-gradient(1px 1px at 90% 20%, rgba(129, 140, 248, 0.6), transparent),
        radial-gradient(1.5px 1.5px at 50% 90%, rgba(99, 102, 241, 0.5), transparent),
        radial-gradient(1px 1px at 15% 60%, rgba(129, 140, 248, 0.4), transparent);
    background-size: 500px 500px;
    animation: starFloat 60s linear infinite;
}

@keyframes starFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-400px); }
}

body > * {
    position: relative;
    z-index: 1;
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 28px;
}

/* ===== Navbar ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 1000;
    transition: background 0.4s, backdrop-filter 0.4s, box-shadow 0.4s;
}

.navbar.scrolled {
    background: rgba(8, 8, 10, 0.85);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    box-shadow: 0 1px 0 var(--border), 0 8px 32px rgba(0, 0, 0, 0.3);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 28px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    transition: opacity 0.3s;
}

.nav-logo:hover {
    opacity: 0.8;
}

.logo-j {
    color: var(--accent-warm);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 36px;
}

.nav-links a {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.3s;
    position: relative;
    letter-spacing: 0.02em;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: var(--gradient-warm);
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-links a:hover {
    color: var(--text-primary);
}

.nav-links a:hover::after {
    width: 100%;
}

/* Mobile nav toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 1.5px;
    background: var(--text-primary);
    transition: transform 0.3s, opacity 0.3s;
    border-radius: 1px;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Hero ===== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 120px 28px 100px;
}

.hero-bg-gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 50% -10%, rgba(99, 102, 241, 0.18), transparent),
        radial-gradient(ellipse 50% 40% at 80% 50%, rgba(129, 140, 248, 0.08), transparent),
        radial-gradient(ellipse 40% 30% at 20% 60%, rgba(99, 102, 241, 0.06), transparent);
    animation: gradientPulse 10s ease-in-out infinite alternate;
}

.hero-bg-gradient::before,
.hero-bg-gradient::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
}

.hero-bg-gradient::before {
    width: 500px;
    height: 500px;
    background: rgba(99, 102, 241, 0.1);
    top: 5%;
    left: -15%;
    animation: orbFloat1 14s ease-in-out infinite alternate;
}

.hero-bg-gradient::after {
    width: 350px;
    height: 350px;
    background: rgba(129, 140, 248, 0.06);
    bottom: 10%;
    right: -5%;
    animation: orbFloat2 12s ease-in-out infinite alternate;
}

@keyframes orbFloat1 {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(80px, 40px) scale(1.15); }
    100% { transform: translate(40px, -30px) scale(0.9); }
}

@keyframes orbFloat2 {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-60px, -50px) scale(1.2); }
    100% { transform: translate(-30px, 20px) scale(0.95); }
}

@keyframes gradientPulse {
    0% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.03); }
}

.hero-content {
    position: relative;
    text-align: center;
    max-width: 840px;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 28px;
    letter-spacing: -0.02em;
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.15), 0 0 60px rgba(99, 102, 241, 0.08);
}

.hero-name {
    display: inline-block;
    background: var(--gradient-mixed);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.35)) drop-shadow(0 0 60px rgba(129, 140, 248, 0.15));
}

/* Glitch effect */
.glitch {
    position: relative;
    display: inline-block;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.glitch::before {
    color: var(--accent);
    -webkit-text-fill-color: var(--accent);
    animation: glitch1 5s infinite;
}

.glitch::after {
    color: var(--accent-warm);
    -webkit-text-fill-color: var(--accent-warm);
    animation: glitch2 5s infinite;
}

.hero-name.glitch::before {
    animation: glitch2 6s 1s infinite;
}

.hero-name.glitch::after {
    animation: glitch1 6s 0.5s infinite;
}

@keyframes glitch1 {
    0%, 92%, 100% { opacity: 0; transform: none; }
    93% { opacity: 0.6; transform: translate(-2px, -1px); clip-path: inset(20% 0 60% 0); }
    95% { opacity: 0; }
    97% { opacity: 0.4; transform: translate(2px, 1px); clip-path: inset(50% 0 20% 0); }
    99% { opacity: 0; }
}

@keyframes glitch2 {
    0%, 92%, 100% { opacity: 0; transform: none; }
    94% { opacity: 0.6; transform: translate(2px, 1px); clip-path: inset(40% 0 30% 0); }
    96% { opacity: 0; }
    98% { opacity: 0.4; transform: translate(-1px, -2px); clip-path: inset(10% 0 70% 0); }
}

.hero-description {
    font-size: 1.12rem;
    color: var(--text-secondary);
    max-width: 580px;
    margin: 0 auto 44px;
    line-height: 1.85;
    font-weight: 400;
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 8px 24px;
    background: linear-gradient(325deg, #0044ff 0%, #2ccfff 55%, #0044ff 90%);
    background-size: 280% auto;
    background-position: left center;
    border: none;
    border-radius: 4px;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.95rem;
    color: #fff;
    letter-spacing: 0.02em;
    box-shadow:
        0px 0px 20px rgba(71, 184, 255, 0.5),
        0px 5px 5px -1px rgba(58, 125, 233, 0.25),
        inset 4px 4px 8px rgba(175, 230, 255, 0.5),
        inset -4px -4px 8px rgba(19, 95, 216, 0.35);
    transition: background-position 0.7s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.hero-cta:hover {
    background-position: right top;
    transform: translateY(-2px);
}

.hero-cta:focus-visible {
    outline: none;
    box-shadow:
        0px 0px 20px rgba(71, 184, 255, 0.5),
        0px 5px 5px -1px rgba(58, 125, 233, 0.25),
        inset 4px 4px 8px rgba(175, 230, 255, 0.5),
        inset -4px -4px 8px rgba(19, 95, 216, 0.35),
        0 0 0 2px rgba(96, 165, 250, 0.8);
}

.hero-cta svg {
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.hero-cta:hover svg {
    transform: translateX(4px);
}

/* Scroll indicator — refined vertical line style */
.hero-scroll-indicator {
    position: absolute;
    bottom: 36px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.scroll-line {
    width: 1px;
    height: 48px;
    background: linear-gradient(to bottom, var(--accent-warm), transparent);
    position: relative;
    overflow: hidden;
}

.scroll-line::after {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--accent-warm-light), transparent);
    animation: scrollDrop 2.4s ease-in-out infinite;
}

@keyframes scrollDrop {
    0% { top: -100%; }
    50% { top: 100%; }
    100% { top: 100%; }
}

.hero-scroll-indicator span {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ===== Sections shared ===== */
.section-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.section-label {
    display: block;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent-light);
    margin-bottom: 14px;
}

.section-description {
    text-align: center;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 64px;
    font-size: 1.05rem;
    line-height: 1.8;
}

/* ===== Portfolio ===== */
.portfolio {
    padding: 140px 0;
    position: relative;
}

.portfolio::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-hover), transparent);
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.portfolio-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.5s, border-color 0.5s;
    position: relative;
}

.portfolio-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.05), transparent 40%);
    opacity: 0;
    transition: opacity 0.5s;
    z-index: 1;
    pointer-events: none;
}

.portfolio-item:hover::before {
    opacity: 1;
}

.portfolio-item:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow:
        0 24px 64px rgba(99, 102, 241, 0.12),
        0 0 0 1px rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.2);
}

.portfolio-video {
    position: relative;
    padding-bottom: 177.78%;
    background: #000;
}

.portfolio-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ===== Contact ===== */
.contact {
    padding: 140px 0;
    position: relative;
}

.contact::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-hover), transparent);
}

.contact-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 64px;
    align-items: start;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.hidden-field {
    display: none;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 15px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color 0.4s, box-shadow 0.4s, background 0.4s;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
    background: var(--bg-card-hover);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.form-group textarea {
    resize: vertical;
    min-height: 130px;
}

.form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 36px;
    background: var(--gradient);
    border: none;
    border-radius: 50px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.form-submit::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.form-submit:hover::before {
    opacity: 1;
}

.form-submit:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.35);
}

.form-submit.sent {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    pointer-events: none;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.4s, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s;
}

.contact-card:hover {
    border-color: rgba(99, 102, 241, 0.25);
    transform: translateX(6px);
    box-shadow: -4px 0 24px rgba(99, 102, 241, 0.08);
}

.contact-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    color: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.12);
}

.contact-card h4 {
    font-family: var(--font-display);
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text-primary);
}

.contact-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Footer ===== */
.footer {
    padding: 40px 0;
    border-top: 1px solid var(--border);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-logo {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.footer-brand p {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

.footer-meta {
    text-align: right;
}

.footer-meta p {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.footer .ytunnus {
    margin-top: 4px;
    font-size: 0.72rem;
    opacity: 0.5;
}

/* ===== Animations ===== */
.animate-fade-up {
    opacity: 0;
    transform: translateY(24px);
    animation: fadeInUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.delay-1 { animation-delay: 0.15s; }
.delay-2 { animation-delay: 0.3s; }
.delay-3 { animation-delay: 0.45s; }
.delay-4 { animation-delay: 0.6s; }

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

/* Scroll animations */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered children */
.portfolio-grid .animate-on-scroll:nth-child(2) { transition-delay: 0.1s; }
.portfolio-grid .animate-on-scroll:nth-child(3) { transition-delay: 0.2s; }
.portfolio-grid .animate-on-scroll:nth-child(4) { transition-delay: 0.3s; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: rgba(8, 8, 10, 0.97);
        backdrop-filter: blur(24px);
        flex-direction: column;
        padding: 28px;
        gap: 18px;
        border-bottom: 1px solid var(--border);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-toggle {
        display: flex;
    }

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

    .contact-wrapper {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero {
        padding: 100px 24px 80px;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .footer-meta {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2.2rem;
    }

    .hero-description {
        font-size: 0.98rem;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .portfolio, .contact {
        padding: 100px 0;
    }
}
