/*
 * SLBD accessibility foundation.
 * Uses existing approved brand tokens; no new brand colours are introduced.
 */
:root {
    --slbd-accessibility-focus-color: var(--wp--preset--color--deep-emerald, #102C25);
    --slbd-accessibility-focus-on-dark: var(--wp--preset--color--warm-ivory, #F7F4EB);
    --slbd-accessibility-control-border: var(--wp--preset--color--muted, #65716A);
}

/* Preserve an unmistakable keyboard indicator for all theme-controlled controls. */
:where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 3px solid var(--slbd-accessibility-focus-color);
    outline-offset: 3px;
}

.slbd-site-footer :where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline-color: var(--slbd-accessibility-focus-on-dark);
}

.slbd-skip-link:focus,
.slbd-skip-link:focus-visible {
    left: 0.5rem;
    outline: 3px solid var(--slbd-accessibility-focus-color);
    outline-offset: 3px;
}

/* A reusable visually-hidden utility that becomes visible when focused. */
.slbd-screen-reader-text:not(:focus):not(:active) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Keep keyboard focus and in-page destinations clear of the viewport edge. */
:where(main[id], h1[id], h2[id], h3[id], h4[id], h5[id], h6[id], [tabindex="-1"]) {
    scroll-margin-block: 1rem;
}

/* Theme-owned search form: explicit label, legible controls and usable targets. */
.slbd-search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem;
    max-width: 100%;
}

.slbd-search-form__field {
    display: grid;
    flex: 1 1 18rem;
    min-width: min(100%, 18rem);
    gap: 0.375rem;
}

.slbd-search-form__label,
.slbd-comments label,
.slbd-entry__content label {
    display: block;
    color: var(--wp--preset--color--ink, #202A25);
    font-weight: 600;
}

.slbd-search-form input[type="search"],
.slbd-comments input[type="text"],
.slbd-comments input[type="email"],
.slbd-comments input[type="url"],
.slbd-comments textarea,
.slbd-entry__content input[type="text"],
.slbd-entry__content input[type="email"],
.slbd-entry__content input[type="url"],
.slbd-entry__content input[type="search"],
.slbd-entry__content select,
.slbd-entry__content textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--slbd-accessibility-control-border);
    border-radius: 2px;
    background: var(--wp--preset--color--paper-white, #FFFEFA);
    color: var(--wp--preset--color--ink, #202A25);
    font: inherit;
    line-height: 1.5;
}

.slbd-comments textarea,
.slbd-entry__content textarea {
    min-height: 12rem;
    resize: vertical;
}

.slbd-search-form__submit,
.slbd-comments input[type="submit"],
.slbd-entry__content input[type="submit"],
.slbd-entry__content button,
.slbd-comments button,
.slbd-entry__content .wp-block-button__link {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    border: 1px solid var(--wp--preset--color--deep-emerald, #102C25);
    border-radius: 2px;
    background: var(--wp--preset--color--deep-emerald, #102C25);
    color: var(--wp--preset--color--warm-ivory, #F7F4EB);
    font: inherit;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.slbd-search-form__submit:hover,
.slbd-comments input[type="submit"]:hover,
.slbd-entry__content input[type="submit"]:hover,
.slbd-entry__content button:hover,
.slbd-comments button:hover,
.slbd-entry__content .wp-block-button__link:hover {
    background: var(--wp--preset--color--rainforest, #173C32);
    color: var(--wp--preset--color--warm-ivory, #F7F4EB);
}

.slbd-search-form__submit:focus-visible,
.slbd-comments input[type="submit"]:focus-visible,
.slbd-entry__content input[type="submit"]:focus-visible,
.slbd-entry__content button:focus-visible,
.slbd-comments button:focus-visible,
.slbd-entry__content .wp-block-button__link:focus-visible {
    outline-color: var(--slbd-accessibility-focus-color);
}

.slbd-comments {
    margin-block-start: clamp(2rem, 5vw, 4rem);
}

.slbd-comments__title {
    margin-block: 0 1rem;
}

.slbd-comments :where(.comment-notes, .logged-in-as, .comment-form-cookies-consent, .form-allowed-tags) {
    color: var(--wp--preset--color--muted, #65716A);
}

.slbd-comments .comment-form-cookies-consent {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
}

.slbd-comments .comment-form-cookies-consent {
    min-height: 44px;
}

.slbd-comments input[type="checkbox"],
.slbd-comments input[type="radio"],
.slbd-entry__content input[type="checkbox"],
.slbd-entry__content input[type="radio"] {
    width: 1.5rem;
    height: 1.5rem;
    min-width: 24px;
    min-height: 24px;
    accent-color: var(--wp--preset--color--deep-emerald, #102C25);
}

.slbd-comments .comment-form-cookies-consent input[type="checkbox"] {
    flex: 0 0 auto;
    margin-block-start: 0.2rem;
}

.slbd-comments [aria-invalid="true"],
.slbd-entry__content [aria-invalid="true"] {
    border-width: 2px;
    border-color: var(--wp--preset--color--deep-emerald, #102C25);
}

.slbd-comments .required {
    color: var(--wp--preset--color--ink, #202A25);
    font-weight: 700;
}

.slbd-comments .comment-respond,
.slbd-comments .comment-form > p {
    max-width: 100%;
}

/* Long editorial strings and wide data remain usable at narrow viewports. */
.slbd-entry__content,
.slbd-site-main__inner {
    min-width: 0;
    overflow-wrap: break-word;
}

.slbd-entry__content pre,
.slbd-entry__content .wp-block-table {
    max-width: 100%;
    overflow-x: auto;
}

.slbd-entry__content pre {
    white-space: pre;
}

.slbd-posts-pagination .page-numbers,
.navigation.pagination .page-numbers {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

/* Do not use colour alone to distinguish focus, errors or current state. */
.slbd-entry__content a,
.slbd-comments a {
    text-decoration: underline;
    text-underline-offset: 0.16em;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (forced-colors: active) {
    :where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
        outline: 3px solid Highlight;
        outline-offset: 3px;
    }

    .slbd-search-form__submit,
    .slbd-comments input[type="submit"],
    .slbd-entry__content input[type="submit"] {
        border: 1px solid ButtonText;
    }
}

@media (max-width: 359px) {
    .slbd-search-form__field {
        flex-basis: 100%;
        min-width: 0;
    }

    .slbd-search-form__submit {
        width: 100%;
    }
}
