/**
 * Direct Mail target-area field styles.
 * Author: Murtaza — 17 September 2026
 *
 * Every rule is scoped under .dm-target-area so the pages' existing
 * stylesheets (campaign_builder.css, direct_mail_build_mailing_list.css,
 * shared_mail_targeting_tool.css, ...) are untouched. Loaded after them, so
 * these overrides win where they overlap.
 *
 * Theme (8 October 2026, from the Figma address bar): teal brand #067577,
 * panel #eef6fc, white inputs with an inset shadow and no border, DM Sans
 * (inherited from base.css) 700 / 18px in #1a629e. Labels and hints stay in
 * the markup for assistive technology but are visually hidden, because the
 * design shows the prompt as placeholder text only.
 *
 * Colours, radii and shadows read the --pl-* tokens from theme.css.
 *
 * Edit log:
 *   30 Oct 2026 - Read --pl-* tokens.
 */

.dm-target-area.address-form-container {
  background-color: var(--pl-color-surface-tint);
  border-radius: 5px;
  padding: 10px 20px;
}

.dm-target-area .address-fields {
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 30px;
  width: 100%;
  padding: 0;
  box-sizing: border-box;
}

.dm-target-area .dm-ta-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  text-align: left;
}

.dm-target-area .dm-ta-field--address {
  flex: 1 1 320px;
  max-width: 741px;
}

/* Wide enough for the whole "Enter a 5-digit ZIP code" placeholder. */
.dm-target-area .dm-ta-field--zip {
  flex: 0 1 300px;
}

.dm-target-area .dm-ta-field--zip .dm-ta-input {
  padding-left: 20px;
  padding-right: 20px;
}

/* "OR" is centred on the 53px input row, not on the whole field, so an inline
   error under a field does not push it down. */
.dm-target-area .dm-ta-divider {
  align-self: flex-start;
  display: flex;
  align-items: center;
  height: 53px;
  padding: 0;
  font-weight: 700;
  font-size: 20px;
  line-height: 26px;
  color: var(--pl-color-primary);
}

/* Visually hidden, still announced: the label names the input and the hint is
   referenced by aria-describedby. */
.dm-target-area .dm-ta-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Override the fixed 800px/200px widths from the page stylesheets so the
   fields shrink instead of forcing a horizontal scrollbar. */
.dm-target-area .dm-ta-input {
  width: 100%;
  max-width: 100%;
  height: 53px;
  padding: 15px 30px;
  border: 0;
  border-radius: 5px;
  background: var(--pl-color-surface);
  box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.1);
  font-family: 'DM Sans', Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 23px;
  color: var(--pl-color-blue);
  text-align: left;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.dm-target-area .dm-ta-input::placeholder {
  color: var(--pl-color-blue);
  opacity: 1;
}

.dm-target-area .dm-ta-input:focus-visible {
  outline: 2px solid var(--pl-color-primary);
  outline-offset: 2px;
}

.dm-target-area .dm-ta-input[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* The inputs have no border in the design, so an invalid field is marked with
   a 2px red ring (3:1 against the panel) instead of a border colour. */
.dm-target-area .dm-ta-input[aria-invalid='true'] {
  box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.1), 0 0 0 2px #c0392b;
}

/* One colour per state: while a field is invalid its focus ring is red too,
   so the teal focus ring never stacks on the red error ring. */
.dm-target-area .dm-ta-input[aria-invalid='true']:focus-visible {
  outline-color: #c0392b;
}

/* Visually hidden hint (see .dm-ta-label). */
.dm-target-area .dm-ta-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.dm-target-area .dm-ta-status {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #4a5b68;
}

.dm-target-area .dm-ta-error {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
  color: #c0392b;
}

/* The error nodes are assertive live regions. A region that is display:none at
   the instant its text arrives is skipped by several screen readers, so the
   empty error collapses with the visually-hidden pattern instead: it stays
   rendered and in the accessibility tree, is taken out of the flex flow (so it
   claims neither height nor a `gap` slot), and is clipped to nothing on screen.
   The `:empty` rule stops matching the moment showError() writes text, which
   returns the node to normal flow already-live. */
.dm-target-area .dm-ta-error:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The status node is a polite region for search progress; hiding it outright
   when empty is correct and unchanged. */
.dm-target-area .dm-ta-status:empty {
  display: none;
}

/* Suggestions are anchored to the field, not to a hardcoded page offset. */
.dm-target-area .dm-ta-listbox {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10000;
  margin: 2px 0 0 0;
  padding: 0;
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  background: var(--pl-color-surface);
  border: 1px solid var(--pl-color-accent);
  border-radius: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.dm-target-area .dm-ta-option {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 16px;
  color: var(--pl-color-blue);
  overflow-wrap: anywhere;
}

.dm-target-area .dm-ta-option:hover,
.dm-target-area .dm-ta-option[aria-selected='true'] {
  background-color: var(--pl-color-surface-tint);
}

/* Keyboard highlight must not rely on the background tint alone. */
.dm-target-area .dm-ta-option[aria-selected='true'] {
  outline: 2px solid var(--pl-color-primary);
  outline-offset: -2px;
}

/* The Shared Mail, Digital, Billboards and Streaming TV pages build their own
   suggestion list (#autocomplete-results). The container position and size
   come from each page script; only the look is themed here. */
.dm-target-area .autocomplete-results {
  border-radius: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.dm-target-area .autocomplete-suggestion {
  font-size: 16px;
  color: var(--pl-color-blue);
  text-align: left;
}

.dm-target-area .autocomplete-suggestion:hover,
.dm-target-area .autocomplete-suggestion[aria-selected='true'] {
  background-color: var(--pl-color-surface-tint);
}

/* Keyboard highlight (target_area_suggestion_keys.js) must not rely on the
   background tint alone. */
.dm-target-area .autocomplete-suggestion[aria-selected='true'] {
  outline: 2px solid var(--pl-color-primary);
  outline-offset: -2px;
}

@media (max-width: 768px) {
  .dm-target-area .address-fields {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .dm-target-area .dm-ta-divider {
    align-self: center;
    justify-content: center;
    height: auto;
  }

  .dm-target-area.address-form-container {
    padding: 10px;
  }

  .dm-target-area .dm-ta-field--address,
  .dm-target-area .dm-ta-field--zip {
    flex: 1 1 auto;
    max-width: 100%;
  }
}
