/**
 * BoltPress base utilities
 *
 * Enqueued unconditionally from boltpress_scripts() as `boltpress-base`.
 *
 * These rules used to live only in assets/css/header.css, which header.php
 * enqueues *after* it has already returned early for a child-theme custom
 * header override — so on any site that sets `custom_header_file` the rules
 * never loaded and every `.screen-reader-text` span (excerpt "Continue
 * reading", the menu toggle label, the WooCommerce quantity label, the skip
 * link, …) rendered as visible body text. They are duplicated here rather
 * than moved so header.css keeps working unchanged for existing installs.
 *
 * Since 1.4.0 it also carries the body font fallback and the parent's fallback
 * layout. Every one of those selectors is wrapped in :where(), so it has zero
 * specificity and any rule in a child theme wins.
 */

/* Layout variables. --bp-max-width is the one Launchpad child themes already
   define, so changing it there moves the header and these rules together. */
:root {
    --boltpress-content-width: var(--bp-max-width, 1200px);
    --boltpress-gutter: 1rem;
}

@media (max-width: 480px) {
    :root {
        --boltpress-gutter: 0.75rem;
    }
}

/* Without a body font token or a child stylesheet the browser falls back to
   Times; a system sans-serif is a saner default. */
:where(body) {
    font-family: var(--boltpress-typography-font-family-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

/* Fallback layout for the parent's own page.php and index.php. The body class
   is added only when one of those renders the request, so child and starter
   templates are untouched. */
:where(.boltpress-default-layout) :where(.site-main) > :where(article, .no-results) > :where(.entry-header, .page-header, .entry-content, .page-content, .entry-footer, .post-thumbnail, .page-links),
:where(.boltpress-default-layout) :where(.site-main) > :where(.navigation) {
    max-width: var(--boltpress-content-width);
    margin-inline: auto;
    padding-inline: var(--boltpress-gutter);
}

/* Full-width blocks break out of the content column to the viewport edges.
   100vw includes a desktop scrollbar, so main clips the few pixels that would
   otherwise scroll sideways; clip, unlike hidden, keeps position: sticky working. */
:where(.boltpress-default-layout .site-main) {
    overflow-x: clip;
}

:where(.boltpress-default-layout .entry-content) > :where(.alignfull) {
    margin-inline: calc(50% - 50vw);
    max-width: 100vw;
    width: auto;
}

:where(.boltpress-default-layout .entry-content) > :where(.alignwide) {
    max-width: 100%;
}

/* Core's password form for protected posts and pages. */
:where(.post-password-form) {
    max-width: 32rem;
}

:where(.post-password-form) p {
    margin: 0 0 1rem;
}

:where(.post-password-form) label {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

:where(.post-password-form) input[type="password"] {
    box-sizing: border-box;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font: inherit;
}

/* Utility Classes */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    width: 1px;
    word-wrap: normal !important;
}

/* Un-hide focusable screen-reader text (the skip link) on keyboard focus.
   Required because the rule above clips the element to 1x1px and it is never
   un-clipped anywhere else — without this the skip link stays invisible even
   while focused. Only `clip` needs !important here (it mirrors the clipping
   rule's own weight); everything else is a plain declaration a child theme can
   still override.

   Note this DOES apply to the skip link: header.php gives it both `skip-link`
   and `screen-reader-text`, so `.screen-reader-text:focus` (0,2,0) outranks
   header.css's `.skip-link:focus` (0,1,1 on the pseudo-class, same weight but
   losing the class count). That is intended — the skip link must become visible
   on focus even when a custom header override means header.css never loads, and
   before this file existed it stayed clipped to 1x1px and was unusable. A header
   stylesheet that wants its own focused appearance can still win with a more
   specific selector (e.g. `.site-header .skip-link:focus`). */
.screen-reader-text:focus {
    background-color: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    clip-path: none;
    color: #21759b;
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}
