/* ============================================================
   Komponenten — Buttons, Cards, Inputs, Nav, Modals, Toasts,
   Avatare, Badges, Krone
   ============================================================ */

/* --- Icons ---------------------------------------------------- */
.icon { width: 22px; height: 22px; flex: none; stroke-width: 2; display: block; }
.icon-sm { width: 18px; height: 18px; flex: none; }
.icon-lg { width: 28px; height: 28px; flex: none; }
/* Nur echte Wrapper-Spans mit Kind-SVG füllen; ein <svg class="icon"> behält seine feste Größe. */
.icon > svg { width: 100%; height: 100%; display: block; }

/* --- Buttons -------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  height: 48px; padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--fs-md); font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  transition: transform var(--dur-1) var(--ease-standard),
              background var(--dur-2) var(--ease-standard),
              box-shadow var(--dur-2) var(--ease-standard),
              opacity var(--dur-2);
  touch-action: manipulation; user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.965); }
.btn .icon { width: 20px; height: 20px; }

.btn-primary {
  --btn-bg: var(--fando); --btn-fg: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { --btn-bg: var(--fando-600); }
.btn-primary:active { --btn-bg: var(--fando-700); }

.btn-dark { --btn-bg: var(--anthracite); --btn-fg: var(--offwhite); box-shadow: var(--shadow-sm); }
.btn-dark:hover { --btn-bg: var(--ink-800); }

.btn-ghost { --btn-bg: transparent; --btn-fg: var(--text); }
.btn-ghost:hover { --btn-bg: var(--stone-100); }

.btn-outline {
  --btn-bg: transparent; --btn-fg: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
}
.btn-outline:hover { --btn-bg: var(--stone-100); }

.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; box-shadow: var(--shadow-sm); }
.btn-danger.ghost { --btn-bg: var(--danger-tint); --btn-fg: var(--danger); box-shadow: none; }

.btn-block { display: flex; width: 100%; }
.btn-sm { height: 38px; padding: 0 var(--sp-4); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { height: 54px; font-size: var(--fs-lg); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.btn.loading { color: transparent; position: relative; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 20px; height: 20px;
  border: 2.5px solid currentColor; border-top-color: transparent;
  border-radius: 50%; color: var(--btn-fg);
  animation: spin 0.7s linear infinite;
}

/* Icon-Button */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: var(--r-md);
  color: var(--text); transition: background var(--dur-2), transform var(--dur-1);
  touch-action: manipulation;
}
.icon-btn:hover { background: var(--stone-100); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn.round { border-radius: var(--r-circle); }

/* --- Chips / Segmented --------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 34px; padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--stone-100); color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  transition: background var(--dur-2), color var(--dur-2), transform var(--dur-1);
}
.chip.active { background: var(--fando); color: #fff; }
.chip:active { transform: scale(0.95); }

.segmented {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--bg-sunken); border-radius: var(--r-md);
  position: relative;
}
.segmented button {
  flex: 1; height: 40px; padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  color: var(--text-muted);
  transition: color var(--dur-2);
  position: relative; z-index: 1;
}
.segmented button.active { color: var(--text); }
.segmented .thumb {
  position: absolute; top: 4px; bottom: 4px;
  background: var(--surface); border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur-3) var(--ease-out), width var(--dur-3) var(--ease-out);
  z-index: 0;
}

/* --- Cards ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--sp-5); }
.card-tap {
  transition: transform var(--dur-2) var(--ease-standard),
              box-shadow var(--dur-2) var(--ease-standard);
  touch-action: manipulation;
}
.card-tap:active { transform: scale(0.985); box-shadow: var(--shadow-xs); }

/* --- Inputs --------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text); }
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field .err { font-size: var(--fs-xs); color: var(--danger); font-weight: var(--fw-medium); }

.input, .textarea, .select {
  width: 100%;
  height: 50px; padding: 0 var(--sp-4);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-md); color: var(--text);
  transition: border-color var(--dur-2), box-shadow var(--dur-2), background var(--dur-2);
}
.textarea { height: auto; min-height: 96px; padding: var(--sp-3) var(--sp-4); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--stone-500); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--fando);
  box-shadow: 0 0 0 4px var(--fando-tint);
}
.input.has-error, .textarea.has-error { border-color: var(--danger); }
.input-group { position: relative; }
.input-group .input { padding-left: 46px; }
.input-group .lead {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--stone-500); pointer-events: none;
}
.input-group .trail {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
}

/* --- Avatare -------------------------------------------------- */
.avatar {
  --sz: 44px;
  width: var(--sz); height: var(--sz);
  border-radius: var(--r-circle);
  background: var(--stone-200);
  object-fit: cover; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: var(--fw-bold); color: var(--ink-600);
  overflow: hidden; position: relative;
  box-shadow: inset 0 0 0 1px rgba(35,37,37,0.06);
}
.avatar.xs { --sz: 30px; font-size: var(--fs-xs); }
.avatar.sm { --sz: 38px; font-size: var(--fs-sm); }
.avatar.lg { --sz: 64px; font-size: var(--fs-lg); }
.avatar.xl { --sz: 96px; font-size: var(--fs-2xl); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* --- Badges --------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
}
.badge-green { background: var(--fando-100); color: var(--fando-700); }
.badge-stone { background: var(--stone-100); color: var(--text-muted); }
.badge-gold  { background: var(--gold-soft); color: #8a6d1f; }
.badge-danger{ background: var(--danger-tint); color: var(--danger); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* --- Krone ---------------------------------------------------- */
.crown {
  color: var(--gold);
  filter: drop-shadow(0 1px 1px rgba(138,109,31,0.35));
}
.crown.animated { animation: crown-float 3.4s var(--ease-in-out) infinite; }
.crown-badge {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-circle);
  background: linear-gradient(160deg, #f2dfa8, #d8b45c);
  color: #6d5416; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.crown-badge .icon { width: 18px; height: 18px; position: relative; z-index: 1; }
.crown-badge::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.75), transparent);
  transform: translateX(-120%) skewX(-18deg);
  animation: crown-shine 3.6s var(--ease-in-out) 1.2s infinite;
}

/* --- Divider -------------------------------------------------- */
.divider { height: 1px; background: var(--divider); border: 0; margin: var(--sp-4) 0; }
.dot-sep { color: var(--stone-400); }

/* --- Bottom-Navigation ---------------------------------------- */
.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: var(--z-nav);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(255,255,255,0.86);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--stone-500);
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
  transition: color var(--dur-2) var(--ease-standard);
  position: relative; touch-action: manipulation;
}
.nav-item .icon { width: 24px; height: 24px; transition: transform var(--dur-3) var(--ease-spring); }
.nav-item.active { color: var(--fando); }
.nav-item.active .icon { transform: translateY(-1px) scale(1.06); }
.nav-item .nav-badge {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff;
  border-radius: var(--r-pill);
  font-size: 10px; font-weight: var(--fw-bold);
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.nav-item::before {
  content: ""; position: absolute; top: -1px; width: 26px; height: 3px;
  border-radius: var(--r-pill); background: var(--fando);
  transform: scaleX(0); transition: transform var(--dur-3) var(--ease-spring);
}
.nav-item.active::before { transform: scaleX(1); }

/* --- App-Header ----------------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: var(--z-header);
  display: flex; align-items: flex-end; gap: var(--sp-3);
  padding: calc(var(--safe-top) + 22px) var(--sp-5) 15px;
  background: rgba(248,247,252,0.86);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-3), padding var(--dur-3) var(--ease-out);
}
.app-header.scrolled { border-bottom-color: var(--border); }
.ah-nav { align-self: center; }
.ah-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ah-eyebrow {
  font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  letter-spacing: 0.11em; text-transform: uppercase; color: var(--fando);
  margin-bottom: 4px; display: inline-flex; align-items: center; gap: 6px;
}
.ah-eyebrow::before { content: ""; width: 14px; height: 2px; border-radius: 2px; background: var(--fando); }
.ah-title { font-size: var(--fs-2xl); font-weight: var(--fw-black); letter-spacing: var(--tracking-tight); line-height: 1.08; }
.ah-sub { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); margin-top: 3px; }
.ah-actions { align-self: center; display: flex; align-items: center; gap: 6px; }

/* --- Modal / Sheet -------------------------------------------- */
.backdrop {
  position: absolute; inset: 0; z-index: var(--z-modal);
  background: rgba(35,37,37,0.42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: backdrop-in var(--dur-2) ease both;
}
.backdrop.center { align-items: center; padding: var(--sp-4); }
.sheet {
  width: 100%; max-width: var(--app-max);
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + var(--safe-bottom));
  box-shadow: var(--shadow-xl);
  animation: modal-in var(--dur-4) var(--ease-out) both;
  max-height: 92dvh; overflow-y: auto;
}
.sheet .grabber {
  width: 40px; height: 4px; border-radius: var(--r-pill);
  background: var(--stone-300); margin: 4px auto var(--sp-4);
}
.dialog {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: var(--r-lg);
  padding: var(--sp-6); box-shadow: var(--shadow-xl);
  animation: modal-in var(--dur-3) var(--ease-out) both;
}

/* --- Toasts --------------------------------------------------- */
.toast-wrap {
  position: absolute; top: calc(var(--safe-top) + 10px); left: 0; right: 0;
  z-index: var(--z-toast);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-4); pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--sp-3);
  max-width: 100%; padding: var(--sp-3) var(--sp-4);
  background: var(--anthracite); color: var(--offwhite);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  animation: toast-in var(--dur-3) var(--ease-out) both;
}
.toast.leaving { animation: fade-up var(--dur-2) var(--ease-standard) reverse both; }
.toast .icon { width: 20px; height: 20px; flex: none; }
.toast.success .icon { color: var(--fando-300); }
.toast.error .icon { color: #e98a76; }

/* --- Empty / Loading States ----------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-6); text-align: center; color: var(--text-muted);
}
.empty .icon { width: 44px; height: 44px; color: var(--stone-400); }

.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2.5px solid var(--stone-200); border-top-color: var(--fando);
  animation: spin 0.7s linear infinite;
}

/* --- Progress-Ripple (pulse ring auf Avataren o.ä.) ----------- */
.ripple { position: relative; }
.ripple::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  border: 2px solid var(--fando);
  animation: pulse-ring 1.8s var(--ease-out) infinite;
}
