/* ==========================================================================
   Memory – Kennzeichnungen im Onlinehandel
   bevh – Bundesverband E-Commerce und Versandhandel Deutschland e.V.

   Aufbau:
   1. Design-Tokens (Farben, Abstände, Schatten, Animationen)
   2. Basis
   3. Kopfbereich
   4. Informationsleiste
   5. Spielfeld & Karten
   6. Buttons
   7. Popups (Wissensfenster & Spielende)
   8. Konfetti & Hilfsklassen
   9. Responsive Anpassungen
   10. Reduzierte Bewegung

   Alle Klassen tragen das Präfix "bm-", damit sich das Spiel konfliktfrei
   in eine bestehende Website einbetten lässt.
   ========================================================================== */


/* 1. Design-Tokens
   ========================================================================== */
:root {
  /* Farbwelt */
  --bm-navy: #004286;
  --bm-navy-dark: #00336a;
  --bm-sky: #5d98c0;
  --bm-sky-soft: #e8f1f7;
  --bm-white: #ffffff;
  --bm-surface: #f4f7fa;
  --bm-line: #e2e9f0;
  --bm-text: #14263a;
  --bm-muted: #5a6b7d;

  /* Typografie (Systemschriften, keine externen Fonts) */
  --bm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Formen & Schatten */
  --bm-radius-card: 12px;
  --bm-radius-panel: 20px;
  --bm-shadow-card: 0 1px 2px rgba(0, 38, 77, 0.06), 0 4px 14px rgba(0, 38, 77, 0.08);
  --bm-shadow-card-hover: 0 2px 4px rgba(0, 38, 77, 0.08), 0 14px 30px rgba(0, 38, 77, 0.14);
  --bm-shadow-modal: 0 24px 60px rgba(0, 30, 60, 0.25);

  /* Bewegung */
  --bm-ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --bm-flip-duration: 600ms;

  /* Spielfeld */
  --bm-board-max: 1000px;
  --bm-gap: clamp(8px, 1.8vw, 20px);
  --bm-card-ratio: 4 / 3;
}


/* 2. Basis
   ========================================================================== */
.bm-body {
  margin: 0;
  background: var(--bm-white);
  color: var(--bm-text);
  font-family: var(--bm-font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.bm-app *,
.bm-app *::before,
.bm-app *::after,
.bm-modal *,
.bm-modal *::before,
.bm-modal *::after {
  box-sizing: border-box;
}

.bm-app {
  max-width: calc(var(--bm-board-max) + 2 * clamp(16px, 4vw, 48px));
  margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) clamp(16px, 4vw, 48px) clamp(40px, 6vw, 80px);
  font-family: var(--bm-font);
}


/* 3. Kopfbereich
   ========================================================================== */
.bm-header {
  max-width: 720px;
  margin: 0 auto clamp(28px, 4vw, 44px);
  text-align: center;
}

.bm-title {
  margin: 0 0 16px;
  color: var(--bm-navy);
  font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* Feine Akzentlinie unter der Überschrift */
.bm-title::after {
  content: "";
  display: block;
  width: 48px;
  height: 3px;
  margin: 18px auto 0;
  border-radius: 3px;
  background: var(--bm-sky);
}

.bm-intro {
  margin: 0;
  color: var(--bm-muted);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
}


/* 4. Informationsleiste
   ========================================================================== */
.bm-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--bm-gap);
  max-width: var(--bm-board-max);
  margin: 0 auto clamp(20px, 3vw, 32px);
}

.bm-stat {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid var(--bm-line);
  border-radius: 14px;
  background: var(--bm-white);
}

.bm-stat__icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bm-sky-soft);
  color: var(--bm-navy);
}

.bm-stat__icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bm-stat__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bm-stat__label {
  color: var(--bm-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-stat__value {
  color: var(--bm-navy);
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}


/* 5. Spielfeld & Karten
   ========================================================================== */
.bm-board-wrap {
  max-width: var(--bm-board-max);
  margin: 0 auto;
  padding: var(--bm-gap);
  border-radius: var(--bm-radius-panel);
  background: var(--bm-surface);
}

.bm-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--bm-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Während des Austeilens keine Klicks zulassen */
.bm-board.is-dealing {
  pointer-events: none;
}

.bm-cell {
  aspect-ratio: var(--bm-card-ratio);
  /* Ebene für die Einflug-Animation (per Web Animations API) */
  will-change: transform, opacity;
}

/* Die Karte selbst ist ein Button: tastaturbedienbar und screenreaderfreundlich */
.bm-card {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--bm-radius-card);
  background: transparent;
  cursor: pointer;
  perspective: 1200px;
  transition: transform 260ms var(--bm-ease);
  -webkit-tap-highlight-color: transparent;
}

.bm-card:focus-visible {
  outline: 3px solid var(--bm-sky);
  outline-offset: 4px;
}

.bm-card__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--bm-flip-duration) var(--bm-ease);
}

.bm-card.is-flipped .bm-card__inner,
.bm-card.is-matched .bm-card__inner {
  transform: rotateY(180deg);
}

.bm-card__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bm-line);
  border-radius: var(--bm-radius-card);
  background: var(--bm-white);
  box-shadow: var(--bm-shadow-card);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: box-shadow 260ms var(--bm-ease), border-color 260ms var(--bm-ease);
}

.bm-card__face--back {
  padding: 18%;
}

.bm-card__face--front {
  padding: 12% 7%;
  transform: rotateY(180deg);
}

.bm-card__logo,
.bm-card__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.bm-card__logo {
  width: 100%;
  height: 100%;
}

/* Hover: Karte hebt sich leicht an, Schatten wird stärker
   (nur auf Geräten mit echter Maus und nur bei verdeckten Karten) */
@media (hover: hover) and (pointer: fine) {
  .bm-card:not(.is-flipped):not(.is-matched):hover {
    transform: translateY(-4px);
  }

  .bm-card:not(.is-flipped):not(.is-matched):hover .bm-card__face {
    box-shadow: var(--bm-shadow-card-hover);
  }
}

/* Gefundenes Paar: dauerhaft sichtbar, feiner Rahmen in Hellblau */
.bm-card.is-matched {
  cursor: default;
}

.bm-card.is-matched .bm-card__face--front {
  border-color: rgba(93, 152, 192, 0.6);
  box-shadow: 0 0 0 1px rgba(93, 152, 192, 0.35), var(--bm-shadow-card);
}

/* Kurze, dezente Bestätigungsanimation */
.bm-card.is-celebrating {
  animation: bm-match-pulse 620ms var(--bm-ease);
}

.bm-card.is-celebrating .bm-card__face--front {
  animation: bm-match-ring 900ms ease-out;
}

@keyframes bm-match-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.045); }
  100% { transform: scale(1); }
}

@keyframes bm-match-ring {
  0%   { box-shadow: 0 0 0 0 rgba(93, 152, 192, 0.55), var(--bm-shadow-card); }
  100% { box-shadow: 0 0 0 12px rgba(93, 152, 192, 0), var(--bm-shadow-card); }
}

/* Kleines Häkchen oben rechts bei gefundenen Paaren */
.bm-card__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bm-sky);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 300ms var(--bm-ease) 250ms, transform 300ms var(--bm-ease) 250ms;
}

.bm-card__badge svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--bm-white);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bm-card.is-matched .bm-card__badge {
  opacity: 1;
  transform: scale(1);
}


/* 6. Buttons
   ========================================================================== */
.bm-actions {
  display: flex;
  justify-content: center;
  margin-top: clamp(24px, 4vw, 40px);
}

.bm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 28px;
  border: 2px solid var(--bm-navy);
  border-radius: 999px;
  font-family: var(--bm-font);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

.bm-btn:focus-visible {
  outline: 3px solid var(--bm-sky);
  outline-offset: 3px;
}

.bm-btn--primary {
  background: var(--bm-navy);
  color: var(--bm-white);
}

.bm-btn--primary:hover {
  border-color: var(--bm-navy-dark);
  background: var(--bm-navy-dark);
  box-shadow: 0 6px 18px rgba(0, 66, 134, 0.25);
}

.bm-btn--ghost {
  background: var(--bm-white);
  color: var(--bm-navy);
}

.bm-btn--ghost:hover {
  background: var(--bm-navy);
  color: var(--bm-white);
}

.bm-btn:active {
  transform: translateY(1px);
}

.bm-btn__icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* 7. Popups (Wissensfenster & Spielende)
   ========================================================================== */
.bm-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: var(--bm-font);
}

.bm-modal[hidden] {
  display: none;
}

.bm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 28, 58, 0.48);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: bm-fade-in 260ms ease both;
}

.bm-modal__panel {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: clamp(24px, 5vw, 40px);
  border-radius: var(--bm-radius-panel);
  background: var(--bm-white);
  box-shadow: var(--bm-shadow-modal);
  color: var(--bm-text);
  animation: bm-panel-in 380ms var(--bm-ease) both;
  overscroll-behavior: contain;
}

.bm-modal__panel--center {
  max-width: 480px;
  text-align: center;
}

.bm-modal.is-closing .bm-modal__backdrop {
  animation: bm-fade-out 200ms ease both;
}

.bm-modal.is-closing .bm-modal__panel {
  animation: bm-panel-out 200ms ease both;
}

@keyframes bm-fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes bm-fade-out  { from { opacity: 1; } to { opacity: 0; } }
@keyframes bm-panel-in  { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes bm-panel-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(0.98); } }

.bm-modal__head {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--bm-line);
}

/* Symbol: das jeweilige Kennzeichen */
.bm-modal__symbol {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 96px;
  height: 96px;
  padding: 12px;
  border: 1px solid var(--bm-line);
  border-radius: 14px;
  background: var(--bm-white);
  box-shadow: var(--bm-shadow-card);
}

.bm-modal__symbol img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.bm-modal__eyebrow {
  margin: 0 0 4px;
  color: var(--bm-sky);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bm-modal__title {
  margin: 0;
  color: var(--bm-navy);
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.6rem);
  font-weight: 700;
  line-height: 1.25;
}

.bm-modal__body {
  color: var(--bm-text);
  font-size: 1rem;
}

.bm-modal__body p {
  margin: 0 0 12px;
}

.bm-modal__body ul {
  margin: 0 0 14px;
  padding-left: 0;
  list-style: none;
}

.bm-modal__body li {
  position: relative;
  margin-bottom: 6px;
  padding-left: 22px;
}

.bm-modal__body li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bm-sky);
}

/* Zitierte Pflichtformulierungen (z. B. Warnhinweis) */
.bm-modal__body .bm-quote {
  margin: 0 0 8px;
  padding: 10px 16px;
  border-left: 3px solid var(--bm-navy);
  border-radius: 0 8px 8px 0;
  background: var(--bm-sky-soft);
  color: var(--bm-navy);
  font-weight: 600;
}

.bm-modal__body .bm-or {
  margin: 0 0 8px 19px;
  color: var(--bm-muted);
  font-size: 0.875rem;
}

.bm-modal__body > :last-child {
  margin-bottom: 0;
}

.bm-modal__footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
}

.bm-modal__footer--center {
  justify-content: center;
}

.bm-modal__trophy {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--bm-sky-soft);
  color: var(--bm-navy);
}

.bm-modal__trophy svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bm-modal__lead {
  margin: 10px 0 24px;
  color: var(--bm-muted);
  font-size: 1.0625rem;
}

.bm-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.bm-result__item {
  padding: 16px 12px;
  border: 1px solid var(--bm-line);
  border-radius: 14px;
  background: var(--bm-surface);
}

.bm-result dt {
  color: var(--bm-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.bm-result dd {
  margin: 4px 0 0;
  color: var(--bm-navy);
  font-size: 1.625rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}


/* 8. Konfetti & Hilfsklassen
   ========================================================================== */
.bm-confetti {
  position: fixed;
  inset: 0;
  z-index: 1100;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.bm-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}


/* 9. Responsive Anpassungen
   ========================================================================== */

/* Tablet */
@media (max-width: 820px) {
  .bm-stat {
    gap: 10px;
    padding: 12px 14px;
  }

  .bm-stat__icon {
    width: 36px;
    height: 36px;
  }

  .bm-stat__icon svg {
    width: 19px;
    height: 19px;
  }

  .bm-stat__value {
    font-size: 1.2rem;
  }
}

/* Smartphone */
@media (max-width: 600px) {
  :root {
    --bm-card-ratio: 1 / 1;
    --bm-radius-card: 10px;
  }

  .bm-stats {
    gap: 8px;
  }

  .bm-stat {
    flex-direction: column;
    gap: 6px;
    padding: 12px 6px;
    text-align: center;
  }

  .bm-stat__text {
    align-items: center;
  }

  .bm-stat__label {
    font-size: 0.75rem;
  }

  .bm-stat__value {
    font-size: 1.1rem;
  }

  .bm-board-wrap {
    border-radius: 14px;
  }

  .bm-card__face--back {
    padding: 16%;
  }

  .bm-card__face--front {
    padding: 14% 9%;
  }

  .bm-card__badge {
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
  }

  .bm-card__badge svg {
    width: 10px;
    height: 10px;
  }

  .bm-modal {
    align-items: flex-end;
    padding: 12px;
  }

  .bm-modal__head {
    gap: 14px;
  }

  .bm-modal__symbol {
    width: 72px;
    height: 72px;
    padding: 8px;
  }

  .bm-modal__footer .bm-btn {
    width: 100%;
  }
}


/* 10. Reduzierte Bewegung (Systemeinstellung respektieren)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  :root {
    --bm-flip-duration: 1ms;
  }

  .bm-card,
  .bm-card__face,
  .bm-card__badge,
  .bm-btn {
    transition: none;
  }

  .bm-card.is-celebrating,
  .bm-card.is-celebrating .bm-card__face--front,
  .bm-modal__backdrop,
  .bm-modal__panel,
  .bm-modal.is-closing .bm-modal__backdrop,
  .bm-modal.is-closing .bm-modal__panel {
    animation: none;
  }
}
