Theme authoring›Surface model

Surface model (theme config)

Refrakt's surface system gives every rune up to two decorable surfaces — self (the rune box) and media (a [data-section="media"] slot) — and a fill/chrome vocabulary over them. Content authors use the attributes (see Surfaces); this page covers the theme-side pieces: the preset registries, the routing config, and the tokens.

Two surfaces, two vocabularies

VocabularyTargetsCarries
elevationselfdepth ladder: sunken · flush · flat · raised · floating · overlay (fill, border, resting box-shadow)
prominenceselfsection-header family: quiet · normal · prominent · display · marquee (title and blurb size, header spacing, a flush band's padding)
framemediaaspect · displace · offset · oversize · place · anchor · shadow (drop-shadow)
substrate / inset / tint / bgfillpattern, color, image

elevation (the self surface's depth — fill, border, resting box-shadow) and frame-shadow (drop-shadow silhouette on media) never collide — different property, different surface. A rune's resting rung comes from its config defaultElevation / defaultProminence; an author overrides per-instance, a theme overrides per-rune via mergeThemeConfig. The values are styled by attribute ([data-elevation] / [data-prominence]) — no BEM modifier class. (width is the third axis but a layout concern, not a surface one — see below.)

frame & background preset registries

A theme registers named frame presets in a frames registry, structurally parallel to backgrounds, sharing the same extends resolution as bg/tint:

// refrakt.config.json / theme config → frames
"frames": {
  "screenshot": { "shadow": "lg", "aspect": "16/9" },
  "hero-peek":  { "extends": "screenshot", "displace": "bottom", "offset": "lg" },
  "code-peek":  { "displace": "bottom-end", "offset": "md", "oversize": "1.4", "anchor": "top left" }
}

frame="screenshot" applies a preset; inline frame-* facets override individual facets and work standalone. frame-offset is a named scale (none|sm|md|lg|xl|2xl|3xl|4xl → block-spacing for sm–xl, section-spacing for 2xl–4xl); an unknown value warns and collapses to none, keeping the facet family on one vocabulary. frame-displace-mode picks the rendering model — peek (default, translate inside the frame target — for card / bento-cell) or bleed (negative margin on the media zone, so the guest extends past a section host like hero with no gap above).

Routing — frameTarget & substrateTarget

RuneConfig.frameTarget ('media' | 'self') routes frame chrome:

  • defaults to 'media' when the rune declares a media section (sections.*: 'media');
  • figure / showcase set 'self' — their body is the media;
  • frame on a rune with no frame target emits a build warning rather than guessing.

RuneConfig.substrateTarget ('media' | 'self') routes the pattern fill — but defaults to 'self' ("a background" means "behind everything"), so it is a separate field from frameTarget (a media-default would wrongly scope a hero's pattern to its image). It is theme-overridable; a per-instance substrate-target always wins; targeting media on a rune with no media section warns.

Host-owned clip

displace/offset/oversize move and size the guest, but whether the result spills into view or is cut belongs to the host surface:

  • clipping hosts (card / bento-cell / figure media wells): overflow: hidden → a displaced/oversized guest is cropped into a peek (anchor picks the focal point);
  • breakout hosts (showcase-self, a standalone section/page): overflow: visible → the guest spills past the edge. offset collapses on mobile regardless of host.

Page-level full-bleed is a width concern (the article named-line grid's content|wide|full tracks), distinct from displace (the local/nested breakout). For bento, a grid-level frame (and elevation) cascades to the cells, since heading-sugar cells have no per-cell attribute surface; frame-aspect/frame-anchor feed bento's existing --bento-media-aspect/--bento-media-anchor.

The inset surface

The recessed inset fill is derived at use-site from the in-scope surface, so it tracks tint automatically. It lowers only the lightness via relative-color syntax — keeping the surface's chroma and hue exactly, so the recess stays the same temperature (mixing toward black would drag the low chroma toward grey and read colder):

background: oklch(from var(--rf-color-surface) calc(l - var(--rf-surface-inset-shift)) c h);

--rf-surface-inset-shift is a lightness delta (an OKLCH L amount, not a color): 0.04 light / 0.06 dark (dark dips a touch deeper), tunable. There is deliberately no precomputed inset-color token — a static one would freeze to the untinted :root surface and wouldn't track tint. It writes background-color only, so insets don't compound under nesting; --rf-surface-inset-shift: 0 disables it per rune. Default consumers: the media wells of card/bento-cell/recipe/realm/faction/playlist, and the chart/diagram self surface (the standalone "darker surface").

substrate ownership

substrate is not a theme preset registry — a dot is a dot on every theme. Ownership is split four ways:

  • the engine owns the pattern enum (dots|grid|lines|cross|checker|none);
  • a shared base stylesheet (dimensions/substrate.css, always included — not a theme's swappable CSS) owns the token-driven gradient recipes;
  • the theme tunes only the token hooks (--substrate-ink, resolved from --rf-color-border, and the default cell size);
  • the engine emits markers only (data-substrate + --substrate-* custom props); CSS does the drawing.

Memorable named recipes (a pattern + facets bundle) are a deferred project concern (refrakt.config.json), never theme config.

showcase migration

showcase is the degenerate frameTarget: 'self' case — its body is the media slot, so it collapses into the frame model. Its bespoke attributes are deprecated aliases for frame-* and warn when used; breakout is retained as its distinct value.

Old (showcase)New
shadow="soft|hard|elevated"frame-shadow="sm|md|lg"
bleed=frame-displace=
offset="<length>"frame-offset="sm|md|lg|xl|2xl|3xl|4xl" (named scale; raw lengths warn)
aspect=frame-aspect=
place=frame-place=

See Surfaces for the content-author attribute reference and live examples.

Background: ·

Surface chrome: elevation and frame presets

SPEC-086shipped

Surface chrome: elevation and frame presets

Visual chrome — shadows, crop ratios, bleed/breakout — is currently welded to the showcase wrapper rune. That forces nesting ({% showcase %}…{% /showcase %} around an image) for an effect that is really just styling, and it duplicates attribute combinations every time. tint and bg already solved the analogous problem for colour and background: define a named preset once, apply it via an attribute on any rune. This spec brings the same model to chrome, and resolves the ambiguity that blocks it: when a rune (like card) hosts media, which surface does a given chrome attribute decorate?

chromerunesengineluminadx

Overview

The governing principle: chrome attaches to a named surface

A rune can expose more than one surface that accepts chrome. A card exposes two:

  • self — the card box (background, border, radius, shadow).
  • media — the [data-section="media"] slot and its guest (crop, bleed, offset, placement).

Ambiguity is removed by putting the target in the attribute's vocabulary, never inferring it. Two vocabularies, two surfaces:

VocabularyTargets the rune's…CarriesValid where
elevationself surfaceshadow (z-height, box-shadow)universal — anything can float
framemedia surfaceaspect · displace · offset · oversize · place · anchor · shadowrunes that declare a frame target
{% card elevation="md" frame="screenshot" %}
![Dashboard](dashboard.png)
---
Body copy.
{% /card %}

elevation floats the card; frame presents the media. There is never a bare shadow whose target must be guessed — the card's z-shadow is elevation; the photo's silhouette drop-shadow is a facet inside frame. Same physical property, two names, because they are two surfaces.

Why showcase collapses into this

showcase is simply a rune whose self surface IS a media slot — its body is the media. So frame on a card targets the card's media zone; frame on a showcase targets its own viewport. Same attribute, because each rune declares its frame target in config. Showcase stops being a special chrome wrapper and becomes the degenerate frameTarget: 'self' case; its only irreducible job — relational bleed past a clipping ancestor when there is no host rune to carry the attribute — remains honest wrapper work.

This also unifies the three runes that motivated the design:

  • card → elevation = card shadow; frame = hosted image (aspect/bleed/offset). Two surfaces, two vocabularies.
  • figure → it is a frame around an image, so frameTarget: 'self': frame presents the image, elevation lifts the figure.
  • showcase → frameTarget: 'self'; frame does everything, breakout bleed is its unique value.

Design

1. elevation — universal self-surface shadow

  • New universal attribute elevation (joins tint, bg, width, spacing, inset in UNIVERSAL_ATTRIBUTE_NAMES). Values: none | sm | md | lg.
  • Backed by a shared token scale --rf-shadow-none | --rf-shadow-sm | --rf-shadow-md | --rf-shadow-lg (extends today's --rf-shadow-sm/md). The engine sets data-elevation; CSS maps it to box-shadow: var(--rf-shadow-{level}).
  • Existing per-rune shadows are migrated to reference the scale: figure (--rf-shadow-sm), codegroup (--rf-shadow-md), card, etc. — one scale, no bespoke values.
  • elevation is always box-shadow (the object floats as a rectangle). The silhouette-hugging drop-shadow lives only in frame's shadow facet (§2), so the two never collide.

2. frame — media-surface preset, modelled on bg

  • New theme-config registry frames, structurally parallel to backgrounds:
    interface FramePresetDefinition {
      aspect?: string;    // "16/9", "1/1"
      displace?: string;  // edge/corner the guest moves toward: top | bottom | end | bottom-end | top-end
      offset?: string;    // displacement distance — named scale: none | sm | md | lg | xl
      oversize?: string;  // how far the guest exceeds its slot (scale factor / min-size); clipped guests only
      place?: string;     // guest-box alignment in the slot: left|center|right × top|bottom
      anchor?: string;    // crop focal point when the guest is cut (object-position)
      shadow?: string;    // none|sm|md|lg — rendered as drop-shadow (silhouette)
      extends?: string;   // layer onto a base preset (same `extends` resolution as bg/tint)
    }
    
    Note there is no clip facet — whether a displaced guest spills or is cut is owned by the host surface, not the frame (§4).
    "frames": {
      "screenshot": { "shadow": "lg", "aspect": "16/9" },
      "hero-peek":  { "extends": "screenshot", "displace": "bottom", "offset": "lg" },
      "code-peek":  { "displace": "bottom-end", "offset": "md", "oversize": "1.4", "anchor": "top left" }
    }
    
  • Applied via frame="screenshot", with inline facet overrides mirroring bg's inline overrides: frame-aspect, frame-displace, frame-offset, frame-oversize, frame-place, frame-anchor, frame-shadow. Inline values override the named preset's facets; a preset is optional (facets work standalone).
  • offset is a named scale (none | sm | md | lg | xl), not a raw length — the existing resolveOffset preset map (sm|md|lg → --rf-spacing-*) is completed (xl, none) and its raw-value fallthrough closed so an unknown value warns rather than passing through. This matches frame-shadow/elevation (also none|sm|md|lg), keeping the frame facet family on one vocabulary.
  • Engine pipeline reuses the bg machinery (packages/transform/src/engine.ts bg resolution, BgPresetDefinition, merge.ts extends resolution): read meta → look up frames → resolve extends → emit data-displace, data-frame-shadow, and --frame-offset / --frame-oversize / --frame-place-* / --frame-anchor custom properties onto the frame-target element.

3. frameTarget — the unambiguity backbone

  • New RuneConfig.frameTarget?: 'media' | 'self'.
    • Defaults to 'media' when the rune declares a media section (sections.media / emits data-section="media").
    • showcase and figure set 'self' (the rune's own root is the frame).
  • frame is universally accepted but validated against frameTarget: applied on a rune with no frame target → build warning (not a silent guess), consistent with the composability-contract validation philosophy (SPEC-084).
  • The frame chrome lands on the resolved surface: the [data-section="media"] zone (reusing the WORK-339 media-zone contract — it already clips, rounds, and is a container-query context) or the rune root for self.

4. Clip is host-owned; displacement is guest-owned

displace/offset/oversize move and size the guest, but whether the result spills into view or is cut belongs to the media surface, not the guest. The host declares its clip contract; the same displaced guest reads as a bleed in a non-clipping host and a peek in a clipping one — so the author writes one intent and the context decides how it renders:

  • Clipping hosts (card / bento-cell / figure media wells): overflow: hidden, keeping the rounded clip and the container-query context. A displaced, oversized guest is cropped — a window onto something larger, and the slice shown shifts with the slot width (the media zone is already a container-query context). anchor picks the focal point.
  • Breakout hosts (showcase as frameTarget: 'self', or a standalone section/page): overflow: visible. The displaced guest spills past the edge and may overlap neighbours (its silhouette shadow and z-index apply).

This is already how the engine behaves — a showcase[bleed] inside a bento cell stays clipped via the --in-bento-cell opt-out (split.css) while the same showcase standalone breaks out. The amendment makes it explicit and generalises that one-off: clip is a property of the host surface contract, not a guest attribute. Authors choose breakout by choosing a breakout host (§2's framing of showcase), and a host may honour a guest's requested edge (the hero-peek preset bleeding a card's media out the bottom) — but the decision stays with the host. offset collapses on mobile regardless of host (existing showcase behaviour).

Because clipping hosts normalise guests to width: 100% (the WORK-339 media-zone rule), an oversized guest must opt out of that normalisation to exceed the slot — folding frame guests into the existing preview / juxtapose / showcase opt-out list in split.css rather than inventing a new mechanism.

Full-bleed is a width concern, not a displace one — don't conflate the two breakout mechanisms:

  • Page-level full-bleed = width. The page layout makes the article a named-line grid (packages/lumina/styles/layouts/default.css): [full-start] … [content-start] min(--rf-content-max, …) [content-end] … [full-end]. Every article child defaults to grid-column: content (the prose measure); width="wide" / width="full" simply place it in a wider track. The block is allocated the track — it never overflows, so there are no clipping ancestors to fight and the host-owned-clip question above does not apply. This is the canonical way for a top-level block to span the section/viewport.
  • Local / nested breakout = displace (this section). The negative-margin spill past a component host (out of a card, a cover, a showcase), and the only place host-owned clip is relevant.

So showcase/figure is the attribute-surface wrapper that lets a bare markdown image carry width="full" (top-level) or displace/frame (nested) — not a distinct breakout primitive. A bare image has no attribute surface, so you wrap it; what it wraps into is the width grid (top-level) or displace (nested).

Limitation: the width tracks live on direct article children (.rf-page-content > article > *), so width="full" reaches the viewport only from the top level of the page flow. From inside a nested context (a multi-column rune, a card, a blockquote, the docs body), the article tracks are unavailable, so breakout there is the fragile displace negative-margin path and requires every ancestor to be non-clipping.

5. Migration (breaking)

showcase's bespoke attributes become frame facets. Provide deprecated aliases for one minor release with a build warning, then remove:

Old (showcase)New
shadow="soft"frame-shadow="sm"
shadow="hard"frame-shadow="md"
shadow="elevated"frame-shadow="lg"
bleed=frame-displace=
offset="<length>"frame-offset="sm|md|lg|xl" (named scale; raw lengths warn and are dropped)
aspect=frame-aspect=
place=frame-place=

Changesets: @refrakt-md/runes + @refrakt-md/lumina (minor for elevation / frames; the showcase attribute rename is the breaking part — gated behind aliases so the major can land later).

Acceptance Criteria

  • elevation is a universal attribute (none|sm|md|lg) on all block runes, backed by a --rf-shadow-* token scale; figure/codegroup/card reference the scale instead of bespoke shadow values.
  • A frames preset registry exists in theme config, structurally parallel to backgrounds, with extends resolution shared with bg/tint.
  • frame="preset" applies a named preset; inline frame-aspect|displace|offset|oversize|place|anchor|shadow override individual facets and work without a preset.
  • offset is a named scale (none|sm|md|lg|xl) backed by --rf-spacing-* tokens; the resolveOffset raw-length fallthrough is closed so unknown values warn rather than passing through (matching frame-shadow/elevation).
  • RuneConfig.frameTarget ('media' | 'self', defaulting to 'media' when a media section exists) routes frame chrome to the correct surface; card → media zone, figure/showcase → self.
  • frame on a rune with no frame target emits a build warning rather than applying ambiguously.
  • The frame shadow facet renders as drop-shadow (silhouette); elevation renders as box-shadow (box) — they never collide on the same surface.
  • Clip is host-owned, not a guest attribute: clipping hosts (card/bento-cell/figure) crop a displaced/oversized guest (peek, keeping the container-query context + anchor focal point); breakout hosts (showcase-self, section/page) let it spill (bleed). The --in-bento-cell one-off is generalised to this contract; offset collapses on mobile.
  • Page-level full-bleed is a width concern (the article named-line grid's content|wide|full tracks), distinct from displace/host-owned-clip (the local/nested breakout); showcase/figure is the attribute-surface wrapper carrying width (top-level) or displace (nested), not a separate primitive; width="full" reaches the viewport only from the top level (nested breakout is the fragile displace path).
  • An oversized guest opts out of the media-zone width: 100% normalisation (folded into the existing preview/juxtapose/showcase opt-out in split.css) so it can exceed and be clipped by the slot.
  • frame facets reconcile with bento's existing media vars rather than duplicating them: frame-aspect drives --bento-media-aspect, frame-anchor drives --bento-media-anchor, and a grid-level frame default cascades to cells (mirroring media-position/content-height), since heading-sugar cells have no per-cell attribute surface.
  • showcase is re-expressed as frameTarget: 'self' consuming frame; its old shadow|bleed|offset|aspect|place attributes are deprecated aliases (warn) per the migration table (bleed → frame-displace, raw-length offset → scale), with breakout retained as its distinct value.
  • Card/figure/showcase/bento reference docs and a theme-authoring "frames" section document the surface model (elevation = self, frame = media) and the preset registry.

Work breakdown (provisional)

  1. elevation + --rf-shadow-* scale — universal attribute, token scale, migrate existing shadows.
  2. frames registry + frame attribute + inline overrides — types + engine, modelled on bg; complete the offset named scale and close the resolveOffset fallthrough.
  3. frameTarget routing + host-owned clip — config field, media-zone vs self binding, build-time validation; the host surface declares its clip (overflow) contract and the oversize opt-out; move aspect/displace/offset/oversize/place/anchor CSS into a shared frame layer; reconcile with bento's --bento-media-aspect/--bento-media-anchor and the grid→cell frame-default cascade.
  4. Collapse showcase into the frame model — frameTarget: 'self', deprecated aliases, migration, breakout bleed retained.
  5. Docs — surface-model authoring page + card/figure/showcase/bento reference updates + theme-authoring frames section.

References

  • Preset template: bg pipeline — packages/transform/src/engine.ts (bg resolution), BgPresetDefinition/ThemeConfig in packages/transform/src/types.ts, extends resolution in packages/transform/src/merge.ts, packages/lumina/styles/runes/bg.css.
  • Universal attributes: packages/runes/src/attribute-presets.ts (UNIVERSAL_ATTRIBUTE_NAMES).
  • Surface to decorate: media-zone contract WORK-339; composability validation philosophy SPEC-084.
  • Surface fill sibling (the other half of the surface model — colour/pattern/inset, not chrome): SPEC-087.
  • Current chrome to absorb: packages/runes/src/tags/showcase.ts, Showcase config in packages/runes/src/config.ts, packages/lumina/styles/runes/showcase.css, media rules in packages/lumina/styles/layouts/split.css.

Surface fills: substrate patterns and tint-tracked inset surfaces

SPEC-087shipped

Surface fills: substrate patterns and tint-tracked inset surfaces

SPEC-086 gave a surface its chrome — shadow (elevation) and media presentation (frame). A surface also has a fill. Today two fill primitives exist — tint (a colour-token bridge) and bg (an image/video layer) — but there is no way to print a generated pattern/texture (dots, grid) on a surface, no recessed inset fill that tracks the surface colour, and no way to scope a fill to a rune's inner media well versus its whole surface. This spec adds substrate (the pattern layer) and a derived inset surface, and defines how surface fills target the self surface vs an addressable media well — the missing fill column of the surface model.

surfacesrunesengineluminatokensdx

Overview

The three fill layers (and what each is not)

A surface carries three independent visual layers; substrate is the one missing.

PrimitiveAnswersMechanismAsset?
tintwhat colour is this surface?bridges --tint-* → --rf-color-* (incl. surface/inset)no — tokens
bgwhat image/video sits behind content?[data-name="bg"] positioned layer (object-fit/blur/overlay)yes — a media asset
substratewhat texture/pattern is on the surface?token-generated dot/line/grid patternno — tokens

They stack and compose: a hero may carry a bg photo, a tint brand colour, and a substrate dot-grid at once — image layer, surface colour, surface texture. substrate is defined precisely by exclusion: it is not a colour role (tint) and not a media asset (bg). Being token-generated rather than an image is the differentiator — themeable, crisp at any size, cheap, and composable: it inherits the current colour and paints over whatever tint/inset fill sits beneath it.

Fill is target-routed like chrome — but defaults to self

SPEC-086 established that a rune exposes up to two decorable surfaces — self and media — and routed chrome to them (elevation → self, frame → media). Fill uses the same two surfaces, with the opposite default, because "a background" means "behind everything":

  • substrate and the inset fill default to the self surface (the whole rune). A pattern on hero/cta/feature covers the entire banner; on a card it covers the whole tile.
  • The media well is an addressable inner surface you opt into (substrate-target="media", or by carrying the fill on the guest) — for the scoped case: a dotted backdrop behind a displaced guest, with body copy on the clean surface.

This is why fill must not reuse frameTarget: frameTarget(hero) is media, so a media-default would wrongly scope a hero's pattern to its image. Unlike chrome, fill needs only one attribute per layer, target-routed — the dotted pattern is the same thing whichever surface it lands on, whereas chrome genuinely differs (box-shadow vs presentation), which is why chrome took two names and fill takes one.

Design

1. substrate — generated surface pattern

Substrate is not a theme preset registry (unlike tints/frames/backgrounds). Those are semantic — the name is an intent the theme gives meaning (tint="brand"). A pattern name is concrete — substrate="dots" describes the literal output, so routing it through the theme would add coupling without semantics and force a catalogue to maintain. Ownership is split across four layers instead, none of which is the swappable aesthetic theme:

LayerOwnsPortable?
Enginethe pattern vocabulary + geometry (dots/grid/lines/cross/checker/none) — a fixed enum, a dot is a dot everywhereuniversal
Shared base CSSthe token-driven gradient recipes that realise each pattern (ships with runes/lumina base, always included — not per-theme)universal
Themeonly the tokens the recipes read — ink colour, default cell-sizeyes (semantic tokens)
Project config (refrakt.config.json)optional named recipes composed from primitives + facets (deferred — see below)yes (travels with content)
Content (inline facets)direct substrate="dots" substrate-size="md"yes (self-contained)
  • Pattern enum (engine): dots | grid | lines | cross | checker | none. Fixed, spec-owned; none is the empty default. New geometry (e.g. grain) is an engine/plugin contribution, never a config bundle.

  • Inline facets (content, portable): substrate="dots" plus substrate-size (sm|md|lg), substrate-opacity (sm|md|lg), substrate-fill (inherit (default) | inset — selects the surface token the pattern sits on; full colour stays with tint). Facets are self-contained and travel with the content.

  • The engine emits markers only — it never draws. It sets data-substrate="dots" and --substrate-* custom properties on the target surface element; CSS does the rendering, exactly like data-method="GET":

    <div data-section="media" data-substrate="dots"
         style="--substrate-cell: 16px; --substrate-ink: var(--rf-color-border);">
    
  • Shared base layer realises the geometry, token-driven. The gradient recipes live in a base stylesheet that ships with the engine/runes (always included, not in a theme's swappable CSS), exposing only the --substrate-* token hooks. This is what makes "dots = dots on every theme" a guarantee rather than a convention — themes retune tokens, they don't get a [data-substrate="dots"]{…} block to redefine. Patterns are pure CSS, no image assets, crisp at any zoom:

    /* dots — one tiled radial-gradient */
    [data-substrate="dots"] {
      background-image: radial-gradient(var(--substrate-ink) var(--substrate-dot, 1.5px), transparent 0);
      background-size: var(--substrate-cell, 16px) var(--substrate-cell, 16px);
    }
    /* grid — two tiled linear-gradients */
    [data-substrate="grid"] {
      background-image:
        linear-gradient(var(--substrate-ink) 1px, transparent 1px),
        linear-gradient(90deg, var(--substrate-ink) 1px, transparent 1px);
      background-size: var(--substrate-cell, 24px) var(--substrate-cell, 24px);
    }
    

    --substrate-ink resolves from --rf-color-border/muted (tint-bridged), so the pattern recolours with the surface; the pattern is a background-image over the background-color fill (§3), and the gradient's transparent gaps reveal it.

  • Named recipes are a project concern, deferred. If substrate="code-well" (a memorable bundle of pattern + facets) earns its keep, it is defined in refrakt.config.json (project-level, theme-independent) so it travels with the content — never in theme config. Start without it (inline facets are concise); add it only if real content shows the inline form repeating.

2. Target — rune-declared default (self), theme-overridable, author wins

Three owners, distinct responsibilities:

  • Surface vocabulary is the rune contract. A rune declares which surfaces a fill can target — self (rune root) and, if it has a media section, media ([data-section="media"], the WORK-339 zone). This lives in rune config (engine for core runes, plugin for plugin runes), not in swappable CSS, so it is portable.
  • Default surface is RuneConfig.substrateTarget (defaults to 'self'), and a theme may override it via the existing mergeThemeConfig path. This is "themes define where it lands": a theme can declare its card paints the media well by default while a banner paints the whole surface. It is a separate field from frameTarget and defaults to 'self' — it does not inherit frame's media-default (which would wrongly scope a hero's pattern to its image).
  • Explicit author intent always wins, on every theme. A per-instance substrate-target="self|media" overrides the rune/theme default and is never relocated by a theme — the portability boundary. Targeting media on a rune with no media section emits a build warning (SPEC-084 validation), as with frame.
  • Carrying substrate on a media-slot guest (Case A) lands it on the guest's own surface (self); the guest fills the slot, so the pattern covers the well without targeting it.

3. Inset surface — derived, tint-tracking

  • New token --rf-surface-inset-shift — a mix amount, not a colour: light 5%, dark 8% (tunable), in tokens/base.css / dark.css.

  • The inset fill is computed at use-site from the in-scope surface:

    background: color-mix(in oklch, var(--rf-color-surface), black var(--rf-surface-inset-shift));
    
  • Because the mix reads the inherited --rf-color-surface, it recomputes from a tinted surface automatically — tint cascades into the fill with no extra plumbing. A static absolute --rf-color-surface-inset token would freeze to the untinted :root surface and would not track tint; the derivation must live where surface is in scope.

  • Mix toward black in oklch (lowers lightness, preserves the tinted hue) rather than toward --rf-color-bg (which is untinted — both modes have bg darker than surface, but mixing toward it would desaturate a tinted well). Same recipe both modes; only the shift differs.

  • Two default consumers:

    • Media well of card/bento-cell/recipe/realm/faction/playlist ([data-section="media"]): gains the inset fill as its surface — a recessed sub-surface that tracks the card's (possibly tinted) colour. Invisible under a full-bleed cover; visible in the gaps (transparent, displaced, or absent guest).
    • chart/diagram self surface: default tint resolves their --rf-color-surface to the inset, giving the standalone "darker surface" (the deferred inset-surface idea), tint-tracked.
  • Nesting. Because the inset writes background-color and never re-bases --rf-color-surface, it derives from the nearest tinted surface and does not compound: a re-tinted nested rune gets an inset from its own tint, while a chart inside an inset well derives from the same surface token and lands on the same shade as the well — depth is conveyed by border/elevation, not progressive darkening (consistent with untinted nested cards, which already share one --rf-color-surface). This correctness depends on the use-site rule above: only the --rf-surface-inset-shift amount is a token; there must be no precomputed inset-colour token, which would freeze to the wrong scope under nesting. (Relatedly, tint cascades into nested untinted containers — a card inside a tinted card inherits that tint; re-tint it to contrast.)

  • --rf-surface-inset-shift: 0 is the per-rune escape hatch (well flush with its surface).

4. Relationship to tint and bg

  • The solid inset/darker fill is firmly tint's job (a surface-colour token); substrate is strictly the pattern layer above the fill. Single-purpose primitives.
  • tint may later want the same self/media-well targeting (to colour a card's well independently). This spec defines the addressable media-well surface once and wires substrate + the inset fill to it; media-targeted tint is a follow-on (the inset-fill default already covers the common "well recedes" case).
  • bg is unchanged; substrate composes above a bg layer (pattern over photo) when both are present.
  • Gradient fills are bg's domain, not substrate's. A smooth colour gradient is a token-driven background-image (linear-gradient with stops from --rf-color-*), occupying the same layer slot as a bg photo and composing beneath a substrate pattern (gradient backdrop + dot overlay). Spec'd separately in SPEC-088 (bg gradients + formalized escape hatch); noted here only to mark the seam.
  • Image-behind-text splits by intent: media cover mode vs decorative bg. When the image is the rune's media (a poster/cover card — the subject), it stays a media guest in a cover layout mode — the media well fills the rune, content overlays it, the thin-edge frame and in-flow height are preserved (SPEC-089). When the image/gradient is decorative ambiance behind content (edge-to-edge, out of flow), it is bg + scrim (SPEC-088). The distinguishing question is "is this the rune's media, or a backdrop." The media slot's normal top/bottom/start/end layouts stay non-overlapping by contract; the overlay is cover mode, not bg.

Case studies

  • hero / cta — pattern the whole banner. {% hero substrate="dots" %} → self surface; the dot-grid covers the entire banner behind eyebrow/title/media. (The self default is load-bearing here: frameTarget(hero) is media, so a media-default would wrongly scope the pattern to the hero image.)
  • Case A — juxtapose fills the slot with its own dots. {% juxtapose substrate="dots" %} inside a card media slot → self surface; the guest fills the slot, so its pattern covers the well. The card's own well fill is never seen.
  • Case B — displaced codegroup over a dotted well. {% card substrate="dots" substrate-fill="inset" substrate-target="media" frame="code-peek" %} hosting a codegroup → the dotted pattern over the inset fill paints the media well; frame displaces/oversizes/clips the codegroup over it (SPEC-086 §4); the top-left gap reveals the substrate; body copy sits on the card's clean surface. (A project could bundle substrate-fill="inset" substrate="dots" as a named refrakt.config.json recipe — deferred.)
  • chart / diagram standalone. Default inset tint → a recessed surface that tracks the page/section tint; dropped into a card media slot, the chart fills the well and its inset surface shows (Case A, no explicit attribute).

Acceptance Criteria

  • The pattern vocabulary is a fixed engine-level enum (dots|grid|lines|cross|checker|none), not a theme preset registry; none is the empty default and new geometry is an engine/plugin contribution.
  • substrate="dots" plus inline facets substrate-size|opacity|fill work standalone (no preset needed); substrate-fill selects inherit|inset (full colour stays with tint).
  • The gradient recipes ship in a shared base stylesheet (always included, not per-theme) exposing only --substrate-* token hooks; the theme tunes ink colour + cell-size tokens but cannot redefine a pattern's geometry. Patterns are token-generated (no image assets) and coloured from --rf-color-* so they track tint and the inset fill.
  • Optional named recipes are defined in refrakt.config.json (project-level, theme-independent), not theme config — and are deferred until inline facets prove insufficient.
  • Surface fill target is RuneConfig.substrateTarget, defaulting to 'self' (separate from frameTarget, so hero/cta/feature pattern the whole banner), theme-overridable via mergeThemeConfig; a per-instance substrate-target="self|media" always wins and is never relocated by a theme; targeting media on a rune with no media section emits a build warning.
  • A --rf-surface-inset-shift token (mix amount, mode-specific) plus a use-site color-mix(in oklch, var(--rf-color-surface), black …) recipe yields a recessed inset fill that tracks tint (no static absolute inset-colour token); 0 disables it per rune.
  • The inset is correct under nesting: a re-tinted nested rune derives its inset from its own tint, insets do not compound (presentational background-color, no surface re-basing — depth via border/elevation), and no precomputed inset-colour token exists; the cascade of tint into nested untinted containers is documented (re-tint to contrast).
  • The media well of card/bento-cell/recipe/realm/faction/playlist carries the inset fill by default (recessed sub-surface), invisible under a full-bleed guest — verified by a visual sweep.
  • chart/diagram default tint to the inset surface for their self surface (the standalone "darker surface"), tint-tracked.
  • The three fill primitives are documented as distinct layers (tint = colour, bg = image layer, substrate = pattern) in a theme-authoring "surfaces" page, with the self/media-well targeting and the Case A/B examples.

Work breakdown (provisional)

  1. Inset token + recipe — --rf-surface-inset-shift, use-site color-mix, applied to media wells + chart/diagram; visual sweep; 0 escape hatch.
  2. substrate attribute + engine enum + shared base layer — engine emits data-substrate/--substrate-*; ship the token-driven gradient recipes (dots|grid|lines|cross|checker) in an always-included base stylesheet exposing only token hooks; theme contributes ink/scale tokens.
  3. substrateTarget routing — RuneConfig.substrateTarget (default self, theme-overridable), per-instance substrate-target override (author wins), media-zone binding (WORK-339 element), build-time validation; define the addressable media-well surface for later tint reuse.
  4. Docs — theme-authoring "surfaces" page (three layers + targeting), reference updates for tint/bg/substrate and the inset surface; chart/diagram/card/hero examples.

References

  • Sibling chrome model: SPEC-086 (elevation/frame, self/media surfaces, host-owned clip, frameTarget).
  • Composability + validation philosophy: SPEC-084; media-zone contract: WORK-339.
  • Colour bridge: packages/lumina/styles/runes/tint.css, TintDefinition in packages/transform/src/types.ts.
  • Image layer: packages/lumina/styles/runes/bg.css, BgPresetDefinition.
  • Surface tokens + archetypes: packages/lumina/tokens/base.css / dark.css, packages/lumina/styles/dimensions/surfaces.css.
  • Media zone: packages/lumina/styles/layouts/split.css.