/* Draci Strakonice: forms. Label above, help under the label, error under the field. Maps 1:1 to Symfony form_row. */

.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; } /* one track: a wide control never pushes the fields past the card */
.form-row { display: grid; gap: 0.5rem; min-width: 0; }
.form-row > label:not(.check), .form-label { font-size: var(--fs-14); font-weight: 600; line-height: 1.3; color: var(--ink); }
.form-label .optional { font-weight: 400; color: var(--muted); }
.form-help { font-size: var(--fs-14); color: var(--muted); line-height: 1.4; margin-top: -0.25rem; }

.input, .select, .textarea {
  width: 100%; min-height: var(--control-h);
  padding: 0.6rem 0.85rem;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--control); border-radius: var(--radius-control); /* taste-skill-ignore: form field edge, 3.7:1 for WCAG 1.4.11 */
  font-size: max(1rem, var(--fs-16)); /* 16px+ so iOS does not zoom */
  line-height: 1.4;
  transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease;
}
.textarea { min-height: 7.5rem; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent); } /* taste-skill-ignore: focus ring, not elevation */
@media (hover: hover) and (pointer: fine) { .input:hover, .select:hover, .textarea:hover { border-color: var(--ink); } }
.input[disabled], .select[disabled] { background: var(--surface); color: var(--muted); cursor: not-allowed; }

.select {
  appearance: none; padding-right: 2.5rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%230B1F3A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1.1rem;
}

/* Error: red border + message under the field, linked with aria-describedby; aria-invalid on the input. */
.form-row.has-error .input, .form-row.has-error .select, .form-row.has-error .textarea, .input[aria-invalid="true"] { border-color: var(--bad); border-width: 2px; padding: calc(0.6rem - 1px) calc(0.85rem - 1px); }
.form-error { display: flex; gap: 0.4rem; align-items: flex-start; font-size: var(--fs-14); font-weight: 600; color: var(--bad); line-height: 1.4; }
.form-error svg { width: 1rem; height: 1rem; flex: none; margin-top: 0.15rem; }

/* Field with a trailing button (show password). */
.input-group { position: relative; }
.input-group .input { padding-right: 3.25rem; }
.input-group .icon-btn { position: absolute; right: 0; top: 0; height: 100%; width: 3rem; border-radius: 0 var(--radius-control) var(--radius-control) 0; }

/* Checkbox and radio: native inputs, 22px, a 44px row. */
.check { display: flex; align-items: flex-start; gap: 0.75rem; min-height: var(--touch); padding-block: 0.6rem; cursor: pointer; font-size: var(--fs-16); line-height: 1.35; }
.check input:not(.switch) { appearance: none; flex: none; width: 1.375rem; height: 1.375rem; margin: 0; background: var(--sheet); border: 2px solid var(--control); border-radius: 4px; display: grid; place-content: center; cursor: pointer; transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease; }
.check input[type="radio"] { border-radius: 50%; }
.check input:not(.switch)::after { content: ""; width: 0.75rem; height: 0.75rem; transform: scale(0.6); opacity: 0; transition: transform var(--t-press) var(--ease-out), opacity var(--t-press) ease; background: var(--on-ink);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
.check input[type="radio"]::after { clip-path: circle(50%); width: 0.6rem; height: 0.6rem; }
.check input:not(.switch):checked { background: var(--ink); border-color: var(--ink); }
.check input:not(.switch):checked::after { transform: scale(1); opacity: 1; }
.check input:not(.switch):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.check small { display: block; color: var(--muted); font-size: var(--fs-14); }

/* Switch (settings rows). On colour is ink, not the brand hue. */
.switch { appearance: none; flex: none; width: 2.75rem; height: 1.625rem; margin: 0; border-radius: 999px; background: var(--control); position: relative; cursor: pointer; transition: background-color var(--t-hover) ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--sheet); transition: transform var(--t-ui) var(--ease-out); }
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(1.125rem); }
.switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.check--switch { justify-content: space-between; } /* settings row: label left, switch right */

fieldset.form-row { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.form-row legend { padding: 0; margin-bottom: 0.25rem; font-size: var(--fs-14); font-weight: 600; }

/* File picker: the native control, its button a 44px outline button. */
.form-row input[type="file"] { max-width: 100%; min-height: var(--touch); font-size: var(--fs-14); color: var(--muted); }
.form-row input[type="file"]::file-selector-button {
  min-height: var(--touch); margin-right: 0.75rem; padding: 0 1rem;
  background: var(--sheet); color: var(--ink); font: inherit; font-weight: 600;
  border: 1px solid var(--control); border-radius: var(--radius-control); cursor: pointer; /* taste-skill-ignore: panel control edge (app rules) */
}
.form-row input[type="file"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-top: 0.5rem; }
