/* Wow-Momente (Design-Nacht 01./02.10.2026): Bewegung nur dort, wo sie etwas erklärt.
   Leitlinie: keine Animation länger als 150 ms, keine Endlosschleifen, reduced motion = Endzustand sofort.
   Wird nach den Markenstilen geladen. */

/* ---------- W7 · Fokus-Ring: überall einheitlich 2 px Akzent, 2 px Abstand ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- W7 · Delta-Pillen: Pfeil vor dem Vorzeichen (Farbfehlsichtigkeit), 12 px ---------- */
.chip.pos::before, .chip.neg::before, .gl.pos::before, .gl.neg::before {
  content: ""; display: inline-block; flex: 0 0 auto; width: 10px; height: 9px; margin-right: 5px; vertical-align: .02em;
  background: currentColor; }
.chip.pos::before, .gl.pos::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.chip.neg::before, .gl.neg::before { clip-path: polygon(0 0, 100% 0, 50% 100%); }
.chip::before { margin-right: 0; }          /* im Flex-Chip übernimmt gap den Abstand */
.chip { align-items: center; }

/* ---------- W7 · Tageskursbalken (Positionsliste) ---------- */
.ptable td.daycell { position: relative; }
.daybar { position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px; display: block; pointer-events: none;
  background: color-mix(in srgb, var(--rule) 55%, transparent); border-radius: 1px; }   /* Spur = 10 % */
.daybar i { display: block; height: 100%; width: max(var(--w), 3px); margin-left: auto; border-radius: 1px; background: var(--pos); }
.daybar.neg i { background: var(--neg); }
.daybar.l { left: 12px; right: 12px; bottom: 1px; }
.daybar.l i { margin-left: 0; }
.has-daybar { position: relative; }

/* ---------- W7 · Leere Zustände ---------- */
.empty-state { padding: 40px 20px 44px; }
.empty-state .empty-ill { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto 8px; }
.empty-state p { margin: 0 auto 18px; max-width: 42ch; }

/* ---------- W6 · Skeletons in finaler Form ---------- */
.sk { position: relative; }
.sk-bar { display: block; background: var(--surface-3); border-radius: 6px; }
.sk-pulse { animation: none; }
@keyframes sk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.sk-chart { min-height: 434px; }
.sk-legend { display: flex; gap: 16px; margin: 20px 0 8px; }
.sk-plot { position: relative; margin-top: 10px;
  background: linear-gradient(var(--rule), var(--rule)) 0 0 / 100% 1px no-repeat,
              repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), var(--rule) calc(25% - 1px), var(--rule) 25%); opacity: .95; }
.sk-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sk-plot path { fill: none; stroke: var(--surface-3); stroke-width: 3; stroke-linecap: round; }
.sk-axis { display: flex; justify-content: space-between; margin-top: 10px; padding: 0 8px; }
.sk-explain { min-height: 292px; }
.sk-wf { display: grid; gap: 10px; margin-top: 20px; }
.sk-wfrow { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; align-items: center; }
.sk-track { display: block; height: 14px; }
@media (max-width: 760px) {
  .sk-chart { min-height: 410px; }
  .sk-wfrow { grid-template-columns: 1fr; gap: 4px; } .sk-track { height: 10px; }
  .sk-explain { min-height: 300px; }
}

/* ---------- W1 · Depotwert, der ankommt ---------- */
.bigrow { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; margin-top: 6px; }
.bigrow .big { margin-top: 0; }
.spark { position: relative; display: inline-block; width: 64px; height: 24px; flex: 0 0 auto; border-radius: 6px; }
.spark[hidden] { display: none; }
.spark svg { display: block; width: 64px; height: 24px; overflow: visible; }
.spark path { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: currentColor; }
.spark.pos { color: var(--pos); } .spark.neg { color: var(--neg); } .spark.flat { color: var(--muted); }
.spark.draw path { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); }
.spark.draw.go path { stroke-dashoffset: 0; transition: stroke-dashoffset 150ms cubic-bezier(.25, .6, .3, 1); }
.spark.draw circle { opacity: 0; } .spark.draw.go circle { opacity: 1; transition: opacity 150ms ease; }
.spark-tip { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 5; padding: 4px 9px; border-radius: var(--radius-8);
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity 120ms ease; font-feature-settings: "tnum" 1; }
.spark:hover .spark-tip, .spark:focus-visible .spark-tip { opacity: 1; }
@media (max-width: 760px) { .spark-tip { left: auto; right: 0; transform: none; } }

/* ---------- W2 · Wasserfall ---------- */
.wf { display: grid; gap: 6px; margin: 14px 0 6px; overflow-x: clip; }
.wf-row { --bar: var(--s1); position: relative; display: grid; grid-template-columns: 132px minmax(0, 1fr) 104px; gap: 12px; align-items: center;
  min-height: 26px; padding: 0 6px; border-radius: var(--radius-8); transition: opacity 150ms ease, background-color 150ms ease; }
.wf-row[data-kind="pos"] { --bar: var(--pos); } .wf-row[data-kind="neg"] { --bar: var(--neg); } .wf-row[data-kind="warning"] { --bar: var(--warn); }
.wf-l { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-v.pos { color: var(--pos); } .wf-v.neg { color: var(--neg); }
.wf-v { text-align: right; font-size: 13px; font-weight: 600; white-space: nowrap; font-feature-settings: "tnum" 1; }
.wf-track { position: relative; height: 14px; }
.wf-bar { position: absolute; top: 0; bottom: 0; left: var(--l); width: max(var(--w), 3px); border-radius: 4px; background: var(--bar);
  transform-origin: left center; }
.wf-row[data-kind="neg"] .wf-bar { transform-origin: right center; }
.wf-row[data-kind="warning"] .wf-bar { background: repeating-linear-gradient(135deg, var(--bar) 0 4px, color-mix(in srgb, var(--bar) 45%, transparent) 4px 7px); }
/* Gekürzte Achse: Bruchmarke (zwei schräge Linien) am linken Ende von Start und Ende. */
.wf.trunc .wf-row[data-kind="total"] .wf-bar::before { content: ""; position: absolute; left: 7px; top: -2px; bottom: -2px; width: 5px;
  background: var(--surface); transform: skewX(-28deg); border-radius: 0; }
.wf.trunc #erklaerung .wf-row.wf-on .wf-bar::before, #erklaerung .wf.trunc .wf-row.wf-on .wf-bar::before { background: var(--accent-soft); }
.wf-axis { margin: 2px 0 0 6px; font-size: 12px; }
.wf-row:focus-visible { outline-offset: -2px; }
/* Verbinder zwischen den Balken: dünne Linie von der Kante dieses Balkens zur Kante des nächsten. */
.wf-row:not(:last-child) .wf-track::after { content: ""; position: absolute; left: var(--c); top: 100%; width: 1px; height: 18px; background: var(--muted); opacity: .45; }
.wf.armed .wf-bar { transform: scaleX(0); }
.wf.armed .wf-track::after { opacity: 0; }
.wf.armed.in .wf-bar { transform: none; transition: transform 150ms cubic-bezier(.2, .7, .2, 1); }
.wf.armed.in .wf-track::after { opacity: .45; transition: opacity 150ms ease; }
@media (max-width: 760px) {
  .wf { gap: 8px; }
  .wf-row { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 3px 6px; }
  .wf-track { grid-column: 1 / -1; grid-row: 2; height: 10px; }
  .wf-row:not(:last-child) .wf-track::after { display: none; }
}
/* Verknüpfung Zeile <-> Balken <-> Beleg-Chip */
#erklaerung.wf-active [data-wf]:not(.wf-on) { opacity: .4; }
#erklaerung [data-wf].wf-on { opacity: 1; }
#erklaerung .wf-row.wf-on { background: var(--accent-soft); }
#erklaerung .wf-row.wf-on .wf-l { color: var(--text); }
#erklaerung .item[data-wf] { transition: opacity 150ms ease, background-color 150ms ease; }
#erklaerung .item.wf-on { background: var(--accent-soft); }
#erklaerung .waterfall .item[data-wf]:focus-visible { outline-offset: -2px; }

/* ---------- W3 · Beleg-Chips im Erklärsatz ---------- */
/* :not(#_) hebt die Spezifität über die Pluma-Regel für Textlinks in Listen (44-px-Fläche gilt nicht für Links im Fließtext). */
:root:not(#_) a.beleg { display: inline; min-width: 0; min-height: 0; padding: 0 2px; margin: 0 -2px; border-radius: 5px;
  color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent);
  text-decoration-thickness: 1.5px; text-underline-offset: 3px; transition: background-color 150ms ease; }
a.beleg:hover, a.beleg:focus-visible, a.beleg.on { background: var(--accent-soft); text-decoration-color: var(--accent); }
a.beleg:focus-visible { outline-offset: 1px; }

/* ---------- W5 · Schnellsuche ---------- */
dialog.palette { width: min(620px, calc(100vw - 24px)); margin: 11vh auto auto; overflow: hidden; }
dialog.palette[open] { animation: pal-in 140ms ease-out; }
@keyframes pal-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 18px; border-bottom: 1px solid var(--rule); }
.pal-in svg { width: 20px; height: 20px; color: var(--muted); flex: 0 0 auto; }
.pal-in input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: 500 17px Inter, system-ui, sans-serif; padding: 12px 0; outline: none; min-height: 48px; }
.pal-in input::placeholder { color: var(--muted); }
.pal-in kbd, .pal-foot kbd { font: 600 11.5px Inter, system-ui, sans-serif; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--rule); }
.pal-list { list-style: none; margin: 0; padding: 6px 8px 8px; max-height: min(52vh, 420px); overflow: auto; }
.pal-list .pal-h { padding: 10px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.pal-list [role="option"] { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 48px; padding: 6px 10px;
  border-radius: var(--radius-10); cursor: pointer; color: var(--text); }
.pal-list [role="option"].page { grid-template-columns: minmax(0, 1fr) auto; }
.pal-list [role="option"][aria-selected="true"], .pal-list [role="option"]:hover { background: var(--accent-soft); }
.pal-list .pn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-list .ps { color: var(--muted); font-size: 12.5px; margin-left: 6px; font-weight: 500; }
.pal-list .pc { color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
.pal-list mark { background: transparent; color: var(--accent); font-weight: 700; }
.pal-empty { padding: 22px 18px; color: var(--muted); text-align: center; font-size: 14px; }
.pal-foot { display: flex; gap: 6px 16px; flex-wrap: wrap; padding: 9px 16px 11px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 12px; }
.pal-foot span { display: inline-flex; align-items: center; gap: 5px; }
.pal-open[hidden] { display: none; }
@media (max-width: 760px) { dialog.palette { margin-top: 8vh; } .pal-foot { display: none; } .pal-in kbd { display: none; } }

/* ---------- W4 · Seitenwechsel: Namen für die stehenden Teile; Übergang und Dauer stehen seit N2 in motion.css ---------- */
.vt-name { display: inline-block; max-width: 100%; vertical-align: top; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top { view-transition-name: pt-bar; }
.tabbar { view-transition-name: pt-tabs; }
main { view-transition-name: pt-page; }

@media (prefers-reduced-motion: reduce) {
  .sk-pulse, .pal-list, dialog.palette[open] { animation: none !important; }
  .spark.draw path { stroke-dasharray: none; stroke-dashoffset: 0; }
  .spark.draw circle { opacity: 1; }
  .wf.armed .wf-bar { transform: none; } .wf.armed .wf-track::after { opacity: .45; }
  .wf-row, #erklaerung .item[data-wf], a.beleg, .spark-tip { transition: none !important; }
}
