/* ==========================================================================
   Wiederverwendbare Bausteine – von allen Bereichen nutzbar.
   Namenskonvention: BEM-artig  .block, .block__element, .block--variante
   ========================================================================== */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-5);
  border: none;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast), opacity var(--dur-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn--danger {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
}

.btn--block {
  width: 100%;
}

.btn--small {
  min-height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-s);
}

/* Runder Icon-Button (z. B. "Standort", "Schließen") */
.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-s);
  transition: transform var(--dur-fast) var(--ease-out);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* Schwebender Haupt-Button (Floating Action Button) */
.fab {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 20px;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-m), 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform var(--dur-m) var(--ease-spring);
}

.fab:active {
  transform: scale(0.9) rotate(90deg);
}

/* --- Karten / Kacheln -------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  padding: var(--space-4);
}

/* --- Chips & Segment-Schalter ------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--text-s);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}

/* Chips als Radio-Buttons: das <input> ist versteckt, das Label ist der Chip */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip-group input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-group input:checked + .chip {
  border-color: var(--chip-color, var(--accent));
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 14%, var(--surface));
  color: var(--text);
}

.chip-group input:focus-visible + .chip {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip-color, var(--accent));
}

/* Segment-Schalter (zwei bis drei gleichwertige Optionen nebeneinander) */
.segmented {
  display: flex;
  padding: 4px;
  gap: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-s);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-m) var(--ease-out), color var(--dur-fast), box-shadow var(--dur-m);
}

.segmented input:checked + label {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-s);
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
}

/* --- Formulare ----------------------------------------------------------- */

.form {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: grid;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--text-s);
  font-weight: 600;
  color: var(--text-muted);
}

.input {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid transparent;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  /* 16px verhindert das automatische Hineinzoomen von iOS beim Fokussieren */
  font-size: 16px;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

textarea.input {
  min-height: 110px;
  resize: vertical;
}

/* <fieldset> ohne Browser-Rahmen (für Gruppen wie Kategorie-Chips) */
.fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.fieldset legend {
  padding: 0;
  margin-bottom: var(--space-2);
}

/* Foto-Feld (core/ui/photo-field.js) */
.photo-field {
  display: grid;
  gap: var(--space-2);
}

.photo-field__preview {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius-m);
}

.photo-field__pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 56px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-m);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}

.photo-field__pick:hover,
.photo-field__pick:focus-within {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* Schalter-Zeile mit Checkbox (z. B. "Bald machen") */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 48px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  font-weight: 500;
  cursor: pointer;
}

.toggle-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

/* --- Bottom-Sheet (von unten hereingleitendes Panel) --------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgb(15 25 18 / 0.35);
  animation: fade-in var(--dur-m) var(--ease-out) both;
}

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 2001;
  max-width: var(--content-max);
  max-height: 92dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-l);
  animation: sheet-in var(--dur-slow) var(--ease-out) both;
}

.sheet.is-closing {
  animation: sheet-out var(--dur-m) ease-in both;
  pointer-events: none; /* kein Doppel-Absenden während des Ausblendens */
}

.sheet-backdrop.is-closing {
  animation: fade-out var(--dur-m) ease-in both;
}

/* Kleiner "Griff" oben – signalisiert: das ist ein Sheet */
.sheet__handle {
  width: 40px;
  height: 5px;
  margin: var(--space-2) auto 0;
  border-radius: var(--radius-pill);
  background: var(--border);
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-2) var(--space-5);
}

.sheet__header h2 {
  font-size: var(--text-l);
}

.sheet__header .icon-btn {
  box-shadow: none;
  background: var(--surface-2);
  width: 36px;
  height: 36px;
}

.sheet__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-3) var(--space-5) calc(var(--space-5) + var(--safe-bottom));
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

/* --- Toast (kurze Meldung unten) ---------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-4));
  z-index: 3000;
  max-width: calc(100% - 2 * var(--space-4));
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-s);
  font-weight: 500;
  box-shadow: var(--shadow-m);
  transform: translateX(-50%);
  animation: toast-in var(--dur-m) var(--ease-spring) both;
}

.toast.is-closing {
  animation: fade-out var(--dur-m) ease-in both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.96);
  }
}

/* --- Herzchen-Animation (core/ui/celebrate.js) --------------------------- */

.celebrate {
  position: fixed;
  z-index: 3000;
  width: 0;
  height: 0;
  pointer-events: none;
}

.celebrate__heart {
  position: absolute;
  left: -9px;
  top: -9px;
  color: var(--heart);
  animation: heart-fly 1.1s var(--ease-out) both;
}

.celebrate__heart svg {
  fill: currentColor;
}

@keyframes heart-fly {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.2);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(var(--scale));
  }
}

/* --- Kleinkram ------------------------------------------------------------ */

.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.muted {
  color: var(--text-muted);
}
