/* Custom utilities and the prose treatment for semql.org.
   Design tokens live in scripts/tailwind/input.css; this file is where they are
   composed into the handful of things Tailwind utilities express badly. */

/* ---------------------------------------------------------------------------
   Theme surface
   Tokens resolve through these variables so a single [data-theme] attribute or
   the OS preference switches the whole page without duplicating every rule.
   --------------------------------------------------------------------------- */
:root {
    --paper: #edeee9;
    --surface: #ffffff;
    --ink: #12131a;
    --ink-muted: #5a5f6b;
    --accent: #e9542f;
    --attract: #1d7a5f;
    --repel: #8b1e3f;
    --band-sand: #e8e4d9;
    --band-steel: #d9e4e8;
    --code-surface: #161a22;
    --code-ink: #e6e4dd;

    --border-w: 1.5px;
    --shadow-hard: 3px 3px 0 0 var(--ink);
    --shadow-hard-sm: 2px 2px 0 0 var(--ink);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --paper: #12141a;
        --surface: #1a1d25;
        --ink: #edeee9;
        --ink-muted: #9ca3af;
        --accent: #ff7a52;
        --attract: #4fbf98;
        --repel: #d96a87;
        --band-sand: #232019;
        --band-steel: #1a2226;
    }
}

:root[data-theme='dark'] {
    --paper: #12141a;
    --surface: #1a1d25;
    --ink: #edeee9;
    --ink-muted: #9ca3af;
    --accent: #ff7a52;
    --attract: #4fbf98;
    --repel: #d96a87;
    --band-sand: #232019;
    --band-steel: #1a2226;
}

html {
    background: var(--paper);
    color: var(--ink);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans, 'IBM Plex Sans', system-ui, sans-serif);
    line-height: 1.6;
}

h1,
h2,
h3 {
    font-family: var(--font-display, 'Bricolage Grotesque', system-ui, sans-serif);
    font-weight: 700;
    letter-spacing: -0.015em;
}

/* Never removed, only restyled. A focus ring is the entire keyboard interface;
   :focus-visible keeps it off mouse clicks so there is no reason to suppress it. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a {
    color: var(--accent);
    text-underline-offset: 0.15em;
}

/* ---------------------------------------------------------------------------
   Hard-edged surfaces
   The shared structural language with noetive.io: visible border, zero-blur
   offset shadow, generous radius.
   --------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: var(--border-w) solid var(--ink);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-hard);
}

/* The press: the element moves toward its own shadow and the shadow shortens,
   as if pushed into the page. This replaces noetive.io's hover-tilt and its
   animated rainbow shadow — a 3s infinite animation is wrong on a page someone
   reads for twenty minutes. */
.press {
    transition:
        transform 120ms ease-out,
        box-shadow 120ms ease-out;
}

.press:hover {
    transform: translate(1px, 1px);
    box-shadow: var(--shadow-hard-sm);
}

.press:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    .press {
        transition: none;
    }

    .press:hover,
    .press:active {
        transform: none;
        box-shadow: var(--shadow-hard);
    }
}

/* Section bands. Used sparingly to separate a page into readable stretches. */
.band-sand {
    background: var(--band-sand);
}

.band-steel {
    background: var(--band-steel);
}

/* The dark callout band, noetive.io's `blackboard` retuned. */
.slab {
    background: var(--code-surface);
    color: var(--code-ink);
    border: var(--border-w) solid var(--ink);
    border-radius: 0.5rem;
}

/* Clause badges. attract/repel are the language's own geometry, so they carry
   the only two colours on the site that are not accent or ink — and they appear
   nowhere except badges and diagrams. */
.badge {
    display: inline-block;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.1rem 0.4rem;
    border: var(--border-w) solid currentColor;
    border-radius: 0.25rem;
}

.badge-attract {
    color: var(--attract);
}

.badge-repel {
    color: var(--repel);
}

/* ---------------------------------------------------------------------------
   Navigation
   --------------------------------------------------------------------------- */
.nav-bar {
    background: var(--surface);
    border-bottom: var(--border-w) solid var(--ink);
}

.nav-item {
    color: var(--ink);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--band-sand);
}

.nav-item[data-current] {
    color: var(--accent);
    font-weight: 600;
}

.sidebar-link {
    display: block;
    padding: 0.2rem 0.6rem;
    border-left: var(--border-w) solid transparent;
    color: var(--ink-muted);
    text-decoration: none;
}

.sidebar-link:hover {
    color: var(--ink);
    border-left-color: var(--ink);
}

.sidebar-link[data-current] {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Prose
   noetive.io's prose-blog, retuned. Applied to generator-rendered markdown, so
   every selector here has to work without a class on the element itself.
   --------------------------------------------------------------------------- */
.prose-docs {
    max-width: 68ch;
}

.prose-docs h2 {
    font-size: 1.5rem;
    margin: 2.5rem 0 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: var(--border-w) solid var(--ink);
}

.prose-docs h3 {
    font-size: 1.15rem;
    margin: 1.75rem 0 0.5rem;
}

.prose-docs h2:first-child,
.prose-docs h3:first-child {
    margin-top: 0;
}

.prose-docs p {
    margin: 0 0 1rem;
}

.prose-docs ul,
.prose-docs ol {
    margin: 0 0 1rem 1.25rem;
}

.prose-docs ul {
    list-style: disc;
}

.prose-docs ol {
    list-style: decimal;
}

.prose-docs li {
    margin-bottom: 0.35rem;
}

.prose-docs blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--ink-muted);
}

.prose-docs code {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.875em;
    background: var(--band-steel);
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
}

.prose-docs pre {
    position: relative;
    background: var(--code-surface);
    color: var(--code-ink);
    padding: 1rem 1.25rem;
    border: var(--border-w) solid var(--ink);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-hard-sm);
    overflow-x: auto;
    margin: 0 0 1.5rem;
}

.prose-docs pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.875rem;
    line-height: 1.65;
}

/* The language label. data-language is written on every <pre> by the generator,
   including for unlabelled fences, so there is one shape to target — the :empty
   guard is what keeps the corner clean when the fence had no info string. */
.prose-docs pre[data-language]:not([data-language=''])::after {
    content: attr(data-language);
    position: absolute;
    top: 0.4rem;
    right: 0.6rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.prose-docs table {
    width: 100%;
    margin: 0 0 1.5rem;
    border: var(--border-w) solid var(--ink);
    border-radius: 0.5rem;
    border-collapse: collapse;
    overflow: hidden;
}

.prose-docs th,
.prose-docs td {
    padding: 0.4rem 0.7rem;
    border-bottom: 1px solid var(--ink-muted);
    text-align: left;
}

.prose-docs th {
    background: var(--band-sand);
    font-weight: 600;
}

.prose-docs tr:last-child td {
    border-bottom: none;
}

.prose-docs hr {
    margin: 2rem 0;
    border: none;
    border-top: var(--border-w) solid var(--ink);
}

/* ---------------------------------------------------------------------------
   SemQL syntax tokens
   Emitted by internal/adapters/semqlsource from the parser's own lexer, so this
   list is the token set the language actually has rather than a guess.
   --------------------------------------------------------------------------- */
.tok-keyword {
    color: #ff8f6b;
    font-weight: 600;
}

.tok-clause {
    color: #7cc2ec;
    font-weight: 600;
}

.tok-string {
    color: #9ed49a;
}

.tok-number {
    color: #e9c46a;
}

.tok-punct {
    color: #9aa1ad;
}

.tok-ident {
    color: var(--code-ink);
}
