/* ... Previous Custom CSS ... */

:root {
  /* Scientific Teal - Exact Match #2a9d8f */
  --primary-color: #2a9d8f;
  --primary-dark: #1d7066; /* Darker variant */
  --primary-light: #e0f2f1; /* Very light teal */
  --primary-alpha: rgba(42, 157, 143, 0.1);

  /* Modern Colors */
  --text-main: #333333;
  --bg-body: #ffffff;
  --bg-card: #f8f9fa;
  --border-color: #dee2e6;

  /* Styling */
  --border-radius: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg-body: #1a1a1a;
  --bg-card: #2d2d2d;
  --text-main: #e0e0e0;
  --border-color: #444;
  --primary-light: rgba(42, 157, 143, 0.2);
}

/* Global Typography & Structure */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-body);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header & Menu (Correct Classes: .menu__list, .menu__link) */
.header {
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.logo__link, .site-title a {
  color: var(--primary-color);
  font-weight: 800;
  text-decoration: none;
}

.menu__link {
  color: var(--text-main);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
}

.menu__link:hover {
  color: var(--primary-color);
  background-color: var(--primary-light);
  text-decoration: none;
}

/* Post Styling */
.post-title, .post__title {
  color: var(--text-main);
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.post-title a, .post__title a {
  color: var(--text-main);
  text-decoration: none;
  background-image: linear-gradient(transparent 90%, var(--primary-alpha) 90%);
  background-size: 0% 100%;
  background-repeat: no-repeat;
  transition: background-size 0.3s ease, color 0.3s ease;
}

.post-title a:hover, .post__title a:hover {
  color: var(--primary-color);
  background-size: 100% 100%;
}

/* Tags (Pill Style) */
.tags__link, .widget-taglist__link, .tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 9999px; /* Pill */
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  margin-right: 5px;
  margin-bottom: 5px;
  transition: all 0.2s ease;
}

.tags__link:hover, .widget-taglist__link:hover, .tag:hover {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Buttons (Teal Gradient) */
.btn, .read-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--border-radius);
  background-color: var(--primary-color);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.btn:hover, .read-more-btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: #fff;
}

/* Widgets & Sidebar */
.widget {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.widget__title {
  color: var(--text-main);
  border-bottom: 2px solid var(--primary-color);
  display: inline-block;
  padding-bottom: 5px;
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.widget__link {
  color: var(--text-main);
  text-decoration: none;
  transition: color 0.2s;
}

.widget__link:hover {
  color: var(--primary-color);
}

/* --- NEW STYLES BELOW --- */

/* 1. Table of Contents (Top Card Style) */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-sm);
}

.toc__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 15px;
  border-bottom: 2px solid var(--primary-alpha);
  padding-bottom: 8px;
  display: block; /* For summary tag */
  cursor: pointer;
  outline: none;
}

.toc__content ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc__content ul ul {
  padding-left: 20px;
  margin-top: 5px;
}

.toc__content li {
  margin-bottom: 8px;
}

.toc__content a {
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.95rem;
  transition: color 0.2s;
}

.toc__content a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

/* 2. Recommended Reads (Compact Cards Grid - 3 Columns - TIGHTER) */
.related-posts {
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.related-posts h3 {
    font-size: 1.5rem;
    margin-bottom: 25px;
    color: var(--primary-color);
    font-weight: 700;
}

.related-posts .grid-container {
    display: grid;
    grid-template-columns: 1fr; /* Single column */
    gap: 15px;
}

.compact-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.compact-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-alpha);
}

.compact-card__image {
    height: 120px; /* Reduced from 140px */
    overflow: hidden;
    position: relative;
}

.compact-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.compact-card:hover .compact-card__image img {
    transform: scale(1.05);
}

.compact-card__content {
    padding: 10px; /* Tighter padding */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.compact-card__title {
    font-size: 0.95rem; /* Smaller font */
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.compact-card__title a {
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.2s;
}

.compact-card__title a:hover {
    color: var(--primary-color);
}

.compact-card__excerpt {
    font-size: 0.8rem; /* Smaller font */
    color: var(--text-main);
    opacity: 0.8;
    margin-bottom: 10px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.compact-card__meta {
    font-size: 0.7rem; /* Tiny meta */
    color: var(--text-main);
    opacity: 0.6;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 6px;
}

/* 3. Post Metadata (Enhanced) */
.post__meta, .meta {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--text-main);
    opacity: 0.75;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.meta__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.meta__icon {
    fill: var(--primary-color);
    width: 14px;
    height: 14px;
}

.meta__text a {
    color: inherit; /* Inherit form parent opacity */
    text-decoration: none;
    font-weight: 500;
}

.meta__text a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* 4. Main Post List Cards (Homepage) */
.post-list .post {
    margin-bottom: 40px; /* Space between cards */
}

.card--horizontal {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

/* Fix for Summary.html partial inclusion */
.card__thumbnail {
    flex: 0 0 280px; /* Fixed width for thumbnail */
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
    min-height: 200px; /* Ensure height if empty */
    background-color: #eee; /* Placeholder bg */
}

/* Reset figure styles inserted by partial */
.card__thumbnail figure {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* Reset anchor styles inside thumbnail */
.card__thumbnail a.thumbnail__link {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

/* Ensure images (and SVGs) fill the container */
.card__thumbnail img, .list__thumbnail-flex {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    transition: transform 0.5s ease;
}

.card:hover .card__thumbnail img {
    transform: scale(1.03);
}

.card__content {
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card__title {
    margin-top: 0;
    font-size: 1.5rem;
    line-height: 1.3;
}

.card__excerpt {
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-main);
    opacity: 0.85;
}

.card__footer {
    margin-top: auto;
    text-align: right;
}

/* Footer Restore & Subscribe Widget */
.footer {
    /* Ensure footer looks like before (centered content usually) */
    text-align: center;
}

.subscribe-widget {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Responsive adjustments for horizontal cards */
@media (max-width: 768px) {
    .card--horizontal {
        flex-direction: column;
    }
    .card__thumbnail {
        flex: 0 0 200px; /* Height on mobile */
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        width: 100%;
    }
    .card__content {
        padding: 20px;
    }
}

/* --- JULES ENHANCEMENTS --- */
body {
    background-image: radial-gradient(var(--primary-alpha) 1px, transparent 1px);
    background-size: 24px 24px;
}

.widget, .compact-card, .toc, .card, .post {
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02), 0 10px 40px rgba(0,0,0,0.04);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: var(--bg-card);
    border-radius: 12px;
}

.widget:hover, .compact-card:hover, .toc:hover, .card:hover, .post:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.08), 0 5px 15px rgba(0,0,0,0.04);
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    box-shadow: 0 4px 15px rgba(42, 157, 143, 0.3);
    color: white;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 50px;
    letter-spacing: 0.5px;
}

.btn--primary:hover {
    box-shadow: 0 6px 20px rgba(42, 157, 143, 0.5);
    transform: translateY(-2px);
}

/* Post Content Typography */
.post__content {
    line-height: 1.8;
    font-size: 1.05rem;
}

.post__content h2 {
    color: var(--primary-dark);
    position: relative;
    padding-bottom: 10px;
    margin-top: 2em;
}

.post__content h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

.post__content blockquote {
    border-left: 4px solid var(--primary-color);
    background: linear-gradient(to right, var(--primary-light), transparent);
    padding: 1.5em;
    border-radius: 0 12px 12px 0;
    font-style: italic;
    color: var(--text-main);
    margin: 2em 0;
}

/* Load Comments Button specific */
#comments-list button {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    cursor: pointer;
}

/* Popup */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.popup-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
}

.popup-content h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 0.5em;
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-main);
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.popup-close:hover {
    opacity: 1;
}

/* Contact Page Form */
.contact-form {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-body);
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.form-status {
    margin-top: 15px;
    font-weight: 600;
    min-height: 24px;
}

.form-status.success { color: var(--primary-color); }
.form-status.error { color: #e63946; }


/* Comment Replies */
.comment {
    background: var(--bg-card);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.comment-date {
    font-size: 0.8rem;
    opacity: 0.7;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    margin-left: 10px;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--primary-dark);
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Responsive Images Fix */
img {
    max-width: 100%;
    height: auto;
}

.img-fluid {
    max-width: 100%;
    height: auto;
    display: block;
}

/* CLS Fixes */
#comments-list {
    min-height: 200px; /* Reserve space */
}

/* Fonts */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/Inter-Regular.woff2') format('woff2');
}
/* Assuming fonts are loaded from CDN or local, but font-display swap is key */
