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

:root {
    --primary-color: #ed6a5a;
    --secondary-color: #f4a688;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #222222;
    --text-muted: #666666;
    --border-color: #e0e0e0;
    --accent-color: #ed6a5a;
    --success-color: #5fc04b;
    --hover-bg: #fff5f3;
    --shadow-light: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.06);
    --error-bg: #fff5f5;
    --error-border: #ef4444;
    --error-text: #c53030;
}

/* Dark mode via data attribute (manual toggle) */
[data-theme="dark"] {
    --primary-color: #f4a688;
    --secondary-color: #ed6a5a;
    --bg-color: #1a1a1a;
    --card-bg: #2a2a2a;
    --text-color: #e5e5e5;
    --text-muted: #a0a0a0;
    --border-color: #404040;
    --accent-color: #f4a688;
    --success-color: #6fd65f;
    --hover-bg: #333333;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --error-bg: #3a1a1a;
    --error-border: #ef4444;
    --error-text: #fca5a5;
}

/* Dark mode via system preference (only if no manual preference set) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --primary-color: #f4a688;
        --secondary-color: #ed6a5a;
        --bg-color: #1a1a1a;
        --card-bg: #2a2a2a;
        --text-color: #e5e5e5;
        --text-muted: #a0a0a0;
        --border-color: #404040;
        --accent-color: #f4a688;
        --success-color: #6fd65f;
        --hover-bg: #333333;
        --shadow-light: rgba(0, 0, 0, 0.3);
        --shadow-medium: rgba(0, 0, 0, 0.2);
        --error-bg: #3a1a1a;
        --error-border: #ef4444;
        --error-text: #fca5a5;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* Theme toggle switch inside header */
.theme-switch {
    position: absolute;
    top: 16px;
    right: 16px;
}

.theme-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-switch label {
    display: inline-block;
    position: relative;
    width: 56px;
    height: 30px;
    cursor: pointer;
}

.switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--border-color);
    transition: background-color 0.2s ease;
}

.switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--card-bg);
    box-shadow: 0 2px 6px var(--shadow-light);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.switch-icons {
    position: absolute;
    top: 50%;
    left: 8px;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    font-size: 14px;
}

/* Slightly nudge sun icon right */
.theme-switch .icon-sun {
    display: inline-block;
    transform: translateX(3px);
}

.theme-switch .icon-moon {
    display: inline-block;
    transform: translateX(-2px);
}

.theme-switch input:checked + label .switch-track {
    background: var(--primary-color);
}

.theme-switch input:checked + label .switch-thumb {
    transform: translateX(26px);
}

header {
    position: relative;
    text-align: center;
    padding: 40px 20px;
    margin-bottom: 30px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

/* openFrameworks logo in title (image) */
.of-logo {
    height: 1.2em;
    width: auto;
    margin-right: 0.4rem;
    vertical-align: -0.2em;
    display: inline-block;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.rss-button {
    display: inline-block;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(237, 106, 90, 0.3);
}

.rss-button:hover {
    background: #d85a4a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(237, 106, 90, 0.4);
}

.last-updated {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    padding: 30px;
    background: var(--card-bg);
    border-radius: 12px;
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-light);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.search-box {
    margin-bottom: 30px;
}

#searchInput {
    width: 100%;
    padding: 16px 20px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(237, 106, 90, 0.1);
}

.loading {
    text-align: center;
    padding: 60px 20px;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.error {
    text-align: center;
    padding: 40px 20px;
    background: var(--error-bg);
    border: 2px solid var(--error-border);
    border-radius: 8px;
    color: var(--error-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.posts-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

.post-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px 24px;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: center;
    box-shadow: 0 1px 3px var(--shadow-medium);
}

.post-card:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(244, 166, 136, 0.25);
}

.post-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.post-title {
    font-size: 1.15rem;
    font-weight: 600;
}

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

.post-title a:hover {
    color: var(--primary-color);
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.875rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.post-author {
    color: var(--primary-color);
    font-weight: 600;
}

.stat {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
}

.post-dates {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 24px;
    border-left: 2px solid var(--border-color);
    text-align: right;
    min-width: 150px;
}

.post-date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.date-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.date-value {
    font-weight: 600;
    color: var(--text-color);
}

footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 60px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--secondary-color);
}

.github-link {
    margin-top: 10px;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .stats {
        gap: 20px;
    }

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

    .post-card {
        padding: 16px 20px;
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .post-dates {
        padding-left: 0;
        padding-top: 12px;
        border-left: none;
        border-top: 2px solid var(--border-color);
        text-align: left;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
