/* Bauteile: Knöpfe, Kürzel, Reihen, Felder mit schwebender Beschriftung, der Link zum Kopieren, Toasts und die
   Rückfrage. Überall gleich, auf jeder Seite. */

@layer bauteile {
  .knopf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1.15rem;
    font: 500 var(--gr-15) / 1 var(--schrift-titel);
    color: var(--text);
    background: var(--glas);
    border: 1px solid var(--rand);
    border-radius: var(--pille);
    box-shadow: inset 0 1px 0 var(--kante), var(--schatten-knopf);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform var(--dauer-kurz) var(--kurve), box-shadow var(--dauer-kurz), background var(--dauer-kurz), filter var(--dauer-kurz);

    &:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 var(--kante), var(--schatten-1); }
    &:active { transform: scale(0.98); }
    & .icon { width: 1.05em; height: 1.05em; }

    &.haupt {
      color: var(--akzent-text);
      background: var(--verlauf-akzent);
      border-color: transparent;
      box-shadow: var(--leuchten);
      &:hover { filter: brightness(1.08); box-shadow: var(--leuchten), var(--schatten-1); }
    }
    &.leise {
      color: var(--text-2);
      background: none;
      border-color: transparent;
      box-shadow: none;
      &:hover { color: var(--text); background: var(--tinte-flaeche); transform: none; }
    }
    &.gefahr { color: var(--minus-text); background: var(--minus); border-color: transparent; &:hover { filter: brightness(1.08); } }
    &.klein { padding: 0.45rem 0.8rem; font-size: var(--gr-14); }
    &.gross { padding: var(--a4) 1.9rem; font-size: var(--gr-18); }
    &.rund { padding: var(--a2); border-radius: 50%; & .icon { width: 1.15rem; height: 1.15rem; } }
  }
  /* Ein Knopf mit kleiner Zahl oben rechts (neue Nachrichten, Personen) */
  .mit-zahl { position: relative; }
  .zahl {
    position: absolute;
    top: -0.3rem;
    right: -0.3rem;
    display: grid;
    place-items: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    font: 600 var(--gr-12) / 1 var(--schrift-titel);
    color: var(--akzent-text);
    background: var(--akzent);
    border-radius: var(--pille);
    box-shadow: 0 0 0 2px var(--grund);
  }

  .reihe {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--a2);
    &.auseinander { justify-content: space-between; }
  }

  /* Kürzel: Anfangsbuchstaben (oder ein Icon) im Kreis; zart in Listen, groß in Karten */
  .kuerzel {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    font: 600 var(--gr-13) / 1 var(--schrift-titel);
    color: var(--akzent-text);
    background: var(--verlauf-akzent);
    border-radius: 50%;

    & .icon { width: 50%; height: 50%; }
    &.zart { width: 2rem; height: 2rem; font-size: var(--gr-12); color: var(--text); background: var(--tinte-flaeche); }
    &.gross { width: 3.25rem; height: 3.25rem; font-size: var(--gr-18); box-shadow: var(--schatten-knopf); }
  }

  /* Titel eines Abschnitts in einer Karte */
  .abschnitt-titel { display: flex; align-items: center; gap: 0.45rem; font-size: var(--gr-18); }
  .abschnitt-titel .icon { color: var(--marke-grau); }

  /* Wortmarke neben dem Logo: VIDEO kräftig, CALL leicht */
  .wortmarke {
    font: 500 var(--gr-15) / 1 var(--schrift-titel);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-2);
    & b { font-weight: 300; color: var(--marke-grau); }
  }

  /* Formulare: Felder untereinander, die Beschriftung schwebt im leeren Feld und rutscht beim Tippen nach oben.
     Felder dafür brauchen placeholder (ein Leerzeichen genügt). Ein Icon steht links im Feld. */
  .formular { display: grid; gap: var(--a4); width: 100%; }
  .feld {
    position: relative;
    display: grid;
    min-width: 0;

    & > :is(input, select) { height: 3.4rem; padding-top: 1.4rem; padding-bottom: 0.35rem; line-height: 1.3; }
    & > input::placeholder { color: transparent; }
    & > :is(input, select) + label {
      position: absolute;
      top: 0.9rem;
      left: 0.85rem;
      right: 0.85rem;
      overflow: hidden;
      font-size: var(--gr-16);
      color: var(--text-leise);
      text-overflow: ellipsis;
      white-space: nowrap;
      pointer-events: none;
      transform-origin: left top;
      transition: translate var(--dauer-kurz) var(--kurve), scale var(--dauer-kurz) var(--kurve), color var(--dauer-kurz);
    }
    & > :is(input:focus, input:not(:placeholder-shown), input:autofill, select) + label { translate: 0 -0.6rem; scale: 0.76; }
    & > :is(input, select):focus + label { color: var(--akzent); }
    & > .icon {
      position: absolute;
      top: 1.1rem;
      left: 0.85rem;
      z-index: 1;
      width: 1.15rem;
      height: 1.15rem;
      color: var(--text-leise);
      pointer-events: none;
    }
    &:has(> .icon) > :is(input, select) { padding-left: 2.6rem; }
    &:has(> .icon) > :is(input, select) + label { left: 2.6rem; }
    &:focus-within > .icon { color: var(--akzent); }
    & > select { appearance: none; padding-right: 2.6rem; }
    &:has(> select)::after { content: ""; position: absolute; top: 1.7rem; right: 1.1rem; width: 0.5rem; height: 0.5rem; pointer-events: none;
      border-right: 1.5px solid var(--text-leise); border-bottom: 1.5px solid var(--text-leise); translate: 0 -75%; rotate: 45deg; }
    & .fehler { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.35rem; font-size: var(--gr-13); color: var(--minus); }
    & .fehler .icon { width: 1rem; height: 1rem; }
  }

  input:not([type="hidden"], [type="checkbox"], [type="radio"]), select, textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.55rem 0.8rem;
    font-size: var(--gr-16);
    background: var(--glas-leicht);
    border: 1px solid var(--linie-stark);
    border-radius: var(--rund-s);
    box-shadow: inset 0 1px 0 var(--kante);
    transition: border-color var(--dauer-kurz), box-shadow var(--dauer-kurz), background var(--dauer-kurz);

    &:hover { border-color: var(--text-leise); }
    &:focus { outline: 0; border-color: var(--akzent); box-shadow: 0 0 0 4px var(--fokus-schein); background: var(--flaeche); }
    &[aria-invalid="true"] { border-color: var(--minus); background: var(--minus-flaeche); }
  }
  select { cursor: pointer; }
  textarea { resize: none; line-height: 1.45; }
  .code-feld { font-family: var(--schrift-titel); letter-spacing: 0.3em; }

  /* Ein Link zum Weitergeben: im Feld, Kopieren darin (teile/link_feld.php, js/kern/kopieren.js) */
  .link-feld {
    display: flex;
    align-items: center;
    gap: var(--a2);
    padding: 0.3rem 0.3rem 0.3rem var(--a4);
    background: var(--glas-leicht);
    border: 1px solid var(--linie-stark);
    border-radius: var(--pille);
    box-shadow: inset 0 1px 0 var(--kante);
    &:focus-within { border-color: var(--akzent); box-shadow: 0 0 0 4px var(--fokus-schein); }
    & input, & input:focus { flex: 1; min-width: 0; min-height: 0; padding: 0; font-size: var(--gr-15); color: var(--text-2);
      text-overflow: ellipsis; background: none; border: 0; box-shadow: none; }
  }

  /* Toasts unten rechts: dunkles Glas in beiden Modi, fahren herein und gehen nach ihrer Frist von selbst */
  .ecke {
    position: fixed;
    right: var(--a4);
    bottom: var(--a4);
    z-index: 90;
    width: min(24rem, calc(100vw - 2 * var(--a4)));
  }
  .toasts { display: grid; gap: var(--a2); }
  .toast {
    --frist: 6s;
    display: flex;
    align-items: start;
    gap: var(--a3);
    padding: 0.65rem 0.55rem 0.65rem var(--a3);
    font-size: var(--gr-15);
    line-height: 1.35;
    background: var(--glas-dunkel);
    border: 1px solid var(--glas-dunkel-rand);
    border-radius: var(--rund);
    box-shadow: var(--schatten-2);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    backdrop-filter: blur(24px) saturate(150%);
    animation: toast-auf var(--dauer) var(--kurve), toast-weg var(--dauer) ease-in var(--frist) forwards;

    & > * { color-scheme: dark; color: var(--text); }
    & > .icon { width: 2rem; height: 2rem; padding: 0.4rem; border-radius: 50%; color: var(--plus); background: var(--plus-flaeche); }
    & .text { flex: 1; min-width: 0; padding-block: calc((2rem - 1lh) / 2); }
    & .schliessen {
      display: grid;
      padding: 0.3rem;
      color: var(--text-leise);
      background: none;
      border: 0;
      border-radius: var(--rund-s);
      cursor: pointer;
      &:hover { color: var(--text); background: var(--tinte-flaeche); }
    }
    &.hinweis > .icon { color: var(--text); background: var(--tinte-flaeche); }
    &.fehler { --frist: 10s; }
    &.fehler > .icon { color: var(--minus); background: var(--minus-flaeche); }
    &:is(:hover, :focus-within) { animation-play-state: running, paused; }
    &.geht { animation: toast-zu var(--dauer-kurz) ease-in forwards; }
  }
  @keyframes toast-auf { from { opacity: 0; translate: 2rem 0; } }
  @keyframes toast-weg { to { opacity: 0; translate: 2rem 0; visibility: hidden; } }
  @keyframes toast-zu { to { opacity: 0; translate: 2rem 0; visibility: hidden; } }

  /* Rückfrage mitten auf der Seite (js/kern/rueckfrage.js): das Zeichen wackelt kurz, Ja ist rot, Abbrechen hat den Fokus */
  .rueckfrage {
    width: min(27rem, calc(100vw - 2 * var(--a4)));
    padding: 0;
    color: var(--text);
    background: var(--glas-stark);
    border: 1px solid var(--rand);
    border-radius: var(--rund-l);
    box-shadow: var(--schatten-2);
    &::backdrop { background: var(--vorhang); }
    & form { display: grid; gap: var(--a3); padding: var(--a5); }
    & .zeichen { display: grid; place-items: center; width: 3rem; height: 3rem; color: var(--minus); background: var(--minus-flaeche);
      border-radius: 50%; animation: wackeln 0.9s var(--kurve) 0.2s; }
    & .zeichen .icon { width: 1.4rem; height: 1.4rem; }
    & p { color: var(--text-2); }
    & .reihe { justify-content: flex-end; margin-top: var(--a3); }
  }
  @keyframes wackeln { 0%, 100% { rotate: 0deg; } 20% { rotate: -8deg; } 40% { rotate: 7deg; } 60% { rotate: -4deg; } 80% { rotate: 2deg; } }
}
