/* Cloth Banner Studio: the page's arrangement and its own drawings only. Every control's look (buttons, fields,
   switches, menus, dialogs, toasts, the toolbar, the navigation, the status strip) and every colour comes from Myth
   Engine's editor kit (vendor/myth-ui/myth-ui.css) and its theme tokens, as Myth's UI standards ask
   (Myth/docs/UI-STANDARDS.md, "Local CSS may"; MythUI/CONVENTIONS.md). The kit also lays out the Preview Area (toolbar,
   viewport, status strip) and places the navigation in its corner. */

.cloth-host { flex: 1 1 auto; min-height: 0; display: flex; }
.cloth-host > .myth-editor-layout { flex: 1 1 auto; min-width: 0; }
/* Whatever the page hides (a setting that does not apply to the banner on show) stays hidden, whatever its arrangement,
   in the drawers and in Export's dialog. */
.cloth-host [hidden], .cloth-export [hidden] { display: none !important; }

/* The banner fills the Preview Area's viewport; the canvas fills the banner's stage. */
.cloth-stage { position: absolute; inset: 0; overflow: hidden; }
.cloth-stage > canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; outline-offset: -2px; }
.cloth-stage > canvas:active { cursor: grabbing; }
/* Packing (the export being made): in the middle of the view. */
.cloth-busy { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 14px; background: var(--myth-ui-surface-raised, var(--panel)); border: 1px solid var(--myth-ui-border, var(--border)); white-space: nowrap; }
.cloth-busy > .myth-ui-progress { width: 90px; }
.cloth-problem { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; }
/* The wind compass over the view: the wind seen from above, turned with the view (a drawing of the banner's own world).
   It keeps to the top corner away from the tool rail. */
.cloth-compass { position: absolute; right: 12px; top: 12px; z-index: 1; width: 96px; display: grid; justify-items: center; gap: 2px; padding: 4px 4px 3px; border-radius: 8px; background: var(--myth-ui-surface-raised, var(--panel)); border: 1px solid var(--myth-ui-border, var(--border)); color: var(--myth-ui-text-muted, var(--text-muted)); cursor: grab; touch-action: none; user-select: none; }
.cloth-stage[data-rail="right"] > .cloth-compass { right: auto; left: 12px; }
.cloth-compass svg { width: 86px; height: 86px; display: block; }
.cloth-compass .dial { fill: var(--myth-ui-surface-muted, #1e1f22); stroke: var(--myth-ui-border, #6b707a); stroke-width: 1.5; }
.cloth-compass #compassArrow line { stroke: var(--myth-ui-accent, #4c7df0); stroke-width: 4; stroke-linecap: round; }
.cloth-compass #compassArrow path { fill: var(--myth-ui-accent, #4c7df0); }
.cloth-compass #compassCloth { fill: #e8d9a8; }
/* The status strip (the kit's myth-editor-statusbar): the banner's name, how it hangs and the wind, the take for
   export, and the note at the end. In a narrow window the hanging and the wind give way first, then the take, then the
   note: each ends in "..." rather than running under the next. */
.cloth-title { white-space: nowrap; }
.cloth-subtitle { flex: 0 1000 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloth-take { flex: 0 100 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloth-note { flex: 0 1 auto; margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Settings, behind the bar's menu button: the theme, the side panels, the keys. */
.cloth-settings { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
.cloth-settings-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

/* The drawers. Reset to Defaults sits in the Banner drawer's top row, as in Myth's other editors. */
.cloth-host .myth-ui-property-inspector-toolbar { display: flex; align-items: center; gap: 6px; }
.cloth-host .myth-ui-property-inspector-toolbar > #resetDefaults { flex: none; white-space: nowrap; }
.cloth-swatch { display: block; max-width: 100%; max-height: 150px; margin: 0 auto 6px; border-radius: 3px; background: var(--myth-ui-surface-muted, #222327); }
.cloth-readout { display: block; margin: 0; }
.cloth-buttons { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cloth-buttons > button, #browseCards, #anotherTake { width: 100%; }
.cloth-switch-row { display: flex; }
/* Play, with what it plays beside it (Live Cloth or The Export). */
.cloth-play-row { align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cloth-rings { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }

/* Export's dialog: what the pack will hold, the export's options, and the model's size. */
.cloth-export { width: min(480px, 94vw); }
.cloth-export .myth-ui-dialog-body { display: flex; flex-direction: column; gap: 12px; }

/* The library, in its dialog: a grid of the kit's choice cards, each a picture over its name. */
.cloth-library { width: min(1040px, 94vw); }
.cloth-library-filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.cloth-library-filters > .myth-ui-editor-field { flex: 1 1 200px; }
.cloth-library-count { margin: 10px 0; }
.cloth-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cloth-library-item { flex-direction: column; align-items: stretch; }
.cloth-library-item > img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }

/* In a narrow window Myth's editor layout stacks its columns (the kit's own query: the editor 980 px wide or less). The
   banner then comes first and fills the screen but for the top of the drawers' row, which shows below it so it is plain
   there is more (the drawers, on their rail) as the editor scrolls. */
@container (max-width: 980px) {
  .cloth-host .myth-editor-layout-main { order: -1 !important; height: calc(100svh - 56px) !important; }
  .cloth-host .myth-editor-layout-main > .cloth-preview { height: 100%; }
}
/* A phone: the compass closer to the edge. */
@media (max-width: 700px) {
  .cloth-compass { right: 6px; top: 6px; }
  .cloth-stage[data-rail="right"] > .cloth-compass { left: 6px; }
}
