/* =====================================================================
   Puzzles — gemeinsamer Rahmen aller Spielseiten (/puzzles/<spiel>),
   Markup aus snippets/puzzles/spiel.php: Kopf mit Titel + Umschalter,
   Buttons, Ergebnis-Karte, Anleitung. Das Spielfeld selbst gehört dem
   jeweiligen Spiel (assets/css/puzzles/<spiel>.css).
   ===================================================================== */

.puzzles-col {
  width: 460px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* JS schaltet Bereiche per hidden-Attribut — gegen display:flex durchsetzen */
.puzzles-spiel [hidden] {
  display: none !important;
}

/* Übungsmodus im Panel ausgeschaltet: alle Übungs-Einstiege verschwinden */
.puzzles-spiel[data-practice="0"] [data-practice-only] {
  display: none !important;
}

.puzzles-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- head ---- */

.puzzles-back {
  display: inline-block;
  margin-top: 40px;
  font-size: 12.5px;
  color: var(--sub);
}

.puzzles-kopf {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.puzzles-kopf__text {
  min-width: 0;
}

.puzzles-kopf h1 {
  font-size: 28px;
  line-height: 1.15;
}

/* reserves its line — the game fills it on load */
.puzzles-kopf__sub {
  margin: 4px 0 0;
  min-height: 1.6em;
  font-size: 14px;
  line-height: 1.6;
  color: var(--sub);
}

.puzzles-noscript {
  margin: 24px 0 0;
  padding: 18px 22px;
  font-size: 14px;
  color: var(--body);
}

/* ---- segmented control (mode tabs, sizes) — as .spiele-seg ---- */

.puzzles-seg {
  display: flex;
  gap: 3px;
  background: var(--panel);
  border-radius: var(--radius-pill);
  padding: 3px;
}

.puzzles-seg__btn {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1.4;
  background: transparent;
  color: var(--sub);
  font-weight: 400;
  touch-action: manipulation;
}

.puzzles-seg__btn[aria-selected="true"],
.puzzles-seg__btn[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
}

/* ---- buttons ---- */

.puzzles-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.puzzles-btn:hover:not(:disabled) {
  box-shadow: 0 2px 6px rgba(60, 40, 20, .12);
}

.puzzles-btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.puzzles-btn:disabled {
  opacity: .4;
  cursor: default;
}

.puzzles-btn:focus-visible,
.puzzles-seg__btn:focus-visible,
.puzzles-anleitung summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- result card ---- */

@keyframes puzzles-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.puzzles-ergebnis {
  margin-top: 26px;
  padding: 22px 24px 24px;
  animation: puzzles-in .3s ease-out;
}

.puzzles-ergebnis h2 {
  font-size: 20px;
  line-height: 1.25;
}

.puzzles-ergebnis p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--body);
  text-wrap: pretty;
}

.puzzles-ergebnis .puzzles-ergebnis__caption {
  color: var(--ink);
  font-weight: 600;
}

.puzzles-ergebnis__caption:empty {
  display: none;
}

/* primary action on its own row, the rest share the next one evenly */
.puzzles-ergebnis__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.puzzles-ergebnis__actions .puzzles-btn {
  flex: 1 1 auto;
  padding: 0 14px;
  white-space: nowrap;
}

.puzzles-ergebnis__actions .puzzles-btn--primary {
  flex-basis: 100%;
}

.puzzles-fallback {
  margin-top: 14px;
}

.puzzles-fallback textarea {
  display: block;
  width: 100%;
  min-height: 170px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
}

/* ---- how to play ---- */

.puzzles-anleitung {
  margin-top: 40px;
  padding: 16px 22px;
}

.puzzles-anleitung summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
}

.puzzles-anleitung summary::-webkit-details-marker {
  display: none;
}

.puzzles-anleitung__caret {
  font-size: 10px;
  color: var(--sub);
  transition: transform .2s ease;
}

.puzzles-anleitung:not([open]) .puzzles-anleitung__caret {
  transform: rotate(-90deg);
}

.puzzles-anleitung__text {
  padding-bottom: 4px;
}

.puzzles-anleitung__text p {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--body);
  text-wrap: pretty;
}

.puzzles-anleitung__text .puzzles-anleitung__tasten {
  font-size: 12.5px;
  color: var(--faint);
}

/* keyboard hints are noise on touch-only devices */
@media (hover: none) and (pointer: coarse) {
  .puzzles-anleitung__tasten {
    display: none;
  }
}

/* ---- responsive ---- */

@media (max-width: 600px) {
  .puzzles-back {
    margin-top: 28px;
  }
}

@media (max-width: 480px) {
  .puzzles-ergebnis {
    padding: 20px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .puzzles-ergebnis {
    animation: none;
  }

  .puzzles-btn,
  .puzzles-anleitung__caret {
    transition: none;
  }
}
