/*
 * The shared components. Each block here goes with a template in templates/components/
 * (named in the block's title), which says how to use it. Reads only tokens.css.
 *
 *    1. Buttons            button.html
 *    2. Cards              card.html, and the gc-card classes for a card written by hand
 *    3. Avatars            avatar.html
 *    4. Cat card           cat_card.html (the home page's "Au nevoie de tine")
 *    5. Badges and dots    badge.html, status_badge.html
 *    6. Stat tiles         stat_tile.html
 *    7. Tables             table.html
 *    8. Form fields        field.html, form_errors.html
 *    9. Empty states       empty_state.html
 *   10. Pagination         pagination.html
 *   11. Details list       (classes only)
 *   12. htmx               what a part of the page looks like while its request is running
 *   13. Confirm button     confirm_button.html
 *
 * Everything a finger can press is at least var(--gc-tap) high (44px).
 * The page at /_design (development only) shows every one of them.
 */

/* --- 1. Buttons ----------------------------------------------------------------------------- */
.gc-btn {
  min-height: var(--gc-tap);
  padding: 0 16px;
  border-radius: var(--gc-radius-pill);
  border: 1px solid transparent;
  font: inherit;
  font-size: var(--gc-text-md);
  font-weight: 600;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.gc-btn--block { flex: 1; width: 100%; }

/* The main action of a page or a card. */
.gc-btn--accent { background: var(--gc-accent); color: var(--gc-on-accent); }
.gc-btn--accent:hover { background: var(--gc-brand); color: var(--gc-on-brand); }
/* Any other action. */
.gc-btn--ghost { background: var(--gc-surface); color: var(--gc-ink); border-color: var(--gc-line); }
.gc-btn--ghost:hover { background: var(--gc-ground); color: var(--gc-ink); }
/* Something already done, which the button undoes ("Notat azi · Anulează"). */
.gc-btn--done { background: var(--gc-ok-soft); color: var(--gc-ok-soft-ink); }
.gc-btn--done:hover { color: var(--gc-ok-soft-ink); }
/* An action to think about first: an export with personal data, a merge. */
.gc-btn--warn { background: var(--gc-warn-soft); color: var(--gc-warn-soft-ink); border-color: var(--gc-warn-line); }
.gc-btn--warn:hover { color: var(--gc-warn-soft-ink); }
/* Deleting. */
.gc-btn--danger { background: var(--gc-surface); color: var(--gc-late-soft-ink); border-color: var(--gc-late); }
.gc-btn--danger:hover { background: var(--gc-late-soft); color: var(--gc-late-soft-ink); }

.gc-btn:disabled,
.gc-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- 2. Cards ------------------------------------------------------------------------------- */
.gc-card {
  background: var(--gc-surface);
  border-radius: var(--gc-radius-card);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
/* Something to check or to fix, not an error. */
.gc-card--warn {
  background: var(--gc-warn-soft);
  color: var(--gc-warn-soft-ink);
  /* An inset shadow draws the edge without making the card 2px bigger than its neighbours. */
  box-shadow: inset 0 0 0 1px var(--gc-warn-line);
}
.gc-card--warn .gc-card__title { color: var(--gc-ink); }
.gc-card--warn .gc-card__text { color: var(--gc-warn-soft-ink); }
/* A quiet tray that holds other cards, such as a column of adoption cases. */
.gc-card--sunken { background: var(--gc-chip); }

.gc-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
}
.gc-card__title {
  font-family: var(--gc-font-display);
  font-weight: 500;
  font-size: var(--gc-title-card);
  line-height: 1.15;
}
.gc-card__text {
  font-size: var(--gc-text-md);
  color: var(--gc-muted);
}
.gc-card__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--gc-tap);
  font-size: var(--gc-text-md);
  font-weight: 600;
}

/* Cards next to each other, as many as fit; one per row on a phone. */
.gc-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 18px;
}

@media (max-width: 759.98px) {
  .gc-card { padding: 16px; }
}

/* --- 3. Avatars ----------------------------------------------------------------------------- */
/* A photo, or the initial of the name on a quiet colour when there is no photo. */
.gc-avatar {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: var(--gc-radius-avatar);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--gc-font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  color: var(--gc-avatar-ink);
  background: var(--gc-avatar-0);
}
.gc-avatar--sm { width: 32px; height: 32px; border-radius: 50%; font-size: 15px; }
.gc-avatar--md { width: 48px; height: 48px; border-radius: 16px; font-size: 20px; }
.gc-avatar--xl { width: 128px; height: 128px; border-radius: 36px; font-size: 52px; }
.gc-avatar--tone-0 { background: var(--gc-avatar-0); }
.gc-avatar--tone-1 { background: var(--gc-avatar-1); }
.gc-avatar--tone-2 { background: var(--gc-avatar-2); }
.gc-avatar--tone-3 { background: var(--gc-avatar-3); }
.gc-avatar--tone-4 { background: var(--gc-avatar-4); }
.gc-avatar--tone-5 { background: var(--gc-avatar-5); }

/* --- 4. Cat card ---------------------------------------------------------------------------- */
.gc-cat-card {
  background: var(--gc-surface);
  border-radius: var(--gc-radius-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.gc-cat-card__head { display: flex; gap: 16px; align-items: center; }
.gc-cat-card__text { min-width: 0; flex: 1; }
.gc-cat-card__name {
  margin: 0;
  font-family: var(--gc-font-display);
  font-weight: 600;
  font-size: var(--gc-title-name);
  line-height: 1.15;
}
.gc-cat-card__where { margin: 2px 0 0; font-size: var(--gc-text-md); color: var(--gc-muted); }
.gc-cat-card__headline { margin: 4px 0 0; font-size: var(--gc-text-sm); font-weight: 600; color: var(--gc-link); }
.gc-cat-card__headline.is-done { color: var(--gc-ok-soft-ink); }

/* Health strip: one bar per kind of treatment, with its name under it. */
.gc-health {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.gc-health__bar { display: block; height: 10px; border-radius: 5px; background: var(--gc-none); }
.gc-health__bar[data-state="ok"] { background: var(--gc-ok); }
.gc-health__bar[data-state="late"] { background: var(--gc-late); }
.gc-health__label {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--gc-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* What the three colours of the strip mean. */
.gc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: var(--gc-text-sm);
  color: var(--gc-muted);
}
.gc-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.gc-legend__swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--gc-none); }
.gc-legend__swatch[data-state="ok"] { background: var(--gc-ok); }
.gc-legend__swatch[data-state="late"] { background: var(--gc-late); }

.gc-cat-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gc-cat-card__actions form { flex: 1; display: flex; margin: 0; }

@media (max-width: 759.98px) {
  .gc-cat-card { padding: 16px; }
}

/* --- 5. Badges and dots --------------------------------------------------------------------- */
.gc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: var(--gc-radius-pill);
  background: var(--gc-chip);
  color: var(--gc-ink);
  font-size: var(--gc-text-xs);
  font-weight: 600;
  line-height: 1.3;
}
.gc-badge--neutral { background: var(--gc-chip); color: var(--gc-ink); }
.gc-badge--ok { background: var(--gc-ok-soft); color: var(--gc-ok-soft-ink); }
.gc-badge--late { background: var(--gc-late-soft); color: var(--gc-late-soft-ink); }
.gc-badge--warn { background: var(--gc-warn-soft); color: var(--gc-warn-soft-ink); }

/* The small dot in front of a status or a place. */
.gc-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gc-muted);
}
.gc-dot--foster { background: var(--gc-dot-foster); }
.gc-dot--shelter { background: var(--gc-dot-shelter); }
.gc-dot--other { background: var(--gc-dot-other); }
.gc-dot--clinic { background: var(--gc-dot-clinic); }
.gc-dot--adopted { background: var(--gc-brand); }
.gc-dot--warn { background: var(--gc-warn-soft-ink); }
.gc-dot--none { background: var(--gc-muted); }

/* --- 6. Stat tiles -------------------------------------------------------------------------- */
.gc-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.gc-stat {
  display: block;
  flex: 1 1 132px;
  max-width: 260px;
  padding: 14px 18px;
  border-radius: var(--gc-radius-tile);
  background: var(--gc-surface);
  color: var(--gc-ink);
  text-decoration: none;
}
a.gc-stat:hover { color: var(--gc-ink); box-shadow: inset 0 0 0 2px var(--gc-line); }
.gc-stat__value {
  display: block;
  font-family: var(--gc-font-display);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.gc-stat--alert .gc-stat__value { color: var(--gc-late); }
.gc-stat__label { display: block; font-size: var(--gc-text-sm); color: var(--gc-muted); }
.gc-stat__hint { display: block; margin-top: 2px; font-size: var(--gc-text-xs); color: var(--gc-muted); }

/* --- 7. Tables ------------------------------------------------------------------------------ */
/* A wide table scrolls sideways inside its own box; the page itself never does. */
.gc-table-wrap {
  overflow-x: auto;
}
.gc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--gc-text-md);
}
.gc-table caption {
  padding-bottom: 8px;
  text-align: left;
  font-size: var(--gc-text-sm);
  color: var(--gc-muted);
}
.gc-table th,
.gc-table td {
  padding: 10px 16px 10px 0;
  text-align: left;
  vertical-align: top;
}
.gc-table th:last-child,
.gc-table td:last-child {
  padding-right: 0;
}
.gc-table thead th {
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: var(--gc-text-xs);
  font-weight: 600;
  color: var(--gc-muted);
  white-space: nowrap;
}
.gc-table tbody tr {
  border-top: 1px solid var(--gc-line);
}
.gc-table tbody th {
  font-weight: 500;
}
/* A column of numbers: to the right, with digits of equal width. */
.gc-table .gc-table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- 8. Form fields ------------------------------------------------------------------------- */
.gc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.gc-field__label {
  padding: 0;
  font-size: var(--gc-text-md);
  font-weight: 600;
}
.gc-field__optional {
  font-weight: 400;
  color: var(--gc-muted);
}

/* The text boxes: Django's own <input>, <select> and <textarea> inside a field, and any
 * control written by hand with class="gc-input". 16px text, so a phone does not zoom in. */
.gc-input,
.gc-field input:not([type="checkbox"], [type="radio"], [type="file"]),
.gc-field select,
.gc-field textarea {
  width: 100%;
  min-height: var(--gc-tap);
  padding: 0 14px;
  border: 1px solid var(--gc-line-strong);
  border-radius: var(--gc-radius-field);
  background: var(--gc-surface);
  color: var(--gc-ink);
  font-size: var(--gc-text-base);
}
textarea.gc-input,
.gc-field textarea {
  min-height: 96px;
  padding: 10px 14px;
  resize: vertical;
}
.gc-input::placeholder,
.gc-field input::placeholder,
.gc-field textarea::placeholder {
  color: var(--gc-muted);
  opacity: 1;
}
.gc-input:disabled,
.gc-field input:disabled,
.gc-field select:disabled,
.gc-field textarea:disabled {
  background: var(--gc-chip);
  color: var(--gc-muted);
  cursor: not-allowed;
}
.gc-field input[type="file"] {
  min-height: var(--gc-tap);
  max-width: 100%;
  font: inherit;
  font-size: var(--gc-text-md);
  color: var(--gc-muted);
}
/* The browser's own "Choose file" button, drawn like a ghost button. */
.gc-field input[type="file"]::file-selector-button {
  min-height: var(--gc-tap);
  margin-right: 12px;
  padding: 0 16px;
  border: 1px solid var(--gc-line);
  border-radius: var(--gc-radius-pill);
  background: var(--gc-surface);
  color: var(--gc-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
/* A field the form refused: a red edge, and the reason under it in words. */
.gc-input[aria-invalid="true"],
.gc-field [aria-invalid="true"]:not([type="checkbox"], [type="radio"]) {
  border-color: var(--gc-late);
  box-shadow: inset 0 0 0 1px var(--gc-late);
}
.gc-field__hint {
  font-size: var(--gc-text-sm);
  color: var(--gc-muted);
}
.gc-field__error {
  font-size: var(--gc-text-sm);
  font-weight: 600;
  color: var(--gc-late-soft-ink);
}

/* One tick box with its label next to it. */
.gc-field__check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--gc-tap);
  font-size: var(--gc-text-md);
  font-weight: 600;
  cursor: pointer;
}
.gc-field input[type="checkbox"],
.gc-field input[type="radio"] {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--gc-accent);
}
/* A group of choices (Django's RadioSelect or CheckboxSelectMultiple). */
.gc-field__options label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--gc-tap);
  font-size: var(--gc-text-md);
  cursor: pointer;
}

/* Fields under each other, with the form's buttons at the end. */
.gc-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  margin: 0;
}

/* --- 9. Empty states ------------------------------------------------------------------------ */
.gc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  border: 1px dashed var(--gc-line-strong);
  border-radius: var(--gc-radius-card);
  text-align: center;
}
.gc-empty__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gc-chip);
  color: var(--gc-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}
.gc-empty__title { font-size: var(--gc-text-base); font-weight: 600; }
.gc-empty__text { font-size: var(--gc-text-md); color: var(--gc-muted); }
.gc-empty .gc-btn { margin-top: 8px; }

/* --- 10. Pagination ------------------------------------------------------------------------- */
.gc-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
}
.gc-pager__status {
  font-size: var(--gc-text-md);
  color: var(--gc-muted);
  font-variant-numeric: tabular-nums;
}

/* --- 11. Details list ----------------------------------------------------------------------- */
/* <dl class="gc-details">: names on the left, values on the right. */
.gc-details {
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 16px;
  font-size: var(--gc-text-md);
}
.gc-details dt { color: var(--gc-muted); }
.gc-details dd { margin: 0; overflow-wrap: anywhere; }

/* --- 12. htmx ------------------------------------------------------------------------------- */
/* htmx would add these two rules itself, in a <style> tag, which the Content-Security-Policy
 * does not allow. They are here instead (base.html tells htmx not to add them). An element
 * with class="htmx-indicator" shows only while a request is running. */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* A cat card is dimmed while its request is running, and can't be pressed twice. */
.gc-cat-card.htmx-request { opacity: 0.6; transition: opacity 120ms; }
.gc-cat-card.htmx-request .gc-btn { pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .htmx-indicator,
  .gc-cat-card.htmx-request {
    transition: none;
  }
}

/* --- 13. Confirm button --------------------------------------------------------------------- */
/* A <details>: its <summary> is the first button, and opening it shows the button that
 * sends the form, next to the first one, or under it where there is no room. */
.gc-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.gc-confirm > summary {
  list-style: none; /* no triangle */
  user-select: none;
}
.gc-confirm > summary::-webkit-details-marker {
  display: none;
}
/* Browsers from before 2025 lay a <details> out their own way, whatever `display` says:
 * what it reveals goes under the <summary>. There the second button keeps its distance. */
@supports not selector(::details-content) {
  .gc-confirm__yes { margin-top: 8px; }
}
/* While it asks, the first button steps back and the second one carries the colour. */
.gc-confirm[open] > summary {
  border-color: var(--gc-line);
  color: var(--gc-ink);
}
.gc-confirm__yes {
  background: var(--gc-late-soft);
  color: var(--gc-late-soft-ink);
  border-color: var(--gc-late);
}
.gc-confirm__yes:hover {
  background: var(--gc-late);
  color: var(--gc-on-accent); /* 6.6:1 on late */
}
