/* Perlenzauber — Sticker-Look nach Design-Entwurf (Creme, Violett-Konturen, Fredoka) */

:root {
  --paper: #FFF7EC;
  --card: #FFFFFF;
  --ink: #46325F;
  --ink-border: #46325F;
  --shadow-card: 6px 6px 0 rgba(70, 50, 95, 0.12);
  --red: #FF5A5A;
  --pink: #FF6FA5;
  --pink-deep: #FF5C99;
  --yellow: #FFC93C;
  --orange: #FF8A3D;
  --green: #4CB944;
  --blue: #5BB8F5;
  --teal: #21C0AD;
  --chip-bg: #FFF1D6;
  --chip-hover: #FFE3A8;
  --tip-bg: #E8F6FF;
  --radius: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
}

h1, h2, h3 { font-family: "Fredoka", "Nunito", sans-serif; font-weight: 600; }

main {
  max-width: 660px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ---------- Perlen (Donut mit Papier-Loch) ---------- */

.bead {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: 0 3px 0 rgba(70, 50, 95, 0.15);
}
.bead-r { background: radial-gradient(circle, var(--paper) 0 26%, var(--red) 27% 100%); }
.bead-y { background: radial-gradient(circle, var(--paper) 0 26%, var(--yellow) 27% 100%); }
.bead-g { background: radial-gradient(circle, var(--paper) 0 26%, var(--green) 27% 100%); }
.bead-b { background: radial-gradient(circle, var(--paper) 0 26%, var(--blue) 27% 100%); }
.bead-v { background: radial-gradient(circle, var(--paper) 0 26%, var(--pink) 27% 100%); }

/* ---------- Header ---------- */

.site-header {
  text-align: center;
  padding: 40px 20px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logo-beads {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.logo-beads .bead {
  width: 22px;
  height: 22px;
  animation: bead-drop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.logo-beads .bead:nth-child(even) { margin-top: 8px; }
.logo-beads .bead:nth-child(1) { animation-delay: 0.05s; }
.logo-beads .bead:nth-child(2) { animation-delay: 0.15s; }
.logo-beads .bead:nth-child(3) { animation-delay: 0.25s; }
.logo-beads .bead:nth-child(4) { animation-delay: 0.35s; }
.logo-beads .bead:nth-child(5) { animation-delay: 0.45s; }

@keyframes bead-drop {
  from { transform: translateY(-40px); opacity: 0; }
  to { opacity: 1; }
}

.site-title {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 3.6rem);
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink);
}
.site-title .title-accent { color: var(--pink); }

.site-sub {
  margin: 0 auto;
  max-width: 29em;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
}

/* ---------- Karten / Schritte ---------- */

.step {
  background: var(--card);
  border: 3px solid var(--ink-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-top: 26px;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  font-size: 1.55rem;
}

.step-num {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--ink-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
}
#step-board .step-num { background: radial-gradient(circle, var(--paper) 0 22%, var(--yellow) 23% 100%); }
#step-idea .step-num { background: radial-gradient(circle, var(--paper) 0 22%, var(--blue) 23% 100%); }

/* ---------- Plattenauswahl ---------- */

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.board-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 2.5px solid rgba(70, 50, 95, 0.35);
  border-radius: 18px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  transition: all 0.15s ease;
  min-height: 44px;
}
.board-card:hover { background: var(--chip-hover); }
.board-card:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.board-card.selected {
  background: var(--chip-hover);
  border: 3px solid var(--ink-border);
  box-shadow: 4px 4px 0 rgba(70, 50, 95, 0.2);
  transform: translateY(-2px);
}

.board-card svg { display: block; margin: 0 auto 2px; }
.board-card .board-name {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 1.02rem;
  display: block;
}
.board-card .board-dims {
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.7;
  display: block;
}

.board-note {
  margin: 14px 0 0;
  font-size: 0.92rem;
  font-weight: 700;
  opacity: 0.75;
}

/* ---------- Idee ---------- */

#ideaInput {
  width: 100%;
  border: 3px solid var(--ink-border);
  border-radius: 16px;
  padding: 16px 18px;
  font-family: "Nunito", sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  resize: vertical;
  background: var(--paper);
}
#ideaInput:focus { outline: none; background: #fff; }
#ideaInput::placeholder { color: var(--ink); opacity: 0.45; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.chip {
  border: 2.5px solid var(--ink-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-family: "Nunito", sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  background: var(--chip-bg);
  min-height: 44px;
}
.chip:hover { background: var(--chip-hover); }
.chip:active { transform: translateY(2px); }
.chip:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Zauber-Button ---------- */

.step-go {
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  margin-top: 26px;
}

.btn-magic {
  border: 3px solid var(--ink-border);
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-family: "Fredoka", sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  padding: 18px 30px;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--ink-border);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
  width: 100%;
  max-width: 620px;
}
.btn-magic:hover { background: var(--pink-deep); }
.btn-magic:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink-border); }
.btn-magic:disabled { opacity: 0.55; cursor: wait; }
.btn-magic:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

/* ---------- Laden ---------- */

.loading {
  margin-top: 26px;
  background: var(--card);
  border: 3px solid var(--ink-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  animation: card-pop 0.35s ease-out;
}
.loading[hidden] { display: none; }

.loading p { margin: 0; }
#loadingText {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 1.5rem;
  text-align: center;
}
.loading-hint { font-size: 0.9rem; font-weight: 700; opacity: 0.65; }

.loading-beads { display: flex; justify-content: center; gap: 16px; padding-top: 16px; }
.loading-beads .bead {
  width: 34px;
  height: 34px;
  box-shadow: none;
  animation: bead-bounce 1s ease-in-out infinite;
}
.loading-beads .bead:nth-child(2) { animation-delay: 0.15s; }
.loading-beads .bead:nth-child(3) { animation-delay: 0.3s; }
.loading-beads .bead:nth-child(4) { animation-delay: 0.45s; }
.loading-beads .bead:nth-child(5) { animation-delay: 0.6s; }

@keyframes bead-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

@keyframes card-pop {
  0% { transform: scale(0.5); opacity: 0; }
  75% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

.error-box {
  margin: 20px auto 0;
  max-width: 34em;
  background: #FFE7E8;
  border: 3px solid var(--red);
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 800;
  color: #A62226;
}

/* ---------- Ergebnis ---------- */

.result {
  background: var(--card);
  border: 3px solid var(--ink-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
  margin-top: 26px;
  animation: card-pop 0.4s ease-out;
}

.result-title {
  margin: 0 0 20px;
  font-size: 1.9rem;
  font-weight: 700;
  text-align: center;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.canvas-wrap {
  overflow: auto;
  border: 3px dashed var(--ink-border);
  border-radius: 18px;
  background: var(--paper);
  padding: 16px;
  text-align: center;
}

#patternCanvas {
  max-width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}

.legend-box h3, .editor-box h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 800;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 2.5px solid var(--ink-border);
  border-radius: 999px;
  padding: 8px 14px;
}
.legend .swatch {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink-border);
  position: relative;
}
.legend .swatch::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: var(--paper);
}
.legend .count { opacity: 0.8; }

.legend-total { margin: 12px 0 0; font-weight: 800; font-size: 0.95rem; }

.tip-box {
  background: var(--tip-bg);
  border: 2.5px solid var(--ink-border);
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.5;
}

.editor-hint { margin: 0 0 10px; font-size: 0.88rem; font-weight: 700; opacity: 0.7; }

.paint-palette { display: flex; flex-wrap: wrap; gap: 7px; }

.paint-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid var(--ink-border);
  cursor: pointer;
  position: relative;
  padding: 0;
}
.paint-swatch::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: var(--paper);
}
.paint-swatch.eraser {
  background:
    linear-gradient(45deg, transparent 42%, var(--red) 42%, var(--red) 58%, transparent 58%),
    #fff;
}
.paint-swatch.eraser::after { display: none; }
.paint-swatch.active {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
}
.paint-swatch:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 22px;
}

.btn-primary, .btn-secondary, .btn-tertiary {
  border: 3px solid var(--ink-border);
  border-radius: 999px;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  padding: 14px 26px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink-border);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  color: var(--ink);
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-secondary { background: var(--yellow); }
.btn-tertiary { background: #fff; }
.btn-primary:active, .btn-secondary:active, .btn-tertiary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink-border);
}
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-tertiary:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* ---------- Footer / Kaffee ---------- */

.site-footer {
  max-width: 660px;
  margin: 0 auto;
  padding: 10px 20px 56px;
  text-align: center;
}

.coffee-card {
  background: var(--chip-bg);
  border: 3px solid var(--ink-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  text-align: left;
}
.coffee-emoji { font-size: 2.4rem; }
.coffee-text { flex: 1; min-width: 220px; }
.coffee-text strong {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 1.15rem;
  display: block;
  margin-bottom: 2px;
}
.coffee-text p { margin: 0; font-size: 0.88rem; font-weight: 700; line-height: 1.5; opacity: 0.85; }

.btn-coffee {
  display: inline-block;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  border: 2.5px solid var(--ink-border);
  border-radius: 999px;
  padding: 12px 20px;
  white-space: nowrap;
}
.btn-coffee:hover { background: var(--chip-hover); }
.btn-coffee:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.footer-note {
  margin-top: 26px;
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.55;
  line-height: 1.6;
}

/* ---------- Druck ---------- */

.print-sheet { display: none; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }

  body { background: #fff; }
  .site-header, main, .site-footer { display: none !important; }

  .print-sheet {
    display: block;
    background: #fff;
    color: #000;
  }

  .print-title {
    font-size: 20pt;
    margin: 0 0 2mm;
    text-align: center;
  }
  .print-meta {
    text-align: center;
    font-size: 10pt;
    margin: 0 0 4mm;
    color: #333;
  }
  .print-img {
    display: block;
    margin: 0 auto;
    max-width: 175mm;
    max-height: 185mm;
  }
  .print-legend {
    margin-top: 5mm;
    display: flex;
    flex-wrap: wrap;
    gap: 2mm 6mm;
    justify-content: center;
    font-size: 9pt;
  }
  .print-legend .pl-item { display: flex; align-items: center; gap: 2mm; }
  .print-legend .pl-dot {
    width: 4mm; height: 4mm; border-radius: 50%;
    border: 0.4mm solid #555;
    display: inline-block;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-footer {
    margin-top: 5mm;
    text-align: center;
    font-size: 8pt;
    color: #555;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .site-header { padding-top: 28px; }
  .coffee-card { text-align: center; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-beads .bead, .loading-beads .bead { animation: none; }
  .loading, .result { animation: none; }
  .board-card, .chip, .btn-magic, .btn-primary, .btn-secondary, .btn-tertiary { transition: none; }
}
