/* ============================================================================
   CONTENT — pages, blog and FAQ (Phase 14)
   ============================================================================
   Nothing here introduces a colour, a font, a spacing step or a breakpoint.
   Every value is a token from the design system, because a blog that invents
   its own type scale is a second design system with one page in it.

   The reading measure is the one decision this file makes that the rest of the
   site does not need: an article read straight through wants a narrower column
   than a grid of product cards, so `.content-page` is capped at 68 characters
   rather than at the container width.
   ============================================================================ */

.content-page {
  /* About sixty-eight characters at the body size: long enough not to feel
     clipped, short enough that the eye finds the next line without hunting. */
  max-width: 68ch;
  margin-inline: auto;
}

.content-page--wide {
  max-width: none;
}

.content-page__head {
  margin-bottom: var(--space-6);
}

.content-page__head--listing {
  margin-bottom: var(--space-7);
}

.content-page__eyebrow {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.content-page__title {
  font-size: var(--text-4xl);
  line-height: 1.15;
  margin: 0 0 var(--space-3);
}

.content-page__lede {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
}

.content-page__meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.content-page__more {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: var(--border-width) solid var(--color-border);
  color: var(--color-text-muted);
}

.content-crumbs {
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.content-empty {
  padding: var(--space-6);
  border: var(--border-width) dashed var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------
   The body of an article.
   ---------------------------------------------------------------------------
   These rules style the sanitised markup an editor wrote. Only the elements
   HtmlSanitizer allows are worth styling; anything else never reaches the page.
   --------------------------------------------------------------------------- */

.content-body {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
}

.content-body > :first-child { margin-top: 0; }
.content-body > :last-child  { margin-bottom: 0; }

.content-body p,
.content-body ul,
.content-body ol,
.content-body dl,
.content-body table,
.content-body figure,
.content-body blockquote,
.content-body pre {
  margin: 0 0 var(--space-5);
}

.content-body h2,
.content-body h3,
.content-body h4,
.content-body h5,
.content-body h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
  /* More space above than below, so a heading belongs to what follows it
     rather than floating between two blocks. */
  margin: var(--space-7) 0 var(--space-3);
}

.content-body h2 { font-size: var(--text-2xl); }
.content-body h3 { font-size: var(--text-xl); }
.content-body h4 { font-size: var(--text-lg); }

.content-body ul,
.content-body ol {
  padding-inline-start: var(--space-6);
}

.content-body li {
  margin-bottom: var(--space-2);
}

.content-body a {
  color: var(--color-link);
  text-underline-offset: 0.15em;
}

.content-body a:hover {
  color: var(--color-link-hover);
}

.content-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}

.content-body figure {
  margin-inline: 0;
}

.content-body figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.content-body blockquote {
  padding: var(--space-2) var(--space-5);
  border-inline-start: 4px solid var(--color-accent);
  color: var(--color-text-muted);
  font-size: var(--text-lg);
}

.content-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
}

.content-body pre {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-sunken);
  /* A long line of code scrolls inside its own box. The page never does. */
  overflow-x: auto;
}

.content-body pre code {
  padding: 0;
  background: none;
}

/* A wide table scrolls inside its own wrapper rather than pushing the page
   sideways at 375px. `display:block` on the table is what makes the overflow
   apply to it, and the semantics are unchanged for a screen reader. */
.content-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.content-body th,
.content-body td {
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid var(--color-border);
  text-align: start;
}

.content-body th {
  background: var(--color-surface-sunken);
  font-weight: 600;
}

.content-body hr {
  margin: var(--space-7) 0;
  border: 0;
  border-top: var(--border-width) solid var(--color-border);
}

/* ---------------------------------------------------------------------------
   Contact details, beside a page rather than inside its body.
   --------------------------------------------------------------------------- */

.content-contact {
  margin-top: var(--space-7);
  padding: var(--space-5);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.content-contact__title {
  font-size: var(--text-xl);
  margin: 0 0 var(--space-3);
}

.content-contact__demo {
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.content-contact__body {
  line-height: 1.7;
}

/* ---------------------------------------------------------------------------
   Blog listing
   --------------------------------------------------------------------------- */

.post-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .post-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.post-card__category {
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.post-card__title {
  font-size: var(--text-xl);
  line-height: 1.3;
  margin: 0;
}

.post-card__title a {
  color: inherit;
  text-decoration: none;
}

.post-card__title a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.post-card__meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.post-card__excerpt {
  color: var(--color-text-muted);
}

.post-card__more {
  /* Pins the link to the bottom, so cards of different lengths in one row
     still line their actions up. */
  margin-top: auto;
  padding-top: var(--space-3);
}

.post-card__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: 600;
  text-decoration: none;
}

.post-card__link:hover {
  text-decoration: underline;
}

.content-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-7);
}

.content-pagination__status {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------
   Between posts
   --------------------------------------------------------------------------- */

.post-nav {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: var(--border-width) solid var(--color-border);
}

@media (min-width: 768px) {
  .post-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* With only a "next", it sits on the right where it belongs. */
  .post-nav__link--next:only-child { grid-column: 2; }
  .post-nav__link--next { text-align: end; }
}

.post-nav__link {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  text-decoration: none;
  color: inherit;
}

.post-nav__link:hover {
  border-color: var(--color-primary-border);
  background: var(--color-primary-subtle);
}

.post-nav__label {
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.post-nav__title {
  font-family: var(--font-heading);
  font-weight: 600;
}

.post-related {
  margin-top: var(--space-8);
}

.post-related__title {
  font-size: var(--text-2xl);
  margin: 0 0 var(--space-5);
}

/* The related rail lives inside a reading-width article, so it stays one
   column until there is room for more. */
.post-grid--related {
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .post-grid--related { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------------------
   FAQ
   ---------------------------------------------------------------------------
   Native <details>. Keyboard operable and announced correctly without a line
   of JavaScript — which matters twice here, because the site's CSP allows no
   inline handler and an accordion that needs one would silently not open.
   --------------------------------------------------------------------------- */

.faq-group {
  margin-bottom: var(--space-7);
}

.faq-group__title {
  font-size: var(--text-xl);
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-accent);
}

.faq-item {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  margin-bottom: var(--space-3);
}

.faq-item__question {
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* Safari draws its own triangle through a pseudo-element of its own. */
.faq-item__question::-webkit-details-marker { display: none; }

.faq-item__question::after {
  content: "+";
  flex: none;
  font-size: var(--text-xl);
  line-height: 1;
  color: var(--color-primary);
}

.faq-item[open] .faq-item__question::after {
  content: "\2212";   /* a real minus sign, not a hyphen */
}

.faq-item__question:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
  border-radius: var(--radius-lg);
}

.faq-item__answer {
  padding: 0 var(--space-5) var(--space-5);
}
