/* excerpt — <excerpt> tag: source text quoted verbatim as a card

   Usage (rendered by src/content/tags/excerpt.ts):
     <figure class="ex ex--num-paren ex--notes">
       <figcaption class="ex-head">icon · title / subtitle / meta · source link</figcaption>
       <blockquote class="ex-body" cite="…">
         <div class="ex-para" id="art-26-dsgvo-1"><a class="ex-num">(1)</a><div class="ex-text">…</div><div class="ex-notes">…</div></div>
       </blockquote>
       <details class="ex-more">…</details> <p class="ex-foot">…</p>
     </figure>

   Themes:    .ex--accent .ex--green .ex--orange .ex--neutral (default navy)
   Numbering: .ex--num-paren .ex--num-dot .ex--num-rn
   Notes:     .ex--notes, .ex--note-color .ex--note-theme (default neutral), .ex-note--warn
   Collapse:  .ex--collapse, .ex-para--rest, .ex-gap--fold, .ex-more
   Script:    ExcerptInit.astro opens a collapsed excerpt when an anchor targets a hidden paragraph
── */

/* ── Theme: one accent (icon tile, numbers) + one tint (head) ─────────────── */
article .ex {
  --ex-accent: var(--color-primary);
  --ex-tint:   var(--color-primary-25);
  --ex-line:   var(--color-neutral-200);
  --ex-num-w:  0px;
  container-type: inline-size;
  margin: 1.5rem 0;
  border: 1px solid var(--ex-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow: hidden;
}
article .ex--accent { --ex-accent: var(--color-accent);      --ex-tint: var(--color-accent-25); }
article .ex--green { --ex-accent: var(--status-success-text); --ex-tint: var(--status-success-bg); }
article .ex--orange { --ex-accent: var(--status-warning-text);   --ex-tint: var(--status-warning-bg); }
article .ex--neutral { --ex-accent: var(--color-text-body);   --ex-tint: var(--color-neutral-50); }

/* Number gutter width per numbering style */
article .ex--num-paren { --ex-num-w: 2.1rem; }
article .ex--num-dot { --ex-num-w: 1.8rem; }
article .ex--num-rn { --ex-num-w: 3.6rem; }

/* ── Head: icon tile · title + subtitle · source link ─────────────────────── */
article .ex-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--ex-line);
  background: var(--ex-tint);
}
article .ex-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-sm);
  background: var(--ex-accent);
  color: var(--color-surface);
}
article .ex-titles { display: flex; flex-direction: column; min-width: 0; }
article .ex-title { font-weight: 700; line-height: 1.25; color: var(--color-text-primary); }
article .ex-subtitle { font-size: 0.875rem; line-height: 1.3; color: var(--color-text-muted); }
article .ex-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
article .ex-date { display: inline-flex; align-items: center; gap: 0.25rem; }
article .ex-lang {
  padding: 0 0.3rem;
  border: 1px solid var(--ex-line);
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
article .ex-source {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
  color: var(--color-primary);
}

/* ── Body: optional hanging number gutter ────────────────────────────────── */
article .ex-body { margin: 0; padding: 0.9rem 1.1rem 1rem; }   /* <blockquote cite> – reset browser margins */
article .ex-para, article .ex-gap, article .ex-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
article .ex[class*="ex--num-"] :is(.ex-para, .ex-gap, .ex-cols) { grid-template-columns: var(--ex-num-w) minmax(0, 1fr); }
article .ex-para + .ex-para, article .ex-gap + .ex-para, article .ex-para + .ex-gap { margin-top: 0.8rem; }
article .ex-num {
  position: relative;
  justify-self: start;
  padding-top: 0.15rem;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ex-accent);
}
article .ex-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--color-text-body);
}
/* "Nr. 1, 2 …" inside a paragraph: <ol>/<ul> in <para> */
article .ex-text :is(ol, ul) { margin: 0.35rem 0 0; padding-left: 1.5em; }
article .ex-text ol { list-style: decimal; counter-reset: none; }
article .ex-text li { margin: 0.2rem 0 0; padding-left: 0.2rem; line-height: 1.65; }
/* content-base.css turns every "article ol > li" into a big step circle – not inside a quoted text */
article .ex-text ol > li { counter-increment: none; position: static; }
article .ex-text ol > li::before { content: none; display: none; }
article .ex-text li::marker { font-weight: 700; color: var(--ex-accent); }

/* Paragraph anchors: the number links to its paragraph; link icon on hover, target flashes */
article .ex-num-link {
  position: absolute;
  top: 0.35rem;
  left: -1rem;
  display: inline-flex;
  opacity: 0;
  transition: opacity 120ms;
}
article .ex-para:hover .ex-num-link, article .ex-num:focus-visible .ex-num-link { opacity: 1; }
article .ex-num:hover { text-decoration: underline; }
article .ex-para { scroll-margin-top: 6rem; }
article .ex-para:target > .ex-num {
  padding: 0.1rem 0.35rem;
  margin-left: -0.35rem;
  border-radius: 999px;
  background: var(--ex-accent);
  color: var(--color-surface);
}
article .ex-gap { color: var(--color-text-muted); letter-spacing: 0.1em; }

/* Paragraph highlight (highlight="2"): line-by-line highlighter, matches <mark> */
article .ex-hl {
  padding: 0.05em 0.1em;
  background: linear-gradient(transparent 38%, var(--status-warning-tint) 38%);
  -webkit-box-decoration-break: clone;
          box-decoration-break: clone;
}

/* Marker after a phrase and in front of its note */
article .ex-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 1.1rem;
  height: 1.1rem;
  margin-left: 0.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-surface);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: 0.35em;
}

/* ── Notes: cards with a pointer, right of their paragraph ───────────────── */
article .ex--notes :is(.ex-para, .ex-gap, .ex-cols) { grid-template-columns: minmax(0, 1fr) minmax(11rem, 32%); }
article .ex--notes[class*="ex--num-"] :is(.ex-para, .ex-gap, .ex-cols) {
  grid-template-columns: var(--ex-num-w) minmax(0, 1fr) minmax(11rem, 32%);
}
article .ex--notes .ex-text { padding-right: 1.5rem; }
article .ex-notes { display: grid; gap: 0.5rem; }

/* note-style: neutral (default) · color · theme – always a white card; the style only
   colours frame and icon. Frame = icon colour mixed with white, like the heading badges. */
article .ex {
  --ex-note-icon: var(--color-text-muted);
  --ex-note-line: var(--color-neutral-200);
}
article .ex--note-color { --ex-note-icon: var(--status-warning-text); --ex-note-line: color-mix(in srgb, var(--ex-note-icon) 42%, var(--color-surface)); }
article .ex--note-theme { --ex-note-icon: var(--ex-accent);       --ex-note-line: color-mix(in srgb, var(--ex-note-icon) 30%, var(--color-surface)); }

article .ex-note {
  position: relative;
  display: flex;
  gap: 0.45rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--ex-note-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--color-text-primary) 8%, transparent);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text-primary);
}
article .ex-note::before {
  content: '';
  position: absolute;
  top: 0.75rem;
  left: -6px;
  width: 10px;
  height: 10px;
  border-left: 1px solid var(--ex-note-line);
  border-bottom: 1px solid var(--ex-note-line);
  background: var(--color-surface);
  transform: rotate(45deg);
}
article .ex-note > .ex-marker { margin: 0.15rem 0 0; vertical-align: 0; }
article .ex-note-icon { flex: none; padding-top: 0.1rem; color: var(--ex-note-icon); }

/* note-type="warn": crimson frame and triangle in every note-style – still a white card */
article .ex-note--warn {
  --ex-note-icon: var(--color-accent-dark);
  --ex-note-line: color-mix(in srgb, var(--color-accent) 35%, var(--color-surface));
}

/* Column headers (notes-title) */
article .ex-cols { margin-bottom: 0.6rem; }
article .ex-col {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
article .ex-col--notes { color: var(--ex-note-icon); }

article .ex-foot {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0 1.1rem 0.75rem calc(1.1rem + var(--ex-num-w));
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ── collapse: only key paragraphs until "Alle Absätze anzeigen" ───────────── */
article .ex-more { padding: 0 1.1rem 0.8rem calc(1.1rem + var(--ex-num-w)); }
article .ex-more > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
}
article .ex-more > summary::-webkit-details-marker { display: none; }
article .ex-more > summary::before { content: '▸'; transition: transform 120ms; }
article .ex-more[open] > summary::before { transform: rotate(90deg); }
article .ex-more[open] .ex-more-show, article .ex-more:not([open]) .ex-more-hide { display: none; }
article .ex--collapse:has(.ex-more:not([open])) .ex-para--rest { display: none; }
article .ex--collapse:has(.ex-more[open]) .ex-gap--fold { display: none; }

/* ── Narrow: notes move under their paragraph, pointer turns upwards ─────── */
@container (max-width: 36rem) {
  article .ex--notes :is(.ex-para, .ex-gap) { grid-template-columns: minmax(0, 1fr); }
  article .ex--notes[class*="ex--num-"] :is(.ex-para, .ex-gap) { grid-template-columns: var(--ex-num-w) minmax(0, 1fr); }
  article .ex--notes .ex-text { padding-right: 0; }
  article .ex-notes { grid-column: -2; margin-top: 0.6rem; }
  article .ex-note::before { top: -6px; left: 0.9rem; transform: rotate(135deg); }
  article .ex-cols { display: none; }
  article .ex-head { flex-wrap: wrap; }
  article .ex-source { margin-left: calc(2.1rem + 0.75rem); }
}
