/*
 * Kontrastkopf Core · Labor-Kandidat 0.4.0
 * Technische Grundlage unterhalb individueller Seitenlayouts.
 * Schichten: Tokens -> Reset -> Base -> Primitives -> Components -> Motion -> Utilities.
 */

@layer kk.tokens, kk.reset, kk.base, kk.primitives, kk.components, kk.motion, kk.utilities;

@layer kk.tokens {
  :root {
    --kk-color-pink: #ff007f;
    --kk-color-lime: #dfff00;
    --kk-color-night: #0b0b0c;
    --kk-color-ink: #111111;
    --kk-color-paper: #f2f0eb;
    --kk-color-white: #ffffff;
    --kk-color-grey: #818181;

    --kk-font-body: Inter, Arial, sans-serif;
    --kk-font-display: Anton, Impact, sans-serif;

    --kk-space-0: 0;
    --kk-space-1: 4px;
    --kk-space-2: 8px;
    --kk-space-3: 12px;
    --kk-space-4: 16px;
    --kk-space-5: 24px;
    --kk-space-6: 32px;
    --kk-space-7: 48px;
    --kk-space-8: 64px;
    --kk-space-9: 96px;
    --kk-space-10: 128px;

    --kk-container-wide: 1280px;
    --kk-container-content: 1120px;
    --kk-container-reading: 780px;
    --kk-content-wide: var(--kk-container-wide);
    --kk-content-reading: 68ch;
    --kk-content-heading: 24ch;
    --kk-type-page-title: clamp(2.5rem, 4.8vw, 4rem);
    --kk-type-section-title: clamp(2.25rem, 4.4vw, 4rem);
    --kk-page-gutter: clamp(22px, 4vw, 64px);
    --kk-edge-wide: max(var(--kk-page-gutter), calc((100vw - var(--kk-container-wide)) / 2));
    --kk-edge-content: max(var(--kk-page-gutter), calc((100vw - var(--kk-container-content)) / 2));
    --kk-section-space: clamp(72px, 10vw, 144px);
    --kk-card-padding: clamp(24px, 2.4vw, 32px);

    --kk-control-min: 48px;
    --kk-control-padding-block: 16px;
    --kk-control-padding-inline: 24px;
    --kk-control-gap: 12px;
    --kk-target-gap: 8px;
    --kk-border-width: 1px;
    --kk-focus-width: 3px;
    --kk-focus-offset: 4px;

    --kk-motion-current-pink-duration: 15s;
    --kk-motion-current-lime-duration: 18s;
    --kk-motion-current-ease: ease-in-out;
    --kk-touch-pointer-size: 12px;
    --kk-touch-pointer-active-size: 36px;
    --kk-touch-pointer-duration: 150ms;

    --kk-glass-radius: 16px;
    --kk-glass-blur: 20px;
    --kk-glass-saturation: 150%;
    --kk-glass-dark-surface: linear-gradient(135deg, #202024fa, #0b0b0cfa);
    --kk-glass-dark-surface-hover: linear-gradient(135deg, #303036fa, #151518fa);
    --kk-glass-dark-edge: #ffffff42;
    --kk-glass-dark-edge-hover: #ffffff73;
    --kk-glass-dark-shadow: inset 0 1px 0 #ffffff2e, inset 0 -1px 0 #ffffff0d, 0 16px 38px #00000042;
    --kk-glass-dark-shadow-hover: inset 0 1px 0 #ffffff63, inset 0 -1px 0 #ffffff14, 0 18px 44px #00000066;
    --kk-glass-light-surface: linear-gradient(135deg, #fffffffa, #f2f0ebf7);
    --kk-glass-light-surface-hover: linear-gradient(135deg, #ffffff, #f2f0ebfc);
    --kk-glass-light-edge: #818181;
    --kk-glass-light-edge-hover: #111111;
    --kk-glass-light-shadow: inset 0 1px 0 #ffffff, inset 0 -1px 0 #11111112, 0 16px 38px #0b0b0c24;
    --kk-glass-light-shadow-hover: inset 0 1px 0 #ffffff, inset 0 -1px 0 #1111111f, 0 18px 44px #0b0b0c33;

    --kk-shell-glass-background: rgba(12, 12, 14, .92);
    --kk-shell-glass-border: rgba(255, 255, 255, .16);
    --kk-shell-glass-filter: blur(24px) saturate(135%);
  }
}

@layer kk.reset {
  *, *::before, *::after { box-sizing: border-box; }
  :where(body, h1, h2, h3, h4, p, blockquote, figure) { margin-top: 0; }
  :where(img, svg, video) { display: block; max-width: 100%; height: auto; }
  :where(button, input, textarea, select) { font: inherit; }
}

@layer kk.base {
  :where(body) {
    margin: 0;
    background: var(--kk-color-paper);
    color: var(--kk-color-ink);
    font-family: var(--kk-font-body);
    line-height: 1.65;
  }

  :where(p, li, blockquote) { max-width: var(--kk-content-reading); }

  :where(a, button, input, textarea, select, summary):focus-visible {
    outline: var(--kk-focus-width) solid var(--kk-color-pink);
    outline-offset: var(--kk-focus-offset);
  }

  :where([data-kk-surface='dark']) :where(a, button, input, textarea, select, summary):focus-visible {
    outline-color: var(--kk-color-lime);
  }

  :where([data-kk-surface='signal']) :where(a, button, input, textarea, select, summary):focus-visible {
    outline-color: var(--kk-color-ink);
  }
}

@layer kk.primitives {
  .kk-container {
    width: min(calc(100% - var(--kk-page-gutter) - var(--kk-page-gutter)), var(--kk-container-content));
    margin-inline: auto;
  }

  .kk-container--wide {
    width: min(calc(100% - var(--kk-page-gutter) - var(--kk-page-gutter)), var(--kk-container-wide));
  }

  .kk-container--reading {
    width: min(calc(100% - var(--kk-page-gutter) - var(--kk-page-gutter)), var(--kk-container-reading));
  }

  .kk-section { padding-block: var(--kk-section-space); }

  .kk-stack { display: flex; flex-direction: column; gap: var(--kk-stack-gap, var(--kk-space-5)); }

  .kk-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--kk-cluster-gap, var(--kk-space-4));
  }

  .kk-grid {
    display: grid;
    grid-template-columns: repeat(var(--kk-grid-columns, 3), minmax(0, 1fr));
    gap: var(--kk-grid-gap, var(--kk-space-4));
  }

  .kk-card-grid {
    display: grid;
    grid-template-columns: repeat(var(--kk-grid-columns, 3), minmax(0, 1fr));
    border-top: var(--kk-border-width) solid currentColor;
    border-left: var(--kk-border-width) solid currentColor;
  }
}

@layer kk.components {
  .kk-card {
    min-width: 0;
    padding: var(--kk-card-padding);
    display: grid;
    grid-template-rows: auto minmax(4.8em, auto) 1fr;
    gap: var(--kk-space-4);
    border-right: var(--kk-border-width) solid currentColor;
    border-bottom: var(--kk-border-width) solid currentColor;
  }

  .kk-card > :where(h2, h3, h4) { align-self: start; margin: 0; }
  .kk-card > :where(p, ul, ol):last-child { margin-bottom: 0; }

  .kk-button {
    min-width: var(--kk-control-min);
    min-height: var(--kk-control-min);
    padding: var(--kk-control-padding-block) var(--kk-control-padding-inline);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--kk-control-gap);
    border: 2px solid currentColor;
    border-radius: 0;
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
  }

  .kk-button--primary { background: var(--kk-color-lime); color: var(--kk-color-ink); }
  .kk-button--secondary { background: transparent; color: inherit; }
  .kk-button--highlight { background: var(--kk-color-pink); color: var(--kk-color-ink); }
  .kk-button--icon { width: var(--kk-control-min); padding: 0; }
  .kk-button__icon { flex: 0 0 auto; width: 24px; height: 24px; display: block; align-self: center; }

  .kk-highlight { background: var(--kk-color-pink); color: var(--kk-color-ink); }
  .kk-underline-safe {
    display: inline-block;
    padding-bottom: .06em;
    border-bottom: .11em solid var(--kk-color-pink);
    color: inherit;
    line-height: .98;
    text-decoration: none;
  }
  .kk-surface-dark { background: var(--kk-color-night); color: var(--kk-color-white); }
  .kk-surface-paper { background: var(--kk-color-paper); color: var(--kk-color-ink); }
  .kk-surface-light { background: var(--kk-color-white); color: var(--kk-color-ink); }
  .kk-surface-signal { background: var(--kk-color-lime); color: var(--kk-color-ink); }

  .kk-glass {
    position: relative;
    isolation: isolate;
    border: var(--kk-border-width) solid var(--kk-glass-edge);
    border-radius: var(--kk-glass-radius);
    background: var(--kk-glass-surface);
    color: var(--kk-glass-text);
    box-shadow: var(--kk-glass-shadow);
  }

  .kk-glass--dark {
    --kk-glass-surface: var(--kk-glass-dark-surface);
    --kk-glass-surface-hover: var(--kk-glass-dark-surface-hover);
    --kk-glass-edge: var(--kk-glass-dark-edge);
    --kk-glass-edge-hover: var(--kk-glass-dark-edge-hover);
    --kk-glass-text: var(--kk-color-white);
    --kk-glass-shadow: var(--kk-glass-dark-shadow);
    --kk-glass-shadow-hover: var(--kk-glass-dark-shadow-hover);
  }

  .kk-glass--light {
    --kk-glass-surface: var(--kk-glass-light-surface);
    --kk-glass-surface-hover: var(--kk-glass-light-surface-hover);
    --kk-glass-edge: var(--kk-glass-light-edge);
    --kk-glass-edge-hover: var(--kk-glass-light-edge-hover);
    --kk-glass-text: var(--kk-color-ink);
    --kk-glass-shadow: var(--kk-glass-light-shadow);
    --kk-glass-shadow-hover: var(--kk-glass-light-shadow-hover);
  }

  .kk-glass-button {
    min-width: var(--kk-control-min);
    min-height: var(--kk-control-min);
    padding: var(--kk-control-padding-block) var(--kk-control-padding-inline);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--kk-control-gap);
    border: var(--kk-border-width) solid var(--kk-glass-edge);
    border-radius: calc(var(--kk-glass-radius) - 2px);
    background: var(--kk-glass-surface);
    color: var(--kk-glass-text);
    box-shadow: var(--kk-glass-shadow);
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .22s ease, border-color .22s ease, box-shadow .22s ease, transform .22s ease;
  }

  .kk-glass-button:hover {
    border-color: var(--kk-glass-edge-hover);
    background: var(--kk-glass-surface-hover);
    box-shadow: var(--kk-glass-shadow-hover);
    transform: translateY(-1px);
  }

  .kk-glass-button:active { transform: translateY(0); }
  .kk-glass-button--icon { width: var(--kk-control-min); padding: 0; }

  /* Bestehende Shell-Oberflächen des WordPress-Themes. */
  .kk-shell-glass {
    background: var(--kk-shell-glass-background);
    border-color: var(--kk-shell-glass-border);
    -webkit-backdrop-filter: var(--kk-shell-glass-filter);
    backdrop-filter: var(--kk-shell-glass-filter);
  }

  /* Theme-identisches, seitenübergreifendes Kontaktmenü. */
  .contact-dock {
    position: fixed;
    z-index: 90;
    right: clamp(18px, 3vw, 42px);
    bottom: calc(clamp(20px, 3vw, 38px) + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    transition: opacity .18s ease, visibility .18s ease;
  }

  .contact-dock.is-context-hidden,
  .contact-dock.is-suppressed {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .contact-dock__toggle {
    position: relative;
    order: 2;
    width: 68px;
    height: 68px;
    padding: 0;
    overflow: visible;
    border: 2px solid var(--kk-color-pink);
    border-radius: 50%;
    background: var(--kk-color-ink);
    color: var(--kk-color-white);
    cursor: pointer;
  }

  .contact-dock__toggle img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
  }

  .contact-dock__status {
    position: absolute;
    right: -1px;
    bottom: 1px;
    width: 16px;
    height: 16px;
    border: 3px solid var(--kk-color-ink);
    border-radius: 50%;
    background: var(--kk-color-lime);
  }

  .contact-dock__panel {
    position: relative;
    order: 1;
    width: min(370px, calc(100vw - 36px));
    padding: 26px;
    border: 1px solid var(--kk-shell-glass-border);
    border-top: 6px solid var(--kk-color-pink);
    border-radius: 22px;
    background: var(--kk-shell-glass-background);
    color: var(--kk-color-white);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .6);
    -webkit-backdrop-filter: var(--kk-shell-glass-filter);
    backdrop-filter: var(--kk-shell-glass-filter);
    animation: kk-contact-dock-in .2s ease-out;
  }

  .contact-dock__panel[hidden] { display: none; }

  .contact-dock__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 50%;
    background: #1d1d20;
    color: var(--kk-color-white);
    cursor: pointer;
  }

  .contact-dock__close:is(:hover, :focus-visible) { border-color: var(--kk-color-pink); }
  .contact-dock__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

  .contact-dock__person {
    padding-right: 40px;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 17px;
  }

  .contact-dock__person img {
    width: 72px;
    height: 72px;
    border: 3px solid var(--kk-color-pink);
    border-radius: 50%;
    object-fit: cover;
  }

  .contact-dock__person span {
    display: block;
    color: var(--kk-color-paper);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    line-height: 1.4;
    text-transform: uppercase;
  }

  .contact-dock__person p {
    margin: 7px 0 0;
    color: var(--kk-color-white);
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
  }

  .contact-dock__actions {
    margin-top: 22px;
    display: grid;
    gap: 10px;
  }

  .contact-dock__actions a {
    min-height: 54px;
    padding: 12px 17px;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 12px;
    background: #1b1b1e;
    color: var(--kk-color-white);
    font-weight: 750;
    text-decoration: none;
    transition: background-color .2s ease, border-color .2s ease;
  }

  .contact-dock__actions a:is(:hover, :focus-visible) {
    border-color: var(--kk-color-pink);
    background: #252529;
  }

  .contact-dock__actions a.is-whatsapp { border-color: rgba(223, 255, 0, .6); }
  .contact-dock__actions a.is-whatsapp:is(:hover, :focus-visible) { border-color: var(--kk-color-lime); }
  .contact-dock__actions svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .contact-dock__actions img { width: 24px; height: 24px; object-fit: contain; }

  @keyframes kk-contact-dock-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: none; }
  }

  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .kk-glass, .kk-glass-button {
      -webkit-backdrop-filter: blur(var(--kk-glass-blur)) saturate(var(--kk-glass-saturation));
      backdrop-filter: blur(var(--kk-glass-blur)) saturate(var(--kk-glass-saturation));
    }

    .kk-glass--dark {
      --kk-glass-surface: linear-gradient(135deg, #202024f7, #0b0b0cf9);
      --kk-glass-surface-hover: linear-gradient(135deg, #303036f7, #151518f9);
    }

    .kk-glass--light {
      --kk-glass-surface: linear-gradient(135deg, #fffffffa, #f2f0ebf7);
      --kk-glass-surface-hover: linear-gradient(135deg, #ffffff, #f2f0ebfc);
    }
  }
}

@layer kk.motion {
  /* Originaler Acid-Lime-Touchpointer des WordPress-Themes. */
  .kk-touch-pointer {
    position: fixed;
    z-index: 100;
    top: 0;
    left: 0;
    width: var(--kk-touch-pointer-size);
    height: var(--kk-touch-pointer-size);
    display: none;
    border-radius: 50%;
    background: var(--kk-color-lime);
    mix-blend-mode: difference;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: width var(--kk-touch-pointer-duration), height var(--kk-touch-pointer-duration);
  }

  .kk-touch-pointer.is-active {
    width: var(--kk-touch-pointer-active-size);
    height: var(--kk-touch-pointer-active-size);
  }

  /*
   * Markenstrom: die unveränderten Bewegungsbahnen des Kontrastkopf-Linkhubs.
   * Der Host braucht position: relative, isolation: isolate und overflow: hidden.
   */
  .kk-motion-current {
    position: absolute;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    contain: paint;
    pointer-events: none;
  }

  .kk-motion-current__field {
    position: absolute;
    width: clamp(340px, 56vw, 660px);
    height: clamp(340px, 56vw, 660px);
    border-radius: 50%;
    filter: blur(58px);
    mix-blend-mode: screen;
    will-change: transform;
  }

  .kk-motion-current__field--pink {
    top: 6%;
    left: -26%;
    background: radial-gradient(circle at 36% 36%, #ff007ff2 0, #ff007f70 38%, transparent 72%);
    opacity: .68;
    animation: kk-pink-current var(--kk-motion-current-pink-duration) var(--kk-motion-current-ease) infinite alternate;
  }

  .kk-motion-current__field--lime {
    right: -28%;
    bottom: -12%;
    background: radial-gradient(circle at 56% 48%, #dfff00c7 0, #dfff0047 39%, transparent 72%);
    opacity: .48;
    animation: kk-lime-current var(--kk-motion-current-lime-duration) var(--kk-motion-current-ease) infinite alternate;
  }

  @keyframes kk-pink-current {
    0% { transform: translate3d(-5vw, -2vh, 0) scale(.92) rotate(-8deg); }
    50% { transform: translate3d(42vw, 24vh, 0) scale(1.1) rotate(8deg); }
    100% { transform: translate3d(12vw, 52vh, 0) scale(.96) rotate(-3deg); }
  }

  @keyframes kk-lime-current {
    0% { transform: translate3d(7vw, 5vh, 0) scale(.92) rotate(6deg); }
    50% { transform: translate3d(-38vw, -30vh, 0) scale(1.08) rotate(-8deg); }
    100% { transform: translate3d(-8vw, -62vh, 0) scale(.98) rotate(4deg); }
  }
}

@media (min-width: 1101px) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  @layer kk.motion {
    .kk-touch-pointer { display: block; }
  }
}

@layer kk.utilities {
  .kk-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .kk-m-0 { margin: 0; }
  .kk-mt-4 { margin-top: var(--kk-space-4); }
  .kk-mt-5 { margin-top: var(--kk-space-5); }
  .kk-mt-6 { margin-top: var(--kk-space-6); }
  .kk-mt-8 { margin-top: var(--kk-space-8); }
  .kk-mb-0 { margin-bottom: 0; }
  .kk-p-5 { padding: var(--kk-space-5); }
  .kk-p-6 { padding: var(--kk-space-6); }
  .kk-text-balance { text-wrap: balance; }
  .kk-measure { max-width: var(--kk-content-reading); }
  .kk-line { display: block; }
}

@media (max-width: 767px) {
  @layer kk.components {
    .kk-card { grid-template-rows: auto auto 1fr; }
  }

  @layer kk.primitives {
    .kk-grid, .kk-card-grid { --kk-grid-columns: 1; }
  }

  @layer kk.components {
    .contact-dock { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
    .contact-dock__toggle { width: 62px; height: 62px; }
    .contact-dock__panel { width: calc(100vw - 28px); padding: 22px 18px; border-radius: 18px; }
    .contact-dock__person { grid-template-columns: 62px minmax(0, 1fr); gap: 13px; }
    .contact-dock__person img { width: 62px; height: 62px; }
    .contact-dock__person p { font-size: 18px; }
    .contact-dock__actions a { min-height: 52px; }
  }
}

@media (max-height: 650px) {
  @layer kk.components {
    .contact-dock__panel { max-height: calc(100vh - 110px); overflow: auto; }
  }
}

@media (max-width: 460px) {
  @layer kk.motion {
    .kk-motion-current__field { width: 360px; height: 360px; filter: blur(48px); }
    .kk-motion-current__field--pink { left: -35%; opacity: .62; }
    .kk-motion-current__field--lime { right: -38%; bottom: -10%; opacity: .43; }
  }
}

@media (prefers-reduced-motion: reduce) {
  @layer kk.base {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  }

  @layer kk.motion {
    .kk-motion-current__field { animation: none; transform: none; will-change: auto; }
    .kk-touch-pointer { display: none; }
  }

  @layer kk.components {
    .kk-glass-button { transition: none; }
    .kk-glass-button:hover, .kk-glass-button:active { transform: none; }
    .contact-dock { transition: none; }
    .contact-dock__panel { animation: none; }
  }
}

@media (forced-colors: active) {
  @layer kk.components {
    .kk-button, .kk-glass, .kk-glass-button, .kk-shell-glass, .contact-dock__panel, .contact-dock__actions a, .contact-dock__close { border: 2px solid ButtonText; background: ButtonFace; color: ButtonText; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
    .kk-underline-safe { border-bottom-color: CanvasText; }
  }

  @layer kk.motion {
    .kk-motion-current { display: none; }
    .kk-touch-pointer { display: none; }
  }
}

@media print {
  @layer kk.motion {
    .kk-touch-pointer { display: none; }
  }

  @layer kk.components {
    .contact-dock { display: none; }
  }
}
