/* =================================================
   Color system (updated with new blue theme)
   ================================================= */
:root {
  --navbar-bg-color: #333;
  --text-color: #ffffff;
  --page-bg-color: #fdfcfb;
  --card-bg-color: rgba(255, 255, 255, 0.65);
  --border-color-light: #dddddd;
  --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.15);
  --accent-color: #007bff;
  --accent-hover: #0056b3;
  --light-accent: rgba(0, 123, 255, 0.15);
  --medium-accent: rgba(0, 123, 255, 0.25);
  --dark-accent: rgba(0, 123, 255, 0.4);
  --wipe-color-light: #007bff;
  --wipe-color-dark: #0056b3;
}

[data-theme="dark"] {
  --page-bg-color: #111;
  --text-color: #eee;
  --card-bg-color: rgba(30, 30, 40, 0.7);
  --border-color-light: rgba(255, 255, 255, 0.1);
  --accent-color: #007bff;
  --accent-hover: #66aaff;
  --light-accent: rgba(0, 123, 255, 0.15);
  --medium-accent: rgba(0, 123, 255, 0.25);
  --dark-accent: rgba(0, 123, 255, 0.4);
}

/* =================================================
   Base with proper footer positioning
   ================================================= */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  min-height: 100vh;
  background: var(--page-bg-color);
  color: #000;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* =================================================
   Background layers (updated for blue theme)
   ================================================= */
#greenBlobBg {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(
      circle at 20% 30%,
      rgba(0, 120, 255, 0.25) 0%,
      rgba(0, 120, 255, 0.12) 25%,
      rgba(0, 120, 255, 0.03) 45%,
      transparent 65%
    ),
    radial-gradient(
      circle at 80% 60%,
      rgba(0, 200, 255, 0.22) 0%,
      rgba(0, 200, 255, 0.10) 30%,
      rgba(0, 200, 255, 0.02) 50%,
      transparent 70%
    );
  filter: blur(40px);
}

[data-theme="dark"] #greenBlobBg {
  background:
    radial-gradient(
      circle at 20% 30%,
      rgba(0, 120, 255, 0.15) 0%,
      rgba(0, 120, 255, 0.07) 25%,
      rgba(0, 120, 255, 0.02) 40%,
      transparent 60%
    ),
    radial-gradient(
      circle at 80% 60%,
      rgba(0, 180, 255, 0.12) 0%,
      rgba(0, 180, 255, 0.05) 30%,
      rgba(0, 180, 255, 0.01) 45%,
      transparent 65%
    );
  filter: blur(40px);
}

#ambientLight {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(
      circle at center,
      rgba(0, 140, 255, 0.12) 0%,
      rgba(0, 140, 255, 0.05) 30%,
      rgba(0, 140, 255, 0.00) 60%
    );
}

[data-theme="dark"] #ambientLight {
  background:
    radial-gradient(
      circle at center,
      rgba(0, 120, 255, 0.08) 0%,
      rgba(0, 120, 255, 0.03) 20%,
      rgba(0, 120, 255, 0.00) 50%
    );
}

/* =================================================
   Navbar
   ================================================= */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
  background: rgba(20, 20, 20, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-color);
  z-index: 100;
}

.nav-title {
  font-size: 25px;
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  font-family: 'Courier New', Courier, monospace;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  border-radius: 50%;
}

.theme-toggle:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}

[data-theme="light"] .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

[data-theme="dark"] .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

[data-theme="dark"] .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* =================================================
   Blog Container - Main content area
   ================================================= */
.blog-container {
  max-width: 800px;
  margin: 100px auto 0;
  padding: 0 20px 40px;
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
}

.blog-header {
  text-align: center;
  margin-bottom: 50px;
  padding-bottom: 20px;
  position: relative;
}

.blog-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 3px;
  background: var(--accent-color);
}

.blog-main-title {
  font-size: 3rem;
  margin: 0 0 15px;
  color: rgb(25, 25, 25);
  font-weight: 700;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: -0.5px;
}

[data-theme="dark"] .blog-main-title {
  color: #f0f0f0;
}

/* =================================================
   Article Grid
   ================================================= */
.articles-grid {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* =================================================
   Article Header and Expand Button (Fixed for mobile)
   ================================================= */
.blog-article {
  background: var(--card-bg-color);
  border: 1px solid var(--border-color-light);
  border-radius: 14px;
  padding: 25px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-light);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.article-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 15px;
}

.article-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  min-height: 40px; /* Ensure minimum height for the button */
}

.article-title {
  font-size: 1.7rem;
  margin: 0;
  color: #000;
  flex: 1;
  font-weight: 700;
  line-height: 1.3;
  font-family: 'Georgia', serif;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  min-width: 0; /* Important: allows text to wrap */
}

[data-theme="dark"] .article-title {
  color: #fff;
}

.article-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent-color);
  transition: all 0.2s ease;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--light-accent);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  /* Position fixed for top-right placement */
  position: relative;
  top: 0;
  right: 0;
}

.article-expand-btn:hover {
  background: var(--medium-accent);
  transform: scale(1.05);
}

.blog-article.expanded .article-expand-btn {
  transform: rotate(180deg) scale(1.05);
}

.expand-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

/* =================================================
   Responsive Design (Fixed for mobile)
   ================================================= */
@media (max-width: 768px) {
  .blog-container {
    margin: 80px auto 0;
    padding: 0 15px 30px;
  }
  
  .blog-main-title {
    font-size: 2.5rem;
  }
  
  .blog-article {
    padding: 20px;
  }
  
  /* FIXED: Keep button at top right, allow title to wrap */
  .article-title-row {
    /* Remove flex-direction: column */
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    position: relative;
  }
  
  .article-title {
    font-size: 1.5rem;
    /* Allow title to wrap under button if needed */
    padding-right: 50px; /* Space for the button */
    box-sizing: border-box;
    margin-right: 0;
  }
  
  .article-expand-btn {
    /* Keep button at top right */
    position: absolute;
    right: 0;
    top: 0;
    margin-left: 0;
    align-self: flex-start;
    margin-top: 0;
  }
  
  /* Fix for very small screens */
  @media (max-width: 380px) {
    .article-title {
      font-size: 1.3rem;
      padding-right: 45px;
    }
    
    .article-expand-btn {
      width: 36px;
      height: 36px;
    }
  }
  
  .share-fallback-content {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .share-fallback-content p {
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .blog-main-title {
    font-size: 2rem;
  }
  
  .article-title {
    font-size: 1.3rem;
    padding-right: 48px;
  }
  
  /* Ensure the title text breaks properly */
  .article-title {
    word-break: break-word;
    hyphens: auto;
  }
  
  .share-btn {
    width: 100%;
    justify-content: center;
  }
  
  .share-fallback {
    width: 95%;
  }
}

/* Additional fix for extremely narrow screens */
@media (max-width: 320px) {
  .article-title-row {
    flex-wrap: nowrap; /* Prevent wrapping to new line */
  }
  
  .article-title {
    font-size: 1.2rem;
    line-height: 1.4;
    padding-right: 42px;
  }
  
  .article-expand-btn {
    width: 34px;
    height: 34px;
  }
  
  .expand-icon {
    width: 18px;
    height: 18px;
  }
}

/* =================================================
   Article Preview
   ================================================= */
.article-preview {
  margin-top: 10px;
}

.article-preview p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: #333;
  margin: 0;
  font-family: 'Georgia', serif;
}

[data-theme="dark"] .article-preview p {
  color: #ddd;
}

/* =================================================
   Article Content (expanded)
   ================================================= */
.article-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0;
  padding-top: 0;
}

.blog-article.expanded .article-content {
  max-height: 3000px;
  opacity: 1;
  margin-top: 25px;
  padding-top: 25px;
  border-top: 1px solid var(--border-color-light);
}

.article-content h3 {
  font-size: 1.5rem;
  margin: 25px 0 15px;
  color: #000;
  font-weight: 700;
  font-family: 'Georgia', serif;
}

[data-theme="dark"] .article-content h3 {
  color: #fff;
}

.article-content h4 {
  font-size: 1.25rem;
  margin: 20px 0 12px;
  color: #222;
  font-weight: 600;
  font-family: 'Georgia', serif;
}

[data-theme="dark"] .article-content h4 {
  color: #eee;
}

.article-content p {
  font-size: 1.05rem;
  line-height: 1.8;
  margin: 0 0 20px 0;
  color: #444;
  font-family: 'Georgia', serif;
}

[data-theme="dark"] .article-content p {
  color: #ccc;
}

.article-content ul, .article-content ol {
  margin: 15px 0 20px 25px;
  padding: 0;
}

.article-content li {
  margin-bottom: 10px;
  line-height: 1.7;
  color: #444;
  font-family: 'Georgia', serif;
}

[data-theme="dark"] .article-content li {
  color: #ccc;
}

.article-content li strong {
  color: var(--accent-color);
}

/* =================================================
   Article Footer
   ================================================= */
.article-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px dashed var(--border-color-light);
}

.article-actions {
  display: flex;
  justify-content: flex-end;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--light-accent);
  border: 1px solid var(--accent-color);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 1rem;
  color: var(--accent-color);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  font-family: system-ui, sans-serif;
}

.share-btn:hover {
  background: var(--medium-accent);
  transform: translateY(-1px);
}

.share-btn svg {
  width: 18px;
  height: 18px;
}

/* =================================================
   Footer
   ================================================= */
.footer {
  width: 100%;
  background: rgba(20, 20, 20, 0.9);
  color: var(--text-color);
  padding: 6px 0;
  font-size: 12px;
  display: flex;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

[data-theme="dark"] .footer {
  background: rgba(20, 20, 20, 0.9);
  color: var(--text-color);
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* =================================================
   Modern Share Fallback Message (Toast Notification)
   ================================================= */
.share-fallback {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  width: 90%;
  max-width: 400px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.share-fallback.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.share-fallback-content {
  background: var(--card-bg-color);
  padding: 16px 20px;
  border-radius: 12px;
  text-align: center;
  width: 100%;
  border: 1px solid var(--border-color-light);
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.share-fallback-content p {
  margin: 0;
  font-size: 1rem;
  color: var(--accent-color);
  font-weight: 500;
  flex: 1;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-fallback-content p::before {
  content: '✓';
  width: 22px;
  height: 22px;
  background: var(--accent-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: bold;
}

#close-share-fallback {
  background: var(--border-color-light);
  border: 1px solid var(--border-color-light);
  color: var(--text-color);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

#close-share-fallback:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

/* Specific styling for light and dark modes */
[data-theme="light"] #close-share-fallback {
  background: #f0f0f0;
  border-color: #ddd;
  color: #333;
}

[data-theme="light"] #close-share-fallback:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

[data-theme="dark"] #close-share-fallback {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-color);
}

[data-theme="dark"] #close-share-fallback:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #000;
}

/* =================================================
   Responsive Design
   ================================================= */
@media (max-width: 768px) {
  .blog-container {
    margin: 80px auto 0;
    padding: 0 15px 30px;
  }
  
  .blog-main-title {
    font-size: 2.5rem;
  }
  
  .blog-article {
    padding: 20px;
  }
  
  .article-title-row {
    flex-direction: column;
    gap: 10px;
  }
  
  .article-expand-btn {
    align-self: flex-end;
    margin-left: 0;
  }
  
  .article-title {
    font-size: 1.5rem;
  }
  
  .share-fallback-content {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .share-fallback-content p {
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .blog-main-title {
    font-size: 2rem;
  }
  
  .article-title {
    font-size: 1.3rem;
  }
  
  .share-btn {
    width: 100%;
    justify-content: center;
  }
  
  .share-fallback {
    width: 95%;
  }
}