/*
 * Sortier-Raetsel. Jeder Eintrag ist eine Karte (.ltrs-card) mit Inhalt links
 * und zwei Pfeil-Buttons (.ltrs-icon-button) rechts; Aussehen von Karte und
 * Buttons kommt aus riddle-components.css, hier steht nur die Anordnung.
 */
.sort-riddle .sort-container {
  margin-top: var(--ltrs-gap);
}

.sort-riddle .sortable-items {
  display: flex;
  gap: 14px;
}

.sort-riddle .sortable-items.vertical {
  flex-direction: column;
}

/* Waagerecht: Karten nebeneinander, Pfeile unter dem Inhalt - so bleiben die
   Karten schmal. Reicht die Breite nicht, bricht die Reihe um (gelesen wird
   zeilenweise), statt Karten seitlich aus dem Blick zu schieben. */
.sort-riddle .sortable-items.horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

.sort-riddle .sortable-items.horizontal .sort-item {
  flex-direction: column;
}

.sort-riddle .sort-item {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
  padding: 12px 12px 12px 18px;
  cursor: grab;
  /* Ueber der Karte scrollt der Finger die Seite; gezogen wird am Griff */
  touch-action: pan-y;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sort-riddle .sort-item:active {
  cursor: grabbing;
}

/* Griff nur auf Touch-Geraeten: dort zieht allein er (siehe sort-riddle.js),
   mit der Maus ist die ganze Karte greifbar. */
.sort-riddle .sort-item-grip {
  display: none;
}

@media (pointer: coarse) {
  .sort-riddle .sort-item {
    padding-left: 2px;
  }

  .sort-riddle .sort-item-grip {
    display: block;
    flex: 0 0 auto;
    align-self: stretch;
    width: 40px;
    min-height: 44px;
    margin: -12px 0;
    position: relative;
    touch-action: none;
    cursor: grab;
  }

  /* Griffmarke: 2x3 Punkte in der Mitte */
  .sort-riddle .sort-item-grip::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 21px;
    background: radial-gradient(circle, var(--ltrs-ink-soft) 1.6px, transparent 2px) 0 0 / 7px 7px;
    transform: translate(-50%, -50%);
  }

  /* Fingergerecht: mindestens 44px statt der 38px der Komponente */
  .sort-riddle .sort-move {
    width: 44px;
    height: 44px;
  }
}

.sort-riddle .sort-item-body {
  flex: 1 1 auto;
  min-width: 0;
}

.sort-riddle .sort-placeholder {
  flex: 0 0 auto;
  border: 2px dashed var(--ltrs-paper-edge);
  border-radius: var(--ltrs-radius);
  background: color-mix(in srgb, var(--ltrs-paper) 35%, transparent);
}

/* Optionales Symbol vor dem Wort, abgetrennt wie eine Randnotiz */
.sort-riddle .sort-item-body:has(> .sort-item-symbol) {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sort-riddle .sort-item-symbol {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-right: 14px;
  border-right: 1px dashed var(--ltrs-ink-soft);
}

.sort-riddle .sort-item-symbol img {
  display: block;
  max-width: 96px;
  height: 48px;
  object-fit: contain;
}

/* Woerter linksbuendig wie Zeilen eines Briefs */
.sort-riddle .word-item {
  display: block;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  line-height: 1.45;
  text-align: left;
}

.sort-riddle .image-item {
  width: 150px;
  height: 150px;
}

.sort-riddle .image-item img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--ltrs-radius);
  object-fit: cover;
}

.sort-riddle .sound-item {
  min-width: 250px;
  padding: 0;
  border: 0;
  background: none;
}

.sort-riddle .custom-audio-player {
  margin: 0;
}

.sort-riddle .custom-audio-player audio {
  display: block;
  width: 100%;
  height: 40px;
  margin: 0;
}

.sort-riddle .custom-audio-player audio::-webkit-media-controls-panel {
  background: color-mix(in srgb, var(--ltrs-paper) 70%, #ffffff);
}

/* Pfeile: Alternative zum Ziehen, auch per Tastatur */
.sort-riddle .sort-item-moves {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 6px;
}

.sort-riddle .sort-move {
  font-size: 12px;
  line-height: 1;
}

.sort-riddle .sortable-items.horizontal .sort-item-moves {
  flex-direction: row;
}

/* In der Zeile bedeutet "nach oben" nach links */
.sort-riddle .sortable-items.horizontal .sort-move {
  transform: rotate(-90deg);
}

@media (max-width: 768px) {
  .sort-riddle .sound-item {
    min-width: 0;
    width: 100%;
  }

  .sort-riddle .sortable-items.horizontal .sort-item:has(.sound-item) {
    flex-basis: 100%;
  }
}

/* Handy: die Zeile wird zur Liste - Karten voll breit, Pfeile zeigen wieder
   nach oben und unten. Die Reihenfolge bleibt: links ist jetzt oben. */
@media (max-width: 480px) {
  .sort-riddle .sortable-items.horizontal {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .sort-riddle .sortable-items.horizontal .sort-item {
    flex-direction: row;
    width: 100%;
  }

  .sort-riddle .sortable-items.horizontal .sort-item-moves {
    flex-direction: column;
  }

  .sort-riddle .sortable-items.horizontal .sort-move {
    transform: none;
  }

  .sort-riddle .image-item {
    width: 120px;
    height: 120px;
  }

  .sort-riddle .sort-item-symbol img {
    max-width: 48px;
    height: 36px;
  }

  /* Text bleibt rechts neben dem Bild und bricht dort um */
  .sort-riddle .sort-item-body:has(> .sort-item-symbol) {
    gap: 10px;
  }

  .sort-riddle .sort-item-symbol {
    padding-right: 10px;
  }
}
