/* style.css */

/* --- 0. MODERN FEATURES --- */
/* Detta gör att sidbyten känns som en SPA (Native App-känsla) */
@view-transition {
    navigation: auto;
}

/* --- 1. VARIABLES --- */
:root {
    /* BACKGROUND: Dark Mode Default */
    --bg-base: #0a0a0a;
    --text-main: #ededed;
    --text-muted: #888888;
    --accent: #FF8C00;
    --error: #ff3333;

    /* Header Backgrounds */
    --header-bg-scroll: rgba(20, 20, 20, 0.85);
    --header-bg-solid: rgba(20, 20, 20, 0.95);
    --header-border: rgba(255, 255, 255, 0.1);

    /* CARDS */
    --card-glass: rgba(20, 20, 20, 0.6);
    --border-alpha: rgba(255, 255, 255, 0.15);
    --shadow-sm: none;
    --shadow-hover: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
}

/* --- 2. GLOBAL RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* AMBIENT MESH */
.ambient-mesh {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    /* Dark mode dots (visible on dark bg) */
    background: radial-gradient(circle at 50% 50%, rgba(125, 125, 125, 0.05), transparent 60%);
    z-index: -1;
    pointer-events: none;
    view-transition-name: ambient-mesh;
}

/* --- 3. NAVBAR --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 2rem 0;
    transition: padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    /* Håll headern stabil vid sidbyten */
    view-transition-name: main-header;
}

.header-inner {
    position: relative;
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
    background: transparent;
    padding: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

header.compact {
    padding: 1rem 0;
}

header.compact .header-inner {
    width: fit-content;
    min-width: 140px;
    padding: 0.5rem 0.75rem;
    border-radius: 100px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.05);
    background: var(--header-bg-solid);
    border: 1px solid var(--header-border);
}

header.compact .header-inner:hover {
    padding: 0.5rem 2rem;
}

.logo-link {
    display: flex;
    align-items: center;
    height: 100%;
}

.logo-img {
    display: block;
    height: 60px;
    width: auto;
    transition: height 0.5s ease;
}

header.compact .logo-img {
    height: 32px;
}

.nav-cluster {
    display: flex;
    align-items: center;
    gap: 2rem;
    overflow: hidden;
    max-width: 800px;
    opacity: 1;
    margin: 0 2rem;
    transition: all 0.5s ease;
    position: relative; /* Context for absolute highlighter */
}

/* Sliding Background Pill */
.nav-highlight {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(255, 255, 255, 0.1); /* Dark mode white-ish pill */
    border-radius: 8px;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: -1;
}

header.compact .nav-cluster {
    max-width: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

header.compact .header-inner:hover .nav-cluster {
    max-width: 800px;
    opacity: 1;
    margin: 0 1.5rem;
    pointer-events: auto;
}

.nav-link {
    text-decoration: none;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--accent);
}

.nav-link.active {
    color: var(--accent);
}

.nav-separator {
    width: 1px;
    height: 24px;
    background-color: var(--text-muted);
    opacity: 0.3;
}

.tools-cluster {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(125, 125, 125, 0.2);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

header.compact .theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
}

.theme-toggle:hover {
    background: rgba(125, 125, 125, 0.1);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

header.compact .mobile-menu-btn {
    display: flex;
    opacity: 1;
}

header.compact .header-inner:hover .mobile-menu-btn {
    opacity: 0;
    width: 0;
}

.mobile-menu-btn span {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.mobile-menu-btn span::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 0;
    width: 100%;
    height: 100%;
    background: currentColor;
}

.mobile-menu-btn span::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 0;
    width: 100%;
    height: 100%;
    background: currentColor;
}

/* --- 4. MAIN CONTENT --- */
.main-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    padding-bottom: 6rem;
}

.hero {
    margin-top: 25vh;
    margin-bottom: 6rem;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s forwards;
}

h1 {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(3rem, 6vw, 5.5rem);
    font-weight: 700;
    letter-spacing: -0.06em;
    line-height: 1;
    margin-bottom: 2rem;
    color: var(--text-main);
}

h1 span {
    color: var(--accent);
}

.lead {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    line-height: 1.6;
}

#rotating-text {
    display: inline-block;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#rotating-text.fade-out {
    opacity: 0;
    transform: translateY(20px);
}

#rotating-text.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 2rem;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.3s forwards;
}

.card {
    position: relative;
    background: var(--card-glass);
    border: 1px solid var(--border-alpha);
    border-radius: 24px;
    padding: 3rem;
    text-decoration: none;
    color: var(--text-main);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card:hover {
    transform: translateY(-5px) scale(1.01);
    border-color: var(--accent);
    box-shadow: 0 20px 40px -10px rgba(255, 140, 0, 0.15);
}

.card-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1.5rem;
    display: inline-block;
    border: 1px solid var(--border-alpha);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
}

.card h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.card p {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
}

/* --- 5. FOOTER --- */
.git-footer {
    width: 100%;
    margin-top: 6rem;
    padding: 3rem 0;
    border-top: 1px solid var(--border-alpha);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.git-container {
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 1.5rem;
}

.git-graph-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 20px;
}

.git-line {
    width: 2px;
    height: 100%;
    background: var(--border-alpha);
}

.git-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
    box-shadow: 0 0 10px var(--accent);
}

.git-content {
    flex: 1;
}

.git-hash {
    color: var(--accent);
    font-weight: 700;
    margin-right: 0.5rem;
}

.git-links a {
    color: var(--text-main);
    text-decoration: none;
}

.git-links a:hover {
    color: var(--accent);
}

.link-val {
    color: var(--accent);
    opacity: 0.8;
}

/* --- 6. ABOUT / TERMINAL --- */
.hero-terminal {
    margin-top: 25vh;
    margin-bottom: 6rem;
    display: flex;
    justify-content: center;
    width: 100%;
}

.terminal-window {
    width: 100%;
    max-width: 800px;
    background: #1e1e1e;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.terminal-header {
    background: #2d2d2d;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.red {
    background: #ff5f56;
}

.yellow {
    background: #ffbd2e;
}

.green {
    background: #27c93f;
}

.terminal-title {
    margin-left: 1rem;
    color: #999;
    font-size: 0.85rem;
}

.terminal-body {
    padding: 2rem;
    color: #f0f0f0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.cmd-line {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.prompt {
    color: var(--accent);
    font-weight: 700;
}

.output {
    margin-bottom: 2rem;
    color: #ccc;
    padding-left: 1.5rem;
}

.accent-text {
    color: var(--accent);
}

/* --- 7. BLUEPRINT SYSTEM --- */
.full-height {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-top: 6rem;
}

.blueprint-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 4rem;
    align-items: center;
    width: 100%;
}

.system-graph-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 600px;
    margin: 0 auto;
}

.system-graph {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-image: linear-gradient(rgba(125, 125, 125, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(125, 125, 125, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

#circuit-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.circuit-line {
    fill: none;
    stroke: var(--border-alpha);
    stroke-width: 1px;
}

.circuit-flow {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2px;
    stroke-linecap: round;
    stroke-dasharray: 0 15;
    animation: flowData 1s linear infinite;
    opacity: 0.6;
}

.sys-node {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 2;
    cursor: pointer;
    transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    min-width: 140px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sys-node.is-center {
    background: var(--bg-base);
    border: 2px solid var(--accent);
    color: var(--text-main);
    font-weight: 700;
    z-index: 10;
}

.sys-node.is-satellite {
    background: var(--card-glass);
    border: 1px solid var(--border-alpha);
    color: var(--text-muted);
    backdrop-filter: blur(12px);
}

.sys-node.is-satellite:hover {
    border-color: var(--accent);
    color: var(--text-main);
}

.sys-node.is-back {
    min-width: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--text-muted);
    color: white;
    opacity: 0.5;
}

.readout-panel {
    background: var(--card-glass);
    border: 1px solid var(--border-alpha);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 2.5rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.readout-panel h2 {
    font-family: 'Inter', sans-serif;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.action-link {
    background: none;
    border: none;
    font-family: 'JetBrains Mono';
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
}

/* --- 8. 404 PAGE STYLES (NEW) --- */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
    margin-top: 2rem;
}

.error-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.3;
    line-height: 1;
    position: relative;
}

.error-title {
    font-size: 2rem;
    color: var(--error);
    margin-bottom: 2rem;
    letter-spacing: 0.1em;
}

.error-terminal {
    max-width: 600px;
    margin-bottom: 3rem;
    text-align: left;
    border-color: var(--error);
}

.error-text {
    color: var(--error);
}

.action-btn {
    padding: 1rem 2rem;
    background: transparent;
    border: 1px solid var(--text-main);
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: var(--text-main);
    color: var(--bg-base);
}

/* Glitch Animation */
.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-base);
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 #ff00c1;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 #00fff9;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(30px, 9999px, 10px, 0);
    }

    20% {
        clip: rect(80px, 9999px, 90px, 0);
    }

    100% {
        clip: rect(10px, 9999px, 40px, 0);
    }
}

@keyframes glitch-anim2 {
    0% {
        clip: rect(10px, 9999px, 80px, 0);
    }

    20% {
        clip: rect(90px, 9999px, 10px, 0);
    }

    100% {
        clip: rect(50px, 9999px, 30px, 0);
    }
}

@keyframes flowData {
    to {
        stroke-dashoffset: -15;
    }
}

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

/* Mobile */
@media (max-width: 1024px) {
    header.compact .mobile-menu-btn {
        display: flex;
        opacity: 1;
    }

    .blueprint-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .nav-cluster {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
        width: 32px;
        height: 32px;
        border: none;
        background: transparent;
        color: var(--text-main);
    }

    .mobile-menu-btn span {
        width: 16px;
        height: 2px;
        background: currentColor;
        position: relative;
    }

    .mobile-menu-btn span::before,
    .mobile-menu-btn span::after {
        content: '';
        position: absolute;
        left: 0;
        width: 100%;
        height: 100%;
        background: currentColor;
    }

    .mobile-menu-btn span::before {
        top: -6px;
    }

    .mobile-menu-btn span::after {
        top: 6px;
    }

    .nav-cluster.active {
        display: flex;
        position: fixed;
        top: 4rem;
        left: 5%;
        width: 90%;
        background: var(--bg-base);
        border: 1px solid var(--border-alpha);
        flex-direction: column;
        padding: 2rem;
        border-radius: 12px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
        z-index: 999;
    }
}

/* --- 9. NEW TECH STACK STYLES (Modules) --- */
.stack-section {
    margin: 6rem 0;
}

.section-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-main);
    letter-spacing: -0.04em;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.module-card {
    background: var(--card-glass);
    border: 1px solid var(--border-alpha);
    border-radius: 16px;
    padding: 2rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.module-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
}

.module-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-alpha);
}

.module-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    opacity: 0.8;
}

.module-header h3 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--text-main);
}

.tech-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tech-pill {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    background: var(--bg-base);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.module-card:hover .tech-pill {
    border-color: var(--border-alpha);
    color: var(--text-main);
}

.tech-pill:hover {
    background: var(--text-main);
    color: var(--bg-base);
    cursor: default;
}

/* --- 10. TIMELINE UPDATE --- */
.timeline-section {
    margin-bottom: 6rem;
}

.timeline-container {
    position: relative;
    border-left: 1px solid var(--border-alpha);
    padding-left: 2rem;
    margin-left: 1rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 3rem;
}

.timeline-marker {
    position: absolute;
    left: -2.35rem;
    top: 0.4rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-base);
    border: 2px solid var(--text-muted);
    transition: all 0.3s;
}

.timeline-item:hover .timeline-marker {
    border-color: var(--accent);
    background: var(--accent);
}

.timeline-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.timeline-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
}

.commit-hash {
    display: inline-block;
    margin-top: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.6;
    background: rgba(125,125,125,0.1);
    padding: 2px 6px;
    border-radius: 4px;
}