/* === bistdudirsicher — Findings Card System ===
   Design: Swiss/Helvetic, TUV-industrial precision
   Mobile-first: 375px baseline
   Typography: DM Sans + Work Sans, modular scale with clamp()
   Colour-blind safe: luminance-gapped risk levels + border thickness + text labels
*/

/* ── Risk Palette (colour-blind safe: distinct luminance per level) ── */
:root {
  --risk-low:       #f59e0b;   /* amber,  L*≈69 */
  --risk-low-bg:    #fffbeb;   /* warm  tint 5% */
  --risk-mid:       #d97706;   /* orange, L*≈52 */
  --risk-mid-bg:    #fff7ed;   /* warm  tint 5% */
  --risk-high:      #ba1a1a;   /* red,    L*≈39 */
  --risk-high-bg:   #fef2f2;   /* red    tint 5% */

  --risk-border-low:  3px;
  --risk-border-mid:  4px;
  --risk-border-high: 5px;

  /* Typography — modular scale */
  --fs-xs:   clamp(0.625rem, 0.5vi + 0.55rem, 0.7rem);
  --fs-sm:   clamp(0.75rem,  0.5vi + 0.68rem, 0.875rem);
  --fs-base: clamp(0.875rem, 0.5vi + 0.8rem,  1rem);
  --fs-md:   clamp(1rem,     0.6vi + 0.9rem,  1.2rem);
  --fs-lg:   clamp(1.15rem,  0.7vi + 1.0rem,  1.45rem);
  --fs-xl:   clamp(1.35rem,  0.8vi + 1.15rem, 1.7rem);
  --fs-2xl:  clamp(1.6rem,   1.0vi + 1.3rem,  2.1rem);
  --fs-3xl:  clamp(2rem,     1.5vi + 1.5rem,  2.8rem);

  /* Spacing rhythm (8px base) */
  --space-1: clamp(4px,  0.4vi + 3px,  6px);
  --space-2: clamp(8px,  0.6vi + 6px,  12px);
  --space-3: clamp(12px, 0.8vi + 10px, 18px);
  --space-4: clamp(16px, 1.0vi + 13px, 24px);
  --space-5: clamp(20px, 1.2vi + 16px, 32px);
  --space-6: clamp(28px, 1.5vi + 22px, 44px);

  /* Timing */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:   180ms;
  --dur-base:   300ms;
  --dur-slow:   420ms;
}

/* ── Results Section Layout ── */
.results-section {
  max-width: var(--max-width, 852px);
  margin: 0 auto;
  padding: 0;
}

/* ── Verdict Card (summary — always first) ── */
.verdict-card {
  position: relative;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-left: 5px solid var(--black, #000);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.verdict-card__trust {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: var(--space-2);
}

.verdict-card__trust[data-level="HOCH"]     { color: var(--green, #059669); }
.verdict-card__trust[data-level="MITTEL"]   { color: var(--amber-dark, #855300); }
.verdict-card__trust[data-level="NIEDRIG"]  { color: var(--red, #ba1a1a); }

.verdict-card__summary {
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text2, #4c4546);
}

.verdict-card__summary strong {
  color: var(--text, #191c1d);
  font-weight: 600;
}

.verdict-card__charakter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.verdict-card__charakter span {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--border, #e5e7eb);
  color: var(--text2, #4c4546);
  background: var(--surface2, #f3f4f5);
}

.verdict-card__gesamtschaden {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border, #e5e7eb);
  font-size: var(--fs-sm);
  color: var(--text2, #4c4546);
}

.verdict-card__gesamtschaden strong {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--red, #ba1a1a);
}

/* ── Domain Group Header ── */
.domain-group {
  margin-bottom: var(--space-4);
}

.domain-group__header {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted, #7e7576);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border, #e5e7eb);
  margin-bottom: var(--space-2);
}

.domain-group__count {
  font-weight: 400;
  color: var(--muted, #7e7576);
  letter-spacing: 0;
}

/* ── Finding Card ── */
.finding-card {
  position: relative;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  margin-bottom: var(--space-2);
  transition: border-color var(--dur-base) var(--ease-out);
}

/* Risk-level left border — primary signal (colour-blind safe) */
.finding-card[data-risk="gering"]  { border-left: var(--risk-border-low)  solid var(--risk-low); }
.finding-card[data-risk="mittel"]  { border-left: var(--risk-border-mid)  solid var(--risk-mid); }
.finding-card[data-risk="hoch"]    { border-left: var(--risk-border-high) solid var(--risk-high); }

.finding-card[data-risk="gering"]  .finding-card__header { background: var(--risk-low-bg); }
.finding-card[data-risk="mittel"]  .finding-card__header { background: var(--risk-mid-bg); }
.finding-card[data-risk="hoch"]    .finding-card__header { background: var(--risk-high-bg); }

/* ── Card Header (always visible) ── */
.finding-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.finding-card__header:focus-visible {
  outline: 2px solid var(--black, #000);
  outline-offset: -2px;
}

.finding-card__title-group {
  flex: 1;
  min-width: 0;
}

.finding-card__index {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted, #7e7576);
  display: block;
  margin-bottom: 2px;
}

.finding-card__behauptung {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text, #191c1d);
  /* clamp to 2 lines in collapsed state */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.finding-card:not(.is-collapsed) .finding-card__behauptung {
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
}

/* ── EUR Badge ── */
.finding-card__eur {
  flex-shrink: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: right;
  line-height: 1.1;
  padding: 2px 0;
}

.finding-card[data-risk="gering"]  .finding-card__eur { color: var(--risk-low); }
.finding-card[data-risk="mittel"]  .finding-card__eur { color: var(--risk-mid); }
.finding-card[data-risk="hoch"]    .finding-card__eur { color: var(--risk-high); }

.finding-card__eur-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted, #7e7576);
}

/* ── Risk Label (colour-blind safe textual indicator) ── */
.finding-card__risk-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 2px;
  white-space: nowrap;
}

.finding-card[data-risk="gering"] .finding-card__risk-label {
  color: var(--risk-low);
  background: var(--risk-low-bg);
  border: 1px solid var(--risk-low);
}

.finding-card[data-risk="mittel"] .finding-card__risk-label {
  color: var(--risk-mid);
  background: var(--risk-mid-bg);
  border: 1px solid var(--risk-mid);
}

.finding-card[data-risk="hoch"] .finding-card__risk-label {
  color: var(--risk-high);
  background: var(--risk-high-bg);
  border: 1px solid var(--risk-high);
}

/* ── Collapse Indicator ── */
.finding-card__chevron {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted, #7e7576);
  transition: transform var(--dur-base) var(--ease-spring);
}

.finding-card:not(.is-collapsed) .finding-card__chevron {
  transform: rotate(180deg);
}

.finding-card__chevron svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* ── Card Details (expandable) ── */
.finding-card__details {
  overflow: hidden;
  transition: max-height var(--dur-slow) var(--ease-out),
              opacity    var(--dur-base) var(--ease-out);
}

.finding-card.is-collapsed .finding-card__details {
  max-height: 0;
  opacity: 0;
}

.finding-card:not(.is-collapsed) .finding-card__details {
  max-height: 1200px; /* large enough for any single finding */
  opacity: 1;
}

.finding-card__details-inner {
  padding: 0 var(--space-3) var(--space-3);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text2, #4c4546);
}

/* ── Detail Rows ── */
.finding-detail {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  align-items: flex-start;
}

.finding-detail + .finding-detail {
  border-top: 1px solid var(--surface2, #f3f4f5);
}

.finding-detail__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  margin-top: 1px;
}

.finding-detail__label {
  flex-shrink: 0;
  width: clamp(72px, 20vw, 96px);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #7e7576);
  padding-top: 1px;
}

.finding-detail__content {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text, #191c1d);
}

.finding-detail__content em {
  font-style: italic;
  color: var(--text2, #4c4546);
}

/* ── Zitat (clickable quote — links to source text position) ── */
.finding-detail__zitat {
  display: block;
  padding: var(--space-2);
  background: var(--surface2, #f3f4f5);
  border-left: 2px solid var(--border, #e5e7eb);
  font-style: italic;
  color: var(--text2, #4c4546);
  margin: var(--space-1) 0;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  position: relative;
}

.finding-detail__zitat:hover,
.finding-detail__zitat:focus-visible {
  background: #ede9e0;
  border-left-color: var(--text2, #4c4546);
}

.finding-detail__zitat::after {
  content: "↩";
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  font-style: normal;
  font-size: var(--fs-sm);
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.finding-detail__zitat:hover::after {
  opacity: 0.6;
}

/* ── Source link ── */
.finding-detail__source {
  color: var(--amber-dark, #855300);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  word-break: break-all;
}

.finding-detail__source:hover {
  color: var(--text, #191c1d);
}

/* ── Konsequenz EUR emphasis ── */
.finding-detail__eur-amount {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.finding-card[data-risk="hoch"] .finding-detail__eur-amount {
  color: var(--risk-high);
}

/* ── Enforcement Badge ── */
.enforcement-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--surface2, #f3f4f5);
  color: var(--text2, #4c4546);
  white-space: nowrap;
}

.enforcement-badge--high {
  background: #fef2f2;
  color: #991b1b;
}

.enforcement-badge--medium {
  background: #fff7ed;
  color: #9a3412;
}

.enforcement-badge--low {
  background: #fffbeb;
  color: #92400e;
}

/* ── Korrektur (green-tinted — the correct answer) ── */
.finding-detail--korrektur .finding-detail__icon {
  color: var(--green, #059669);
}

.finding-detail--korrektur .finding-detail__content {
  color: #065f46;
  font-weight: 500;
}

/* ── Original Text Panel (Zitat source with anchors) ── */
.source-panel {
  margin-top: var(--space-5);
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
}

.source-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--surface2, #f3f4f5);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text2, #4c4546);
}

.source-panel__body {
  padding: var(--space-3);
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--text, #191c1d);
  max-height: 400px;
  overflow-y: auto;
  position: relative;
}

/* Zitat anchor — highlight on target */
.source-anchor {
  scroll-margin-top: 20px;
  transition: background 0.15s;
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}

.source-anchor.is-highlighted {
  background: #fef3c7;
  animation: anchor-flash 1.8s var(--ease-out) forwards;
}

@keyframes anchor-flash {
  0%   { background: #fde68a; }
  60%  { background: #fef3c7; }
  100% { background: transparent; }
}

.source-anchor__index {
  display: inline-block;
  width: 22px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted, #7e7576);
  background: var(--surface2, #f3f4f5);
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.source-anchor__index:hover {
  background: var(--text2, #4c4546);
  color: #fff;
}

/* ── Collapse Show-More Row (appears after top 3 when 6+ total) ── */
.findings-show-more {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  border: 1px dashed var(--border, #e5e7eb);
  background: var(--surface2, #f3f4f5);
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2, #4c4546);
  transition: background var(--dur-fast), border-color var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
}

.findings-show-more:hover,
.findings-show-more:focus-visible {
  background: var(--surface, #fff);
  border-color: var(--text2, #4c4546);
  border-style: solid;
}

.findings-show-more__count {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--fs-base);
  font-weight: 800;
  color: var(--text, #191c1d);
  letter-spacing: -0.01em;
}

.findings-show-more__chevron {
  margin-left: auto;
  transition: transform var(--dur-base) var(--ease-spring);
}

.findings-show-more.is-expanded .findings-show-more__chevron {
  transform: rotate(180deg);
}

/* ── Collapsed stub card (in-place collapsed placeholder) ── */
.finding-card.is-collapsed .finding-card__stub {
  display: block;
}

.finding-card__stub {
  display: none;
  padding: 0 var(--space-3) var(--space-2);
  font-size: var(--fs-xs);
  color: var(--muted, #7e7576);
}

/* ── No findings state ── */
.findings-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--muted, #7e7576);
  font-size: var(--fs-sm);
}

/* ── Animations ── */

/* Cards stagger in on load */
@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.finding-card {
  animation: card-enter var(--dur-slow) var(--ease-out) both;
}

.verdict-card {
  animation: card-enter var(--dur-slow) var(--ease-out) both;
  animation-delay: 0ms;
}

/* Stagger by index */
.finding-card:nth-child(1) { animation-delay: 80ms; }
.finding-card:nth-child(2) { animation-delay: 130ms; }
.finding-card:nth-child(3) { animation-delay: 180ms; }
.finding-card:nth-child(4) { animation-delay: 230ms; }
.finding-card:nth-child(5) { animation-delay: 280ms; }
.finding-card:nth-child(6) { animation-delay: 330ms; }
.finding-card:nth-child(7) { animation-delay: 380ms; }
.finding-card:nth-child(8) { animation-delay: 430ms; }
.finding-card:nth-child(9) { animation-delay: 480ms; }
.finding-card:nth-child(10) { animation-delay: 530ms; }

/* ── Responsive ── */

/* 375px baseline — everything above is the default */

/* Tablet: 600px+ — side-by-side source panel */
@media (min-width: 600px) {
  .findings-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: var(--space-3);
  }

  .findings-layout__verdict {
    grid-column: 1 / -1;
  }

  .source-panel {
    margin-top: 0;
  }
}

/* Desktop: 852px+ */
@media (min-width: 852px) {
  .findings-layout {
    grid-template-columns: 1fr 1fr;
  }

  .findings-layout__verdict {
    grid-column: 1 / -1;
  }

  .finding-card__behauptung {
    font-size: var(--fs-md);
  }

  .finding-detail__label {
    width: 100px;
  }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .finding-card,
  .verdict-card {
    animation: none;
  }

  .finding-card__details {
    transition: none;
  }

  .finding-card__chevron,
  .findings-show-more__chevron {
    transition: none;
  }

  .source-anchor.is-highlighted {
    animation: none;
    background: #fef3c7;
  }
}

/* ── Print ── */
@media print {
  .finding-card.is-collapsed .finding-card__details {
    max-height: none;
    opacity: 1;
  }

  .finding-card__chevron {
    display: none;
  }

  .findings-show-more {
    display: none;
  }

  .source-panel {
    break-inside: avoid;
    border: 1px solid #ccc;
  }

  .finding-card {
    break-inside: avoid;
    border: 1px solid #ccc;
    border-left-width: 3px;
    animation: none;
  }
}
