/* ============================================================================
   Base Styles - Reset, Typography, Accessibility
   ============================================================================ */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

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

body {
    margin: 0;
    font-family: var(--adst-font-family);
    font-size: var(--wp--preset--font-size--medium);
    line-height: 1.65;
    color: var(--adst-muted);
    background: var(--adst-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Fix sticky positioning - ensure parent containers don't block it */
html,
body,
.wp-site-blocks,
.wp-block-template-part,
header.wp-block-template-part {
    overflow: visible !important;
    /* These properties break sticky positioning - force reset them */
    transform: none !important;
    filter: none !important;
    perspective: none !important;
}

/* Initial values prevent content flashing beneath the fixed desktop header. */
:root {
    --adst-est-topbar: 41.3px; /* measured: 25.3px prod button + 16px local padding (ticket #22 production measurements) */
    --adst-est-header: 84px; /* measured: prod desktop charcoal nav section (ticket #22 production measurements) */
    --adst-header-offset: calc(var(--adst-est-topbar) + var(--adst-est-header));
}

/* Headings use dark navy */
h1, h2, h3, h4, h5, h6 {
    color: var(--adst-text);
    font-family: var(--adst-font-heading);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

/* Open Sans has no 700 face after #61; keep semantic emphasis on the shipped 600 face. */
strong,
b {
    font-weight: var(--adst-font-semibold);
}

/* Improved paragraph spacing */
p {
    margin-bottom: 1.25rem;
    line-height: 1.7;
}

p:last-child {
    margin-bottom: 0;
}

/* Lists spacing */
ul, ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

ul li, ol li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

/* Text selection styling */
::selection {
    background: rgb(var(--adst-primary-rgb) / 0.2);
    color: var(--adst-text);
}

::-moz-selection {
    background: rgb(var(--adst-primary-rgb) / 0.2);
    color: var(--adst-text);
}

main {
    display: block;
    margin-top: 0;
}

/* Block theme root wrapper: pad down by header wrap height */
.wp-site-blocks {
    padding-top: var(--adst-header-offset);
    transition: padding-top 280ms ease;
}

/* Footer template part spacing */
footer.wp-block-template-part {
    margin-top: 40px;
}

a {
    color: var(--adst-primary);
    text-decoration: none;
    transition: color var(--adst-transition);
}

a:hover,
a:focus {
    color: var(--adst-primary-dark);
}

/* Links inside running text need more than colour (WCAG 1.4.1, #86). Scoped to prose containers so
   nav, cards and the #33 CTA levels keep their own affordance; button-styled anchors are excluded. */
:is(.adst-page-content, .adst-single-post__content) :is(p, li, td, th, dd, dt, figcaption) a:not(.site-btn, .wp-block-button__link, .wp-element-button) {
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em; /* Same offset the contact block uses (blocks/contact-details/style.css). */
}

/* ============================================
   Focus Styles - Keyboard Accessibility
   ============================================ */

/* Visible focus for keyboard navigation (WCAG 2.1 compliant) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.wp-block-button__link:focus-visible,
.wp-element-button:focus-visible,
.site-btn:focus-visible {
    outline: 2px solid var(--adst-primary);
    outline-offset: 2px;
    transition: outline-offset 0.2s ease;
}

/* Remove outline ONLY for mouse clicks (not keyboard) */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus for form inputs */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--adst-primary);
    outline-offset: 0px;
    box-shadow: 0 0 0 3px rgb(var(--adst-primary-rgb) / 0.1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wp-element-button:where(:not(.adst-btn-bestia, .adst-btn-stroke)),
    .wp-block-button__link:where(:not(.adst-btn-bestia, .adst-btn-stroke)),
    .site-btn:where(:not(.adst-btn-bestia, .adst-btn-stroke)) {
        border: 2px solid var(--adst-secondary);
    }

    .site-btn--primary,
    .wp-block-button.is-style-fill .wp-block-button__link {
        background: var(--button-primary-bg);
        color: var(--button-primary-text);
    }

    .site-btn--secondary,
    .wp-block-button.is-style-secondary .wp-block-button__link {
        background: var(--button-secondary-bg);
        color: var(--button-secondary-text);
    }

    .site-btn--tertiary,
    .wp-block-button.is-style-tertiary .wp-block-button__link {
        background: transparent;
        border: 0;
        text-decoration-thickness: 3px; /* forced-colors/high-contrast: 3px keeps the tertiary underline visible where the 2px default is thinned by system colours (chosen basis; ticket #33 contrast calculations). */
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wp-element-button:where(:not(.adst-btn-bestia, .adst-btn-stroke)),
    .wp-block-button__link:where(:not(.adst-btn-bestia, .adst-btn-stroke)),
    .site-btn:where(:not(.adst-btn-bestia, .adst-btn-stroke)) {
        transition: none !important;
        transform: none !important;
    }

    .wp-element-button::before,
    .wp-block-button__link::before,
    .site-btn::before {
        display: none;
    }
}

img,
svg,
video {
    display: block;
    max-width: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 1.2rem;
    color: var(--adst-secondary);
    letter-spacing: -0.01em;
}

h1 {
    font-size: var(--wp--preset--font-size--xx-large);
    line-height: 1.08;
}
h2 {
    font-size: var(--wp--preset--font-size--display);
    line-height: 1.12;
}
h3 {
    font-size: var(--wp--preset--font-size--heading-small);
}
h4 {
    font-size: var(--wp--preset--font-size--lead);
}

p {
    margin: 0 0 1.2rem;
    word-spacing: 0.01em;
}

blockquote {
    margin: 0 0 2rem;
    padding: 1.4rem 2rem;
    background: rgb(var(--adst-primary-rgb) / 0.06);
    border-left: 4px solid var(--adst-primary);
    border-radius: 0 var(--adst-radius) var(--adst-radius) 0;
    font-style: italic;
    color: rgb(var(--adst-secondary-rgb) / 0.85);
}
