/* Shared public forms. Keep the native elements so mobile pickers, labels,
   keyboard shortcuts, IMEs and the existing submission logic stay in sync. */
@media screen {
  :root {
    --wt-field-border: #b1c2cd;
    --wt-field-focus: #12669c;
    --wt-field-radius: var(--wt-radius-control, 8px);
    --wt-field-panel: #f3f7f9;
  }

  #app :is(.lawyer-finder, .archive-filter, .lt-controls, .filter-bar) {
    background: var(--wt-field-panel) !important;
    border: 1px solid #d4e0e7 !important;
    border-radius: 14px;
    padding: clamp(16px, 2.2vw, 28px) !important;
    gap: 18px;
    box-shadow: none;
    backdrop-filter: none;
  }
  #app :is(.lawyer-finder, .archive-filter, .lt-controls, .field, .enquiry-builder) label,
  #search-dialog label {
    color: var(--wt-ink, #163345);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
  }
  #app :is(.archive-filter, .lt-controls, .enquiry-builder) label { gap: 8px; }
  #app .lawyer-filter-actions, #app .archive-filter-actions {
    gap: 8px 12px;
    align-items: center;
    flex-wrap: wrap;
  }
  :is(#app, #search-dialog) :is(input[type="search"], select, textarea) {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--wt-field-border) !important;
    border-radius: var(--wt-field-radius);
    background: #fff !important;
    box-shadow: none;
    color: var(--wt-ink, #163345);
    font: inherit;
    font-size: 16px !important;
    font-weight: 400;
    line-height: 1.45;
  }
  :is(#app, #search-dialog) select { cursor: pointer; }
  :is(#app, #search-dialog) :is(input, textarea)::placeholder {
    color: #607481;
    opacity: 1;
  }
  #app textarea { resize: vertical; }
  #search-dialog .search-input { margin-top: 8px; }
  :is(#app, #search-dialog) :is(input, select, textarea):focus-visible {
    border-color: var(--wt-field-focus) !important;
    outline: 2px solid var(--wt-field-focus);
    outline-offset: 2px;
  }
  :is(#app, #search-dialog) :is(input, select, textarea):disabled {
    color: #637783;
    border-color: #ccd8de !important;
    background: #edf2f5 !important;
    cursor: default;
  }
  #app .enquiry-builder textarea:user-invalid {
    border-color: #ad4939 !important;
  }
  #app :is(.archive-filter, .lawyer-finder, .lt-controls, .filter-bar, .enquiry-builder, #preferences-form)
       :is(.btn, .filter-reset, .lawyer-reset) {
    padding: 10px 16px;
    min-height: 46px;
    gap: 10px;
    border-radius: var(--wt-field-radius);
    line-height: 1.4;
    text-align: start;
  }
  #app :is(.filter-reset, .lawyer-reset),
  #app :is(.lt-controls, .filter-bar) .btn:is([type="reset"], [data-action^="reset"]) {
    color: var(--wt-field-focus);
    background: #fff;
    border: 1px solid var(--wt-field-border);
  }
  #app .lawyer-filter-actions .btn[type="submit"] .en {
    color: inherit !important;
    opacity: .92;
  }
  #app .network-region-tabs { gap: 6px; }
  #app .network-region-tabs button {
    min-height: 44px;
    border-radius: var(--wt-field-radius);
  }
  #app .network-region-tabs button[aria-pressed="true"] {
    color: #fff;
    background: var(--wt-field-focus);
  }
  #app .preference-options label {
    min-height: 46px;
    padding: 12px 16px;
    border-radius: var(--wt-field-radius);
    cursor: pointer;
  }
  #app .preference-options label:has(:checked) {
    background: #eaf3f8;
    border-color: var(--wt-field-focus);
  }
  #app .preference-options input { accent-color: var(--wt-field-focus); }
}

@media screen and (hover: hover) {
  :is(#app, #search-dialog) :is(input[type="search"], select, textarea):enabled:hover {
    border-color: #64859b !important;
  }
  #app :is(.filter-reset, .lawyer-reset):hover,
  #app :is(.lt-controls, .filter-bar) .btn:is([type="reset"], [data-action^="reset"]):hover {
    background: #eaf3f8;
  }
}

/* Progressive enhancement for mouse/keyboard browsers. Touch devices
   continue to open the platform picker, including on iOS and Android. */
@supports (appearance: base-select) and selector(select::picker(select)) {
  @media screen and (pointer: fine) and (hover: hover) {
    :is(#app, #search-dialog) select,
    :is(#app, #search-dialog) select::picker(select) { appearance: base-select; }
    :is(#app, #search-dialog) select {
      display: inline-flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    :is(#app, #search-dialog) select::picker-icon {
      content: "";
      flex: 0 0 auto;
      width: 7px;
      height: 7px;
      margin-inline: 4px;
      border: solid currentColor;
      border-width: 0 1.5px 1.5px 0;
      color: #506c80;
      transform: translateY(-2px) rotate(45deg);
    }
    :is(#app, #search-dialog) select:open { border-color: var(--wt-field-focus) !important; }
    :is(#app, #search-dialog) select:open::picker-icon {
      transform: translateY(2px) rotate(225deg);
    }
    :is(#app, #search-dialog) select::picker(select) {
      box-sizing: border-box;
      margin-block: 4px;
      min-inline-size: anchor-size(width);
      max-inline-size: calc(100vw - 32px);
      max-block-size: min(22rem, 50dvh);
      overflow: auto;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: #91acbd #fff;
      padding: 4px;
      border: 1px solid var(--wt-field-border);
      border-radius: 10px;
      background: white;
      color: var(--wt-ink, #163345);
      font: inherit;
      box-shadow: 0 8px 24px #15344920;
    }
    :is(#app, #search-dialog) select option {
      min-height: 40px;
      padding: 8px 12px;
      justify-content: space-between;
      gap: 12px;
      border-radius: 6px;
      white-space: normal;
      overflow-wrap: anywhere;
      font-weight: 400;
    }
    :is(#app, #search-dialog) option::checkmark { order: 1; }
    :is(#app, #search-dialog) option:checked {
      color: #124e74;
      background: #e3eff6;
      font-weight: 600;
    }
    :is(#app, #search-dialog) option:is(:hover, :focus-visible) {
      background: #eff5f8;
      outline: 1px solid #7897a8;
      outline-offset: -1px;
    }
  }
}

@media screen and (max-width: 600px) {
  #app :is(.archive-filter, .lawyer-finder, .lt-controls, .filter-bar) { gap: 14px; }
  #app .lawyer-filter-actions, #app .archive-filter-actions { justify-content: flex-start; }
  #app .lawyer-filter-actions .btn, #app .archive-filter-actions .btn { min-width: 0; }
}
