﻿/* Variables and reset */
:root {
    --bg-color: #121212;
    --text-color: #f4f4f4;
    --accent-color: #4da6ff;
    --card-bg: #1e1e1e;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    line-height: 1.6;
}

/* Header/Navigation */
.main-header {
    background-color: #000;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    position: relative; /* anchor for the underline below */
    display: inline-block;
    padding: 0.25rem 0;
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

/* Accent underline: hidden by default, grows in on hover and on the active link */
.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    background-color: var(--accent-color);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.25s ease;
}

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

.nav-links a:hover::after {
    transform: scaleX(1);
}

/* Current page (set by Liquid) or section in view (set by js/nav.js) */
.nav-links a.is-active {
    color: var(--accent-color);
    font-weight: 600;
}

.nav-links a.is-active::after {
    transform: scaleX(1);
}

/* --- Keyboard accessibility --- */

/* Skip link: hidden above the viewport until it receives keyboard focus */
.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 200; /* above the sticky header */
    padding: 0.5rem 1rem;
    background-color: var(--accent-color);
    color: #000;
    font-weight: bold;
    border-radius: 4px;
    text-decoration: none;
}

.skip-link:focus {
    top: 1rem;
}

/* Clear focus ring for keyboard users (mouse clicks don't show it).
   Accent blue on the dark background is 7.3:1, well above the 3:1 required. */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
    border-radius: 2px;
}

/* <main> gets focus from the skip link; no ring needed around the whole page */
main:focus {
    outline: none;
}

/* Anchor jumps (/#skills etc.) stop below the sticky header instead of under it */
html {
    scroll-padding-top: 5rem;
}

@media (prefers-reduced-motion: reduce) {
    .nav-links a,
    .nav-links a::after {
        transition: none;
    }
}

/* General sektions*/
section, footer {
    padding: 4rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

h2 {
    margin-bottom: 2rem;
    font-size: 2.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

/* Hero */
.hero-section {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60vh;
}

.hero-content h1 {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

/* Subtitle under the name. A <p>, not a heading: it describes the h1 rather than starting a section */
.hero-subtitle {
    font-weight: bold;
    font-size: 2rem;
    color: var(--accent-color);
    border-bottom: none;
    margin-bottom: 1rem;
}

/* Skills */
.skills-container {
    display: flex;
    gap: 4rem;
    flex-wrap: wrap;
}

.skill-category ul {
    list-style-position: inside;
}

/* Projekt Grid */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.project-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.project-info {
    padding: 1.5rem;
}

.project-info h3 {
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

/* Footer / Contact */
.footer-section {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2rem;
    background-color: #0a0a0a;
    max-width: 100%;
    padding: 4rem 10%;
}

.about-me, .contact-info {
    flex: 1;
    min-width: 300px;
}

/* --- Itch.io Button Styling --- */
.project-meta {
    display: flex;
    gap: 2rem;
    align-items: center; /* Centrerar elementen i höjdled */
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding: 1rem;
    background-color: var(--card-bg);
    border-radius: 8px;
}

.itch-btn {
    display: inline-block;
    /* Darker shade of Itch.io's red (#fa5c5c): white text on #fa5c5c is only 3.1:1,
       on #c93636 it is 5.2:1, which passes WCAG AA (4.5:1) */
    background-color: #c93636;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.itch-btn:hover {
    background-color: #a82c2c; /* 6.9:1 with white */
    transform: translateY(-2px);
}

/* --- Social Media Container Styling --- */
.social-media-container {
    margin-bottom: 1rem;
    border-radius: 6px;
    overflow: hidden;
    background-color: #000;
}

.social-media-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* --- About & Contact Centered Sections --- */
.about-section {
    display: flex;
    justify-content: center;
    text-align: center;
}

.about-container {
    max-width: 800px; /* Begränsar radlängden för att följa god UX/läsbarhet */
}

.about-container p {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #ccc;
}

.footer-section {
    background-color: #0a0a0a;
    text-align: center;
    padding: 5rem 2rem;
}

.contact-container {
    max-width: 600px;
    margin: 0 auto;
}

.contact-container p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.contact-container a {
    color: var(--accent-color);
    text-decoration: none;
}

.contact-container a:hover {
    text-decoration: underline;
}

/* --- Logo is now a link back to the start page --- */
a.logo {
    text-decoration: none;
}

/* --- Project detail pages (classes used by _layouts/project.html) --- */
.project-detail-section {
    max-width: 900px;
}

.project-header h1 {
    font-size: 3rem;
    line-height: 1.2;
}

/* Role under the project name (a <p>, see .hero-subtitle) */
.project-role {
    font-weight: bold;
    font-size: 1.5rem;
    color: var(--accent-color);
    border-bottom: none;
    margin-bottom: 1.5rem;
}

.project-media img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.project-media {
    margin-bottom: 2rem;
}

/* Section headings on project pages are h2 (directly under the h1), styled smaller
   than the big underlined h2 used on the start page */
.project-description h2,
.project-tweet h2 {
    display: block;
    font-size: 1.3rem;
    border-bottom: none;
    margin: 2rem 0 0.75rem;
    color: var(--accent-color);
}

.project-description ul {
    padding-left: 1.5rem;
}

.project-description li {
    margin-bottom: 0.4rem;
}

.social-post-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
}

.social-post-text {
    margin-bottom: 1rem;
    color: #ccc;
}

/* --- Blog index --- */
.post-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.post-list-item a {
    display: block;
    padding: 1.5rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    color: var(--text-color);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-list-item a:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

/* Post titles in the list are h2 (under the page's h1), styled smaller than section h2s */
.post-list-item h2 {
    display: block;
    font-size: 1.3rem;
    border-bottom: none;
    color: var(--accent-color);
    margin-bottom: 0.25rem;
}

/* h1 on sub-pages such as /blog/, same look as the section h2s on the start page */
.page-title {
    margin-bottom: 2rem;
    font-size: 2.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

.post-meta {
    color: #999;
    font-size: 0.95rem;
}

/* --- Blog post --- */
.post {
    max-width: 760px; /* ~70 characters per line for long-form reading */
    margin: 0 auto;
    padding: 4rem 2rem;
}

.post-header {
    margin-bottom: 3rem;
}

.post-back {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.95rem;
}

.post-title {
    font-size: 2.75rem;
    line-height: 1.15;
    margin: 1rem 0 0.75rem;
}

.post-description {
    font-size: 1.2rem;
    color: #ccc;
    margin-bottom: 0.75rem;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #ddd;
}

.post-content h2 {
    font-size: 1.9rem;
    margin: 3rem 0 1rem;
}

.post-content h3 {
    font-size: 1.35rem;
    margin: 2rem 0 0.75rem;
    color: var(--accent-color);
}

.post-content p,
.post-content ul,
.post-content ol,
.post-content table,
.post-content figure,
.post-content blockquote {
    margin-bottom: 1.25rem;
}

.post-content ul,
.post-content ol {
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content a {
    color: var(--accent-color);
}

.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 6px;
}

.post-content figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: #999;
    margin-top: 0.5rem;
}

.post-content blockquote {
    border-left: 3px solid var(--accent-color);
    padding: 0.5rem 1rem;
    color: #ccc;
    background-color: var(--card-bg);
}

/* Table of contents generated by kramdown ({:toc} gives the list id="markdown-toc") */
#markdown-toc {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1.25rem 1.25rem 1.25rem 2.5rem;
    font-size: 1rem;
}

#markdown-toc ul {
    padding-left: 1.25rem;
    margin: 0.25rem 0 0;
}

#markdown-toc li {
    margin-bottom: 0.25rem;
}

/* Tables (e.g. architecture comparison) */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    display: block;
    overflow-x: auto;
}

.post-content th,
.post-content td {
    border: 1px solid #333;
    padding: 0.6rem 0.8rem;
    text-align: left;
    vertical-align: top;
}

.post-content th {
    background-color: var(--card-bg);
    color: var(--accent-color);
}

/* Inline code and code blocks */
.post-content code,
.project-description code {
    font-family: Consolas, 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.9em;
    background-color: var(--card-bg);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.post-content pre {
    background-color: #0d0d0d;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    font-size: 0.9rem; /* line-height is based on this, keeps code lines tight */
    line-height: 1.5;
}

.post-content pre code {
    background: none;
    padding: 0;
    font-size: 0.9rem;
}

/* Rouge syntax highlighting (dark) */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp, .highlight .cpf { color: #6a9955; font-style: italic; } /* comments, preprocessor */
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt, .highlight .kc { color: #569cd6; } /* keywords, types */
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sc, .highlight .se { color: #ce9178; } /* strings */
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh { color: #b5cea8; } /* numbers */
.highlight .nf, .highlight .fm { color: #dcdcaa; } /* function names */
.highlight .nc, .highlight .nn { color: #4ec9b0; } /* classes, namespaces */
.highlight .o, .highlight .p { color: #d4d4d4; } /* operators, punctuation */
.highlight .n, .highlight .nb, .highlight .nv { color: #9cdcfe; } /* names, variables */
/* --- Small screens (phones) ---
   WCAG 1.4.10 Reflow: all content must fit at 320 px width without sideways scrolling.
   The nav wraps under the logo instead of running off-screen. */
@media (max-width: 600px) {
    .main-header {
        padding: 0.75rem 1rem;
    }

    nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem 1.1rem;
        font-size: 0.95rem;
    }

    /* The header is taller when wrapped, so anchor jumps need more room */
    html {
        scroll-padding-top: 6.5rem;
    }

    section, footer {
        padding: 3rem 1.25rem;
    }

    h2,
    .page-title {
        font-size: 1.9rem;
    }

    .hero-content h1 {
        font-size: 2.75rem;
        line-height: 1.15;
    }

    .hero-subtitle {
        font-size: 1.5rem;
    }

    .project-header h1,
    .post-title {
        font-size: 2.1rem;
    }

    .post {
        padding: 3rem 1.25rem;
    }

    .project-grid {
        grid-template-columns: 1fr; /* minmax(300px) would overflow below ~340 px */
    }
}
