/*
 * Shared components: cards, buttons, alerts, badges, form controls, the photo
 * dialog. Everything here is touch-first — interactive targets stay at or
 * above 48px, which is 2.4rem at the 20px root.
 */

/* Layout helpers ------------------------------------------------------ */

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.row--baseline {
  align-items: baseline;
}

.row--top {
  align-items: flex-start;
}

.row--wrap {
  flex-wrap: wrap;
}

/* Typography ---------------------------------------------------------- */

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

.section-title {
  font-size: 1.5rem;
  font-weight: 400;
}

/* Card ---------------------------------------------------------------- */

.card {
  background-color: var(--surface);
  border-radius: var(--radius-box);
}

.card--fill {
  flex: 1 1 auto;
  min-height: 0;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.card__body--spread {
  gap: 1.25rem;
  justify-content: space-between;
  height: 100%;
}

/* For a widget that has to share a column: less air, so the card it sits next
   to keeps the height its own content needs. */
.card__body--tight {
  gap: 0.5rem;
  padding: 1.25rem;
}

.card__body--solar {
  gap: 0.4rem;
  padding: 1rem 1.25rem;
}

.card__body--clip {
  overflow: hidden;
  height: 100%;
}

.card__title {
  font-size: 1.5rem;
  font-weight: 400;
  color: rgba(var(--content-rgb), 0.6);
}

/* Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  min-width: 3rem;
  padding: 0 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-field);
  background-color: var(--surface-alt);
  color: var(--content);
  font: inherit;
  font-size: 1.125rem;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  opacity: 0.7;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn--primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-content);
}

.btn--ghost {
  background-color: transparent;
  border-color: transparent;
}

.btn--danger {
  background-color: transparent;
  border-color: var(--error);
  color: var(--error);
}

.btn--small {
  min-height: 2.4rem;
  min-width: 2.4rem;
  padding: 0 0.75rem;
  font-size: 1rem;
}

/* button_to wraps its button in a form; keep that wrapper out of the way. */
.button_to {
  margin: 0;
}

/* A button dropped straight into a card body sizes to its label instead of
   stretching over the card, which is what a flex item does by default. */
.card__body > .btn,
.card__body > .button_to {
  align-self: flex-start;
}

/* Alerts and badges ---------------------------------------------------- */

.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-field);
  font-size: 1.125rem;
  background-color: var(--surface-alt);
  color: var(--content);
}

.alert--success {
  background-color: var(--success);
  color: var(--success-content);
}

.alert--error {
  background-color: var(--error);
  color: var(--error-content);
}

.alert--warning {
  background-color: var(--warning);
  color: var(--warning-content);
}

.alert__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.5rem;
}

.badge {
  display: inline-block;
  vertical-align: middle;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background-color: var(--surface-alt);
  color: rgba(var(--content-rgb), 0.7);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Form controls -------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__label {
  font-size: 1rem;
  color: rgba(var(--content-rgb), 0.6);
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
}

.input,
.select {
  width: 100%;
  min-height: 3rem;
  padding: 0 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-field);
  background-color: var(--bg);
  color: var(--content);
  font: inherit;
  font-size: 1.125rem;
}

.input:focus,
.select:focus,
.btn:focus,
.toggle:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* The native arrow does not follow the theme, so it is drawn here instead.
   Two rules rather than one because a data URI cannot use currentColor. */
.select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.5rem;
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 0.75rem 0.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231e242e' stroke-width='2'/%3E%3C/svg%3E");
}

:root[data-theme="bredager-nat"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23c2c8d1' stroke-width='2'/%3E%3C/svg%3E");
}

.toggle {
  position: relative;
  flex: none;
  width: 3.6rem;
  height: 2rem;
  margin: 0;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background-color: var(--surface-alt);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 150ms linear;
}

.toggle::before {
  content: "";
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background-color: rgba(var(--content-rgb), 0.55);
  transition: transform 150ms linear;
}

.toggle:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.toggle:checked::before {
  transform: translateX(1.6rem);
  background-color: var(--primary-content);
}

.file-input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-field);
  background-color: var(--bg);
  color: var(--content);
  font: inherit;
  font-size: 1.125rem;
}

.file-input::-webkit-file-upload-button {
  min-height: 2.6rem;
  margin-right: 0.9rem;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-field);
  background-color: var(--surface-alt);
  color: var(--content);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.progress {
  width: 8rem;
  height: 0.6rem;
  border: 0;
  border-radius: 999px;
  background-color: var(--surface-alt);
  -webkit-appearance: none;
  appearance: none;
}

.progress::-webkit-progress-bar {
  border-radius: 999px;
  background-color: var(--surface-alt);
}

.progress::-webkit-progress-value {
  border-radius: 999px;
  background-color: var(--primary);
}

/* Photo dialog --------------------------------------------------------- */

.modal {
  width: 95vw;
  max-width: 95vw;
  height: 90vh;
  max-height: 90vh;
  padding: 0;
  border: 0;
  background-color: transparent;
  color: var(--content);
}

.modal::backdrop {
  background-color: rgba(0, 0, 0, 0.7);
}

.modal__box {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  padding: 1rem;
  border-radius: var(--radius-box);
  background-color: var(--bg);
}

.modal__image {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}

/* Feed colours ---------------------------------------------------------- */

/* Picked on a phone, so each swatch is its own tap target rather than a row in
   a select. `:checked + span` rather than `:has`, which the frame cannot use
   and admin pages have no reason to need either. */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.swatch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
}

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

.swatch__dot {
  display: inline-block;
  flex: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background-color: rgb(var(--feed));
}

.swatch__input:checked ~ .swatch__name {
  font-weight: 600;
}

.swatch__input:checked ~ .swatch__dot {
  box-shadow: 0 0 0 3px rgba(var(--feed), 0.35);
}

.swatch__input:focus ~ .swatch__dot {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
