/* TEXT ENTRY LAW
 * Imported in the first named layer by the shared tokens, including auth.
 * Important declarations in this layer outrank page-local focus/hover paint,
 * even when that paint uses !important or arrives later in a dynamic drawer.
 * Fields and their containers are borderless at rest, focus and while typing.
 * The resting field and focused field use exactly the same semantic paint.
 * Commands, selects, switches, color pickers and user-authored artwork retain
 * their own semantics. Only the editable caret communicates typing focus.
 */

@layer ollira-text-entry {
:is(input:not([type]), input:is([type="text"], [type="search"], [type="email"], [type="password"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]), textarea) {
  --entry-bg: var(--ds-entry-bg, var(--auth-control, var(--field, var(--ds-color-bg-subtle, #f3f4f6))));
  --entry-ink: var(--ds-entry-ink, var(--auth-text, var(--text, var(--ds-color-text, #1d1d1f))));
  border: 0 !important;
  border-radius: var(--ds-field-control-radius, 6px) !important;
  background: var(--entry-bg) !important;
  color: var(--entry-ink) !important;
  -webkit-text-fill-color: var(--entry-ink) !important;
  outline: none !important;
  box-shadow: none !important;
  caret-color: currentColor !important;
}

/* Explicit frame owners, audited against focus-within rules across app/admin/book.
 * Do not target all labels/divs containing inputs: form rows are not field frames.
 * Future composite controls opt in with data-ds-entry-frame. */
:is(
  [data-ds-entry-frame], [class*="search"], [data-toolbar-control="search"],
  .auth-login__control, .auth-control, .authd-input, .onb-field,
  .oll-tagpicker__field, .adx__fld, .oba-field,
  .cal-v4-apptc2__priceinput, .cal-v4-apptc2__extra-step, .cal-v4-blocked-time__time-cell,
  .promo-input-affix, .promo-time-input, .olmsg__composer-box,
  .platform-support-inbox__compose-row, .platform-support-popover__compose-row,
  .platform-filter-builder__duration, .platform-filter-builder__number,
  .sc-scan, .sc-editor__input, .sc-line__disc, .sc-ledit__box, .sc-promotion-entry,
  .sc-gp-amount > div, .olwmsg-cbox,
  .platform-gantt-quick-create > label, .platform-create-task-popover__date-inputs label,
  .platform-calendar-quick-create__range label
):has(> :is(input:not([type]), input:is([type="text"], [type="search"], [type="email"], [type="password"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]), textarea, [contenteditable="true"], [contenteditable="plaintext-only"])) {
  --entry-bg: var(--ds-entry-bg, var(--auth-control, var(--field, var(--ds-color-bg-subtle, #f3f4f6))));
  --entry-ink: var(--ds-entry-ink, var(--auth-text, var(--text, var(--ds-color-text, #1d1d1f))));
  border: 0 !important;
  border-radius: var(--ds-field-control-radius, 6px) !important;
  background: var(--entry-bg) !important;
  color: var(--entry-ink) !important;
  outline: none !important;
  box-shadow: none !important;
}

/* A composite has one filled surface; neither owner nor inner editor has a border. */
:is(
  [data-ds-entry-frame], [class*="search"], [data-toolbar-control="search"],
  .auth-login__control, .auth-control, .authd-input, .onb-field,
  .oll-tagpicker__field, .adx__fld, .oba-field,
  .cal-v4-apptc2__priceinput, .cal-v4-apptc2__extra-step, .cal-v4-blocked-time__time-cell,
  .promo-input-affix, .promo-time-input, .olmsg__composer-box,
  .platform-support-inbox__compose-row, .platform-support-popover__compose-row,
  .platform-filter-builder__duration, .platform-filter-builder__number,
  .sc-scan, .sc-editor__input, .sc-line__disc, .sc-ledit__box, .sc-promotion-entry,
  .sc-gp-amount > div, .olwmsg-cbox,
  .platform-gantt-quick-create > label, .platform-create-task-popover__date-inputs label,
  .platform-calendar-quick-create__range label
) > :is(input:not([type]), input:is([type="text"], [type="search"], [type="email"], [type="password"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]), textarea) {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
}

/* Rich/plain text editors keep authored colors and document geometry. */
:is([contenteditable="true"], [contenteditable="plaintext-only"]) {
  outline: none !important;
  box-shadow: none !important;
  caret-color: currentColor !important;
}

:is(input, textarea)::placeholder {
  color: var(--ds-entry-placeholder, var(--auth-muted, var(--ds-color-text-secondary, #62656f))) !important;
  opacity: 1 !important;
}

/* Validation is a real state, independent of focus; it must remain visible. */
:is(input, textarea):is([aria-invalid="true"], .is-invalid, .input--error),
[class*="field--error"] :is(input, textarea),
[class*="field--invalid"] :is(input, textarea),
.ie-row.is-invalid .ie-in,
.ssched-time-field.is-invalid,
:is(label, div, span):has(> :is(input, textarea):is([aria-invalid="true"], .is-invalid, .input--error)),
[data-ds-entry-frame]:has([aria-invalid="true"], .is-invalid),
:is([class*="search"], .auth-login__control, .auth-control, .authd-input):has([aria-invalid="true"], .is-invalid) {
  --entry-ink: var(--auth-danger, var(--ds-color-danger, #c41e3a)) !important;
}

:is(input, textarea):disabled {
  color: var(--ds-color-text-secondary, #62656f) !important;
  -webkit-text-fill-color: var(--ds-color-text-secondary, #62656f) !important;
}

/* Autofill is a value state, never a second focus ring. Its inset paint covers
 * the UA fill without changing the frame when focus enters/leaves the field. */
input:is(:-webkit-autofill, :autofill) {
  -webkit-box-shadow: 0 0 0 1000px var(--entry-bg) inset !important;
  box-shadow: 0 0 0 1000px var(--entry-bg) inset !important;
  -webkit-text-fill-color: var(--entry-ink) !important;
}

@media (forced-colors: active) {
  :is(input, textarea, [data-ds-entry-frame]) {
    --ds-entry-bg: Canvas;
    --ds-entry-ink: CanvasText;
  }
}
}
