/*
 * Long-form content: articles, blogs and pages on the site (.entry-content) and the same rules
 * inside the block editor (.editor-styles-wrapper), so what admins write looks like the result.
 *
 * Type roles
 *   Inter        reading text
 *   Roboto Slab  headings, quotes, titles
 *   Roboto Mono  small accents: captions, labels, meta, buttons, footnotes, code
 *
 * Colours, fonts and sizes come from theme.json (--wp--preset--*), which the editor also uses.
 */

:is(.entry-content, .editor-styles-wrapper) {
    --content-ink: var(--wp--preset--color--black);
    --content-text: var(--wp--preset--color--text);
    --content-muted: var(--wp--preset--color--muted);
    --content-line: var(--wp--preset--color--line);
    --content-cream: var(--wp--preset--color--cream);
    --content-sand: var(--wp--preset--color--sand);
    --content-mono: var(--wp--preset--font-family--mono);
    --content-serif: var(--wp--preset--font-family--heading);
    --content-sans: var(--wp--preset--font-family--body);
    font-family: var(--content-sans);
    font-size: var(--wp--preset--font-size--normal);
    line-height: 1.7;
    color: var(--content-text);
}

.editor-styles-wrapper {
    background: #ffffff;
}

/* Vertical rhythm */
:is(.entry-content, .editor-styles-wrapper) :where(p, ul, ol, dl, figure, table, pre, blockquote, details, hr, .wp-block-group, .wp-block-columns, .wp-block-buttons, .wp-block-file, .wp-block-embed, .wp-block-footnotes) {
    margin-top: 0;
    margin-bottom: 1.5em;
}

:is(.entry-content, .editor-styles-wrapper) p {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

/* Headings */
:is(.entry-content, .editor-styles-wrapper) :is(h1, h2, h3, h4, h5) {
    font-family: var(--content-serif);
    font-weight: 400;
    color: var(--content-ink);
    margin-top: 2em;
    margin-bottom: .6em;
}

:is(.entry-content, .editor-styles-wrapper) h1 { font-size: clamp(34px, 2.1vw, 2.1vw); line-height: 1.15; }
:is(.entry-content, .editor-styles-wrapper) h2 { font-size: clamp(27px, 1.6vw, 1.6vw); line-height: 1.2; }
:is(.entry-content, .editor-styles-wrapper) h3 { font-size: clamp(22px, 1.3vw, 1.3vw); line-height: 1.25; }
:is(.entry-content, .editor-styles-wrapper) h4 { font-size: clamp(19px, 1.05vw, 1.05vw); line-height: 1.35; }
:is(.entry-content, .editor-styles-wrapper) h5 { font-size: var(--wp--preset--font-size--normal); line-height: 1.5; }

/* h6 is the small mono label (e.g. above a section) */
:is(.entry-content, .editor-styles-wrapper) h6 {
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    font-weight: 400;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--content-muted);
    margin-top: 2em;
    margin-bottom: .8em;
}

:is(.entry-content, .editor-styles-wrapper) > :first-child,
:is(.entry-content, .editor-styles-wrapper) .is-root-container > :first-child {
    margin-top: 0;
}

/* Links */
:is(.entry-content, .editor-styles-wrapper) a:where(:not(.wp-block-button__link, .wp-block-file__button)) {
    color: var(--content-ink);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: .2em;
}

:is(.entry-content, .editor-styles-wrapper) a:where(:not(.wp-block-button__link, .wp-block-file__button)):hover {
    text-decoration-thickness: 2px;
}

:is(.entry-content, .editor-styles-wrapper) strong {
    font-weight: 600;
    color: var(--content-ink);
}

/* Lists */
:is(.entry-content, .editor-styles-wrapper) :is(ul, ol) {
    padding-left: 1.4em;
}

:is(.entry-content, .editor-styles-wrapper) li {
    margin-bottom: .4em;
    font-size: inherit;
}

:is(.entry-content, .editor-styles-wrapper) li::marker {
    color: var(--content-muted);
}

:is(.entry-content, .editor-styles-wrapper) ol li::marker {
    font-family: var(--content-mono);
    font-size: .85em;
}

/* Quote */
:is(.entry-content, .editor-styles-wrapper) .wp-block-quote {
    margin-left: 0;
    margin-right: 0;
    padding: .2em 0 .2em 1.2em;
    border-left: 2px solid var(--content-ink);
    font-family: var(--content-serif);
    font-weight: 300;
    font-size: var(--wp--preset--font-size--medium);
    line-height: 1.55;
    color: var(--content-ink);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-quote p:last-of-type {
    margin-bottom: 0;
}

:is(.entry-content, .editor-styles-wrapper) :is(.wp-block-quote, .wp-block-pullquote) cite {
    display: block;
    margin-top: .9em;
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    font-style: normal;
    color: var(--content-muted);
}

/* Pullquote */
:is(.entry-content, .editor-styles-wrapper) .wp-block-pullquote {
    padding: 1.6em 0;
    border-top: 1px solid var(--content-ink);
    border-bottom: 1px solid var(--content-ink);
    text-align: center;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-pullquote blockquote {
    margin: 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-pullquote p {
    font-family: var(--content-serif);
    font-weight: 300;
    font-size: var(--wp--preset--font-size--large);
    line-height: 1.35;
    color: var(--content-ink);
}

/* Images, galleries, video and their captions */
:is(.entry-content, .editor-styles-wrapper) :is(img, video) {
    max-width: 100%;
    height: auto;
}

:is(.entry-content, .editor-styles-wrapper) :is(figcaption, .wp-element-caption) {
    margin-top: .7em;
    margin-bottom: 0;
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    line-height: 1.5;
    color: var(--content-muted);
    text-align: left;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-gallery figcaption.wp-element-caption {
    color: #ffffff;
}

/* Tables */
:is(.entry-content, .editor-styles-wrapper) .wp-block-table {
    overflow-x: auto;
}

:is(.entry-content, .editor-styles-wrapper) table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95em;
    line-height: 1.5;
}

:is(.entry-content, .editor-styles-wrapper) :is(th, td) {
    padding: .65em .8em .65em 0;
    border: none;
    border-bottom: 1px solid var(--content-line);
    text-align: left;
    vertical-align: top;
}

:is(.entry-content, .editor-styles-wrapper) :is(th, thead td) {
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    font-weight: 500;
    color: var(--content-ink);
    border-bottom-color: var(--content-ink);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
    background: var(--content-cream);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-table.is-style-stripes {
    border-bottom: none;
}

/* Code */
:is(.entry-content, .editor-styles-wrapper) code {
    font-family: var(--content-mono);
    font-size: .88em;
    padding: .1em .35em;
    border-radius: 4px;
    background: var(--content-cream);
}

:is(.entry-content, .editor-styles-wrapper) :is(pre, .wp-block-code, .wp-block-preformatted) {
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    line-height: 1.6;
    padding: 1em 1.2em;
    border: 1px solid var(--content-sand);
    border-radius: 8px;
    background: var(--content-cream);
    color: var(--content-ink);
    overflow-x: auto;
    white-space: pre-wrap;
}

:is(.entry-content, .editor-styles-wrapper) pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

/* Separator */
:is(.entry-content, .editor-styles-wrapper) hr,
:is(.entry-content, .editor-styles-wrapper) .wp-block-separator {
    width: 100%;
    max-width: 100%;
    height: 0;
    margin: 2.5em auto;
    border: none;
    border-top: 1px solid var(--content-line);
    background: none;
    opacity: 1;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-separator.is-style-dots {
    height: auto;
    overflow: visible;
    line-height: 1;
    border-top: none;
    text-align: center;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-separator.is-style-dots::before {
    content: "· · ·";
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--medium);
    letter-spacing: .4em;
    color: var(--content-muted);
}

/* Buttons and file downloads: the site's black pill */
:is(.entry-content, .editor-styles-wrapper) .wp-block-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .6em;
}

:is(.entry-content, .editor-styles-wrapper) :is(.wp-block-button__link, .wp-block-file__button) {
    display: inline-block;
    padding: .75em 1.4em;
    border: 1px solid var(--content-ink);
    border-radius: 999px;
    background: var(--content-ink);
    color: #ffffff;
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    line-height: 1.2;
    text-decoration: none;
    transition: background-color .2s, color .2s;
}

:is(.entry-content, .editor-styles-wrapper) :is(.wp-block-button__link, .wp-block-file__button):hover {
    background: #000000;
    color: #ffffff;
}

:is(.entry-content, .editor-styles-wrapper) .is-style-outline .wp-block-button__link {
    background: transparent;
    color: var(--content-ink);
}

:is(.entry-content, .editor-styles-wrapper) .is-style-outline .wp-block-button__link:hover {
    background: var(--content-ink);
    color: #ffffff;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .8em;
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
}

/* Footnotes (core Footnotes block, handy for legal writing) */
:is(.entry-content, .editor-styles-wrapper) sup.fn a,
:is(.entry-content, .editor-styles-wrapper) sup a[id^="fn-"],
:is(.entry-content, .editor-styles-wrapper) .fn {
    font-family: var(--content-mono);
    font-size: .75em;
    text-decoration: none;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-footnotes {
    margin-top: 3em;
    padding-top: 1.2em;
    padding-left: 1.6em;
    border-top: 1px solid var(--content-line);
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    line-height: 1.6;
    color: var(--content-muted);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-footnotes li {
    margin-bottom: .6em;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-footnotes a {
    color: var(--content-ink);
}

/* Details (expandable text) */
:is(.entry-content, .editor-styles-wrapper) .wp-block-details {
    padding: .9em 0;
    border-top: 1px solid var(--content-line);
    border-bottom: 1px solid var(--content-line);
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-details summary {
    font-family: var(--content-mono);
    font-size: var(--wp--preset--font-size--small);
    color: var(--content-ink);
    cursor: pointer;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-details[open] summary {
    margin-bottom: .8em;
}

/* Blocks with a background colour get room to breathe */
:is(.entry-content, .editor-styles-wrapper) :is(p, .wp-block-group, .wp-block-column).has-background {
    padding: 1.2em 1.4em;
    border-radius: 8px;
}

:is(.entry-content, .editor-styles-wrapper) :is(.wp-block-group, .wp-block-column, .wp-block-details) > :last-child {
    margin-bottom: 0;
}

:is(.entry-content, .editor-styles-wrapper) .wp-block-columns {
    gap: 2em;
}

/* Small text preset in mono reads as a note */
:is(.entry-content, .editor-styles-wrapper) .has-mono-font-family {
    letter-spacing: 0;
}

/* Wide and full-width blocks break out of the reading column on the site */
.entry-content .alignwide {
    width: min(var(--wp--style--global--wide-size), calc(100vw - 32px));
    max-width: none;
    margin-left: 50%;
    transform: translateX(-50%);
}

.entry-content .alignfull {
    width: 100vw;
    max-width: none;
    margin-left: 50%;
    transform: translateX(-50%);
}

.entry-content .alignfull img,
.entry-content .alignwide img {
    width: 100%;
}

.entry-content .alignleft {
    float: left;
    max-width: 50%;
    margin: .3em 1.5em 1em 0;
}

.entry-content .alignright {
    float: right;
    max-width: 50%;
    margin: .3em 0 1em 1.5em;
}

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

/* Editor only: the post title looks like the page title */
.editor-styles-wrapper .editor-post-title,
.editor-styles-wrapper .editor-post-title__input {
    font-family: var(--content-serif);
    font-weight: 400;
    font-size: clamp(34px, 2.4vw, 2.4vw);
    line-height: 1.15;
    color: var(--content-ink);
}
