/* Form controls, checkboxes, ALTCHA security check. Loaded only on pages with forms. */

/* Forms */
.form-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.form-stack > label, .form-stack fieldset > label, .form-row > label, .builder-choice-row > label, .filter-bar label, .operator-filters label {
  display: grid; align-content: start; gap: 8px; min-width: 0; color: var(--ink-2); font-weight: 550; font-size: .9375rem; line-height: 1.35;
}
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 1rem; font-weight: 450; line-height: 1.4;
  box-shadow: var(--shadow-sm); outline: none; appearance: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--ink) 28%, var(--line-2)); }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  border-color: var(--violet); box-shadow: 0 0 0 4px color-mix(in srgb, var(--violet) 18%, transparent);
}
/* Fields have their own focus ring; the global outline stays transparent and shows only in forced-colors mode. */
input:not([type="checkbox"]):not([type="radio"]):focus-visible, select:focus-visible, textarea:focus-visible { outline-color: transparent; }
input[readonly] { background: var(--surface-sunken); color: var(--muted); box-shadow: none; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
textarea { min-height: 112px; resize: vertical; }
select {
  padding-right: 42px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23868899' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
}
option { background-color: var(--surface); color: var(--ink); }
/* Option list in site styles: Chromium 135+ (Chrome, Edge, Yandex Browser). Safari and Firefox keep the system list. */
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { display: flex; align-items: center; gap: 10px; padding-right: 14px; background-image: none; white-space: nowrap; overflow: hidden; }
  select::picker-icon {
    content: ""; flex: none; width: 16px; height: 16px; margin-left: auto;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23868899' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") center / 16px no-repeat;
    transition: rotate .2s var(--ease);
  }
  select:open { border-color: var(--violet); box-shadow: 0 0 0 4px color-mix(in srgb, var(--violet) 18%, transparent); }
  select:open::picker-icon { rotate: 180deg; }
  ::picker(select) {
    margin-block: 6px; padding: 6px; border: 1px solid var(--line-2); border-radius: 12px;
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
    max-block-size: min(20rem, 60dvh); overflow-y: auto; scrollbar-width: thin;
    opacity: 0; translate: 0 -4px;
    transition: opacity .15s var(--ease), translate .15s var(--ease), display .15s allow-discrete, overlay .15s allow-discrete;
  }
  ::picker(select):popover-open { opacity: 1; translate: 0 0; }
  @starting-style { ::picker(select):popover-open { opacity: 0; translate: 0 -4px; } }
  select option {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; border-radius: 8px;
    background: transparent; color: var(--ink-2); font-size: .9375rem; line-height: 1.35; overflow-wrap: anywhere; cursor: pointer;
    transition: background-color .12s var(--ease), color .12s var(--ease);
  }
  select option:hover, select option:focus-visible { background: var(--surface-sunken); color: var(--ink); outline: none; }
  select option:checked { background: var(--violet-soft); color: var(--violet-text); font-weight: 600; }
  select option::checkmark { order: 1; margin-left: auto; color: var(--violet); }
  select option:disabled { color: var(--faint); cursor: default; }
  @media (prefers-reduced-motion: reduce) { select::picker-icon, ::picker(select) { transition: none; } }
}
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="number"]::-webkit-inner-spin-button { opacity: .5; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--red-ink); }
.field-hint { display: block; color: var(--muted); font-size: .875rem; font-weight: 400; line-height: 1.5; }
.field-hint a { color: var(--violet-text); font-weight: 600; }

.checkbox { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: 12px; color: var(--ink-2); font-weight: 400 !important; font-size: .9375rem; line-height: 1.5; cursor: pointer; }
.checkbox a { color: var(--violet-text); font-weight: 600; }
.checkbox a:hover { color: var(--ink); }
input[type="checkbox"] {
  flex: none; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--line-2); border-radius: 6px;
  background: var(--surface) center / 14px no-repeat; appearance: none; cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
input[type="checkbox"]:hover { border-color: var(--violet); }
input[type="checkbox"]:checked {
  border-color: var(--violet); background-color: var(--violet);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4.5 4.5L19 7'/%3E%3C/svg%3E");
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

progress { width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: var(--surface-sunken); appearance: none; }
progress::-webkit-progress-bar { background: var(--surface-sunken); border-radius: 99px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--violet), #8F86FF); border-radius: 99px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--violet), #8F86FF); border-radius: 99px; }

/* ALTCHA security widget */
.security-check { min-width: 0; --altcha-border-radius: 10px; --altcha-border-width: 1px; --altcha-border-color: var(--line-2); --altcha-color-base: var(--surface); --altcha-color-base-content: var(--ink); --altcha-color-primary: var(--violet); --altcha-color-neutral: var(--line-2); --altcha-font-size: 1rem; --altcha-max-width: 100%; font: inherit; }
.security-check altcha-widget { display: block; min-height: 56px; width: 100%; max-width: 100%; font-family: inherit; }
.security-check altcha-widget * { font-family: inherit; }
.security-check .field-hint { margin: 8px 0 0; }
.security-check-status:empty { display: none; }
.security-retry { align-items: center; gap: 8px; min-height: 44px; font-size: .875rem; }
.security-retry:not([hidden]) { display: flex; }
.bot-trap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; pointer-events: none; }
altcha-widget:not(:defined) { display: block; min-height: 56px; border: 1px solid var(--line-2); border-radius: 10px; }
altcha-widget:not(:defined)::before { content: 'Проверка безопасности…'; display: block; padding: 16px; color: var(--muted); }
html[lang="en"] altcha-widget:not(:defined)::before { content: 'Security check…'; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 52px !important; }
.password-toggle { position: absolute; top: 50%; right: 5px; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); transform: translateY(-50%); }
.password-toggle:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.password-toggle[aria-pressed="true"] { color: var(--violet); }
form[aria-busy="true"] button[type="submit"], form[aria-busy="true"] button:not([type]) { cursor: progress; }

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}
