/*
 * Editor-written content: blog posts (single.php) and pages made in wp-admin (page.php).
 *
 * The Astro CSS bundle only contains the Tailwind utilities the Astro source used, and its
 * preflight resets headings, lists and links to plain text. Content typed in the block editor
 * (<p>, <h2 class="wp-block-heading">, <ul class="wp-block-list">, links, quotes, images) carries
 * none of those utilities, so this file gives it the look of the sample posts: paragraphs as
 * "mt-5 text-lg text-muted leading-relaxed", headings in the display face, lists with markers,
 * links in the brand color. Only the design tokens from src/styles/tokens.css are used.
 *
 * Loaded after the bundle, on posts and editor pages only (inc/head.php).
 *
 * Scope and specificity. The post body is the <article> in single.php; page.php wraps content in
 * .korel-prose. Every selector starts with the scope in :where(), which counts for nothing, and
 * lists its elements with :is(), which counts as one element. So a rule here weighs as much as
 * its element selectors (0,0,1 or 0,0,2): enough to beat the bundle's preflight resets (0,0,1,
 * earlier in the cascade), never enough to beat a utility class (0,1,0). The sample posts'
 * paragraphs are classed with those utilities and every property set on p below is one the
 * utilities also set, so their rendering does not change. Links are only styled inside text
 * (p, li, headings, quotes, captions, tables), which leaves the classed "Back to blog" link alone.
 */

/* ---- text ---------------------------------------------------------------------------- */

:where(.korel-prose, main article.max-w-3xl) p {
  margin-top: 1.25rem;
  font-size: 1.125rem;
  line-height: 1.625;
  color: rgb(var(--color-muted));
}

:where(.korel-prose, main article.max-w-3xl) :is(strong, b) {
  font-weight: 600;
  color: rgb(var(--color-text));
}

:where(.korel-prose, main article.max-w-3xl) :is(p, li, h1, h2, h3, h4, h5, h6, blockquote, figcaption, td, th, dd) a {
  color: rgb(var(--color-primary));
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur-fast) var(--ease);
}

:where(.korel-prose, main article.max-w-3xl) :is(p, li, h1, h2, h3, h4, h5, h6, blockquote, figcaption, td, th, dd) a:hover {
  color: rgb(var(--color-primary-hover));
  text-decoration-thickness: 2px;
}

/* ---- headings ------------------------------------------------------------------------ */

:where(.korel-prose, main article.max-w-3xl) :is(h1, h2, h3, h4, h5, h6) {
  font-family: var(--font-display);
  color: rgb(var(--color-text));
  scroll-margin-top: 6rem;
}

:where(.korel-prose, main article.max-w-3xl) :is(h1, h2) {
  margin-top: 2.75rem;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

:where(.korel-prose, main article.max-w-3xl) h3 {
  margin-top: 2.25rem;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

:where(.korel-prose, main article.max-w-3xl) h4 {
  margin-top: 2rem;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
}

:where(.korel-prose, main article.max-w-3xl) :is(h5, h6) {
  margin-top: 1.75rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
}

/* A paragraph or list straight after a heading sits closer to it. */
:where(.korel-prose, main article.max-w-3xl) :is(h1, h2, h3, h4, h5, h6) + :is(p, ul, ol) {
  margin-top: 0.75rem;
}

/* ---- lists --------------------------------------------------------------------------- */

:where(.korel-prose, main article.max-w-3xl) :is(ul, ol) {
  margin-top: 1.25rem;
  padding-left: 1.5rem;
  font-size: 1.125rem;
  line-height: 1.625;
  color: rgb(var(--color-muted));
}

:where(.korel-prose, main article.max-w-3xl) ul { list-style: disc; }
:where(.korel-prose, main article.max-w-3xl) ol { list-style: decimal; }
:where(.korel-prose, main article.max-w-3xl) :is(ul, ol) ul { list-style: circle; }

:where(.korel-prose, main article.max-w-3xl) li {
  margin-top: 0.5rem;
  padding-left: 0.25rem;
}

:where(.korel-prose, main article.max-w-3xl) li::marker {
  color: rgb(var(--color-accent));
}

:where(.korel-prose, main article.max-w-3xl) ol > li::marker {
  font-weight: 600;
}

:where(.korel-prose, main article.max-w-3xl) li :is(ul, ol) {
  margin-top: 0.5rem;
}

/* ---- quotes -------------------------------------------------------------------------- */

:where(.korel-prose, main article.max-w-3xl) blockquote {
  margin: 2rem 0 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid rgb(var(--color-accent));
  color: rgb(var(--color-text));
}

:where(.korel-prose, main article.max-w-3xl) blockquote p {
  color: inherit;
  font-style: italic;
}

:where(.korel-prose, main article.max-w-3xl) blockquote > p:first-child {
  margin-top: 0;
}

:where(.korel-prose, main article.max-w-3xl) blockquote cite {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  font-style: normal;
  color: rgb(var(--color-muted));
}

/* ---- images, embeds, figures ---------------------------------------------------------- */

:where(.korel-prose, main article.max-w-3xl) figure {
  margin: 2rem 0 0;
}

:where(.korel-prose, main article.max-w-3xl) :is(figure, p) img {
  height: auto;
  max-width: 100%;
  border-radius: var(--radius-lg);
}

:where(.korel-prose, main article.max-w-3xl) figcaption {
  margin-top: 0.625rem;
  font-size: 0.875rem;
  line-height: 1.5;
  text-align: center;
  color: rgb(var(--color-muted));
}

:where(.korel-prose, main article.max-w-3xl) :is(iframe, video) {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-lg);
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-embed.is-type-rich :is(iframe) {
  aspect-ratio: auto;
}

/* Alignment classes from the editor (WordPress's block CSS is not loaded on this site). */
:where(.korel-prose, main article.max-w-3xl) :is(.aligncenter, .has-text-align-center) { text-align: center; }
:where(.korel-prose, main article.max-w-3xl) .has-text-align-right { text-align: right; }
:where(.korel-prose, main article.max-w-3xl) .has-text-align-left { text-align: left; }
:where(.korel-prose, main article.max-w-3xl) :is(.aligncenter) img { margin-inline: auto; }
:where(.korel-prose, main article.max-w-3xl) :is(figure.aligncenter, img.aligncenter) {
  margin-inline: auto;
  width: fit-content;
  max-width: 100%;
}

@media (min-width: 640px) {
  :where(.korel-prose, main article.max-w-3xl) :is(.alignleft) {
    float: left;
    max-width: 50%;
    margin: 0.5rem 1.5rem 1rem 0;
  }
  :where(.korel-prose, main article.max-w-3xl) :is(.alignright) {
    float: right;
    max-width: 50%;
    margin: 0.5rem 0 1rem 1.5rem;
  }
}

/* Floated images end above the "Back to blog" rule (single.php) and inside the page body
   (page.php). Neither rule has any effect when nothing is floated. */
:where(main article.max-w-3xl > div.border-t) {
  clear: both;
}

.korel-prose::after {
  content: "";
  display: table;
  clear: both;
}

/* ---- block editor colours, sizes, columns and galleries --------------------------------
   WordPress's block CSS and global styles are not loaded on this site (inc/cleanup.php), so the
   classes the editor writes for its default palette, font sizes, Columns and Gallery do nothing
   without these. Values are core's defaults, which is what the editor preview shows. A class
   here weighs 0,1,0: it beats the element rules above, as the editor's choice should. */

:where(.korel-prose, main article.max-w-3xl) .has-black-color { color: #000; }
:where(.korel-prose, main article.max-w-3xl) .has-cyan-bluish-gray-color { color: #abb8c3; }
:where(.korel-prose, main article.max-w-3xl) .has-white-color { color: #fff; }
:where(.korel-prose, main article.max-w-3xl) .has-pale-pink-color { color: #f78da7; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-red-color { color: #cf2e2e; }
:where(.korel-prose, main article.max-w-3xl) .has-luminous-vivid-orange-color { color: #ff6900; }
:where(.korel-prose, main article.max-w-3xl) .has-luminous-vivid-amber-color { color: #fcb900; }
:where(.korel-prose, main article.max-w-3xl) .has-light-green-cyan-color { color: #7bdcb5; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-green-cyan-color { color: #00d084; }
:where(.korel-prose, main article.max-w-3xl) .has-pale-cyan-blue-color { color: #8ed1fc; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-cyan-blue-color { color: #0693e3; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-purple-color { color: #9b51e0; }

:where(.korel-prose, main article.max-w-3xl) .has-black-background-color { background-color: #000; }
:where(.korel-prose, main article.max-w-3xl) .has-cyan-bluish-gray-background-color { background-color: #abb8c3; }
:where(.korel-prose, main article.max-w-3xl) .has-white-background-color { background-color: #fff; }
:where(.korel-prose, main article.max-w-3xl) .has-pale-pink-background-color { background-color: #f78da7; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-red-background-color { background-color: #cf2e2e; }
:where(.korel-prose, main article.max-w-3xl) .has-luminous-vivid-orange-background-color { background-color: #ff6900; }
:where(.korel-prose, main article.max-w-3xl) .has-luminous-vivid-amber-background-color { background-color: #fcb900; }
:where(.korel-prose, main article.max-w-3xl) .has-light-green-cyan-background-color { background-color: #7bdcb5; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-green-cyan-background-color { background-color: #00d084; }
:where(.korel-prose, main article.max-w-3xl) .has-pale-cyan-blue-background-color { background-color: #8ed1fc; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-cyan-blue-background-color { background-color: #0693e3; }
:where(.korel-prose, main article.max-w-3xl) .has-vivid-purple-background-color { background-color: #9b51e0; }

/* Coloured text keeps its colour in links and bold words inside it. */
:where(.korel-prose, main article.max-w-3xl) .has-text-color :is(a, strong, b) { color: inherit; }

:where(.korel-prose, main article.max-w-3xl) :is(p, h1, h2, h3, h4, h5, h6, .wp-block-group).has-background {
  padding: 1.25em 2.375em;
  border-radius: var(--radius-md);
}

:where(.korel-prose, main article.max-w-3xl) .has-small-font-size { font-size: 0.8125rem; }
:where(.korel-prose, main article.max-w-3xl) .has-medium-font-size { font-size: 1.25rem; }
:where(.korel-prose, main article.max-w-3xl) .has-large-font-size { font-size: 2.25rem; line-height: 1.25; }
:where(.korel-prose, main article.max-w-3xl) .has-x-large-font-size { font-size: 2.625rem; line-height: 1.2; }

/* Row and Stack groups (the layout styles WordPress would print are not loaded either). */
:where(.korel-prose, main article.max-w-3xl) .is-layout-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
}

:where(.korel-prose, main article.max-w-3xl) .is-layout-flex > * { margin: 0; }

:where(.korel-prose, main article.max-w-3xl) .wp-block-columns {
  display: flex;
  flex-wrap: wrap;
  align-items: normal;
  gap: 2rem;
  margin-top: 2rem;
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-columns.are-vertically-aligned-center { align-items: center; }

:where(.korel-prose, main article.max-w-3xl) .wp-block-column {
  flex: 1 1 100%;
  min-width: 0;
  overflow-wrap: break-word;
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-column > :first-child { margin-top: 0; }

@media (min-width: 782px) {
  :where(.korel-prose, main article.max-w-3xl) .wp-block-columns:not(.is-not-stacked-on-mobile) { flex-wrap: nowrap; }
  :where(.korel-prose, main article.max-w-3xl) .wp-block-column { flex-basis: 0; flex-grow: 1; }
  /* A column given a width in the editor carries it as an inline flex-basis. */
  :where(.korel-prose, main article.max-w-3xl) .wp-block-column[style*="flex-basis"] { flex-grow: 0; }
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-columns.is-not-stacked-on-mobile { flex-wrap: nowrap; }
:where(.korel-prose, main article.max-w-3xl) .wp-block-columns.is-not-stacked-on-mobile > .wp-block-column { flex-basis: 0; flex-grow: 1; }

:where(.korel-prose, main article.max-w-3xl) .wp-block-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-gallery > figure {
  flex: 1 1 calc(50% - 0.5rem);
  max-width: 100%;
  margin: 0;
}

@media (min-width: 600px) {
  :where(.korel-prose, main article.max-w-3xl) .wp-block-gallery:is(.columns-3, .columns-default) > figure { flex-basis: calc(33.333% - 0.667rem); }
  :where(.korel-prose, main article.max-w-3xl) .wp-block-gallery.columns-default > figure:first-child:nth-last-child(2),
  :where(.korel-prose, main article.max-w-3xl) .wp-block-gallery.columns-default > figure:first-child:nth-last-child(2) ~ figure { flex-basis: calc(50% - 0.5rem); }
  :where(.korel-prose, main article.max-w-3xl) .wp-block-gallery.columns-4 > figure { flex-basis: calc(25% - 0.75rem); }
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-gallery.is-cropped > figure img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-gallery > figcaption { flex-basis: 100%; margin-top: 0; }

/* ---- rules, tables, code ------------------------------------------------------------- */

:where(.korel-prose, main article.max-w-3xl) hr {
  clear: both;
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid rgb(var(--color-border));
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-table {
  overflow-x: auto;
}

:where(.korel-prose, main article.max-w-3xl) table {
  width: 100%;
  margin-top: 2rem;
  font-size: 1rem;
  line-height: 1.5;
  color: rgb(var(--color-muted));
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-table table {
  margin-top: 0;
}

:where(.korel-prose, main article.max-w-3xl) :is(th, td) {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid rgb(var(--color-border));
  text-align: left;
  vertical-align: top;
}

:where(.korel-prose, main article.max-w-3xl) th {
  font-weight: 600;
  color: rgb(var(--color-text));
}

:where(.korel-prose, main article.max-w-3xl) code {
  padding: 0.1em 0.35em;
  font-size: 0.9em;
  border-radius: var(--radius-sm);
  background: rgb(var(--color-surface-2));
  color: rgb(var(--color-text));
}

:where(.korel-prose, main article.max-w-3xl) pre {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  border-radius: var(--radius-md);
  background: rgb(var(--color-surface-2));
  font-size: 0.9375rem;
  line-height: 1.6;
}

:where(.korel-prose, main article.max-w-3xl) pre code {
  padding: 0;
  background: none;
}

/* ---- buttons and the password form ---------------------------------------------------- */

:where(.korel-prose, main article.max-w-3xl) .wp-block-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-button__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius-md);
  background: rgb(var(--color-primary));
  color: rgb(var(--color-primary-fg));
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: background-color var(--dur-fast) var(--ease);
}

:where(.korel-prose, main article.max-w-3xl) .wp-block-button__link:hover {
  background: rgb(var(--color-primary-hover));
}

:where(.korel-prose, main article.max-w-3xl) .post-password-form :is(input[type="password"]) {
  margin-top: 0.5rem;
  display: block;
  width: 100%;
  max-width: 20rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid rgb(var(--color-border));
  border-radius: var(--radius-md);
  background: rgb(var(--color-surface));
  color: rgb(var(--color-text));
}

:where(.korel-prose, main article.max-w-3xl) .post-password-form :is(input[type="submit"]) {
  margin-top: 0.75rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  background: rgb(var(--color-primary));
  color: rgb(var(--color-primary-fg));
  font-weight: 600;
  cursor: pointer;
}
