/* Shared design system for the RiderSOS blog (index + detail pages).
   Editorial journal styling: serif display type, a narrow reading
   column, restrained imagery and hairline rules instead of stacked
   drop-shadow cards - built to read as a real publication, not a
   templated SaaS landing page. */

.blog-detail-page,
.blog-index-page {
  --blog-serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --blog-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --blog-ink: #17140f;
  --blog-muted: #625d54;
  --blog-faint: #948d81;
  --blog-rule: rgba(23, 20, 15, 0.1);
  --blog-paper: #fbf9f6;
  --blog-accent: #b3211a;
  background: var(--blog-paper);
  font-family: var(--blog-sans);
  color: var(--blog-ink);
}

.blog-kicker {
  font-family: var(--blog-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blog-accent);
}

.blog-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--blog-sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blog-faint);
}

.blog-card__meta span:first-child {
  color: var(--blog-accent);
}

.blog-card__meta span + span::before {
  content: "\2022";
  margin-right: 0.55rem;
  color: var(--blog-rule);
}

/* ---------- Shared image frame ---------- */

.blog-media-frame {
  position: relative;
  background: #efece5;
}

.blog-media-frame picture,
.blog-media-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.blog-media-frame__caption {
  margin-top: 0.65rem;
  font-family: var(--blog-serif) !important;
  font-style: italic;
  font-size: 0.86rem;
  color: var(--blog-faint);
  line-height: 1.5;
}

/* ---------- Reading progress + sticky bar (detail page) ---------- */

.blog-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1200;
  width: 0%;
  height: 2px;
  background: var(--blog-accent);
  transition: width 80ms linear;
}

.blog-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 1100;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 220ms ease, opacity 220ms ease;
  background: rgba(251, 249, 246, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}

.blog-sticky-bar.is-visible {
  max-height: 4.5rem;
  opacity: 1;
  border-bottom-color: var(--blog-rule);
}

.blog-sticky-bar__inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.blog-sticky-bar__back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--blog-ink);
  text-decoration: none;
  white-space: nowrap;
}

.blog-sticky-bar__back:hover {
  color: var(--blog-accent);
}

.blog-sticky-bar__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--blog-serif) !important;
  font-size: 0.95rem;
  color: var(--blog-ink);
}

.blog-sticky-bar__cta {
  flex: none;
}

@media (max-width: 720px) {
  .blog-sticky-bar__title {
    display: none;
  }
}

/* ---------- Detail page shell ---------- */

.blog-article-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

.blog-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--blog-muted);
  text-decoration: none;
}

.blog-back-link:hover {
  color: var(--blog-accent);
}

.blog-back-link--footer {
  margin-top: 0;
  margin-bottom: 0;
}

.blog-article-hero {
  display: grid;
  gap: 1.1rem;
  justify-items: center;
  text-align: center;
  padding-bottom: 2.25rem;
  border-bottom: 1px solid var(--blog-rule);
}

.blog-article-meta,
.blog-article-byline {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blog-faint);
}

.blog-article-meta span:first-child {
  color: var(--blog-accent);
}

.blog-article-title {
  margin: 0;
  max-width: 26ch;
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: clamp(1.7rem, 3.1vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--blog-ink) !important;
}

.blog-article-intro {
  max-width: 38rem;
  margin: 0;
  color: var(--blog-muted);
  font-family: var(--blog-serif) !important;
  font-style: italic;
  line-height: 1.65;
  font-size: 1.15rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.blog-article-byline {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  color: var(--blog-faint);
  font-size: 0.82rem;
}

.blog-article-media {
  margin: 0.5rem 0 0;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid var(--blog-rule);
  background: #efece5;
}

.blog-article-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

/* ---------- Table of contents: mobile accordion ---------- */

.blog-toc-mobile {
  display: none;
  margin-top: 1.5rem;
}

.blog-toc-mobile__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-radius: 0.6rem;
  border: 1px solid var(--blog-rule);
  background: #ffffff;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--blog-ink);
  cursor: pointer;
}

.blog-toc-mobile__toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

.blog-toc-mobile__toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.blog-toc-mobile__panel {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.5rem;
  padding: 0.6rem;
  border-radius: 0.6rem;
  border: 1px solid var(--blog-rule);
  background: #ffffff;
}

.blog-toc-mobile__panel a {
  padding: 0.55rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--blog-muted);
  text-decoration: none;
}

.blog-toc-mobile__panel a.is-active,
.blog-toc-mobile__panel a:hover {
  background: #f1ede5;
  color: var(--blog-accent);
}

@media (max-width: 999px) {
  .blog-toc-mobile {
    display: block;
  }
}

/* ---------- Article layout: content + sticky sidebar TOC ---------- */

.blog-article-layout {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

@media (min-width: 1000px) {
  .blog-article-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .blog-toc-sidebar {
    order: 1;
  }

  .blog-article-body {
    order: 2;
  }
}

.blog-article-body {
  max-width: 680px;
}

.blog-article-section + .blog-article-section {
  margin-top: 2.25rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--blog-rule);
}

.blog-article-section h2 {
  margin: 0 0 1rem;
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: clamp(1.3rem, 2.1vw, 1.65rem);
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--blog-ink) !important;
  scroll-margin-top: 6rem;
}

.blog-article-section p {
  margin: 0 0 1.05rem;
  color: var(--blog-muted);
  font-size: 1.02rem;
  line-height: 1.75;
}

.blog-article-section ul {
  margin: 0 0 1.05rem;
  padding-left: 1.15rem;
  color: var(--blog-muted);
  line-height: 1.75;
}

.blog-article-section li::marker {
  color: var(--blog-accent);
}

.blog-article-section__media-figure {
  margin: 1.75rem 0;
}

.blog-article-section__media {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid var(--blog-rule);
  background: #efece5;
}

.blog-toc-sidebar {
  display: none;
}

@media (min-width: 1000px) {
  .blog-toc-sidebar {
    display: block;
    position: sticky;
    top: 5.5rem;
  }
}

.blog-toc-sidebar__inner {
  padding: 1.1rem;
  border-radius: 0.6rem;
  border: 1px solid var(--blog-rule);
  background: #ffffff;
  display: grid;
  gap: 0.85rem;
}

.blog-toc-sidebar__inner nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.blog-toc-sidebar__inner nav a {
  padding: 0.45rem 0.55rem;
  border-radius: 0.4rem;
  border-left: 2px solid transparent;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--blog-muted);
  text-decoration: none;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.blog-toc-sidebar__inner nav a:hover {
  color: var(--blog-ink);
}

.blog-toc-sidebar__inner nav a.is-active {
  color: var(--blog-accent);
  border-left-color: var(--blog-accent);
  background: rgba(179, 33, 26, 0.06);
}

.blog-toc-sidebar__cta {
  padding-top: 0.85rem;
  border-top: 1px solid var(--blog-rule);
  display: grid;
  gap: 0.6rem;
}

.blog-toc-sidebar__cta p {
  margin: 0;
  font-family: var(--blog-serif) !important;
  font-style: italic;
  font-size: 0.86rem;
  color: var(--blog-muted);
  line-height: 1.5;
}

/* ---------- Prev / next navigation ---------- */

.blog-prevnext {
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--blog-rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.blog-prevnext__link {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--blog-rule);
  text-decoration: none;
  transition: border-color 150ms ease, background 150ms ease;
}

.blog-prevnext__link:hover {
  border-color: rgba(179, 33, 26, 0.4);
  background: rgba(179, 33, 26, 0.04);
}

.blog-prevnext__link--next {
  text-align: right;
}

.blog-prevnext__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blog-accent);
}

.blog-prevnext__title {
  font-family: var(--blog-serif) !important;
  font-size: 0.98rem;
  color: var(--blog-ink);
  line-height: 1.35;
}

@media (max-width: 640px) {
  .blog-prevnext {
    grid-template-columns: 1fr;
  }

  .blog-prevnext__link--next {
    text-align: left;
  }
}

/* ---------- Related articles: compact editorial list, not tiles ---------- */

.blog-related {
  margin-top: 3rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--blog-rule);
}

.blog-related__title {
  margin: 0;
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: var(--blog-ink) !important;
}

.blog-related__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 1.25rem;
}

.blog-related__card {
  display: flex;
  align-items: flex-start;
  gap: 1.1rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--blog-rule);
  text-decoration: none;
}

.blog-related__media {
  flex: 0 0 120px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 0.4rem;
  background: #efece5;
}

.blog-related__media img {
  transition: transform 320ms ease;
}

.blog-related__card:hover .blog-related__media img {
  transform: scale(1.04);
}

.blog-related__body {
  display: grid;
  gap: 0.45rem;
  padding: 0;
  min-width: 0;
}

.blog-related__card h3,
.blog-related__card p {
  margin: 0;
}

.blog-related__card h3 {
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--blog-ink) !important;
}

.blog-related__card p {
  display: none;
}

@media (min-width: 560px) {
  .blog-related__card p {
    display: block;
    color: var(--blog-muted);
    font-size: 0.9rem;
    line-height: 1.55;
  }
}

@media (max-width: 640px) {
  .blog-article-shell {
    padding: 1.25rem 1.1rem 3.5rem;
  }

  .blog-article-media {
    aspect-ratio: 4 / 3;
    max-width: 100%;
  }
}

/* ============================================================= */
/* Blog index page                                                */
/* ============================================================= */

.blog-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.blog-hero {
  display: grid;
  gap: 1rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--blog-rule);
}

.blog-title {
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: clamp(2rem, 3.6vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--blog-ink) !important;
  max-width: 16ch;
}

.blog-copy {
  max-width: 40rem;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--blog-muted);
}

/* Category filter pills */

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.blog-filter-pill {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--blog-rule);
  background: transparent;
  font-family: var(--blog-sans);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--blog-muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.blog-filter-pill:hover {
  border-color: var(--blog-accent);
  color: var(--blog-ink);
}

.blog-filter-pill.is-active {
  background: var(--blog-ink);
  border-color: var(--blog-ink);
  color: #ffffff;
}

/* Featured post: asymmetric, text-led */

.blog-featured {
  margin-top: 2.25rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  padding-bottom: 2.25rem;
  border-bottom: 1px solid var(--blog-rule);
  text-decoration: none;
  color: inherit;
}

@media (min-width: 760px) {
  .blog-featured {
    grid-template-columns: 0.9fr 1.1fr;
    align-items: center;
    gap: 2rem;
  }
}

.blog-featured__media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 0.5rem;
  background: #efece5;
}

.blog-featured__media img {
  transition: transform 400ms ease;
}

.blog-featured:hover .blog-featured__media img {
  transform: scale(1.03);
}

.blog-featured__body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.blog-featured__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--blog-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blog-accent);
}

.blog-featured__title {
  margin: 0;
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: clamp(1.55rem, 2.8vw, 2.15rem);
  line-height: 1.12;
  letter-spacing: -0.005em;
  color: var(--blog-ink) !important;
}

.blog-featured__excerpt {
  margin: 0;
  color: var(--blog-muted);
  line-height: 1.7;
  max-width: 38rem;
}

/* Article list: horizontal editorial rows, not a tile grid */

.blog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 0.5rem;
}

.blog-card {
  border-top: 1px solid var(--blog-rule);
}

.blog-card:last-child {
  border-bottom: 1px solid var(--blog-rule);
}

.blog-card__row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.6rem 0;
  text-decoration: none;
  color: inherit;
}

@media (min-width: 640px) {
  .blog-card__row {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.6rem;
  }
}

.blog-card__media {
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 0.5rem;
  background: #efece5;
}

@media (min-width: 640px) {
  .blog-card__media {
    flex: 0 0 220px;
    aspect-ratio: 4 / 3;
  }
}

.blog-card__media img {
  transition: transform 320ms ease;
}

.blog-card:hover .blog-card__media img {
  transform: scale(1.035);
}

.blog-card__content {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 0.55rem;
  align-content: center;
}

.blog-card h2 {
  margin: 0;
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--blog-ink) !important;
}

.blog-card p {
  margin: 0;
  color: var(--blog-muted);
  line-height: 1.65;
  max-width: 52ch;
}

.blog-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--blog-accent);
}

.blog-card:hover .blog-card__cta {
  text-decoration: underline;
}

.blog-empty-state {
  margin-top: 2rem;
  padding: 2.5rem;
  text-align: center;
  border-radius: 0.6rem;
  border: 1px dashed var(--blog-rule);
  color: var(--blog-muted);
  font-size: 0.95rem;
}

.blog-support {
  margin-top: 3rem;
  display: grid;
  gap: 1rem;
  padding: 2rem;
  border-radius: 0.6rem;
  background: var(--blog-ink);
  color: #ffffff;
}

.blog-support__title {
  margin: 0;
  font-family: var(--blog-serif) !important;
  font-weight: 500 !important;
  font-size: clamp(1.5rem, 2.8vw, 2.05rem);
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: #ffffff !important;
}

.blog-support p {
  margin: 0;
  max-width: 42rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.7;
}

.blog-support__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.blog-support__actions .btn-secondary {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff !important;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.blog-support__actions .btn-secondary:hover,
.blog-support__actions .btn-secondary:focus-visible {
  background: var(--blog-accent) !important;
  border-color: var(--blog-accent) !important;
  color: #ffffff !important;
}

@media (max-width: 640px) {
  .blog-shell {
    padding: 1.5rem 1.1rem 3.5rem;
  }

  .blog-title {
    max-width: none;
  }

  .blog-support {
    padding: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blog-card__media img,
  .blog-related__media img,
  .blog-featured__media img,
  .blog-sticky-bar,
  .blog-toc-mobile__toggle svg,
  .blog-progress {
    transition: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  .blog-detail-page,
  .blog-index-page {
    --blog-ink: #f2ede4;
    --blog-muted: #c3bcb0;
    --blog-faint: #8f887c;
    --blog-rule: rgba(242, 237, 228, 0.14);
    --blog-paper: #14120f;
    --blog-accent: #ff6a5e;
  }

  .blog-sticky-bar {
    background: rgba(20, 18, 15, 0.9);
  }

  .blog-toc-mobile__toggle,
  .blog-toc-mobile__panel,
  .blog-toc-sidebar__inner {
    background: #1c1a16;
  }

  .blog-media-frame,
  .blog-card__media,
  .blog-related__media,
  .blog-featured__media {
    background: #26221d;
  }

  .blog-support {
    background: #26221d;
  }
}
