/* ==========================================================================
   Base — element defaults in the STS-ED voice. No components, no layout.
   ========================================================================== */

html {
    scroll-behavior: smooth;
}

body {
    background: var( --stsed-color-bg );
    color: var( --stsed-color-text );
    font-family: var( --stsed-font-body );
    font-size: var( --stsed-text-base );
    line-height: var( --stsed-leading-normal );
}

/* --- Headings ---------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var( --stsed-font-heading );
    font-weight: var( --stsed-weight-semibold );
    line-height: var( --stsed-leading-tight );
    color: var( --stsed-color-text );
    text-wrap: balance;
}

h1 {
    font-size: var( --stsed-text-3xl );
    letter-spacing: -0.02em;
}

h2 {
    font-size: var( --stsed-text-2xl );
    letter-spacing: -0.01em;
}

h3 {
    font-size: var( --stsed-text-xl );
}

h4 {
    font-size: var( --stsed-text-lg );
}

h5,
h6 {
    font-size: var( --stsed-text-base );
}

/* --- Flow spacing ------------------------------------------------------
   Owl selector: space between siblings, no leading/trailing margin to fight.
   Headings get extra space above, none below — they belong to what follows. */

p,
ul,
ol,
dl,
blockquote,
figure,
pre,
table,
hr {
    margin-block: 0 var( --stsed-space-sm );
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-block: var( --stsed-space-lg ) var( --stsed-space-2xs );
}

:is( h1, h2, h3, h4, h5, h6 ):first-child {
    margin-block-start: 0;
}

/* --- Links -------------------------------------------------------------- */

a {
    color: var( --stsed-color-link );
    text-decoration: none;
    transition: color var( --stsed-transition );
}

a:hover,
a:focus-visible {
    color: var( --stsed-color-link-hover );
    text-decoration: underline;
}

/* Body copy links stay underlined — colour alone isn't an accessible cue.
   Prose only. .stsed-content wraps the_content(), which also renders shortcodes,
   whose UI links are controls, not prose — often unclassed and inside an <li>,
   so neither :not([class]) nor the wrapper element distinguishes them. Every
   plugin component roots itself in a namespaced .stsed-* container, so "not
   inside a component nested in the content" is the reliable test, with no
   per-component allowlist to maintain. The inner `.stsed-content` in the :not()
   matters: without it, .stsed-content matches [class*="stsed-"] itself and the
   rule excludes everything. This has to not match rather than be overridden —
   it outranks a component's own `text-decoration: none`. */
.stsed-content a:not( [class] ):not( .stsed-content [class*="stsed-"] a ) {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

/* --- Lists -------------------------------------------------------------- */

ul:not( [class] ),
ol:not( [class] ) {
    padding-inline-start: var( --stsed-space-md );
}

li + li {
    margin-block-start: var( --stsed-space-3xs );
}

/* --- Text-level --------------------------------------------------------- */

strong,
b {
    font-weight: var( --stsed-weight-semibold );
}

small {
    font-size: var( --stsed-text-sm );
}

hr {
    border: 0;
    border-block-start: 1px solid var( --stsed-color-border );
    margin-block: var( --stsed-space-lg );
}

blockquote {
    padding-inline-start: var( --stsed-space-sm );
    border-inline-start: 3px solid var( --stsed-color-primary );
    color: var( --stsed-color-text-muted );
    font-style: italic;
}

code,
kbd,
samp {
    font-family: var( --stsed-font-mono );
    font-size: 0.9em;
    background: var( --stsed-color-surface-sunken );
    border: 1px solid var( --stsed-color-border );
    border-radius: var( --stsed-radius-sm );
    padding: 0.1em 0.35em;
}

pre {
    font-family: var( --stsed-font-mono );
    font-size: var( --stsed-text-sm );
    background: var( --stsed-color-surface-sunken );
    border: 1px solid var( --stsed-color-border );
    border-radius: var( --stsed-radius-md );
    padding: var( --stsed-space-sm );
    overflow-x: auto;
}

pre code {
    background: none;
    border: 0;
    padding: 0;
}

/* --- Media -------------------------------------------------------------- */

figure img {
    border-radius: var( --stsed-radius-md );
}

figcaption {
    font-size: var( --stsed-text-sm );
    color: var( --stsed-color-text-muted );
    margin-block-start: var( --stsed-space-2xs );
}

/* --- Tables ------------------------------------------------------------
   The theme owns table margins now (GeneratePress used to set 1.5em, which is
   why stsed-events/calendar.css carries a defensive table reset). */

table {
    width: 100%;
    font-size: var( --stsed-text-sm );
}

th,
td {
    text-align: start;
    padding: var( --stsed-space-2xs ) var( --stsed-space-xs );
    border-block-end: 1px solid var( --stsed-color-border );
}

th {
    font-weight: var( --stsed-weight-semibold );
    color: var( --stsed-color-text );
}

/* --- Selection ---------------------------------------------------------- */

::selection {
    background: color-mix( in srgb, var( --stsed-color-primary ) 22%, transparent );
}
