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

/*
 * The design's components: buttons, the segmented control, the switch,
 * tags, cards, the page header, search field, filter bar and info tips.
 */

/* ---------- Components ---------- */

.button {
  min-height: var(--size-control);
}

/* A button showing only its icon (createIconButton): square, the icon in the middle. */
.button.is-icon-only {
  justify-content: center;
  width: var(--size-control);
  padding: 0;
}

.button.is-icon-only svg {
  width: 20px;
  height: 20px;
}

.button.is-danger {
  border-color: var(--color-danger-border);
  color: var(--color-danger);
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.label-caps {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.page-title {
  font-size: 2.25rem;
}

/* A choice of two or more, such as Practice or Tournament. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  border-radius: 10px;
  background: var(--color-track);
}

.segment {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control);
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text-secondary);
  font: 600 0.9rem var(--font-body);
  text-decoration: none;
  cursor: pointer;
}

/* A small choice inside a line of text, such as a photo's lane L / R. */
.segmented.is-small {
  padding: 2px;
  border-radius: 8px;
}

.segmented.is-small .segment {
  justify-content: center;
  min-width: 40px;
  min-height: 36px;
  padding: 0 10px;
}

.segment[aria-current="page"],
.segment[aria-pressed="true"] {
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
  color: var(--color-text);
}

/* A choice whose buttons share its column's whole width, such as a side
   in a form (sideChoice): up to about a drop-down's width, so two buttons
   don't stretch across a wide form. */
.segmented.is-full {
  display: flex;
  max-width: 360px;
}

.segmented.is-full .segment {
  flex: 1 1 0;
  justify-content: center;
}

/* A small or full choice's lit side: in dark mode the surface is too close
   to the track to tell, so it takes a clearly lighter fill there. */
.segmented.is-small .segment[aria-pressed="true"],
.segmented.is-full .segment[aria-pressed="true"] {
  background: var(--color-segment-lit-small);
}

/* A side, Left or Right (sideChoice): its label beside it in a row, or
   above it in a form, and a hint under it. */
.side-choice {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.side-choice-line {
  display: grid;
  gap: 4px;
}

.side-choice.is-above .side-choice-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.side-choice.is-beside .side-choice-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-choice.is-beside .side-choice-label {
  color: var(--color-text-secondary);
}

/* align "end": the choice and its hint at the line's end, anything leading
   it (a batch row's score) taking the rest of the line. */
.side-choice.is-end .side-choice-line {
  justify-content: end;
  justify-items: end;
}

.side-choice.is-end .side-choice-hint {
  text-align: end;
}

.side-choice-leading {
  flex: 1;
  min-width: 0;
}

.side-choice.is-above .segmented.is-small {
  justify-self: start;
}

.side-choice-hint {
  margin: 0;
  font-size: 0.85rem;
}

/* An on-off switch: a checkbox with role="switch". */
input[type="checkbox"].switch {
  appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  background: var(--color-control-border);
  cursor: pointer;
}

input[type="checkbox"].switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}

input[type="checkbox"].switch:checked {
  background: var(--color-accent);
}

input[type="checkbox"].switch:checked::after {
  left: 21px;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-neutral-soft);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}

/* A score's change, colored by its sign (components/score-change.parts.ts), and
   the star beside a new personal best. */
.score-change.is-up {
  color: var(--color-accent-strong);
}

.score-change.is-down {
  color: var(--color-review-text);
}

.score-change.is-same {
  color: var(--color-text-muted);
}

.best-mark {
  display: inline-flex;
  margin-left: 6px;
  color: var(--color-ten-text);
  vertical-align: -2px;
}

.star-icon {
  fill: currentcolor;
}

.tag.is-practice {
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
}

.tag.is-tournament {
  background: var(--color-tournament-soft);
  color: var(--color-tournament);
}

/* An icon with its word (Format and Kind in the scorecard tables); the word
   goes below 900px, where there's no rail and the table is tight. */
.icon-cell,
.tag .cell-word,
.tag svg {
  vertical-align: middle;
}

.icon-cell,
.tag:has(svg) {
  white-space: nowrap;
}

/* Side by side and centered on each other, so the picture sits level with the
   word whatever the font's baseline does. */
.icon-cell {
  display: inline-flex;
  align-items: center;
}

.icon-cell svg {
  flex: none;
}

.icon-cell svg,
.tag svg {
  margin-right: 6px;
}

.kind-dash {
  display: none;
}

@media (max-width: 899px) {
  .cell-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .icon-cell svg,
  .tag svg {
    margin-right: 0;
  }

  /* A column of small pictures (Format and Kind), with only the picture left: heading and cells in the middle. */
  .data-table th.is-centered,
  .data-table td.is-centered {
    text-align: center;
  }

  .tag.is-practice:has(.kind-dash) {
    padding-inline: 0;
    background: none;
  }

  .kind-dash {
    display: inline;
    color: var(--color-text-muted);
  }
}

.tag.is-review {
  background: var(--color-review-soft);
  color: var(--color-review-text);
}

.card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

/*
 * A card that opens a page, as a whole (issue #495): it lifts a little under
 * the pointer and presses in when held down, like a button. Either the card
 * is the link (a tournament on the Tournaments list), or its title's link
 * (.pressable-card-link) is stretched over the card, with the card's other
 * links and controls kept above it so they still work on their own (a
 * school's card at All schools).
 */
.pressable-card {
  position: relative;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.08s ease;
}

.pressable-card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.pressable-card :is(a, button, input, select, label):not(.pressable-card-link) {
  position: relative;
  z-index: 1;
}

.pressable-card:is(a:hover, :has(.pressable-card-link:hover)),
.pressable-card:has(.pressable-card-link:focus-visible) {
  border-color: var(--color-control-border);
  box-shadow: 0 3px 10px rgb(0 0 0 / 12%);
}

.pressable-card:is(a:active, :has(.pressable-card-link:active)) {
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 16%);
  transform: translateY(1px);
}

@media (prefers-reduced-motion: reduce) {
  .pressable-card {
    transition: none;
  }

  .pressable-card:active,
  .pressable-card:has(.pressable-card-link:active) {
    transform: none;
  }
}

.card.is-review {
  border-color: var(--color-review-border);
  background: var(--color-review-soft);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-header h2 {
  font-weight: 600;
  font-size: 1.35rem;
}

/* A card whose header has its title on the left and its buttons on the
   right (components.ts headedCard), like a stat tile's. */
.headed-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.headed-card-header > :first-child {
  min-width: 0;
}

.headed-card-actions {
  flex: none;
  display: flex;
  gap: 4px;
  margin: -6px -8px 0 0;
}

/* A link and a card's buttons side by side at the right of a header, such
   as "More on Progress" beside the numbers button. */
.card-header-end {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* The round look of an icon-only button (createIconButton, look "round"),
   for the small buttons in a card's header: the Edit pencil, the numbers. */
.button.is-icon-only.is-round {
  height: var(--size-control);
  min-height: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--color-text-muted);
}

.button.is-icon-only.is-round:hover,
.button.is-icon-only.is-round:focus-visible {
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
}

/* The states of a round icon button: rest (above), hover or keyboard focus
   (above), pressed down, switched on (`pressed`, such as Aa while its row
   shows), on and pointed at, and disabled. */
.button.is-icon-only.is-round:active {
  background: var(--color-row-pressed);
}

.button.is-icon-only.is-round.is-on {
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--color-accent);
}

.button.is-icon-only.is-round.is-on:hover,
.button.is-icon-only.is-round.is-on:focus-visible {
  background: var(--color-row-pressed);
}

.button.is-icon-only.is-round:disabled,
.button.is-icon-only.is-round:disabled:hover {
  color: var(--color-text-muted);
  background: none;
  box-shadow: none;
  opacity: 0.4;
  cursor: default;
}

/* A round Delete (kind quiet-danger): as quiet as the others until pointed at. */
.button.is-icon-only.is-round.is-danger:hover,
.button.is-icon-only.is-round.is-danger:focus-visible {
  color: var(--color-danger);
  background: var(--color-review-soft);
}

.button.is-icon-only.is-round .line-icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.6;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-divider);
  text-align: left;
}

.data-table th {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* A view's parts never grow wider than the page: a wide table scrolls in its box. */
.app-content,
.app-content .team-view,
.app-content .team-view-content {
  grid-template-columns: minmax(0, 1fr);
}

/* A page's header (components.ts pageHeader): a small line, the title,
   and the page's main buttons, which go under the title on a phone. */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-header-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.page-header .page-title {
  margin: 0;
  line-height: 1;
}

.page-header .page-title:focus:not(:focus-visible) {
  outline: none;
}

/* The title with its round "?" help link beside it. */
.page-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-help-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-link);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}

.page-help-link:hover {
  background: var(--color-accent-soft);
}

.page-eyebrow {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-notes {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.page-intro {
  max-width: 60ch;
  margin: 0;
  color: var(--color-text-secondary);
}

/* Shown only where there's no rail: under 900px wide. */
@media (min-width: 900px) {
  .phone-only {
    display: none !important;
  }
}

/* A panel opened from a page's buttons (Add archer, Edit) under its header. */
.page-panel-slot:empty {
  display: none;
}

.page-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.page-panel h2:focus:not(:focus-visible) {
  outline: none;
}

.segment-count {
  color: var(--color-text-muted);
  font-weight: 500;
}

/* A search box with its magnifier (components.ts searchField). */
.search-field {
  display: flex;
  flex: 1 1 220px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: var(--size-control);
  padding: 0 12px;
  border: 1px solid var(--color-control-border);
  border-radius: 8px;
  background: var(--color-field);
  color: var(--color-text-muted);
}

.search-field:focus-within {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.search-field input {
  flex: 1;
  min-width: 0;
  min-height: calc(var(--size-control) - 2px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  outline: none;
}

/* A filter's list with its label beside it (components.ts filterSelect). */
.filter-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.filter-field > label {
  flex: none;
}

/* A long choice (a tournament's full name) is cut short with an ellipsis
   rather than widening the list past the screen; the open list shows it whole. */
.filter-field select,
.filter-select {
  /* 100% (of a box as wide as the list needs) lets the list shrink to the
     screen; "auto" would hold it at the width of its longest choice. */
  width: 100%;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The "i" after a number's label that explains it (components.ts infoTip). */
.info-tip {
  display: inline;
}

.info-tip-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--color-text-muted);
  vertical-align: -3px;
  cursor: pointer;
}

/* The "i" in a circle (components.ts infoIcon), the same in every tile. */
.info-tip-icon {
  display: block;
  width: 100%;
  height: 100%;
}

/* A bigger area to tap than the circle it draws. */
.info-tip-button::after {
  content: "";
  position: absolute;
  inset: -12px;
}

.info-tip-button:hover,
.info-tip-button[aria-expanded="true"] {
  color: var(--color-accent-strong);
}

.info-tip-text {
  position: fixed;
  inset: auto;
  margin: 0;
  width: max-content;
  max-width: min(300px, calc(100vw - 16px));
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
}
