/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

:root {
  /* Color System */
  --color-primary: #00a9ea;
  --color-primary-hover: #00a9ea;
  --color-accent: #f59e0b;
  --color-accent-hover: #d97706;
  --color-neutral-50: #fafafa;
  --color-neutral-100: #f5f5f5;
  --color-neutral-200: #e5e5e5;
  --color-neutral-300: #d4d4d4;
  --color-neutral-400: #a3a3a3;
  --color-neutral-500: #737373;
  --color-neutral-600: #525252;
  --color-neutral-700: #404040;
  --color-neutral-800: #262626;
  --color-neutral-900: #171717;

  /* Typography */
  --font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-neutral-800);
  background-color: var(--color-neutral-50);
}

/* ---------- Blog Header ---------- */
.blog-header {
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-primary-hover) 100%
  );
  color: white;
  padding: var(--space-16) 0 var(--space-12);
  margin-bottom: var(--space-8);
}

.header-content {
  text-align: center;
}

.main-title {
  font-size: var(--font-size-4xl);
  font-weight: 700;
  margin: 0 0 var(--space-4);
  letter-spacing: -0.025em;
}

.subtitle {
  font-size: var(--font-size-lg);
  margin: 0;
  opacity: 0.9;
  font-weight: 400;
}

/* Container: wider on desktop / ultra-wide */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

@media (min-width: 1600px) {
  .container {
    max-width: 1680px;
  }
}

/* ---------- Grid (auto-fit columns) ---------- */
.grid {
  display: grid;
  gap: 28px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
@media (max-width: 900px) {
  .grid {
    gap: 24px;
  }
}

/* ---------- Card ---------- */
.card {
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card img {
  width: 100%;
  aspect-ratio: 16 / 9; /* keeps rows aligned */
  object-fit: cover;
  display: block;
}
.p16 {
  padding: 16px;
}
.badge {
  display: inline-block;
  background: #eef3ff;
  color: #2c4bff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}
.title {
  font-size: 18px;
  margin: 8px 0 6px;
  line-height: 1.3;
}
.meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

/* Excerpt clamp: 2 lines on mobile, 3 on â‰¥768px */
.card p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  font-size: 14px;
  line-height: 1.5;
  color: #444;
  margin: 0 0 10px;
}
@media (min-width: 768px) {
  .card p {
    -webkit-line-clamp: 3;
  }
}

.actions a {
  display: inline-block;
  margin-top: auto;
  padding: 12px 16px;
  text-decoration: none;
  border-top: 1px solid #eee;
}
.actions a:hover {
  background: #fafafa;
}

/* ---------- Toolbar (search + category + button) ---------- */
.toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto; /* search | select | button */
  gap: var(--space-4);
  align-items: center;
}
@media (max-width: 768px) {
  .toolbar {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

.search-section {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-8);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-neutral-200);
}

.search-input-wrapper input[type="search"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  transition: all 0.2s ease;
  background: var(--color-neutral-50);
}

.search-input-wrapper input[type="search"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.1);
  outline: none;
  background: white;
}

.category-select {
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  background: white;
  min-width: 180px;
  transition: all 0.2s ease;
}

.category-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.1);
  outline: none;
}

.filter-btn {
  padding: var(--space-3) var(--space-6);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ---------- Blog Grid ---------- */
.blog-grid {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-bottom: var(--space-12);
}

@media (max-width: 768px) {
  .blog-grid {
    gap: var(--space-6);
    grid-template-columns: 1fr;
  }
}

.blog-card {
  background: white;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-neutral-200);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-neutral-300);
}

.card-image {
  position: relative;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.blog-card:hover .card-image img {
  transform: scale(1.05);
}

.category-badge {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  background: var(--color-accent);
  color: white;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-content {
  padding: var(--space-6);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-meta {
  margin-bottom: var(--space-3);
}

.publish-date {
  font-size: var(--font-size-sm);
  color: var(--color-neutral-500);
  font-weight: 500;
}

.card-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin: 0 0 var(--space-4);
  line-height: 1.3;
  color: var(--color-neutral-900);
}

.card-excerpt {
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-neutral-600);
  margin: 0 0 var(--space-6);
  flex: 1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: 3;
}

.read-more-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--font-size-base);
  transition: all 0.2s ease;
  margin-top: auto;
}

.read-more-btn:hover {
  color: var(--color-primary-hover);
}

.read-more-btn .arrow {
  transition: transform 0.2s ease;
}

.read-more-btn:hover .arrow {
  transform: translateX(4px);
}

/* ---------- Pagination ---------- */
.pagination-nav {
  display: flex;
  justify-content: center;
  margin-top: var(--space-12);
}

.pagination {
  display: flex;
  gap: var(--space-2);
  background: white;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-neutral-200);
}

.page-link {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-neutral-700);
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 44px;
  text-align: center;
}

.page-link:hover {
  background: var(--color-neutral-100);
  color: var(--color-neutral-900);
}

.page-link.active {
  background: var(--color-primary);
  color: white;
}

.page-link.active:hover {
  background: var(--color-primary-hover);
}

/* ---------- Detail page: 2-column with sidebar ---------- */
.layout-2col {
  display: grid;
  grid-template-columns: 1fr 360px; /* content | sidebar */
  gap: 28px;
}
@media (min-width: 1600px) {
  .layout-2col {
    grid-template-columns: 1fr 420px;
  }
}
@media (max-width: 900px) {
  .layout-2col {
    grid-template-columns: 1fr;
  }
  .sidebar {
    order: 2;
  }
}
.post-content {
  min-width: 0;
} /* avoid overflow */

/* Sidebar list */
.sidebar .sb-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 600;
  border-bottom: 2px solid #2563eb;
  padding-bottom: 6px;
  color: #111;
}
.sb-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sb-card {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  text-decoration: none;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.sb-card:hover {
  background: #fafafa;
}
.sb-img {
  width: 110px;
  height: 110px;
  object-fit: cover;
  display: block;
}
.sb-body {
  padding: 8px 10px 8px 0;
}
.sb-date {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}
.sb-title-2 {
  font-size: 14px;
  color: #111827;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: 3;
}

/* ===== Header redesign: top bar + hero (non-breaking patch) ===== */

/* Top bar wrapper */
.site-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-primary-hover) 100%
  );
  color: #fff;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Top bar layout */
.site-topbar .container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
}

/* Brand (logo + small text) */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  display: block;
  width: 150px; /* adjust if you want smaller/larger */
  height: auto;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 6px 8px;
  box-shadow: var(--shadow-sm);
}
.brand-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-title {
  margin: 0;
  font-weight: 800;
  font-size: var(--font-size-lg);
  line-height: 1.2;
  letter-spacing: 0.2px;
}
.brand-subtitle {
  margin: 2px 0 0;
  font-size: var(--font-size-xs);
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Simple right-side links (optional) */
.top-links {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.top-link {
  color: #f8fafc;
  text-decoration: none;
  font-weight: 700;
  font-size: var(--font-size-sm);
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-lg);
  transition: transform 0.15s ease, background 0.15s ease,
    border-color 0.15s ease;
}
.top-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.45);
}

/* Keep your existing .blog-header as â€œheroâ€ under the top bar */
.blog-header {
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-primary-hover) 100%
  );
  color: #fff;
  padding: var(--space-16) 0 var(--space-12);
  margin-bottom: var(--space-8);
}
.blog-header .header-content {
  text-align: center;
}

.site-topbar {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-primary-hover) 100%
  );
  color: #fff;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* reserve space so content starts below the fixed header */
body {
  padding-top: 88px;
} /* set to your actual header height */
@media (min-width: 992px) {
  body {
    padding-top: 110px;
  }
} /* example breakpoint */

/* Mobile tweaks */
@media (max-width: 768px) {
  .brand-subtitle {
    display: none;
  }
  .top-links {
    display: none;
  }

  #HeaderWrap {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: #fff; /* or gradient if you want */
    margin: 0 !important;
    padding: 0 !important;
    backface-visibility: hidden;
    transform: translateZ(0); /* GPU render, prevents jitter */
  }

  #HeaderSpacer {
    height: 110px; /* match desktop header height */
  }

  @media (max-width: 768px) {
    #HeaderSpacer {
      height: 88px; /* match mobile header height */
    }
  }
}
