/* Public-surface form controls.
 *
 * The mpalo-select component is shared with the Mind Platform. Its structure
 * and behavior live in /mindscript/mpalo-select.js; this file maps the same
 * component to the public token names and keeps the panel solid, with no
 * border and no shadow.
 *
 * Public forms also use fixed-height textareas. The browser resize handle is
 * a second, unstyled control on the right edge of the field, so it is
 * removed here for every public form.
 */

/* Public fields sit one step above the page surface. The shared .form-input
   fill is too close to --color-bg-primary to read as a control on this
   surface. */
.form-input,
.form-textarea,
.form-select {
  background-color: var(--color-bg-tertiary);
}

.form-input:hover:not(:focus):not(:disabled),
.form-textarea:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled) {
  background-color: var(--color-bg-quaternary);
}

.mpalo-select {
  position: relative;
  display: block;
  width: 100%;
}

/* The native select keeps its name, value, and change events. Hiding it with
   display: none would drop it from form submission in some browsers. */
.mpalo-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.mpalo-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  min-height: var(--field-h);
  padding: 0.625rem 0.75rem;
  background: var(--color-bg-tertiary);
  border: 0;
  border-radius: var(--radius);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) linear;
}

.mpalo-select-trigger:hover {
  background: var(--color-bg-quaternary);
}

.mpalo-select-trigger:focus-visible,
.mpalo-select.is-open .mpalo-select-trigger {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.mpalo-select.is-disabled .mpalo-select-trigger {
  opacity: 0.5;
  cursor: not-allowed;
}

.mpalo-select-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mpalo-select-label.is-placeholder {
  color: var(--color-text-muted);
}

.mpalo-select-arrow {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.125rem;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--dur-fast) linear;
}

.mpalo-select.is-open .mpalo-select-arrow {
  transform: rotate(225deg) translate(-2px, -2px);
}

/* The panel is fixed to the viewport and parented to <body>, so a card with
   overflow: hidden cannot clip it. */
.mpalo-select-panel {
  position: fixed;
  z-index: 10000;
  box-sizing: border-box;
  min-width: 10rem;
  padding: 0.25rem;
  background: var(--color-bg-quaternary);
  border: 0;
  border-radius: var(--radius);
  box-shadow: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mpalo-select-panel[hidden],
.mpalo-select-option[hidden] {
  display: none;
}

.mpalo-select-option {
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  color: var(--color-text-primary);
  font-size: 0.875rem;
  line-height: 1.3;
  cursor: pointer;
}

.mpalo-select-option.is-placeholder {
  color: var(--color-text-muted);
}

.mpalo-select-option.is-active {
  background: var(--color-bg-tertiary);
}

.mpalo-select-option.is-selected {
  background: var(--color-bg-tertiary);
  font-weight: 600;
}

.mpalo-select-option.is-selected::after {
  content: "";
  float: right;
  width: 0.3rem;
  height: 0.6rem;
  margin: 0.15rem 0.15rem 0 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.mpalo-select-option[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* One fixed field height. No drag handle on the public surface, including
   the support form, which uses its own .form-textarea class. */
textarea,
textarea.form-input,
textarea.form-textarea {
  resize: none;
}
