/* copy-text — <copy-text> tag: sample text to copy, with switches, explanations and versions

   Rendered by src/content/tags/copy-text.ts; behaviour: CopyTextInit.astro (via BlockScripts).

     <div class="ct" data-ct>
       <div class="ct-head">kicker · title · [Text kopieren] [HTML]</div>
       <div class="ct-controls">
         selection: .ct-label (label + .ct-i) · .ct-seg > .ct-seg-btn[role=radio] | .ct-seg-item (button + .ct-i)
         Ihr Setup: .ct-opts > .ct-opt[role=checkbox] | .ct-chip (button + .ct-i)
         .ct-pop[data-info-pop] … (popovers, top layer once opened)
       </div>
       <div class="ct-body">… <mark class="ct-ph"> … .ct-part / .ct-version (.ct-off = hidden) … <p class="ct-source"></div>
       <p class="ct-hint">…</p>
     </div>
── */

/* White card like <excerpt> / <checklist>; colour only for placeholders (amber, like <mark>) and the copy button */
article .ct {
  margin: 1.5rem 0;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow: hidden;
}

/* Head: kicker + title · copy buttons */
article .ct-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.65rem 1rem 0.65rem 1.25rem;
  border-bottom: 1px solid var(--color-neutral-200);
  background: var(--color-neutral-50);
}
article .ct-titles { flex: 1; display: flex; flex-direction: column; min-width: 12rem; }
article .ct-kicker { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); }
article .ct-title { font-weight: 700; line-height: 1.3; color: var(--color-text-primary); }
article .ct-actions { display: inline-flex; gap: 0.4rem; }
article .ct-copy {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-surface);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
article .ct-copy > span { display: inline-flex; align-items: center; gap: 0.35rem; }
article .ct-copy--ghost { border-color: var(--color-neutral-300); background: var(--color-surface); color: var(--color-text-body); }
article .ct-copy-done { display: none !important; }
article .ct-copy--done .ct-copy-idle { display: none; }
article .ct-copy--done .ct-copy-done { display: inline-flex !important; }
article .ct-copy--done { border-color: var(--status-success-text); background: var(--status-success-text); color: var(--color-surface); }

/* Controls: versions (segmented) and options (switch chips) – the active state looks the same in both
   (primary-25 surface, primary-100 border); the segmented area itself is a light flat surface without a border */
article .ct-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.5rem;
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--color-neutral-200);
}
article .ct-control { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
article .ct-control-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); }
article .ct-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--color-neutral-50); }
article .ct-seg-btn {
  padding: 0.25rem 0.7rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-body);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
article .ct-seg-btn[aria-checked="true"] { background: var(--color-primary-25); color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary-100); }
article .ct-opts { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }
article .ct-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem 0.25rem 0.45rem;
  border: 1px solid var(--color-neutral-300);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-body);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
article .ct-opt-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--color-neutral-400);
  border-radius: 3px;
  color: var(--color-surface);
}
article .ct-opt-box svg { opacity: 0; }
article .ct-opt[aria-checked="true"] { border-color: var(--color-primary-100); background: var(--color-primary-25); color: var(--color-primary); }
article .ct-opt[aria-checked="true"] .ct-opt-box { border-color: var(--color-primary); background: var(--color-primary); }
article .ct-opt[aria-checked="true"] .ct-opt-box svg { opacity: 1; }

/* (i) button – next to a selection's label, or inside a chip / segment */
article .ct-i {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}
article .ct-i:hover, article .ct-i[aria-expanded="true"] { background: var(--color-primary-50); color: var(--color-primary); }
article .ct-i:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
article .ct-label { display: inline-flex; align-items: center; gap: 0.15rem; }

/* Chip with (i): one pill, the switch and the (i) side by side inside it */
article .ct-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-neutral-300);
  border-radius: 999px;
  background: var(--color-surface);
}
article .ct-chip .ct-opt { padding-right: 0.3rem; border: 0; background: transparent; }
article .ct-chip .ct-i { margin-right: 0.25rem; }
article .ct-chip:has(.ct-opt[aria-checked="true"]) { border-color: var(--color-primary-100); background: var(--color-primary-25); }
article .ct-chip:has(.ct-opt[aria-checked="true"]) .ct-i { color: var(--color-primary); }

/* Segment with (i): the selected look moves from the button to the whole item */
article .ct-seg-item { display: inline-flex; align-items: center; border-radius: 4px; }
article .ct-seg-item .ct-seg-btn { padding-right: 0.25rem; background: transparent !important; box-shadow: none !important; }
article .ct-seg-item .ct-i { width: 18px; height: 18px; margin-right: 0.3rem; }
article .ct-seg-item .ct-i svg { width: 13px; height: 13px; }
article .ct-seg-item:has([aria-checked="true"]) { background: var(--color-primary-25); box-shadow: inset 0 0 0 1px var(--color-primary-100); }
article .ct-seg-item:has([aria-checked="true"]) .ct-i { color: var(--color-primary); }

/* Popover: top layer, positioned by CopyTextInit below or above its (i) – hidden until opened */
article .ct-pop:not(:popover-open) { display: none; }
article .ct-pop {
  position: fixed;
  inset: auto;
  width: max-content;
  max-width: min(22rem, calc(100vw - 16px));
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--color-text-primary) 16%, transparent), 0 1px 3px color-mix(in srgb, var(--color-text-primary) 10%, transparent);
  color: var(--color-text-body);
  font-size: 0.875rem;
  line-height: 1.55;
  text-align: left;
}
article .ct-pop::before {   /* arrow towards the (i) – --ax set by the script */
  content: '';
  position: absolute;
  top: -6.5px;
  left: calc(var(--ax, 22px) - 6px);
  width: 11px;
  height: 11px;
  border: 1px solid var(--color-neutral-300);
  border-width: 1px 0 0 1px;
  background: inherit;
  rotate: 45deg;
}
article .ct-pop[data-side="above"]::before { top: auto; bottom: -6.5px; border-width: 0 1px 1px 0; }
article .ct-pop-head { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.7rem 0.6rem 0.15rem 1rem; }
article .ct-pop-title { flex: 1; font-weight: 700; color: var(--color-text-primary); }
article .ct-pop-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: -2px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}
article .ct-pop-close:hover { background: var(--color-neutral-100); color: var(--color-text-primary); }
article .ct-pop-body { max-height: min(50vh, 20rem); overflow: auto; padding: 0.1rem 1rem 0.8rem; }
article .ct-pop-body p { margin: 0 0 0.5rem; }
article .ct-pop-body p:last-child { margin-bottom: 0; }

/* Link footer: jump mark or external link – the host follows the label directly */
article .ct-more {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--color-neutral-200);
  color: var(--color-primary);
  font-size: 0.8125rem;
  line-height: 1.45;
  text-decoration: none;
}
article .ct-more svg { flex: none; margin-top: 0.1rem; }
article .ct-more-label { font-weight: 600; }
article .ct-more:hover .ct-more-label { text-decoration: underline; }
article .ct-more-host { color: var(--color-text-muted); white-space: nowrap; }
article .ct-more-host::before { content: '· '; }

/* info-style="dark": compact navy popover – also opens on hover, a click pins it */
article .ct-pop--dark {
  max-width: min(17rem, calc(100vw - 16px));
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-surface);
  font-size: 0.8125rem;
}
article .ct-pop--dark::before { border-color: var(--color-primary); }
article .ct-pop--dark .ct-pop-head { padding: 0.55rem 0.85rem 0; }
article .ct-pop--dark .ct-pop-title { color: var(--color-surface); }
article .ct-pop--dark .ct-pop-close { display: none; }
article .ct-pop--dark .ct-pop-body { padding: 0.1rem 0.85rem 0.6rem; }
article .ct-pop--dark .ct-more { padding: 0.45rem 0.85rem; border-color: color-mix(in srgb, var(--color-surface) 25%, transparent); color: var(--color-surface); }
article .ct-pop--dark .ct-more-host { color: inherit; opacity: 0.7; }

/* Body: the sample text itself */
article .ct-body { padding: 1rem 1.25rem 0.9rem; font-size: 0.9375rem; line-height: 1.65; color: var(--color-text-body); }
article .ct-body p { margin: 0 0 0.75rem; }
/* global "p:last-child { margin-bottom: 0 }" would glue a part's last paragraph to the next one */
article .ct-body :is(.ct-part, .ct-version) > p:last-child { margin-bottom: 0.75rem; }
article .ct-off { display: none; }   /* switched-off passage / inactive version (set by CopyTextInit) */
article .ct-ph {
  padding: 0.05em 0.2em;
  border-radius: 3px;
  background: var(--status-warning-tint);
  color: inherit;
  -webkit-box-decoration-break: clone;
          box-decoration-break: clone;
}
article .ct-source { margin: 0.25rem 0 0 !important; font-size: 0.8125rem; color: var(--color-text-muted); }
article .ct-hint {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.55rem 1.25rem;
  border-top: 1px solid var(--color-neutral-200);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}
article .ct-hint svg { flex: none; color: var(--status-warning-text); }
