/* ===== Invoicely Blog — Modern Premium Design System ===== */

:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-code: #f1f5f9;
  --bg-hero: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #f5f0ff 100%);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #5c5c66; /* WCAG AA: 5.7:1 on #f8fafc */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-dark: #1d4ed8;
  --accent-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --accent-glow: rgba(37, 99, 235, 0.15);
  --purple: #7c3aed;
  --emerald: #059669;
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,0.08), 0 4px 6px -4px rgba(15,23,42,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15,23,42,0.08), 0 8px 10px -6px rgba(15,23,42,0.04);
  --shadow-glow: 0 0 20px rgba(37,99,235,0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --max-width: 1200px;
  --content-width: 740px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: #1e293b;
    --bg-code: #1e293b;
    --bg-hero: linear-gradient(135deg, #0b0f19 0%, #111827 50%, #0f172a 100%);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #9494a0; /* WCAG AA: 5.0:1 on #0b0f19 */
    --border: #1e293b;
    --border-light: #1e293b;
    --accent-light: #1e3a5f;
    --accent-glow: rgba(37, 99, 235, 0.25);
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.5);
  }
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-dark); }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img { max-width: 100%; height: auto; display: block; }

/* ===== HEADER / NAV ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248,250,252,0.8);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--transition);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(11,15,25,0.8); }
}
.site-header.scrolled { box-shadow: var(--shadow-md); }

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-primary);
  text-decoration: none;
}
.nav-logo-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.nav-links { display: flex; align-items: center; gap: 4px; list-style: none; }
.nav-links a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-links a:hover { color: var(--text-primary); background: var(--border-light); }
.nav-links .nav-cta {
  background: var(--accent-gradient);
  color: white !important;
  font-weight: 600;
  padding: 8px 18px;
}
.nav-links .nav-cta:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-glow); }

.nav-mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-primary);
}

/* ===== HERO ===== */
.hero {
  padding: 72px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
  background: var(--bg-hero);
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px circle at 30% 20%, var(--accent-glow), transparent 60%),
    radial-gradient(400px circle at 70% 80%, rgba(124,58,237,0.08), transparent 50%);
  pointer-events: none;
  will-change: transform;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--purple), transparent);
  opacity: 0.3;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 24px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.hero-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--emerald);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(5,150,105,0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(5,150,105,0); }
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 16px;
  position: relative;
}
.hero h1 .gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.hero p {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto 28px;
  position: relative;
}

.hero-search {
  max-width: 440px;
  margin: 0 auto;
  position: relative;
}
.hero-search input {
  width: 100%;
  padding: 12px 18px 12px 44px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.hero-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.hero-search svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ===== CATEGORIES ===== */
.categories {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 36px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.cat-tag {
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.cat-tag:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-light);
}
.cat-tag.active {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-glow);
}

/* ===== ARTICLE GRID ===== */
.articles-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 80px;
}
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  position: relative;
}
.article-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  padding: 1px;
  background: linear-gradient(135deg, transparent 40%, var(--accent-glow) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
  border-color: transparent;
  color: inherit;
}
.article-card:hover::before { opacity: 1; }

.article-card-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.article-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.article-card-category {
  background: var(--accent-light);
  color: var(--accent-dark); /* 5.9:1 contrast */
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.article-card-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.article-card-read {
  color: var(--accent);
  font-weight: 600;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--transition);
}
.article-card:hover .article-card-read { gap: 8px; }

/* ===== SINGLE ARTICLE ===== */
.article-page { padding: 40px 24px 80px; }
.article-container {
  max-width: var(--content-width);
  margin: 0 auto;
}

.article-header { margin-bottom: 40px; }
.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.article-breadcrumb a { color: var(--text-muted); }
.article-breadcrumb a:hover { color: var(--accent); }

.article-header .article-card-category { margin-bottom: 16px; display: inline-block; }
.article-header h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
}
.article-header .article-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.article-header .article-meta-row span { display: flex; align-items: center; gap: 6px; }

.article-hero-img {
  width: 100%;
  aspect-ratio: 2/1;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 40px;
  box-shadow: var(--shadow-md);
}

.article-content { font-size: 1.0625rem; color: var(--text-secondary); }
.article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 48px 0 16px;
  letter-spacing: -0.02em;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
}
.article-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 32px 0 12px;
}
.article-content p { margin-bottom: 20px; }
.article-content ul, .article-content ol {
  margin-bottom: 20px;
  padding-left: 24px;
}
.article-content li { margin-bottom: 8px; }
.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 16px 24px;
  margin: 24px 0;
  background: var(--bg-code);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}
.article-content code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
}
.article-content strong { color: var(--text-primary); font-weight: 600; }
.article-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.article-content img {
  border-radius: var(--radius-md);
  margin: 24px 0;
  box-shadow: var(--shadow-sm);
}
/* Article content tables */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.article-content th {
  background: var(--accent);
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
}
.article-content td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}
.article-content tr:last-child td { border-bottom: none; }
.article-content tr:nth-child(even) td { background: var(--bg-code); }

/* CTA Box */
.article-cta {
  margin: 48px 0;
  padding: 32px;
  background: var(--accent-gradient);
  border-radius: var(--radius-xl);
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
}
.article-cta::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1), transparent 60%);
  pointer-events: none;
}
.article-cta h3 { color: white; margin: 0 0 8px; font-size: 1.25rem; position: relative; }
.article-cta p { color: rgba(255,255,255,0.9); margin-bottom: 20px; font-size: 0.9375rem; position: relative; }
.article-cta a {
  display: inline-block;
  padding: 12px 28px;
  background: white;
  color: var(--accent);
  font-weight: 700;
  border-radius: 100px;
  transition: all var(--transition);
  text-decoration: none;
  position: relative;
  box-shadow: var(--shadow-md);
}
.article-cta a:hover { transform: translateY(-2px); box-shadow: var(--shadow-xl); }

/* Social Share Buttons */
.article-share {
  margin: 32px 0 48px;
  padding: 24px;
  background: var(--bg-code);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.share-label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.share-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: white !important;
  text-decoration: none !important;
  transition: all var(--transition);
}
.share-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: white; }
.share-linkedin { background: #0077B5; }
.share-facebook { background: #1877F2; }
.share-x { background: #0f172a; }
.share-email { background: var(--accent); }

/* Related Articles */
.related-section {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}
.related-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 48px 24px 24px;
  position: relative;
}
.site-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--purple), transparent);
  opacity: 0.4;
}
.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}
.footer-brand p { color: var(--text-secondary); font-size: 0.875rem; margin-top: 12px; line-height: 1.6; }
.footer-brand p a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.footer-social {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.footer-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 100px;
  background: var(--border-light);
  color: var(--text-muted);
  transition: all var(--transition);
  border: 1px solid var(--border);
}
.footer-social a:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}
.footer-col h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 10px; }
.footer-col a { color: var(--text-secondary); font-size: 0.875rem; }
.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  max-width: var(--max-width);
  margin: 40px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.footer-bottom a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 2px; }
.footer-bottom a:hover { color: var(--accent); }

/* ===== LOAD MORE ===== */
.load-more {
  text-align: center;
  margin-top: 48px;
}
.load-more button {
  padding: 12px 32px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all var(--transition);
}
.load-more button:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-glow);
}

/* ===== ANIMATIONS (GPU-composited) ===== */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeInUp 0.4s ease forwards;
  will-change: opacity, transform;
}
@keyframes fadeInUp {
  to { opacity: 1; transform: translateY(0); }
}
.article-card {
  animation: fadeInUp 0.4s ease forwards;
  will-change: opacity, transform;
}
.article-card:nth-child(2) { animation-delay: 0.05s; }
.article-card:nth-child(3) { animation-delay: 0.1s; }
.article-card:nth-child(4) { animation-delay: 0.12s; }
.article-card:nth-child(5) { animation-delay: 0.15s; }
.article-card:nth-child(6) { animation-delay: 0.18s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-mobile-toggle { display: block; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    box-shadow: var(--shadow-lg);
  }
  .hero { padding: 48px 20px 36px; }
  .articles-grid { grid-template-columns: 1fr; }
  .footer-container { grid-template-columns: 1fr 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; gap: 12px; text-align: center; }
}

@media (max-width: 480px) {
  .footer-container { grid-template-columns: 1fr; }
  .categories { gap: 6px; }
  .cat-tag { padding: 6px 14px; font-size: 0.75rem; }
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 48px;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 100px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

/* ===== 404 PAGE ===== */
.not-found {
  text-align: center;
  padding: 120px 24px;
}
.not-found h1 {
  font-size: 6rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}
.not-found p { color: var(--text-secondary); font-size: 1.125rem; margin: 16px 0 32px; }

/* ===== READING PROGRESS BAR ===== */
.reading-progress {
  position: fixed;
  top: 64px;
  left: 0;
  height: 3px;
  background: var(--accent-gradient);
  z-index: 99;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}
