/* A Lean page (kind 'lean'): its toolbar, its output pane (verdict, goals at
   the cursor, messages, sorries, declarations), its insertion menus, and the
   unicode-input underline. Built by static/js/lean-page.js; tokens only
   (docs/theming.md). See docs/lean.md § Lean pages. */

/* ── Toolbar ── */

.lean-toolbar {
    display: flex; align-items: center; gap: 0.15rem; min-width: 0; position: relative;
}
.lean-toolbar button { font-family: var(--font-ui); }
.lean-tb-check {
    display: inline-flex; align-items: center; gap: 0.3rem; height: 26px; padding: 0 0.6rem;
    border: 1px solid var(--accent); border-radius: var(--radius-sm);
    background: var(--accent); color: var(--text-inverse); font-size: 0.78rem; font-weight: 600;
    cursor: pointer; flex-shrink: 0;
}
.lean-tb-check:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.lean-tb-check:disabled { background: var(--surface-4); border-color: var(--border-4); color: var(--text-6); cursor: default; }
.lean-tb-check.is-running { background: var(--accent-wash-2); border-color: var(--accent-light); color: var(--accent-deep); }
.lean-tb-auto, .lean-tb-menu {
    height: 26px; padding: 0 0.45rem; border: 1px solid transparent; border-radius: var(--radius-sm);
    background: none; color: var(--text-4); font-size: 0.78rem; cursor: pointer; flex-shrink: 0;
    white-space: nowrap;
}
.lean-tb-auto:hover, .lean-tb-menu:hover, .lean-tb-menu[aria-expanded="true"] {
    background: var(--surface-5); color: var(--text-1);
}
.lean-tb-auto[aria-pressed="true"] {
    color: var(--accent-deep); background: var(--accent-wash-2); border-color: var(--accent-light);
}
.lean-tb-menu { font-family: var(--font-mono); }
.lean-tb-caret { font-size: 0.6rem; color: var(--text-6); }
.lean-tb-sep { width: 1px; height: 16px; margin: 0 0.25rem; background: var(--border-3); flex-shrink: 0; }
.lean-toolbar .toolbar-btn:disabled { opacity: 0.4; cursor: default; background: none; }

/* The insertion menus: fixed under their button, so the header's layout
   never clips them. */
.lean-menu {
    position: fixed; z-index: 1000; max-height: min(70vh, 30rem); overflow: auto;
    min-width: 12rem; max-width: 19rem; padding: 0.35rem;
    background: var(--surface-1); color: var(--text-1);
    border: 1px solid var(--border-3); border-radius: var(--radius-md);
    box-shadow: 0 4px 16px var(--shadow-3);
    font-family: var(--font-ui); font-size: 0.8rem;
}
.lean-menu-group + .lean-menu-group { margin-top: 0.35rem; }
.lean-menu-head {
    padding: 0.2rem 0.35rem; font-size: 0.66rem; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-5);
}
.lean-sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(1.9rem, 1fr)); gap: 2px; }
.lean-sym {
    height: 1.9rem; border: none; border-radius: var(--radius-xs); background: none;
    color: var(--text-1); font-family: var(--font-mono); font-size: 0.95rem; cursor: pointer;
}
.lean-sym:hover, .lean-sym:focus-visible { background: var(--accent-wash-2); outline: none; }
.lean-menu-row {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; width: 100%;
    padding: 0.25rem 0.45rem; border: none; border-radius: var(--radius-xs); background: none;
    color: var(--text-1); text-align: left; cursor: pointer;
}
.lean-menu-row:hover, .lean-menu-row:focus-visible { background: var(--accent-wash-2); outline: none; }
.lean-menu-row code { font-family: var(--font-mono); font-size: 0.8rem; background: none; padding: 0; }
.lean-menu-note { font-size: 0.66rem; color: var(--text-6); }

/* ── Unicode input: the abbreviation being typed ── */

.lean-abbrev { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }

/* ── Output pane ── */

.lean-out {
    flex: 1 1 auto; min-height: 0; padding: 0.75rem 1rem 1.5rem; outline: none;
    font-family: var(--font-ui); font-size: 0.85rem; color: var(--text-1); line-height: 1.5;
}
.lean-out-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; min-height: 1.6rem; }
.lean-verdict {
    padding: 0.1rem 0.55rem; border-radius: var(--radius-pill);
    font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600;
    color: var(--text-2); background: var(--surface-4);
}
.lean-verdict.is-proved { color: var(--success-deep); background: var(--success-bg); }
.lean-verdict.is-incomplete { color: var(--warning-deep); background: var(--warning-bg); }
.lean-verdict.is-failed, .lean-verdict.is-error { color: var(--danger-deep); background: var(--danger-bg); }
.lean-out-meta { color: var(--text-5); font-size: 0.78rem; }
/* A solid block, the warning pair inverted, at the row's right end. */
.lean-out-stale {
    margin-left: auto; padding: 0.1rem 0.5rem; border-radius: 0;
    color: var(--warning-bg); background: var(--warning-deep);
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.lean-out.is-stale .lean-verdict, .lean-out.is-stale .lean-sec { opacity: 0.6; }
.lean-out-running { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--accent-deep); font-size: 0.78rem; }
.lean-out-running[hidden], .lean-out-stale[hidden] { display: none; }
.lean-spinner {
    width: 11px; height: 11px; border: 2px solid var(--accent-wash-3); border-top-color: var(--accent);
    border-radius: 50%; animation: lean-spin 0.8s linear infinite;
}
@keyframes lean-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lean-spinner { animation: none; } }
.lean-out-gloss { margin: 0.35rem 0 0; color: var(--text-3); font-size: 0.8rem; }
.lean-out-gloss code, .lean-goals code, .lean-sec-title code {
    font-family: var(--font-mono); font-size: 0.92em; background: none; padding: 0;
}
.lean-out-hint { margin: 0.6rem 0; color: var(--text-4); }
.lean-out-error {
    margin: 0.6rem 0; padding: 0.45rem 0.6rem; border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm); background: var(--danger-bg); color: var(--danger-deep);
    white-space: pre-wrap; overflow-wrap: anywhere;
}

/* The goals at the cursor: the pane's live part, so it gets a box. */
.lean-goals {
    margin: 0.75rem 0 0.5rem; border: 1px solid var(--border-3); border-radius: var(--radius-md);
    background: var(--surface-2);
}
.lean-goals-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
    padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border-2);
    font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4);
}
.lean-goals-where { font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text-6); font-size: 0.72rem; }
.lean-goals-body { padding: 0.45rem 0.6rem 0.55rem; }
.lean-goals-before { color: var(--text-4); font-size: 0.75rem; margin-bottom: 0.3rem; overflow-wrap: anywhere; }
.lean-goal {
    margin: 0 0 0.4rem; padding: 0.4rem 0.55rem; border-radius: var(--radius-sm);
    background: var(--surface-1); border: 1px solid var(--border-2);
    font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.45; color: var(--text-1);
    white-space: pre; overflow-x: auto;
}
.lean-goals-none, .lean-goals-note { margin: 0.2rem 0; color: var(--text-5); font-size: 0.78rem; }
.lean-goals-done { margin: 0.2rem 0; color: var(--success-deep); font-weight: 600; font-size: 0.8rem; }
.lean-goals-msgs { margin-top: 0.4rem; }

/* Sections: errors, warnings, info, sorries, declarations. */
.lean-sec { margin-top: 0.6rem; }
.lean-sec-head {
    display: flex; align-items: center; gap: 0.35rem; width: 100%; padding: 0.2rem 0;
    border: none; background: none; cursor: pointer; font-family: inherit;
    font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4);
}
.lean-sec-head:hover { color: var(--text-2); }
.lean-sec-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--radius-xs); }
.lean-sec-chevron { transition: transform 0.18s ease; }
.lean-sec.is-open .lean-sec-chevron { transform: rotate(90deg); }
.lean-sec-title code { text-transform: none; letter-spacing: 0; }
.lean-sec-count { font-weight: 500; letter-spacing: 0.02em; text-transform: none; color: var(--text-5); }
.lean-sec-body { display: none; padding-left: 0.2rem; }
.lean-sec.is-open .lean-sec-body { display: block; }
.lean-item { margin: 0.35rem 0 0.55rem; }
.lean-item pre {
    margin: 0.15rem 0 0; font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.45;
    white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-1);
}
.lean-item--error { border-left: 3px solid var(--danger); padding-left: 0.5rem; }
.lean-item--warning { border-left: 3px solid var(--warning); padding-left: 0.5rem; }
.lean-item--info { border-left: 3px solid var(--border-5); padding-left: 0.5rem; }
.lean-item .lean-goal { white-space: pre; overflow-wrap: normal; }
.lean-loc {
    padding: 0; border: none; background: none; cursor: pointer;
    font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent-deep);
}
.lean-loc:hover { text-decoration: underline; }
.lean-loc:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--radius-xs); }
.lean-decl { margin: 0.2rem 0; font-size: 0.8rem; overflow-wrap: anywhere; }
.lean-decl code { font-family: var(--font-mono); font-size: 0.8rem; background: none; padding: 0; }
.lean-clean { color: var(--text-5); }
.lean-dirty { color: var(--warning-deep); }

/* On a shared view the result sits under the read-only source. */
.lean-out--shared {
    margin-top: 1rem; padding: 0.75rem 1rem 1rem; border: 1px solid var(--border-3);
    border-radius: var(--radius-md); background: var(--surface-1);
}
