/* Kralenketting (Bead Patterns): home tile, the tier pictures, the string of beads with its empty
   place, the tray of beads to drag, the copy that follows the finger, the dots of the round. Shared
   look lives in css/style.css; the HUD is Dogudoku's. */

/* ---------- home tile and menu ---------- */
#tile-kralen .tile-art { display: flex; align-items: center; justify-content: center; }
.kr-tile-svg { width: 100%; height: 100%; max-width: 116px; display: block; }
.kr-tier-art { display: flex; justify-content: center; margin: 0 0 var(--bz-space-2); }
.kr-mini-svg { width: min(100%, 260px); height: auto; display: block; }
.kr-how-svg { width: min(100%, 300px); height: auto; display: block; margin: 0 auto; }
.kr-num { font-family: var(--bz-font); }

/* ---------- a round ---------- */
#kr-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 8px 12px;
}
.kr-top { flex: none; width: min(100%, 640px); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.kr-status {
  margin: 0;
  min-height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: var(--bz-text-m);
  font-weight: var(--bz-weight-head);
  line-height: 1.25;
  color: var(--bz-ink);
  text-wrap: balance;
}
.kr-status.said { color: var(--bz-group-ink); }
.kr-dots { display: flex; gap: 6px; margin: 0; }
.kr-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--bz-group-acc); }
.kr-dots i.on { background: var(--bz-group-acc); }
.kr-dots i.now:not(.on) { box-shadow: 0 0 0 3px var(--bz-group-tint); }
/* Pip, the little bird beside the line (decoration: the line says everything; aria-hidden) */
.kr-chat { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.kr-chat .kr-status { flex: 0 1 auto; min-width: 0; }
.kr-bird { flex: none; width: 64px; height: 64px; transform-origin: 50% 100%; }
.kr-bird-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.kr-bird-wing { transform-origin: 0 0; }
.kr-bird.hop { animation: kr-hop 0.55s ease 1; }
.kr-bird.hop .kr-bird-wing { animation: kr-clap 0.18s ease-in-out 3; } /* three claps inside the hop */
.kr-bird.tilt .kr-bird-svg { animation: kr-tilt 0.9s ease 1; transform-origin: 50% 90%; }
.kr-bird.party .kr-bird-svg { animation: kr-dance 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
.kr-bird.party .kr-bird-wing { animation: kr-clap 0.6s ease-in-out infinite; }
.kr-bird .kr-bird-sparkles { animation: kr-twinkle 1.2s ease-in-out infinite; }
@keyframes kr-hop { 0%, 100% { transform: translateY(0) scale(1); } 30% { transform: translateY(2px) scale(1.05, 0.93); } 60% { transform: translateY(-10px) scale(0.97, 1.04); } }
@keyframes kr-clap { 50% { transform: rotate(14deg); } }
@keyframes kr-tilt { 0%, 100% { transform: rotate(0); } 30%, 70% { transform: rotate(-12deg); } }
@keyframes kr-dance { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes kr-twinkle { 50% { opacity: 0.4; } }
.ov-art .kr-ov-end { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ov-art .kr-ov-stars { display: flex; gap: 6px; }
.ov-art .kr-ov-bird { width: 88px; height: 88px; }

#kr-stringbox {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: 360px;
  width: min(100%, 760px);
  border-radius: var(--bz-radius-l);
  background: var(--bz-surface);
  box-shadow: var(--bz-shadow-s);
  overflow: hidden;
  position: relative;
}
#kr-string { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
#kr-string .kr-gap { animation: kr-pulse 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
#kr-string.filled .kr-found { animation: kr-pop 0.45s ease-out; transform-box: fill-box; transform-origin: center; }
#kr-string.filled .kr-bead { animation: kr-bob 0.7s ease-in-out; transform-box: fill-box; transform-origin: center; }
@keyframes kr-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes kr-pop { from { transform: scale(0.4); } 70% { transform: scale(1.12); } to { transform: scale(1); } }
@keyframes kr-bob { 40% { transform: translateY(-6px); } }

.kr-tray { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: min(100%, 640px); }
.kr-opt {
  width: 84px;
  height: 84px;
  padding: 6px;
  border: 0;
  border-radius: var(--bz-radius-l);
  background: var(--bz-surface);
  box-shadow: var(--bz-edge-s) var(--bz-brand-edge), var(--bz-shadow-s);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.kr-opt svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.kr-opt:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 3px; }
.kr-opt.tried { opacity: 0.35; box-shadow: none; cursor: default; }
.kr-opt.lifted { opacity: 0.3; }
.kr-opt.used { visibility: hidden; }
.kr-opt.glow { box-shadow: 0 0 0 4px var(--bz-group-acc), var(--bz-shadow-s); animation: kr-glow 1.4s ease-in-out infinite; }
.kr-opt.bounce { animation: kr-roll 0.5s ease-out; }
@keyframes kr-glow { 50% { box-shadow: 0 0 0 8px var(--bz-group-tint), var(--bz-shadow-s); } }
@keyframes kr-roll { 30% { transform: translateX(-8px) rotate(-12deg); } 60% { transform: translateX(6px) rotate(8deg); } }
.kr-drag { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; filter: drop-shadow(0 8px 10px rgba(40, 36, 92, 0.3)); }
.kr-drag svg { width: 100%; height: 100%; display: block; }

@media (prefers-reduced-motion: reduce) {
  #kr-string .kr-gap, #kr-string.filled .kr-found, #kr-string.filled .kr-bead, .kr-opt.glow, .kr-opt.bounce { animation: none; }
  .kr-bird.hop, .kr-bird.hop .kr-bird-wing, .kr-bird.tilt .kr-bird-svg, .kr-bird.party .kr-bird-svg, .kr-bird.party .kr-bird-wing, .kr-bird .kr-bird-sparkles { animation: none; }
}

/* short sideways phones: the string over the width, the tray in a row under it */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-kralen { flex-direction: row; }
  #kr-stage { padding: 4px 8px 6px 0; gap: 4px; }
  .kr-top { flex-direction: row; justify-content: space-between; }
  .kr-status { min-height: 0; }
  #kr-stringbox { min-height: 90px; }
  .kr-opt { width: 70px; height: 70px; }
  .kr-bird { width: 46px; height: 46px; }
  /* the end card: Pip beside the stars, so the buttons stay in sight */
  .ov-art .kr-ov-end { flex-direction: row; gap: 8px; }
  .ov-art .kr-ov-bird { width: 56px; height: 56px; }
}

/* short upright phones (320x568): Pip a little smaller, so the string keeps its room */
@media (orientation: portrait) and (max-height: 620px) {
  .kr-bird { width: 48px; height: 48px; }
  .ov-art .kr-ov-bird { width: 64px; height: 64px; }
}

/* very short sideways phones (568x320): Pip on the end card no taller than the stars, so the card
   needs no more room than without it */
@media (orientation: landscape) and (max-height: 360px) {
  .ov-art .kr-ov-bird { width: 44px; height: 44px; }
}
