/* Journal entry typography — ONE stylesheet for the web composer and the
 * web read view (modal + timeline). Scoped to the three surfaces that render
 * a journal entry on web; nothing else on the page changes.
 *
 * Why this exists (2026-09-05): the "font size" preference was implemented as
 * H1/H2/H3 applied to every line, so entries were written entirely in
 * headings and a list line (which drops the heading) came out a different
 * size from the text around it. Body size is now a real CSS variable, headings
 * are headings again, and lists share one gutter so bullet, number and
 * checkbox text all start at the same x.
 *
 * Quill 2 list markup: <ol><li data-list="bullet|ordered|checked|unchecked">
 *   <span class="ql-ui"></span>text</li></ol>, nesting via li.ql-indent-N.
 * The marker is drawn on .ql-ui so the composer and the read view use the
 * exact same HTML and the exact same rules.
 *
 * Body size = 18px × --reading-scale, the same S/M/L/XL the user already
 * picks with the Aa control on the reading surfaces and in Settings. The old
 * "font size" preference (a heading level; column default 1) sets nothing.
 *
 * `.journal-prose` is stamped by common_journal_modal.js on every surface that
 * renders an entry on web: the composer, the modal journal tab, the timeline
 * bubbles and the read-only Quill instances.
 */

:root {
    --journal-font-size: 18px;
    --journal-serif: Palatino, 'Palatino Linotype', 'Book Antiqua', 'Noto Serif TC', Georgia, serif;
    --journal-measure: 64ch;
    --journal-marker: var(--button-bg, #8b5cf6); /* skin.js sets --button-bg per theme: purple, brown in Zen Garden */
    /* One OPAQUE highlight per theme, mixed from the accent and the theme's
       solid input surface, so a highlight is the same colour in the composer,
       the entry modal and the timeline instead of a tint over three grounds. */
    --journal-highlight: color-mix(in srgb, var(--journal-marker) 24%, var(--input-bg, #ffffff));
}

/* ---------- surface ---------- */
.journal-prose {
    font-family: var(--journal-serif);
    /* the Aa reading-size control (reading_scale.js) scales the composer too */
    font-size: calc(var(--journal-font-size) * var(--reading-scale, 1));
    line-height: 1.7;
}

/* the composer gets a reading measure; the read views are already boxed */
#editor .journal-prose {
    position: relative;
    max-width: var(--journal-measure);
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* placeholder in roman, aligned to the measure (design lock: never italic) */
#editor .journal-prose.ql-blank::before {
    font-style: normal !important;
    font-size: 1em;
    font-weight: 400;
    left: 24px;
    right: 24px;
    opacity: 0.45 !important;
}

/* A guided ritual's questions and earlier answers (#guided-dialogue, mounted
 * above #editor by common_journal_modal.js) sit on the same measure, so the
 * question text, every answer and the line being written share one left edge.
 * Without this the dialogue spanned the whole composer and the answer started
 * 64px right of its question (CEO, 2026-10-07). The serif and size are only
 * here so 64ch resolves to the editor's width; the children set their own. */
#guided-dialogue {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--journal-measure);
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
    font-family: var(--journal-serif);
    font-size: calc(var(--journal-font-size) * var(--reading-scale, 1));
}
/* the mentor's face hangs in the gutter, left of the question it asks */
#guided-dialogue [data-guided-q-row] { margin-left: -28px; }
#guided-dialogue [data-guided-q-row="current"] { margin-left: -40px; }
/* a phone's gutter is 16px + 24px: the current face takes the answered size
   so it hangs clear of the screen edge (main.css mobile composer breakpoint) */
@media (max-width: 768px) {
    #guided-dialogue [data-guided-q-row="current"] { margin-left: -28px; gap: 8px !important; }
    #guided-dialogue [data-guided-q-row="current"] img { width: 20px !important; height: 20px !important; }
}

/* ---------- legacy entries keep the look they always had ----------
 * No scheme mark (stamped .journal-legacy by common_journal_modal.js): every
 * line was a heading under the old "font size" scheme and every read surface
 * showed those headings at body size. Keep that, exactly. Markdown-derived
 * headings (.jp-h1/2/3 from simpleMarkdownToHTML) keep their main.css sizes. */
.journal-prose.journal-legacy :is(h1, h2, h3):not([class*="jp-h"]),
.ql-editor.journal-prose.journal-legacy :is(h1, h2, h3):not([class*="jp-h"]) {
    font-size: 1em;
    font-weight: 400;
    line-height: inherit;
    letter-spacing: 0;
    margin: 0;
    text-wrap: initial;
}

/* ---------- blocks ---------- */
.journal-prose p {
    margin: 0;
}

/* .ql-editor.journal-prose outranks skin.js's per-theme `.ql-editor h1..h6 { color }`
   rules; a heading is the body's colour in every theme, never its own. */
.journal-prose h1, .journal-prose h2, .journal-prose h3,
.ql-editor.journal-prose h1, .ql-editor.journal-prose h2, .ql-editor.journal-prose h3 {
    color: inherit !important; /* skin.js injects per-theme heading colours with !important and stacks them across theme switches */
    font-family: inherit;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.005em;
    margin: 1.3em 0 0.35em;
    text-wrap: balance;
}
/* .ql-editor twins outrank quill.bubble.css's .ql-bubble .ql-editor h1 (2em) so the composer matches the read views */
.journal-prose:not(.journal-legacy) h1, .ql-editor.journal-prose:not(.journal-legacy) h1 { font-size: 1.5em; }
.journal-prose:not(.journal-legacy) h2, .ql-editor.journal-prose:not(.journal-legacy) h2 { font-size: 1.25em; }
.journal-prose:not(.journal-legacy) h3, .ql-editor.journal-prose:not(.journal-legacy) h3 { font-size: 1.1em; }

.journal-prose > :is(h1, h2, h3):first-child {
    margin-top: 0;
}

/* .ql-editor.journal-prose: outranks Quill's own .ql-bubble .ql-editor blockquote */
.journal-prose blockquote, .ql-editor.journal-prose blockquote {
    margin: 0.6em 0;
    padding-left: 1em;
    border-left: 2px solid var(--journal-marker);
    opacity: 0.9;
}

/* highlight: a quiet tint, never a colour picker */
.journal-prose mark, .ql-editor.journal-prose mark {
    background: var(--journal-highlight);
    color: inherit; /* skin.js injects per-theme heading colours with !important and stacks them across theme switches */
    padding: 0 0.12em;
    border-radius: 2px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* links: accent, thin underline, the URL on hover; never a preview card */
.journal-prose a, .ql-editor.journal-prose a {
    color: var(--journal-marker);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.16em;
    text-decoration-color: color-mix(in srgb, var(--journal-marker) 55%, transparent);
}
.journal-prose a:hover, .ql-editor.journal-prose a:hover {
    text-decoration-color: var(--journal-marker);
    text-decoration-thickness: 1.5px;
}

/* ---------- lists: one gutter ---------- */
.journal-prose ol, .journal-prose ul {
    list-style: none;
    padding: 0;
    margin: 0.35em 0;
    counter-reset: list-0;
}

.journal-prose li {
    position: relative;
    list-style: none;
    padding-left: 1.75em;
    margin: 0.2em 0;
}

/* marker lives in the gutter, right-aligned to one edge */
.journal-prose li > .ql-ui {
    position: absolute;
    left: 0;
    top: 0;
    width: 1.25em;
    margin: 0;
    text-align: right;
    color: var(--journal-marker);
    font-variant-numeric: tabular-nums lining-nums;
    user-select: none;
}

.journal-prose li[data-list="bullet"] > .ql-ui::before {
    content: '\2022';
}

.journal-prose li[data-list="ordered"] {
    counter-increment: list-0;
    counter-reset: list-1 list-2;
}
.journal-prose li[data-list="ordered"] > .ql-ui::before {
    content: counter(list-0);
}

/* checklist: a drawn box, not a glyph */
.journal-prose li[data-list="checked"] > .ql-ui::before, .journal-prose li[data-list="unchecked"] > .ql-ui::before, .journal-prose li[data-list="check"] > .ql-ui::before {
    content: '';
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    box-sizing: border-box;
    border: 1.5px solid var(--journal-marker);
    border-radius: 3px;
    vertical-align: -0.08em;
    background-color: transparent;
    background-size: 70%;
    background-position: center;
    background-repeat: no-repeat;
}
.journal-prose li[data-list="checked"] > .ql-ui::before {
    background-color: var(--journal-marker);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.5l2.3 2.3L9.5 4' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.journal-prose li[data-list="checked"] {
    opacity: 0.6;
    text-decoration: line-through;
    text-decoration-color: color-mix(in srgb, var(--journal-marker) 60%, transparent);
}

/* semantic lists (no Quill .ql-ui child: Markdown-converted or hand-written
   <ul>/<ol>) draw their marker on ::before in the same gutter (Codex, PR #1493) */
.journal-prose li:not(:has(> .ql-ui))::before {
    position: absolute;
    left: 0;
    top: 0;
    width: 1.25em;
    text-align: right;
    color: var(--journal-marker);
    font-variant-numeric: tabular-nums lining-nums;
}
.journal-prose li:not(:has(> .ql-ui)):not([data-list])::before,   /* incl. orphan <li> from simpleMarkdownToHTML */
.journal-prose ul > li:not(:has(> .ql-ui))::before,
.journal-prose li[data-list="bullet"]:not(:has(> .ql-ui))::before { content: '\2022'; }
.journal-prose ol > li:not(:has(> .ql-ui)):not([data-list]),
.journal-prose li[data-list="ordered"]:not(:has(> .ql-ui)) { counter-increment: list-0; }
.journal-prose ol > li:not(:has(> .ql-ui)):not([data-list])::before,
.journal-prose li[data-list="ordered"]:not(:has(> .ql-ui))::before { content: counter(list-0); }
/* checklist items converted to text glyphs (☑/☐ in the text) keep no extra marker */
.journal-prose li[data-list="checked"]:not(:has(> .ql-ui))::before,
.journal-prose li[data-list="unchecked"]:not(:has(> .ql-ui))::before { content: none; }

/* nesting: step in by one gutter, ring bullet, letters for sub-numbers */
.journal-prose li.ql-indent-1 { padding-left: 3.5em; margin-left: 0; }
.journal-prose li.ql-indent-2 { padding-left: 5.25em; margin-left: 0; }
.journal-prose li.ql-indent-1 > .ql-ui { left: 1.75em; }
.journal-prose li.ql-indent-2 > .ql-ui { left: 3.5em; }
.journal-prose li.ql-indent-1[data-list="bullet"] > .ql-ui::before { content: '\25E6'; }
.journal-prose li.ql-indent-1[data-list="ordered"] { counter-increment: list-1; counter-reset: list-2; }
.journal-prose li.ql-indent-2[data-list="ordered"] { counter-increment: list-2; counter-reset: none; }
.journal-prose li.ql-indent-2[data-list="ordered"] > .ql-ui::before { content: counter(list-2, lower-roman); }
.journal-prose li.ql-indent-2[data-list="bullet"] > .ql-ui::before { content: '\25AA'; }
.journal-prose li.ql-indent-1[data-list="ordered"] > .ql-ui::before { content: counter(list-1, lower-alpha); }

/* ---------- CJK ---------- */
.journal-prose.journal-cjk {
    line-height: 1.9;
    letter-spacing: 0.015em;
}

/* ---------- composer link tooltip ----------
 * Quill's bubble tooltip inherits the page's link and font sizing, so the
 * close mark rendered at 27px on a 46px line inside a 39px bar and spilled
 * out of the corner. Pin the editor row's geometry and the ✕ to the middle.
 */
#editor.ql-bubble .ql-tooltip-editor {
    position: relative;
    height: 40px;
    width: min(360px, 80vw);
}
/* while editing a link only the input row shows, never the format buttons */
#editor.ql-bubble .ql-tooltip.ql-editing .ql-toolbar {
    display: none;
}
#editor.ql-bubble .ql-tooltip-editor input[type="text"] {
    position: absolute;
    inset: 0;
    height: 40px;
    padding: 0 44px 0 16px;
    font: 500 14px/40px -apple-system, 'Helvetica Neue', Arial, sans-serif;
    text-align: left;
}
#editor.ql-bubble .ql-tooltip-editor a.ql-close {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    line-height: 1;
}
#editor.ql-bubble .ql-tooltip-editor a.ql-close::before {
    content: '\00d7';
    font-size: 18px;
    line-height: 1;
    font-weight: 500;
    color: #ccc;
}

/* ---------- toolbar hover labels ----------
 * Instant, in the app's own style. The native title tooltip waits ~1s and
 * renders in the OS chrome, which reads as lag.
 */
#editor.ql-bubble .ql-toolbar [data-tip] {
    position: relative;
}
#editor.ql-bubble .ql-toolbar [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, 8px) scale(0.98);
    background: #1f1b2e;
    color: #f4f1fa;
    font: 500 12px/1.2 -apple-system, 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: 0.01em;
    padding: 5px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity 120ms ease 60ms, transform 120ms ease 60ms;
}
#editor.ql-bubble .ql-toolbar [data-tip]:hover::after,
#editor.ql-bubble .ql-toolbar [data-tip]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 6px) scale(1);
}
@media (prefers-reduced-motion: reduce) {
    #editor.ql-bubble .ql-toolbar [data-tip]::after { transition: none; }
}

/* ---------- selection and caret own the accent ---------- */
.journal-prose ::selection { background: color-mix(in srgb, var(--journal-marker) 24%, transparent); }
#editor .journal-prose { caret-color: var(--journal-marker); }

/* ---------- heading picker: journal words, localised via data-label ---------- */
#editor.ql-bubble .ql-picker.ql-header .ql-picker-label[data-label]::before,
#editor.ql-bubble .ql-picker.ql-header .ql-picker-item[data-label]::before {
    content: attr(data-label);
}
#editor.ql-bubble .ql-picker.ql-header .ql-picker-item[data-value="1"]::before { font-size: 1.35em; font-weight: 600; }
#editor.ql-bubble .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { font-size: 1.15em; font-weight: 600; }
#editor.ql-bubble .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { font-size: 1em; font-weight: 600; }

/* ---------- draft recovery: one quiet line, no toast ---------- */
#journalEntryModal .journal-draft-notice {
    max-width: var(--journal-measure);
    margin: 4px auto 0;
    padding: 0 24px;
    font: 500 12px/1.4 -apple-system, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color, #4a4a4a);
    opacity: 0.7;
    display: flex;
    gap: 10px;
    align-items: baseline;
}
#journalEntryModal .journal-draft-notice button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--journal-marker);
    cursor: pointer;
}
#journalEntryModal .journal-draft-notice button:hover { text-decoration: underline; }
