/* — light-DOM component: define() wraps this sheet in @scope (pebble-tablet) { … }; :scope is the host. State reaches CSS through custom properties and attributes, never as generated CSS text; the page themes the editor by setting the --tablet-* properties on the host. Part hooks: part="editor field" — one element, two roles: the textarea is the editing surface AND the form field of record, before and after the upgrade, so enhancement never reflows. With a decorating dialect ([data-decorated]) the field's glyphs turn transparent and part="backdrop" paints the same text over it, laid over the field's box (absolute, so only the field sizes the host) with the same font, padding, border width, wrap and scrollbar gutter, so every glyph lands where the field's would. Anything a page adds to the backdrop must keep glyph widths (docs/tablet.md). */ :scope { display: block; position: relative; font-family: var(--tablet-font, inherit); } :scope > textarea, :scope > [part~="backdrop"] { box-sizing: border-box; margin: 0; white-space: pre-wrap; overflow-wrap: break-word; scrollbar-gutter: stable; } :scope > textarea { display: block; width: 100%; min-height: var(--tablet-min-height, 4lh); max-height: var(--tablet-max-height, none); padding: var(--tablet-padding, 0.5rem 0.75rem); font: inherit; color: var(--tablet-color, inherit); background: var(--tablet-background, transparent); border: var(--tablet-border, 1px solid color-mix(in srgb, currentColor 25%, transparent)); border-radius: var(--tablet-radius, 6px); caret-color: var(--tablet-caret, currentColor); /* The field fits its text, from min- to max-height (then it scrolls, and the backdrop follows). A browser without field-sizing keeps the rows and the resize handle. */ field-sizing: var(--tablet-sizing, content); } @supports (field-sizing: content) { :scope > textarea { resize: var(--tablet-resize, none); } } :scope > textarea:focus { outline: var(--tablet-focus-outline, 2px solid var(--accent, currentColor)); outline-offset: -1px; } /* Only the glyphs' fill goes transparent: `color` stays the text's, so the caret (currentColor) and spellcheck marks stay visible. */ :scope[data-decorated] > textarea { -webkit-text-fill-color: transparent; } :scope[data-decorated] > textarea::selection { color: transparent; -webkit-text-fill-color: transparent; background: var(--tablet-selection, color-mix(in srgb, var(--accent, Highlight) 30%, transparent)); } :scope[data-decorated] > textarea::placeholder { color: var(--tablet-placeholder, GrayText); -webkit-text-fill-color: var(--tablet-placeholder, GrayText); } :scope > [part~="backdrop"] { position: absolute; inset: 0; overflow: hidden; padding: var(--tablet-padding, 0.5rem 0.75rem); font: inherit; color: var(--tablet-color, inherit); border: var(--tablet-border, 1px solid color-mix(in srgb, currentColor 25%, transparent)); border-color: transparent; pointer-events: none; } :scope > [part~="backdrop"] > .line { min-height: 1lh; } :scope [part~="box"] { /* inline-block: a line's text-decoration (a struck-through done task) does not paint across an atomic inline; its width is still its text's. text-fill-color: the "[ ]" glyphs stay hidden whatever colour a page's classes give the segment. */ display: inline-block; position: relative; color: transparent; -webkit-text-fill-color: transparent; pointer-events: auto; cursor: pointer; } :scope [part~="box"]::before { content: ""; position: absolute; inset: 0; width: 1em; height: 1em; margin: auto; box-sizing: border-box; border: 1.5px solid var(--tablet-box, var(--accent, CanvasText)); border-radius: 3px; } :scope [part~="box"][data-checked]::before { background: var(--tablet-box, var(--accent, CanvasText)); } :scope [part~="box"][data-checked]::after { content: ""; position: absolute; inset: 0; width: 0.3em; height: 0.55em; margin: auto; translate: 0 -0.08em; border: solid var(--tablet-box-mark, Canvas); border-width: 0 2px 2px 0; rotate: 45deg; }