/* bale: the AF Automations site family (afautomations.co.uk, fitness.afautomations.co.uk).
   Every colour comes from these tokens. Light by default; dark when <html data-theme="dark"> (theme.js),
   or, with scripts off, when the system prefers dark. */
:root {
    color-scheme: light;
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f3f5f8;
    --text: #1a1a1a;
    --text-2: #3d4248;
    --muted: #5c636a;
    --border: #e1e4e8;
    --border-strong: #d0d4d9;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-solid: #2563eb;
    --accent-solid-hover: #1d4ed8;
    --accent-rgb: 37, 99, 235;
    --ink: #0f172a;
    --code-bg: #eef1f5;
    --hero-from: #0f172a;
    --hero-to: #1e293b;
    --fire: #e8340c;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1b1f27;
    --text: #e6e8eb;
    --text-2: #c4c9d0;
    --muted: #9aa3ad;
    --border: #2c323c;
    --border-strong: #3b424e;
    --accent: #6ea8ff;
    --accent-hover: #8fbcff;
    --accent-solid: #2f6fe0;
    --accent-solid-hover: #3f7ff0;
    --accent-rgb: 110, 168, 255;
    --ink: #ffffff;
    --code-bg: #232831;
    --hero-from: #0a0f1d;
    --hero-to: #172033;
    --fire: #ff7a45;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --bg: #0f1115;
        --surface: #171a21;
        --surface-2: #1b1f27;
        --text: #e6e8eb;
        --text-2: #c4c9d0;
        --muted: #9aa3ad;
        --border: #2c323c;
        --border-strong: #3b424e;
        --accent: #6ea8ff;
        --accent-hover: #8fbcff;
        --accent-solid: #2f6fe0;
        --accent-solid-hover: #3f7ff0;
        --accent-rgb: 110, 168, 255;
        --ink: #ffffff;
        --code-bg: #232831;
        --hero-from: #0a0f1d;
        --hero-to: #172033;
        --fire: #ff7a45;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

main { flex: 1; }

.wrap {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0 1.25rem;
}

h1, h2, h3 { line-height: 1.25; color: var(--text); }
h1 { font-size: 2rem; margin: 0 0 0.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; margin: 2.25rem 0 0.75rem; font-weight: 700; }
h3 { font-size: 1.1rem; margin: 0 0 0.4rem; font-weight: 600; }
p { margin: 0 0 1rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
/* Links inside running text are underlined, so they don't rely on colour alone. */
main p a:not(.btn):not(.footnote-mark), main li a:not(.btn) { text-decoration: underline; text-underline-offset: 0.15em; }
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

code, pre {
    font-family: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
}
code {
    background: var(--code-bg);
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
}
pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.9rem 1rem;
    overflow-x: auto;
    margin: 0 0 1rem;
}
pre code { background: none; padding: 0; }

.skip-link {
    position: absolute;
    left: -999px;
    top: 0.5rem;
    background: var(--surface);
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    z-index: 10;
}
.skip-link:focus { left: 0.5rem; }

/* Header */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.site-header-inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-height: 3.75rem;
}
.site-logo {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    color: var(--ink);
}
.site-logo:hover { color: var(--ink); }
.bale-logo-header { height: 2.5rem; width: auto; }
.site-nav {
    display: flex;
    gap: 1.25rem;
    flex: 1;
}
.site-nav a {
    color: var(--text-2);
    font-weight: 500;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); text-decoration: none; }

.theme-toggle {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 2px;
    background: var(--surface-2);
    flex: none;
}
.theme-toggle-btn {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.theme-toggle-btn:hover { color: var(--text); }
.theme-toggle-btn.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Logo: letters follow the theme (currentColor); the flames flicker unless the visitor prefers less motion. */
.bale-logo { display: block; overflow: visible; }
@media (prefers-reduced-motion: no-preference) {
    .bale-fire-a, .bale-fire-b, .bale-fire-c {
        transform-box: fill-box;
        transform-origin: 50% 100%;
    }
    .bale-fire-a { animation: bale-flicker-a 2.8s ease-in-out infinite; }
    .bale-fire-b { animation: bale-flicker-b 2.1s ease-in-out infinite; }
    .bale-fire-c { animation: bale-flicker-c 1.6s ease-in-out infinite; }
}
@keyframes bale-flicker-a {
    0%, 100% { transform: scale(1, 1) skewX(0deg); }
    35% { transform: scale(1.02, 1.05) skewX(-1.5deg); }
    70% { transform: scale(0.99, 0.97) skewX(1deg); }
}
@keyframes bale-flicker-b {
    0%, 100% { transform: scale(1, 1) skewX(0deg); }
    40% { transform: scale(0.98, 1.07) skewX(2deg); }
    75% { transform: scale(1.02, 0.96) skewX(-1deg); }
}
@keyframes bale-flicker-c {
    0%, 100% { transform: scale(1, 1); }
    50% { transform: scale(1.04, 1.1); }
}

/* Hero */
.hero {
    background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%);
    color: #e6e8eb;
    padding: 3rem 0 3.25rem;
}
.hero-inner { max-width: 48rem; margin-left: auto; margin-right: auto; }
.hero h1 { margin: 0 0 1.5rem; color: #ffffff; line-height: 0; }
.bale-logo-hero { width: min(22rem, 78vw); height: auto; color: #ffffff; }
.definition {
    border-left: 3px solid var(--fire);
    padding: 0.25rem 0 0.25rem 1rem;
    margin: 0 0 1.5rem;
}
.definition p { margin: 0; }
.definition-head { font-size: 1.15rem; color: #ffffff; }
.definition-head .pron, .definition-head em { color: #b8c0cc; margin-left: 0.35rem; }
.definition-body { font-size: 1.35rem; color: #ffffff; line-height: 1.4; }
.footnote-mark { color: #ffb38a; text-decoration: none; margin-left: 0.1rem; }
.footnote-mark:hover { color: #ffd0b3; }
.footnote { font-size: 0.9rem; color: #b8c0cc; margin-top: 0.4rem !important; }
.hero .lead { font-size: 1.1rem; color: #d6dbe2; margin-bottom: 1.75rem; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.25rem 0 0; }
.btn {
    display: inline-block;
    padding: 0.65rem 1.2rem;
    border-radius: 0.375rem;
    font-weight: 600;
    border: 1px solid transparent;
    text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent-solid); color: #ffffff; }
.btn-primary:hover { background: var(--accent-solid-hover); color: #ffffff; }
.btn-ghost { border-color: var(--border-strong); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.hero .btn-primary { background: #2563eb; }
.hero .btn-primary:hover { background: #1d4ed8; }
.hero .btn-ghost { border-color: rgba(255, 255, 255, 0.55); color: #ffffff; }
.hero .btn-ghost:hover { border-color: #ffffff; color: #ffffff; background: rgba(255, 255, 255, 0.08); }

/* Sections */
.band { padding: 2.5rem 0 3rem; }
.band > .wrap > h2:first-child { margin-top: 0; }
.band-muted { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-lead { font-size: 1.08rem; color: var(--text-2); max-width: 48rem; }
.page-head { padding: 2.5rem 0 0; }
.page-head .section-lead { margin-bottom: 0; }
.meta { color: var(--muted); font-size: 0.95rem; }

.cards, .points {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}
.card, .points li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.15rem 1.25rem;
}
.card p:last-child, .points li p:last-child { margin-bottom: 0; }
.card h3, .points h3 { color: var(--accent); }
.points { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.points li { border-left: 4px solid var(--accent-solid); }
.works-with {
    margin: 1.5rem 0 0;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text-2);
}

/* Download */
.release { margin-bottom: 1rem; }
.release h2 { margin-top: 0; }
.release-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1.25rem;
    margin: 0 0 0.5rem;
}
.release-facts dt { color: var(--muted); font-weight: 500; }
.release-facts dd { margin: 0; min-width: 0; }
.hash { word-break: break-all; }
.steps { padding-left: 1.4rem; }
.steps li { margin-bottom: 0.6rem; }
.note { color: var(--text-2); font-size: 0.95rem; }

.prose .wrap { max-width: 48rem; }
.prose h3 { margin-top: 1.25rem; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.92rem;
}
.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding-top: 1.1rem;
    padding-bottom: 1.1rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer-links { display: flex; gap: 1.25rem; }

@media (max-width: 40rem) {
    h1 { font-size: 1.7rem; }
    .site-header-inner { flex-wrap: wrap; gap: 0.5rem 1rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
    .site-nav { order: 3; flex-basis: 100%; gap: 1.1rem; }
    .site-logo { margin-right: auto; }
    .bale-logo-header { height: 2.2rem; }
    .definition-body { font-size: 1.18rem; }
    .release-facts { grid-template-columns: 1fr; }
    .release-facts dd { margin-bottom: 0.4rem; }
}
