/*
  learn.css - Revamped for Glassmorphism, Dark/Light Mode, and Modern UI
*/

:root {
  --bg-main: #020617;
  /* Core Palette - Premium & Modern */
  --blue1: #38bdf8;
  /* Sky 400 */
  --blue2: #0ea5e9;
  /* Sky 500 */
  --blue3: #0284c7;
  /* Sky 600 */
  --blue4: #0369a1;
  /* Sky 700 */
  --blue5: #0c4a6e;
  /* Sky 900 */

  --purple1: #a78bfa;
  /* Violet 400 */
  --purple2: #8b5cf6;
  /* Violet 500 */
  --purple3: #7c3aed;
  /* Violet 600 */
  --purple4: #6d28d9;
  /* Violet 700 */
  --purple5: #5b21b6;
  /* Violet 800 */
  --purple6: #4c1d95;
  /* Violet 900 */

  --accent-gradient: linear-gradient(135deg, var(--blue2), var(--purple2));
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur: blur(12px);

  /* Tines Pastel Colors (Light side) */
  --tines-1-light: #fff1f2;
  --tines-1-dark: #fb7185;
  /* Rose */
  --tines-2-light: #f5f3ff;
  --tines-2-dark: #8b5cf6;
  /* Violet */
  --tines-3-light: #ecfeff;
  --tines-3-dark: #06b6d4;
  /* Cyan */
  --tines-4-light: #fdf4ff;
  --tines-4-dark: #d946ef;
  /* Fuchsia */
}

/* Light / Dark Theme Variables */
html.light-theme body {
  --bg-main: #f8fafc;
  /* Slate 50 */
  --text-main: #0f172a;
  /* Slate 900 */
  --text-sub: #334155;
  /* Slate 700 */
  --text-muted: #64748b;
  /* Slate 500 */
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  /* Slate 200 */
  --glass-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
  --tag-bg: #f1f5f9;
  /* Slate 100 */
  --tag-text: #475569;
  /* Slate 600 */
  --compact-card-bg: #f8fafc;
  --input-border: #cbd5e1;
  /* Slate 300 */
  --hero-bg-gradient: radial-gradient(circle at top right, #e0f2fe, transparent 40%), radial-gradient(circle at bottom left, #f5f3ff, transparent 40%);
}

html.dark-theme body {
  --bg-main: #020617;
  /* Slate 950 */
  --text-main: #f8fafc;
  /* Slate 50 */
  --text-sub: #cbd5e1;
  /* Slate 300 */
  --text-muted: #94a3b8;
  /* Slate 400 */
  --card-bg: #0f172a;
  /* Slate 900 */
  --card-border: #1e293b;
  /* Slate 800 */
  --glass-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --tag-bg: #1e293b;
  /* Slate 800 */
  --tag-text: #e2e8f0;
  /* Slate 200 */
  --compact-card-bg: #1e293b;
  --input-border: #334155;
  /* Slate 700 */
  --hero-bg-gradient: radial-gradient(circle at top right, rgba(14, 165, 233, 0.15), transparent 40%), radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.15), transparent 40%);
  background: #020617 !important;
  color: #f8fafc !important;
}

/* Reading Mode (Post Pages) - Dark Mode Enforcement */
body.post-page {
  /* Enforce Dark Theme Variables for Reading Pages */
  --bg-main: #000000;
  /* Deep Black */
  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-muted: #94a3b8;
  --card-bg: #0f172a;
  --card-border: #1e293b;

  /* Unique Background for Reading Pages */
  background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #000000 60%);
  /* Deep Indigo to Black */
  min-height: 100vh;
}

/* Reading Mode - White/Light Mode */
body.post-page.post-page-light {
  --bg-main: #ffffff;
  --text-main: #0f172a;
  /* Slate 900 */
  --text-sub: #334155;
  /* Slate 700 */
  --text-muted: #64748b;
  /* Slate 500 */
  --card-bg: #f8fafc;
  /* Slate 50 */
  --card-border: #e2e8f0;
  /* Slate 200 */

  background: linear-gradient(to bottom, #ffffff, #f8fafc);
  min-height: 100vh;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  margin: 0;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* Layout Wrapper */
.main-content {
  width: 100%;
  max-width: 1200px;
  margin: 6rem auto 4rem auto;
  padding: 2rem;
  flex: 1;
  box-sizing: border-box;
}

/* Search Bar */
.search-container {
  margin-bottom: 2.5rem;
  position: relative;
  max-width: 600px;
  margin: 0 auto 3rem auto;
}

.search-input {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  border-radius: 50px;
  border: 1px solid var(--input-border);
  background: var(--card-bg);
  color: var(--text-main);
  box-sizing: border-box;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: var(--glass-shadow);
}

.search-input:focus {
  border-color: var(--blue2);
  box-shadow: 0 0 0 3px rgba(0, 182, 255, 0.1);
}

/* Hero Section */
.hero-wrapper {
  padding: 10rem 0 6rem 0;
  text-align: center;
  position: relative;
  background-image: var(--hero-bg-gradient);
  overflow: hidden;
}

.hero-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(circle, #646464 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 100%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 100%);
  opacity: 0.5;
  pointer-events: none;
}

.hero-title {
  font-size: 4.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: var(--text-main);
  letter-spacing: -0.04em;
  line-height: 1.1;
  position: relative;
  z-index: 1;
}

.hero-subtitle {
  font-size: 1.35rem;
  color: var(--text-sub);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
  font-weight: 400;
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

/* Theme Toggle Floating */
.theme-toggle-btn {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  color: var(--text-main);
  box-shadow: var(--glass-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle-btn:hover {
  transform: scale(1.1);
  background: var(--card-bg);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

/* --- Blog Grid & Cards --- */
.blog-list {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem;
  /* Reduced gap for tighter packing */
  margin-top: 2rem;
}

/* Base Card */
.blog-card {
  position: relative;
  border-radius: 16px;
  /* Slightly smaller radius */
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: var(--card-bg);
  border: 1px solid transparent;
  box-shadow: var(--glass-shadow);
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Type 1: Image Cards - Updated for Smaller Size */
.blog-card.has-image {
  grid-column: span 4;
  /* Changed from 6 to 4 (3 cards per row) */
  background: #ffffff;
}

html.dark-theme .blog-card.has-image {
  background: var(--card-bg);
}

.blog-card.has-image .card-image-link {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  padding: 0;
  text-decoration: none;
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--card-bg);
}

.card-image-blur {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  filter: blur(20px);
  opacity: 0.6;
  transform: scale(1.1);
  /* Prevent blur edges showing white */
}

.card-image-contain {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
  transition: transform 0.5s ease;
}

.blog-card.has-image:hover .card-image-contain {
  transform: scale(1.05);
}

.blog-card.has-image .card-content {
  padding: 1rem 1.25rem;
  /* Compact padding */
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.blog-card.has-image .card-title {
  font-size: 1.15rem;
  /* Smaller title */
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.3rem 0;
  line-height: 1.3;
}

.blog-card.has-image .arrow {
  opacity: 0;
  transform: translateX(-5px);
  transition: all 0.2s;
  color: var(--blue2);
}

.blog-card.has-image:hover .arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Post Layout Grid (Sidebar) */
.post-layout-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .post-layout-grid {
    grid-template-columns: 1fr;
  }
}

/* Compact Card Style (Image as Background) */
.compact-card {
  position: relative;
  height: 200px;
  /* Adjust as needed */
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  text-decoration: none;
  transition: transform 0.3s;
  box-shadow: var(--glass-shadow);
}

.compact-card:hover {
  transform: scale(1.02);
}

.compact-card-image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1;
}

.compact-card-blur {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  filter: blur(15px);
  opacity: 0.7;
  transform: scale(1.1);
  transition: transform 0.5s;
}

.compact-card-contain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
  transition: transform 0.5s;
}

.compact-card:hover .compact-card-blur {
  transform: scale(1.2);
}

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

.compact-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.2));
  z-index: 2;
}

.compact-card-content {
  position: relative;
  z-index: 3;
  padding: 1rem;
  width: 100%;
}

.compact-card-title {
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.compact-card-date {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: var(--text-main);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

html.light-theme .markdown-body h1 {
  color: var(--purple1);
  border-bottom-color: var(--purple1);
}

html.light-theme .markdown-body h2 {
  color: var(--purple2);
  border-bottom-color: var(--purple2);
}

html.dark-theme .markdown-body h1 {
  color: var(--blue1);
  border-bottom-color: var(--blue1);
}

html.dark-theme .markdown-body h2 {
  color: var(--purple4);
  border-bottom-color: var(--purple4);
}

body.post-page-light .markdown-body h1 {
  color: var(--purple2);
  border-bottom-color: var(--purple2);
}

body.post-page-light .markdown-body h2 {
  color: var(--purple3);
  border-bottom-color: var(--purple3);
}

.markdown-body p,
.markdown-body li {
  color: var(--text-main);
}

.markdown-body blockquote {
  background: var(--tag-bg);
  color: var(--text-sub);
  border-left: 4px solid var(--blue2);
  padding: 1rem;
  margin: 1.5rem 0;
  border-radius: 0 8px 8px 0;
}

.markdown-body img {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.post-page-light .markdown-body img {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-excerpt {
  font-size: 0.95rem;
  /* Smaller excerpt */
  color: var(--text-sub);
  line-height: 1.5;
  margin-top: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.9;
}

.card-meta {
  font-size: 0.75rem;
  /* Smaller meta */
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Type 2: Text/Tines Cards */
.blog-card.no-image {
  grid-column: span 4;
  /* Keep consistent width */
  flex-direction: column;
  /* Stack vertically for consistency */
  min-height: 200px;
}

.tines-left {
  width: 100%;
  /* Full width */
  height: 40%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 1rem;
  box-sizing: border-box;
}

.tines-right {
  width: 100%;
  /* Full width */
  height: 60%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  position: relative;
  box-sizing: border-box;
}

.bookmark-icon {
  position: absolute;
  top: 0;
  right: 1rem;
  color: rgba(255, 255, 255, 0.4);
}

.bookmark-icon .material-icons {
  font-size: 24px;
}

.tines-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  line-height: 1.3;
  margin-bottom: 0.5rem;
  display: block;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tines-excerpt {
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.6);
  line-height: 1.4;
  font-weight: 500;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  /* Reduced */
  -webkit-box-orient: vertical;
}

.tines-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tines-stats {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Color Variants for Tines Cards */
.tines-card-1 .tines-left {
  background-color: var(--tines-1-light);
}

.tines-card-1 .tines-right {
  background-color: var(--tines-1-dark);
}

.tines-card-1 .tines-title,
.tines-card-1 .tines-stats {
  color: white;
}

.tines-card-2 .tines-left {
  background-color: var(--tines-2-light);
}

.tines-card-2 .tines-right {
  background-color: var(--tines-2-dark);
}

.tines-card-3 .tines-left {
  background-color: var(--tines-3-light);
}

.tines-card-3 .tines-right {
  background-color: var(--tines-3-dark);
}

.tines-card-4 .tines-left {
  background-color: var(--tines-4-light);
}

.tines-card-4 .tines-right {
  background-color: var(--tines-4-dark);
}

.tines-left {
  color: rgba(0, 0, 0, 0.4);
}

/* Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
}

.tag-chip {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
}

.tag-chip:hover {
  background: var(--tag-text);
  color: #fff;
}

.tines-tag {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.tines-tag:hover {
  background: rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2.8rem;
  }

  .blog-card.no-image {
    grid-column: span 12;
  }

  .theme-toggle-btn {
    top: 7.5rem;
  }
}


/* Ad Card Styling */
.blog-card.ad-card {
  grid-column: span 4;
  background: var(--card-bg);
  border: 1px dashed var(--card-border);
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 220px;
  display: none;
}

.blog-card.ad-card.active-ad {
  display: flex;
}

.ad-card-inner {
  padding: 1rem;
  width: 100%;
}

/* Responsive */
@media (max-width: 1024px) {
  .blog-card.has-image {
    grid-column: span 6;
  }

  /* 2 per row on tablet */
  .blog-card.no-image {
    grid-column: span 6;
  }

  .blog-card.ad-card {
    grid-column: span 6;
  }
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2.8rem;
  }

  .blog-card.has-image {
    grid-column: span 12;
  }

  /* 1 per row on mobile */
  .blog-card.no-image {
    grid-column: span 12;
  }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 3rem;
}

.pagination a,
.pagination span {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  text-decoration: none;
  transition: all 0.2s;
}

.pagination a:hover {
  background: var(--blue2);
  color: white;
  border-color: var(--blue2);
}

.pagination .current {
  background: var(--text-main);
  color: var(--bg-main);
  border-color: var(--text-main);
}

/* Markdown Body */
.markdown-body {
  color: var(--text-main);
  font-size: 1.125rem;
  /* 18px base size */
  line-height: 1.8;
  position: relative;
}

.markdown-body h1,
.markdown-body h2 {
  margin-top: 1.5em;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.markdown-body a {
  color: var(--blue2);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.markdown-body a:hover {
  border-bottom-color: var(--blue2);
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 2rem 0;
  box-shadow: var(--glass-shadow);
  display: block;
}

/* Mobile Responsive Improvements */
@media (max-width: 768px) {
  .main-content {
    padding: 1rem;
    margin-top: 4rem;
  }

  .hero-title {
    font-size: 3rem;
    padding: 0 1rem;
  }

  .post-content-wrapper {
    padding: 0 !important;
    /* ZERO padding as requested */
  }

  .markdown-body {
    font-size: 1.05rem;
    /* Slightly smaller but readable */
    line-height: 1.7;
    padding: 0 1rem;
    /* Add internal padding to text so it doesn't touch edge, but wrapper is 0 */
  }

  .markdown-body p {
    margin-bottom: 1.5rem;
  }

  .markdown-body img {
    margin: 1.5rem 0;
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    /* Rounded corners on mobile as requested */
  }

  .post-header {
    padding: 1rem 0 !important;
  }

  .post-title {
    font-size: 2.2rem !important;
  }
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 4rem 0;
  border-top: 1px solid var(--card-border);
  color: var(--text-muted);
  background: var(--card-bg);
  text-align: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
}

.footer-links a {
  color: var(--text-sub);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

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

.footer-copy {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* Utility for compact cards */
.compact-card-bg {
  background: var(--compact-card-bg);
}

/* Highlight utility for search */
.highlight {
  background-color: #fff176;
  color: black;
  padding: 0 2px;
  border-radius: 2px;
}