/* ============================================================================
 * Odahl — Forms
 * Editorial form controls. Italic Cormorant labels. Hairline borders.
 * Vespera focus states. Ember validation tones. Requires tokens.css.
 * ============================================================================ */

/* ── Field wrap: label + input + helper, vertical stack ───────────── */
.odahl-field {
  display: flex; flex-direction: column; gap: 0.4rem;
  margin-bottom: var(--gap-sm);
}
.odahl-field-label {
  font-family: var(--display); font-style: italic;
  font-size: var(--type-body-sm); font-weight: 500;
  color: var(--ink); letter-spacing: -0.005em;
}
.odahl-field-label .required { color: var(--ember-deep); margin-left: 0.2rem; }
.odahl-field-helper {
  font-family: var(--body); font-size: 0.82rem;
  color: var(--ink-mute); line-height: 1.5;
}
.odahl-field-error {
  font-family: var(--body); font-size: 0.82rem;
  color: var(--ember-deep); display: flex; gap: 0.4rem; align-items: flex-start;
  animation: field-error-in var(--speed-standard) var(--ease-out);
}
@keyframes field-error-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: translateY(0); } }

/* ── Text input ────────────────────────────────────────────────────── */
.odahl-input {
  width: 100%; padding: 0.65rem 0.9rem;
  border: 1px solid var(--seam); background: var(--bone);
  font-family: var(--body); font-size: var(--type-body); color: var(--ink);
  outline: none; line-height: 1.4;
  transition: border-color var(--speed-quick) var(--ease-out),
              background var(--speed-quick) var(--ease-out);
}
.odahl-input::placeholder { color: var(--ink-mute); font-style: italic; }
.odahl-input:hover:not(:focus):not([disabled]) { border-color: var(--ash-light); }
.odahl-input:focus { border-color: var(--aether-deep); background: var(--bone-warm); }
.odahl-input[disabled] { opacity: 0.5; cursor: not-allowed; }
.odahl-input[aria-invalid="true"] { border-color: var(--ember-deep); }
.odahl-input[aria-invalid="true"]:focus { border-color: var(--ember-deep); background: var(--ember-veil); }

/* ── Textarea ──────────────────────────────────────────────────────── */
.odahl-textarea {
  width: 100%; min-height: 100px; padding: 0.7rem 0.9rem;
  border: 1px solid var(--seam); background: var(--bone);
  font-family: var(--body); font-size: var(--type-body); color: var(--ink);
  outline: none; line-height: 1.55; resize: vertical;
  transition: border-color var(--speed-quick) var(--ease-out);
}
.odahl-textarea::placeholder { color: var(--ink-mute); font-style: italic; }
.odahl-textarea:focus { border-color: var(--aether-deep); background: var(--bone-warm); }
.odahl-textarea[aria-invalid="true"] { border-color: var(--ember-deep); }

/* ── Native select (use custom-select from dynamic-components for polish) ── */
.odahl-select-native {
  width: 100%; padding: 0.65rem 2rem 0.65rem 0.9rem;
  border: 1px solid var(--seam); background: var(--bone);
  font-family: var(--body); font-size: var(--type-body); color: var(--ink);
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%238E7BA3' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 12px;
}
.odahl-select-native:focus { outline: none; border-color: var(--aether-deep); background-color: var(--bone-warm); }

/* ── Checkbox: square hairline, italic check mark ───────────────────── */
.odahl-check {
  display: inline-flex; align-items: flex-start; gap: 0.6rem;
  cursor: pointer; user-select: none; padding: 0.2rem 0;
}
.odahl-check input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.odahl-check-box {
  flex-shrink: 0; width: 18px; height: 18px;
  border: 1px solid var(--seam); background: var(--bone);
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  transition: all var(--speed-quick) var(--ease-out);
}
.odahl-check input:checked ~ .odahl-check-box {
  background: var(--ink); border-color: var(--ink);
}
.odahl-check input:checked ~ .odahl-check-box::after {
  content: ''; width: 8px; height: 4px;
  border-left: 1.5px solid var(--bone); border-bottom: 1.5px solid var(--bone);
  transform: rotate(-45deg) translate(1px, -1px);
}
.odahl-check input:focus-visible ~ .odahl-check-box {
  outline: 2px solid var(--aether-deep); outline-offset: 2px;
}
.odahl-check-label {
  font-family: var(--body); font-size: var(--type-body); color: var(--ink);
  line-height: 1.5;
}

/* ── Radio: round hairline, ink-filled inner dot ────────────────────── */
.odahl-radio {
  display: inline-flex; align-items: flex-start; gap: 0.6rem;
  cursor: pointer; user-select: none; padding: 0.2rem 0;
}
.odahl-radio input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.odahl-radio-circle {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--seam); background: var(--bone);
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  transition: all var(--speed-quick) var(--ease-out);
}
.odahl-radio input:checked ~ .odahl-radio-circle { border-color: var(--aether-deep); }
.odahl-radio input:checked ~ .odahl-radio-circle::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--aether-deep);
}
.odahl-radio input:focus-visible ~ .odahl-radio-circle {
  outline: 2px solid var(--aether-deep); outline-offset: 2px;
}

/* ── Switch: editorial toggle, off → cream / on → Vespera ──────────── */
.odahl-switch {
  display: inline-flex; align-items: center; gap: 0.7rem;
  cursor: pointer; user-select: none;
}
.odahl-switch input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.odahl-switch-track {
  width: 36px; height: 20px; background: var(--seam);
  border: 1px solid var(--seam-warm);
  position: relative;
  transition: all var(--speed-standard) var(--ease-out);
}
.odahl-switch-thumb {
  position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px; background: var(--bone);
  transition: transform var(--speed-standard) var(--ease-out);
}
.odahl-switch input:checked ~ .odahl-switch-track { background: var(--aether-deep); border-color: var(--aether-deep); }
.odahl-switch input:checked ~ .odahl-switch-track .odahl-switch-thumb { transform: translateX(16px); }
.odahl-switch input:focus-visible ~ .odahl-switch-track {
  outline: 2px solid var(--aether-deep); outline-offset: 2px;
}

/* ── File upload: dropzone + browse button combined ─────────────────── */
.odahl-file {
  border: 1px dashed var(--seam); padding: 1.5rem;
  background: var(--bone-warm); text-align: center;
  cursor: pointer; transition: all var(--speed-standard) var(--ease-out);
}
.odahl-file:hover, .odahl-file[data-dragging="true"] {
  border-color: var(--aether-deep); background: var(--aether-trace);
}
.odahl-file input[type="file"] { display: none; }
.odahl-file-prompt {
  font-family: var(--display); font-style: italic; font-size: 1rem;
  color: var(--ink-soft); margin-bottom: 0.4rem;
}
.odahl-file-prompt em { color: var(--aether-deep); font-weight: 500; }
.odahl-file-hint {
  font-family: var(--body); font-size: 0.82rem; color: var(--ink-mute);
}

/* ── Field row: input + button (e.g., copy / submit on enter) ──────── */
.odahl-field-row {
  display: flex; gap: 0; align-items: stretch;
}
.odahl-field-row .odahl-input { flex: 1; border-right: 0; }
.odahl-field-row .odahl-btn { flex-shrink: 0; }

/* ── Fieldset (grouped fields) ──────────────────────────────────────── */
.odahl-fieldset {
  border: 0; padding: 0; margin: 0 0 var(--gap-lg);
}
.odahl-fieldset-legend {
  font-family: var(--display); font-style: italic;
  font-size: 0.82rem; color: var(--ink-mute);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 0.8rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--seam); width: 100%;
}

/* ── Range slider ──────────────────────────────────────────────────── */
.odahl-range {
  width: 100%; height: 4px; background: var(--seam);
  appearance: none; cursor: pointer; outline: none;
}
.odahl-range::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px;
  background: var(--aether-deep); border: 0;
  cursor: pointer;
  transition: transform var(--speed-quick) var(--ease-out);
}
.odahl-range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.odahl-range::-moz-range-thumb {
  width: 16px; height: 16px; background: var(--aether-deep);
  border: 0; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .odahl-input, .odahl-textarea, .odahl-check-box, .odahl-radio-circle,
  .odahl-switch-track, .odahl-switch-thumb, .odahl-file, .odahl-range::-webkit-slider-thumb {
    transition: none;
  }
}
