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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  background: #f8f9fa;
  color: #333;
}

/* Typography System */
h1, h2, h3, h4, h5, h6,
.site-header h1,
.race-title,
.section-title {
  font-family: 'Montserrat Alternates', 'Poppins', sans-serif;
  font-weight: 600;
}

.race-title {
  font-weight: 700;
}

/* Enhanced button and link styling */
.nav-link,
.race-link,
button {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
}

/* Header Styles */
.site-header {
  background: linear-gradient(135deg, #0056b3 0%, #004494 100%);
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.site-header h1 a {
  color: white;
  text-decoration: none;
  font-size: 1.8rem;
  font-weight: 700;
}

.main-nav {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-weight: 500;
}

.nav-link:hover {
  background: rgba(255,255,255,0.1);
  transform: translateY(-1px);
}

/* Container Layout */
.site-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
}

/* Main Content */
.main-content {
  min-height: 500px;
}

/* Race Cards */
.races-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.race-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.race-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.race-card-header {
  background: linear-gradient(135deg, #0056b3, #004494);
  color: white;
  padding: 1rem;
  position: relative;
}

.race-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.race-indicators {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.discipline-icon {
  font-size: 1.2rem;
  opacity: 0.9;
}

.country-flag {
  font-size: 1rem;
  opacity: 0.9;
}

.race-date {
  font-size: 0.9rem;
  opacity: 0.9;
  margin: 0;
}

.race-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  clear: both;
}

.race-card-body {
  padding: 1.5rem;
}

.race-summary {
  color: #666;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.race-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid #eee;
  font-size: 0.9rem;
  color: #777;
}

.race-link {
  color: #0056b3;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

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

/* Sidebar */
.sidebar {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 1.5rem;
  height: fit-content;
  position: sticky;
  top: 2rem;
}

.sidebar h3 {
  color: #0056b3;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e9ecef;
}

.year-navigation {
  margin-bottom: 2rem;
}

.month-link {
  display: block;
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  background: #f8f9fa;
  border-radius: 6px;
  text-decoration: none;
  color: #333;
  transition: all 0.3s ease;
}

.month-link:hover {
  background: #e9ecef;
  transform: translateX(4px);
}

.month-link.current {
  background: linear-gradient(135deg, #0056b3, #004494);
  color: white;
}

.race-count {
  display: block;
  font-size: 0.8rem;
  opacity: 0.8;
  margin-top: 0.2rem;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-item {
  text-align: center;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 6px;
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: bold;
  color: #0056b3;
}

.stat-label {
  font-size: 0.9rem;
  color: #666;
}

/* Footer */
.site-footer {
  background: #2c3e50;
  color: #ecf0f1;
  padding: 3rem 0 1rem;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.footer-section h4 {
  color: #3498db;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.footer-section a {
  color: #bdc3c7;
  text-decoration: none;
}

.footer-section a:hover {
  color: #3498db;
}

.footer-bottom {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding: 1rem 2rem;
  border-top: 1px solid #34495e;
  text-align: center;
  font-size: 0.9rem;
  color: #bdc3c7;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

table th, table td {
  padding: 0.8rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #555;
}

table tr:hover {
  background-color: #f8f9fa;
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2rem 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 3px solid #0056b3;
}

.section-title {
  color: #0056b3;
  font-size: 1.8rem;
  font-weight: 600;
  margin: 0;
}

.view-all-link {
  color: #0056b3;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.view-all-link:hover {
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }
  
  .main-nav {
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
  }
  
  .site-container {
    grid-template-columns: 1fr;
    padding: 0 1rem;
  }
  
  .races-grid {
    grid-template-columns: 1fr;
  }
  
  .race-card {
    margin: 0;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

/* Page-specific styles */
.page-intro {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
}

.page-intro h1 {
  color: #0056b3;
  margin-bottom: 1rem;
}

.page-intro p {
  color: #666;
  font-size: 1.1rem;
  line-height: 1.7;
}

/* Enhanced paragraph styling for race content */
.main-content p {
  text-align: justify;
  margin-bottom: 1.8rem;
  line-height: 1.8;
  font-size: 1.05rem;
  color: #333;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Special styling for the first paragraph after headers */
.main-content h2 + p,
.main-content h3 + p {
  margin-top: 1rem;
}

/* Better spacing for content sections */
.main-content h1 {
  margin: 2rem 0 1.5rem 0;
  color: #0056b3;
  line-height: 1.3;
}

.main-content h2 {
  margin: 2.5rem 0 1.2rem 0;
  color: #2c3e50;
  line-height: 1.4;
  border-bottom: 2px solid #e74c3c;
  padding-bottom: 0.5rem;
}

.main-content h3 {
  margin: 2rem 0 1rem 0;
  color: #34495e;
  line-height: 1.4;
}

/* Override for race title cards - keep them white */
.main-content h3.race-title {
  color: #fff;
}

/* Table styling improvements */
.main-content table {
  margin: 2rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.main-content table th,
.main-content table td {
  padding: 1rem 0.8rem;
}

/* Better spacing for lists */
.main-content ul,
.main-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

.main-content li {
  margin-bottom: 0.8rem;
  line-height: 1.7;
  text-align: justify;
}

/* Blockquote improvements */
.main-content blockquote {
  margin: 2rem 0;
  padding: 1.5rem;
  border-left: 4px solid #e74c3c;
  background: #f8f9fa;
  border-radius: 0 8px 8px 0;
}

.main-content blockquote p {
  margin-bottom: 0;
  font-style: italic;
}

/* Author signature styling */
.main-content hr + p strong {
  color: #0056b3;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .main-content p {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
  }
  
  .main-content h1 {
    font-size: 1.8rem;
    margin: 1.5rem 0 1rem 0;
  }
  
  .main-content h2 {
    font-size: 1.4rem;
    margin: 2rem 0 1rem 0;
  }
  
  .main-content h3 {
    font-size: 1.2rem;
    margin: 1.5rem 0 0.8rem 0;
  }
}

/* ========================================
   Amazon Affiliate Block Styles
   ======================================== */

.affiliate-block {
  margin: 2.5rem 0;
  padding: 2rem;
  background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
  border-radius: 10px;
  border-left: 5px solid #0056b3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.affiliate-block-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.affiliate-block h3 {
  color: #0056b3;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  font-family: 'Poppins', sans-serif;
}

.affiliate-block h3::before {
  content: "🛒 ";
  display: inline-block;
  margin-right: 0.5rem;
}

.affiliate-disclaimer {
  font-size: 0.7rem;
  color: #777;
  font-style: italic;
  max-width: 100%;
  text-align: right;
  line-height: 1.3;
}

.affiliate-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 1rem;
}

.product-card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(0, 86, 179, 0.2);
  border-color: #0056b3;
}

/* Product image - Removed */
/* .product-image { ... } */

.product-category {
  display: inline-block;
  font-size: 0.75rem;
  color: #0056b3;
  background: #e3f2fd;
  padding: 0.3rem 0.8rem;
  border-radius: 12px;
  margin-bottom: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  align-self: flex-start;
}

.product-name {
  font-weight: 700;
  color: #222;
  margin-bottom: 0.6rem;
  font-size: 1.05rem;
  line-height: 1.4;
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  display: inline-block;
  font-size: 0.75rem;
  color: #0056b3;
  background: #e3f2fd;
  padding: 0.3rem 0.8rem;
  border-radius: 12px;
  margin: 0 !important;
  margin-bottom: 0.8rem !important;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  align-self: flex-start;
}

.product-description {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 1.2rem;
  line-height: 1.5;
  flex-grow: 1;
}

.product-cta {
  background: linear-gradient(135deg, #0056b3 0%, #004494 100%);
  color: white;
  padding: 0.8rem 1.8rem;
  border-radius: 8px;
  text-decoration: none;
  display: inline-block;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
  box-shadow: 0 2px 6px rgba(0, 86, 179, 0.3);
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  margin-top: auto;
}

.product-cta:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 86, 179, 0.4);
  text-decoration: none;
  color: white;
  background: linear-gradient(135deg, #0066cc 0%, #0055aa 100%);
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
  .affiliate-products-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .affiliate-block {
    padding: 1.5rem;
    margin: 2rem 0;
  }
  
  .product-card {
    padding: 1.2rem;
  }
  
  .affiliate-block-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .affiliate-disclaimer {
    text-align: left;
    margin-top: 0.5rem;
    max-width: 100%;
    font-size: 0.65rem;
  }
}

/* Responsive Design - Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .affiliate-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* Sidebar Affiliate Section - Force single column */
.sidebar-affiliate-section {
  margin-top: 2rem;
}

.sidebar-affiliate-section .affiliate-block {
  padding: 1.2rem;
  margin: 0;
}

.sidebar-affiliate-section .affiliate-products-grid {
  grid-template-columns: 1fr;
  gap: 1.2rem;
}

.sidebar-affiliate-section .product-card {
  padding: 1rem;
}

.sidebar-affiliate-section .affiliate-block h3 {
  font-size: 1.1rem;
}

.sidebar-affiliate-section .affiliate-disclaimer {
  font-size: 0.65rem;
  text-align: left;
  max-width: 100%;
}

/* Grid Inline Affiliate - Spans full width in grid */
.grid-inline-affiliate {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.grid-inline-affiliate .affiliate-block {
  max-width: 100%;
  background: linear-gradient(to bottom, #f0f7ff 0%, #ffffff 100%);
}

.grid-inline-affiliate .affiliate-products-grid {
  grid-template-columns: repeat(3, 1fr);
  max-width: 100%;
  gap: 1.5rem;
}

/* Article Affiliate Section - After first h2 in race articles */
.article-affiliate-section {
  margin: 2rem 0;
  max-width: 100%;
}

.article-affiliate-section .affiliate-block {
  background: linear-gradient(to bottom, #f0f7ff 0%, #ffffff 100%);
  border-left-color: #0056b3;
}

.article-affiliate-section .affiliate-products-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* Mobile responsiveness for inline affiliate blocks */
@media (max-width: 768px) {
  .grid-inline-affiliate .affiliate-products-grid,
  .article-affiliate-section .affiliate-products-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-inline-affiliate .affiliate-products-grid,
  .article-affiliate-section .affiliate-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
  }
}
