/* Kcorp Prime: reset, colour scheme and element defaults. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--kp-toolbar-h) + var(--kp-header-h) + 1rem);
}

body {
    margin: 0;
}

/*
 * The colour scheme is scoped to the page wrapper, not <html>, so the Concrete
 * toolbar and dialogs outside of it always keep their own light styling.
 * Default: follow the OS. The header toggle sets data-theme on <html>.
 */
.kp-site {
    color-scheme: light dark;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--kp-bg);
    color: var(--kp-ink);
    font: 400 var(--kp-fs-base) / 1.7 var(--kp-font-sans);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-wrap: break-word;
}

[data-theme="light"] .kp-site { color-scheme: light; }
[data-theme="dark"] .kp-site { color-scheme: dark; }

/* Re-scope a subtree to a fixed scheme: every token flips inside it. */
.scheme-dark { color-scheme: dark; }
.scheme-light { color-scheme: light; }

.kp-site > main {
    flex: 1 0 auto;
}

::selection {
    background: color-mix(in srgb, var(--kp-accent) 30%, transparent);
}

:focus-visible {
    outline: 2px solid var(--kp-accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5em;
    font-family: var(--kp-font-display);
    font-weight: 650;
    line-height: 1.12;
    letter-spacing: -0.025em;
    color: var(--kp-ink);
    text-wrap: balance;
}

h1 { font-size: var(--kp-fs-h1); letter-spacing: -0.04em; line-height: 1.04; }
h2 { font-size: var(--kp-fs-h2); letter-spacing: -0.035em; }
h3 { font-size: var(--kp-fs-h3); }
h4 { font-size: var(--kp-fs-h4); }
h5, h6 { font-size: 1rem; }

/* <em> inside a heading is the brand accent: serif italic with a gradient fill. */
h1 em, h2 em, h3 em, .text-gradient {
    font-family: var(--kp-font-serif);
    font-style: italic;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--kp-accent);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    h1 em, h2 em, h3 em, .text-gradient {
        padding-right: 0.06em;
        background: var(--kp-gradient);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        color: transparent;
    }
}

p {
    margin: 0 0 1.15em;
    text-wrap: pretty;
}

.lead {
    font-size: var(--kp-fs-lead);
    line-height: 1.55;
    color: var(--kp-ink-soft);
}

.eyebrow {
    margin: 0 0 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--kp-accent);
}

.small-print {
    font-size: var(--kp-fs-sm);
    color: var(--kp-muted);
}

a {
    color: var(--kp-accent);
    text-decoration: none;
    transition: color var(--kp-fast) ease;
}

a:hover {
    color: var(--kp-accent-strong);
}

/* Links inside running text are underlined so they never rely on colour alone. */
:where(p, li, td, dd, blockquote) > a:not(.btn) {
    text-decoration: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.2em;
    text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}

ul, ol {
    margin: 0 0 1.15em;
    padding-left: 1.4em;
}

.kp-site li + li {
    margin-top: 0.3em;
}

hr {
    margin: var(--kp-gap-lg) 0;
    border: 0;
    border-top: 1px solid var(--kp-line);
}

blockquote {
    margin: 1.5em 0;
    padding: 0.25em 0 0.25em 1.25em;
    border-left: 3px solid var(--kp-accent);
    font-family: var(--kp-font-serif);
    font-size: 1.2em;
    font-style: italic;
    color: var(--kp-ink-soft);
}

code, kbd, pre {
    font-family: var(--kp-font-mono);
    font-size: 0.9em;
}

:not(pre) > code {
    padding: 0.15em 0.4em;
    border-radius: 6px;
    background: var(--kp-bg-soft);
    border: 1px solid var(--kp-line);
}

pre {
    margin: 0 0 1.5em;
    padding: 1.1rem 1.25rem;
    overflow: auto;
    border-radius: var(--kp-radius);
    background: var(--kp-dark-surface);
    color: #e6ebf8;
}

img, svg, video, canvas, iframe {
    max-width: 100%;
}

img, video {
    height: auto;
}

figure {
    margin: 0 0 1.5em;
}

figcaption {
    margin-top: 0.6em;
    font-size: var(--kp-fs-sm);
    color: var(--kp-muted);
}

/* Accessibility helpers */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1000;
    padding: 0.6rem 1rem;
    border-radius: var(--kp-radius-sm);
    background: var(--kp-accent);
    color: var(--kp-on-accent);
    font-weight: 600;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
    color: var(--kp-on-accent);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .site-header, .site-footer, .announcement, .reading-progress { display: none !important; }
    .kp-site { color-scheme: light; }
}
