documentation/components/source/playground.css

1/* Compose your own: one working copy, shown in two real slots.
2
3   The editor has two faces. Rules up to "The workbench" style the strip a
4   lesson teaches and what both faces share: the previews, the empty marker
5   and the cues of a move. The workbench's own rules all begin `.workbench`. */
6.editor-panel {
7  display: contents;
8}
9.bar [hidden] {
10  display: none;
11}
12.starter[hidden],
13.workspace[hidden] {
14  display: none;
15}
16.starter {
17  display: flex;
18  flex-wrap: wrap;
19  align-items: baseline;
20  gap: 8px 16px;
21}
22.start-action {
23  padding: 8px 14px;
24  border: 1px solid var(--ink);
25  border-radius: 4px;
26  color: var(--ink);
27  font-weight: 600;
28}
29.start-blank {
30  color: var(--ink);
31  padding: 8px 4px;
32}
33.starter-note {
34  color: var(--quiet);
35  font-size: 12px;
36}
37
38/* Each preview is a host of its own size. These are demonstration slots:
39   ordinary CSS sizes them, and the composition inside responds to the space
40   it is given. Side by side when the page has room, one above the other
41   when it does not; neither can be wider than the page. */
42.previews {
43  display: flex;
44  flex-wrap: wrap;
45  align-items: flex-start;
46  gap: 12px 24px;
47}
48.preview {
49  min-inline-size: 0;
50  max-inline-size: 100%;
51}
52.preview[data-preview="wide"] {
53  flex: 1 1 560px;
54}
55.preview[data-preview="rail"] {
56  flex: 0 1 260px;
57}
58.preview[data-preview="rail"] .stage {
59  padding-inline-end: 0;
60}
61.preview[data-preview="rail"] .viewport {
62  inline-size: 260px;
63}
64.preview-label {
65  padding: 4px 0;
66}
67/* One readout for each view: the selected item, or its Switchers' result.
68   Two lines are reserved so a selection does not move the controls below. */
69.preview .caption {
70  min-block-size: 2lh;
71}
72.preview .caption:has(.selection:not(:empty)) .note {
73  display: none;
74}
75
76/* A group with no members, or a text with no characters, renders nothing.
77   An outline marks its place. It adds no size to the layout and no extent to
78   a scrolling Shelf; the declaration is where such a node is selected. */
79.rendered :is(.node, .leaf)[data-empty="true"] {
80  outline: 1px dotted color-mix(in srgb, var(--ink) 60%, transparent);
81  outline-offset: 4px;
82}
83.rendered
84  :is(.node, .leaf)[data-empty="true"]:is(
85    [data-chosen="true"],
86    [data-inspected="true"]
87  ) {
88  outline: 1.5px solid var(--ink);
89  outline-offset: 4px;
90}
91
92/* The text of the one selected fact. It sits outside the previews, which are
93   replaced as it changes. */
94.working .text-edit {
95  flex-basis: 100%;
96  flex-wrap: nowrap;
97  margin-block-start: 0;
98}
99.working .text-edit input {
100  min-inline-size: 0;
101}
102.working .text-edit input:disabled {
103  opacity: 0.55;
104}
105.creation {
106  display: flex;
107  align-items: baseline;
108  flex-wrap: wrap;
109  gap: 8px 20px;
110  flex-basis: 100%;
111}
112.creation label {
113  display: inline-flex;
114  align-items: baseline;
115  gap: 8px;
116}
117.creation select {
118  font: inherit;
119  color: var(--ink);
120  background: var(--paper);
121  border: 1px solid var(--line);
122  border-radius: 4px;
123  padding: 4px 6px;
124}
125.creation select:focus-visible {
126  outline: 2px solid var(--ink);
127  outline-offset: 3px;
128}
129@media (pointer: coarse) {
130  .creation select,
131  .starter button {
132    min-block-size: 44px;
133  }
134}
135
136/* Keep editing beside the visible part of a tall comparison. Sticky remains
137   bounded by this workspace and releases at the strip's normal position.
138   Short windows retain ordinary flow so the controls cannot cover the view.
139   This query sizes teaching chrome; primitives still adapt intrinsically. */
140@media (min-height: 40rem) and (pointer: fine),
141  (min-height: 56rem) and (pointer: coarse) {
142  .working {
143    position: sticky;
144    inset-block-end: 0;
145    z-index: 2;
146    margin-block-end: 0;
147    padding-block: 10px 14px;
148    border-block-start: 1px solid var(--line);
149    background: var(--paper);
150    max-block-size: 40dvh;
151    overflow: auto;
152  }
153  /* Native keyboard scrolling reserves the strip's maximum footprint.
154     Mouse selection keeps its position; no rectangle tracking is needed.
155     The workbench has no strip over its previews. */
156  :host(:not([standalone])) .rendered .node[tabindex="0"]:focus-visible {
157    scroll-margin-block-end: 42dvh;
158  }
159}
160.working .inside-action,
161.working .after-action {
162  color: var(--ink);
163  font-weight: 600;
164}
165/* Their wording follows the selection; reserve room so neighbors stay put. */
166.working .inside-action {
167  min-inline-size: 10em;
168  text-align: start;
169}
170.working .after-action {
171  min-inline-size: 8em;
172  text-align: start;
173}
174@media (forced-colors: active) {
175  .rendered :is(.node, .leaf)[data-empty="true"] {
176    outline: 1px dotted GrayText;
177    outline-offset: 4px;
178  }
179  .rendered
180    :is(.node, .leaf)[data-empty="true"]:is(
181      [data-chosen="true"],
182      [data-inspected="true"]
183    ) {
184    outline: 2px solid Highlight;
185    outline-offset: 4px;
186  }
187  .start-action {
188    border-color: ButtonText;
189  }
190}
191
192/* Move keeps the authored selection while choosing a separate destination.
193   Both are painted on existing boxes; no measured overlay participates. */
194/* Every moving member has its own solid edge, including a run and forced
195   colors. Inset edges survive native clipping inside a scrolling Shelf. */
196.workspace[data-moving]
197  .rendered
198  :is(.node, .leaf)[data-chosen="true"]:not([data-empty="true"]) {
199  outline: 1.5px solid var(--ink);
200  outline-offset: -1.5px;
201}
202.rendered :is(.node, .leaf)[data-destination] {
203  outline: 2px dashed var(--ink);
204  outline-offset: -2px;
205}
206/* A destination underline coexists with the ordinary solid focus ring. */
207.code-name[data-destination] {
208  text-decoration: underline dashed;
209  text-decoration-thickness: 2px;
210  text-underline-offset: 3px;
211}
212/* While a move's destination is being chosen, its controls stand in for
213   the others. */
214.workspace[data-moving]
215  .working
216  > :is(.text-edit, .arrangement, .creation, .composition-actions, .history),
217.workspace[data-moving] .inspector-body {
218  display: none;
219}
220.move-controls {
221  display: flex;
222  flex-wrap: wrap;
223  flex-basis: 100%;
224  gap: 6px 16px;
225}
226.move-source,
227.move-destination {
228  flex-basis: 100%;
229  overflow-wrap: anywhere;
230}
231.move-source {
232  font-weight: 600;
233}
234.move-destination {
235  color: var(--quiet);
236}
237.move-placements {
238  display: flex;
239  flex-wrap: wrap;
240  gap: 6px 20px;
241}
242.move-placements button:not(.cancel-move):enabled,
243.move-action:enabled {
244  color: var(--ink);
245  font-weight: 600;
246}
247.move-placements .cancel-move {
248  margin-inline-start: 12px;
249}
250@media (forced-colors: active) {
251  .workspace[data-moving] .rendered :is(.node, .leaf)[data-chosen="true"] {
252    outline-color: Highlight;
253  }
254  .rendered :is(.node, .leaf)[data-destination] {
255    outline-color: CanvasText;
256  }
257  .code-name[data-destination] {
258    text-decoration-color: CanvasText;
259  }
260}
261
262/* Empty groups have no area to paint inside; mark their native zero-sized
263   box, with a stronger dash than the idle dotted placeholder. Code remains
264   their complete selector. */
265.rendered :is(.node, .leaf)[data-empty="true"][data-destination] {
266  outline: 2px dashed var(--ink);
267  outline-offset: 4px;
268}
269@media (forced-colors: active) {
270  .code-name[data-chosen="true"] {
271    text-decoration: underline solid;
272    text-decoration-thickness: 2px;
273    text-underline-offset: 3px;
274  }
275  .code-name[data-destination] {
276    text-decoration-style: dashed;
277  }
278  .rendered :is(.node, .leaf)[data-empty="true"][data-destination] {
279    outline-color: CanvasText;
280  }
281}
282
283/* Scrollable Shelves are keyboard stops. Their native focus ring takes
284   precedence while focused; the code cue and destination label remain. */
285.rendered .node[data-destination]:focus-visible,
286.workspace[data-moving] .rendered .node[data-chosen="true"]:focus-visible {
287  outline: 2px solid var(--ink);
288  outline-offset: 3px;
289}
290@media (forced-colors: active) {
291  .rendered .node[data-destination]:focus-visible,
292  .workspace[data-moving] .rendered .node[data-chosen="true"]:focus-visible {
293    outline-color: Highlight;
294  }
295}
296
297/* ------------------------------------------------------------------------
298   The workbench: the editor on its own page.
299
300   The result is on top, in its two real slots. Below it the hierarchy sits
301   beside an inspector for whatever is selected there. Nothing here sizes a
302   composition: these rules lay out editing chrome, and the previews remain
303   hosts that ordinary CSS sizes.
304
305   Type is sized on the chrome and never on an ancestor of the previews: the
306   separation between a row's members follows the font size it inherits.
307   ------------------------------------------------------------------------ */
308:host([standalone]) {
309  margin: 0;
310}
311.workbench {
312  display: grid;
313  grid-template-columns: minmax(0, 1fr);
314  gap: 24px;
315}
316.workbench [hidden] {
317  display: none !important;
318}
319.workbench h2 {
320  margin: 0;
321  font-size: 14px;
322  font-weight: 650;
323  line-height: 1.4;
324}
325/* The chrome's own buttons. Names in the hierarchy have their own rules. */
326.workbench
327  :where(.document-actions, .hierarchy-head, .view-choice, .inspector)
328  button {
329  padding: 6px 0;
330  color: var(--ink);
331}
332.workbench
333  :where(.document-actions, .hierarchy-head, .view-choice, .inspector)
334  button:disabled {
335  color: var(--quiet);
336  opacity: 0.6;
337  cursor: default;
338}
339
340/* The result, and what acts on the whole composition. */
341.workbench .results {
342  min-inline-size: 0;
343}
344.workbench .results-head {
345  display: flex;
346  flex-wrap: wrap;
347  align-items: baseline;
348  justify-content: space-between;
349  gap: 6px 24px;
350  margin-block-end: 12px;
351  font-size: 12px;
352}
353.workbench .results-hint {
354  margin-block-start: 2px;
355  color: var(--quiet);
356  line-height: 1.5;
357}
358.workbench .document-actions {
359  display: flex;
360  flex-wrap: wrap;
361  gap: 0 20px;
362}
363.workbench .result-views:focus-visible {
364  outline: 2px solid var(--ink);
365  outline-offset: 2px;
366}
367/* A tall result scrolls within about half the window, so the editor below
368   stays in reach while it changes. The box has no height of its own: a short
369   result leaves no empty canvas. The gutter is reserved so that a scrollbar
370   appearing cannot change the space the previews are offered. Short windows
371   keep ordinary flow. This query sizes editing chrome only. */
372@media (min-height: 40rem) {
373  .workbench .result-views {
374    max-block-size: 55dvh;
375    /* Room for a focus ring at the box's edges, which now clip. */
376    padding-block: 4px;
377    overflow: hidden auto;
378    scrollbar-gutter: stable;
379  }
380}
381/* The card is as wide as it was asked to be, with the rail beside it. This
382   independent box says how wide the card may become; the 24px is the room
383   the card's stage keeps for its grip. */
384.workbench .preview-limit {
385  position: relative;
386  inline-size: calc(100% - 24px);
387  block-size: 0;
388}
389.workbench .previews {
390  gap: 16px 24px;
391}
392.workbench .preview[data-preview="wide"] {
393  flex: 0 1 auto;
394}
395.workbench .empty-hint {
396  margin-block-start: 8px;
397  color: var(--quiet);
398  font-size: 12px;
399}
400/* The inspector names the selection, so each view keeps reporting what its
401   Switchers did. Showing structure brings the selected group's measured
402   readout back in its place. */
403.workbench
404  .preview:not(:has(.rendered[data-structure="true"]))
405  .caption
406  .selection {
407  display: none;
408}
409.workbench
410  .preview:not(:has(.rendered[data-structure="true"]))
411  .caption
412  .note:not(:empty) {
413  display: inline;
414}
415/* A selected box has a wash and a flat inset edge, one for each member of a
416   run. The edge is the cue that remains where colors are forced. It yields
417   to the empty marker, a move's destination and keyboard focus. */
418.workbench :where(.rendered) :where(.node, .leaf)[data-chosen="true"] {
419  outline: 1.5px solid var(--ink);
420  outline-offset: -1.5px;
421}
422
423/* The hierarchy beside the inspector. */
424.workbench .editing {
425  display: grid;
426  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
427  align-items: start;
428  padding-block-start: 18px;
429  border-block-start: 1px solid var(--line);
430  font-size: 13px;
431}
432.workbench .hierarchy {
433  min-inline-size: 0;
434  padding-inline-end: 24px;
435}
436.workbench .inspector {
437  min-inline-size: 0;
438  padding-inline-start: 24px;
439  border-inline-start: 1px solid var(--line);
440}
441.workbench .hierarchy-head {
442  display: flex;
443  flex-wrap: wrap;
444  align-items: baseline;
445  justify-content: space-between;
446  gap: 0 16px;
447}
448.workbench .view-choice {
449  display: flex;
450  gap: 16px;
451  margin-block-end: 6px;
452}
453.workbench :is(.hierarchy-head, .view-choice) button {
454  font-size: 12px;
455}
456.workbench .view-choice button {
457  color: var(--quiet);
458}
459/* A choice that is on is underlined, as a link in use would be. */
460.workbench :is(.view-choice button, .several)[aria-pressed="true"] {
461  color: var(--ink);
462  text-decoration: underline;
463  text-decoration-thickness: 1.5px;
464  text-underline-offset: 5px;
465}
466.workbench .select-help {
467  margin-block-end: 8px;
468  color: var(--quiet);
469  font-size: 12px;
470  line-height: 1.5;
471}
472/* A long composition scrolls in its list. */
473.workbench :is(.outline, .source) {
474  max-block-size: min(24rem, 50dvh);
475  overflow: auto;
476}
477.workbench pre {
478  margin: 0;
479  padding: 4px 8px;
480  border-radius: 0;
481  background: none;
482}
483
484/* The inspector: what is selected, then what can be done with it. */
485.workbench .selection-context {
486  margin-block-end: 14px;
487}
488.workbench .inspector .parent {
489  display: block;
490  padding: 0 0 4px;
491  font-size: 12px;
492}
493.workbench .inspector .selected-title {
494  display: inline;
495  font-size: 17px;
496}
497.workbench .selected-detail {
498  margin-inline-start: 8px;
499  color: var(--quiet);
500  font-size: 12px;
501}
502.workbench .wording {
503  display: grid;
504  gap: 6px;
505  color: var(--quiet);
506  font-size: 12px;
507}
508.workbench .wording input {
509  inline-size: 100%;
510  min-inline-size: 0;
511  padding: 8px 10px;
512  border: 1px solid var(--line);
513  border-radius: 3px;
514  background: var(--paper);
515  color: var(--color-text, #26332c);
516  font-size: 14px;
517}
518.workbench .choice {
519  min-inline-size: 0;
520  margin: 16px 0 0;
521  padding: 0;
522  border: 0;
523}
524.workbench .choice legend {
525  margin-block-end: 4px;
526  padding: 0;
527  color: var(--quiet);
528  font-size: 12px;
529}
530.workbench .choice label {
531  display: inline-flex;
532  align-items: center;
533  gap: 6px;
534  margin-inline-end: 16px;
535  padding-block: 4px;
536  cursor: pointer;
537}
538.workbench .group-arrangement label {
539  display: flex;
540  margin-inline-end: 0;
541}
542.workbench .choice input {
543  inline-size: 1em;
544  block-size: 1em;
545  margin: 0;
546  accent-color: var(--ink);
547}
548.workbench .choice small {
549  margin-inline-start: 4px;
550  color: var(--quiet);
551  font-size: 11px;
552}
553.workbench .choice p {
554  margin-block-start: 6px;
555  color: var(--quiet);
556  font-size: 12px;
557  line-height: 1.5;
558}
559.workbench .add-area {
560  margin-block-start: 18px;
561  padding-block-start: 14px;
562  border-block-start: 1px solid var(--line);
563}
564.workbench .insertion-context {
565  color: var(--quiet);
566  font-size: 12px;
567}
568.workbench .inspector .place-toggle {
569  margin-inline-start: 12px;
570  padding: 0;
571  font-size: 12px;
572}
573.workbench .add-actions {
574  display: flex;
575  flex-wrap: wrap;
576  align-items: baseline;
577  gap: 4px 16px;
578  margin-block-start: 8px;
579}
580.workbench .add-groups {
581  display: inline-flex;
582  flex-wrap: wrap;
583  align-items: baseline;
584  gap: 0 14px;
585  color: var(--quiet);
586  font-size: 12px;
587}
588.workbench .selection-actions {
589  display: flex;
590  flex-wrap: wrap;
591  gap: 0 20px;
592  margin-block-start: 12px;
593  font-size: 12px;
594}
595/* An action that does not apply to the selection is not shown. */
596.workbench .selection-actions button:disabled {
597  display: none;
598}
599.workbench .inspector .move-action {
600  font-weight: 400;
601}
602.workbench .inspector .remove-action {
603  margin-inline-start: auto;
604  color: var(--quiet);
605}
606/* The one action a selection most invites: adding to it, or grouping a run. */
607.workbench .inspector .add-text,
608.workbench .inspector[data-multiple] .group-action {
609  padding: 6px 12px;
610  border-radius: 3px;
611  background: var(--ink);
612  color: var(--paper);
613  font-weight: 600;
614}
615.workbench .inspector .add-text:disabled,
616.workbench .inspector[data-multiple] .add-text {
617  padding: 6px 0;
618  background: none;
619  color: var(--ink);
620  font-weight: 400;
621}
622.workbench .inspector .add-text:disabled {
623  color: var(--quiet);
624}
625.workbench .move-source {
626  font-size: 15px;
627}
628.workbench .author-status {
629  display: block;
630  min-block-size: 1lh;
631  margin-block-start: 14px;
632  color: var(--quiet);
633  font-size: 12px;
634  line-height: 1.5;
635}
636
637@media (width < 44rem) {
638  .workbench .editing {
639    grid-template-columns: minmax(0, 1fr);
640  }
641  .workbench .hierarchy {
642    padding-inline-end: 0;
643  }
644  .workbench .inspector {
645    margin-block-start: 16px;
646    padding: 16px 0 0;
647    border-inline-start: 0;
648    border-block-start: 1px solid var(--line);
649  }
650  .workbench :is(.outline, .source) {
651    max-block-size: 14rem;
652  }
653}
654@media (pointer: coarse) {
655  .workbench
656    :where(.document-actions, .hierarchy-head, .view-choice, .inspector)
657    button,
658  .workbench .choice label,
659  .workbench .wording input {
660    min-block-size: 44px;
661  }
662}
663@media (forced-colors: active) {
664  /* Stronger than the edge every box gets while structure is shown, and
665     still behind the empty marker, a destination and keyboard focus. */
666  .workbench
667    .rendered
668    :is(.node, .leaf)[data-chosen="true"]:not(
669      [data-empty],
670      [data-destination],
671      :focus-visible
672    ) {
673    outline: 2px solid Highlight;
674    outline-offset: -2px;
675  }
676  .workbench .inspector:not([data-multiple]) .add-text:enabled,
677  .workbench .inspector[data-multiple] .group-action {
678    border: 1px solid ButtonText;
679  }
680}