/* RewriteAI blog — 3-column desktop, bottom-nav mobile.
 *
 * Colour policy: every surface here uses explicit values, never the site's
 * semantic theme vars. The site ships both a light and a dark theme, and
 * --primary-on-soft is a TEXT colour in both, so using it as a background
 * produced dark-blue-on-blue text that was unreadable. Nothing in this file
 * can inherit a theme value, so contrast cannot break when the theme flips.
 *
 * Look: light page chrome, black cards, white text.
 */

:root {
  /* page (light) */
  --fb-page: #eef1f7;
  --fb-page-ink: #0f172a;
  --fb-page-muted: #5b6779;
  --fb-page-line: rgba(16, 23, 40, 0.12);

  /* cards (black) */
  --fb-card: #0b0e14;
  --fb-card-hover: #11151d;
  --fb-card-line: rgba(255, 255, 255, 0.12);
  --fb-card-line-strong: rgba(255, 255, 255, 0.24);
  --fb-ink: #f8fafc;
  --fb-ink-muted: #aab4c4;

  /* accent */
  --fb-blue: #3d63e8;
  --fb-blue-strong: #2f52d4;
  --fb-blue-on-dark: #9db6ff;
  --fb-blue-wash: rgba(79, 124, 255, 0.16);
  --fb-blue-line: rgba(99, 140, 255, 0.42);

  --fb-radius: 16px;
  --fb-max: 1280px;
  /* Medium thumbnails: big enough to read at a glance, small enough to keep
   * the text column comfortable. */
  --fb-thumb-w: 280px;
  --fb-thumb-h: 180px;
}

.feed-body {
  margin: 0;
  background: var(--fb-page);
  color: var(--fb-page-ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.feed-body a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------------ topbar */

.feed-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--fb-page-line);
  color: var(--fb-page-ink);
}

.feed-topbar__inner {
  max-width: var(--fb-max);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.feed-brand { display: inline-flex; align-items: center; gap: 9px; font-size: 15px; color: var(--fb-page-ink); }
.feed-brand strong { font-weight: 700; letter-spacing: -0.01em; }
.feed-brand span { color: var(--fb-page-muted); font-weight: 500; }

.feed-topnav { display: flex; gap: 20px; font-size: 13px; color: var(--fb-page-muted); }
.feed-topnav a:hover { color: var(--fb-page-ink); }
.feed-topnav a[aria-current="page"] { color: var(--fb-blue); font-weight: 600; }

/* ------------------------------------------------------------------- shell */

.feed-shell {
  max-width: var(--fb-max);
  margin: 0 auto;
  padding: 26px 20px 80px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
}

.feed-left,
.feed-right { position: sticky; top: 84px; }

.feed-side-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fb-page-muted);
}

/* ------------------------------------------------------------------ topics */

.feed-topics { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.feed-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fb-page-ink);
  transition: background 120ms ease, color 120ms ease;
}

.feed-pill:hover { background: rgba(16, 23, 40, 0.06); }

.feed-pill.is-active {
  background: var(--fb-blue);
  color: #ffffff;
  font-weight: 600;
}

.feed-pill.is-active:hover { background: var(--fb-blue-strong); }

.feed-pill__count {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fb-page-muted);
}

.feed-pill.is-active .feed-pill__count { color: rgba(255, 255, 255, 0.9); }

/* -------------------------------------------------------------------- head */

.feed-head { margin-bottom: 20px; }
.feed-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; color: var(--fb-page-ink); }
.feed-head p { margin: 0; font-size: 13px; color: var(--fb-page-muted); }

/* ------------------------------------------------------------------- cards */

.feed-list { display: flex; flex-direction: column; gap: 16px; }

.post-card {
  display: flex;
  gap: 18px;
  padding: 18px;
  background: var(--fb-card);
  border: 1px solid var(--fb-card-line);
  border-radius: var(--fb-radius);
  color: var(--fb-ink);
  box-shadow: 0 10px 26px rgba(8, 12, 20, 0.18);
  transition: border-color 140ms ease, background 140ms ease;
}

.post-card:hover {
  background: var(--fb-card-hover);
  border-color: var(--fb-card-line-strong);
}

.post-card__thumb {
  flex: none;
  width: var(--fb-thumb-w);
  height: var(--fb-thumb-h);
  border-radius: 12px;
  overflow: hidden;
  background: #161b24;
  display: block;
}

.post-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-card__body { min-width: 0; flex: 1; }

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

.post-card__cat {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--fb-blue-wash);
  border: 1px solid var(--fb-blue-line);
  color: var(--fb-blue-on-dark);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.5;
}

.dot { color: var(--fb-ink-muted); opacity: 0.7; }

.post-card__title {
  margin: 0 0 8px;
  font-size: 19px;
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--fb-ink);
}

.post-card__title a:hover { color: var(--fb-blue-on-dark); }

.post-card__excerpt {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fb-ink-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- buttons */

.btn-read {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--fb-blue);
  color: #ffffff !important;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.btn-read:hover { background: var(--fb-blue-strong); }

.btn-ghost {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--fb-card-line-strong);
  color: var(--fb-ink);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

/* ------------------------------------------------------------------- share */

.share { position: relative; }

.share summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--fb-card-line-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--fb-ink);
}

.share summary::-webkit-details-marker { display: none; }
.share summary:hover { background: rgba(255, 255, 255, 0.08); }

.share__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 156px;
  padding: 6px;
  background: #12161e;
  border: 1px solid var(--fb-card-line-strong);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}

.share__menu a,
.share__menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--fb-ink);
  cursor: pointer;
}

.share__menu a:hover,
.share__menu button:hover { background: rgba(255, 255, 255, 0.1); }

/* ------------------------------------------------------------------ pager */

.feed-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  font-size: 13px;
  color: var(--fb-page-muted);
}

.feed-pager a { font-weight: 600; color: var(--fb-blue); }
.feed-pager a:hover { color: var(--fb-blue-strong); }

.feed-empty {
  padding: 34px;
  text-align: center;
  background: var(--fb-card);
  border: 1px solid var(--fb-card-line);
  border-radius: var(--fb-radius);
  color: var(--fb-ink);
}

.feed-empty a { color: var(--fb-blue-on-dark); font-weight: 600; }

/* --------------------------------------------------------------- right rail */

.feed-widget {
  padding: 16px;
  background: var(--fb-card);
  border: 1px solid var(--fb-card-line);
  border-radius: var(--fb-radius);
  margin-bottom: 16px;
  color: var(--fb-ink);
  box-shadow: 0 10px 26px rgba(8, 12, 20, 0.18);
}

.feed-widget .feed-side-title { color: var(--fb-ink-muted); }

.feed-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--fb-card-line-strong);
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  background: #070a10;
  color: var(--fb-ink);
  outline: none;
}

.feed-search::placeholder { color: #8b96a8; }

.feed-search:focus {
  border-color: var(--fb-blue-on-dark);
  box-shadow: 0 0 0 3px rgba(99, 140, 255, 0.25);
}

.feed-search__status {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--fb-ink-muted);
  min-height: 14px;
}

.feed-tools { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.feed-tools a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--fb-card-line);
  transition: background 120ms ease, border-color 120ms ease;
}

.feed-tools a:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--fb-card-line-strong);
}

.feed-tools strong { display: block; font-size: 13.5px; color: var(--fb-ink); }
.feed-tools span { font-size: 12px; color: var(--fb-ink-muted); }

.feed-rss {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fb-blue-on-dark);
}

.feed-rss:hover { color: #ffffff; }

/* ----------------------------------------------------------------- article */

.article-shell { max-width: 1180px; margin: 0 auto; padding: 28px 20px 90px; }

/* Article page uses the same width as the feed so the card no longer floats
 * in a 240px gutter. The freed space becomes a sticky sidebar rather than
 * being spent on 100+ character lines. */
.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
}

.article-main { min-width: 0; }

.article-rail {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.article-rail .feed-widget { margin-bottom: 0; }

.rail-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.rail-links a {
  display: block;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--fb-ink);
}

.rail-links a:hover { background: rgba(255, 255, 255, 0.07); }

.rail-links span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fb-ink-muted);
}

.article-crumbs {
  display: flex;
  gap: 7px;
  font-size: 12px;
  color: var(--fb-page-muted);
  margin-bottom: 18px;
}

.article-crumbs a:hover { color: var(--fb-blue); }

.article {
  background: var(--fb-card);
  border: 1px solid var(--fb-card-line);
  border-radius: var(--fb-radius);
  padding: 30px 34px;
  color: var(--fb-ink);
  box-shadow: 0 14px 34px rgba(8, 12, 20, 0.2);
}

.article__head h1 {
  margin: 10px 0 12px;
  font-size: 32px;
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: #ffffff;
}

.article__hero {
  width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 22px 0;
  display: block;
}

.article__body { font-size: 17px; line-height: 1.78; color: #e6ebf4; }
.article__body h2 { margin: 36px 0 12px; font-size: 23px; letter-spacing: -0.015em; color: #ffffff; }
.article__body h3 { margin: 28px 0 10px; font-size: 19px; color: #ffffff; }
.article__body p { margin: 0 0 16px; }
.article__body ul,
.article__body ol { margin: 0 0 16px; padding-left: 22px; }
.article__body li { margin-bottom: 7px; }
.article__body li::marker { color: var(--fb-blue-on-dark); }
.article__body a { color: var(--fb-blue-on-dark); text-decoration: underline; text-underline-offset: 3px; }
.article__body a:hover { color: #ffffff; }
.article__body img { max-width: 100%; height: auto; border-radius: 12px; }
.article__body strong { color: #ffffff; }

.article__body blockquote {
  margin: 22px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--fb-blue);
  background: rgba(79, 124, 255, 0.12);
  border-radius: 0 12px 12px 0;
  color: #e6ebf4;
}

.article__body code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 5px;
}

.article__body pre {
  background: #05070c;
  border: 1px solid var(--fb-card-line);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
}

.article__body pre code { background: none; padding: 0; }

.article-cta {
  margin: 34px 0;
  padding: 20px;
  border: 1px solid var(--fb-blue-line);
  border-radius: var(--fb-radius);
  background: rgba(79, 124, 255, 0.12);
}

.article-cta__title { margin: 0 0 6px; font-weight: 700; font-size: 15px; color: #ffffff; }
.article-cta p { margin: 0 0 14px; font-size: 14px; color: #d5dcea; }
.article-cta__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.article-tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 28px 0 0; padding: 0; }

.article-tags li {
  padding: 5px 11px;
  border: 1px solid var(--fb-card-line-strong);
  border-radius: 999px;
  font-size: 12px;
  color: var(--fb-ink-muted);
}

.post-card--compact { padding: 16px; }
.post-card--compact .post-card__title { font-size: 17px; }

/* ------------------------------------------------------------- bottom nav */

.feed-bottomnav { display: none; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1140px) {
  .feed-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .feed-right { display: none; }
  :root { --fb-thumb-w: 240px; --fb-thumb-h: 160px; }
}

/* Article: drop the sidebar before the text column gets too narrow. The rail
 * is after the article in the DOM, so it simply stacks underneath. */
@media (max-width: 1024px) {
  .article-grid { grid-template-columns: 1fr; gap: 24px; }
  .article-rail { position: static; }
}

@media (max-width: 860px) {
  .feed-shell {
    grid-template-columns: 1fr;
    padding: 16px 14px 96px;
    gap: 16px;
  }

  .feed-left { position: static; }
  .feed-topics {
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .feed-topics::-webkit-scrollbar { display: none; }
  .feed-pill {
    white-space: nowrap;
    border: 1px solid var(--fb-page-line);
    background: #ffffff;
  }
  .feed-pill.is-active { background: var(--fb-blue); border-color: var(--fb-blue); }

  .feed-right { display: block; position: static; }

  .post-card { flex-direction: column; gap: 14px; padding: 14px; }
  .post-card__thumb { width: 100%; height: 200px; }
  .post-card__title { font-size: 17px; }

  .feed-topnav { display: none; }

  .feed-bottomnav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    background: var(--fb-card);
    border-top: 1px solid var(--fb-card-line);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .feed-bottomnav a {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--fb-ink-muted);
    padding: 4px 2px;
  }
  .feed-bottomnav a.is-active { color: var(--fb-blue-on-dark); }

  .article-shell { padding: 18px 14px 100px; }
  .article { padding: 18px; }
  .article__head h1 { font-size: 25px; }
  .article__body { font-size: 15.5px; }
}
