/*
 * Kingside Digital — blog post styles
 * https://dashboard.kingside.digital/blog-content.css
 *
 * The single source of truth for how a post written in the dashboard editor
 * renders. The dashboard imports this file directly, so what a writer sees is
 * what the website shows. Client sites link to it instead of copying it:
 *
 *   <link rel="stylesheet" href="https://dashboard.kingside.digital/blog-content.css">
 *   <div class="blog-prose">{{ post.content_html }}</div>
 *
 * Everything is scoped to `.blog-prose`, so it can't leak into the rest of the
 * site. Type sizes are in `em` and colours come from the variables below, so a
 * site can match its own brand by overriding just those:
 *
 *   .blog-prose { --blog-accent: #b8860b; --blog-heading: #111; }
 *
 * Fonts are deliberately not set — a post inherits the website's own typeface.
 */
.blog-prose {
  --blog-text: #19233a;
  --blog-heading: #0d1426;
  --blog-quote: #475069;
  --blog-accent: #2563eb;
  --blog-radius: 0.625rem;
  /* Width of a photo that text wraps around, when no size was chosen. */
  --blog-float-width: 45%;
  /* Gap between a wrapped photo and the text beside it. */
  --blog-float-gap: 1.5rem;

  color: var(--blog-text);
  line-height: 1.7;
  /* A pasted URL shouldn't be able to push the column wider than its container. */
  overflow-wrap: anywhere;
}
.blog-prose > * + * {
  margin-top: 0.75em;
}
.blog-prose h2 {
  margin-top: 1.25em;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--blog-heading);
}
.blog-prose h3 {
  margin-top: 1.1em;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--blog-heading);
}
.blog-prose ul,
.blog-prose ol {
  padding-left: 1.5rem;
}
.blog-prose ul {
  list-style: disc;
}
.blog-prose ol {
  list-style: decimal;
}
.blog-prose li + li {
  margin-top: 0.25em;
}
.blog-prose blockquote {
  border-left: 3px solid var(--blog-accent);
  padding-left: 1rem;
  font-style: italic;
  color: var(--blog-quote);
}
.blog-prose a {
  color: var(--blog-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/*
 * Photos. A saved photo is a bare `<img>` carrying `data-align`, an optional
 * `data-ratio` and an inline percentage width. Inside the dashboard editor the
 * placement and width sit on a `.blog-image` wrapper instead, which is where the
 * resize handles hang — hence the paired selectors.
 */
.blog-prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--blog-radius);
}
.blog-prose .blog-image {
  position: relative;
  max-width: 100%;
}
.blog-prose .blog-image img {
  width: 100%;
}
/* Placement: on its own line, or floated so text wraps alongside. The widths
   here are only a fallback — a sized photo carries its own inline width, which
   wins over these rules. */
.blog-prose img[data-align="center"],
.blog-prose .blog-image[data-align="center"] {
  margin: 1.25em auto;
}
.blog-prose img[data-align="left"],
.blog-prose .blog-image[data-align="left"] {
  float: left;
  width: var(--blog-float-width);
  margin: 0.35em var(--blog-float-gap) 0.9em 0;
}
.blog-prose img[data-align="right"],
.blog-prose .blog-image[data-align="right"] {
  float: right;
  width: var(--blog-float-width);
  margin: 0.35em 0 0.9em var(--blog-float-gap);
}
/* Optional crop: fix the shape and let the photo fill it rather than squash. */
.blog-prose img[data-ratio="16-9"] {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.blog-prose img[data-ratio="4-3"] {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.blog-prose img[data-ratio="1-1"] {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.blog-prose img[data-ratio="3-4"] {
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
/* A heading always starts a fresh block, and the post never leaks a float. */
.blog-prose h2,
.blog-prose h3 {
  clear: both;
}
.blog-prose::after {
  content: "";
  display: block;
  clear: both;
}

/* On a narrow screen there is no room for text beside a photo, so stop wrapping
   and let every photo take the full width. `!important` is doing real work here:
   the chosen size is an inline style, and going full width on a phone means
   deliberately overriding it. */
@media (max-width: 40rem) {
  .blog-prose img[data-align="left"],
  .blog-prose img[data-align="right"],
  .blog-prose .blog-image[data-align="left"],
  .blog-prose .blog-image[data-align="right"] {
    float: none;
    width: 100% !important;
    margin: 1.25em 0;
  }
}
