/* ==========================================================
   SERKEM Bento-Grid (Startseite, Sektion "Lösungen")
   Genutzt von index.html und en/index.html. Tokens sind auf .bento
   gescoped, Dark Mode folgt html.dark-mode (main.js).
   ========================================================== */

.bento {
  --b-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --b-ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  --b-page: #FFFFFF;
  --b-card: #FFFFFF;
  --b-card-tint: rgba(237, 229, 255, 0.55);
  --b-border: rgba(18, 0, 46, 0.08);
  --b-edge: rgba(76, 17, 255, 0.42);
  --b-spot: rgba(76, 17, 255, 0.05);
  --b-text: #12002E;
  --b-muted: rgba(18, 0, 46, 0.62);
  --b-faint: rgba(18, 0, 46, 0.40);
  --b-ink: #4C11FF;
  --b-ink-soft: rgba(76, 17, 255, 0.08);
  --b-line: rgba(18, 0, 46, 0.12);
  --b-node-top: #FFFFFF;
  --b-node-bot: #FAF8FF;
  --b-node-border: rgba(18, 0, 46, 0.10);
  --b-node-shadow: 0 6px 14px rgba(18, 0, 46, 0.07);
  --b-skel: rgba(18, 0, 46, 0.07);
  --b-dot: rgba(18, 0, 46, 0.07);
  --b-success: #2D8F5C;
  --b-glow: rgba(76, 17, 255, 0.45);
  --b-box: #EDE5FF;
  --b-box-stroke: rgba(76, 17, 255, 0.22);
  --b-mast: rgba(18, 0, 46, 0.22);
  --b-globe-a: rgba(76, 17, 255, 0.07);
  --b-globe-b: rgba(76, 17, 255, 0.01);
  --b-globe-line: rgba(76, 17, 255, 0.30);
  --b-globe-rim: rgba(76, 17, 255, 0.22);
  --b-shadow: 0 1px 2px rgba(18, 0, 46, 0.04), 0 16px 40px -24px rgba(18, 0, 46, 0.18);
  --b-panel: rgba(255, 255, 255, 0.92);
}

html.dark-mode .bento {
  --b-page: #08050F;
  --b-card: #0F0B18;
  --b-card-tint: rgba(202, 194, 255, 0.05);
  --b-border: rgba(255, 255, 255, 0.07);
  --b-edge: rgba(202, 194, 255, 0.40);
  --b-spot: rgba(124, 92, 255, 0.10);
  --b-text: #F5F3FA;
  --b-muted: rgba(245, 243, 250, 0.60);
  --b-faint: rgba(245, 243, 250, 0.36);
  --b-ink: #CAC2FF;
  --b-ink-soft: rgba(202, 194, 255, 0.10);
  --b-line: rgba(255, 255, 255, 0.10);
  --b-node-top: #1C1529;
  --b-node-bot: #130E1D;
  --b-node-border: rgba(255, 255, 255, 0.08);
  --b-node-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  --b-skel: rgba(255, 255, 255, 0.08);
  --b-dot: rgba(255, 255, 255, 0.05);
  --b-success: #5CC795;
  --b-glow: rgba(124, 92, 255, 0.85);
  --b-box: rgba(202, 194, 255, 0.12);
  --b-box-stroke: rgba(202, 194, 255, 0.26);
  --b-mast: rgba(255, 255, 255, 0.22);
  --b-globe-a: rgba(124, 92, 255, 0.16);
  --b-globe-b: rgba(124, 92, 255, 0.02);
  --b-globe-line: rgba(202, 194, 255, 0.32);
  --b-globe-rim: rgba(202, 194, 255, 0.22);
  --b-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 24px 48px -28px rgba(0, 0, 0, 0.8);
  --b-panel: rgba(22, 16, 33, 0.92);
}

/* ---------- Grid ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.bento-card--span2 { grid-column: span 2; }
.bento-card--span3 { grid-column: 1 / -1; }

/* ---------- Card ---------- */
.bento-card {
  --mx: -999px;
  --my: -999px;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 520px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--b-border);
  background:
    radial-gradient(120% 70% at 50% 0%, var(--b-card-tint) 0%, transparent 60%),
    var(--b-card);
  box-shadow: var(--b-shadow);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  transition: border-color 350ms ease, transform 350ms var(--b-ease);
}

/* Inneres Licht unter dem Cursor */
.bento-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(520px circle at var(--mx) var(--my), var(--b-spot), transparent 55%);
  opacity: 0;
  transition: opacity 450ms ease;
  pointer-events: none;
}

/* Kantenlicht — wandert über alle Karten mit */
.bento-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(320px circle at var(--mx) var(--my), var(--b-edge), transparent 50%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity 450ms ease;
  pointer-events: none;
}

.bento:hover .bento-card::after { opacity: 1; }
.bento-card:hover::before { opacity: 1; }

.bento-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.bento-card__stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 280px;
}

/* Feines Punkteraster, radial ausgeblendet */
.bento-card__stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--b-dot) 1px, transparent 1.4px);
  background-size: 18px 18px;
  background-position: center;
  -webkit-mask-image: radial-gradient(ellipse 65% 60% at 50% 45%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse 65% 60% at 50% 45%, #000 20%, transparent 75%);
  pointer-events: none;
}

.bento-card__stage > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.bento-card__body {
  position: relative;
  z-index: 2;
  padding: 0 32px 32px;
}

.bento-card__title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 450;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--b-text);
}

.bento-card__text {
  margin: 0;
  max-width: 52ch;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--b-muted);
}

.bento-card__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  font-size: 14px;
  font-weight: 450;
  line-height: 1.3;
  color: var(--b-ink);
}

.bento-card__link svg {
  width: 14px;
  height: 14px;
  transition: transform 350ms var(--b-ease);
}

.bento-card:hover .bento-card__link svg { transform: translateX(4px); }

/* Reveal */
.bento-card[data-bento-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 800ms var(--b-ease-out), transform 800ms var(--b-ease-out),
              border-color 350ms ease;
  transition-delay: calc(var(--i, 0) * 90ms);
}

.bento-card[data-bento-reveal].is-in {
  opacity: 1;
  transform: none;
}

.bento-card.is-paused *,
.bento-card.is-paused *::before,
.bento-card.is-paused *::after { animation-play-state: paused !important; }

/* ---------- Gemeinsame SVG-Bausteine ---------- */
.sv-node {
  fill: url(#bNode);
  stroke: var(--b-node-border);
  stroke-width: 1;
  filter: drop-shadow(var(--b-node-shadow));
  transition: stroke 400ms ease;
}

.sv-line {
  fill: none;
  stroke: var(--b-line);
  stroke-width: 1;
}

.sv-trail {
  fill: none;
  stroke: var(--b-ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.9;
  transition: opacity 900ms ease;
}

.sv-dot {
  fill: var(--b-ink);
  filter: drop-shadow(0 0 5px var(--b-glow));
}

.sv-t {
  font: 400 10px/1 'Inter', system-ui, sans-serif;
  fill: var(--b-muted);
}

.sv-t--strong { fill: var(--b-text); font-weight: 500; }
.sv-t--faint { fill: var(--b-faint); }
.sv-skel { fill: var(--b-skel); }

.sv-icon {
  fill: none;
  stroke: var(--b-text);
  stroke-opacity: 0.72;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sv-ring {
  fill: none;
  stroke: var(--b-ink);
  stroke-width: 1;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.sv-ring.is-pulse { animation: sv-ring 1.1s var(--b-ease-out); }

@keyframes sv-ring {
  0%   { opacity: 0.55; transform: scale(0.92); }
  100% { opacity: 0;    transform: scale(1.32); }
}

/* ---------- Karte 1: Versand ---------- */
.v-step rect {
  fill: transparent;
  stroke: var(--b-line);
  transition: fill 350ms ease, stroke 350ms ease;
}

.v-step text { transition: fill 350ms ease; }
.v-step.is-on rect { fill: var(--b-ink-soft); stroke: var(--b-ink); }
.v-step.is-on text { fill: var(--b-ink); }

.v-tile text {
  font: 600 13px/1 'Inter', system-ui, sans-serif;
  letter-spacing: 0.02em;
  fill: var(--b-text);
  fill-opacity: 0.78;
  transition: fill 400ms ease;
}

.v-tile.is-hit .sv-node { stroke: var(--b-ink); }
.v-tile.is-hit text { fill: var(--b-ink); fill-opacity: 1; }

.v-tile--more rect {
  fill: none;
  stroke: var(--b-line);
  stroke-dasharray: 3 4;
}

.v-tile--more text { font-weight: 450; fill: var(--b-muted); }

.v-doc-id {
  font: 500 15px/1 'Inter', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  fill: var(--b-text);
  letter-spacing: 0.01em;
}

.v-doc-id.is-new { animation: v-id 700ms var(--b-ease-out); }

@keyframes v-id {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ---------- Karte 2: E-Invoicing ---------- */
.bento-globe {
  position: absolute;
  inset: 0;
  display: block;
}

.einv-chip {
  position: absolute;
  left: 50%;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 236px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--b-node-border);
  border-radius: 12px;
  background: var(--b-panel);
  box-shadow: var(--b-node-shadow);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 500ms ease, transform 500ms var(--b-ease-out);
}

.einv-chip.is-in { opacity: 1; transform: translate(-50%, 0); }

.einv-chip__code {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--b-ink-soft);
  color: var(--b-ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.einv-chip__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.einv-chip__fmt {
  font-size: 14px;
  font-weight: 450;
  line-height: 1.2;
  color: var(--b-text);
  white-space: nowrap;
}

.einv-chip__meta {
  font-size: 12px;
  line-height: 1.2;
  color: var(--b-muted);
  white-space: nowrap;
}

.einv-chip__check {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: auto;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--b-success);
  background: color-mix(in srgb, var(--b-success) 14%, transparent);
}

.einv-chip__check svg { width: 12px; height: 12px; }

/* ---------- Karte 3: Integration ---------- */
.i-hub-box { fill: var(--color-primary); }

html.dark-mode .i-hub-box { filter: drop-shadow(0 0 22px rgba(76, 17, 255, 0.55)); }
html:not(.dark-mode) .i-hub-box { filter: drop-shadow(0 10px 22px rgba(76, 17, 255, 0.28)); }

.i-hub-glyph {
  fill: none;
  stroke: #FFFFFF;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.i-halo {
  fill: none;
  stroke: var(--b-ink);
  stroke-opacity: 0.14;
  transform-box: fill-box;
  transform-origin: center;
  animation: i-breathe 5s ease-in-out infinite;
}

.i-halo--2 { animation-delay: -2.5s; stroke-opacity: 0.08; }

@keyframes i-breathe {
  0%, 100% { transform: scale(0.96); opacity: 0.6; }
  50%      { transform: scale(1.04); opacity: 1; }
}

.i-node.is-hit .sv-node { stroke: var(--b-ink); }

.iflow-pill {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 40px);
  padding: 8px 14px;
  border: 1px solid var(--b-node-border);
  border-radius: var(--radius-md);
  background: var(--b-panel);
  box-shadow: var(--b-node-shadow);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.iflow-pill__dot {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--b-success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--b-success) 18%, transparent);
}

.iflow-pill__name,
.iflow-pill__ms {
  transition: opacity 300ms ease, transform 300ms ease;
}

.iflow-pill__name {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--b-text);
  font-weight: 450;
}

.iflow-pill__ms {
  color: var(--b-muted);
  font-variant-numeric: tabular-nums;
}

.iflow-pill.is-swap .iflow-pill__name,
.iflow-pill.is-swap .iflow-pill__ms { opacity: 0; transform: translateY(3px); }

/* ---------- Karte 4: S/4HANA ---------- */
.s4-ecc-row { transition: opacity 600ms ease; }

.s4-tile .sv-node { transition: stroke 500ms ease; }
.s4-tile .s4-bar { fill: var(--b-skel); transition: fill 500ms ease; }
.s4-tile.is-on .sv-node { stroke: var(--b-ink); stroke-opacity: 0.55; }
.s4-tile.is-on .s4-bar { fill: var(--b-ink); }

.s4-node {
  fill: var(--b-card);
  stroke: var(--b-line);
  stroke-width: 1.5;
  transition: fill 400ms ease, stroke 400ms ease;
}

.s4-node.is-done { fill: var(--b-ink); stroke: var(--b-ink); }

.s4-label { transition: fill 400ms ease; }
.s4-label.is-done { fill: var(--b-text); }

.s4-progress {
  stroke: var(--b-ink);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.s4-gauge-bg { fill: var(--b-card); stroke: var(--b-line); stroke-width: 3; }

.s4-gauge {
  fill: none;
  stroke: var(--b-ink);
  stroke-width: 3;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-box: fill-box;
  transform-origin: center;
}

.s4-pct {
  font: 500 16px/1 'Inter', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  fill: var(--b-text);
}

.s4-pkt {
  fill: var(--b-ink);
  opacity: 0;
}

.s4-svg.is-flowing .s4-pkt { animation: s4-flow 2.2s ease-in-out infinite; }

@keyframes s4-flow {
  0%   { transform: translateX(0);     opacity: 0; }
  15%  { opacity: 0.85; }
  85%  { opacity: 0.85; }
  100% { transform: translateX(162px); opacity: 0; }
}

.s4-svg { transition: opacity 500ms ease; }
.s4-svg.is-fading { opacity: 0; }

/* ---------- Karte 5: EWM MFS ---------- */
.bento-card--ewm {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr);
  min-height: 440px;
}

.bento-card--ewm .bento-card__body {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 32px;
}

.ewm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.ewm-tags li {
  padding: 5px 10px;
  border: 1px solid var(--b-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.3;
  color: var(--b-muted);
}

.ewm-rack-line { stroke: var(--b-line); stroke-width: 1; }
.ewm-beam { stroke: var(--b-line); stroke-width: 1.5; }

.ewm-box {
  fill: var(--b-box);
  stroke: var(--b-box-stroke);
  stroke-width: 1;
  transition: opacity 700ms ease;
}

.ewm-box.is-empty { opacity: 0; }
.ewm-box.is-flash { animation: ewm-flash 1.4s var(--b-ease-out); }

@keyframes ewm-flash {
  0%   { fill: var(--b-ink); }
  100% { fill: var(--b-box); }
}

.ewm-box--active { fill: var(--b-ink); stroke: none; }

.ewm-mast { fill: var(--b-mast); }
.ewm-carriage { fill: var(--b-ink); }

.ewm-belt {
  stroke: var(--b-line);
  stroke-width: 2;
  stroke-dasharray: 2 6;
}

.ewm-svg.is-conveying .ewm-belt { animation: ewm-belt 0.6s linear infinite; }

@keyframes ewm-belt { to { stroke-dashoffset: -8; } }

.ewm-roller { fill: none; stroke: var(--b-line); stroke-width: 1; }

.tg-panel {
  position: absolute;
  z-index: 2;
  top: 28px;
  left: 4%;
  width: min(46%, 384px);
  border: 1px solid var(--b-node-border);
  border-radius: 12px;
  background: var(--b-panel);
  box-shadow: var(--b-node-shadow);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
}

.tg-panel__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--b-border);
  color: var(--b-text);
  font-weight: 450;
}

.tg-panel__bar svg { width: 14px; height: 14px; color: var(--b-ink); }

.tg-panel__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--b-muted);
  font-weight: 400;
}

.tg-panel__live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--b-success);
  animation: tg-live 2.4s ease-in-out infinite;
}

@keyframes tg-live {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.tg-rows {
  display: flex;
  flex-direction: column;
  height: 170px;
  padding: 6px 0;
  overflow: hidden;
}

.tg-row {
  display: grid;
  grid-template-columns: 78px 72px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  height: 31px;
  padding: 0 14px;
  color: var(--b-muted);
  font-variant-numeric: tabular-nums;
}

.tg-row.is-new { animation: tg-in 600ms var(--b-ease-out); }
.tg-row.is-new .tg-code { color: var(--b-ink); }

@keyframes tg-in {
  0%   { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: none; }
}

.tg-dir {
  justify-self: start;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--b-ink-soft);
  color: var(--b-text);
  font-size: 11px;
  white-space: nowrap;
}

.tg-dir--in {
  background: color-mix(in srgb, var(--b-success) 14%, transparent);
}

.tg-code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--b-text);
  font-weight: 500;
  transition: color 1.2s ease;
}

.tg-code span { color: var(--b-muted); font-weight: 400; margin-left: 6px; }

.ewm-visual { position: relative; min-height: 440px; }

.ewm-visual .bento-card__stage {
  position: absolute;
  inset: 0;
  min-height: 0;
}

.ewm-visual .bento-card__stage > svg {
  inset: 24px 24px 20px 0;
  width: calc(100% - 24px);
  height: calc(100% - 44px);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento-card--span2,
  .bento-card--span3 { grid-column: 1 / -1; }
  .bento-card--ewm { grid-template-columns: 1fr; }
  .bento-card--ewm .bento-card__body { order: 2; padding-top: 0; }
  .bento-card--ewm .ewm-visual { order: 1; }
}

@media (max-width: 760px) {
  .bento { grid-template-columns: 1fr; }
  .bento-card { min-height: 0; }
  .bento-card__stage { min-height: 300px; }
  .bento-card__body { padding: 0 24px 24px; }
  .bento-card--ewm .bento-card__body { padding: 0 24px 24px; }
  .ewm-visual { min-height: 0; display: flex; flex-direction: column; }
  .tg-panel { position: relative; top: auto; left: auto; width: auto; margin: 24px 24px 0; }
  .ewm-visual .bento-card__stage { position: relative; inset: auto; min-height: 240px; }
  .ewm-visual .bento-card__stage > svg { inset: 0; width: 100%; height: 100%; }
  .tg-row { grid-template-columns: 72px minmax(0, 1fr); padding: 0 12px; gap: 8px; }
  .tg-time { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bento-card[data-bento-reveal] { opacity: 1; transform: none; transition: none; }
  .i-halo, .tg-panel__live::before { animation: none; }
}
