/* CSS Variables for Theming */
:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f8;
    --bg-hover: #f5f5f5;
    --bg-article: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #444444;
    --text-muted: #666666;
    --border-color: #e0e0e0;
    --border-light: #e8e8e8;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --twitter-blue: #1da1f2;
    --selection-bg: #1da1f2;
    --selection-text: #ffffff;
    --header-bg: #ffffff;
    --footer-bg: #f8f8f8;
    --article-bg-hover: #f7f9fa;
}

[data-theme="dark"] {
    /* Dark theme colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-hover: #1c2128;
    --bg-article: #161b22;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border-color: #30363d;
    --border-light: #21262d;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --twitter-blue: #58a6ff;
    --selection-bg: #58a6ff;
    --selection-text: #0d1117;
    --header-bg: #161b22;
    --footer-bg: #0d1117;
    --article-bg-hover: #1c2128;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

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

/* Container */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 40px;
    transition: background-color 0.3s ease;
}

.header-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.twitter-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    transition: all 0.2s ease;
}

.twitter-link:hover {
    background-color: var(--bg-hover);
    border-color: var(--twitter-blue);
    color: var(--twitter-blue);
}

.twitter-link svg {
    width: 20px;
    height: 20px;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-hover);
    border-color: var(--twitter-blue);
}

.theme-toggle-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.sun-icon,
.moon-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
    stroke: currentColor;
}

.theme-toggle:hover .sun-icon,
.theme-toggle:hover .moon-icon {
    transform: rotate(20deg);
}

/* Show/hide icons based on theme */
[data-theme="light"] .sun-icon,
:not([data-theme]) .sun-icon {
    display: block;
}

[data-theme="light"] .moon-icon,
:not([data-theme]) .moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

.header-image {
    margin-top: 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
}

.header-image img {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0.95;
}

[data-theme="dark"] .header-image img {
    opacity: 0.85;
}

/* Main Content */
main {
    min-height: calc(100vh - 300px);
    padding-bottom: 60px;
}

/* Articles */
.articles {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.article-card {
    background-color: var(--bg-article);
    border-radius: 12px;
    padding: 30px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.article-card:last-child {
    border-bottom: none;
}

[data-theme="dark"] .article-card {
    background-color: transparent;
}

.article-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.article-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.article-text {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.article-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0 0 0;
    box-shadow: 0 2px 8px var(--shadow-color);
}

/* Remove bottom margin when image is last element */
.article-content > .article-image:last-child {
    margin-bottom: 0;
}

[data-theme="dark"] .article-image {
    opacity: 0.9;
}

/* Twitter Embed Container */
.twitter-embed-container {
    margin: 16px 0 0 0;
    display: flex;
    justify-content: center;
}

/* Remove bottom margin when embed is last element */
.article-content > .twitter-embed-container:last-child {
    margin-bottom: 0;
}

.twitter-tweet {
    max-width: 550px !important;
    width: 100% !important;
}

/* Dark theme adjustments for Twitter embeds */
[data-theme="dark"] .twitter-tweet-rendered iframe {
    opacity: 0.9;
}

/* Footer */
footer {
    background-color: var(--footer-bg);
    border-top: 1px solid var(--border-color);
    padding: 40px 0;
    margin-top: 80px;
    transition: background-color 0.3s ease;
}

footer p {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 5px 0;
    transition: color 0.3s ease;
}

footer a {
    color: var(--twitter-blue);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 20px;
    }
    
    .logo-section {
        width: 100%;
        justify-content: center;
    }
    
    nav {
        width: 100%;
        justify-content: center;
    }
    
    .article-title {
        font-size: 1.2rem;
    }
    
    .article-text {
        font-size: 1rem;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .header-container {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
    }
    
    .logo {
        width: 40px;
        height: 40px;
    }
    
    .twitter-link {
        font-size: 0.9rem;
        padding: 6px 12px;
    }
    
    .theme-toggle {
        font-size: 0.9rem;
        padding: 6px 10px;
    }
    
    .theme-toggle-text {
        display: none;
    }
    
    .article-card {
        padding: 20px 15px;
    }
}

/* Loading state for Twitter embeds */
.twitter-tweet.twitter-tweet-rendered {
    margin: 20px auto !important;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus states for accessibility */
a:focus,
button:focus {
    outline: 2px solid var(--twitter-blue);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    header,
    footer,
    .twitter-embed-container,
    .theme-toggle {
        display: none;
    }
    
    .article-card {
        page-break-inside: avoid;
    }
    
    body {
        font-size: 12pt;
        color: #000 !important;
        background-color: #fff !important;
    }
}

/* Animation for article cards on hover */
@media (hover: hover) {
    .article-card:hover {
        transform: translateY(-2px);
        background-color: var(--article-bg-hover);
    }
}

/* Selection color */
::selection {
    background-color: var(--selection-bg);
    color: var(--selection-text);
}

::-moz-selection {
    background-color: var(--selection-bg);
    color: var(--selection-text);
}

/* Smooth transitions for theme switching */
* {
    transition-property: none;
}

body.theme-transition,
body.theme-transition *,
body.theme-transition *::before,
body.theme-transition *::after {
    transition-property: background-color, color, border-color, box-shadow, opacity !important;
    transition-duration: 0.3s !important;
    transition-timing-function: ease !important;
}