/* ============================================================================
   base.css — Klever Klox design system
   ----------------------------------------------------------------------------
   Tokens, reset, typography, layout primitives, buttons, forms and utilities.
   Every public page loads this first; components.css adds the site chrome and
   the per-page files only add what is genuinely unique to that page.

   Theming: the light palette is defined on bare :root so it is always the
   fallback. Dark is applied twice — once for the system preference (guarded so
   an explicit light choice wins) and once for the explicit dark choice.
   ========================================================================= */

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
    /* Surfaces */
    --paper:        #f7f5f0;   /* page background */
    --surface:      #fffefb;   /* cards, raised panels */
    --surface-2:    #efece4;   /* subtle fills, table stripes */
    --inverse:      #14130f;   /* dark bands inside a light page */
    --inverse-ink:  #f6f4ee;

    /* Ink */
    --ink:          #14130f;   /* 17.1:1 on paper */
    --ink-soft:     #45423a;   /*  9.2:1 */
    --ink-muted:    #5f5c53;   /*  6.1:1 */
    --ink-faint:    #6d6860;   /*  5.1:1 — the floor for body-size text,
                                  and 4.7:1 on the --surface-2 table headers */

    /* Lines */
    --line:         rgba(20, 19, 15, .14);
    --line-strong:  rgba(20, 19, 15, .28);

    /* Brand — the "dawn" accents, same colours the clock's LEDs sweep through */
    --accent:       #c23a14;   /*  4.9:1 on paper, 5.4:1 under white text */
    --amber:        #e8992c;
    --gold:         #f0c14b;
    --accent-ink:   #ffffff;   /* text on top of --accent */
    --accent-wash:  rgba(194, 58, 20, .09);

    /* Decorative gradient: rules, bars, glows — never behind text. */
    --dawn: linear-gradient(90deg, #b6301f 0%, #d8451c 28%, #e8992c 66%, #f0c14b 100%);
    --dawn-soft: linear-gradient(135deg, rgba(216,69,28,.14), rgba(240,193,75,.16));

    /* The gradient used as a text fill. Every stop is dark enough to read on
       paper — the amber and gold end of --dawn is around 2:1 and would make
       the tail of any word set in it effectively invisible. */
    --dawn-text: linear-gradient(90deg, #9e2a1c 0%, #c23a14 50%, #b03a0e 100%);

    /* Status */
    --ok:      #2f7d4f;
    --ok-wash: rgba(47, 125, 79, .1);
    --warn:    #a86a12;
    --warn-wash: rgba(168, 106, 18, .12);
    --bad:     #c22c2c;
    --bad-wash: rgba(194, 44, 44, .1);

    /* Type */
    --font-display: 'Space Grotesk', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body:    'Space Grotesk', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;

    /* Fluid type scale — clamp() so nothing needs a breakpoint to stay readable */
    --step--2: clamp(.69rem, .66rem + .12vw, .75rem);
    --step--1: clamp(.81rem, .78rem + .16vw, .89rem);
    --step-0:  clamp(1rem, .96rem + .2vw, 1.09rem);
    --step-1:  clamp(1.2rem, 1.12rem + .38vw, 1.42rem);
    --step-2:  clamp(1.44rem, 1.3rem + .7vw, 1.9rem);
    --step-3:  clamp(1.73rem, 1.5rem + 1.15vw, 2.53rem);
    --step-4:  clamp(2.07rem, 1.7rem + 1.85vw, 3.38rem);
    --step-5:  clamp(2.49rem, 1.9rem + 2.9vw, 4.5rem);
    --step-6:  clamp(2.9rem, 1.9rem + 4.6vw, 6rem);

    /* Space */
    --sp-1: .25rem;
    --sp-2: .5rem;
    --sp-3: .75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;
    --sp-8: 4rem;
    --sp-9: 6rem;
    --sp-10: 8rem;

    /* Shape */
    --radius-sm: 4px;
    --radius:    8px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(20, 19, 15, .06);
    --shadow:    0 2px 6px rgba(20, 19, 15, .07), 0 12px 28px -18px rgba(20, 19, 15, .3);
    --shadow-lg: 0 4px 12px rgba(20, 19, 15, .08), 0 32px 64px -32px rgba(20, 19, 15, .38);

    /* Layout */
    --measure: 68ch;
    --wide:   1240px;
    --narrow: 820px;
    --gutter: clamp(1.15rem, 4vw, 3rem);
    --header-h: 66px;

    /* Motion */
    --ease: cubic-bezier(.22, .61, .36, 1);
    --fast: .16s;
    --slow: .4s;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
    --paper:       #100f0d;
    --surface:     #1a1916;
    --surface-2:   #232219;
    --inverse:     #f6f4ee;
    --inverse-ink: #14130f;

    --ink:         #f4f1e9;
    --ink-soft:    #d5d1c6;
    --ink-muted:   #a29d90;
    --ink-faint:   #928d80;   /* 5.8:1 on paper */

    --line:        rgba(244, 241, 233, .15);
    --line-strong: rgba(244, 241, 233, .32);

    --accent:      #ff6a35;
    --amber:       #ffb454;
    --gold:        #ffd479;
    --accent-ink:  #1a0d06;
    --accent-wash: rgba(255, 106, 53, .14);

    --dawn: linear-gradient(90deg, #e0451f 0%, #ff6a35 30%, #ffb454 68%, #ffd479 100%);
    --dawn-soft: linear-gradient(135deg, rgba(255,106,53,.18), rgba(255,212,121,.14));

    /* On a dark ground every stop of --dawn is 6.7:1 or better, so the text
       fill can be the full sunrise here. */
    --dawn-text: linear-gradient(90deg, #ff6a35 0%, #ffb454 60%, #ffd479 100%);

    --ok:        #5fc98a;
    --ok-wash:   rgba(95, 201, 138, .14);
    --warn:      #e8b45c;
    --warn-wash: rgba(232, 180, 92, .14);
    --bad:       #ff7a7a;
    --bad-wash:  rgba(255, 122, 122, .14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 2px 6px rgba(0, 0, 0, .4), 0 12px 28px -18px rgba(0, 0, 0, .8);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, .45), 0 32px 64px -32px rgba(0, 0, 0, .9);

    color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper:       #100f0d;
    --surface:     #1a1916;
    --surface-2:   #232219;
    --inverse:     #f6f4ee;
    --inverse-ink: #14130f;

    --ink:         #f4f1e9;
    --ink-soft:    #d5d1c6;
    --ink-muted:   #a29d90;
    --ink-faint:   #928d80;   /* 5.8:1 on paper */

    --line:        rgba(244, 241, 233, .15);
    --line-strong: rgba(244, 241, 233, .32);

    --accent:      #ff6a35;
    --amber:       #ffb454;
    --gold:        #ffd479;
    --accent-ink:  #1a0d06;
    --accent-wash: rgba(255, 106, 53, .14);

    --dawn: linear-gradient(90deg, #e0451f 0%, #ff6a35 30%, #ffb454 68%, #ffd479 100%);
    --dawn-soft: linear-gradient(135deg, rgba(255,106,53,.18), rgba(255,212,121,.14));

    /* On a dark ground every stop of --dawn is 6.7:1 or better, so the text
       fill can be the full sunrise here. */
    --dawn-text: linear-gradient(90deg, #ff6a35 0%, #ffb454 60%, #ffd479 100%);

    --ok:        #5fc98a;
    --ok-wash:   rgba(95, 201, 138, .14);
    --warn:      #e8b45c;
    --warn-wash: rgba(232, 180, 92, .14);
    --bad:       #ff7a7a;
    --bad-wash:  rgba(255, 122, 122, .14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 2px 6px rgba(0, 0, 0, .4), 0 12px 28px -18px rgba(0, 0, 0, .8);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, .45), 0 32px 64px -32px rgba(0, 0, 0, .9);

    color-scheme: dark;
}


/* ── Reset ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
    margin: 0;
    /* Column flex so .site-footer's margin-top:auto pins it to the bottom of
       short pages instead of floating mid-screen. */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.65;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol {
    margin: 0;
}

ul[class], ol[class] { list-style: none; padding: 0; }

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

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: .18em;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--sp-6) 0;
}

::selection {
    background: var(--accent);
    color: var(--accent-ink);
}


/* ── Typography ─────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -.022em;
    text-wrap: balance;
}

h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); letter-spacing: -.012em; }
h4 { font-size: var(--step-0); letter-spacing: 0; }

p { text-wrap: pretty; }

strong { font-weight: 700; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: .92em; }

kbd {
    display: inline-block;
    padding: .1em .45em;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: .82em;
    line-height: 1.5;
}

/* The small mono label that sits above most headings. */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .55em;
    font-family: var(--font-mono);
    font-size: var(--step--2);
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: var(--sp-4);
}

.eyebrow::before {
    content: "";
    width: 1.6em;
    height: 2px;
    border-radius: 2px;
    background: var(--dawn);
    flex: none;
}

.eyebrow--plain::before { display: none; }

.lead {
    font-size: var(--step-1);
    line-height: 1.5;
    color: var(--ink-soft);
    max-width: var(--measure);
}

.muted { color: var(--ink-muted); }
.mono  { font-family: var(--font-mono); }

/* Prose blocks: the only place where bare <p>/<ul> get vertical rhythm. */
.prose > * + * { margin-top: 1.1em; }
.prose h2 { margin-top: 2.2em; margin-bottom: .2em; }
.prose h3 { margin-top: 1.8em; margin-bottom: .1em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose p, .prose li { max-width: var(--measure); color: var(--ink-soft); }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li + li { margin-top: .45em; }
.prose a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
}
.prose a:hover { color: var(--accent); }


/* ── Layout ─────────────────────────────────────────────────────────────── */

.wrap {
    width: 100%;
    max-width: var(--wide);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.wrap--narrow { max-width: var(--narrow); }

.section { padding-block: clamp(3.5rem, 8vw, 7rem); }
.section--tight { padding-block: clamp(2.5rem, 5vw, 4rem); }

/* Standard page opener for every non-home page. */
.page-head {
    padding-block: clamp(2.75rem, 7vw, 5.5rem) clamp(1.75rem, 4vw, 3rem);
    border-bottom: 1px solid var(--line);
}

.page-head__title { max-width: 20ch; }

.page-head .lead { margin-top: var(--sp-4); }

.stack > * + * { margin-top: var(--sp-4); }

.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }

.cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: center;
}



/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
    --btn-bg: var(--ink);
    --btn-fg: var(--paper);
    --btn-border: var(--ink);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .6em;
    padding: .82em 1.6em;
    border: 1.5px solid var(--btn-border);
    border-radius: var(--radius-pill);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    font-weight: 500;
    letter-spacing: .04em;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--fast) var(--ease),
                background var(--fast) var(--ease),
                border-color var(--fast) var(--ease),
                color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active { transform: translateY(0); }

.btn--accent {
    --btn-bg: var(--accent);
    --btn-fg: var(--accent-ink);
    --btn-border: var(--accent);
}

.btn--ghost {
    --btn-bg: transparent;
    --btn-fg: var(--ink);
    --btn-border: var(--line-strong);
}

.btn--ghost:hover {
    --btn-border: var(--ink);
    background: var(--accent-wash);
}


.btn--on-dark {
    --btn-bg: transparent;
    --btn-fg: currentColor;
    --btn-border: currentColor;
}

.btn--sm { padding: .6em 1.1em; font-size: var(--step--2); }
.btn--block { width: 100%; }

.btn[disabled], .btn[aria-disabled="true"] {
    opacity: .5;
    pointer-events: none;
}

/* Text link with an arrow that nudges on hover. */
.link {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1.5px solid var(--accent);
    padding-bottom: .15em;
    transition: color var(--fast) var(--ease), gap var(--fast) var(--ease);
}

.link:hover { color: var(--accent); gap: .75em; }
.link__arrow { transition: transform var(--fast) var(--ease); }
.link:hover .link__arrow { transform: translateX(2px); }


/* ── Forms ──────────────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: var(--sp-5); }

.field__label {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--step--2);
    font-weight: 500;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: var(--sp-2);
}

.field__req { color: var(--accent); }

.field__help {
    display: block;
    margin-top: var(--sp-2);
    font-size: var(--step--1);
    color: var(--ink-muted);
}

.field__error {
    display: block;
    margin-top: var(--sp-2);
    font-size: var(--step--1);
    font-weight: 500;
    color: var(--bad);
}

.input,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
    width: 100%;
    padding: .78em 1em;
    background: var(--surface);
    color: var(--ink);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: var(--step-0);
    transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.field textarea { resize: vertical; min-height: 8rem; line-height: 1.6; }

.field select {
    appearance: none;
    /* Chevron drawn inline so the CSP does not need an extra image host. */
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 1.15em) 55%, calc(100% - .8em) 55%;
    background-size: .38em .38em, .38em .38em;
    background-repeat: no-repeat;
    padding-right: 2.5em;
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.field--invalid input,
.field--invalid select,
.field--invalid textarea {
    border-color: var(--bad);
}

::placeholder { color: var(--ink-faint); opacity: 1; }

/* Honeypot: off-screen rather than display:none, which some bots skip. */
.honeypot {
    position: absolute !important;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}


/* ── Notices ────────────────────────────────────────────────────────────── */

.notice {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border: 1px solid var(--line);
    border-left: 3px solid var(--ink-muted);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: var(--step--1);
}

.notice__icon { flex: none; font-size: 1.1em; line-height: 1.4; }

.notice--success { border-left-color: var(--ok); background: var(--ok-wash); }
.notice--error, .notice--danger { border-left-color: var(--bad); background: var(--bad-wash); }
.notice--warning { border-left-color: var(--warn); background: var(--warn-wash); }
.notice--info { border-left-color: var(--accent); background: var(--accent-wash); }


/* ── Small pieces ───────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    padding: .3em .8em;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: var(--step--2);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.badge--accent {
    border-color: transparent;
    background: var(--accent);
    color: var(--accent-ink);
}

.badge--live::before {
    content: "";
    width: .5em;
    height: .5em;
    border-radius: 50%;
    background: currentColor;
    animation: kk-pulse 2s var(--ease) infinite;
}

@keyframes kk-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .25; }
}



/* ── Accessibility ──────────────────────────────────────────────────────── */

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: var(--sp-4);
    z-index: 200;
    padding: .7em 1.2em;
    background: var(--ink);
    color: var(--paper);
    border-radius: 0 0 var(--radius) var(--radius);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    text-decoration: none;
}

.skip-link:focus { top: 0; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2.5px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}


/* ── Reveal-on-scroll ───────────────────────────────────────────────────── */
/* Content is visible by default. site.js hides it only after it has an
   IntersectionObserver actually watching, by putting .reveal-armed on <html>,
   and drops that class again on a failsafe timer. So every route to this code
   failing — no JS, no observer, an observer that never fires — ends with the
   page readable rather than blank. */

.reveal-armed [data-reveal] {
    opacity: 0;
    transform: translateY(18px);
}

[data-reveal] {
    transition: opacity .6s var(--ease), transform .6s var(--ease);
    transition-delay: var(--reveal-delay, 0ms);
}

.reveal-armed [data-reveal].is-revealed {
    opacity: 1;
    transform: none;
}

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

    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    .reveal-armed [data-reveal] { opacity: 1; transform: none; }
}


/* ── Print ──────────────────────────────────────────────────────────────── */

@media print {
    .site-header, .site-footer, .btn, .theme-toggle { display: none !important; }
    body { background: #fff; color: #000; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; }
}
