*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1C4D8D;
  --primary-dark: #093C5D;
  --primary-light: #dbeafe;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(28,77,141,.2), 0 8px 32px rgba(0,0,0,.1);
  --radius: 16px;
  --nav-bg: #ffffff;
  --hero-gradient: linear-gradient(135deg, #051e3e 0%, #093C5D 50%, #1C4D8D 100%);
}

[data-theme="dark"] {
  --primary: #4d8fd4;
  --primary-dark: #93c5fd;
  --primary-light: #1e3a5f;
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  --shadow-hover: 0 4px 12px rgba(77,143,212,.25), 0 8px 32px rgba(0,0,0,.3);
  --nav-bg: #1e293b;
  --hero-gradient: linear-gradient(135deg, #020c1b 0%, #051e3e 50%, #093C5D 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Nav ── */
.site-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.site-nav .brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-nav .brand .logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #4d8fd4, #1C4D8D);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
}
.site-nav .nav-links { display: flex; gap: 20px; margin-left: auto; }
.site-nav .nav-links a {
  font-size: .875rem; font-weight: 600;
  color: var(--text-muted); text-decoration: none;
  transition: color .15s;
}
.site-nav .nav-links a:hover { color: var(--primary); }
.theme-toggle {
  background: #1C4D8D; border: 1px solid #093C5D; border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  margin-left: 8px; transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: #093C5D; border-color: #051e3e; }
[data-theme="dark"] .theme-toggle { background: #334155; border-color: #475569; }

/* ── Hero (homepage) ── */
.site-hero {
  background: var(--hero-gradient);
  color: #fff;
  padding: 36px 24px 52px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.site-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 60% 0%, rgba(77,143,212,.3) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 100%, rgba(28,77,141,.2) 0%, transparent 50%);
  pointer-events: none;
}
.site-hero .logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 1.6rem; font-weight: 800; letter-spacing: -.5px;
  margin-bottom: 20px; position: relative;
}
.site-hero .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #4d8fd4, #1C4D8D);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.site-hero h1 {
  font-size: clamp(2rem,5vw,3.2rem);
  font-weight: 800; letter-spacing: -1px;
  margin-bottom: 16px; position: relative;
}
.site-hero p {
  font-size: 1.15rem; color: rgba(255,255,255,.75);
  max-width: 520px; margin: 0 auto 28px; position: relative;
}
.hero-inner { position: relative; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px; padding: 5px 16px; font-size: .82rem; font-weight: 600;
  margin-bottom: 20px; color: rgba(255,255,255,.9);
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: #093C5D; font-weight: 700; font-size: .95rem;
  padding: 12px 28px; border-radius: 50px; text-decoration: none;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.9); font-weight: 600; font-size: .95rem;
  padding: 12px 28px; border-radius: 50px; text-decoration: none;
  border: 1px solid rgba(255,255,255,.25); transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.2); }

/* ── Section header (title + "view all" link) ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .85rem; font-weight: 600; color: var(--primary); text-decoration: none;
  transition: gap .15s;
}
.section-link:hover { gap: 8px; }

/* ── Blog hero ── */
.blog-hero {
  background: var(--hero-gradient);
  color: #fff; padding: 36px 24px 56px; text-align: center;
}
.blog-hero-inner { max-width: 600px; margin: 0 auto; }
.blog-hero h1 { font-size: clamp(2rem,4vw,2.8rem); font-weight: 800; margin-bottom: 10px; letter-spacing: -.5px; }
.blog-hero p { color: rgba(255,255,255,.75); font-size: 1.05rem; }

/* ── Blog filter bar ── */
.blog-filter-bar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.blog-filter-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 24px;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
}
.blog-filter-inner::-webkit-scrollbar { display: none; }
.blog-cat-chip {
  flex-shrink: 0; padding: 5px 14px; border-radius: 20px; font-size: .8rem; font-weight: 600;
  border: 1.5px solid var(--border); color: var(--text-muted); background: var(--bg);
  text-decoration: none; transition: all .15s;
}
.blog-cat-chip:hover { border-color: var(--primary); color: var(--primary); }
.blog-cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Blog main ── */
.blog-main { max-width: 960px; margin: 0 auto; padding: 0 24px 80px; transform: translateY(-24px); }

/* ── Featured post ── */
.blog-featured {
  display: grid; grid-template-columns: 1fr 1fr; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow);
  background: var(--surface); text-decoration: none; color: inherit;
  margin-bottom: 28px; transition: box-shadow .2s, border-color .2s;
  min-height: 300px;
}
.blog-featured:hover { border-color: var(--primary); box-shadow: var(--shadow-hover); }
.blog-featured-img {
  background-size: cover; background-position: center; background-color: var(--primary-light);
  min-height: 260px;
}
.blog-featured-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-light), var(--border));
  color: var(--primary);
}
.blog-featured-body { padding: 32px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.blog-featured-title { font-size: clamp(1.2rem,2.5vw,1.6rem); font-weight: 800; line-height: 1.3; }
.blog-featured-excerpt { font-size: .95rem; color: var(--text-muted); line-height: 1.6; flex: 1; }

/* ── Blog meta row ── */
.blog-meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.blog-tag {
  font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px;
  background: var(--primary-light); color: var(--primary); letter-spacing: .3px;
}
.blog-date { font-size: .78rem; color: var(--text-muted); }
.blog-read-time { font-size: .78rem; color: var(--text-muted); }
.blog-read-time::before { content: '·'; margin-right: 6px; }
.blog-read-link {
  display: inline-flex; align-items: center; gap: 5px; font-size: .85rem;
  font-weight: 700; color: var(--primary); margin-top: auto;
}

/* ── Blog grid ── */
.blog-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr));
  gap: 20px; margin-bottom: 24px;
}
.blog-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s, border-color .2s; overflow: hidden;
}
.blog-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--primary); }
.blog-card-img { height: 160px; background-size: cover; background-position: center; background-color: var(--primary-light); }
.blog-card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.blog-card-title { font-size: 1rem; font-weight: 700; line-height: 1.4; }
.blog-card-excerpt { font-size: .875rem; color: var(--text-muted); line-height: 1.55; flex: 1; }

/* ── Blog pagination ── */
.blog-pagination { display: flex; justify-content: center; gap: 8px; margin-top: 40px; }
.blog-pagination a, .blog-pagination span {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .875rem; font-weight: 600; text-decoration: none; color: var(--text-muted);
  background: var(--surface); transition: all .15s;
}
.blog-pagination a:hover { border-color: var(--primary); color: var(--primary); }
.blog-pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Blog empty state ── */
.blog-empty { text-align: center; padding: 80px 24px; color: var(--text-muted); }
.blog-empty-icon { font-size: 3rem; margin-bottom: 16px; }
.blog-empty h2 { font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.blog-empty p { font-size: .95rem; }
.tool-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px; padding: 4px 14px; font-size: .8rem; font-weight: 600;
  margin-bottom: 16px;
}

/* ── Main container ── */
.site-main { max-width: 1100px; margin: 0 auto; padding: 0 24px 80px; transform: translateY(-40px); }
.blog-main { max-width: 900px; margin: 0 auto; padding: 0 24px 80px; transform: translateY(-32px); }

/* ── Toolbar (search + filter) ── */
.toolbar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-input {
  width: 100%; padding: 12px 14px 12px 42px; font-size: .95rem;
  font-family: inherit; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28,77,141,.15); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: .82rem; font-weight: 600; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 50px;
  background: var(--surface); color: var(--text-muted);
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip .count { opacity: .7; margin-left: 4px; font-weight: 500; }

/* ── Tools grid ── */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; text-decoration: none;
  color: inherit; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative; overflow: hidden;
}
.tool-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--primary); }
.tool-card-top { display: flex; align-items: center; gap: 14px; }
.tool-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tool-icon svg { width: 22px; height: 22px; stroke-width: 1.8; }
.tool-card h2 { font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--primary-light); color: var(--primary-dark); }
/* Description: hidden by default, shown on hover */
.tool-card .tool-desc {
  font-size: .88rem; color: var(--text-muted); line-height: 1.5;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .25s ease, opacity .2s ease, margin .2s ease;
  margin-top: 0;
}
.tool-card:hover .tool-desc { max-height: 80px; opacity: 1; margin-top: 4px; }
.tool-link { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--primary); margin-top: 4px; }
.tool-link svg { transition: transform .2s; }
.tool-card:hover .tool-link svg { transform: translateX(4px); }

/* ── Category sections ── */
.category-section { margin-bottom: 36px; }
.category-section:last-child { margin-bottom: 0; }
.category-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.category-heading h3 { font-size: 1.05rem; font-weight: 700; }
.count-badge { font-size: .75rem; font-weight: 600; color: var(--text-muted); background: var(--border); padding: 2px 10px; border-radius: 50px; }
.section-title { font-size: .8rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 20px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state strong { color: var(--text); display: block; margin-bottom: 4px; }

/* Icon colors */
/* Per-category icon colors */
.cat-developer  { background: #fff7ed; color: #c2410c; }
.cat-security   { background: #fdf2f8; color: #9d174d; }
.cat-generator  { background: #ede9fe; color: #6d28d9; }
.cat-encoding   { background: #eff6ff; color: #1d4ed8; }
.cat-writing    { background: #d1fae5; color: #065f46; }
.cat-pdf-tools  { background: #fef3c7; color: #b45309; }
.cat-islamic    { background: #fef9c3; color: #854d0e; }
/* dark mode icon bg */
[data-theme="dark"] .cat-developer  { background: #431407; color: #fb923c; }
[data-theme="dark"] .cat-security   { background: #500724; color: #f9a8d4; }
[data-theme="dark"] .cat-generator  { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .cat-encoding   { background: #172554; color: #93c5fd; }
[data-theme="dark"] .cat-writing    { background: #022c22; color: #6ee7b7; }
[data-theme="dark"] .cat-pdf-tools  { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .cat-islamic    { background: #422006; color: #fde68a; }

/* ── Blog cards ── */
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 20px; margin-bottom: 20px; }
.blog-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; text-decoration: none;
  color: inherit; display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s, border-color .2s;
}
.blog-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--primary); }
.blog-card .post-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.blog-card h2 { font-size: 1.1rem; font-weight: 700; line-height: 1.4; }
.blog-card .excerpt { font-size: .9rem; color: var(--text-muted); line-height: 1.55; flex: 1; }
.post-date { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }

/* ── Single post ── */
.post-hero { background: var(--hero-gradient); color:#fff; padding:28px 24px 40px; text-align:center; }
.post-hero h1 { font-size: clamp(1.6rem,4vw,2.4rem); font-weight: 800; margin-bottom: 12px; max-width: 720px; margin-left: auto; margin-right: auto; }
.post-hero .post-meta { color: rgba(255,255,255,.7); font-size: .9rem; display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.post-main { max-width: 720px; margin: 0 auto; padding: 0 24px 80px; transform: translateY(-32px); }
.post-body {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; box-shadow: var(--shadow);
}
.post-body h1,.post-body h2,.post-body h3 { font-weight: 700; margin: 1.5em 0 .5em; line-height: 1.3; }
.post-body h2 { font-size: 1.4rem; }
.post-body h3 { font-size: 1.15rem; }
.post-body p { margin-bottom: 1.1em; color: var(--text); }
.post-body a { color: var(--primary); }
.post-body ul,.post-body ol { margin: 1em 0 1em 1.5em; }
.post-body li { margin-bottom: .4em; }
.post-body pre { background: #1e293b; color: #e2e8f0; border-radius: 10px; padding: 20px; overflow-x: auto; margin: 1.5em 0; font-size: .875rem; }
.post-body code { font-family: 'SF Mono',Consolas,monospace; font-size: .875em; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }
.post-body pre code { background: none; padding: 0; }
.post-body blockquote { border-left: 4px solid var(--primary); padding: 12px 20px; margin: 1.5em 0; color: var(--text-muted); background: var(--primary-light); border-radius: 0 8px 8px 0; }
.post-body img { max-width: 100%; border-radius: 8px; margin: 1em 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; font-weight: 600; color: var(--primary); text-decoration: none; margin-bottom: 20px; }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 32px; }
.pagination a, .pagination span {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .875rem; font-weight: 600; text-decoration: none; color: var(--text-muted);
  background: var(--surface); transition: all .15s;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Footer ── */
.site-footer {
  text-align: center; padding: 32px 24px;
  color: var(--text-muted); font-size: .875rem;
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--primary); text-decoration: none; }

/* ── View all btn ── */
.view-all-wrap { text-align: center; margin-top: 20px; }
.view-all-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .875rem; font-weight: 600; color: var(--primary); text-decoration: none;
  padding: 10px 22px; border: 1px solid var(--primary-light);
  border-radius: 50px; background: var(--primary-light); transition: all .15s;
}
.view-all-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Dark mode overrides ── */
[data-theme="dark"] .site-nav { background: var(--nav-bg); }
[data-theme="dark"] .toolbar { background: var(--surface); }
[data-theme="dark"] .search-input { background: var(--bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .chip { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .chip.active { background: #1C4D8D; border-color: #4d8fd4; color: #fff; box-shadow: 0 0 0 2px rgba(77,143,212,.4); }
[data-theme="dark"] .tool-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .blog-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .blog-featured { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .blog-filter-bar { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .blog-cat-chip { background: var(--bg); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .blog-cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .blog-tag { background: var(--primary-light); color: var(--primary); }
[data-theme="dark"] .post-body { background: var(--surface); }
[data-theme="dark"] .post-body pre { background: #0f172a; color: #e2e8f0; }
[data-theme="dark"] .post-body code { background: #0f172a; }
[data-theme="dark"] .state-box { background: var(--surface); }
[data-theme="dark"] .pagination a, [data-theme="dark"] .pagination span { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .blog-pagination a, [data-theme="dark"] .blog-pagination span { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .btn-primary { background: var(--surface); color: var(--primary-dark); }

@media(max-width:720px) {
  .blog-featured { grid-template-columns: 1fr; }
  .blog-featured-img { min-height: 200px; }
  .blog-featured-body { padding: 22px 20px; }
}

@media(max-width:600px) {
  .site-hero { padding: 40px 16px 60px; }
  .site-main, .blog-main, .post-main { padding: 0 16px 60px; }
  .post-body { padding: 24px 20px; }
  .tools-grid, .blog-grid { grid-template-columns: 1fr; }
  .blog-filter-inner { padding: 10px 16px; }
}
