/* Page kinds: code pages (.tex, .lean) in the editor, the sidebar's kind
   icons and status marks, the "+ New" menu, and a code page's read-only source
   on the shared views. Tokens only (docs/theming.md). See static/js/page-kinds.js
   and docs/document_view.md § Code pages. */

/* ── The editor: a code page swaps the markdown pieces for its kind's ── */

.kind-toolbar, .kind-editor-host, .kind-output-host { display: none; }

.editor-panel.is-code-page .toolbar-left { display: none; }
/* A kind's toolbar is one row that keeps its size: a second row made the
   header jump as controls came and went. The title field (the file name,
   and how a code page is renamed) gives way instead, down to its minimum.
   (Not a size container: that can make the header a containing block for
   the Lean toolbar's position:fixed menus.) */
.editor-panel.is-code-page .kind-toolbar {
    display: flex; align-items: center; gap: 0.2rem; flex-shrink: 0; min-width: 0;
}
.editor-panel.is-code-page .editor-header > .kind-toolbar { flex: none; flex-wrap: nowrap; }
.editor-panel.is-code-page .editor-header > .doc-title-input { min-width: 7rem; }
/* A narrow window: the file name gives up more room, so the toolbar and the
   header's right-hand controls still fit beside it. */
@media (max-width: 1000px) {
    .editor-panel.is-code-page .editor-header > .doc-title-input { min-width: 4.5rem; }
}
.editor-panel.is-code-page .editor-input-pane > .editor-scroll-wrapper { display: none; }
.editor-panel.is-code-page .kind-editor-host {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0;
    overflow: hidden;
}
.editor-panel.is-code-page #preview-pane { display: none; }
.editor-panel.is-code-page .kind-output-host {
    display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; min-height: 0;
    overflow: auto; outline: none; background: var(--surface-1);
}
.kind-output-host:focus { box-shadow: inset 0 2px 0 0 var(--accent); }
/* The preview's −/+ sizes rendered markdown; an output pane brings its own
   controls. The scroll-sync toggle has no preview to follow. */
.editor-panel.is-code-page .preview-pane-wrap > .pane-font-control,
.editor-panel.is-code-page .scroll-sync-toggle { display: none; }

.kind-editor-host .cm-editor { flex: 1 1 auto; min-height: 0; }
/* The pane's focus line (style.css draws it as an inset shadow, which the
   editor's own background would cover): drawn over the editor instead. */
.editor-panel.is-code-page .editor-input-pane:focus-within::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--accent); z-index: 6; pointer-events: none;
}
.kind-editor-host .cm-scroller { overflow: auto; }
/* The editor's floating −/+ would sit on the search panel's buttons. */
.editor-panel.is-code-page .editor-input-pane:has(.cm-panels-bottom) > .pane-font-control { display: none; }
.code-editor-loading {
    padding: 1rem; color: var(--text-5); font-family: var(--font-ui); font-size: 0.85rem;
}
/* The download menu's per-kind rows sit with the markdown ones they replace. */
.download-kind-item { white-space: nowrap; }

/* ── The sidebar ── */

.page-kind-icon {
    display: inline-flex; align-items: center; justify-content: center;
    flex: none; width: 14px; height: 14px; color: var(--sb-text-faint);
}
.page-kind-icon svg { display: block; }
.page-item.active .page-kind-icon { color: var(--sb-text-mid); }
.page-kind-icon--tex, .page-kind-icon--lean { color: var(--sb-text-soft); }

/* A run's outcome (a kind's statusMark hook): a dot, or a short word. */
.page-kind-status {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    min-width: 8px; height: 8px; border-radius: var(--radius-pill);
    background: var(--sb-text-dimmest); font-size: 0.62rem; line-height: 1;
}
.page-kind-status:not(:empty) {
    height: auto; padding: 1px 5px; background: none; color: var(--sb-text-dim);
    border: 1px solid var(--sb-border-strong);
}
.page-kind-status[data-state="ok"] { background: var(--success); }
.page-kind-status[data-state="error"] { background: var(--danger-vivid); }
.page-kind-status[data-state="warning"] { background: var(--warning-vivid); }
.page-kind-status[data-state="running"] {
    background: var(--sb-accent); animation: page-kind-pulse 1.2s ease-in-out infinite;
}
.page-kind-status[data-state="stale"] { background: var(--sb-text-dimmest); }
.page-kind-status[data-state="ok"]:not(:empty) { background: none; color: var(--success); border-color: var(--success); }
.page-kind-status[data-state="error"]:not(:empty) { background: none; color: var(--danger-vivid); border-color: var(--danger-vivid); }
.page-kind-status[data-state="warning"]:not(:empty) { background: none; color: var(--warning-vivid); border-color: var(--warning-vivid); }
@keyframes page-kind-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
    .page-kind-status[data-state="running"] { animation: none; }
}

/* The "+ New" menu and a page folder's menu: icon, then the kind's name. */
.context-menu .new-kind-row {
    display: flex; align-items: center; gap: 0.5rem; white-space: nowrap;
}
.context-menu .new-kind-row .page-kind-icon { color: var(--text-5); }

/* ── The shared views: a code page as read-only, highlighted source ── */

.code-source-view {
    border: 1px solid var(--border-3); border-radius: var(--radius-md);
    overflow: hidden; background: var(--surface-1);
}
.code-source-view .cm-editor { height: auto; }
.code-source-fallback {
    margin: 0; padding: 0.8rem; white-space: pre-wrap; font-family: var(--font-mono);
    font-size: 0.9em; color: var(--text-1); background: var(--surface-2);
}
