/* Copyright (c) 2026 Brownie, LLC. All rights reserved. */

/*
 * One look for each kind of control (CODING_STANDARDS.md, "Controls"):
 * links, fields, drop-downs, input groups and filter rows.
 */

/* ---------- One look for each kind of control (CODING_STANDARDS.md, "Controls") ---------- */

/* Links: one green everywhere, never the browser's blue. No specificity, so
   a component that colors its links (a tab, the rail) keeps its own. */
:where(body.app) :where(a) {
  color: var(--color-accent-strong);
  text-underline-offset: 2px;
}

/* A link drawn as a button or a segment reads as one: no underline. */
body.app a.button,
body.app a.segment {
  text-decoration: none;
}

/* The one field look (shared/inputs.ts): every text box, drop-down and text
   area carries `field`, wherever it sits, in the app and the admin site.
   Pages never restyle a field; width stays with each layout. */
.field {
  min-width: 0;
  min-height: var(--size-control);
  padding: 0 10px;
  border: 1px solid var(--color-control-border);
  border-radius: var(--control-radius);
  background-color: var(--color-field);
  color: var(--color-text);
  font: 500 0.95rem var(--font-body);
}

select.field {
  height: var(--size-control);
}

/* iPhone Safari zooms in on a field under 16px when it is tapped and stays
   zoomed, which leaves the page cut off at the left (issue #997). On touch
   screens a field is at least 16px. */
@media (pointer: coarse) {
  .field {
    font-size: max(16px, 0.95rem);
  }
}

/* A drop-down whose choices show a picture (components/picture-list.ts,
   for <nb-picture-select> and pictureSelect()): a
   button in the field look, with the choice's picture, its words and a
   caret, that opens .picture-select-list. Width stays with each layout. */
.picture-select {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: var(--size-control);
  text-align: left;
  cursor: pointer;
}

.picture-select-words {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* In the theme's color, as the state shapes on tournament tags (.state-tag). */
.picture-select-picture {
  flex: none;
  fill: var(--color-accent-strong);
}

.picture-select-caret {
  flex: none;
  color: var(--color-text-secondary);
}

/* The list it opens (.popover-list, below), in the field's words. */
.picture-select-list {
  font: 500 0.95rem var(--font-body);
}

.field.is-multiline {
  padding: 8px 10px;
  resize: vertical;
}

/* Text to copy as it is, such as the scanner's log as text (createTextArea, look "code"). */
.field.is-code {
  font: 0.8rem/1.4 var(--font-monospace);
}

/* iOS Safari gives a native date box its own minimum width, height and
   centered text, which push it out of its column into the next field. */
.field[type="date"] {
  appearance: none;
}

.field[type="date"]::-webkit-date-and-time-value {
  margin: 0;
  text-align: left;
}

/* A field that needs a second look (a scanned value the reader wasn't sure of). */
.field.needs-review {
  border-color: var(--color-review);
  background: var(--color-review-soft);
}

/* A field shown but not typed in, such as a batch photo's matched archer. */
input.field[readonly] {
  background: var(--color-neutral-soft);
  color: var(--color-text-secondary);
}

/* Input groups (inputGroup in ui.ts): a field with its button joined to its
   right edge, one border between them, the same height, and square corners
   where they meet. The field takes the room; a number box keeps its width. */
.input-group {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.input-group > .field,
.input-group > :is(nb-input, nb-select) > .field {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.input-group > .tournament-box,
.input-group > nb-input > .tournament-box {
  flex: none;
}

.input-group > .button,
.input-group > :is(nb-button, nb-icon-button) > .button {
  flex: none;
  justify-content: center;
  margin-left: -1px;
  white-space: nowrap;
}

.input-group > :not(:last-child),
.input-group > :is(nb-input, nb-select, nb-button, nb-icon-button):not(:last-child) > * {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group > :not(:first-child),
.input-group > :is(nb-input, nb-select, nb-button, nb-icon-button):not(:first-child) > * {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* The part pointed at or typed in draws its whole border, over the shared edge. */
.input-group > :is(:hover, :focus, :focus-visible),
.input-group
  > :is(nb-input, nb-select, nb-button, nb-icon-button)
  > :is(:hover, :focus, :focus-visible) {
  position: relative;
  z-index: 1;
}

/* A field with a small button off to its side (labeledWithAction). */
.field-with-action {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.field-with-action > .field,
.field-with-action > :is(nb-input, nb-select) > .field {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.field-with-action > .button,
.field-with-action > :is(nb-button, nb-icon-button) > .button {
  flex: none;
}

/* In a row of fields, a field with its button may be wider than the others. */
.team-form .form-field.has-input-group {
  flex-basis: 260px;
  max-width: 440px;
}

/* A row of filters that wraps on a narrow screen. */
.filter-bar,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.filter-row {
  justify-content: space-between;
}
