/* --- Core Newspaper Styles --- */
body {
  background-color: #f4f1ea; /* Old paper color */
  font-family: 'Merriweather', sans-serif;
  color: #333;
  margin: 0;
  padding: 0;
}

/* ============================================
   OLD NEWSPAPER SHADER EFFECT
   Vintage aging, texture, and print artifacts
   Applied globally to all pages
   ============================================ */

/* Global paper aging overlay - applied to main container */
.container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 100;
  /* Noise/grain texture using SVG filter */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: multiply;
}

/* Paper texture and aging overlay for news wrapper */
#news-wrapper,
.page-content,
.chat-container {
  position: relative;
}

#news-wrapper::before,
.page-content::before,
.chat-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
  /* Aged paper stains and discoloration */
  background: 
    /* Coffee stain effect */
    radial-gradient(ellipse at 15% 20%, rgba(139, 90, 43, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 75%, rgba(160, 120, 60, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 60% 10%, rgba(180, 140, 80, 0.05) 0%, transparent 35%);
  mix-blend-mode: multiply;
}

#news-wrapper::after,
.page-content::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 11;
  /* Additional subtle staining */
  background: 
    radial-gradient(ellipse at 25% 80%, rgba(150, 130, 90, 0.05) 0%, transparent 30%),
    radial-gradient(ellipse at 70% 30%, rgba(140, 120, 80, 0.04) 0%, transparent 25%);
  mix-blend-mode: multiply;
}

/* Sepia aging filter on content sections */
.news-grid-section,
.page-content,
.chat-container {
  filter: sepia(8%) contrast(1.02) brightness(0.98);
}

/* Ink bleeding and print imperfection on text */
.news-item h3 {
  text-shadow: 
    0.3px 0 0 rgba(0, 0, 0, 0.15),
    -0.2px 0 0 rgba(0, 0, 0, 0.1);
}

/* Varied ink density - some articles look slightly faded */
.news-pos-3,
.news-pos-7,
.news-pos-11 {
  opacity: 0.94;
}

.news-pos-4,
.news-pos-8 {
  filter: contrast(0.97) brightness(1.01);
}

/* Yellowed paper patches - subtle fading effects */
.news-pos-1 {
  background: 
    linear-gradient(135deg, rgba(200, 180, 140, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 30% 30%, rgba(255, 253, 248, 0.5) 0%, transparent 60%);
}

.news-pos-9 {
  background: 
    linear-gradient(45deg, transparent 50%, rgba(180, 160, 120, 0.04) 100%),
    radial-gradient(ellipse at 40% 40%, rgba(253, 252, 249, 0.5) 0%, transparent 65%);
}

.news-pos-12 {
  background:
    radial-gradient(ellipse at 80% 20%, rgba(170, 150, 110, 0.05) 0%, transparent 45%),
    radial-gradient(ellipse at 60% 50%, rgba(249, 246, 241, 0.45) 0%, transparent 60%);
}

/* Print registration slight misalignment effect on headlines */
.news-pos-1 h3 {
  text-shadow: 
    0.5px 0.3px 0 rgba(139, 35, 35, 0.08),
    -0.3px -0.2px 0 rgba(0, 50, 80, 0.05),
    0.4px 0 0 rgba(0, 0, 0, 0.2);
}

/* Worn edges effect */
.news-item {
  position: relative;
}

/* Subtle torn/worn corner hints */
.news-pos-1::before,
.news-pos-5::before,
.news-pos-10::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, transparent 50%, rgba(244, 241, 234, 0.5) 50%);
  pointer-events: none;
}

/* Faded masthead dates and meta info */
.news-item-meta {
  opacity: 0.85;
  filter: blur(0.2px);
}

/* Newspaper summary text - slight print variance */
.news-summary {
  letter-spacing: 0.01em;
  word-spacing: 0.02em;
}

.container {
  max-width: 1200px;
  margin: 20px auto;
  background-color: #faf7f0;
  box-shadow: 
    0 0 15px rgba(0,0,0,0.2),
    inset 0 0 80px rgba(139, 119, 80, 0.08);
  padding: 25px;
  border: 1px solid #c9bfa8;
  position: relative;
}

/* Aged paper texture on container */
.container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background: 
    /* Foxing (age spots) */
    radial-gradient(circle at 10% 15%, rgba(150, 120, 80, 0.12) 0%, transparent 3%),
    radial-gradient(circle at 92% 8%, rgba(140, 110, 70, 0.1) 0%, transparent 2%),
    radial-gradient(circle at 5% 85%, rgba(160, 130, 90, 0.08) 0%, transparent 4%),
    radial-gradient(circle at 88% 92%, rgba(145, 115, 75, 0.11) 0%, transparent 3%),
    radial-gradient(circle at 45% 5%, rgba(155, 125, 85, 0.07) 0%, transparent 2%),
    radial-gradient(circle at 75% 45%, rgba(135, 105, 65, 0.06) 0%, transparent 2.5%),
    /* Water damage hint */
    radial-gradient(ellipse at 95% 60%, rgba(180, 160, 130, 0.1) 0%, transparent 25%);
  z-index: 0;
}

/* --- Header & Masthead --- */
.masthead {
  text-align: center;
  border-bottom: 5px double #333;
  padding-bottom: 15px;
  margin-bottom: 20px;
  position: relative;
}

.masthead h1 {
  font-family: 'Playfair Display', serif;
  font-size: 5em;
  margin: 0;
  font-weight: 900;
  letter-spacing: -2px;
  /* Old letterpress ink effect */
  text-shadow: 
    1px 1px 0 rgba(0, 0, 0, 0.1),
    -0.5px -0.5px 0 rgba(255, 255, 255, 0.3),
    0.5px 0 0 rgba(0, 0, 0, 0.15);
  color: #1a1714;
}

.masthead-subline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.1em;
  font-weight: bold;
  color: #4a453e;
  margin-top: 10px;
  border-top: 1px solid #c9bfa8;
  border-bottom: 1px solid #c9bfa8;
  padding: 5px 0;
  /* Faded print effect */
  opacity: 0.9;
  letter-spacing: 0.02em;
}

/* --- Navigation --- */
.nav-bar {
  text-align: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #c9bfa8;
  padding-bottom: 15px;
  /* Subtle aged background */
  background: 
    linear-gradient(180deg, rgba(250, 247, 240, 0.5) 0%, transparent 100%);
}

.nav-bar button {
  font-family: 'Merriweather', serif;
  font-weight: 700;
  font-size: 1.2em;
  text-decoration: none;
  color: #2a2520;
  margin: 0 15px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s, text-shadow 0.2s;
  padding-bottom: 5px;
  border-bottom: 2px solid transparent;
  /* Vintage ink effect */
  text-shadow: 0.2px 0 0 rgba(0, 0, 0, 0.08);
}

.nav-bar button:hover {
  color: #1a1714;
  border-bottom: 2px solid #8b2323;
  text-shadow: 0.3px 0 0 rgba(0, 0, 0, 0.12);
}

.nav-bar button.active {
  color: #8b2323;
  border-bottom: 2px solid #8b2323;
  text-shadow: 0.3px 0 0 rgba(139, 35, 35, 0.15);
}

.nav-bar button:disabled {
    color: #999;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ============================================
   SEARCH BAR - Newspaper Style (Collapsible)
   ============================================ */
.search-bar-container {
  margin-bottom: 20px;
  padding: 0 0 15px 0;
  border-bottom: 1px solid #c9bfa8;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Subtle aged background like nav */
  background: 
    linear-gradient(180deg, rgba(250, 247, 240, 0.3) 0%, transparent 100%);
}

/* Search Toggle Button (Magnifying Glass) */
.search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background-color: transparent;
  border: 1px solid #c9bfa8;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.3s ease;
  /* Vintage styling */
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.08);
}

.search-toggle:hover {
  background-color: rgba(139, 35, 35, 0.08);
  border-color: #8b7355;
}

.search-toggle-icon {
  width: 20px;
  height: 20px;
  color: #5a4a3a;
  transition: color 0.2s;
}

.search-toggle:hover .search-toggle-icon {
  color: #8b2323;
}

/* Hide toggle when expanded */
.search-bar-container.expanded .search-toggle {
  display: none;
}

/* Search Form - Hidden by default */
.search-form {
  display: none;
  justify-content: center;
  align-items: center;
  width: 100%;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Show form when expanded */
.search-bar-container.expanded .search-form {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  animation: searchExpand 0.3s ease forwards;
}

@keyframes searchExpand {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 500px;
  position: relative;
  background-color: #faf7f0;
  border: 1px solid #c9bfa8;
  border-bottom: 2px solid #8b7355;
  padding: 0;
  /* Vintage paper inset */
  box-shadow: 
    inset 0 1px 3px rgba(139, 115, 85, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.5);
}

.search-input {
  flex: 1;
  font-family: 'EB Garamond', serif;
  font-size: 1.05em;
  font-style: italic;
  color: #2a2520;
  background: transparent;
  border: none;
  padding: 10px 12px;
  outline: none;
  letter-spacing: 0.02em;
  /* Old typewriter feel */
  text-shadow: 0.2px 0 0 rgba(0, 0, 0, 0.05);
}

.search-input::placeholder {
  color: #9a8b75;
  font-style: italic;
  opacity: 0.8;
}

.search-input:focus {
  background-color: rgba(255, 253, 248, 0.5);
}

.search-button {
  font-family: 'Merriweather', serif;
  font-weight: 700;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #faf7f0;
  background-color: #8b2323;
  border: none;
  padding: 10px 18px;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
  /* Letterpress button effect */
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 1px 2px rgba(0, 0, 0, 0.15);
}

.search-button:hover {
  background-color: #6b1a1a;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

.search-button:active {
  background-color: #5a1515;
  box-shadow: 
    inset 0 2px 3px rgba(0, 0, 0, 0.2);
}

/* Search Results Info - Only shown when expanded */
.search-results-info {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
  font-family: 'EB Garamond', serif;
  font-size: 0.95em;
  color: #5a5045;
}

.search-bar-container.expanded .search-results-info {
  display: flex;
}

.search-results-count {
  font-style: italic;
  /* Aged ink effect */
  text-shadow: 0.2px 0 0 rgba(0, 0, 0, 0.06);
}

.clear-search {
  font-family: 'Merriweather', serif;
  font-size: 0.85em;
  color: #8b2323;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid #c9bfa8;
  background-color: rgba(250, 247, 240, 0.6);
  transition: all 0.2s;
  /* Vintage button */
  text-shadow: 0.2px 0 0 rgba(139, 35, 35, 0.1);
}

.clear-search:hover {
  background-color: #faf7f0;
  border-color: #8b2323;
  color: #6b1a1a;
}

/* Mobile Search Styles */
@media (max-width: 600px) {
  .search-input-wrapper {
    max-width: 100%;
  }
  
  .search-input {
    font-size: 1em;
    padding: 8px 10px;
  }
  
  .search-button {
    font-size: 0.8em;
    padding: 8px 12px;
    letter-spacing: 0.5px;
  }
  
  .search-results-info {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* Tablet Search Styles */
@media (max-width: 900px) {
  .search-input-wrapper {
    max-width: 400px;
  }
}

/* --- Main Content Area - Newspaper Grid --- */
.page-content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(6, auto);
  gap: 0;
  border: 3px double #333;
  padding: 0;
  background-color: #fefefe;
}

/* --- News Article Base Styling --- */
.news-item {
  padding: 8px 10px;
  transition: background-color 0.2s ease;
  display: flex;
  flex-direction: column;
  background-color: #fefefe;
}

.news-item:hover {
  background-color: #faf8f5;
}

.news-item h3 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  margin: 0;
  padding-bottom: 4px;
  border-bottom: 1px solid #333;
  margin-bottom: 4px;
  line-height: 1.15;
}

.news-item a {
  text-decoration: none;
  color: #1a1a1a;
}

.news-item a:hover h3 {
  color: #8b2323;
}

.news-item-meta {
  font-family: 'EB Garamond', serif;
  font-size: 0.75em;
  color: #666;
  margin-bottom: 4px;
  font-style: italic;
}

.news-summary {
  font-family: 'Crimson Text', serif;
  line-height: 1.45;
  color: #333;
  flex-grow: 1;
}

.no-news-message {
  text-align: center;
  padding: 40px;
  font-style: italic;
  color: #777;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

/* ============================================
   NEWSPAPER 12-ARTICLE FIXED LAYOUT
   Grid: 4 columns × 6 rows
   ============================================ */

/* --- Position 1: HEADLINE / Lead Story --- */
/* Large feature spanning 2 cols × 2 rows - BIGGEST */
.news-pos-1 {
  grid-column: 1 / 3;
  grid-row: 1 / 3;
  background: radial-gradient(ellipse at 30% 30%, rgba(255, 253, 248, 0.6) 0%, transparent 50%);
  padding: 14px 16px;
}
.news-pos-1 h3 {
  font-size: 3em;
  font-weight: 900;
  letter-spacing: -1px;
  border-bottom: 3px double #333;
  padding-bottom: 10px;
  margin-bottom: 10px;
  line-height: 1.05;
}
.news-pos-1 .news-summary {
  font-size: 1.1em;
  line-height: 1.6;
}
.news-pos-1 .news-item-meta {
  font-size: 0.85em;
}

/* --- Position 2: Secondary Feature --- */
/* Tall story spanning 1 col × 2 rows */
.news-pos-2 {
  grid-column: 3;
  grid-row: 1 / 3;
}
.news-pos-2 h3 {
  font-size: 1.75em;
  font-weight: 700;
  line-height: 1.1;
}
.news-pos-2 .news-summary {
  font-size: 0.95em;
}

/* --- Position 3: Sidebar Top --- */
/* Single cell - compact */
.news-pos-3 {
  grid-column: 4;
  grid-row: 1;
  background: radial-gradient(ellipse at 70% 30%, rgba(249, 247, 242, 0.7) 0%, transparent 70%);
}
.news-pos-3 h3 {
  font-size: 0.92em;
  font-weight: 700;
  line-height: 1.2;
}
.news-pos-3 .news-summary {
  font-size: 0.78em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Position 4: Sidebar Second --- */
/* Single cell - compact */
.news-pos-4 {
  grid-column: 4;
  grid-row: 2;
  background: radial-gradient(ellipse at 60% 50%, rgba(250, 248, 243, 0.6) 0%, transparent 65%);
}
.news-pos-4 h3 {
  font-size: 0.88em;
  font-weight: 500;
  line-height: 1.2;
}
.news-pos-4 .news-summary {
  font-size: 0.75em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Position 5: Wide Middle-Left --- */
/* Spans 2 columns - medium-large */
.news-pos-5 {
  grid-column: 1 / 3;
  grid-row: 3;
}
.news-pos-5 h3 {
  font-size: 1.65em;
  font-weight: 700;
  line-height: 1.1;
}
.news-pos-5 .news-summary {
  font-size: 0.95em;
}

/* --- Position 6: Standard Cell --- */
/* Single cell - medium */
.news-pos-6 {
  grid-column: 3;
  grid-row: 3;
}
.news-pos-6 h3 {
  font-size: 1.1em;
  font-weight: 600;
  line-height: 1.15;
}
.news-pos-6 .news-summary {
  font-size: 0.82em;
}

/* --- Position 7: Sidebar Middle --- */
/* Single cell - smallest */
.news-pos-7 {
  grid-column: 4;
  grid-row: 3;
  background: radial-gradient(ellipse at 50% 60%, rgba(248, 245, 239, 0.6) 0%, transparent 60%);
}
.news-pos-7 h3 {
  font-size: 0.82em;
  font-weight: 400;
  line-height: 1.2;
}
.news-pos-7 .news-summary {
  font-size: 0.72em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Position 8: Bottom Row - Compact Left --- */
/* Single cell - small */
.news-pos-8 {
  grid-column: 1;
  grid-row: 4;
}
.news-pos-8 h3 {
  font-size: 0.98em;
  line-height: 1.2;
}
.news-pos-8 .news-summary {
  font-size: 0.78em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Position 9: Bottom Row - Tall Center --- */
/* Spans 2 rows vertically - medium-large */
.news-pos-9 {
  grid-column: 2;
  grid-row: 4 / 6;
  background: radial-gradient(ellipse at 40% 40%, rgba(253, 252, 249, 0.7) 0%, transparent 60%);
}
.news-pos-9 h3 {
  font-size: 1.55em;
  font-weight: 700;
  line-height: 1.1;
}
.news-pos-9 .news-summary {
  font-size: 0.9em;
  line-height: 1.55;
}

/* --- Position 10: Wide Bottom Center-Right --- */
/* Spans 2 columns - medium */
.news-pos-10 {
  grid-column: 3 / 5;
  grid-row: 4;
}
.news-pos-10 h3 {
  font-size: 1.4em;
  font-weight: 600;
  line-height: 1.15;
}
.news-pos-10 .news-summary {
  font-size: 0.88em;
}

/* --- Position 11: Bottom Left Corner --- */
/* Single cell - small */
.news-pos-11 {
  grid-column: 1;
  grid-row: 5;
}
.news-pos-11 h3 {
  font-size: 0.88em;
  line-height: 1.2;
}
.news-pos-11 .news-summary {
  font-size: 0.75em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Position 12: Wide Bottom Right --- */
/* Spans 2 columns - medium */
.news-pos-12 {
  grid-column: 3 / 5;
  grid-row: 5;
  background: radial-gradient(ellipse at 60% 50%, rgba(249, 246, 241, 0.6) 0%, transparent 65%);
}
.news-pos-12 h3 {
  font-size: 1.3em;
  line-height: 1.15;
}
.news-pos-12 .news-summary {
  font-size: 0.85em;
}

/* --- Additional articles beyond 12 - Row 6+ --- */
.news-pos-extra h3 {
  font-size: 0.9em;
}
.news-pos-extra .news-summary {
  font-size: 0.75em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Image Placeholder Styles --- */
/* Images have padding so they don't touch the outside border */
.image-placeholder {
  background-color: #fefefe;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none !important;
  padding: 8px;
  min-height: 120px;
}

/* Halftone dot pattern overlay for old print effect */
.image-placeholder::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  pointer-events: none;
  /* Halftone pattern using radial gradients */
  background-image: 
    radial-gradient(circle, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: multiply;
  opacity: 0.6;
  z-index: 1;
}

.image-placeholder:hover {
  opacity: 0.95;
}

.image-placeholder:hover::after {
  opacity: 0.3;
}

.placeholder-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Old newspaper halftone print effect */
  filter: grayscale(60%) sepia(30%) contrast(1.15) brightness(0.95);
  transition: filter 0.3s ease;
  min-height: 100px;
  /* Slight blur to simulate old print */
  image-rendering: auto;
}

.image-placeholder:hover .placeholder-image {
  filter: grayscale(30%) sepia(15%) contrast(1.08) brightness(0.98);
}

/* ============================================
   TABLET LAYOUT (2 columns)
   ============================================ */
@media (max-width: 900px) {
  .page-content {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
  }
  
  .news-pos-1 {
    grid-column: 1 / 3;
    grid-row: auto;
  }
  .news-pos-1 .news-summary {
    column-count: 1;
  }
  
  .news-pos-2 { grid-column: 1; grid-row: auto; }
  .news-pos-3 { grid-column: 2; grid-row: auto; border-right: none; }
  .news-pos-4 { grid-column: 1; grid-row: auto; }
  .news-pos-5 { 
    grid-column: 2; 
    grid-row: auto;
    border-right: none;
  }
  .news-pos-5 .news-summary {
    column-count: 1;
  }
  .news-pos-6 { grid-column: 1; grid-row: auto; }
  .news-pos-7 { grid-column: 2; grid-row: auto; border-right: none; }
  .news-pos-8 { grid-column: 1; grid-row: auto; }
  .news-pos-9 { 
    grid-column: 2; 
    grid-row: auto;
    border-right: none;
  }
  .news-pos-10 { 
    grid-column: 1 / 3; 
    grid-row: auto;
    border-right: none;
  }
  .news-pos-10 .news-summary {
    column-count: 1;
  }
  .news-pos-11 { grid-column: 1; grid-row: auto; }
  .news-pos-12 { 
    grid-column: 2; 
    grid-row: auto;
    border-right: none;
  }
  .news-pos-12 .news-summary {
    column-count: 1;
  }
  
  .news-item h3 {
    font-size: 1.1em;
  }
  .news-pos-1 h3 {
    font-size: 1.8em;
  }
}

/* ============================================
   MOBILE LAYOUT (single column)
   ============================================ */
@media (max-width: 600px) {
  .page-content {
    grid-template-columns: 1fr;
  }
  
  .news-pos-1,
  .news-pos-2,
  .news-pos-3,
  .news-pos-4,
  .news-pos-5,
  .news-pos-6,
  .news-pos-7,
  .news-pos-8,
  .news-pos-9,
  .news-pos-10,
  .news-pos-11,
  .news-pos-12 {
    grid-column: 1;
    grid-row: auto;
    border-right: none;
  }
  
  .news-pos-1 h3 {
    font-size: 1.6em;
  }
  
  .news-pos-1 .news-summary,
  .news-pos-5 .news-summary,
  .news-pos-10 .news-summary,
  .news-pos-12 .news-summary {
    column-count: 1;
  }
}

/* --- About Page Styles --- */
.about-section {
  margin-bottom: 25px;
  border-left: 3px solid #a52a2a;
  padding: 8px 10px;
  position: relative;
  /* Vintage paper patch effect */
  background: 
    linear-gradient(135deg, rgba(245, 240, 225, 0.4) 0%, transparent 100%);
}

/* Varied aging on different sections */
.about-section:nth-child(odd) {
  background: 
    linear-gradient(45deg, rgba(200, 180, 140, 0.06) 0%, transparent 60%),
    linear-gradient(135deg, rgba(245, 240, 225, 0.3) 0%, transparent 100%);
}

.about-section:nth-child(even) {
  background: 
    radial-gradient(ellipse at 90% 10%, rgba(170, 150, 110, 0.05) 0%, transparent 40%),
    linear-gradient(135deg, rgba(248, 244, 232, 0.35) 0%, transparent 100%);
}

.about-section h3 {
  font-family: 'Merriweather', serif;
  color: #a52a2a;
  margin: 0 0 10px 0;
  font-size: 1.3em;
  /* Ink bleeding effect */
  text-shadow: 
    0.3px 0 0 rgba(139, 35, 35, 0.15),
    -0.2px 0 0 rgba(139, 35, 35, 0.1);
}

.about-section p {
  margin: 8px 0;
  line-height: 1.6;
  /* Slight print imperfection */
  letter-spacing: 0.01em;
}

.tech-list {
  margin: 10px 0;
}

.tech-item {
  color: #444;
  margin: 3px 0;
}

.workflow-step {
  margin: 8px 0;
  padding-left: 20px;
  border-left: 2px solid #8b2323;
  /* Vintage step styling */
  background: 
    linear-gradient(90deg, rgba(245, 240, 225, 0.25) 0%, transparent 50%);
  padding: 6px 10px 6px 20px;
  position: relative;
}

.workflow-step strong {
  color: #3a352f;
  text-shadow: 0.2px 0 0 rgba(0, 0, 0, 0.08);
}

.schedule-table {
  margin: 20px 0;
  border-collapse: collapse;
  width: 100%;
  max-width: 600px;
  /* Vintage table effect */
  filter: sepia(5%) contrast(1.01);
}

.schedule-table td, .schedule-table th {
  border: 1px solid #a52a2a;
  padding: 8px 12px;
  text-align: left;
}

.schedule-table th {
  background-color: #f5f2ea;
  color: #8b2323;
  font-family: 'Merriweather', serif;
  font-weight: 700;
  /* Aged header */
  text-shadow: 0.2px 0 0 rgba(139, 35, 35, 0.1);
}

.schedule-table td {
  color: #3a352f;
  /* Alternate row aging */
  background: 
    linear-gradient(90deg, rgba(245, 240, 225, 0.3) 0%, transparent 100%);
}

.schedule-table tr:nth-child(odd) td {
  background: 
    linear-gradient(90deg, transparent 0%, rgba(240, 235, 220, 0.4) 100%);
}

.creator-info {
  margin-top: 30px;
  text-align: center;
  padding: 15px;
  border: 1px solid #c9bfa8;
  background-color: #f8f5ed;
  grid-column: 1 / -1; /* Make the creator info span all columns */
  /* Aged paper effect */
  background-image: 
    radial-gradient(ellipse at center, rgba(255, 252, 245, 0.5) 0%, transparent 70%),
    linear-gradient(180deg, rgba(245, 240, 225, 0.4) 0%, rgba(248, 244, 232, 0.3) 100%);
  box-shadow: inset 0 0 30px rgba(139, 119, 80, 0.06);
}

/* --- Article Page Styles --- */
/* When page-content is used for single article (not grid) */
.page-content[style*="display: block"] {
  padding: 20px 25px;
}

.article-headline {
  font-family: 'Playfair Display', serif;
  color: #1a1714;
  font-size: 2.5em;
  margin-bottom: 15px;
  text-align: center;
  border-bottom: 1px solid #ccc;
  padding-bottom: 10px;
  font-weight: 700;
  /* Old letterpress headline effect */
  text-shadow: 
    0.5px 0.3px 0 rgba(0, 0, 0, 0.12),
    -0.3px -0.2px 0 rgba(255, 255, 255, 0.2),
    0.4px 0 0 rgba(0, 0, 0, 0.18);
}

.article-meta {
  font-size: 0.9em;
  color: #777;
  margin-bottom: 20px;
  text-align: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
  /* Faded print effect */
  opacity: 0.88;
  filter: blur(0.15px);
}

.article-meta .article-date, .article-meta .article-author {
  margin-right: 15px;
}

.article-content {
  font-size: 1.1em;
  line-height: 1.8;
  color: #2a2520;
  margin-left: 0;
  text-align: justify;
  /* Vintage print text */
  letter-spacing: 0.01em;
  word-spacing: 0.03em;
  /* Column style like old newspapers */
  column-gap: 30px;
}

.article-content a {
  color: #8b2323;
  text-decoration: underline;
  /* Vintage ink link */
  text-shadow: 0.2px 0 0 rgba(139, 35, 35, 0.1);
  transition: color 0.2s, text-shadow 0.2s;
}

.article-content a:hover {
  color: #6b1a1a;
  text-shadow: 0.3px 0 0 rgba(107, 26, 26, 0.15);
}

/* Global link vintage styling */
a {
  transition: color 0.2s;
}

.creator-info a {
  color: #8b2323;
  text-shadow: 0.2px 0 0 rgba(139, 35, 35, 0.1);
}

.creator-info a:hover {
  color: #6b1a1a;
}

/* --- Chat Page Styles --- */
.chat-container {
  height: calc(100vh - 300px); /* Fill most of the screen, leaving space for header and nav */
  min-height: 600px;
  overflow-y: auto;
  border: 3px double #333; /* Double border like newspaper sections */
  padding: 20px;
  background-color: #faf7f0;
  font-family: 'Crimson Text', serif;
  /* Aged paper background */
  background-image: 
    radial-gradient(ellipse at 20% 30%, rgba(180, 160, 120, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 70%, rgba(160, 140, 100, 0.05) 0%, transparent 35%);
}

.chat-message {
  margin-bottom: 20px;
  line-height: 1.7;
  padding: 15px 20px;
  border-top: 1px solid #ccc;
  background-color: rgba(250, 248, 242, 0.7);
  position: relative;
  font-size: 1.1em;
  transition: all 0.3s ease;
  /* Vintage paper patches */
  background-image: 
    linear-gradient(135deg, rgba(245, 240, 225, 0.3) 0%, transparent 100%);
}

.chat-message:first-child {
  border-top: none;
  padding-top: 0;
}

.chat-message:nth-child(odd) {
  background-color: rgba(248, 245, 235, 0.8);
  /* Varied aging */
  background-image: 
    radial-gradient(ellipse at 10% 50%, rgba(170, 150, 110, 0.04) 0%, transparent 50%),
    linear-gradient(135deg, rgba(245, 240, 225, 0.3) 0%, transparent 100%);
}

.chat-message:nth-child(odd) .speaker-name {
  color: #1a1714; /* Aged black for odd messages */
  text-shadow: 0.3px 0 0 rgba(0, 0, 0, 0.1);
}

.chat-message:nth-child(odd) .message-content {
  color: #1a1714; /* Aged black text for odd messages */
}

.chat-message:nth-child(even) {
  background-color: rgba(254, 252, 246, 0.8);
  background-image: 
    radial-gradient(ellipse at 90% 50%, rgba(160, 140, 100, 0.03) 0%, transparent 40%),
    linear-gradient(45deg, rgba(248, 244, 232, 0.25) 0%, transparent 100%);
}

.chat-message:nth-child(even) .speaker-name {
  color: #8b2323; /* Faded red for even messages */
  text-shadow: 0.3px 0 0 rgba(139, 35, 35, 0.12);
}

.chat-message:nth-child(even) .message-content {
  color: #2a2520; /* Aged dark for even messages */
}

.speaker-name {
  font-family: 'Merriweather', serif;
  font-weight: 700;
  font-size: 1.2em;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: block;
  border-bottom: 1px solid #ddd;
  padding-bottom: 5px;
  /* Old print effect */
  text-shadow: 
    0.3px 0 0 rgba(0, 0, 0, 0.1),
    -0.2px 0 0 rgba(0, 0, 0, 0.08);
}

.message-content {
  font-family: 'Crimson Text', serif;
  text-align: justify;
  line-height: 1.6;
  /* Vintage print text */
  letter-spacing: 0.01em;
  word-spacing: 0.02em;
}

.message {
  opacity: 0;
  animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
  from { 
    opacity: 0;
    transform: translateY(10px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

/* Custom scrollbar for newspaper feel */
.chat-container::-webkit-scrollbar {
  width: 12px;
}

.chat-container::-webkit-scrollbar-track {
  background: #f4f1ea;
  border: 1px solid #ddd;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #a52a2a;
  border-radius: 6px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: #8b0000;
}

/* ============================================
   INFINITE SCROLL COMPONENTS
   ============================================ */

/* Wrapper for all grid sections - provides outer frame */
#news-wrapper {
  display: flex;
  flex-direction: column;
  border: 3px double #333;
  background-color: #fefefe;
}

/* Each grid section (batch of 12 articles) - no border, wrapper handles outer frame */
.news-grid-section {
  border: none;
}

/* Fade in animation for new sections */
.news-grid-section.fade-in {
  animation: sectionFadeIn 0.5s ease-out forwards;
}

@keyframes sectionFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Loading Indicator */
.scroll-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px 20px;
  font-family: 'EB Garamond', serif;
  font-style: italic;
  color: #666;
  font-size: 1.1em;
}

.scroll-loader.hidden {
  display: none;
}

.loader-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e8e4dc;
  border-top-color: #a52a2a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Scroll Sentinel for IntersectionObserver (invisible trigger element) */
.scroll-sentinel {
  height: 1px;
  width: 100%;
  visibility: hidden;
  pointer-events: none;
}

/* End of Content Indicator */
.end-of-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px;
  font-family: 'Playfair Display', serif;
  color: #888;
  font-size: 0.95em;
  letter-spacing: 1px;
}

.end-of-content.hidden {
  display: none;
}

.end-divider {
  flex: 0 0 60px;
  height: 1px;
  background: linear-gradient(to right, transparent, #ccc, transparent);
}

.end-text {
  text-transform: uppercase;
  white-space: nowrap;
}

/* Fade-in Animation for New Articles */
.news-item.fade-in {
  animation: articleFadeIn 0.3s ease-out forwards;
}

/* Important: ensure content is always visible after animation */
.news-item {
  opacity: 1;
  /* contain: layout style; improves rendering performance */
  contain: layout style;
}

@keyframes articleFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile performance: simpler animations for iOS */
@media (max-width: 768px) {
  .news-item.fade-in {
    animation: articleFadeInMobile 0.2s ease-out forwards;
  }
  
  .news-grid-section.fade-in {
    animation: sectionFadeIn 0.2s ease-out forwards;
  }
  
  /* Ensure content stays visible - critical for iOS scroll recycling */
  .news-item,
  .news-grid-section {
    opacity: 1 !important;
    transform: none !important;
  }
  
  /* Only animate when fade-in class is present */
  .news-item.fade-in {
    opacity: 0;
    animation: articleFadeInMobile 0.2s ease-out forwards;
  }
  
  .news-grid-section.fade-in {
    opacity: 0;
    animation: sectionFadeIn 0.2s ease-out forwards;
  }
}

@keyframes articleFadeInMobile {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Prefers reduced motion: disable animations for accessibility and performance */
@media (prefers-reduced-motion: reduce) {
  .news-item.fade-in,
  .news-grid-section.fade-in {
    animation: none;
    opacity: 1 !important;
    transform: none !important;
  }
  
  .loader-spinner {
    animation: none;
    border-top-color: #a52a2a;
    border-right-color: #a52a2a;
  }
}
