/* A LaTeX file in the editor (static/js/tex-page.js): its toolbar, the
   compiled-PDF pane (static/js/pdf-view.js), the problems list and the log;
   and the shared views' PDF/source tabs. Tokens only (docs/theming.md). */

/* ── The toolbar, in the editor header ──
   One row of controls that never come and go (tex-page.js _toolbar), so
   nothing in the header moves as a compile runs or a file is opened. */

.kind-toolbar.tex-toolbar { gap: 0.15rem; overflow: visible; flex-wrap: nowrap; }
.tex-toolbar button { font-family: var(--font-ui); }
.tex-tb-sep { width: 1px; height: 16px; margin: 0 0.3rem; background: var(--border-3); flex-shrink: 0; }

/* Recompile with Auto attached: one control, two halves. */
.tex-compile { display: inline-flex; flex-shrink: 0; height: 28px; }
.tex-recompile, .tex-auto {
    display: inline-flex; align-items: center; height: 100%; border: 1px solid var(--accent);
    cursor: pointer; white-space: nowrap; font-size: 0.8rem;
}
.tex-recompile {
    gap: 0.35rem; padding: 0 0.6rem; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    background: var(--accent); color: var(--text-inverse); font-weight: 600;
}
.tex-recompile:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.tex-auto {
    padding: 0 0.45rem; border-left: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--surface-1); color: var(--text-5); font-size: 0.7rem; font-weight: 600;
    letter-spacing: 0.02em;
}
.tex-auto:hover { color: var(--text-1); background: var(--surface-4); }
.tex-auto[aria-pressed="true"] { background: var(--accent-wash-2); color: var(--accent-deep); }
.tex-auto[aria-pressed="true"]:hover { background: var(--accent-wash-3); }
.tex-recompile:disabled { background: var(--accent-disabled); border-color: var(--accent-disabled); cursor: default; }
.tex-recompile:disabled + .tex-auto { border-color: var(--accent-disabled); }
.tex-recompile.is-running svg { animation: tex-pulse 1s ease-in-out infinite; }
@keyframes tex-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) {
    .tex-recompile.is-running svg { animation: none; }
}
/* A narrow window: Recompile keeps its icon and tooltip. */
@media (max-width: 960px) {
    .tex-recompile > span { display: none; }
    .tex-recompile { padding: 0 0.55rem; }
}

.tex-fmt b, .tex-fmt i { font-family: var(--font-reading); font-size: 0.95rem; }
.tex-toolbar .toolbar-btn:disabled { opacity: 0.35; cursor: default; background: none; }
.tex-menu { position: relative; flex-shrink: 0; }
.tex-menu-btn { display: inline-flex; align-items: center; gap: 1px; }
.tex-menu:has(> .tex-menu-list:not(.hidden)) > .tex-menu-btn { background: var(--surface-5); color: var(--text-1); }
.tex-caret { font-size: 0.55rem; color: var(--text-6); }
.tex-menu-list {
    left: 0; right: auto; max-height: 60vh; overflow-y: auto; min-width: 220px;
}
.tex-menu-list button:disabled { color: var(--text-6); cursor: default; background: none; }
/* A choice in the ⋯ menu: a check column, ticked on the current one. */
.tex-menu-list button[role="menuitemradio"] { position: relative; padding-left: 1.7rem; }
.tex-menu-list button[aria-checked="true"]::before {
    content: '✓'; position: absolute; left: 0.65rem; color: var(--accent);
}
.tex-menu-list button[aria-checked="true"]:disabled { color: var(--text-3); }
.tex-menu-note {
    padding: 0.15rem 0.75rem 0.35rem; font-size: 0.78rem; color: var(--text-4);
    max-width: 18rem; overflow-wrap: anywhere;
}
.tex-menu-path { font-family: var(--font-mono); color: var(--text-2); }

/* ── The output pane ── */

.tex-output { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.tex-output-bar {
    display: flex; align-items: center; gap: 0.4rem; flex: none;
    padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--border-2);
    background: var(--surface-2); font-family: var(--font-ui); font-size: 0.75rem;
}
.tex-spacer { flex: 1 1 auto; }
/* The file the PDF is of (the main file): its name, the path in the tooltip. */
.tex-pdf-name {
    flex: 0 1 auto; min-width: 0; max-width: 12rem; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-family: var(--font-mono); color: var(--text-3);
}
.tex-pdf-name:empty { display: none; }
.tex-status { color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tex-status::before {
    content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 0.35rem;
    border-radius: var(--radius-pill); background: var(--text-7); vertical-align: 0;
}
.tex-status[data-state="ok"]::before { background: var(--success); }
.tex-status[data-state="warning"]::before { background: var(--warning-vivid); }
.tex-status[data-state="error"]::before, .tex-status[data-state="failed"]::before { background: var(--danger-vivid); }
.tex-status[data-state="running"]::before { background: var(--accent); animation: tex-pulse 1s ease-in-out infinite; }
.tex-status[data-state="stale"] { color: var(--text-6); }
.tex-status[data-state="failed"] { color: var(--danger); white-space: normal; }
.tex-issues-toggle {
    flex-shrink: 0; padding: 1px 8px; border-radius: var(--radius-pill); cursor: pointer;
    border: 1px solid var(--border-4); background: var(--surface-1); color: var(--text-3);
    font-size: 0.72rem; font-family: var(--font-ui);
}
.tex-issues-toggle[data-level="error"] { border-color: var(--danger-border); color: var(--danger); background: var(--danger-bg); }
.tex-issues-toggle[data-level="warning"] { border-color: var(--warning-border); color: var(--warning-text); background: var(--warning-bg); }
.tex-issues-toggle.hidden { display: none; }
.tex-bar-btn {
    flex-shrink: 0; min-width: 24px; height: 22px; padding: 0 0.35rem;
    border: 1px solid transparent; border-radius: var(--radius-xs);
    background: none; color: var(--text-4); cursor: pointer; font-size: 0.75rem;
}
.tex-bar-btn:hover { background: var(--surface-5); color: var(--text-1); }
.tex-bar-btn.active { background: var(--surface-6); color: var(--text-1); }
.tex-zoom { min-width: 3rem; font-variant-numeric: tabular-nums; }

.tex-issues {
    flex: 0 0 auto; max-height: 40%; overflow-y: auto;
    border-bottom: 1px solid var(--border-3); background: var(--surface-1);
}
.tex-issues.hidden, .tex-log.hidden { display: none; }
.tex-issue { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border-1); border-left: 3px solid var(--text-7); }
.tex-issue[data-level="error"] { border-left-color: var(--danger-vivid); }
.tex-issue[data-level="warning"] { border-left-color: var(--warning-vivid); }
.tex-issue[data-level="box"] { border-left-color: var(--border-5); }
.tex-issue-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; font-size: 0.78rem; }
.tex-issue-level { font-weight: 600; color: var(--text-3); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tex-issue[data-level="error"] .tex-issue-level { color: var(--danger); }
.tex-issue[data-level="warning"] .tex-issue-level { color: var(--warning-text); }
.tex-issue-where {
    font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-4);
    border: none; background: none; padding: 0;
}
button.tex-issue-where { color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.tex-issue-message { color: var(--text-1); overflow-wrap: anywhere; }
.tex-issue-context {
    margin: 0.25rem 0 0; padding: 0.3rem 0.45rem; border-radius: var(--radius-xs);
    background: var(--surface-3); color: var(--text-3);
    font-family: var(--font-mono); font-size: 0.72rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.tex-log {
    flex: 0 0 auto; max-height: 45%; margin: 0; overflow: auto;
    padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border-3);
    background: var(--surface-2); color: var(--text-2);
    font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.45; white-space: pre-wrap;
}

.tex-pdf { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.tex-empty {
    margin: auto; padding: 2rem 1.5rem; max-width: 26rem; text-align: center;
    color: var(--text-5); font-family: var(--font-ui); font-size: 0.85rem; line-height: 1.5;
}
.tex-empty.hidden { display: none; }
.tex-empty p { margin: 0 0 0.8rem; }
.tex-empty-download {
    display: inline-block; padding: 0.35rem 0.9rem; border: 1px solid var(--border-3);
    border-radius: var(--radius-pill); background: var(--surface-1); color: var(--text-1);
    text-decoration: none; font-size: 0.82rem;
}
.tex-empty-download:hover { background: var(--accent-wash-2); border-color: var(--accent-light); }

/* ── The PDF itself (PdfView) ── */

.pdf-view {
    flex: 1 1 auto; min-height: 0; overflow: auto; outline: none;
    background: var(--surface-4); padding: 12px 0;
}
.pdf-view.is-empty { display: none; }
.pdf-view-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: min-content; padding: 0 12px; }
.pdf-page {
    position: relative; flex: none; background: var(--surface-1);
    box-shadow: 0 1px 4px var(--shadow-2);
}
/* pdf.js paints the paper itself, white in either theme, as Overleaf's is. */
.pdf-page canvas { display: block; }
.pdf-link { position: absolute; display: block; }
.pdf-link:hover { background: var(--accent-wash-1); outline: 1px solid var(--accent-light); }

/* ── The shared views ── */

.tex-shared-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.6rem; }
.tex-shared-tabs.hidden, .tex-shared-pdf.hidden, .tex-shared-source.hidden { display: none; }
.tex-shared-tab {
    padding: 0.3rem 0.8rem; border: 1px solid var(--border-3); border-radius: var(--radius-pill);
    background: var(--surface-1); color: var(--text-3); cursor: pointer;
    font-family: var(--font-ui); font-size: 0.82rem;
}
.tex-shared-tab.active { background: var(--accent-wash-2); border-color: var(--accent-light); color: var(--text-1); }
.tex-shared-pdf {
    display: flex; flex-direction: column; height: 82vh;
    border: 1px solid var(--border-3); border-radius: var(--radius-md); overflow: hidden;
}
