/**
 * TelccFree — Exercise tile design (B1 + B2)
 * Default: plain card frame, no success border, no validée icon.
 * Perfect score (.show-validee): ✓ badge only; reward rings on score circle only.
 */

html:not(.telc-scores-ready) .score-dot:not(.score-static),
html:not(.telc-scores-ready) .user-score-badge:not(.score-static),
html:not(.telc-scores-ready) a.ex-btn .score-dot:not(.score-static),
html:not(.telc-scores-ready) div.ex-btn .score-dot:not(.score-static) {
  visibility: hidden !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  color: transparent !important;
}

html.telc-scores-ready .score-dot,
html.telc-scores-ready .user-score-badge {
  visibility: visible;
}

:root {
  --telc-tile-pink: #e91e8c;
  --telc-tile-blue: #1976d2;
  --telc-tile-text: #1a1a2e;
  --telc-tile-border: #f0d0e8;
  --telc-tile-radius: 16px;
  --telc-tile-green: #2e7d32;
  --telc-tile-red: #e53935;
  --telc-tile-yellow: #ca8a04;
  --telc-tile-blue-tier: #1976d2;
  --telc-tile-gold: #f9a825;
}

.section-card,
.section-body {
  overflow: visible !important;
}

.exercise-grid,
.telc-exercise-grid,
#hoeren-hub-grid,
#hoeren-teil1-grid,
#hoeren-teil2-hub-grid,
#hoeren-teil3-hub-grid,
#b1-hoeren-t1-grid,
#b1-hoeren-t2-grid,
#b1-hoeren-t3-grid,
[id^="hoeren-"][id$="-grid"],
[id^="sprechen-"],
[id^="hoeren-turkei-"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  padding: 10px 10px 4px 4px;
  overflow: visible !important;
}

@media (max-width: 640px) {
  .exercise-grid,
  .telc-exercise-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .exercise-grid,
  .telc-exercise-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

/* ── Default card frame (always visible, neutral — no success styling) ── */
a.ex-btn,
div.ex-btn,
button.ex-btn {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  width: 100% !important;
  height: 4rem !important;
  min-height: 4rem !important;
  max-height: 4rem !important;
  text-decoration: none !important;
  background: linear-gradient(135deg, #fce4ec 0%, #e3f2fd 100%) !important;
  border: 1.5px solid var(--telc-tile-border) !important;
  color: var(--telc-tile-text) !important;
  padding: 1rem !important;
  border-radius: var(--telc-tile-radius) !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  transition: all 0.22s ease !important;
  box-shadow: 0 2px 6px rgba(233, 30, 140, 0.07) !important;
  position: relative !important;
  overflow: hidden !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  cursor: pointer !important;
  user-select: none !important;
  -webkit-tap-highlight-color: transparent;
}

a.ex-btn.show-validee,
div.ex-btn.show-validee,
button.ex-btn.show-validee,
div.ex-btn.ex-version-picker-trigger.show-validee {
  overflow: visible !important;
}

a.ex-btn:hover,
div.ex-btn:hover,
button.ex-btn:hover {
  background: linear-gradient(135deg, #f8bbd0 0%, #bbdefb 100%) !important;
  border-color: #e8a0cc !important;
  transform: translateY(-3px) scale(1.015) !important;
  box-shadow: 0 6px 20px rgba(233, 30, 140, 0.18) !important;
}

a.ex-btn:active,
div.ex-btn:active,
button.ex-btn:active {
  transform: translateY(-1px) scale(1.005) !important;
}

a.ex-btn:focus-visible,
div.ex-btn:focus-visible {
  outline: 2px solid rgba(233, 30, 140, 0.45) !important;
  outline-offset: 2px !important;
}

a.ex-btn::before,
div.ex-btn::before,
button.ex-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--telc-tile-pink), var(--telc-tile-blue));
  border-radius: 3px 0 0 3px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

a.ex-btn:hover::before,
div.ex-btn:hover::before,
button.ex-btn:hover::before {
  opacity: 1;
}

/* Validée hidden by default */
a.ex-btn::after,
div.ex-btn::after,
button.ex-btn::after {
  content: none !important;
  display: none !important;
}

/* Legacy is-completed must not show reward visuals */
a.ex-btn.is-completed,
div.ex-btn.is-completed,
button.ex-btn.is-completed {
  border-color: var(--telc-tile-border) !important;
  box-shadow: 0 2px 6px rgba(233, 30, 140, 0.07) !important;
}

a.ex-btn.is-completed::after,
div.ex-btn.is-completed::after,
button.ex-btn.is-completed::after {
  content: none !important;
  display: none !important;
}

/* ── Perfect score: validée checkmark only (no card border change) ── */
a.ex-btn.show-validee,
div.ex-btn.show-validee,
button.ex-btn.show-validee {
  border-color: var(--telc-tile-border) !important;
  box-shadow: 0 2px 6px rgba(233, 30, 140, 0.07) !important;
}

a.ex-btn.show-validee::after,
div.ex-btn.show-validee::after,
button.ex-btn.show-validee::after {
  content: "✓" !important;
  display: flex !important;
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: var(--telc-tile-green);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  z-index: 20;
  pointer-events: none;
}

.ex-btn .ex-label,
a.ex-btn .ex-label,
div.ex-btn .ex-label {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  line-height: 1.25 !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  padding-right: 0.5rem !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  pointer-events: none !important;
  color: #1e293b !important;
}

.ex-btn .ex-label-row,
a.ex-btn .ex-label-row,
div.ex-btn .ex-label-row {
  flex: 1 1 0%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.ex-btn .ex-label-row .ex-label,
a.ex-btn .ex-label-row .ex-label,
div.ex-btn .ex-label-row .ex-label {
  flex: 1 1 auto !important;
  padding-right: 0 !important;
}

.ex-btn .sprechen-mod-badge,
a.ex-btn .sprechen-mod-badge,
div.ex-btn .sprechen-mod-badge,
.version-picker-option-label .sprechen-mod-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fde68a;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  vertical-align: middle;
}

html.dark .ex-btn .sprechen-mod-badge,
html.dark a.ex-btn .sprechen-mod-badge,
html.dark div.ex-btn .sprechen-mod-badge,
html.dark .version-picker-option-label .sprechen-mod-badge {
  background: #facc15;
  color: #422006;
  border-color: #eab308;
}

@media (max-width: 480px) {
  .ex-btn .sprechen-mod-badge,
  a.ex-btn .sprechen-mod-badge,
  div.ex-btn .sprechen-mod-badge,
  .version-picker-option-label .sprechen-mod-badge {
    font-size: 10px;
    padding: 2px 7px;
  }
}

/* Badge row — never shrink */
.ex-btn .ex-static-scores,
a.ex-btn .ex-static-scores,
div.ex-btn .ex-static-scores {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  flex-shrink: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.375rem !important;
  margin-left: auto !important;
  pointer-events: none !important;
}

.ex-btn > .score-dot:not(.score-static),
a.ex-btn > .score-dot:not(.score-static),
div.ex-btn > .score-dot:not(.score-static) {
  flex-shrink: 0 !important;
  margin-left: auto !important;
}

.ex-btn .score-dot,
a.ex-btn .score-dot,
div.ex-btn .score-dot {
  flex-shrink: 0 !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  max-width: 44px !important;
  max-height: 40px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.7rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.02em !important;
  line-height: 1 !important;
  text-align: center !important;
  white-space: nowrap !important;
  pointer-events: none !important;
  position: relative !important;
  z-index: 10 !important;
  isolation: isolate !important;
  transition: background 0.25s, transform 0.15s !important;
  box-shadow: none !important;
}

/* Empty placeholder — untouched / never attempted (no score history) */
.ex-btn .score-dot.is-unattempted,
a.ex-btn .score-dot.is-unattempted,
div.ex-btn .score-dot.is-unattempted,
.ex-btn .score-dot:not(.has-score):not(.score-static),
a.ex-btn .score-dot:not(.has-score):not(.score-static),
div.ex-btn .score-dot:not(.has-score):not(.score-static) {
  background-color: rgba(0, 0, 0, 0.03) !important;
  border: 1px dashed rgba(0, 0, 0, 0.2) !important;
  color: rgba(0, 0, 0, 0.28) !important;
  opacity: 1 !important;
  box-shadow: none !important;
  display: flex !important;
  font-weight: 600 !important;
}

html.dark .ex-btn .score-dot.is-unattempted,
html.dark a.ex-btn .score-dot.is-unattempted,
html.dark div.ex-btn .score-dot.is-unattempted,
html.dark .ex-btn .score-dot:not(.has-score):not(.score-static) {
  background-color: rgba(255, 255, 255, 0.04) !important;
  border: 1px dashed rgba(255, 255, 255, 0.22) !important;
  color: rgba(255, 255, 255, 0.35) !important;
}

.ex-btn .score-dot.has-score,
a.ex-btn .score-dot.has-score,
div.ex-btn .score-dot.has-score,
.score-dot.has-score.score-badge {
  opacity: 1 !important;
  border: none !important;
  outline: none !important;
  color: #fff !important;
  background-image: none !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  font-weight: 800 !important;
  isolation: isolate !important;
  transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease !important;
}

/* Red fallback only without a tier class — must not override score-green on master badges */
.ex-btn .score-dot.has-score:not(.score-green):not(.score-blue):not(.score-gold):not(.score-yellow):not(.telc-gold-crown-badge),
a.ex-btn .score-dot.has-score:not(.score-green):not(.score-blue):not(.score-gold):not(.score-yellow):not(.telc-gold-crown-badge),
div.ex-btn .score-dot.has-score:not(.score-green):not(.score-blue):not(.score-gold):not(.score-yellow):not(.telc-gold-crown-badge),
.ex-btn .score-dot.master-score-badge.has-score:not(.score-green):not(.score-blue):not(.score-gold):not(.score-yellow):not(.telc-gold-crown-badge) {
  background-color: var(--telc-tile-red) !important;
}

.ex-btn .score-dot.has-score.score-red,
a.ex-btn .score-dot.has-score.score-red,
.ex-btn .score-dot.master-score-badge.has-score.score-red {
  background: var(--telc-tile-red) !important;
  background-color: var(--telc-tile-red) !important;
}
.ex-btn .score-dot.has-score.score-green,
a.ex-btn .score-dot.has-score.score-green,
.ex-btn .score-dot.master-score-badge.has-score.score-green {
  background: var(--telc-tile-green) !important;
  background-color: var(--telc-tile-green) !important;
}
.ex-btn .score-dot.has-score.score-blue,
a.ex-btn .score-dot.has-score.score-blue,
.ex-btn .score-dot.master-score-badge.has-score.score-blue {
  background: var(--telc-tile-blue-tier) !important;
  background-color: var(--telc-tile-blue-tier) !important;
}
.ex-btn .score-dot.has-score.score-gold:not(.telc-gold-crown-badge),
a.ex-btn .score-dot.has-score.score-gold:not(.telc-gold-crown-badge),
.ex-btn .score-dot.master-score-badge.has-score.score-gold:not(.telc-gold-crown-badge) {
  background: var(--telc-tile-gold) !important;
  background-color: var(--telc-tile-gold) !important;
}

/* Legacy yellow tier removed — kept as alias to red for stale markup */
.ex-btn .score-dot.has-score.score-yellow,
a.ex-btn .score-dot.has-score.score-yellow,
div.ex-btn .score-dot.has-score.score-yellow {
  background: var(--telc-tile-yellow) !important;
  color: #1a1508 !important;
}

/* Keep score text crisp above decorative page backgrounds (e.g. Hören headphones) */
.ex-btn .score-dot.has-score,
a.ex-btn .score-dot.has-score {
  -webkit-font-smoothing: antialiased;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}

/* Multi-version parent cards — single master badge (see telc-master-score-card.css) */
.ex-btn.ex-version-picker-trigger .ex-static-scores,
.ex-btn.ex-version-picker-trigger .score-more-indicator {
  display: none !important;
}

.ex-btn.ex-version-picker-trigger {
  overflow: visible !important;
}

.ex-btn.ex-version-picker-trigger > .score-dot.master-score-badge.is-unattempted,
.ex-btn.ex-version-picker-trigger > .score-dot.master-score-badge.is-unplayed {
  display: flex !important;
}

.ex-subtask-frame-dots {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
  z-index: 15;
}

.ex-subtask-micro-dot {
  width: 5px;
  height: 5px;
  min-width: 5px;
  min-height: 5px;
  border-radius: 50%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.ex-subtask-micro-dot.is-dim {
  background-color: #888 !important;
  border: none !important;
  opacity: 0.25 !important;
  box-shadow: none !important;
}

.ex-subtask-micro-dot.is-pass.is-green,
.ex-subtask-micro-dot.is-green {
  background-color: #2e7d32 !important;
  border: 1px solid #2e7d32 !important;
  opacity: 1 !important;
  box-shadow: 0 0 4px rgba(46, 125, 50, 0.65) !important;
}

.ex-subtask-micro-dot.is-pass.is-blue,
.ex-subtask-micro-dot.is-blue {
  background-color: #1976d2 !important;
  border: 1px solid #1976d2 !important;
  opacity: 1 !important;
  box-shadow: 0 0 4px rgba(25, 118, 210, 0.65) !important;
}

.ex-subtask-micro-dot.is-pass.is-gold,
.ex-subtask-micro-dot.is-gold {
  background-color: #fbc02d !important;
  border: 1px solid #f9a825 !important;
  opacity: 1 !important;
  box-shadow: 0 0 4px rgba(251, 192, 45, 0.75) !important;
}

.ex-subtask-micro-dot.is-pass.is-red,
.ex-subtask-micro-dot.is-red {
  background-color: #e53935 !important;
  border: 1px solid #e53935 !important;
  opacity: 1 !important;
  box-shadow: 0 0 4px rgba(229, 57, 53, 0.65) !important;
}

/* Legacy alias — generic is-pass = green, but NEVER override red/blue/gold */
.ex-subtask-micro-dot.is-pass:not(.is-blue):not(.is-gold):not(.is-red) {
  background-color: #2e7d32 !important;
  border: 1px solid #2e7d32 !important;
  opacity: 1 !important;
  box-shadow: 0 0 4px rgba(46, 125, 50, 0.65) !important;
}

/* Legacy static version dots stay hidden inside multi-version cards */
.exercise-grid .ex-static-scores > .score-dot.score-static.is-unplayed {
  display: none !important;
}

@keyframes telcDotPop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.ex-btn .score-dot.popping {
  animation: telcDotPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes telcFreshHighlight {
  0% { box-shadow: 0 0 0 0 rgba(233, 30, 140, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(233, 30, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(233, 30, 140, 0); }
}

.ex-btn.fresh-score {
  animation: telcFreshHighlight 1s ease-out 2;
}

/* Neutral dark tiles only — never override mastery premium skins */
html.dark a.ex-btn:not(.telc-m2-premium),
html.dark div.ex-btn:not(.telc-m2-premium),
html.dark button.ex-btn:not(.telc-m2-premium) {
  background: #243047 !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

html.dark a.ex-btn:not(.telc-m2-premium):hover,
html.dark div.ex-btn:not(.telc-m2-premium):hover,
html.dark button.ex-btn:not(.telc-m2-premium):hover {
  background: #2d3a4f !important;
  border-color: #64748b !important;
}

html.dark .ex-btn:not(.telc-m2-premium) .ex-label,
html.dark a.ex-btn:not(.telc-m2-premium) .ex-label {
  color: #f1f5f9 !important;
}

/* Version picker (same modal as Programmierer) — available on Sprechen hubs too */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 30, 0.55);
  backdrop-filter: blur(8px);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}
.version-picker-box {
  background: #fff;
  border-radius: var(--radius-xl, 20px);
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  position: relative;
}
.version-picker-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(233, 30, 140, 0.08);
  color: #9b4d96;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.version-picker-close:hover {
  background: rgba(233, 30, 140, 0.15);
}
.version-picker-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main, #1a1a2e);
  text-align: center;
}
.version-picker-sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: #888;
  text-align: center;
}
.version-picker-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.version-picker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid #f0d0e8;
  border-radius: var(--radius-md, 14px);
  background: linear-gradient(135deg, #fce4ec 0%, #e3f2fd 100%);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main, #1a1a2e);
  text-align: left;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(233, 30, 140, 0.07);
}
.version-picker-option:hover {
  transform: translateY(-2px);
  border-color: #e8a0cc;
  box-shadow: 0 6px 18px rgba(233, 30, 140, 0.15);
}
.version-picker-option-label {
  flex: 1;
  line-height: 1.35;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.version-picker-option-badge {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  font-size: 9px;
  pointer-events: none;
}
html.dark .version-picker-box {
  background: #1e293b;
  border: 1px solid #334155;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
html.dark .version-picker-close {
  background: rgba(148, 163, 184, 0.15);
  color: #e2e8f0;
}
html.dark .version-picker-title {
  color: #f8fafc;
}
html.dark .version-picker-sub {
  color: #94a3b8;
}
html.dark .version-picker-option {
  background: #0f172a;
  border-color: #475569;
  color: #f8fafc;
}
html.dark .version-picker-option:hover {
  background: #243047;
  border-color: #94a3b8;
}
@media (max-width: 480px) {
  .version-picker-box {
    padding: 24px 18px 18px;
    max-width: calc(100vw - 32px);
  }
  .version-picker-option {
    padding: 12px 14px;
    font-size: 13px;
  }
}

[data-sprechen-grid="b1-teil2"] .ex-btn .ex-label,
[data-sprechen-grid="b1-teil2"] div.ex-btn .ex-label {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
