/* =====================================================================
   Zappelix – Komponenten
   Benötigt: tokens.css. Alle Klassen mit Präfix "zx-".
   Inhalt: 1 Basis · 2 Buttons · 3 Glas & Neon · 4 Karten · 5 Tags & Chips
           6 Formulare · 7 Icons · 8 Hilfsklassen
   ===================================================================== */

/* ---------- 1. Basis (optional – passt zum Rest der Seite) ---------- */
.zx-base *, .zx-base *::before, .zx-base *::after { box-sizing: border-box; }
.zx-base,
.zx-base body {
  font-family: var(--zx-font-body);
  font-size: var(--zx-text-base);
  line-height: var(--zx-leading-normal);
  color: var(--zx-text);
  background: var(--zx-grad-sky);
  -webkit-font-smoothing: antialiased;
}
.zx-base :is(h1, h2, h3, h4) {
  font-family: var(--zx-font-heading);
  color: var(--zx-text-strong);
  line-height: var(--zx-leading-tight);
  font-weight: var(--zx-weight-extrabold);
  letter-spacing: var(--zx-tracking-tight);
  margin: 0 0 var(--zx-space-3);
}
.zx-base h1 { font-size: var(--zx-text-4xl); }
.zx-base h2 { font-size: var(--zx-text-3xl); }
.zx-base h3 { font-size: var(--zx-text-xl); line-height: var(--zx-leading-snug); }
.zx-base :where(a:not([class])) { color: var(--zx-primary); text-underline-offset: .2em; text-decoration-thickness: .08em; }
.zx-base :where(a:not([class])):hover { color: var(--zx-primary-strong); }
.zx-base ::selection { background: var(--zx-violet-200); color: var(--zx-text-strong); }

/* Einheitlicher, gut sichtbarer Fokusring für alles Interaktive */
.zx-base :focus-visible,
.zx-focusable:focus-visible {
  outline: 3px solid var(--zx-focus);
  outline-offset: 3px;
  border-radius: var(--zx-radius-sm);
}

.zx-eyebrow {
  display: inline-flex; align-items: center; gap: var(--zx-space-2);
  font-family: var(--zx-font-body);
  font-size: var(--zx-text-xs);
  font-weight: var(--zx-weight-extrabold);
  letter-spacing: var(--zx-tracking-wide);
  text-transform: uppercase;
  color: var(--zx-primary);
}

/* ---------- 2. Buttons ---------- */
.zx-btn {
  box-sizing: border-box;
  --_bg: var(--zx-grad-button);
  --_fg: var(--zx-text-on-primary);
  --_shadow: var(--zx-shadow-md), 0 6px 20px -8px rgba(124, 58, 237, .6);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: var(--zx-tap-target);
  padding: .7em 1.4em;
  border: 2px solid transparent;
  border-radius: var(--zx-radius-pill);
  background: var(--_bg);
  color: var(--_fg);
  font-family: var(--zx-font-heading);
  font-size: var(--zx-text-base);
  font-weight: var(--zx-weight-bold);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--_shadow);
  transition:
    transform var(--zx-duration-base) var(--zx-ease-bounce),
    box-shadow var(--zx-duration-base) var(--zx-ease-out),
    background-color var(--zx-duration-fast) var(--zx-ease-out),
    color var(--zx-duration-fast) var(--zx-ease-out);
  -webkit-tap-highlight-color: transparent;
}
.zx-btn:hover { transform: translateY(-2px); box-shadow: var(--zx-shadow-lg), var(--zx-glow-violet); }
.zx-btn:active { transform: translateY(1px) scale(.97); box-shadow: var(--zx-shadow-sm); transition-duration: var(--zx-duration-instant); }
.zx-btn:focus-visible { outline: none; box-shadow: var(--zx-focus-ring), var(--_shadow); }
.zx-btn:disabled, .zx-btn[aria-disabled="true"] {
  cursor: not-allowed; transform: none; box-shadow: none;
  background: var(--zx-violet-100); color: var(--zx-text-muted);
}
.zx-btn .zx-icon { width: 1.2em; height: 1.2em; flex: none; }

/* Sekundär: helle Fläche, violetter Rand */
.zx-btn--secondary {
  --_bg: var(--zx-surface);
  --_fg: var(--zx-primary-strong);
  --_shadow: var(--zx-shadow-sm);
  border-color: var(--zx-violet-300);
}
.zx-btn--secondary:hover { border-color: var(--zx-primary); background: var(--zx-primary-soft); }

/* Ghost: ohne Fläche, für Nebenaktionen */
.zx-btn--ghost {
  --_bg: transparent;
  --_fg: var(--zx-primary-strong);
  --_shadow: none;
}
.zx-btn--ghost:hover { background: var(--zx-primary-soft); box-shadow: none; transform: none; }

/* Akzent (gelb): z. B. „Mit KI erstellen“ */
.zx-btn--accent {
  --_bg: linear-gradient(135deg, var(--zx-amber-300), var(--zx-amber-400));
  --_fg: var(--zx-text-on-accent);
  --_shadow: var(--zx-shadow-md), 0 6px 20px -8px rgba(245, 158, 11, .7);
}
.zx-btn--accent:hover { box-shadow: var(--zx-shadow-lg), var(--zx-glow-amber); }

.zx-btn--small { min-height: 36px; padding: .5em 1em; font-size: var(--zx-text-sm); }
.zx-btn--large { min-height: 56px; padding: .9em 1.8em; font-size: var(--zx-text-lg); }
.zx-btn--block { width: 100%; }

/* Icon-Button: rund, 44 × 44 px, braucht aria-label */
.zx-icon-btn {
  display: inline-grid; place-items: center;
  width: var(--zx-tap-target); height: var(--zx-tap-target);
  padding: 0;
  border: 2px solid var(--zx-border);
  border-radius: 50%;
  background: var(--zx-surface);
  color: var(--zx-primary-strong);
  cursor: pointer;
  box-shadow: var(--zx-shadow-xs);
  transition: transform var(--zx-duration-base) var(--zx-ease-bounce), background-color var(--zx-duration-fast), border-color var(--zx-duration-fast), color var(--zx-duration-fast);
}
.zx-icon-btn .zx-icon { width: 22px; height: 22px; }
.zx-icon-btn:hover { transform: scale(1.08); border-color: var(--zx-violet-300); background: var(--zx-primary-soft); }
.zx-icon-btn:active { transform: scale(.94); }
.zx-icon-btn:focus-visible { outline: none; box-shadow: var(--zx-focus-ring); }
/* Favorit-Herz: aria-pressed="true" = gemerkt */
.zx-icon-btn--fav[aria-pressed="true"] { color: var(--zx-pink-700); border-color: #fbcfe8; background: var(--zx-warm-soft); }
.zx-icon-btn--fav[aria-pressed="true"] .zx-icon path { fill: currentColor; }
.zx-icon-btn--fav[aria-pressed="true"] .zx-icon { animation: zx-pop var(--zx-duration-slow) var(--zx-ease-spring); }

@keyframes zx-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ---------- 3. Glas & Neon ---------- */
.zx-glass {
  background: var(--zx-surface-glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--zx-shadow-md), inset 0 1px 0 rgba(255, 255, 255, .8);
}
[data-theme="dark"] .zx-glass { border-color: rgba(167, 139, 250, .22); box-shadow: var(--zx-shadow-md), inset 0 1px 0 rgba(255, 255, 255, .06); }

/* Neon-Kante: leuchtender Verlaufsrand (über ::before-Maske) */
.zx-neon { position: relative; isolation: isolate; }
.zx-neon::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  padding: 2px; border-radius: inherit;
  background: var(--zx-neon-color, var(--zx-grad-neon));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .55;
  transition: opacity var(--zx-duration-base) var(--zx-ease-out);
  pointer-events: none;
}
.zx-neon:hover::before, .zx-neon:focus-within::before { opacity: 1; }

/* ---------- 4. Karten ---------- */
.zx-card {
  --cat: var(--zx-violet-500);
  --cat-soft: var(--zx-violet-100);
  --cat-text: var(--zx-violet-700);
  --cat-glow: rgba(139, 92, 246, .35);
  position: relative;
  display: flex; flex-direction: column; gap: var(--zx-space-3);
  padding: var(--zx-space-5);
  border-radius: var(--zx-radius-lg);
  background: var(--zx-surface);
  color: var(--zx-text);
  box-shadow: var(--zx-shadow-md);
  transition: transform var(--zx-duration-base) var(--zx-ease-bounce), box-shadow var(--zx-duration-base) var(--zx-ease-out);
}
.zx-card.zx-glass { background: var(--zx-surface-glass); }
.zx-card:hover, .zx-card:focus-within { transform: translateY(-4px); box-shadow: var(--zx-shadow-lg), 0 12px 36px -10px var(--cat-glow); }

/* Kategorie-Farben (Klasse an Karte, Tag oder Chip) */
.zx-cat--aktivitaet  { --cat: var(--zx-violet-500); --cat-soft: var(--zx-violet-100); --cat-text: var(--zx-violet-700); --cat-glow: rgba(139, 92, 246, .40); }
.zx-cat--reim        { --cat: var(--zx-pink-400);   --cat-soft: #fce7f3;              --cat-text: var(--zx-pink-700);   --cat-glow: rgba(244, 114, 182, .40); }
.zx-cat--experiment  { --cat: var(--zx-cyan-400);   --cat-soft: #ccfbf1;              --cat-text: var(--zx-teal-700);   --cat-glow: rgba(34, 211, 238, .45); }
.zx-cat--jahreskreis { --cat: var(--zx-amber-400);  --cat-soft: #fef3c7;              --cat-text: var(--zx-amber-800);  --cat-glow: rgba(251, 191, 36, .45); }
.zx-cat--ki-helfer   { --cat: var(--zx-violet-600); --cat-soft: #e0e7ff;              --cat-text: var(--zx-violet-700); --cat-glow: rgba(34, 211, 238, .40); }
/* (Kontrast Tag-Text auf Tag-Fläche: Aktivität 5,98 · Reim 5,14 · Experiment 4,86 · Jahreskreis 6,37 · KI-Helfer 5,77 – alle AA, siehe contrast-check.py) */

/* Aktivitätskarte: Glas + Neon-Akzentkante oben + Kategorie-Bildfeld */
.zx-card--activity { overflow: hidden; padding-top: calc(var(--zx-space-5) + 4px); }
.zx-card--activity::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, var(--cat), color-mix(in srgb, var(--cat) 30%, var(--zx-secondary)));
  box-shadow: 0 0 14px var(--cat-glow);
}
.zx-card__media {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: var(--zx-radius-md);
  background:
    radial-gradient(60% 80% at 20% 20%, rgba(255,255,255,.9), transparent 60%),
    linear-gradient(135deg, var(--cat-soft), color-mix(in srgb, var(--cat) 35%, white));
  color: var(--cat-text);
  font-size: 2.6rem;
  overflow: hidden;
}
.zx-card__media .zx-icon { width: 56px; height: 56px; stroke-width: 1.6; }
.zx-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--zx-space-2); }
.zx-card__title {
  margin: 0;
  font-family: var(--zx-font-heading);
  font-size: var(--zx-text-xl);
  font-weight: var(--zx-weight-extrabold);
  line-height: var(--zx-leading-snug);
  color: var(--zx-text-strong);
}
.zx-card__title a { color: inherit; text-decoration: none; }
.zx-card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* ganze Karte klickbar */
.zx-card__title a:focus-visible { outline: none; }
.zx-card:has(.zx-card__title a:focus-visible) { box-shadow: var(--zx-focus-ring), var(--zx-shadow-lg); }
.zx-card__text { margin: 0; color: var(--zx-text-muted); font-size: var(--zx-text-sm); line-height: var(--zx-leading-normal); }
.zx-card__meta {
  display: flex; flex-wrap: wrap; gap: var(--zx-space-2) var(--zx-space-4);
  margin: 0; padding: 0; list-style: none;
  font-size: var(--zx-text-sm); font-weight: var(--zx-weight-bold); color: var(--zx-text-muted);
}
.zx-card__meta li { display: inline-flex; align-items: center; gap: .35em; }
.zx-card__meta .zx-icon { width: 18px; height: 18px; color: var(--cat-text); }
.zx-card__footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--zx-space-2); padding-top: var(--zx-space-2); }
.zx-card__footer > * { position: relative; z-index: 1; } /* über dem Karten-Link */

/* ---------- 5. Tags & Chips ---------- */
/* Tag: nicht interaktiv, zeigt Kategorie */
.zx-tag {
  display: inline-flex; align-items: center; gap: .35em;
  padding: .3em .75em;
  border-radius: var(--zx-radius-pill);
  background: var(--cat-soft, var(--zx-primary-soft));
  color: var(--cat-text, var(--zx-primary-strong));
  font-size: var(--zx-text-xs);
  font-weight: var(--zx-weight-extrabold);
  letter-spacing: .02em;
  line-height: 1.2;
  white-space: nowrap;
}
.zx-tag .zx-icon { width: 14px; height: 14px; stroke-width: 2.4; }
.zx-tag--ki { background: linear-gradient(135deg, #ede9fe, #cffafe); color: var(--zx-violet-700); }

/* Chip: Filter-Schalter (button mit aria-pressed) */
.zx-chip {
  display: inline-flex; align-items: center; gap: .45em;
  min-height: 40px;
  padding: .45em 1em;
  border: 2px solid var(--zx-border);
  border-radius: var(--zx-radius-pill);
  background: var(--zx-surface);
  color: var(--zx-text);
  font-family: var(--zx-font-body);
  font-size: var(--zx-text-sm);
  font-weight: var(--zx-weight-bold);
  cursor: pointer;
  transition: background-color var(--zx-duration-fast), border-color var(--zx-duration-fast), color var(--zx-duration-fast), transform var(--zx-duration-base) var(--zx-ease-bounce), box-shadow var(--zx-duration-base);
}
.zx-chip .zx-icon { width: 18px; height: 18px; color: var(--cat-text, var(--zx-primary)); }
.zx-chip:hover { border-color: var(--cat, var(--zx-violet-300)); transform: translateY(-1px); }
.zx-chip:active { transform: scale(.96); }
.zx-chip:focus-visible { outline: none; box-shadow: var(--zx-focus-ring); }
.zx-chip[aria-pressed="true"] {
  background: var(--cat-soft, var(--zx-primary-soft));
  border-color: var(--cat, var(--zx-primary));
  color: var(--cat-text, var(--zx-primary-strong));
  box-shadow: 0 4px 14px -4px var(--cat-glow, rgba(139, 92, 246, .45));
}
.zx-chip[aria-pressed="true"]::after { content: "✓"; font-weight: 800; }
.zx-chip-group { display: flex; flex-wrap: wrap; gap: var(--zx-space-2); }

/* ---------- 6. Formulare ---------- */
.zx-field { display: grid; gap: var(--zx-space-2); }
.zx-label { font-weight: var(--zx-weight-extrabold); font-size: var(--zx-text-sm); color: var(--zx-text-strong); }
.zx-hint { font-size: var(--zx-text-xs); color: var(--zx-text-muted); }
.zx-input, .zx-select, .zx-textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: .7em 1em;
  border: 2px solid var(--zx-border-strong);    /* 3,59:1 → als Bedienelement erkennbar */
  border-radius: var(--zx-radius-md);
  background: var(--zx-surface);
  color: var(--zx-text);
  font: inherit;
  font-size: var(--zx-text-base);
  transition: border-color var(--zx-duration-fast), box-shadow var(--zx-duration-base) var(--zx-ease-out);
}
.zx-textarea { min-height: 120px; resize: vertical; line-height: var(--zx-leading-normal); }
.zx-input::placeholder, .zx-textarea::placeholder { color: var(--zx-text-muted); opacity: 1; }
.zx-input:hover, .zx-select:hover, .zx-textarea:hover { border-color: var(--zx-primary); }
.zx-input:focus-visible, .zx-select:focus-visible, .zx-textarea:focus-visible {
  outline: none;
  border-color: var(--zx-primary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, .28), var(--zx-glow-violet);
}
.zx-select {
  appearance: none; padding-right: 2.6em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c3aed' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .9em center; background-size: 1.1em;
}
.zx-field--error .zx-input, .zx-input[aria-invalid="true"] { border-color: var(--zx-error); }
.zx-field--error .zx-input:focus-visible, .zx-input[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 4px rgba(190, 18, 60, .2); }
.zx-error-text { display: flex; gap: .4em; align-items: center; font-size: var(--zx-text-xs); font-weight: var(--zx-weight-bold); color: var(--zx-error); }

/* Suchfeld mit Icon */
.zx-search { position: relative; }
.zx-search .zx-icon { position: absolute; left: 1em; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--zx-primary); pointer-events: none; }
.zx-search .zx-input { padding-left: 2.9em; border-radius: var(--zx-radius-pill); }

/* Checkbox / Schalter */
.zx-check { display: inline-flex; align-items: center; gap: .6em; font-weight: var(--zx-weight-semibold); cursor: pointer; }
.zx-check input {
  appearance: none; flex: none;
  width: 24px; height: 24px; margin: 0;
  border: 2px solid var(--zx-border-strong); border-radius: 8px;
  background: var(--zx-surface);
  display: grid; place-items: center;
  transition: background-color var(--zx-duration-fast), border-color var(--zx-duration-fast), transform var(--zx-duration-base) var(--zx-ease-bounce);
}
.zx-check input::after { content: ""; width: 10px; height: 6px; border: 3px solid #fff; border-top: 0; border-right: 0; rotate: -45deg; translate: 0 -1px; scale: 0; transition: scale var(--zx-duration-base) var(--zx-ease-spring); }
.zx-check input:checked { background: var(--zx-primary); border-color: var(--zx-primary); }
.zx-check input:checked::after { scale: 1; }
.zx-check input:focus-visible { outline: 3px solid var(--zx-focus); outline-offset: 2px; }

/* ---------- 7. Icons ---------- */
.zx-icon { width: 24px; height: 24px; flex: none; vertical-align: middle; }
.zx-icon-badge {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; border-radius: var(--zx-radius-md);
  background: var(--cat-soft, var(--zx-primary-soft)); color: var(--cat-text, var(--zx-primary-strong));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 6px 16px -8px var(--cat-glow, rgba(139,92,246,.5));
}

/* ---------- 8. Hilfsklassen ---------- */
.zx-visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.zx-gradient-text { background: var(--zx-grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; } /* nur für große Überschriften */
.zx-float { animation: zx-float-y var(--zx-duration-float) var(--zx-ease-in-out) infinite; }
@keyframes zx-float-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

@media (prefers-reduced-motion: reduce) {
  .zx-btn, .zx-icon-btn, .zx-chip, .zx-card, .zx-check input, .zx-check input::after { transition: none; }
  .zx-btn:hover, .zx-card:hover, .zx-card:focus-within, .zx-chip:hover, .zx-icon-btn:hover { transform: none; }
  .zx-float, .zx-icon-btn--fav[aria-pressed="true"] .zx-icon { animation: none; }
}
