/* ===========================================================================
   blog.css — Home grid + reader page + reactions + comment button
   ---------------------------------------------------------------------------
   Loaded by:
     - index.html   (home grid styles)
     - /blog/index.html (everything)

   Semantic aliases bridge the spec's variable names (--accent, --bg, etc.)
   onto the brand palette already defined in styles.css. This keeps the blog
   module portable to other sites with minimal edits.
   =========================================================================== */

:root {
  --bg:           var(--grey-50);
  --surface:      var(--white);
  --border:       var(--grey-200);
  --text:         var(--grey-700);
  --text-muted:   var(--grey-500);
  --accent:       var(--navy);
  --accent-deep:  var(--navy-deep);
  --accent-soft:  var(--navy-tint);
}

/* ============================================================
   HOME-PAGE BLOG SECTION
   ============================================================ */

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
}

.blog-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: clamp(20px, 2.5vw, 28px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition:
    transform 0.3s var(--ease),
    box-shadow 0.3s var(--ease),
    border-color 0.3s var(--ease);
}
.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 44px rgba(15, 37, 87, 0.14);
  border-color: var(--accent-soft);
}

.blog-tag {
  align-self: flex-start;
  padding: 4px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
html[lang="kn"] .blog-tag { letter-spacing: 0; text-transform: none; font-size: 12px; }

.blog-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: -0.01em;
}
html[lang="kn"] .blog-title { line-height: 1.5; letter-spacing: 0; }

.blog-excerpt {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
}
html[lang="kn"] .blog-excerpt { line-height: 1.7; }

.blog-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
}
.blog-dot {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
}

/* ----- Skeleton loading state ----- */
.blog-card.skeleton {
  pointer-events: none;
  cursor: default;
}
.blog-card.skeleton .blog-tag,
.blog-card.skeleton .blog-title,
.blog-card.skeleton .blog-excerpt,
.blog-card.skeleton .blog-meta span {
  background: var(--grey-100);
  color: transparent;
  border-radius: 6px;
  animation: skel-pulse 1.6s ease-in-out infinite;
}
.blog-card.skeleton .blog-tag    { width: 70px; height: 22px; background: var(--accent-soft); }
.blog-card.skeleton .blog-title  { width: 80%;  height: 22px; }
.blog-card.skeleton .blog-excerpt{ width: 100%; height: 60px; }
.blog-card.skeleton .blog-meta span { width: 90px; height: 14px; }

@keyframes skel-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ----- "View all posts" link below home grid ----- */
.blog-view-all {
  margin-top: var(--space-6);
  text-align: center;
}
.blog-view-all a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), gap 0.2s var(--ease);
}
.blog-view-all a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  gap: 12px;
}

/* ----- Empty / error state ----- */
.blog-message {
  grid-column: 1 / -1;
  padding: 28px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
}
.blog-message a { color: var(--accent); font-weight: 600; }

/* ============================================================
   ARCHIVE PAGE  (/blog/all/index.html)
   ============================================================ */

.archive-container {
  max-width: 1100px;
  margin: 0 auto;
}

.archive-header {
  margin-bottom: var(--space-7);
  text-align: center;
}
.archive-header h1 {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0 0 8px;
}
html[lang="kn"] .archive-header h1 { letter-spacing: 0; line-height: 1.3; padding: 0.1em 0; }

.archive-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--space-6);
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.archive-filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

#archive-cat {
  padding: 8px 36px 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231a3a8a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.2s var(--ease);
}
#archive-cat:focus,
#archive-cat:hover { border-color: var(--accent); }

.archive-year-group {
  margin-bottom: var(--space-7);
}
.archive-year-group:last-child { margin-bottom: 0; }

.archive-year {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0;
  margin: 0 0 var(--space-4);
  padding-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-feature-settings: "tnum";
}
.archive-year::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
  align-self: center;
}

@media (max-width: 480px) {
  .archive-year { font-size: 19px; }
  .archive-filter { padding: 12px 14px; }
}

/* ============================================================
   READER PAGE  (/blog/index.html)
   ============================================================ */

body.reader-body {
  background: var(--bg);
}

.reader-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 4vw, 28px);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.reader-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.reader-brand img {
  width: 32px; height: 32px;
  border-radius: 8px;
  padding: 2px;
  background: var(--white);
  border: 1px solid var(--border);
}
.reader-brand strong {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-header-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.reader-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.reader-back:hover { background: var(--accent-deep); transform: translateY(-1px); }

.reader-main {
  flex: 1;
  padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 24px) 64px;
}

.reader-article {
  max-width: 740px;
  margin: 0 auto;
}

.post-tag {
  display: inline-block;
  padding: 5px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
html[lang="kn"] .post-tag { letter-spacing: 0; text-transform: none; font-size: 12px; }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.post-title {
  font-size: clamp(28px, 4.4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--ink);
}
html[lang="kn"] .post-title { line-height: 1.3; letter-spacing: 0; padding: 0.1em 0; }

.post-author {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 32px;
}
.post-author strong { color: var(--ink); font-weight: 600; }

/* ----- Rendered post body ----- */
.post-content {
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--text);
}
html[lang="kn"] .post-content { line-height: 1.85; }

.post-content > :first-child { margin-top: 0; }
.post-content p { margin: 0 0 1.2em; }

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 1.6em 0 0.6em;
  line-height: 1.25;
}
html[lang="kn"] .post-content h1,
html[lang="kn"] .post-content h2,
html[lang="kn"] .post-content h3,
html[lang="kn"] .post-content h4 { letter-spacing: 0; line-height: 1.4; }
.post-content h1 { font-size: 28px; }
.post-content h2 { font-size: 24px; }
.post-content h3 { font-size: 20px; }
.post-content h4 { font-size: 17px; }

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(26, 58, 138, 0.35);
  text-underline-offset: 2px;
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease), opacity 0.2s var(--ease);
}
.post-content a:hover {
  color: var(--accent-deep);
  text-decoration-color: var(--accent);
}

.post-content strong { color: var(--ink); font-weight: 700; }
.post-content em     { color: var(--text); font-style: italic; }

.post-content ul,
.post-content ol {
  margin: 0 0 1.4em;
  padding-left: 1.5em;
}
.post-content li { margin-bottom: 0.4em; }

.post-content blockquote {
  margin: 1.4em 0;
  padding: 14px 22px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-style: italic;
  color: var(--text);
  border-radius: 0 12px 12px 0;
}
.post-content blockquote p:last-child { margin-bottom: 0; }

.post-content img,
.post-content iframe {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.6em auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.post-content iframe { aspect-ratio: 16 / 9; width: 100%; }

.post-content code {
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--grey-100);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.55;
  margin: 1.4em 0;
}
.post-content pre code {
  background: transparent;
  color: var(--text);
  padding: 0;
  border-radius: 0;
}

.post-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 14px;
}
.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.post-content th { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

/* ============================================================
   REACTIONS
   ============================================================ */

.reactions {
  margin: 48px auto 0;
  max-width: 740px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.reactions-label {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
  font-weight: 500;
}

.reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease),
    color 0.2s var(--ease),
    transform 0.15s var(--ease);
}
.reaction-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.reaction-btn.clicked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.reaction-btn.clicked .reaction-count { color: var(--accent); }

.reaction-emoji {
  font-size: 18px;
  display: inline-block;
  line-height: 1;
}
.reaction-emoji.bump { animation: emoji-bump 0.6s var(--ease); }

@keyframes emoji-bump {
  0%   { transform: scale(1) rotate(0deg); }
  30%  { transform: scale(1.4) rotate(-12deg); }
  60%  { transform: scale(1.15) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.reaction-count {
  font-feature-settings: "tnum";
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

/* ============================================================
   END-OF-POST ACTION ROW
   ============================================================ */

.reader-end {
  max-width: 740px;
  margin: 32px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.end-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition:
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    transform 0.2s var(--ease);
}
.end-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.end-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}
.end-btn.primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: var(--white);
}

/* ============================================================
   READER FOOTER + ERROR STATES
   ============================================================ */

.reader-footer {
  padding: 28px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

.reader-error {
  max-width: 600px;
  margin: 60px auto;
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.reader-error h2 {
  font-size: 22px;
  margin: 0 0 12px;
  color: var(--ink);
}
.reader-error p {
  color: var(--text-muted);
  margin: 0 0 20px;
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 768px) {
  .post-content   { font-size: 16px; line-height: 1.75; }
  .post-content h1 { font-size: 24px; }
  .post-content h2 { font-size: 21px; }
  .post-content h3 { font-size: 18px; }
  .reader-end     { flex-direction: column; align-items: stretch; }
  .end-btn        { justify-content: center; }
  .reader-back span { display: none; }
  .reader-back    { padding: 8px 12px; }
}

@media (max-width: 480px) {
  .reactions      { padding: 18px; margin-top: 32px; }
  .reaction-btn   { padding: 7px 12px; font-size: 13px; }
  .reaction-emoji { font-size: 16px; }
  .reader-brand strong { display: none; }
}
