/* Terrain Stamp Studio: the page's arrangement and the tool's own pictures only. Every control's look (buttons, fields,
   switches, menus, dialogs, toasts) and every colour of the editor 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"). */

.terrain-host { flex: 1 1 auto; min-height: 0; display: flex; }
.terrain-host > .myth-editor-layout { flex: 1 1 auto; min-width: 0; }
/* Whatever the page hides (a tool or a setting that does not apply now) stays hidden, whatever its arrangement. */
.terrain-host [hidden] { display: none !important; }

/* The Preview Area: its toolbar, the view, the elevation transect, the status line. */
.terrain-preview { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.terrain-preview > .myth-preview-viewport { flex: 1 1 auto; min-height: 0; position: relative; display: flex; flex-direction: column; }
/* The bar's right end: Settings, and Export at its full width. (The kit spaces the bar's groups and buttons.) */
.terrain-toolbar-end { flex: none; overflow: visible; }
.terrain-toolbar-end > #export { flex: none; white-space: nowrap; }
.terrain-viewport { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; }

/* The view: the land in 3D under a soft sky, or a map on a quiet ground, the same in every theme so the land's own
   colours read true. The canvases are laid over the stage, so their drawing size never sets the stage's size. */
.terrain-stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden;
  background-image: linear-gradient(#4f6575 0%, #8c9ca5 54%, #a3a597 74%, #6c6e64 100%); }
.terrain-stage.terrain-map { background-color: #22262a;
  background-image: linear-gradient(#8f9aa514 1px, transparent 1px), linear-gradient(90deg, #8f9aa514 1px, transparent 1px), radial-gradient(ellipse at 50% 45%, #30363b, transparent 76%);
  background-size: 24px 24px, 24px 24px, 100% 100%; }
.terrain-stage > canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; outline-offset: -2px; }
#view3d { cursor: grab; }
#view3d:active { cursor: grabbing; }
#view3d.terrain-brushing, #view3d.terrain-brushing:active { cursor: crosshair; }
#view { cursor: crosshair; }
#view.terrain-placing { cursor: cell; }
/* Making the land: in the middle of the view. */
.terrain-busy { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3; pointer-events: none; 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)); }
.terrain-busy > .myth-ui-progress { width: 90px; }
/* The navigation, floating in the view's corner: zoom, Home and the display toggle. */
.terrain-navigation { position: absolute; right: 12px; bottom: 12px; z-index: 2; }
/* The Placement map's key, in the view's other bottom corner. */
.terrain-legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; padding: 5px 10px; border-radius: 6px; font-size: 12px; pointer-events: none;
  background: var(--myth-ui-surface-raised, var(--panel)); border: 1px solid var(--myth-ui-border, var(--border)); }
.terrain-key { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.terrain-key > i { width: 11px; height: 11px; border-radius: 2px; }
.terrain-key-dry > i { background: #68ab66; }
.terrain-key-steep > i { background: #b16649; }
.terrain-key-wet > i { background: #3675a8; }

/* The elevation transect under the view: the land's height along one row, and which row. */
.terrain-transect { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 6px 12px 8px; }
.terrain-transect-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.terrain-transect-title { font-size: 12px; white-space: nowrap; }
.terrain-transect-read { white-space: nowrap; font-variant-numeric: tabular-nums; }
.terrain-transect > canvas { display: block; width: 100%; height: 56px; border-radius: 4px;
  background: repeating-linear-gradient(to bottom, #8f9aa51f 0 1px, transparent 1px 14px), #1e2124; }

/* The status strip (the kit's myth-editor-statusbar): the landform's name and size, and what just happened. */
.terrain-status { display: flex; align-items: baseline; gap: 12px; min-width: 0; overflow: hidden; }
.terrain-title { flex: none; white-space: nowrap; }
.terrain-meta { flex: 0 1 auto; white-space: nowrap; color: var(--myth-ui-text-muted, var(--text-muted)); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.terrain-note { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--myth-ui-text-muted, var(--text-muted)); }
.terrain-note.error { color: var(--myth-ui-danger, #e5534b); }

/* Settings, behind the bar's menu button: the theme, the side panels, the keys. */
.terrain-settings { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
.terrain-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

/* The Landforms drawer: find, filter, and the landforms as cards with their pictures. */
.terrain-library { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 14px; }
.terrain-library-group > h3 { margin: 10px 0 6px; font-size: 13px; font-weight: 600; }
.terrain-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.terrain-landform { display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; height: auto; padding: 5px; white-space: normal; text-align: center; }
.terrain-landform > i { display: block; flex: none; width: 100%; border-radius: 4px; background-repeat: no-repeat; background-color: #2b3034; }
.terrain-landform > .myth-ui-choice-card-title { font-size: 12px; line-height: 1.25; overflow-wrap: anywhere; }
.terrain-readout { display: block; color: var(--myth-ui-text-muted, var(--text-muted)); font-size: 12px; line-height: 1.5; }

/* The properties. Their top row: the filter box takes the room Reset to Defaults leaves. */
.terrain-host .myth-ui-property-inspector-toolbar { display: flex; align-items: center; gap: 6px; }
.terrain-host .myth-ui-property-inspector-toolbar > .myth-ui-property-inspector-search { flex: 1 1 auto; min-width: 0; }
.terrain-host .myth-ui-property-inspector-toolbar > #resetDefaults { flex: none; white-space: nowrap; }
.terrain-switch-row { display: flex; }
.terrain-row { display: flex; align-items: flex-end; gap: 6px; min-width: 0; }
.terrain-row > :first-child { flex: 1 1 auto; min-width: 0; }
.terrain-row > button { flex: none; }
.terrain-legacy > .myth-ui-notice { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.terrain-swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.terrain-swatches > span { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.terrain-swatches i { flex: none; width: 30px; height: 22px; border-radius: 3px; background-size: 200% 200%; }

/* Export's dialog. */
.terrain-export { width: min(520px, 94vw); }
.terrain-export .myth-ui-dialog-body { display: flex; flex-direction: column; gap: 12px; }
.terrain-export-about { margin: 0; }

/* In a narrow window Myth's editor layout stacks its columns (the kit's own query: the editor 980 px wide or less). The
   land 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 landforms and the properties, on the drawers' rail) as the editor scrolls. */
@container (max-width: 980px) {
  .terrain-host .myth-editor-layout-main { order: -1 !important; height: calc(100svh - 56px) !important; }
  .terrain-host .myth-editor-layout-main > .terrain-preview { height: 100%; }
}
/* A phone: the transect gives way to the view, and the Placement map's key moves to the top corner the rail leaves
   free (the navigation spans the bottom). */
@media (max-width: 700px) {
  .terrain-navigation { right: 6px; bottom: 6px; }
  .terrain-legend { left: auto; right: 6px; top: 6px; bottom: auto; flex-direction: column; gap: 4px; }
  .terrain-transect { display: none; }
}
