/* Shared form layout pieces — the compact field layout (templates/forms/_field.html),
   switches (templates/forms/_toggle_field.html), the segmented "pick one" control, the
   sectioned form page (profile edit), sprite cards (templates/pets/_sprite_card.html) and
   pictures in the search pickers (static/js/multiselect.js). Loaded on every page by
   base.html, after site.css; colours all come from site tokens, so dark mode follows. */

/* ---- Label row: the label, then its ⓘ help tip ------------------------------------- */

.field-label-row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

form div.field-label-row { margin-bottom: 0.3rem; }

.field-label-row .field-label {
  display: inline;
  margin: 0;
  font-weight: 800;
}

legend.field-label-row {
  margin-bottom: 0.35rem;
  padding: 0;
}

/* ---- Switch: a checkbox with its label beside it ---------------------------------- */

.toggle-field { margin-bottom: 0.7rem; }

form .toggle-field div { margin-bottom: 0; }

.toggle-field__row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.toggle-field__label {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  font-weight: 700;
  cursor: pointer;
}

.toggle-field input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  margin: 0;
  border: none;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-field input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

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

.toggle-field input[type="checkbox"]:checked::after { transform: translateX(18px); }

.toggle-field input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ---- Segmented control: radios as one row of buttons ------------------------------ */

.choice-field {
  min-width: 0;
  margin: 0 0 0.9rem;
  padding: 0;
  border: none;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 999px;
}

form .segmented { margin-bottom: 0; }

.segmented__option {
  position: relative;
  margin: 0;
  font-weight: 700;
  cursor: pointer;
}

.segmented__option + .segmented__option { border-left: 2px solid var(--line); }

.segmented__option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented__option span {
  display: block;
  padding: 0.35rem 1rem;
  color: var(--ink-soft);
  transition: background 0.12s, color 0.12s;
}

.segmented__option:hover span { color: var(--ink); }

.segmented__option input:checked + span {
  background: var(--rose);
  color: #fff;
}

.segmented__option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

/* ---- Sectioned form page ----------------------------------------------------------- */

.card.form-page {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.form-section {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 2px dashed var(--line);
}

.form-section__title {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}

.form-section__intro {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 1.2rem;
}

.form-page .ms-wrapper,
.form-tabs .ms-wrapper { max-width: none; }

.form-subheading {
  margin: 0.4rem 0 0.7rem;
  font-size: 1.25rem;
}

.form-subheading:not(:first-child) {
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--line);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1.2rem;
}

/* ---- Sprite card: preview beside the upload --------------------------------------- */

.sprite-card {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 1rem 1.2rem;
  align-items: start;
  margin-bottom: 1rem;
  padding: 0.9rem;
  border: 2px solid var(--line);
  border-radius: 14px;
}

form .sprite-card div { margin-bottom: 0; }

.sprite-card__controls {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
}

/* The preview beside the upload already shows the current sprite. */
.sprite-card .file-picker__thumb { display: none; }

.sprite-card .msp-preview { margin: 0; }

.sprite-card .msp-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 112px;
  padding: 0.5rem;
  border: 2px dashed var(--line);
  border-radius: 10px;
  text-align: center;
}

.sprite-card__frames input[type="number"] { max-width: 7rem; }

@media (max-width: 560px) {
  .sprite-card { grid-template-columns: 1fr; }
}

/* ---- Pictures in search pickers (multiselect.js `data-img`) ----------------------- */

.ms-tag-img {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
}

.ms-wrapper--single .ms-tag.has-img {
  gap: 0.6rem;
  padding: 0.3rem;
  font-weight: 700;
}

.ms-wrapper--single .ms-tag.has-img .ms-tag-img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: var(--parch-2);
}

.ms-option.has-img {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.ms-option-img {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--parch-2);
  object-fit: contain;
}

/* ---- Profile edit: avatar beside name and bio -------------------------------------- */

.profile-edit__identity {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.4rem;
  align-items: start;
}

.profile-edit__avatar .file-picker {
  flex-direction: column;
  align-items: center;
}

.profile-edit__avatar .file-picker__thumb {
  width: 150px;
  height: 150px;
  border-radius: 50%;
}

.profile-edit__avatar .file-picker__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-edit__avatar .file-picker__controls {
  flex-basis: auto;
  align-items: center;
}

/* The round picture above already shows what was picked, so hide the file name and
   keep just the button, which then fits the narrow column. */
.profile-edit__avatar input[type="file"] {
  width: 9.5rem;
  color: transparent;
}

@media (max-width: 600px) {
  .profile-edit__identity { grid-template-columns: 1fr; }
  .profile-edit__avatar .field-label-row { justify-content: center; }
}
