/* ==========================================================================
   Design System & Typography for Amine Aichane Portfolio & Blog Engine
   ========================================================================== */

:root {
    --primary: 221.2 83.2% 53.3%;
    --primary-foreground: 210 40% 98%;
    --ring: 221.2 83.2% 53.3%;
    --background: 201 50% 10%;
    --foreground: 190 60% 98%;
    --card: 201 50% 12%;
    --card-foreground: 190 60% 98%;
    --popover: 201 50% 10%;
    --popover-foreground: 190 60% 98%;
    --muted: 200 40% 20%;
    --muted-foreground: 195 30% 70%;
    --border: 200 40% 20%;
    --input: 200 40% 20%;
    --secondary: 200 40% 18%;
    --secondary-foreground: 190 60% 98%;
    --accent: 200 40% 22%;
    --accent-foreground: 190 60% 98%;
    --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

html {
    color-scheme: dark;
    scroll-behavior: smooth;
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: var(--font-sans);
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Global Navigation Bar
   -------------------------------------------------------------------------- */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background-color: hsla(201, 50%, 10%, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid hsla(200, 40%, 20%, 0.7);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nav-container {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (min-width: 768px) {
    .nav-container {
        padding: 1rem 3rem;
    }
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: hsl(var(--foreground));
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.025em;
    transition: opacity 0.2s;
}

.nav-brand:hover {
    opacity: 0.9;
}

.nav-brand-badge {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, hsl(var(--primary)), #3b82f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.875rem;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.nav-links {
    display: none;
    align-items: center;
    gap: 1.75rem;
    list-style: none;
}

@media (min-width: 768px) {
    .nav-links {
        display: flex;
    }
}

.nav-link {
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    transition: color 0.2s ease;
    position: relative;
    padding: 0.25rem 0;
}

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

.nav-link.active {
    color: hsl(var(--foreground));
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: hsl(var(--primary));
    border-radius: 2px;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 9999px;
    padding: 0.5rem 1.25rem;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
}

.nav-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

@media (min-width: 768px) {
    .mobile-menu-btn {
        display: none;
    }
}

.mobile-menu-drawer {
    display: none;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid hsla(200, 40%, 20%, 0.7);
    background-color: hsla(201, 50%, 10%, 0.98);
    gap: 1rem;
}

.mobile-menu-drawer.open {
    display: flex;
}

.mobile-link {
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 1px solid hsla(200, 40%, 20%, 0.3);
    transition: color 0.2s;
}

.mobile-link:hover, .mobile-link.active {
    color: hsl(var(--foreground));
}

/* --------------------------------------------------------------------------
   Blog Listing & Cards
   -------------------------------------------------------------------------- */
.blog-hero {
    padding: 4rem 1.5rem 3rem;
    text-align: center;
    max-width: 56rem;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .blog-hero {
        padding: 5rem 2rem 4rem;
    }
}

.blog-badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    background: hsla(221.2, 83.2%, 53.3%, 0.15);
    color: hsl(var(--primary));
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
    border: 1px solid hsla(221.2, 83.2%, 53.3%, 0.3);
}

.blog-hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: hsl(var(--foreground));
}

@media (min-width: 768px) {
    .blog-hero-title {
        font-size: 3.5rem;
    }
}

.blog-hero-desc {
    font-size: 1.15rem;
    color: hsl(var(--muted-foreground));
    max-width: 42rem;
    margin: 0 auto;
    font-weight: 300;
    line-height: 1.6;
}

.blog-posts-container {
    max-width: 56rem;
    margin: 0 auto 5rem;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.blog-card {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    padding: 2rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.blog-card:hover {
    border-color: hsla(221.2, 83.2%, 53.3%, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.5), 0 0 15px -3px rgba(37, 99, 235, 0.15);
}

.blog-card-meta {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    font-size: 0.825rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.75rem;
}

.blog-card-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    color: hsl(var(--foreground));
    transition: color 0.2s;
}

.blog-card:hover .blog-card-title {
    color: #60a5fa;
}

.blog-card-desc {
    color: hsl(var(--muted-foreground));
    line-height: 1.65;
    margin-bottom: 1.5rem;
    font-size: 0.975rem;
}

.blog-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid hsla(200, 40%, 20%, 0.6);
}

.tag-badge {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    padding: 0.25rem 0.625rem;
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border-radius: 0.375rem;
    border: 1px solid hsla(200, 40%, 30%, 0.4);
    letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   Post Detail Page & Markdown Typography (prose prose-invert)
   -------------------------------------------------------------------------- */
.post-header {
    max-width: 52rem;
    margin: 2rem auto 2.5rem;
    padding: 0 1.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: hsl(var(--foreground));
}

.post-title {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.25;
    color: hsl(var(--foreground));
    margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
    .post-title {
        font-size: 3rem;
    }
}

.post-meta-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid hsl(var(--border));
    font-size: 0.9rem;
    color: hsl(var(--muted-foreground));
}

.post-content {
    max-width: 52rem;
    margin: 0 auto;
    padding: 0 1.5rem 5rem;
    color: hsl(var(--foreground) / 0.92);
    font-size: 1.0625rem;
    line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
    color: hsl(var(--foreground));
    font-weight: 700;
    letter-spacing: -0.025em;
    scroll-margin-top: 5rem;
}

.post-content h2 {
    font-size: 1.75rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid hsla(200, 40%, 20%, 0.8);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.post-content h3 {
    font-size: 1.35rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content strong {
    color: #ffffff;
    font-weight: 600;
}

.post-content a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.post-content a:hover {
    color: #93c5fd;
}

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

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

.post-content blockquote {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid hsl(var(--primary));
    background-color: hsla(200, 40%, 20%, 0.3);
    border-radius: 0 0.5rem 0.5rem 0;
    color: hsl(var(--foreground) / 0.95);
    font-style: italic;
}

.post-content blockquote p:last-child {
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Markdown Tables
   -------------------------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    margin: 2.5rem 0;
    border-radius: 0.75rem;
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.925rem;
}

.post-content th {
    background-color: hsla(200, 40%, 25%, 0.5);
    color: hsl(var(--foreground));
    font-weight: 700;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    text-transform: uppercase;
    font-size: 0.775rem;
    letter-spacing: 0.05em;
}

.post-content td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid hsla(200, 40%, 20%, 0.5);
    vertical-align: top;
    color: hsl(var(--foreground) / 0.9);
}

.post-content tr:last-child td {
    border-bottom: none;
}

.post-content tr:nth-child(even) td {
    background-color: hsla(200, 40%, 15%, 0.3);
}

/* --------------------------------------------------------------------------
   Code Syntax Highlighting (Dark Theme)
   -------------------------------------------------------------------------- */
.post-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 0.2em 0.4em;
    border-radius: 0.375rem;
    background-color: hsla(200, 40%, 20%, 0.7);
    color: #e0f2fe;
    border: 1px solid hsla(200, 40%, 30%, 0.5);
}

.code-block-wrapper {
    position: relative;
    margin: 2rem 0;
    border-radius: 0.75rem;
    border: 1px solid hsl(var(--border));
    background-color: #070e13;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: hsla(200, 40%, 15%, 0.8);
    border-bottom: 1px solid hsla(200, 40%, 20%, 0.8);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-content pre {
    margin: 0;
    padding: 1.25rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.65;
    background-color: transparent;
}

.post-content pre code {
    padding: 0;
    background-color: transparent;
    border: none;
    color: #e2e8f0;
}

/* Highlight.js Tokens */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-name, .hljs-tag {
    color: #93c5fd;
    font-weight: 600;
}
.hljs-string, .hljs-title, .hljs-section, .hljs-attribute, .hljs-literal, .hljs-template-tag, .hljs-template-variable, .hljs-type, .hljs-addition {
    color: #86efac;
}
.hljs-comment, .hljs-quote, .hljs-deletion, .hljs-meta {
    color: #64748b;
    font-style: italic;
}
.hljs-number, .hljs-regexp, .hljs-link {
    color: #fca5a5;
}
.hljs-variable, .hljs-attr, .hljs-subst {
    color: #cbd5e1;
}
.hljs-function {
    color: #67e8f9;
}

/* --------------------------------------------------------------------------
   Post Bottom Navigation & Footer
   -------------------------------------------------------------------------- */
.post-footer-nav {
    max-width: 52rem;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-footer {
    margin-top: auto;
    padding: 2.5rem 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    border-top: 1px solid hsla(200, 40%, 20%, 0.6);
    background-color: hsla(200, 40%, 15%, 0.25);
}

.site-footer a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.site-footer a:hover {
    color: hsl(var(--foreground));
}
