/**
 * Clean Code Dev - Article Styles
 * Premium, typography-focused design for generated articles
 */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #334155;
    --text-muted: #64748b;
    --bg-main: #ffffff;
    --bg-alt: #f8fafc;
    --page-bg: #f1f5f9;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --max-width: 1100px;
    --article-width: 800px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    line-height: 1.75;
    color: var(--text-main);
    background-color: var(--page-bg);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

.article-content {
    max-width: var(--article-width);
    margin: 0 auto;
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--border-light);
    padding: 8px 0;
    background: var(--bg-main);
    position: sticky;
    top: 0;
    z-index: 100;
}

.container-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    min-height: 60px;
}

.header-spacer {
    flex: 1;
}

.nav-wrapper {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 26px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1000;
    position: relative;
}

.menu-toggle .bar {
    height: 2px;
    width: 100%;
    background-color: var(--text-main);
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.menu-toggle.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.main-nav {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: var(--bg-main);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
    padding: 100px 40px;
    transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 999;
    border-left: 1px solid var(--border-color);
}

.main-nav.active {
    right: 0;
}

.nav-content {
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.nav-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-weight: 700;
}

.nav-section ul {
    list-style: none;
    padding: 0;
}

.nav-section li {
    margin-bottom: 16px;
}

.nav-section a {
    text-decoration: none;
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 700;
    transition: all 0.2s;
}

.nav-section a:hover {
    color: var(--primary);
    padding-left: 8px;
}

@media (max-width: 600px) {
    .logo span {
        display: none;
    }

    .main-nav {
        width: 100%;
        right: -100%;
    }
}

@media (max-width: 640px) {
    .tutorials-grid {
        grid-template-columns: 1fr;
    }
}

/* Extra Large Screens */
@media (min-width: 1400px) {
    :root {
        --max-width: 1200px;
    }
}

/* Article Layout */
.article-container {
    padding-top: 24px;
    padding-bottom: 80px;
    background: var(--bg-main);
    min-height: 60vh;
    box-shadow: var(--shadow-subtle);
}

.article-header {
    margin-bottom: 48px;
    text-align: center;
}

.article-header h1 {
    font-size: 3rem;
    line-height: 1.2;
    font-weight: 800;
    margin-bottom: 24px;
    letter-spacing: -0.025em;
}

.article-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.article-meta .separator {
    width: 4px;
    height: 4px;
    background: var(--border-color);
    border-radius: 50%;
}

/* Content Typography */
.article-body {
    font-size: 1.125rem;
}

.article-body h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-top: 48px;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

.article-body h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 32px;
    margin-bottom: 16px;
}

.article-body p {
    margin-bottom: 24px;
}

/* Specific styling for article cover */
.article-cover {
    width: 100%;
    max-width: 150px;
    height: 120px;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    margin: 0 auto 32px auto;
    display: block;
    box-shadow: var(--shadow-card);
}

.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 32px 0;
    box-shadow: var(--shadow-card);
}

/* Code Blocks */
.code-container {
    position: relative;
    margin: 32px 0;
}

.article-body pre {
    background: #0d1117;
    /* GitHub Dark background */
    color: #e6edf3;
    padding: 5px;
    border-radius: 12px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    border: 1px solid #30363d;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #8b949e;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    opacity: 0;
}

.code-container:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f0f6fc;
    border-color: rgba(255, 255, 255, 0.2);
}

.copy-code-btn.copied {
    background: rgba(45, 164, 78, 0.2);
    color: #3fb950;
    border-color: rgba(45, 164, 78, 0.4);
    padding: 6px 10px;
}

.article-body code:not(pre code) {
    background: var(--bg-alt);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: var(--font-mono);
}

.article-body blockquote {
    border-left: 4px solid var(--primary);
    padding: 16px 24px;
    margin: 32px 0;
    font-style: italic;
    background: var(--bg-alt);
    border-radius: 0 8px 8px 0;
}

.article-body ul,
.article-body ol {
    margin-bottom: 24px;
    padding-left: 24px;
}

.article-body li {
    margin-bottom: 8px;
}

/* Horizontal Rule - Subtle Separator */
.article-body hr,
hr {
    border: none !important;
    height: 1px !important;
    background: linear-gradient(to right, transparent, var(--border-color), transparent) !important;
    margin: 48px 0 !important;
    opacity: 0.5 !important;
}

/* Table Styles */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 32px 0;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    line-height: 1.6;
}

.article-body th,
.article-body td {
    padding: 12px 16px;
    border: 1px solid var(--border-light);
}

.article-body th {
    background: var(--bg-alt);
    font-weight: 700;
    color: var(--primary-light);
    text-align: left;
}

.article-body tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.article-body tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Footer */
.site-footer {
    background: var(--bg-main);
    border-top: 1px solid var(--border-light);
    padding: 64px 0;
    margin-top: 0;
}

.container-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 48px;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-brand p {
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 400px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 64px;
    width: 100%;
}

.footer-column h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 20px;
    color: var(--text-main);
}

.footer-column ul {
    list-style: none;
}

.footer-column li {
    margin-bottom: 12px;
}

.footer-column a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-column a:hover {
    color: var(--primary);
}

/* Recent Tutorials Grid (Home Page) */
.recent-tutorials {
    margin-top: 0;
    padding-top: 0;
    border-top: 1px solid var(--border-light);
}

/* Language page header: small cover left, title + description + intro right */
.language-page-header {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 40px;
}

.language-page-cover {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 12px;
    flex-shrink: 0;
    box-shadow: var(--shadow-card);
}

.language-page-header-text {
    flex: 1;
    min-width: 0;
}

.language-page-header .language-page-title {
    margin-bottom: 8px;
    text-align: left;
}

.language-page-description {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 12px;
}

.language-page-intro {
    color: var(--text-main);
    font-size: 1rem;
    line-height: 1.7;
}

@media (max-width: 480px) {
    .language-page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

.section-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 32px;
    text-align: center;
    letter-spacing: -0.02em;
}

.tutorials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 32px;
}

.tutorial-card {
    text-decoration: none;
    color: inherit;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-subtle);
}

.tutorial-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card);
    border-color: var(--border-color);
}

.tutorial-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg-alt);
}

.tutorial-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.tutorial-card:hover .tutorial-thumb img {
    transform: scale(1.05);
}

.tutorial-info {
    padding: 24px;
    flex-grow: 1;
}

.tutorial-info h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tutorial-info p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
}

@media (max-width: 640px) {
    .tutorials-grid {
        grid-template-columns: 1fr;
    }
}