/* =============================================================================
   Design System
   ============================================================================= */

:root {
    /* Colors - Dark Mode (default) */
    --bg-primary: #000000;
    --text-primary: #fffaf6;     /* warm off-white */
    --text-secondary: #d4cfc9;   /* muted warm gray */
    --text-muted: #9a938c;       /* dimmer warm gray */
    --accent: #10b981;           /* emerald-500 (brighter for dark bg) */
    --accent-hover: #34d399;     /* emerald-400 */
    --border: #2a2a2a;           /* subtle dark gray */
    --badge-bg: #1a1a1a;
    --badge-text: #9a938c;
    --badge-early-bg: #2a2520;
    --badge-early-text: #fbbf24;
    --nav-bg: rgba(0, 0, 0, 0.95);
    --screenshot-bg: rgba(255, 255, 255, 0.02);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'EB Garamond', 'Crimson Text', Georgia, serif;
    --font-size-base: 17px;
    --font-size-small: 15px;
    --line-height: 1.7;

    /* Spacing - Tighter */
    --space-section: 80px;
    --space-section-mobile: 48px;
    --space-element: 24px;
    --space-small: 12px;

    /* Layout */
    --max-width: 680px;
    --nav-height: 60px;
}

/* Light Mode */
body.light-mode {
    --bg-primary: #fffaf6;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6a6a6a;
    --accent: #059669;
    --accent-hover: #047857;
    --border: #e5e5e5;
    --badge-bg: #f5f5f5;
    --badge-text: #6a6a6a;
    --badge-early-bg: #fef3c7;
    --badge-early-text: #92400e;
    --nav-bg: rgba(255, 250, 246, 0.95);
    --screenshot-bg: rgba(0, 0, 0, 0.02);
}

/* =============================================================================
   Base Styles
   ============================================================================= */

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-height) + 32px);
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* =============================================================================
   Typography
   ============================================================================= */

h1, h2, h3, h4, h5 {
    font-family: var(--font-serif);
    font-weight: 400;
}

h1 {
    font-size: 2.25rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.75rem;
    line-height: 1.3;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.375rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

h4 {
    font-size: 1.125rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

h5 {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1.25rem;
}

p:last-child {
    margin-bottom: 0;
}

/* Section dividers */
.section-divider {
    text-align: center;
    color: var(--text-muted);
    margin: var(--space-section) 0;
    font-size: 1.5rem;
    letter-spacing: 0.5em;
}

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

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.inline-link {
    text-decoration: none;
}

.inline-link:hover {
    text-decoration: underline;
}

/* =============================================================================
   Navigation
   ============================================================================= */

#main-nav {
    position: sticky;
    top: 0;
    background-color: var(--nav-bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    height: var(--nav-height);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 1.125rem;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-title:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-small);
    font-weight: 400;
    transition: color 0.2s ease;
}

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

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

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    border-radius: 4px;
}

.theme-toggle:hover {
    color: var(--accent);
}

.theme-toggle svg {
    transition: opacity 0.2s ease;
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

body.light-mode .sun-icon {
    display: block;
}

body.light-mode .moon-icon {
    display: none;
}

/* =============================================================================
   Layout
   ============================================================================= */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

.section {
    padding: var(--space-section) 0;
    border-bottom: 1px solid var(--border);
}

.section:last-child {
    border-bottom: none;
}

.section:first-child {
    padding-top: calc(var(--space-section) / 2);
}

.hero-section {
    padding-top: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: none;
}

/* =============================================================================
   Hero & Now Section
   ============================================================================= */

.tagline {
    font-size: 1.125rem;
    font-weight: 300;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.section-date {
    font-size: var(--font-size-small);
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1.5rem;
}

/* =============================================================================
   Writing Section
   ============================================================================= */

.writing-category {
    margin-bottom: 2.5rem;
}

.writing-category:last-child {
    margin-bottom: 0;
}

.writing-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.writing-item {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

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

.writing-description {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.read-link {
    display: inline-block;
    font-size: var(--font-size-small);
    font-weight: 500;
}

.writing-item h4 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.writing-item h4 a:hover {
    color: var(--accent);
}

.writing-date {
    font-size: var(--font-size-small);
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.writing-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.posts-loading,
.posts-empty,
.posts-error,
.content-loading,
.content-empty,
.content-error {
    color: var(--text-muted);
    font-style: italic;
}

.posts-error a,
.content-error a {
    color: var(--accent);
}

/* =============================================================================
   Projects Section
   ============================================================================= */

.project {
    margin-bottom: 3rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid var(--border);
}

.project:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.project-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.project-header h3 {
    margin-bottom: 0;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--badge-bg);
    color: var(--badge-text);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
}

.status-early {
    background-color: var(--badge-early-bg);
    color: var(--badge-early-text);
}

.project-hook {
    font-size: 1.0625rem;
    font-weight: 400;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.project-features {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.project-features h4 {
    margin-bottom: 2rem;
}

.feature {
    margin-bottom: 2.5rem;
}

.feature:last-child {
    margin-bottom: 0;
}

.feature h5 {
    margin-bottom: 1rem;
}

.screenshot-placeholder {
    background-color: var(--screenshot-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2.5rem 1.5rem;
    margin: 1rem 0 1.25rem;
    text-align: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.screenshot-placeholder p {
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--font-size-small);
    margin: 0;
}

.project-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;
}

.project-link {
    font-weight: 500;
}

/* =============================================================================
   Contact Section
   ============================================================================= */

.contact-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.contact-item {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.email-copy {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: var(--font-size-small);
}

.copy-button {
    padding: 0.375rem 0.75rem;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.copy-button:hover {
    background-color: var(--accent-hover);
}

.copy-button:active {
    transform: scale(0.98);
}

.contact-links {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
}

.contact-link {
    font-weight: 500;
}

/* =============================================================================
   Toast Notification
   ============================================================================= */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(200%);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media (max-width: 768px) {
    :root {
        --font-size-base: 16px;
        --nav-height: 56px;
    }

    h1 {
        font-size: 1.875rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .container {
        padding: 0 1.5rem;
    }

    .nav-container {
        padding: 0 1.5rem;
    }

    .nav-links {
        gap: 1.25rem;
    }

    .section {
        padding: var(--space-section-mobile) 0;
    }

    .hero-section {
        padding-top: 2.5rem;
    }

    .contact-links {
        flex-direction: column;
        gap: 0.75rem;
    }

    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

@media (max-width: 480px) {
    .nav-links a {
        font-size: 0.875rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .nav-right {
        gap: 1rem;
    }

    .theme-toggle {
        padding: 0.375rem;
    }

    .theme-toggle svg {
        width: 18px;
        height: 18px;
    }

    .project-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .screenshot-placeholder {
        padding: 2rem 1rem;
    }
}
