@font-face {
    font-family: 'Oxygen Mono';
    src: url('../fonts/OxygenMono-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: optional;
}

@font-face {
    font-family: 'Oxygen';
    src: url('../fonts/Oxygen-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: optional;
}

@font-face {
    font-family: 'Oxygen';
    src: url('../fonts/Oxygen-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: optional;
}

:root {
    --black: #0D0D0D;
    --dkblue: #1a1f35;
    --plum: #2d3561;
    --hotmag: #00d9ff;
    --magenta: #8599dd;
    --aqua: #00d9ff;
    --white: #f7f8fa;
    --font-size: 1.3rem;
    --mono: "Oxygen mono", monospace;
    --sans: "Oxygen", sans-serif;

    /* Stjärnsystem */
    --star-color-bright: rgba(255, 255, 255, 0.75);
    --star-color-medium: rgba(255, 255, 255, 0.7);
    --star-color-dim: rgba(255, 255, 255, 0.5);
    --star-color-faint: rgba(255, 255, 255, 0.3);
}

html {
    box-sizing: border-box;
    scroll-behavior: smooth;
}
*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    padding: 0;
    padding-top: 90px; /* Kompensera för fixed navbar */
    margin: 0;
    font-family: var(--mono);
    font-weight: 400;
    font-style: normal;
    background-color: var(--black);
    color: var(--white);
    font-size: var(--font-size);
    position: relative; /* Skapar positioning context för body::before */
}

/* Stjärnhimmel runt hero/header */
body::before {
    content: ' ';
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    background: transparent;
    opacity: var(--stars-opacity, 1);
    transition: opacity 0.3s ease;
    box-shadow:
        /* Stora ljusa stjärnor (9) */
        5vw 5vh 2px 1px var(--star-color-bright),
        2vw 25vh 2px 1px var(--star-color-bright),
        8vw 48vh 2px 1px var(--star-color-bright),
        45vw 12vh 2px 1px var(--star-color-bright),
        55vw 65vh 2px 1px var(--star-color-bright),
        92vw 8vh 2px 1px var(--star-color-bright),
        78vw 35vh 2px 1px var(--star-color-bright),
        88vw 70vh 2px 1px var(--star-color-bright),
        15vw 88vh 2px 1px var(--star-color-bright),
        /* Medium stjärnor (10) */
        12vw 10vh 1px 0.5px var(--star-color-medium),
        25vw 30vh 1px 0.5px var(--star-color-medium),
        48vw 15vh 1px 0.5px var(--star-color-medium),
        82vw 22vh 1px 0.5px var(--star-color-medium),
        35vw 55vh 1px 0.5px var(--star-color-medium),
        52vw 75vh 1px 0.5px var(--star-color-medium),
        70vw 60vh 1px 0.5px var(--star-color-medium),
        3vw 95vh 1px 0.5px var(--star-color-medium),
        42vw 82vh 1px 0.5px var(--star-color-medium),
        68vw 40vh 1px 0.5px var(--star-color-medium),
        /* Små stjärnor (6) */
        32vw 18vh 1px 0.3px var(--star-color-faint),
        72vw 45vh 1px 0.3px var(--star-color-faint),
        20vw 68vh 1px 0.3px var(--star-color-dim),
        58vw 90vh 1px 0.3px var(--star-color-dim),
        28vw 52vh 1px 0.3px var(--star-color-faint),
        80vw 78vh 1px 0.3px var(--star-color-faint);
    animation: starTwinkle1 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 999;
}

body::after {
    content: ' ';
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    background: transparent;
    opacity: var(--stars-opacity, 1);
    transition: opacity 0.3s ease;
    box-shadow:
        /* Extra stjärnor med annan timing */
        18vw 8vh 1px 0.5px var(--star-color-medium),
        38vw 25vh 1px 0.5px var(--star-color-medium),
        62vw 38vh 1px 0.5px var(--star-color-medium),
        85vw 52vh 1px 0.5px var(--star-color-medium),
        10vw 72vh 1px 0.5px var(--star-color-medium),
        50vw 85vh 1px 0.5px var(--star-color-medium),
        75vw 18vh 1px 0.3px var(--star-color-faint),
        30vw 42vh 1px 0.3px var(--star-color-faint),
        60vw 68vh 1px 0.3px var(--star-color-faint),
        95vw 78vh 1px 0.3px var(--star-color-faint);
    animation: starTwinkle2 5s ease-in-out infinite 1.5s;
    pointer-events: none;
    z-index: 999;
}

html, body {
    max-width: 100%;
    overflow-x: clip;
}

h1, h2, h3 {
    margin: 0;
}

a {
    color: var(--magenta);
}

a:hover {
    color: var(--hotmag);
    text-decoration: none;
}

/* Skip-to-content link (WCAG 2.1) - dold tills fokuserad */
.skip-to-content {
    position: fixed;
    top: -100px;
    left: 0;
    background: var(--aqua);
    color: var(--black);
    padding: 0.75rem 1rem;
    text-decoration: none;
    font-weight: bold;
    z-index: 9999; /* Högsta nivå för accessibility - reducerat från 10000 */
    border-radius: 0 0 5px 0;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 0;
    outline: 2px solid var(--white);
    outline-offset: 2px;
}

/* Screen reader only - dölj visuellt men tillgänglig för skärmläsare */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Nav-stilar */

#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(13, 13, 13, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 2000;
    width: 100%;
    transition: box-shadow 0.3s ease, border-bottom 0.3s ease;
}

#header.scrolled {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(0, 217, 255, 0.1);
}

nav {
    font-family: var(--mono);
    font-size: 80%;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

nav h1 a {
    font-family: var(--sans);
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-flow: row wrap;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

nav li:first-child {
    flex-basis: 100%;
    text-align: center;
}

nav .fa- {
    height: 2rem;
    width: auto;
    vertical-align: middle;
    filter: invert(86%) sepia(25%) saturate(179%) hue-rotate(345deg) brightness(95%) contrast(81%);
}

nav .colorful {
    filter: invert(86%) sepia(25%) saturate(179%) hue-rotate(345deg) brightness(95%) contrast(81%);
    position: relative;
    top: -6px;
}

nav a .home-mobile {
    filter: invert(86%) sepia(25%) saturate(179%) hue-rotate(345deg) brightness(95%) contrast(81%);
}

nav a .home-mobile:hover {
    filter: invert(67%) sepia(92%) saturate(2878%) hue-rotate(158deg) brightness(102%) contrast(101%);
}

nav h1 [class*="fa-"] {
    font-size: 100%;
    color: var(--aqua);
}

nav a {
    color: var(--white);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

nav a:hover,
nav .fa-:hover {
    color: var(--hotmag);
}

nav a:focus {
    outline: 2px solid var(--aqua);
    outline-offset: 4px;
    transform: scale(1.05);
}

nav .fa-:hover {
    filter: invert(67%) sepia(92%) saturate(2878%) hue-rotate(158deg) brightness(102%) contrast(101%);
}

nav .colorful:hover {
    filter: invert(67%) sepia(92%) saturate(2878%) hue-rotate(158deg) brightness(102%) contrast(101%);
}

.hamburger {
    background: transparent;
    border: none;
    color: inherit;
    font: inherit;
    padding: 0;
    display: none;
}

.hamburger:focus {
    outline: 2px solid var(--aqua);
    outline-offset: 4px;
}

.home-mobile {
    display: none;
}

.button {
    background-color: deepskyblue;
    padding: 0.75rem 1rem; /* Ökat från 0.25rem för att uppnå minst 44x44px touch target (WCAG 2.1) */
    border-radius: 5px;
    color: var(--black);
    border: none;
    min-height: 44px; /* Garanterar WCAG 2.1 Level AAA touch target på alla skärmstorlekar */
    min-width: 44px;
}

.button:hover {
    color: var(--black);
    background-color: var(--hotmag);
}

.button:focus {
    outline: 2px solid var(--aqua);
    outline-offset: 4px;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.6);
}

.button-pulse {
    animation: pulse 2.5s ease-in-out infinite;
    will-change: transform, box-shadow;
    position: relative;
    z-index: 10;
}
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 217, 255, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(0, 217, 255, 0);
    }
}

@media (min-width: 850px) {
    .logoName {
        visibility: visible;
    }
}

@media (max-width: 849px) {
    /* Dölj hemknappen helt på mobil - visa bara hamburgare */
    nav a .home-mobile {
        display: none !important;
    }

    .logoName {
        visibility: hidden;
    }

    /* Ge navbar mer höjd på mobil */
    nav {
        padding: 1.5rem 1rem;
        min-height: 70px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hamburger {
        display: block;
        cursor: pointer;
        position: absolute; /* Fixar elementet i förhållande till viewporten */
        top: 50%; /* Centrera vertikalt */
        transform: translateY(-50%); /* Perfekt centrering */
        right: 20px; /* Ökar avståndet från höger för att göra ikonen mer synlig */
        z-index: 1000; /* Ser till att menyn ligger över andra element */
        padding: 14px; /* Ökat till 14px för att säkerställa minst 44x44px touch target (WCAG 2.1 Level AAA) */
    }

    .bar {
        display: block;
        width: 35px; /* Anpassa bredden efter behov */
        height: 4px; /* Anpassa höjden efter behov */
        background-color: var(--white);
        margin: 5px auto; /* Centrerar strecken inuti .hamburger */
        -webkit-transition: all 0.3s ease-in-out;
        transition: all 0.3s ease-in-out;
    }

    .hamburger.active .bar:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active .bar:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }

    .hamburger.active .bar:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    .nav-menu {
        position: fixed;
        top: -200%; /* Startposition utanför skärmen (uppifrån) */
        left: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        background: linear-gradient(180deg, rgba(13, 13, 13, 0.98) 0%, rgba(26, 31, 53, 0.98) 100%);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        padding-top: 20%;
        display: grid; /* Alltid grid för smooth transitions */
        visibility: hidden; /* Dold för skärmläsare och tangentbord */
        pointer-events: none; /* Förhindrar interaktion när stängd */
        opacity: 0; /* Transparent när stängd */
        transition: top 0.5s ease-in-out, opacity 0.3s ease, visibility 0.3s ease; /* Övergång för top, opacity och visibility */
        align-items: center; /* Centrera innehållet vertikalt */
        justify-content: center; /* Centrera innehållet horisontellt */
        grid-template-columns: 1fr;
        grid-template-rows: repeat(5, 1fr);
    }

    /* Overlay för djup-effekt */
    .nav-menu::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: radial-gradient(circle at top right, rgba(0, 217, 255, 0.08), transparent 50%);
        pointer-events: none;
    }

    .nav-menu li {
        margin: 16px 0;
        opacity: 0;
        transform: translateY(-20px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    /* Staggered animation - varje länk flyger in uppifrån */
    .nav-menu.active li:nth-child(1) {
        transition-delay: 0.1s;
        opacity: 1;
        transform: translateY(0);
    }
    .nav-menu.active li:nth-child(2) {
        transition-delay: 0.15s;
        opacity: 1;
        transform: translateY(0);
    }
    .nav-menu.active li:nth-child(3) {
        transition-delay: 0.2s;
        opacity: 1;
        transform: translateY(0);
    }
    .nav-menu.active li:nth-child(4) {
        transition-delay: 0.25s;
        opacity: 1;
        transform: translateY(0);
    }
    .nav-menu.active li:nth-child(5) {
        transition-delay: 0.3s;
        opacity: 1;
        transform: translateY(0);
    }

    .nav-menu a {
        padding: 12px 20px;
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-menu.active {
        top: 0; /* När aktiv, flyttas den till toppen av skärmen */
        visibility: visible; /* Synlig för skärmläsare och tangentbord */
        pointer-events: auto; /* Tillåt interaktion när öppen */
        opacity: 1; /* Opacitet ändras till 1 när aktiv */
        z-index: 3000; /* Ligger över #header (2000) när öppen */
    }

    .nav-menu ul {
        display: flex;
        flex-flow: column wrap;
        justify-content: center; /* Centrera innehållet vertikalt */
        gap: 1rem;
    }
}

/* Intro-stilar */

#intro {
    padding: 0.5rem 1.5rem 10rem 1.5rem;
    width: 100%;
    margin: 0 auto;
    position: relative;
}


/* Stjärn-twinkle animationer med olika patterns */
@keyframes starTwinkle1 {
    0%, 100% {
        opacity: 1;
    }
    20% {
        opacity: 0.8;
    }
    40% {
        opacity: 1;
    }
    60% {
        opacity: 0.6;
    }
    80% {
        opacity: 0.9;
    }
}

@keyframes starTwinkle2 {
    0%, 100% {
        opacity: 0.9;
    }
    25% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    75% {
        opacity: 0.95;
    }
}

/* Accessibility: respektera användarens motion-preferenser */
@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after,
    .button-pulse,
    .button-wiggle {
        animation: none !important;
    }
}

/* Borttaget: #intro > * position: relative som blockerade stjärnorna */

#intro p {
    font-family: var(--mono);
    font-size: 1rem;
    line-height: 1.5;
}

#intro .name {
    font-family: var(--mono);
    font-size: clamp(1.1rem, 2.4vw, 1.4rem);
    margin-bottom: 1.5rem;
}

.name span {
    font-family: var(--sans);
    font-size: clamp(2.5rem, 8vw, 4rem);
    color: var(--aqua);
    display: block;
}

#intro h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: normal;
}

#element {
    min-height: 4rem;
    height: 4rem;
    line-height: 1.3;
    display: flex;
    align-items: flex-start;
    margin: 0 0 2rem 0;
    padding: 0.25rem 0;
    border: 1px solid transparent;
    overflow: visible;
}

.rolling-text {
    color: var(--aqua);
    font-size: 4rem;
    opacity: 0;
    visibility: hidden;
    font-family: var(--sans);
    transition: visibility 0s, opacity 2s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0;
    }
    25%, 75% {
        opacity: 1;
    }
}

/* Intro Grid Layout */
.intro-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 3rem;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.intro-headshot {
    position: relative;
    z-index: 3;
}

.intro-headshot img {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--aqua);
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.8);
    background: rgba(13, 13, 13, 0.65);
}

.intro-content {
    position: relative;
    z-index: 2;
}

/* Highlight Box */
.intro-highlight {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 600;
    color: var(--aqua);
    background: rgba(0, 217, 255, 0.1);
    padding: 1.5rem;
    border-left: 4px solid var(--aqua);
    margin: 2rem 0;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.2);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin: 2.5rem 0;
    text-align: center;
}

.stat-item {
    padding: 1rem;
    background: rgba(0, 217, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(0, 217, 255, 0.2);
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: rgba(0, 217, 255, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.3);
}

.stat-number {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: bold;
    color: var(--aqua);
    font-family: var(--sans);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--grey);
    font-family: var(--mono);
}

/* Tech Stack Badges */
.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 2rem 0;
}

.tech-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(0, 217, 255, 0.1);
    border: 1px solid var(--aqua);
    border-radius: 20px;
    color: var(--aqua);
    font-family: var(--mono);
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

/* Removed hover effect - tech badges are not interactive */

/* NoScript Contact Fallback */
.noscript-contact {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(0, 217, 255, 0.1);
    border: 2px solid var(--aqua);
    border-radius: 10px;
    text-align: center;
}

.noscript-email {
    display: inline-block;
    font-size: 1.2rem;
    color: var(--aqua);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.noscript-email:hover {
    color: var(--white);
}

/* CTA Group */
.cta-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.cta-primary {
    display: inline-block;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--aqua), var(--hotmag));
    color: var(--white);
    text-decoration: none;
    border-radius: 30px;
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.4);
}

.cta-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 217, 255, 0.6);
    color: var(--white);
}

.cta-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.5);
}

.cta-secondary {
    display: inline-block;
    padding: 1rem 2rem;
    background: transparent;
    color: var(--aqua);
    text-decoration: none;
    border-radius: 30px;
    border: 2px solid var(--aqua);
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.cta-secondary:hover {
    background: rgba(0, 217, 255, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.3);
}

.cta-secondary:active {
    transform: translateY(-1px);
    background: rgba(0, 217, 255, 0.2);
}

.scroll-to-projects {
    display: inline-block;
    margin: 2rem auto 0 auto;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--aqua), var(--hotmag));
    color: var(--white);
    text-decoration: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.1rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.4);
}

.scroll-to-projects:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 217, 255, 0.6);
    color: var(--white);
}

/* Projects-stilar */

.projectBackground {
    background-color: var(--dkblue);
    scroll-snap-type: y mandatory;
    overflow-y: auto;
    box-shadow:
        0 -80px 150px 60px rgba(26, 31, 53, 0.9),
        0 80px 150px 60px rgba(26, 31, 53, 0.9);
    position: relative;
    z-index: 1000;
}

.project-label {
    color: var(--aqua);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

article {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 2rem 0;
}

#projects {
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
    scroll-margin-top: clamp(96px, 14vh, 160px);
}

#projects h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    padding-top: 2rem;
    scroll-snap-align: start;
}

#projects h3 {
    color: var(--aqua);
    margin: 0;
    font-family: var(--mono);
}

#projects h4 {
    font-size: 1rem;
    font-family: var(--mono);
}

.blackBox {
    background: linear-gradient(135deg, var(--dkblue) 0%, var(--plum) 100%);
    border: 2px solid var(--aqua);
    padding: 1rem;
    border-radius: 15px;
    color: var(--white);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-box-shadow: 0 10px 30px rgba(0, 217, 255, 0.3);
    box-shadow: 0 10px 30px rgba(0, 217, 255, 0.3);
    transition: all 0.3s ease;
}

.blackBox:hover {
    transform: translateY(-5px);
    -webkit-box-shadow: 0 15px 40px rgba(0, 217, 255, 0.5);
    box-shadow: 0 15px 40px rgba(0, 217, 255, 0.5);
}

#projects ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-flow: row wrap;
    justify-content: flex-start;
    gap: 1rem;
    font-size: 1rem;
    font-family: var(--mono);
}

#projects img {
    margin: 2rem 0;
    border-left: 1px solid var(--aqua);
    border-top: 1px solid var(--aqua);
    border-radius: 25px;
    padding: 1rem;
    -webkit-box-shadow: 1px 15px 31.5px -6px #000000;
    box-shadow: 1px 15px 31.5px -6px #000000;
    width: 100%;
    height: auto;
}

#homeassistant img {
    width: 100%;
    height: auto;
}

#second img {
    width: 100%;
    height: auto;
}

#third img {
    width: 100%;
    height: auto;
}

#fourth img {
    width: 100%;
    height: auto;
}

/* Media query för desktop-läge med grid-layout (min-width: 850px) */
@media (min-width: 850px) {
    article {
        display: grid;
        grid-template-columns: repeat(10, 1fr);
        gap: 1rem;
        align-items: center;
        min-height: 100vh;
        padding: 4rem 0;
    }

    /* Home Assistant projekt */
    #projects #homeassistant img {
        grid-column: 1 / 6;
        grid-row: 1/2;
    }
    #homeassistant .text {
        grid-column: 5/11;
        grid-row: 1/2;
        order: 2;
        text-align: right;
        font-family: var(--mono);
    }
    #projects #homeassistant .blackBox {
        z-index: 10; /* Reducerat från 1000000 - endast behöver ligga över bilden (z-index: 0) */
    }
    #projects #homeassistant ul {
        justify-content: flex-end;
    }

    /* Andra artikeln */
    #projects #second img {
        grid-column: 5 / 11;
        grid-row: 1/2;
        z-index: 0;
    }
    #second .text {
        grid-column: 1/6;
        grid-row: 1/2;
        order: 1;
        text-align: left;
        font-family: var(--mono);
        position: relative;
        z-index: 20; /* Text-containern ligger över bilden */
    }
    #projects #second .blackBox {
        z-index: 10; /* Reducerat från 1000000 - endast behöver ligga över bilden */
    }
    #projects #second ul {
        justify-content: flex-start;
    }

    /* Tredje artikeln */
    #projects #third img {
        grid-column: 1 / 6;
        grid-row: 1/2;
    }
    #third .text {
        grid-column: 5/11;
        grid-row: 1/2;
        order: 2;
        text-align: right;
        font-family: var(--mono);
    }
    #projects #third ul {
        justify-content: flex-end;
    }

    /* Fjärde artikeln – layoutexempel med bilden till höger (likt andra artikeln) */
    #projects #fourth img {
        grid-column: 5 / 11;
        grid-row: 1/2;
    }
    #fourth .text {
        grid-column: 1/6;
        grid-row: 1/2;
        order: 1;
        text-align: left;
        font-family: var(--mono);
    }
    #projects #fourth ul {
        justify-content: flex-start;
    }
}

/* Contact-stilar */

#contact {
    background-color: var(--aqua);
    box-shadow: 0 -100px 180px 70px rgba(0, 217, 255, 0.4);
    margin: 0;
    width: 100%;
    padding: clamp(3rem, 6vw, 5rem) clamp(1.5rem, 6vw, 7rem) clamp(6rem, 10vw, 9rem);
    text-align: center;
    display: grid;
    gap: 2rem;
    justify-items: center;
    scroll-margin-top: clamp(96px, 14vh, 160px);
}

#contact > * {
    max-width: min(100%, 1200px);
}

#contact > button {
    max-width: none;
}

#contact h2 {
    font-size: clamp(2rem, 3vw, 2.6rem);
    color: var(--black);
    margin: 0;
}

#contact p {
    margin: 0 auto;
}

#contact noscript {
    max-width: min(100%, 1200px);
    margin: 0 auto;
}

#contact .noscript-contact {
    margin: 0 auto;
}

.button-wiggle {
    position: relative;
    animation: contactPulse 3.5s ease-in-out infinite;
    will-change: transform, box-shadow;
}

@keyframes contactPulse {
    0%,
    100% {
        transform: translateY(0);
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12), 0 0 0 0 rgba(0, 217, 255, 0.0);
    }
    45% {
        transform: translateY(-4px);
        box-shadow: 0 28px 45px rgba(0, 0, 0, 0.18), 0 0 0 16px rgba(0, 217, 255, 0.15);
    }
    60% {
        transform: translateY(-2px);
        box-shadow: 0 22px 42px rgba(0, 0, 0, 0.18), 0 0 0 10px rgba(0, 217, 255, 0.1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .button-wiggle {
        animation: none;
    }
}

.contactPopUp {
    background-color: deepskyblue;
    display: flex;
    justify-content: center;
    border: none;
    align-items: center;
    padding: 1rem clamp(2rem, 10vw, 5rem);
    border-radius: 10px;
    color: var(--black);
    font-size: clamp(0.9rem, 2vw, 1rem);
    line-height: 1.5;
    font-weight: bold;
    margin: 0 auto 2rem auto;
    cursor: pointer;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14), 0 0 0 0 rgba(0, 217, 255, 0.0);
    transition: transform 0.3s ease, box-shadow 0.4s ease, background-color 0.3s ease, color 0.3s ease;
}

.contactPopUp:hover {
    background-color: var(--hotmag);
    color: var(--black);
    transform: translateY(-3px);
    box-shadow: 0 26px 48px rgba(0, 0, 0, 0.22), 0 0 0 14px rgba(0, 217, 255, 0.2);
}

.contactPopUp:focus {
    outline: 2px solid var(--aqua);
    outline-offset: 4px;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.6);
}

#contact p:last-child {
    margin-top: 3rem;
}

/* Footer-stilar */

footer {
    padding: 8rem 1rem 2rem 1rem;
    font-family: var(--mono);
    font-size: 80%;
    color: var(--white);
    text-align: center;
}

footer h1 {
    font-family: var(--sans);
    text-align: center;
}

footer ul {
    list-style-type: none;
    margin: 0 auto;
    padding: 2.5rem 0 1rem 0;
    display: flex;
    flex-flow: row wrap;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

footer .fa- {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-flow: row wrap;
    justify-content: center;
    gap: 3rem;
    font-size: 3rem;
    height: 3rem;
    width: auto;
    vertical-align: middle;
    filter: invert(86%) sepia(25%) saturate(179%) hue-rotate(345deg) brightness(95%) contrast(81%);
}

footer a {
    text-decoration: none;
}

footer .fa-:hover {
    color: var(--hotmag);
    filter: invert(67%) sepia(92%) saturate(2878%) hue-rotate(158deg) brightness(102%) contrast(101%);
    list-style-type: none;
    text-decoration: none;
}

footer p {
    text-align: center;
}

/* Footer email styling (WCAG 2.1 - no inline styles) */
footer .footer-email {
    margin-top: 1rem;
    font-family: var(--mono);
    color: var(--aqua);
}

footer .footer-email-link {
    color: var(--aqua);
    text-decoration: none;
}

/* Media query för bredare skärmar (min-width: 850px) */
@media (min-width: 850px) {
    nav {
        max-width: 1200px;
        margin: 0 auto;
    }
    nav li:first-child {
        flex-basis: auto;
        text-align: left;
        margin-right: auto;
    }

    /* Intro på desktop */
    #intro {
        margin-top: 0;
        padding: 5rem 3rem 8rem;
        min-height: calc(100vh - 2rem);
        min-height: calc(100dvh - 2rem);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #intro .intro-grid {
        width: 100%;
    }
}

/* Popup-stilar */

.custom-popup {
    background: linear-gradient(135deg, var(--dkblue) 0%, var(--plum) 100%) !important;
    border-radius: 20px;
    color: white !important;
    font-family: 'Oxygen Mono', monospace;
    font-size: 1rem;
    border: 2px solid var(--aqua);
    box-shadow: 0 20px 60px rgba(0, 217, 255, 0.3),
                0 0 40px rgba(0, 217, 255, 0.1) !important;
    padding: 1.5rem !important;
    max-width: min(600px, 90vw) !important;
    width: auto !important;
}

.custom-popup .swal2-title {
    color: var(--aqua) !important;
    font-weight: bold;
    font-size: clamp(1.3rem, 4vw, 2rem) !important;
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    margin-bottom: 1rem !important;
}

.custom-confirm-button {
    background: linear-gradient(135deg, var(--aqua), var(--hotmag)) !important;
    border: none;
    border-radius: 10px;
    padding: 12px 30px !important;
    font-weight: bold;
    font-size: 1.1rem !important;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.4);
}

.custom-confirm-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 217, 255, 0.6) !important;
}

.custom-cancel-button {
    background-color: transparent !important;
    color: var(--aqua) !important;
    border: 2px solid var(--aqua) !important;
    border-radius: 10px;
    padding: 12px 30px !important;
    font-weight: bold;
    font-size: 1.1rem !important;
    transition: all 0.3s ease;
}

.custom-cancel-button:hover {
    background-color: rgba(0, 217, 255, 0.1) !important;
    transform: translateY(-2px);
}

.swal2-input {
    margin: 0.5rem 0 !important;
    border: 2px solid var(--aqua);
    border-radius: 10px;
    padding: 0.75rem !important;
    font-family: 'Oxygen Mono', monospace;
    font-size: 1rem !important;
    color: white !important;
    background-color: rgba(26, 31, 53, 0.6) !important;
    transition: all 0.3s ease;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.swal2-input:focus {
    outline: none;
    border-color: var(--hotmag);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5);
    background-color: rgba(26, 31, 53, 0.8) !important;
}

.swal2-textarea {
    font-family: 'Oxygen Mono', monospace;
    font-size: 1rem !important;
    color: white !important;
    border: 2px solid var(--aqua);
    border-radius: 10px;
    padding: 0.75rem !important;
    margin: 0.5rem 0 !important;
    background-color: rgba(26, 31, 53, 0.6) !important;
    min-height: 100px !important;
    resize: vertical;
    transition: all 0.3s ease;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.swal2-textarea:focus {
    outline: none;
    border-color: var(--hotmag);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5);
    background-color: rgba(26, 31, 53, 0.8) !important;
}

.swal2-html-container {
    color: white !important;
}

.swal2-footer {
    border-top: 1px solid rgba(0, 217, 255, 0.3);
    color: var(--aqua) !important;
}

.swal2-validation-message {
    background-color: rgba(255, 77, 77, 0.9) !important;
    color: white !important;
    border-radius: 10px;
}

@media (max-width: 600px) {
    .custom-popup {
        padding: 1rem !important;
        max-width: 95vw !important;
    }

    .custom-popup .swal2-title {
        font-size: 1.3rem !important;
        margin-bottom: 0.5rem !important;
    }

    .custom-confirm-button,
    .custom-cancel-button {
        padding: 10px 20px !important;
        font-size: 0.95rem !important;
    }

    .swal2-input,
    .swal2-textarea {
        font-size: 0.95rem !important;
        padding: 0.65rem !important;
        margin: 0.4rem 0 !important;
    }

    .swal2-textarea {
        min-height: 80px !important;
    }

    .swal2-html-container {
        margin: 0.5rem 0 !important;
    }
}

@media (min-width: 601px) and (max-width: 768px) {
    .custom-popup {
        max-width: 85vw !important;
    }
}

/* Tablet breakpoint */
@media screen and (min-width: 600px) and (max-width: 849px) {
    #intro {
        padding: 1rem 1.5rem 8rem 1.5rem;
    }

    .intro-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .intro-headshot {
        margin: 0 auto;
    }

    .intro-headshot img {
        width: 180px;
        height: 180px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .cta-group {
        flex-direction: column;
        gap: 1rem;
    }

    .cta-primary,
    .cta-secondary {
        width: 100%;
        text-align: center;
    }

    /* Stäng av grid på tablet - stapla element vertikalt */
    article {
        display: flex !important;
        flex-direction: column !important;
        padding: 3rem 0;
    }

    #projects .text,
    #projects img {
        width: 100%;
        order: unset !important;
        grid-column: unset !important;
        grid-row: unset !important;
    }

    /* Text kommer alltid först, sedan bilden */
    #projects .text {
        order: 1 !important;
    }

    #projects img {
        order: 2 !important;
    }

    /* Återställ textjustering till vänster på tablet */
    #projects .text {
        text-align: left !important;
    }

    /* Se till att tech-listor ligger till vänster */
    #projects ul {
        justify-content: flex-start !important;
    }

    #projects h1 {
        font-size: 2rem;
    }

    .blackBox {
        padding: 1.5rem;
    }

    #contact h2 {
        font-size: 1.8rem;
    }

    #contact p {
        font-size: 1.3rem;
    }
}

/* Media queries för mobilskärmar */
@media screen and (max-width: 600px) {
    /* Minska header margin på mobil */
    #header {
        margin-bottom: 2rem;
    }

    #projects {
        width: 100%;
        padding: 2rem 10px;
    }

    #projects h1 {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }

    /* Stäng av grid på mobil - stapla element vertikalt */
    article {
        display: flex !important;
        flex-direction: column !important;
        padding: 2rem 0;
    }

    #projects .text,
    #projects img {
        width: 100%;
        padding: 10px 0;
        order: unset !important;
        grid-column: unset !important;
        grid-row: unset !important;
    }

    /* Text kommer alltid först, sedan bilden */
    #projects .text {
        order: 1 !important;
    }

    #projects img {
        order: 2 !important;
    }

    /* Återställ textjustering till vänster på mobil */
    #projects .text {
        text-align: left !important;
    }

    /* Se till att tech-listor ligger till vänster */
    #projects ul {
        justify-content: flex-start !important;
    }

    .gradient-project,
    .gradient,
    .gradientTheOtherWay {
        width: 100%;
    }

    .blackBox {
        width: 100%;
        padding: 1rem;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    #intro {
        padding: 0 1.5rem 3rem 1.5rem;
    }

    .intro-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }

    .intro-headshot {
        margin: 0 auto;
    }

    .intro-headshot img {
        width: 150px;
        height: 150px;
    }

    .intro-highlight {
        font-size: 1.1rem;
        padding: 1.2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-number {
        font-size: 2rem;
    }

    .tech-stack {
        justify-content: center;
        gap: 0.5rem;
    }

    .tech-badge {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    .cta-group {
        flex-direction: column;
        gap: 1rem;
    }

    .cta-primary,
    .cta-secondary {
        width: 100%;
        text-align: center;
        font-size: 0.95rem;
        padding: 0.9rem 1.5rem;
    }

    #intro .name {
        margin-bottom: 1rem;
    }

    #intro p {
        font-size: 0.9rem;
        margin: 0.9rem 0;
        line-height: 1.5;
    }

    #element {
        height: 3rem;
        min-height: 3rem;
        margin: 0 0 1rem 0;
        padding: 0.25rem 0;
    }

    .scroll-to-projects {
        font-size: 1rem;
        padding: 0.9rem 1.8rem;
    }

    #contact h2 {
        font-size: 1.5rem;
        padding: 1.5rem;
    }

    #contact p {
        font-size: 1.1rem;
        padding: 1rem;
    }
}

/* Image Lightbox för mobil */
@media (max-width: 849px) {
    #projects img {
        cursor: pointer;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    #projects img:hover {
        transform: scale(1.02);
    }

    #projects img:active {
        transform: scale(0.98);
    }
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.lightbox.active .lightbox-content {
    transform: scale(1);
}

.lightbox-image {
    width: 100%;
    height: auto;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 217, 255, 0.3);
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(0, 217, 255, 0.9);
    color: var(--black);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
}

.lightbox-close:hover {
    background: var(--hotmag);
    transform: rotate(90deg) scale(1.1);
}

.lightbox-close:active {
    transform: rotate(90deg) scale(0.9);
}

/* Pinch-to-zoom hint på mobil */
.lightbox-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 217, 255, 0.9);
    color: var(--black);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-family: var(--mono);
    font-size: 0.85rem;
    opacity: 0;
    animation: fadeInOut 3s ease-in-out;
    pointer-events: none;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* Small mobile breakpoint */
@media screen and (max-width: 480px) {
    :root {
        --font-size: 1.1rem;
    }

    #header {
        margin-bottom: 1rem;
    }

    #intro {
        padding: 0 1rem 3rem 1rem;
    }

    #intro .name {
        margin-bottom: 1.25rem;
    }

    #intro p {
        font-size: 0.9rem;
        line-height: 1.7;
        margin: 1.5rem 0;
    }

    #element {
        height: 2.5rem;
        min-height: 2.5rem;
        margin: 0 0 1.25rem 0;
        padding: 0.25rem 0;
    }

    .blackBox {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    #projects {
        padding: 1.5rem 8px;
    }

    #projects h1 {
        font-size: 1.5rem;
    }

    #projects ul {
        font-size: 0.85rem;
        gap: 0.5rem;
    }

    #contact h2 {
        font-size: 1.3rem;
    }

    #contact p {
        font-size: 1rem;
        max-width: 300px;
    }

    .contactPopUp {
        padding: 1rem 1.5rem;
        font-size: 0.85rem;
        min-height: 44px;
    }
}
