/* ==========================================================================
   Grundlagen: Reset, Typografie, Hilfsklassen, Schaltflächen, Formulare, Chips
   ========================================================================== */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
  body { min-height: 100dvh; }
  img, svg, video, canvas, iframe { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  a { color: inherit; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  h1, h2, h3, h4 { text-wrap: balance; }
  p { text-wrap: pretty; }
  [hidden] { display: none !important; }
  table { border-collapse: collapse; }
}

@layer base {
  body {
    font-family: var(--font-text);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
    font-feature-settings: "ss01", "cv11";
  }

  h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -.02em;
    overflow-wrap: break-word; hyphens: auto;
  }
  h1 { font-size: var(--fs-h1); font-weight: 800; letter-spacing: -.035em; }
  h2 { font-size: var(--fs-h2); letter-spacing: -.03em; }
  h3 { font-size: var(--fs-h3); line-height: 1.2; letter-spacing: -.015em; }

  a { text-decoration: none; }
  p a, .prose a { color: var(--link); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-underline-offset: 3px; }
  p a:hover, .prose a:hover { text-decoration-color: currentColor; }

  :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

  ::selection { background: color-mix(in srgb, var(--brand-2) 55%, transparent); color: #fff; }

  code, kbd, pre, .mono { font-family: var(--font-mono); font-size: .92em; }

  .i { display: inline-block; width: 1.15em; height: 1.15em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.2em; }
  .i-fill { fill: currentColor; stroke: none; }

  .container { width: min(var(--container), 100% - var(--gutter) * 2); margin-inline: auto; }
  .narrow { width: min(820px, 100% - var(--gutter) * 2); margin-inline: auto; }

  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .skip-link { position: fixed; left: 12px; top: -80px; z-index: 1000; background: var(--accent); color: var(--accent-ink); padding: .7rem 1.1rem; border-radius: 10px; font-weight: 700; transition: top .2s; }
  .skip-link:focus { top: 12px; }

  .muted { color: var(--muted); }
  .dim { color: var(--dim); }
  .nowrap { white-space: nowrap; }
  .tnum { font-variant-numeric: tabular-nums; }
  .grad-text { background: var(--grad-brand-wide); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .center { text-align: center; }

  .eyebrow {
    display: inline-flex; align-items: center; gap: .55rem;
    font: 600 .78rem/1 var(--font-text); letter-spacing: .14em; text-transform: uppercase;
    color: var(--accent);
  }
  .eyebrow::before { content: ""; width: 22px; height: 2px; border-radius: 2px; background: var(--grad-brand); }

  .prose { max-width: 70ch; }
  .panel.prose { max-width: none; }
  .panel.prose > :first-child, .prose > h2:first-child { margin-top: 0; }
  .prose > * + * { margin-top: 1em; }
  .prose h2 { font-size: 1.5rem; margin-top: 2em; }
  .prose h3 { font-size: 1.15rem; margin-top: 1.5em; }
  .prose ul, .prose ol { padding-left: 1.3em; }
  .prose li + li { margin-top: .4em; }
  .prose li::marker { color: var(--dim); }
}

@layer ui {
  /* ---------- Schaltflächen ---------- */
  .btn {
    --btn-bg: var(--surface-2);
    --btn-fg: var(--text);
    --btn-bd: var(--line-strong);
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    min-height: 44px; padding: .65rem 1.2rem;
    font: 600 .95rem/1.1 var(--font-text); letter-spacing: -.005em;
    color: var(--btn-fg); background: var(--btn-bg);
    border: 1px solid var(--btn-bd); border-radius: 999px;
    text-decoration: none; white-space: nowrap; isolation: isolate;
    transition: transform .25s var(--ease), background .25s, border-color .25s, box-shadow .25s;
  }
  .btn:hover { transform: translateY(-2px); --btn-bd: color-mix(in srgb, var(--accent) 55%, var(--line-strong)); }
  .btn:active { transform: translateY(0) scale(.98); }
  .btn .i { transition: transform .25s var(--ease); }
  .btn:hover .i-go { transform: translateX(3px); }

  .btn-primary {
    --btn-fg: var(--accent-ink);
    --btn-bd: transparent;
    background: var(--grad-brand);
    box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--brand-1) 60%, transparent), 0 0 0 1px rgb(255 255 255 / .18) inset;
  }
  .btn-primary:hover { box-shadow: 0 16px 40px -8px color-mix(in srgb, var(--brand-1) 75%, transparent), 0 0 0 1px rgb(255 255 255 / .3) inset; }
  .btn-primary::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1;
    background: linear-gradient(120deg, transparent 30%, rgb(255 255 255 / .45) 50%, transparent 70%) -150% 0 / 60% 100% no-repeat;
    transition: background-position .8s var(--ease);
  }
  .btn-primary:hover::after { background-position: 250% 0; }
  :root[data-theme="light"] .btn-primary { --btn-fg: #fff; }
  @media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .btn-primary { --btn-fg: #fff; } }

  .btn-glass { backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); --btn-bg: var(--surface); }
  .btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
  .btn-ghost:hover { --btn-bg: var(--surface); }
  .btn-sm { min-height: 36px; padding: .45rem .9rem; font-size: .86rem; }
  .btn-lg { min-height: 54px; padding: .9rem 1.7rem; font-size: 1.05rem; }
  .btn-block { width: 100%; }
  .btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
  .btn-danger { --btn-fg: #fff; --btn-bg: #be123c; --btn-bd: transparent; }

  .icon-btn {
    display: inline-grid; place-items: center; width: 44px; height: 44px;
    border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
    color: var(--text); transition: background .2s, border-color .2s, transform .25s var(--ease);
  }
  .icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); transform: translateY(-1px); }
  .icon-btn .i { width: 1.25rem; height: 1.25rem; }

  /* ---------- Chips und Plaketten ---------- */
  .chip {
    --h: 200;
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .28rem .7rem; border-radius: 999px;
    font: 600 .78rem/1.2 var(--font-text); letter-spacing: .01em;
    color: color-mix(in oklab, hsl(var(--h) 90% 70%) 85%, var(--text));
    background: color-mix(in oklab, hsl(var(--h) 80% 55%) 14%, transparent);
    border: 1px solid color-mix(in oklab, hsl(var(--h) 80% 60%) 28%, transparent);
    text-decoration: none; white-space: nowrap;
    transition: background .2s, border-color .2s, transform .2s var(--ease);
  }
  a.chip:hover { background: color-mix(in oklab, hsl(var(--h) 80% 55%) 26%, transparent); transform: translateY(-1px); }
  :root[data-theme="light"] .chip { color: color-mix(in oklab, hsl(var(--h) 80% 30%) 90%, #000); }
  @media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .chip { color: color-mix(in oklab, hsl(var(--h) 80% 30%) 90%, #000); } }
  .chip-plain { --h: 220; color: var(--muted); background: var(--surface); border-color: var(--line); }
  .chip-plain:hover, a.chip-plain:hover { color: var(--text); background: var(--surface-2); }
  .chip[aria-pressed="true"], .chip.is-on { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

  .badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .25rem .6rem; border-radius: 8px;
    font: 700 .68rem/1.1 var(--font-text); letter-spacing: .08em; text-transform: uppercase;
    background: rgb(5 8 17 / .72); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgb(255 255 255 / .16);
  }
  .badge-new { background: linear-gradient(135deg, #22d3ee, #34d399); color: #031318; border-color: transparent; }
  .badge-remix { background: linear-gradient(135deg, #8b5cf6, #ec4899); color: #fff; border-color: transparent; }
  .badge-feat { background: linear-gradient(135deg, #fbbf24, #fb923c); color: #2a1503; border-color: transparent; }

  /* ---------- Formulare ---------- */
  .field { display: grid; gap: .45rem; }
  .field > label, .field > .label { font: 600 .88rem/1.2 var(--font-text); color: var(--text); }
  .field .hint { font-size: .82rem; color: var(--dim); }
  .input, .select, .textarea {
    width: 100%; min-height: 46px; padding: .7rem .95rem;
    color: var(--text); background: var(--surface-solid); border: 1px solid var(--line-strong); border-radius: 12px;
    transition: border-color .2s, box-shadow .2s, background .2s;
  }
  .textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
  .input::placeholder, .textarea::placeholder { color: var(--dim); }
  .input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong)); }
  .input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
  .select { appearance: none; padding-right: 2.4rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' 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 .8rem center; }
  .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

  .check { display: flex; gap: .7rem; align-items: flex-start; cursor: pointer; font-size: .92rem; color: var(--muted); }
  .check input { appearance: none; flex: none; width: 20px; height: 20px; margin-top: 2px; border-radius: 6px; border: 1.5px solid var(--line-strong); background: var(--surface-solid); display: grid; place-items: center; transition: background .2s, border-color .2s; cursor: pointer; }
  .check input:checked { background: var(--accent); border-color: var(--accent); }
  .check input:checked::after { content: ""; width: 10px; height: 6px; border-left: 2.2px solid var(--accent-ink); border-bottom: 2.2px solid var(--accent-ink); transform: rotate(-45deg) translate(1px, -1px); }

  .alert { padding: .9rem 1.1rem; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); font-size: .95rem; }
  .alert-error { border-color: color-mix(in srgb, var(--red) 55%, transparent); background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--danger); }
  .alert-ok { border-color: color-mix(in srgb, var(--green) 55%, transparent); background: color-mix(in srgb, var(--green) 12%, transparent); }

  /* ---------- Tooltip-lose Hilfsmittel ---------- */
  .kbd { display: inline-grid; place-items: center; min-width: 1.6em; padding: .1em .45em; font: 600 .75rem/1.6 var(--font-mono); color: var(--muted); background: var(--surface); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; }

  .pulse-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); animation: pulse 2.2s infinite; }
  @keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

  /* Einblenden beim Scrollen: nur mit JS (html.js) – ohne Skript bleibt alles sichtbar */
  .js .reveal { opacity: 0; transform: translateY(22px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
  .js .reveal.is-in { opacity: 1; transform: none; }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
    .js .reveal { opacity: 1; transform: none; }
  }
}
