/* ============================================================
   LoanSpace.ai — Blog Styles
   ============================================================ */

/* ---- Variables (scoped to blog, inherits site vars) ---- */
:root {
  --blog-primary: #1a6db5;
  --blog-primary-dark: #145a96;
  --blog-primary-light: #4a9ad4;
  --blog-orange: #e8922a;
  --blog-orange-dark: #e87d1e;
  --blog-text: #1e293b;
  --blog-text-light: #64748b;
  --blog-bg: #f0f4fb;
  --blog-white: #ffffff;
  --blog-border: #e2e8f0;
  --blog-radius: 12px;
  --blog-radius-lg: 16px;
  --blog-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --blog-shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --blog-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   1. BLOG LISTING PAGE
   ============================================================ */

/* ---- Prevent horizontal overflow on mobile ---- */
html:has(.article-container),
html:has(.blog-container),
body:has(.article-container),
body:has(.blog-container) {
  overflow-x: hidden;
}

.main-content:has(.article-container),
.main-content:has(.blog-container) {
  overflow-x: hidden;
  max-width: 100%;
}

/* ---- Container ---- */
.blog-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Back Link ---- */
.blog-back-bar {
  padding: 14px 24px;
  text-align: left;
}
.blog-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  color: #6366f1;
  text-decoration: none;
  transition: color 0.2s;
}
.blog-back-link:hover {
  color: #4338ca;
}
[data-theme="dark"] .blog-back-link {
  color: #818cf8;
}
[data-theme="dark"] .blog-back-link:hover {
  color: #a5b4fc;
}

/* ---- Hero Banner ---- */
.blog-hero {
  background: linear-gradient(135deg, #0f2a4a 0%, #145a96 50%, #1a6db5 100%);
  color: #ffffff;
  padding: 64px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.blog-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(74,154,212,0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.blog-hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(232,146,42,0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.blog-hero h1 {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 2.75rem;
  font-weight: 800;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
  color: #ffffff !important;
  text-shadow: 0 2px 12px rgba(0,0,0,0.25);
  letter-spacing: -0.02em;
}

.blog-hero-loan {
  color: #4a9ad4;
}

.blog-hero-space {
  color: #e8922a;
}

.blog-hero p {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.125rem;
  color: rgba(255,255,255,0.95) !important;
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.6;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ---- Blog Grid ---- */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  padding: 48px 0 64px;
}

/* ---- Blog Card ---- */
.blog-card {
  background: var(--blog-white);
  border-radius: var(--blog-radius-lg);
  border: 1px solid var(--blog-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--blog-transition), box-shadow var(--blog-transition);
  box-shadow: var(--blog-shadow);
}

.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(26,109,181,0.12), 0 4px 12px rgba(0,0,0,0.06);
}

.blog-card a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Card image / gradient placeholder */
.blog-card-image {
  height: 180px;
  position: relative;
  overflow: hidden;
}

.blog-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Category-based gradient placeholders when no image */
.blog-card-image--mortgage {
  background: linear-gradient(135deg, #1a6db5, #4a9ad4);
}

.blog-card-image--finance {
  background: linear-gradient(135deg, #145a96, #1a6db5);
}

.blog-card-image--tips {
  background: linear-gradient(135deg, #e8922a, #f0b060);
}

.blog-card-image--market {
  background: linear-gradient(135deg, #0f2a4a, #1a6db5);
}

.blog-card-image--first-home {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.blog-card-image--default {
  background: linear-gradient(135deg, #64748b, #94a3b8);
}

/* Card body */
.blog-card-body {
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.blog-card-title {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--blog-text);
  line-height: 1.4;
  margin-bottom: 10px;
}

.blog-card:hover .blog-card-title {
  color: var(--blog-primary);
}

.blog-card-excerpt {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.9rem;
  color: var(--blog-text-light);
  line-height: 1.6;
  margin-bottom: 16px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card footer: author + meta */
.blog-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.8rem;
  color: var(--blog-text-light);
  border-top: 1px solid var(--blog-border);
  padding-top: 14px;
  margin-top: auto;
}

.blog-card-author {
  font-weight: 500;
  color: var(--blog-text);
}

.blog-card-date {
  color: var(--blog-text-light);
}

.blog-card-read-time {
  color: var(--blog-text-light);
  white-space: nowrap;
}

.blog-card-read-time::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  background: var(--blog-text-light);
  border-radius: 50%;
  margin: 0 8px;
  vertical-align: middle;
}

/* ---- Category Badge ---- */
.blog-category-badge {
  display: inline-block;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  width: fit-content;
}

.blog-category-badge--mortgage {
  background: #e8f1fa;
  color: #1a6db5;
}

.blog-category-badge--finance {
  background: #ede9fe;
  color: #7c3aed;
}

.blog-category-badge--tips {
  background: #fff7ed;
  color: #e87d1e;
}

.blog-category-badge--market {
  background: #ecfdf5;
  color: #059669;
}

.blog-category-badge--first-home {
  background: #f0fdf4;
  color: #16a34a;
}

.blog-category-badge--default {
  background: #f1f5f9;
  color: #64748b;
}

/* Badge inside the card image area (overlay) */
.blog-card-image .blog-category-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(4px);
  margin-bottom: 0;
}


/* ============================================================
   2. INDIVIDUAL ARTICLE PAGE
   ============================================================ */

/* ---- Article Container ---- */
.article-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* ---- Article Hero Image ---- */
.article-hero-image {
  width: 100%;
  height: 360px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.article-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Article Header ---- */
.article-header {
  margin-bottom: 40px;
}

.article-header .blog-category-badge {
  margin-bottom: 16px;
}

.article-header h1 {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--blog-text);
  line-height: 1.3;
  margin-bottom: 20px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.9rem;
  color: var(--blog-text-light);
}

.article-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.article-author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a6db5, #4a9ad4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.85rem;
}

.article-author-name {
  font-weight: 600;
  color: var(--blog-text);
}

.article-meta-separator {
  width: 4px;
  height: 4px;
  background: var(--blog-text-light);
  border-radius: 50%;
}

/* ---- Article Body (Prose) ---- */
.article-body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.05rem;
  color: var(--blog-text);
  line-height: 1.8;
  overflow-x: hidden;
  max-width: 100%;
}

.article-body table {
  max-width: 100%;
  font-size: 0.9rem;
  word-break: break-word;
}

.article-body img {
  max-width: 100%;
  height: auto;
}

.article-body h2 {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--blog-text);
  margin-top: 48px;
  margin-bottom: 16px;
  line-height: 1.35;
}

.article-body h3 {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--blog-text);
  margin-top: 36px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.article-body p {
  margin-bottom: 20px;
}

.article-body a {
  color: var(--blog-primary);
  text-decoration: underline;
  text-decoration-color: rgba(26,109,181,0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--blog-transition);
}

.article-body a:hover {
  text-decoration-color: var(--blog-primary);
}

.article-body strong {
  font-weight: 600;
  color: var(--blog-text);
}

.article-body blockquote {
  border-left: 4px solid var(--blog-primary);
  margin: 28px 0;
  padding: 16px 24px;
  background: #f0f6fc;
  border-radius: 0 var(--blog-radius) var(--blog-radius) 0;
  color: var(--blog-text);
  font-style: italic;
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body ul,
.article-body ol {
  margin: 20px 0;
  padding-left: 28px;
}

.article-body ul li,
.article-body ol li {
  margin-bottom: 10px;
  line-height: 1.7;
}

.article-body ul li::marker {
  color: var(--blog-primary);
}

.article-body ol li::marker {
  color: var(--blog-primary);
  font-weight: 600;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--blog-radius);
  margin: 28px 0;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--blog-border);
  margin: 40px 0;
}

/* ---- Tip / Callout Box ---- */
.tip-box {
  background: #e8f4fd;
  border: 1px solid #b6d9f2;
  border-radius: var(--blog-radius);
  padding: 20px 24px;
  margin: 28px 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.tip-box::before {
  content: '\f0eb'; /* lightbulb icon - fallback text below */
  font-family: 'Font Awesome 6 Free', 'FontAwesome';
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--blog-primary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* Fallback if Font Awesome not loaded */
.tip-box-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.tip-box-content {
  flex: 1;
}

.tip-box-content p:last-child {
  margin-bottom: 0;
}

.tip-box-title {
  font-weight: 600;
  color: var(--blog-primary-dark);
  margin-bottom: 4px;
  font-size: 0.95rem;
}

/* ---- Article Share Buttons ---- */
.article-share {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  margin: 40px 0 0;
  border-top: 1px solid var(--blog-border);
}

.article-share-label {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--blog-text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.article-share a,
.article-share button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--blog-border);
  background: var(--blog-white);
  color: var(--blog-text-light);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--blog-transition);
  text-decoration: none;
}

.article-share a:hover,
.article-share button:hover {
  border-color: var(--blog-primary);
  color: var(--blog-primary);
  background: #f0f6fc;
}

/* ---- Article CTA Box ---- */
.article-cta {
  background: linear-gradient(135deg, #0f2a4a 0%, #145a96 100%);
  border-radius: var(--blog-radius-lg);
  padding: 36px 32px;
  margin: 48px 0;
  text-align: center;
  color: #ffffff;
}

.article-cta h3 {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.article-cta p {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.85);
  margin-bottom: 20px;
  line-height: 1.6;
}

.article-cta a,
.article-cta button {
  display: inline-block;
  background: var(--blog-orange);
  color: #ffffff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 28px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--blog-transition), transform var(--blog-transition);
}

.article-cta a:hover,
.article-cta button:hover {
  background: var(--blog-orange-dark);
  transform: translateY(-1px);
}

/* ---- Prev / Next Article Nav ---- */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 32px 0;
  border-top: 1px solid var(--blog-border);
}

.article-nav-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  max-width: 48%;
  transition: color var(--blog-transition);
}

.article-nav-link--next {
  text-align: right;
  margin-left: auto;
}

.article-nav-label {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blog-text-light);
}

.article-nav-title {
  font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--blog-primary);
  line-height: 1.4;
}

.article-nav-link:hover .article-nav-title {
  color: var(--blog-primary-dark);
}


/* ============================================================
   3. DARK MODE
   ============================================================ */

[data-theme="dark"] .blog-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1a3a5c 100%);
}

/* Cards */
[data-theme="dark"] .blog-card {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .blog-card:hover {
  box-shadow: 0 12px 28px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
}

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

[data-theme="dark"] .blog-card:hover .blog-card-title {
  color: #4a9ad4;
}

[data-theme="dark"] .blog-card-excerpt {
  color: #94a3b8;
}

[data-theme="dark"] .blog-card-meta {
  border-top-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .blog-card-author {
  color: #cbd5e1;
}

[data-theme="dark"] .blog-card-image .blog-category-badge {
  background: rgba(30,41,59,0.9);
  color: #cbd5e1;
}

/* Category badges - dark mode */
[data-theme="dark"] .blog-category-badge--mortgage {
  background: rgba(26,109,181,0.2);
  color: #4a9ad4;
}

[data-theme="dark"] .blog-category-badge--finance {
  background: rgba(124,58,237,0.2);
  color: #a78bfa;
}

[data-theme="dark"] .blog-category-badge--tips {
  background: rgba(232,146,42,0.2);
  color: #f0b060;
}

[data-theme="dark"] .blog-category-badge--market {
  background: rgba(5,150,105,0.2);
  color: #34d399;
}

[data-theme="dark"] .blog-category-badge--first-home {
  background: rgba(22,163,74,0.2);
  color: #4ade80;
}

[data-theme="dark"] .blog-category-badge--default {
  background: rgba(100,116,139,0.2);
  color: #94a3b8;
}

/* Article page - dark mode */
[data-theme="dark"] .article-hero-image {
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

[data-theme="dark"] .article-header h1 {
  color: #f1f5f9;
}

[data-theme="dark"] .article-meta {
  color: #94a3b8;
}

[data-theme="dark"] .article-author-name {
  color: #cbd5e1;
}

[data-theme="dark"] .article-meta-separator {
  background: #64748b;
}

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

[data-theme="dark"] .article-body h2,
[data-theme="dark"] .article-body h3 {
  color: #f1f5f9;
}

[data-theme="dark"] .article-body strong {
  color: #f1f5f9;
}

[data-theme="dark"] .article-body a {
  color: #4a9ad4;
  text-decoration-color: rgba(74,154,212,0.3);
}

[data-theme="dark"] .article-body a:hover {
  text-decoration-color: #4a9ad4;
}

[data-theme="dark"] .article-body blockquote {
  background: rgba(26,109,181,0.1);
  border-left-color: #4a9ad4;
  color: #cbd5e1;
}

[data-theme="dark"] .article-body ul li::marker,
[data-theme="dark"] .article-body ol li::marker {
  color: #4a9ad4;
}

[data-theme="dark"] .article-body hr {
  border-top-color: #334155;
}

/* Tip box - dark mode */
[data-theme="dark"] .tip-box {
  background: rgba(26,109,181,0.1);
  border-color: rgba(74,154,212,0.2);
}

[data-theme="dark"] .tip-box::before {
  color: #4a9ad4;
}

[data-theme="dark"] .tip-box-title {
  color: #4a9ad4;
}

/* Share buttons - dark mode */
[data-theme="dark"] .article-share {
  border-top-color: #334155;
}

[data-theme="dark"] .article-share-label {
  color: #94a3b8;
}

[data-theme="dark"] .article-share a,
[data-theme="dark"] .article-share button {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .article-share a:hover,
[data-theme="dark"] .article-share button:hover {
  border-color: #4a9ad4;
  color: #4a9ad4;
  background: rgba(74,154,212,0.1);
}

/* CTA box - dark mode */
[data-theme="dark"] .article-cta {
  background: linear-gradient(135deg, #0f172a 0%, #1a3a5c 100%);
}

/* Article nav - dark mode */
[data-theme="dark"] .article-nav {
  border-top-color: #334155;
}

[data-theme="dark"] .article-nav-label {
  color: #64748b;
}

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

[data-theme="dark"] .article-nav-link:hover .article-nav-title {
  color: #60a5fa;
}


/* ============================================================
   4. RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Tablet: 900px and below */
@media (max-width: 900px) {
  .blog-hero {
    padding: 48px 20px;
  }

  .blog-hero h1 {
    font-size: 2rem;
  }

  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 22px;
    padding: 36px 0 48px;
  }

  .article-container {
    padding: 36px 20px 64px;
  }

  .article-hero-image {
    height: 280px;
    border-radius: 12px;
  }

  .article-header h1 {
    font-size: 1.875rem;
  }

  .article-cta {
    padding: 28px 24px;
  }
}

/* Mobile: 640px and below */
@media (max-width: 640px) {
  .blog-hero {
    padding: 28px 16px;
  }
  .blog-back-bar {
    padding: 10px 16px;
  }

  .blog-hero h1 {
    font-size: 1.625rem;
  }

  .blog-hero p {
    font-size: 1rem;
  }

  .blog-container {
    padding: 0 16px;
  }

  .blog-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 28px 0 40px;
  }

  .blog-card-image {
    height: 160px;
  }

  .blog-card-body {
    padding: 16px 18px 20px;
  }

  .blog-card-title {
    font-size: 1.05rem;
  }

  .article-hero-image {
    height: 220px;
    border-radius: 10px;
    margin-bottom: 24px;
  }

  .article-container {
    padding: 28px 16px 48px;
  }

  .article-header h1 {
    font-size: 1.5rem;
  }

  .article-meta {
    gap: 10px;
    font-size: 0.85rem;
  }

  .article-body {
    font-size: 1rem;
  }

  .article-body h2 {
    font-size: 1.375rem;
    margin-top: 36px;
  }

  .article-body h3 {
    font-size: 1.125rem;
    margin-top: 28px;
  }

  .article-body blockquote {
    padding: 14px 18px;
    margin: 22px 0;
  }

  .tip-box {
    padding: 16px 18px;
    flex-direction: column;
    gap: 8px;
  }

  .article-cta {
    padding: 24px 20px;
    margin: 36px 0;
  }

  .article-cta h3 {
    font-size: 1.2rem;
  }

  .article-nav {
    flex-direction: column;
    gap: 16px;
  }

  .article-nav-link,
  .article-nav-link--next {
    max-width: 100%;
    text-align: left;
  }

  .article-share {
    flex-wrap: wrap;
  }
}
