/* =========================================================================
   Prose - long-form reading styles
   -------------------------------------------------------------------------
   Scoped entirely to .prose. Nothing here applies to the rest of the site,
   so adding long articles cannot disturb any existing page.

   Used by:
     - blog post bodies
     - the content region beneath each tool

   Palette is unchanged from the rest of the site:
     primary   #3369d3   5.12:1 on white, 4.90:1 on #fafafa
     hover     #2854b8   6.88:1 on white
     text      #343a40  11.51:1 on white, 11.02:1 on #fafafa
     muted     #5a6775   5.78:1 on white, 5.54:1 on #fafafa
                         (darkened from the site's #6c757d, which measures
                          4.49:1 on #fafafa and misses AA)
     callout   #f4f7fd   a tint of the primary, not a new hue
   Every pair above passes WCAG AA for body text.
   ========================================================================= */

.prose {
    /* Caps the line at roughly 65-70 characters, the range that reads
       comfortably. Measured in ch so it tracks the font rather than being a
       guess in pixels. The ch unit is the width of a "0", which in Inter is
       narrower than the average letter, so 70ch measures out at about 69
       real characters - verified in the browser, not assumed. */
    max-width: 70ch;
    margin-inline: auto;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* 18px everywhere, including phones. Most readers here are on a phone and
       are about to be given long articles, so the larger size matters more
       than fitting more characters onto a line. */
    font-size: 1.125rem;
    line-height: 1.7;
    color: #343a40;
    /* Stops a long unbroken string (a URL in an article) from widening the
       page on a narrow screen. */
    overflow-wrap: break-word;
}

@media (min-width: 768px) {
    .prose {
        /* Slightly looser once there is room for a full-width line. */
        line-height: 1.75;
    }
}

/* ----------------------------------------------------------- paragraphs */

.prose p {
    margin: 0 0 1.4em;
}

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

/* ------------------------------------------------------------- headings */
/* More space above a heading than below it, so each heading binds to the
   text it introduces rather than floating between two sections. */

.prose h2,
.prose h3,
.prose h4 {
    color: #343a40;
    line-height: 1.25;
    /* Keeps a heading from being stranded at the foot of a column. */
    break-after: avoid;
}

.prose h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2.5em 0 0.7em;
    letter-spacing: -0.01em;
}

.prose h3 {
    font-size: 1.25rem;
    font-weight: 650;
    margin: 2em 0 0.6em;
}

.prose h4 {
    font-size: 1.0625rem;
    font-weight: 650;
    margin: 1.75em 0 0.5em;
}

@media (min-width: 768px) {
    .prose h2 { font-size: 1.75rem; }
    .prose h3 { font-size: 1.375rem; }
    .prose h4 { font-size: 1.125rem; }
}

/* A heading immediately after the container top should not push down. */
.prose > h2:first-child,
.prose > h3:first-child { margin-top: 0; }

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

.prose ul,
.prose ol {
    margin: 0 0 1.4em;
    padding-left: 1.4em;
}

.prose li {
    margin-bottom: 0.55em;
}

.prose li > ul,
.prose li > ol {
    margin: 0.55em 0 0;
}

.prose li::marker {
    color: #5a6775;
}

/* ---------------------------------------------------------------- links */
/* Underlined, so the link is identifiable without relying on colour. */

.prose a {
    color: #3369d3;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
}

.prose a:hover {
    color: #2854b8;
    text-decoration-thickness: 2px;
}

.prose a:focus-visible {
    outline: 3px solid #3369d3;
    outline-offset: 2px;
    border-radius: 2px;
    text-decoration: none;
}

/* ----------------------------------------------------------- blockquote */

.prose blockquote {
    margin: 1.8em 0;
    padding: 0.2em 0 0.2em 1.1em;
    border-left: 4px solid #3369d3;
    color: #343a40;
}

.prose blockquote p:last-child { margin-bottom: 0; }

.prose blockquote cite {
    display: block;
    margin-top: 0.6em;
    font-size: 0.9375rem;
    font-style: normal;
    color: #5a6775;
}

/* ----------------------------------------------------------------- code */

.prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: #f1f3f5;
    color: #343a40;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    /* Long identifiers must wrap rather than widen the page. */
    overflow-wrap: break-word;
}

.prose pre {
    margin: 1.6em 0;
    padding: 1rem;
    background: #f1f3f5;
    border-radius: 8px;
    overflow-x: auto;          /* the block scrolls, the page does not */
    -webkit-overflow-scrolling: touch;
}

.prose pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
    white-space: pre;
}

/* --------------------------------------------------------------- tables */
/* The table lives inside its own scroller so a wide table can never push
   the page sideways on a phone. build.js wraps every table in
   .prose-table-wrap automatically. */

.prose-table-wrap {
    margin: 1.6em 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e3e7ec;
    border-radius: 8px;
}

.prose-table-wrap table {
    margin: 0;
    border: 0;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.prose th,
.prose td {
    padding: 0.7rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid #e3e7ec;
    /* Stops a single long cell collapsing the rest of the columns. */
    min-width: 7rem;
}

.prose thead th {
    background: #f4f7fd;
    font-weight: 650;
    color: #343a40;
    white-space: nowrap;
}

.prose tbody tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------------- callout */
/* For the one line a reader should leave with. */

.prose .callout {
    margin: 1.8em 0;
    padding: 1.1rem 1.25rem;
    background: #f4f7fd;
    border-left: 4px solid #3369d3;
    border-radius: 0 8px 8px 0;
}

.prose .callout > :last-child { margin-bottom: 0; }

.prose .callout-label {
    display: block;
    margin-bottom: 0.35em;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #2854b8;
}

/* --------------------------------------------------------------- images */

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 1.6em auto;
}

.prose figure { margin: 1.8em 0; }

.prose figcaption {
    margin-top: 0.6em;
    font-size: 0.9375rem;
    color: #5a6775;
    text-align: center;
}

/* ------------------------------------------------------------- dividers */

.prose hr {
    margin: 2.5em 0;
    border: 0;
    border-top: 1px solid #e3e7ec;
}

/* ------------------------------------------------- the tool content region */
/* Sits below the tool, never above it. build.js emits nothing at all when a
   tool has no content, so the markup does not exist rather than rendering
   as an empty box.

   The region is published with the same container classes the hand-written
   content blocks use - seo-content container glass-panel content-redesign -
   so the panel itself (background, border, radius, shadow, padding, width)
   comes from the site's own stylesheet and matches the rest of the site
   exactly. Nothing about the panel is redefined here; this block only makes
   the reading column behave inside it. */

.tool-prose .prose {
    /* The panel already supplies the page gutter, so the column only needs
       to centre itself and cap its own line length. */
    width: 100%;
}

/* --------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
    .prose *,
    .prose *::before,
    .prose *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
