/* Blog — modern OLED Animation Maker */
:root {
  --bg: #f4f6fb;
  --bg-hero: linear-gradient(160deg, #eff6ff 0%, #f8fafc 45%, #f4f6fb 100%);
  --card: #ffffff;
  --border: #e2e8f0;
  --border-hover: #93c5fd;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.35);
  --accent-light: #eff6ff;
  --gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 55%, #7c3aed 100%);
  --text: #0f172a;
  --muted: #64748b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(37, 99, 235, 0.12);
  --header-h: 64px;
}

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

html { scroll-behavior: smooth; }

html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); transition: color 0.15s; }
a:hover { color: var(--accent-dark); }

/* ─── Header (sticky glass) ───────────────────────────────────────────── */
.blog-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: var(--shadow-sm);
}

.blog-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.blog-header__brand:hover { color: var(--accent); text-decoration: none; }

.blog-header__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.blog-header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.blog-header__nav a {
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.blog-header__nav a:hover {
  color: var(--text);
  background: #f1f5f9;
  text-decoration: none;
}

.blog-header__nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-light);
}

.blog-header__nav .btn-nav-primary {
  background: var(--gradient);
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.blog-header__nav .btn-nav-primary:hover {
  color: #fff !important;
  background: linear-gradient(135deg, #1d4ed8 0%, #4338ca 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.blog-header__title {
  min-width: 0;
  line-height: 1.2;
}

.blog-header__title-short,
.blog-header__nav .btn-nav-short {
  display: none;
}

/* ─── Layout ──────────────────────────────────────────────────────────── */
.blog-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 56px;
}

.blog-wrap--wide { max-width: 1040px; }

/* ─── Hero (index) ────────────────────────────────────────────────────── */
.blog-hero {
  position: relative;
  margin: 0 -24px 40px;
  padding: 48px 32px 44px;
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 24px 24px;
  text-align: center;
  overflow: hidden;
}

.blog-hero::before {
  content: '';
  position: absolute;
  top: -60%;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(37, 99, 235, 0.08) 0%, transparent 65%);
  pointer-events: none;
}

.blog-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: #fff;
  border: 1px solid #bfdbfe;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.blog-hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
  position: relative;
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.blog-hero__meta {
  font-size: 16px;
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
  position: relative;
}

.blog-hero__meta a {
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.blog-hero__meta a:hover {
  border-bottom-color: var(--accent);
}

.blog-hero__chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  position: relative;
}

.blog-hero__chip {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* ─── Card grid ───────────────────────────────────────────────────────── */
.blog-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

@media (min-width: 640px) {
  .blog-card-grid { grid-template-columns: repeat(2, 1fr); }
}

.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.blog-card::after {
  content: 'Read →';
  position: absolute;
  bottom: 20px;
  right: 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s, transform 0.2s;
}

.blog-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  text-decoration: none;
}

.blog-card:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.blog-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.blog-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.blog-card__icon--beginner { background: #ecfdf5; }
.blog-card__icon--tutorial { background: #eff6ff; }
.blog-card__icon--gif { background: #fdf4ff; }
.blog-card__icon--tools { background: #fff7ed; }
.blog-card__icon--esp32 { background: #f0fdf4; }
.blog-card__icon--hardware { background: #f8fafc; }

.blog-card__tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 10px;
  border-radius: 6px;
}

.blog-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  color: var(--text);
  padding-right: 48px;
}

.blog-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.blog-card time {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
}

/* Legacy: article cards without link wrapper */
.blog-card h2 a {
  color: inherit;
  text-decoration: none;
}

.blog-card h2 a:hover { color: var(--accent); }

/* ─── Article pages ───────────────────────────────────────────────────── */
.blog-article-shell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px 40px;
  box-shadow: var(--shadow);
  margin-top: 8px;
}

article h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
  color: var(--text);
}

article .article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

article .article-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

article h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 32px 0 12px;
  color: var(--text);
  padding-top: 8px;
}

article h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 22px 0 10px;
}

article p, article li {
  margin-bottom: 14px;
  font-size: 16px;
  color: #334155;
}

article ul, article ol {
  padding-left: 22px;
  margin-bottom: 18px;
}

article li { margin-bottom: 8px; }

article code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86em;
  background: #f1f5f9;
  color: #be185d;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

article pre {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #e2e8f0;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  margin: 18px 0 22px;
  line-height: 1.55;
  border: 1px solid #334155;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ─── CTA ─────────────────────────────────────────────────────────────── */
.cta-box {
  position: relative;
  background: var(--gradient);
  border: none;
  border-radius: var(--radius);
  padding: 32px 28px;
  margin: 36px 0;
  text-align: center;
  overflow: hidden;
  box-shadow: 0 8px 32px var(--accent-glow);
}

.cta-box::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.cta-box h3 {
  position: relative;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}

.cta-box p {
  position: relative;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.88);
  margin-bottom: 18px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: var(--accent) !important;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 28px;
  border-radius: 10px;
  text-decoration: none !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}

.cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  color: var(--accent-dark) !important;
  text-decoration: none !important;
}

/* ─── Footer ──────────────────────────────────────────────────────────── */
.blog-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 28px 24px 36px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.blog-footer a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.blog-footer a:hover { text-decoration: underline; }

/* ─── Breadcrumb & misc ───────────────────────────────────────────────── */
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin: 24px 0 20px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: inline-block;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb a:hover { color: var(--accent); }

.seo-keywords-block {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin-top: 32px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

article details {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  background: #fafbfc;
  overflow: hidden;
  transition: border-color 0.15s;
}

article details[open] {
  border-color: #bfdbfe;
  background: #fff;
}

article details summary {
  font-weight: 600;
  cursor: pointer;
  padding: 14px 18px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

article details summary::-webkit-details-marker { display: none; }

article details summary::after {
  content: '+';
  font-size: 18px;
  font-weight: 400;
  color: var(--muted);
}

article details[open] summary::after { content: '−'; }

article details p {
  padding: 0 18px 16px;
  margin-bottom: 0;
  font-size: 15px;
}

/* Article shell on post pages */
.blog-wrap article:not(.blog-card) {
  /* when article is direct child without shell wrapper */
}

@media (max-width: 640px) {
  :root { --header-h: 52px; }

  .blog-header {
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    height: auto;
    min-height: var(--header-h);
    gap: 10px;
  }

  .blog-header__brand {
    font-size: 13px;
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .blog-header__logo {
    width: 30px;
    height: 30px;
    font-size: 15px;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .blog-header__title-full { display: none; }
  .blog-header__title-short { display: inline; }

  .blog-header__nav {
    gap: 6px;
    flex-shrink: 0;
  }

  .blog-header__nav a {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 7px;
    line-height: 1.2;
  }

  .blog-header__nav .btn-nav-primary {
    padding: 6px 11px;
    font-size: 12px;
    box-shadow: 0 1px 6px var(--accent-glow);
  }

  .blog-header__nav .btn-nav-primary:hover {
    transform: none;
  }

  .blog-header__nav .btn-nav-full { display: none; }
  .blog-header__nav .btn-nav-short { display: inline; }

  .blog-hero {
    margin: 0 -12px 28px;
    padding: 32px 18px 28px;
    border-radius: 0 0 18px 18px;
  }

  .blog-hero h1 { font-size: 1.5rem; }
  .blog-hero__meta { font-size: 14px; }
  .blog-hero__chip { font-size: 11px; padding: 5px 10px; }

  .blog-wrap { padding: 0 12px 36px; }
  .blog-article-shell { padding: 22px 18px 26px; }
  .blog-card { padding: 18px 18px 16px; }
  .blog-card::after { display: none; }
  .blog-card h2 { padding-right: 0; font-size: 1.02rem; }

  .cta-box { padding: 24px 18px; margin: 28px 0; }
  .cta-btn { font-size: 14px; padding: 11px 20px; }

  .breadcrumb {
    font-size: 12px;
    padding: 8px 12px;
    margin: 16px 0 14px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .blog-header__nav a:not(.btn-nav-primary) {
    padding: 6px 8px;
  }

  .blog-header__nav .btn-nav-primary {
    padding: 6px 9px;
  }
}

/* ─── Hero Image Enhancements (Card & Article) ────────────────────────── */
.blog-card__media {
  flex-shrink: 0;
  width: calc(100% + 48px);
  margin: -22px -24px 18px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f1f5f9 0%, #e8eef5 100%);
}

.blog-card__hero {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  object-position: center;
  border: none;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.blog-card:hover .blog-card__hero {
  transform: scale(1.04);
}

.blog-article__hero {
  width: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 12px 0 28px;
  box-shadow: var(--shadow-sm);
  display: block;
}

@media (max-width: 640px) {
  .blog-card__media {
    width: calc(100% + 36px);
    margin: -18px -18px 14px;
    aspect-ratio: 16 / 9;
  }

  .blog-article__hero {
    margin: 8px 0 20px;
  }
}

.blog-figure__caption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: -18px 0 24px;
  line-height: 1.5;
}

figure { margin: 0; }

.blog-article__image {
  width: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 18px 0 24px;
  box-shadow: var(--shadow-sm);
  display: block;
}
