/*
 * Public blog stylesheet. Brand palette and lockup mirror the writers-lab
 * SPA (frontend TopBar / Theme): dark surfaces, violet accent, pill buttons,
 * "Writers Lab" wordmark. Independent of the Compose CSS-in-JS.
 */
:root {
  --bg: #15131A;
  --surface: #1D1B23;
  --surface-2: #2B2832;
  --border: rgba(201, 197, 208, 0.14);
  --text: #EDEDED;
  --muted: #C9C5D0;
  --faint: #918AA0;
  --primary: #A5AEF7;
  --primary-strong: #DBE0FF;
  --primary-container: #3A4578;
  --accent-soft: rgba(165, 174, 247, 0.14);
  --radius: 8px;
  --pill: 120px;
  --shell: 760px;   /* simple centered pages (404)         */
  --wide: 1080px;   /* header / footer / feed / article     */
  --read: 720px;    /* article reading column              */
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); line-height: 1.6; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
/* Ambient background — soft violet glows so a wide desktop doesn't read empty. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(620px 440px at 10% 4%, rgba(125,136,239,0.11), transparent 70%),
    radial-gradient(720px 520px at 92% 14%, rgba(58,69,120,0.20), transparent 72%),
    radial-gradient(560px 460px at 50% 108%, rgba(125,136,239,0.07), transparent 70%);
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-strong); }
img { max-width: 100%; height: auto; }

/* Visible keyboard focus on every interactive element. */
a:focus-visible, button:focus-visible, .blog-card:focus-visible,
.blog-side-item:focus-visible, .blog-readnext-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip-to-content link (first focusable element). */
.blog-skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--primary-container); color: var(--primary-strong);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  transition: top 0.15s ease;
}
.blog-skip:focus { top: 12px; }

.blog-shell { width: 100%; max-width: var(--shell); margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.blog-wide { width: 100%; max-width: var(--wide); margin: 0 auto; padding-left: 20px; padding-right: 20px; }

/* Reading-progress bar (article). */
.blog-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--primary); z-index: 50; transition: width 0.08s linear; }

/* ── Header ───────────────────────────────────────────────────────── */
.blog-topbar-wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 16px 20px 0; }
.blog-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-radius: var(--radius); padding: 10px 16px;
}
.blog-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.blog-brand-icon { width: 32px; height: 32px; border-radius: 8px; display: block; cursor: pointer; }
.blog-brand-name { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1; white-space: nowrap; }
.blog-brand-name span { color: var(--primary); }
.blog-brand-sub { color: var(--muted); font-size: 14px; font-weight: 500; padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--border); }
@media (max-width: 520px) { .blog-brand-sub { display: none; } }

.blog-cta {
  display: inline-block; background: var(--primary-container); color: var(--primary-strong);
  font-weight: 600; padding: 9px 18px; border-radius: var(--pill); font-size: 15px;
  white-space: nowrap; transition: filter 0.15s ease;
}
.blog-cta:hover { filter: brightness(1.12); color: var(--primary-strong); }
.blog-cta--sm { padding: 8px 16px; font-size: 14px; }

/* ── Footer ──────────────────────────────────────────────────────── */
.blog-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 26px 0; color: var(--muted); font-size: 14px; }
.blog-footer-inner { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.blog-footer-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.blog-footer-nav a { color: var(--muted); }
.blog-footer-nav a:hover { color: var(--text); }

/* ── Listing (feed) ──────────────────────────────────────────────── */
.blog-list { padding-top: 40px; padding-bottom: 64px; flex: 1; }
.blog-list-head { margin-bottom: 26px; }
.blog-list-head h1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 44px); line-height: 1.08; margin: 0 0 12px; letter-spacing: -0.015em; text-wrap: balance; }
.blog-list-sub { color: var(--muted); font-size: 17px; max-width: 62ch; margin: 0; }
.blog-empty { color: var(--muted); }

.blog-langswitch { display: inline-flex; gap: 4px; margin-top: 16px; }
.blog-langswitch a { font-size: 13px; font-weight: 600; color: var(--muted); padding: 5px 11px; border-radius: var(--pill); background: var(--surface-2); }
.blog-langswitch a:hover { color: var(--text); }
.blog-langswitch a.active { color: var(--primary-strong); background: var(--primary-container); }

.blog-feed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.blog-card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  transition: border-color 0.15s ease, transform 0.08s ease; color: inherit;
}
.blog-card:hover { border-color: #4a4660; transform: translateY(-2px); }
.blog-card-cover { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.blog-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blog-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 0; }
.blog-card-title { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; line-height: 1.22; }
.blog-card-lead { color: var(--muted); margin: 0; font-size: 15px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.blog-card-foot { margin-top: auto; padding-top: 4px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.blog-card-more { color: var(--primary); font-size: 14px; font-weight: 600; }
.blog-card:hover .blog-card-more { color: var(--primary-strong); }

/* Featured (first) card spans the row: cover left, text right. The cover img
 * is absolutely positioned so a tall portrait image can't dictate the card
 * height — the text sets the height, the cover fills it (object-fit: cover). */
.blog-card--feature { grid-column: 1 / -1; flex-direction: row; min-height: 300px; }
.blog-card--feature .blog-card-cover { flex: 0 0 42%; aspect-ratio: auto; position: relative; align-self: stretch; }
.blog-card--feature .blog-card-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.blog-card--feature .blog-card-body { padding: 30px 34px; gap: 14px; justify-content: center; }
.blog-card--feature .blog-card-title { font-size: 30px; line-height: 1.16; }
.blog-card--feature .blog-card-lead { font-size: 16.5px; -webkit-line-clamp: 6; }

.blog-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--faint); font-size: 13px; }
.blog-meta .dot { color: var(--faint); }

.blog-pager { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 40px; }
.blog-pager-btn { border: 1px solid var(--border); border-radius: var(--pill); padding: 8px 16px; color: var(--text); font-size: 14px; }
.blog-pager-btn:hover { border-color: var(--primary); }
.blog-pager-pos { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ── Article (reading column + sidebar) ──────────────────────────── */
.blog-article-wrap { padding-top: 28px; padding-bottom: 64px; flex: 1; }
.blog-article-layout { display: grid; grid-template-columns: minmax(0, var(--read)) 280px; gap: 48px; justify-content: center; align-items: start; }
.blog-article { min-width: 0; }
.blog-article-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.blog-back { color: var(--muted); font-size: 14px; }
.blog-back:hover { color: var(--text); }
.blog-langlink { font-size: 14px; color: var(--primary); }
.blog-langlink:hover { text-decoration: underline; }

.blog-article-title { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 5vw, 44px); line-height: 1.12; letter-spacing: -0.015em; text-wrap: balance; margin: 0 0 16px; }
.blog-article-meta { font-size: 14.5px; margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--border); color: var(--muted); }
.blog-avatar { width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; background: linear-gradient(135deg, var(--primary), #6f7bd8); }
.blog-article-cover { margin: 0 0 30px; }
.blog-article-cover img { width: 100%; border-radius: var(--radius); display: block; }

.blog-content { font-family: var(--serif); font-size: 19px; line-height: 1.78; color: var(--text); }
.blog-content > *:first-child { margin-top: 0; }
.blog-content p { margin: 0 0 24px; }
.blog-content > p:first-child::first-letter { font-size: 3.1em; float: left; line-height: 0.78; padding: 6px 12px 0 0; font-weight: 600; color: var(--primary); }
.blog-content h1 { font-family: var(--serif); font-size: clamp(26px, 3vw, 33px); font-weight: 600; line-height: 1.18; margin: 40px 0 14px; letter-spacing: -0.01em; scroll-margin-top: 80px; }
.blog-content h2 { font-family: var(--serif); font-size: clamp(22px, 2.6vw, 27px); font-weight: 600; line-height: 1.2; margin: 38px 0 14px; letter-spacing: -0.01em; scroll-margin-top: 80px; }
.blog-content h3 { font-family: var(--serif); font-size: 22px; line-height: 1.25; margin: 30px 0 12px; scroll-margin-top: 80px; }
.blog-content h4 { font-size: 18px; font-weight: 700; margin: 26px 0 10px; }
.blog-content a { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: #4b4770; }
.blog-content a:hover { text-decoration-color: var(--primary); }
.blog-content strong { font-weight: 700; color: #FFFFFF; }
.blog-content em { font-style: italic; }
.blog-content del { color: var(--muted); }
.blog-content img { border-radius: var(--radius); margin: 10px 0; }
.blog-content ul, .blog-content ol { margin: 0 0 24px; padding-left: 26px; }
.blog-content li { margin: 8px 0; padding-left: 4px; }
.blog-content li::marker { color: var(--primary); }
.blog-content blockquote { margin: 26px 0; padding: 6px 0 6px 20px; border-left: 3px solid var(--primary); color: var(--muted); font-size: 1em; }
.blog-content blockquote p { margin: 0 0 12px; }
.blog-content blockquote p:last-child { margin-bottom: 0; }
.blog-content hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }
.blog-content code { font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.blog-content pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; overflow-x: auto; margin: 0 0 24px; }
.blog-content pre code { background: none; padding: 0; font-size: 14.5px; }
.blog-content table { border-collapse: collapse; width: 100%; margin: 0 0 24px; font-size: 16px; display: block; overflow-x: auto; }
.blog-content th, .blog-content td { border: 1px solid var(--border); padding: 9px 13px; text-align: left; }
.blog-content th { background: var(--surface-2); font-weight: 600; }

.blog-article-cta { margin-top: 40px; padding: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.blog-article-cta p { margin: 0; color: var(--text); font-size: 17px; }

/* ── Reactions ───────────────────────────────────────────────────── */
.blog-reactions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--border); }
.blog-reactions-label { color: var(--muted); font-size: 15px; margin-right: 4px; }
.blog-react { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--pill); padding: 8px 16px; font-size: 15px; cursor: pointer; font-family: var(--sans); transition: border-color 0.15s ease, background 0.15s ease; }
.blog-react:hover { border-color: #4a4660; }
.blog-react.active { border-color: var(--primary); background: var(--accent-soft); color: var(--primary-strong); }
.blog-react-count { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Read-next block ─────────────────────────────────────────────── */
.blog-readnext { margin-top: 44px; }
.blog-readnext-label { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin: 0 0 12px; }
.blog-readnext-card { display: flex; gap: 20px; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: border-color 0.15s ease, transform 0.08s ease; }
.blog-readnext-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.blog-readnext-cover { flex: 0 0 220px; background: var(--surface-2); }
.blog-readnext-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blog-readnext-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; justify-content: center; min-width: 0; }
.blog-readnext-title { font-family: var(--serif); font-size: 23px; font-weight: 600; margin: 0; line-height: 1.2; color: var(--text); }
.blog-readnext-lead { color: var(--muted); font-size: 15px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.blog-sidebar { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 26px; }
.blog-side-block h2 { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin: 0 0 12px; }
.blog-toc { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.blog-toc li { margin: 0; }
.blog-toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); font-size: 14px; line-height: 1.35; }
.blog-toc a:hover { color: var(--text); }
.blog-toc a.lvl-3 { padding-left: 26px; font-size: 13.5px; }
.blog-toc a.active { color: var(--primary-strong); border-left-color: var(--primary); }
.blog-side-related { display: flex; flex-direction: column; gap: 14px; }
.blog-side-item { color: inherit; display: block; }
.blog-side-item-title { font-size: 14.5px; font-weight: 600; color: var(--text); line-height: 1.3; margin: 0 0 3px; }
.blog-side-item:hover .blog-side-item-title { color: var(--primary); }
.blog-side-item-meta { font-size: 12.5px; color: var(--faint); }

/* ── Mascot easter egg ───────────────────────────────────────────── */
.blog-mascot { position: fixed; left: -160px; bottom: -40px; width: 96px; z-index: 60; pointer-events: none; opacity: 0; }
.blog-mascot.run { animation: blog-fly 2.6s cubic-bezier(.34,.2,.3,1) forwards; }
@keyframes blog-fly {
  0% { opacity: 0; transform: translate(0,0) rotate(-6deg); }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; transform: translate(112vw, -86vh) rotate(14deg); }
}

/* ── 404 ─────────────────────────────────────────────────────────── */
.blog-404 { flex: 1; padding: 80px 0; text-align: center; }
.blog-404 h1 { font-family: var(--serif); font-size: 34px; margin: 0 0 12px; }
.blog-404 p { color: var(--muted); margin: 0 0 26px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 940px) {
  .blog-article-layout { grid-template-columns: 1fr; }
  .blog-sidebar { display: none; }
  .blog-article { max-width: var(--read); margin: 0 auto; }
}
@media (max-width: 720px) {
  .blog-feed { grid-template-columns: 1fr; }
  .blog-card--feature { flex-direction: column; }
  .blog-card--feature .blog-card-cover { flex-basis: auto; aspect-ratio: 16 / 9; }
  .blog-readnext-card { flex-direction: column; }
  .blog-readnext-cover { flex-basis: auto; aspect-ratio: 16 / 9; }
  .blog-content { font-size: 17.5px; }
}
@media (prefers-reduced-motion: reduce) { *, body::before { transition: none !important; animation: none !important; } html { scroll-behavior: auto; } }

@media print {
  .blog-progress, .blog-mascot, .blog-topbar-wrap, .blog-footer, .blog-sidebar,
  .blog-article-cta, .blog-readnext, .blog-reactions, .blog-skip { display: none !important; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
  .blog-content, .blog-article-title, .blog-content strong { color: #000; }
  .blog-article-layout { grid-template-columns: 1fr; }
}
