/* ============================================================================
   RESET & BASE STYLES
   ============================================================================ */

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

:root {
    /* Color palette */
    --color-text-primary: #333;
    --color-text-secondary: #666;
    --color-text-tertiary: #757575;  /* Changed from #999 for better contrast (WCAG AA) */
    --color-background: #f5f5f5;
    --color-surface: #ffffff;
    --color-border: #e0e0e0;
    --color-accent: #0066cc;
    --color-accent-hover: #0052a3;
    --color-error-bg: #fee;
    --color-error-border: #fcc;
    --color-error-text: #c33;
    --color-code-bg: #f5f5f5;
    
    /* Spacing scale */
    --space-xs: 8px;
    --space-sm: 15px;
    --space-md: 20px;
    --space-lg: 30px;
    --space-xl: 40px;
    --space-xxl: 60px;
    
    /* Typography */
    --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-family-mono: 'Monaco', 'Courier New', monospace;
    --line-height-base: 1.6;
    --line-height-heading: 1.3;
    
    /* Layout */
    --container-max-width: 800px;
    --border-radius-sm: 3px;
    --border-radius-md: 5px;
    --border-radius-lg: 8px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
}

body {
    font-family: var(--font-family-base);
    line-height: var(--line-height-base);
    color: var(--color-text-primary);
    background: var(--color-background);
}

/* ============================================================================
   LAYOUT COMPONENTS
   ============================================================================ */

.container {
    max-width: var(--container-max-width);
    margin-inline: auto;
    padding-inline: var(--space-sm);
}

header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding-block: var(--space-md);
    margin-bottom: var(--space-xl);
}

header h1 {
    font-size: clamp(2rem, 5vw, 2.5rem);
    line-height: var(--line-height-heading);
    margin-bottom: var(--space-xs);
}

header h1 a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

.tagline {
    color: var(--color-text-secondary);
    font-size: 1.1rem;
}

main {
    min-height: 60vh;
}

footer {
    margin-top: var(--space-xxl);
    padding-block: var(--space-lg);
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.footer-links {
    margin-top: var(--space-sm);
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.9em;
}

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

/* Legacy footer styles (for backward compatibility) */
footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-xxl);
    padding-block: var(--space-lg);
    text-align: center;
    color: var(--color-text-tertiary);
}

.footer-links {
    margin-top: var(--space-sm);
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.9em;
}

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

/* ============================================================================
   POST LISTING COMPONENTS
   ============================================================================ */

#posts-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.post-preview {
    background: var(--color-surface);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast),
                box-shadow var(--transition-fast);
    overflow: hidden;
}

.post-preview:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.post-thumbnail {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    position: relative;
}

.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-fast);
}

.post-thumbnail:hover img {
    transform: scale(1.05);
}

.post-preview-content {
    padding: var(--space-lg);
}

@media (max-width: 600px) {
    .post-preview-content {
        padding: var(--space-md);
    }
}

.post-preview h2 {
    font-size: clamp(1.25rem, 3.5vw, 1.5rem);
    line-height: 1.3;
    margin: 0 0 var(--space-xs) 0;
}

.post-preview h2 a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.post-preview h2 a:hover {
    color: var(--color-accent);
}

.post-meta {
    color: var(--color-text-tertiary);
    font-size: 0.8rem;
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.post-excerpt {
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-sm);
}

.read-more {
    display: inline-block;
    margin-top: 0;
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color var(--transition-fast);
}

.read-more:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* Load More Button */
.load-more-container {
    text-align: center;
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
}

.load-more-button {
    display: inline-block;
    padding: var(--space-sm) var(--space-xl);
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.load-more-button:hover {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
}

.load-more-button:active {
    transform: translateY(0);
}

.posts-count {
    margin-top: var(--space-sm);
    color: var(--color-text-tertiary);
    font-size: 0.9rem;
}

/* Fade-in animation for dynamically loaded posts */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   ARTICLE / SINGLE POST COMPONENTS
   ============================================================================ */

article {
    background: var(--color-surface);
    padding: var(--space-md);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

article h1 {
    font-size: clamp(2rem, 5vw, 2.5rem);
    line-height: var(--line-height-heading);
    margin-bottom: var(--space-sm);
}

/* Hide the first h1 (page title for SEO) but keep it accessible */
article h1:first-of-type {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

article .post-meta {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

article p {
    margin-bottom: var(--space-md);
}

article h2 {
    font-size: clamp(1.5rem, 4vw, 1.8rem);
    line-height: var(--line-height-heading);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

article h3 {
    font-size: clamp(1.25rem, 3vw, 1.4rem);
    line-height: var(--line-height-heading);
    margin-top: 25px;
    margin-bottom: 12px;
}

article ul,
article ol {
    margin-block: var(--space-sm) var(--space-md);
    margin-inline-start: var(--space-lg);
}

article li {
    margin-bottom: var(--space-xs);
}

article a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

article code {
    background: var(--color-code-bg);
    padding: 2px 6px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family-mono);
    font-size: 0.9em;
}

article pre {
    background: var(--color-code-bg);
    padding: var(--space-sm);
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    margin-block: var(--space-md);
}

article pre code {
    background: none;
    padding: 0;
}

article table {
    width: 100%;
    border-collapse: collapse;
    margin-block: var(--space-lg);
    overflow-x: auto;
    display: block;
}

article table thead {
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
}

article table th {
    padding: var(--space-sm);
    text-align: left;
    font-weight: 600;
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-accent);
}

article table td {
    padding: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
}

article table tbody tr:hover {
    background: var(--color-background);
}

article table td strong {
    color: var(--color-accent);
}

article blockquote {
    border-left: 4px solid var(--color-accent);
    padding-left: var(--space-md);
    margin-block: var(--space-md);
    color: var(--color-text-secondary);
    font-style: italic;
}

/* ============================================================================
   RECOMMENDATIONS
   ============================================================================ */

.recommendations {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
}

.recommendations h2 {
    font-size: 1.3rem;
    margin-bottom: var(--space-sm);
    color: var(--color-text-primary);
}

.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 0;
}

.recommendation-card {
    background: var(--color-surface);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.recommendation-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.rec-thumbnail {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    position: relative;
}

.rec-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-fast);
}

.rec-thumbnail:hover img {
    transform: scale(1.05);
}

.rec-content {
    padding: 10px;
}

.recommendation-card h3 {
    font-size: 0.9rem;
    margin: 0 0 4px 0;
    line-height: 1.25;
    font-weight: 600;
}

.recommendation-card h3 a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.recommendation-card h3 a:hover {
    color: var(--color-accent);
}

.recommendation-card .post-meta {
    font-size: 0.65rem;
    margin-bottom: 6px;
    opacity: 0.6;
}

.recommendation-card p {
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--color-text-secondary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 768px) {
    .recommendations-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: var(--space-sm);
    }
}

/* ============================================================================
   YOUTUBE EMBED
   ============================================================================ */

.youtube-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin-block: var(--space-lg);
    background: var(--color-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================================================
   BACK LINK
   ============================================================================ */

.back-link {
    margin-top: var(--space-lg);
}

.back-link a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

/* ============================================================================
   UTILITY COMPONENTS
   ============================================================================ */

.loading {
    text-align: center;
    color: var(--color-text-tertiary);
    padding-block: var(--space-xl);
}

.error {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    padding: var(--space-md);
    border-radius: var(--border-radius-md);
    color: var(--color-error-text);
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    header {
        padding-block: var(--space-md);
    }
    
    article {
        padding: 25px;
    }
}

/* ============================================================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================================================ */

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (optional, respects system preference) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-text-primary: #e0e0e0;
        --color-text-secondary: #b0b0b0;
        --color-text-tertiary: #9e9e9e;  /* Improved contrast for dark mode (WCAG AA) */
        --color-background: #1a1a1a;
        --color-surface: #2a2a2a;
        --color-border: #3a3a3a;
        --color-accent: #4d9fff;
        --color-accent-hover: #6bb0ff;
        --color-code-bg: #333;
    }
}

/* Main homepage specific styles */
.intro {
  text-align: center;
  margin: 3rem 0;
  font-size: 1.2rem;
  color: #666;
}

.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.site-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 2rem;
  transition: box-shadow 0.3s ease;
  background: white;
}

.site-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.site-card h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.site-card h2 a {
  color: #007bff;
  text-decoration: none;
}

.site-card h2 a:hover {
  text-decoration: underline;
}

.site-card .tagline {
  color: #666;
  margin: 0.5rem 0 1rem 0;
  font-size: 0.95rem;
}

.site-card .visit-link {
  display: inline-block;
  color: #007bff;
  text-decoration: none;
  font-weight: 500;
  margin-top: 1rem;
}

.site-card .visit-link:hover {
  text-decoration: underline;
}
