/* ============================================================
   MABRILE THEME — matteoabrile.it
   Custom tech blog theme: cards, sidebar, auto dark/light
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700;1,9..40,400&family=Inter:wght@400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --font-display: 'DM Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --accent:       #0ea5e9;
  --accent-dim:   #0284c7;
  --accent-glow:  rgba(14, 165, 233, 0.15);

  /* Light */
  --bg:           #f8f9fb;
  --bg-card:      #ffffff;
  --bg-code:      #f1f5f9;
  --border:       #e2e8f0;
  --border-strong:#cbd5e1;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-faint:   #94a3b8;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.12), 0 12px 32px rgba(0,0,0,.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0b0f19;
    --bg-card:      #111827;
    --bg-code:      #1e2535;
    --border:       #1e2d3d;
    --border-strong:#2d3f55;
    --text:         #e2e8f0;
    --text-muted:   #94a3b8;
    --text-faint:   #475569;
    --shadow:       0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    --shadow-hover: 0 4px 12px rgba(0,0,0,.5), 0 12px 32px rgba(0,0,0,.4);
  }
}

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

html { font-size: 16px; scroll-behavior: smooth; overflow-x: hidden; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-dim); }

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

/* ── Layout ────────────────────────────────────────────────── */
.site-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2.5rem;
  align-items: start;
  padding: 2.5rem 0 4rem;
  min-width: 0;
}

@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
}

.main-content { min-width: 0; overflow: hidden; }

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 2rem;
}

.site-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-logo span {
  color: var(--accent);
}

.site-logo:hover { color: var(--text); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav a {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  transition: all .2s;
  border: 1px solid transparent;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-color: rgba(14,165,233,.2);
}

/* ── Hero / Intro ──────────────────────────────────────────── */
.hero {
  padding: 3rem 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.hero-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 2rem;
}

.hero-text h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 1rem;
}

.hero-text h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero-text p {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.7;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.hero-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-code);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

/* ── Post Cards ────────────────────────────────────────────── */
.posts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.posts-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.posts-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all .25s ease;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--cat-color, var(--accent));
  border-radius: 12px 0 0 12px;
  opacity: 0;
  transition: opacity .25s;
}

.post-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.post-card:hover::before { opacity: 1; }

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.post-category {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  border: 1px solid currentColor;
}

/* Category colors */
.cat-embedded   { color: #10b981; background: rgba(16,185,129,.1); --cat-color: #10b981; }
.cat-elettronica{ color: #f59e0b; background: rgba(245,158,11,.1); --cat-color: #f59e0b; }
.cat-networking { color: #0ea5e9; background: rgba(14,165,233,.1); --cat-color: #0ea5e9; }
.cat-sysadmin   { color: #8b5cf6; background: rgba(139,92,246,.1); --cat-color: #8b5cf6; }
.cat-devops     { color: #ef4444; background: rgba(239,68,68,.1);  --cat-color: #ef4444; }
.cat-virtualizzazione { color: #06b6d4; background: rgba(6,182,212,.1); --cat-color: #06b6d4; }
.cat-backup     { color: #f97316; background: rgba(249,115,22,.1); --cat-color: #f97316; }
.cat-general    { color: #94a3b8; background: rgba(148,163,184,.1); --cat-color: #94a3b8; }

.post-date {
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.post-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  transition: color .2s;
}

.post-card:hover .post-card-title { color: var(--accent); }

.post-card-excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.read-more {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: gap .2s;
}

.post-card:hover .read-more { gap: 0.6rem; }

.reading-time {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.sidebar-widget h3 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* Category list */
.cat-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }

.cat-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: all .2s;
  border: 1px solid transparent;
}

.cat-list li a:hover {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(14,165,233,.2);
}

.cat-list .cat-name { display: flex; align-items: center; gap: 0.5rem; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cat-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-code);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  color: var(--text-faint);
}

/* Tag cloud */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag-cloud a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-code);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  transition: all .2s;
}

.tag-cloud a:hover {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(14,165,233,.3);
}

/* About widget */
.about-widget-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: white;
  margin-bottom: 0.75rem;
}

.about-widget p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Single Post ───────────────────────────────────────────── */
.post-header {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.post-header .post-category { margin-bottom: 1rem; display: inline-flex; }

.post-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.post-meta-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.post-meta-bar span { display: flex; align-items: center; gap: 0.4rem; }

/* Post content typography */
.post-content {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}

.post-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.post-content h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.75rem;
}

.post-content h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.5rem 0 0.5rem;
}

.post-content p { margin-bottom: 1.25rem; }

.post-content ul, .post-content ol {
  margin: 1rem 0 1.25rem 1.5rem;
}

.post-content li { margin-bottom: 0.35rem; }

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(14,165,233,.4);
}

.post-content a:hover { text-decoration-color: var(--accent); }

.post-content strong { font-weight: 600; color: var(--text); }

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--accent-glow);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Inline code */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  color: var(--accent);
}

/* Code blocks */
.post-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
  box-shadow: var(--shadow);
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text);
  border-radius: 0;
}

/* Syntax highlight tweaks */
.post-content .highlight {
  border-radius: 10px;
  overflow: hidden;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.post-content .highlight pre {
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* ── Table of Contents ─────────────────────────────────────── */
#TableOfContents {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.875rem;
}

#TableOfContents ul { list-style: none; margin: 0; padding: 0; }
#TableOfContents li { padding: 0.2rem 0; }
#TableOfContents a { color: var(--text-muted); }
#TableOfContents a:hover { color: var(--accent); }

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

.pagination a, .pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all .2s;
  background: var(--bg-card);
}

.pagination a:hover {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(14,165,233,.3);
}

.pagination .current {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Post Navigation ───────────────────────────────────────── */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.post-nav-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  transition: all .2s;
}

.post-nav-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.post-nav-label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.post-nav-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

/* ── Footer ────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 2rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-faint);
}

.footer-brand span { color: var(--accent); }

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ── Utility ───────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Scroll reveal animation */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.post-card {
  animation: fadeUp .4s ease both;
}

.post-card:nth-child(1) { animation-delay: .05s; }
.post-card:nth-child(2) { animation-delay: .10s; }
.post-card:nth-child(3) { animation-delay: .15s; }
.post-card:nth-child(4) { animation-delay: .20s; }
.post-card:nth-child(5) { animation-delay: .25s; }

/* ── About widget extras ───────────────────────────────────── */
.about-excerpt {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1rem;
}

.about-excerpt strong {
  color: var(--text);
  font-weight: 600;
}

.about-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid rgba(14,165,233,.3);
  background: var(--accent-glow);
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  transition: all .2s;
}

.about-link:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
