/*
  Control panel layout (2026 site refresh).

  This app is a prebuilt Angular 7 bundle (source: ../WebGL/<App>/src/app), so the
  layout is adjusted here instead of by rebuilding. Loaded before the component
  styles that Angular injects at runtime, so rules are prefixed with app-root for
  specificity and use !important where the compiled styles ([_ngcontent-*]) set
  the same property. The same file is used by AutomatonSurface and BinaryCompositionSurface.

  Goal: the panel and the WebGL view fill the window, and every control fits in
  the panel without horizontal or vertical scrolling. Rows wrap under their label
  and the vertical gaps shrink on short windows.
*/

html, body { margin: 0; height: 100%; }

/* ---- Window layout: panel on the left, WebGL view takes the rest ---- */

app-root > .layout_flex_row { height: 100vh; overflow: hidden; }

app-root .layout_panel_left {
  box-sizing: border-box;
  flex: 0 0 auto;
  width: clamp(440px, 34vw, 560px) !important;
  min-width: 0 !important;
  height: 100vh !important;
  padding: 10px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important; /* only ever shows on extremely short windows */
}

app-root .layout_panel_right {
  flex: 1 1 0;
  min-width: 0;
  width: auto !important;
  height: 100vh !important;
}

/* Let the canvas follow its container, so window resizes re-fit the view */
app-root .layout_panel_right canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ---- Panel: a column that exactly fills the panel height ---- */

app-root .layout_panel_info {
  box-sizing: border-box;
  display: flex !important;
  flex-direction: column !important;
  gap: clamp(6px, 2.4vh, 26px);
  height: 100% !important;
  min-height: 0;
  padding: 12px 14px !important;
  overflow: hidden;
}
app-root .layout_panel_info > * { flex-shrink: 0; min-width: 0; }

/* The template's fixed-height spacer rows are replaced by the gap above */
app-root .layout_panel_info > div[style*="height"] { display: none !important; }

/* ---- "Click and drag ..." instructions: out of the View row, first in the panel ---- */

app-root .layout_panel_info > .layout_flex_row { display: contents !important; }
app-root .layout_panel_info > .layout_flex_row > .layout_flex_row_end {
  order: -1;
  display: block !important;
  line-height: 1.35;
}
app-root .layout_panel_info > .layout_flex_row > .layout_flex_row_end > .layout_spacer_big { display: none !important; }

/* ---- Rows: label in a fixed left column, controls wrap onto lines beneath ---- */

app-root .layout_panel_info > .layout_flex_row_start,
app-root .layout_panel_info > .layout_flex_row > .layout_flex_row_start {
  flex-wrap: wrap !important;
  row-gap: 6px;
  padding-left: 120px;
  min-width: 0;
}
app-root .layout_panel_info .layout_width_header {
  flex: 0 0 120px;
  min-width: 0 !important;
  margin-left: -120px;
}
app-root .layout_panel_info .layout_flex_row_start > * { flex-shrink: 0; max-width: 100%; }

/* Text never forces the panel wider */
app-root .layout_panel_info span { overflow-wrap: anywhere; }
app-root .layout_panel_info input { box-sizing: border-box; max-width: 100%; min-width: 0; }

/* Long text (example descriptions, status) wraps onto its own line */
app-root .layout_panel_info .layout_flex_row_start > .layout_width_100 { flex: 1 1 100%; }

/* ---- Compact selects (no floating label is used, so drop its reserved space) ---- */

app-root .layout_panel_info .mat-form-field { flex: 1 1 auto; max-width: 300px; width: auto !important; }
app-root .layout_panel_info .select_generic .mat-form-field-wrapper { padding-bottom: 0 !important; }
app-root .layout_panel_info .mat-form-field-infix { border-top-width: 0 !important; padding: 6px 0 !important; width: auto !important; }
app-root .layout_panel_info .mat-form-field-underline { bottom: 0 !important; }

/* ---- Focus: X and Y each on their own line, slider uses the available width ---- */

app-root .layout_panel_info .layout_flex_row_start:has(> mat-slider) > .layout_spacer_big {
  flex-basis: 100%;
  height: 0;
  overflow: hidden;
}
app-root .layout_panel_info .slider_focus { flex: 1 1 120px !important; min-width: 80px !important; }
app-root .layout_panel_info .mat-slider-horizontal { min-width: 80px !important; }

/* ---- Large text areas (Automaton Surface example file) take the remaining height and scroll inside ---- */

app-root .layout_panel_info .layout_textarea,
app-root .layout_panel_info .layout_example_file {
  box-sizing: border-box;
  flex: 1 1 0;
  min-height: 60px;
  width: 100% !important;
  height: auto !important;
  resize: none;
}

/* ---- Desktop: the page itself never scrolls ---- */

@media (min-width: 821px) {
  html, body { overflow: hidden; }
}

/* ---- Narrow windows: panel above, view below (the page scrolls) ---- */

@media (max-width: 820px) {
  app-root > .layout_flex_row { flex-direction: column !important; height: auto; overflow: visible; }
  app-root .layout_panel_left { width: 100% !important; height: auto !important; overflow: visible !important; }
  app-root .layout_panel_info { height: auto !important; gap: 12px; }
  app-root .layout_panel_right { flex: none; height: 75vh !important; }
  app-root .layout_panel_info .layout_textarea,
  app-root .layout_panel_info .layout_example_file { flex: none; height: 320px !important; }
}
