/* Select — a single styled <select class="govbb-select">, no wrapper. The grey
   chevron cell, its divider and the arrow are painted as background layers.
   The hover shadow is two more layers in the same stack — bands confined to
   the field width so they stop at the chevron cell — painted transparent
   until :hover flips --govbb-select-hover. One stack declaration covers every
   state. */

.govbb-select {
  --govbb-select-cell: 3.875rem; /* chevron cell width (62px) */
  --govbb-select-divider: var(--govbb-color-ink); /* recoloured when invalid */
  --govbb-select-hover: transparent; /* hover band colour */

  width: 100%;
  padding: var(--govbb-space-s);
  padding-inline-end: calc(var(--govbb-select-cell) + var(--govbb-space-s));
  font: inherit;
  font-size: var(--govbb-font-size-body);
  line-height: var(--govbb-line-height-base);
  color: var(--govbb-color-ink);
  appearance: none;
  background-color: var(--govbb-color-surface);

  /* Layers, top to bottom: hover band (top), hover band (left), chevron
     arrow, cell divider, grey cell. */
  background-image:
    linear-gradient(var(--govbb-select-hover), var(--govbb-select-hover)),
    linear-gradient(var(--govbb-select-hover), var(--govbb-select-hover)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M0 0 6 8 12 0z'/%3E%3C/svg%3E"),
    linear-gradient(var(--govbb-select-divider), var(--govbb-select-divider)),
    linear-gradient(
      color-mix(
        in srgb,
        var(--govbb-color-neutral) 50%,
        var(--govbb-color-surface)
      ),
      color-mix(
        in srgb,
        var(--govbb-color-neutral) 50%,
        var(--govbb-color-surface)
      )
    );
  background-position:
    left top,
    left top,
    right calc((var(--govbb-select-cell) - 12px) / 2) center,
    right var(--govbb-select-cell) center,
    right center;
  background-repeat: no-repeat;
  background-size:
    calc(100% - var(--govbb-select-cell)) 4px,
    4px 100%,
    12px 8px,
    var(--govbb-border-width-form) 100%,
    var(--govbb-select-cell) 100%;
  border: var(--govbb-border-width-form) solid var(--govbb-color-ink);
  border-radius: var(--govbb-radius);
  outline: 0;
  transition: border-color 0.2s;
}

/* The same top/left inset shadow as other fields, stopping at the chevron. */
.govbb-select:hover {
  --govbb-select-hover: var(--govbb-overlay-dark-10);
}

/* Keyboard focus ring: shared rule in focus.css. */

.govbb-select[aria-invalid='true'] {
  --govbb-select-divider: var(--govbb-color-error);

  border-color: var(--govbb-color-error);
}

.govbb-select:disabled {
  opacity: var(--govbb-opacity-disabled);
  cursor: not-allowed;
}

/* Forced colors: the black data-URI chevron can vanish on dark system
   themes — fall back to the native picker arrow, drawn in system colors. */
@media (forced-colors: active) {
  .govbb-select {
    appearance: auto;
    background-image: none;
  }
}
