/* 
 * ElasticPurple v2 - Documentation-First Design
 * Design philosophy: Confidence through restraint
 * Inspired by: Stripe docs, Tailscale blog, internal eng wikis
 */

/* ===== CSS Variables ===== */
:root {
    /* Light theme - warm paper tones */
    --bg-primary: #fafaf9;
    --bg-secondary: #f5f5f4;
    --bg-tertiary: #ffffff;
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-muted: #a8a29e;
    --border-color: #e7e5e4;
    --border-subtle: #f5f5f4;
    --accent: #7c3aed;
    --accent-muted: #a78bfa;
    --accent-bg: #f5f3ff;
    --success: #059669;
    --warning: #d97706;
    --code-bg: #1e1e1e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
    --bg-primary: #0c0a09;
    --bg-secondary: #1c1917;
    --bg-tertiary: #292524;
    --text-primary: #fafaf9;
    --text-secondary: #a8a29e;
    --text-muted: #78716c;
    --border-color: #292524;
    --border-subtle: #1c1917;
    --accent: #a78bfa;
    --accent-muted: #7c3aed;
    --accent-bg: rgba(124, 58, 237, 0.1);
    --success: #34d399;
    --warning: #fbbf24;
    --code-bg: #1c1917;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Typography ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: 2rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.5rem;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.125rem;
}

p {
    color: var(--text-secondary);
    max-width: 65ch;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-muted);
}

code {
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    font-size: 0.875em;
    background: var(--bg-secondary);
    padding: 0.125em 0.375em;
    border-radius: 4px;
}

pre {
    background: var(--code-bg);
    color: #e5e5e5;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.7;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ===== Layout ===== */
.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

/* ===== Sidebar ===== */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 2rem 0;
    border-right: 1px solid var(--border-color);
    background: var(--bg-primary);
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

.sidebar-brand-text {
    font-weight: 600;
    font-size: 1rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    padding: 0.5rem 1.5rem;
}

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.5rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    transition: all 0.15s ease;
    border-left: 2px solid transparent;
    margin-left: -2px;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-bg);
}

.nav-sublink {
    padding-left: 2.5rem;
    font-size: 0.875rem;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.75rem 1.5rem;
}

/* ===== Main Content ===== */
.main {
    padding: 3rem 4rem;
    max-width: 900px;
}

@media (max-width: 1200px) {
    .main {
        padding: 2rem;
    }
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    margin-bottom: 0.5rem;
}

.page-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 50ch;
}

/* ===== Hero (Home page only) ===== */
.hero {
    margin-bottom: 4rem;
}

.hero-intro {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
    max-width: 20ch;
}

.hero-description {
    font-size: 1.125rem;
    line-height: 1.7;
    margin-bottom: 2rem;
    max-width: 55ch;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-muted);
    color: white;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

/* ===== Section ===== */
.section {
    margin-bottom: 4rem;
}

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

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

.section-link {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===== Credentials Grid ===== */
.credentials-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 700px) {
    .credentials-grid {
        grid-template-columns: 1fr;
    }
}

.credential-group {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.credential-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.credential-group-icon {
    font-size: 1rem;
}

.credential-list {
    list-style: none;
}

.credential-item {
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.credential-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.credential-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.credential-name a {
    color: var(--text-primary);
    text-decoration: none;
}

.credential-name a:hover {
    color: var(--accent);
}

.credential-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
}

.credential-provider {
    color: var(--text-muted);
}

.credential-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

.credential-status.completed {
    background: rgba(5, 150, 105, 0.1);
    color: var(--success);
}

.credential-status.in-progress {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning);
}

/* ===== Projects ===== */
.projects-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.project-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.15s ease;
}

.project-card:hover {
    border-color: var(--text-muted);
}

.project-title {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.project-title a {
    color: var(--text-primary);
}

.project-title a:hover {
    color: var(--accent);
}

.project-description {
    font-size: 0.9375rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
}

.project-links {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===== Skills ===== */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.skill-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.skill-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ===== Footer ===== */
.footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
}

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

/* ===== Controls (Theme/Language) ===== */
.controls {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

.control-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.control-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

/* ===== Mobile Menu ===== */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    align-items: center;
}

.mobile-menu-btn {
    padding: 0.5rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary);
}

@media (max-width: 900px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: 280px;
        box-shadow: var(--shadow-md);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 99;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main {
        padding: 2rem 1.5rem;
    }

    .controls {
        display: none;
    }

    /* Article mobile styles */
    .article-title {
        font-size: 1.5rem;
    }

    .article-content h2 {
        font-size: 1.25rem;
    }

    .article-content h3 {
        font-size: 1.1rem;
    }

    .article-content pre {
        font-size: 0.8rem;
        padding: 1rem;
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        border-radius: 0;
    }

    .note {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        border-radius: 0;
        padding: 1rem;
    }

    /* Hero mobile */
    .hero-title {
        font-size: 1.75rem;
    }

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

    .hero-actions {
        flex-direction: column;
    }

    .hero-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 1.5rem 1rem;
    }

    .article-title {
        font-size: 1.35rem;
    }

    .article-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .article-content pre {
        margin-left: -1rem;
        margin-right: -1rem;
    }

    .note {
        margin-left: -1rem;
        margin-right: -1rem;
    }

    .skills-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .skill-item {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .skill-icon {
        width: 20px;
        height: 20px;
    }
}

/* ===== Article Styles ===== */
.article {
    max-width: 700px;
}

.article-header {
    margin-bottom: 2rem;
}

.article-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.article-title {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.article-content h2 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.article-content h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.article-content p {
    margin-bottom: 1rem;
}

.article-content ul,
.article-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

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

.article-content pre {
    margin: 1.5rem 0;
}

.article-content img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

.article-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Info/Note boxes */
.note {
    padding: 1rem 1.25rem;
    background: var(--accent-bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    margin: 1.5rem 0;
}

.note p {
    margin: 0;
    font-size: 0.9375rem;
}

/* ===== Back Link ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

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

/* ===== Utilities ===== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Print Styles ===== */
@media print {

    .sidebar,
    .controls,
    .mobile-header {
        display: none;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .main {
        padding: 0;
        max-width: 100%;
    }
}