/* Kaartpuzzel: home tile, the menu (the maps as option cards, the rounds per tier in level cells), the map screen (the question, the map, the row of pieces, the dots). Shared look
   lives in css/style.css. */

/* ---------- home tile and menu ---------- */
#tile-kaart .tile-art { display: flex; align-items: center; justify-content: center; }
.km-tile-svg { width: 100%; height: 100%; max-width: 104px; display: block; overflow: visible; }
.km-ov { display: inline-flex; width: 170px; height: 110px; }
.km-ov svg { width: 100%; height: 100%; }
/* the maps: option cards (css/style.css) with the pack's own map as the picture */
.km-packs { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: var(--bz-space-1) 0; }
.km-packs .option-card.pic .option-art { height: 64px; }
.km-packs .option-card.pic .option-art > svg { height: 100%; }
@media (max-width: 359px) { .km-packs { grid-template-columns: repeat(2, minmax(0, 1fr)); } } /* "Werelddelen" stays whole */
.km-pack.other {
  display: block;
  min-height: var(--bz-target);
  margin: var(--bz-space-1) auto var(--bz-space-2);
  padding: 0 var(--bz-space-4);
  border: 0;
  background: transparent;
  font: var(--bz-weight-head) var(--bz-text-m) var(--bz-font);
  color: var(--bz-ink-soft);
  text-decoration: underline;
  cursor: pointer;
  touch-action: manipulation;
}
.km-pack.other:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 2px; border-radius: var(--bz-radius-s); }
.km-round { position: relative; }
.km-round .km-kind { position: absolute; top: 5px; left: 6px; width: 16px; height: 16px; color: var(--bz-ink-quiet); }

/* ---------- the map screen ---------- */
.km-hud { gap: 10px; }
.km-hud .btn.icon[hidden] { display: none; }
#kaart-zoom[aria-pressed='true'] { background: var(--primary); color: #fff; }
#km-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: 'ask' 'map' 'tray' 'foot';
  gap: 8px;
  padding: 2px 10px 10px;
}
#km-stage.side {
  grid-template-columns: minmax(0, 1fr) minmax(150px, 30%);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'map ask' 'map tray' 'map foot';
}
.km-ask {
  grid-area: ask;
  margin: 0;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 #d6cff7;
  text-align: center;
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
}
.km-lead { font-size: 1rem; color: var(--ink-soft); }
.km-q { font-size: 1.15rem; color: var(--ink); }
.km-q b { font-size: 1.5rem; color: var(--primary-dark); white-space: nowrap; }
#km-stage.side .km-q b { white-space: normal; }
.km-mapbox {
  grid-area: map;
  position: relative;
  min-height: 120px;
  border-radius: 18px;
  overflow: hidden;
  background: #bfe3f5;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.km-mapbox svg { display: block; position: absolute; inset: 0; }
.km-sea { fill: #bfe3f5; }
.km-bg { fill: #e4e1d8; stroke: #cfcabc; stroke-width: 1; vector-effect: non-scaling-stroke; }
.km-reg {
  fill: #fff6dc;
  fill-rule: evenodd;
  stroke: #6d6597;
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
}
.km-reg.slot { fill: #fffdf6; stroke: #3d3470; stroke-width: 1.6; }
.km-reg.on { stroke: #3d3470; }
/* the puzzle without lines: the empty land shows no borders (and the continents' sea shows nothing) */
[data-kind='puzzle'][data-lines='false'] .km-reg:not(.on) { stroke: #fff6dc; stroke-width: 1.2; }
[data-kind='puzzle'][data-lines='false'] .km-reg.slot { fill: #fff6dc; }
[data-kind='puzzle'][data-lines='false'][data-silhouette='false'] .km-reg:not(.on) { fill: transparent; stroke: none; }
.km-reg.snap { animation: km-snap 0.45s ease-out; }
.km-reg.nope, .km-dot.nope { animation: km-nope 0.45s ease-out; }
.km-reg.glow { fill: #fff27a; animation: km-glow 1.1s ease-in-out infinite alternate; }
@keyframes km-snap { 40% { transform: scale(1.06); } }
@keyframes km-nope { 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }
@keyframes km-glow { from { fill: #fff6a6; } to { fill: #ffd84d; } }
.km-mark { fill: rgba(255, 255, 255, 0.6); stroke: #3d3470; stroke-width: 1.5; stroke-dasharray: 3 2; }
.km-dot { fill: #fff; stroke: #3d3470; stroke-width: 2.4; transform-box: fill-box; transform-origin: center; }
.km-dot.on { fill: #3fb35f; }
.km-dot.glow { fill: #ffd84d; }
.km-ring { fill: none; stroke: #ff8a3d; stroke-width: 3.5; animation: km-ring 1.1s ease-in-out infinite alternate; }
@keyframes km-ring { from { stroke-opacity: 1; } to { stroke-opacity: 0.35; } }
.km-name, .km-sea-name {
  font: 800 12px var(--font);
  text-anchor: middle;
  fill: #2b2370;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}
.km-sea-name { font-style: italic; font-weight: 700; fill: #2d6f96; }
.km-sea-name.glow { fill: #c2410c; font-size: 15px; }
@media (prefers-reduced-motion: reduce) {
  .km-reg.snap, .km-reg.nope, .km-dot.nope, .km-reg.glow, .km-ring, .km-chip.nope { animation: none; }
}

/* the row of pieces */
.km-tray {
  grid-area: tray;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
  min-height: 92px;
}
.km-tray[hidden] { display: none; }
#km-stage.side .km-tray { flex-direction: column; justify-content: flex-start; align-items: center; min-height: 0; overflow: hidden; }
.km-chip {
  flex: none;
  width: 80px;
  height: 88px;
  padding: 6px 4px 4px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 #d6cff7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: grab;
  touch-action: none;
  color: var(--ink);
}
#km-stage.side .km-chip { width: 132px; height: 84px; }
.km-chip svg { width: 64px; height: 50px; flex: none; overflow: visible; }
.km-chip svg path { fill-rule: evenodd; stroke: #3d3470; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.km-chip-name { font: 800 0.72rem/1.05 var(--font); text-align: center; overflow-wrap: anywhere; max-height: 2.2em; overflow: hidden; }
.km-chip.picked { box-shadow: 0 0 0 4px var(--accent), 0 4px 0 #d6cff7; }
.km-chip.lifted { opacity: 0.35; }
.km-chip.nope { animation: km-nope 0.45s ease-out; }
.km-more { align-self: center; font: 900 1.1rem var(--font); color: var(--ink-soft); padding: 0 4px; }
.km-ghost { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; overflow: visible; }
.km-ghost[hidden] { display: none; }
.km-ghost path { fill-rule: evenodd; stroke: #3d3470; stroke-width: 1.6; vector-effect: non-scaling-stroke; opacity: 0.92; }
.km-ghost circle { fill: none; stroke: #ff8a3d; stroke-width: 3; }

.km-foot { grid-area: foot; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.km-count { font-weight: 800; color: var(--ink-soft); }
.km-foot .klok-status { min-height: 1.3em; margin: 0; text-align: center; }

/* short screens: a smaller question */
@media (max-height: 640px) {
  .km-ask { padding: 4px 12px; }
  .km-q { font-size: 1rem; }
  .km-q b { font-size: 1.3rem; }
  #km-stage { gap: 6px; padding-bottom: 6px; }
}

/* sideways phones: the bar on the left (like Klok kijken), the map big, the pieces beside it */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-kaart { flex-direction: row; }
  .km-hud { flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; max-width: 120px; }
  .km-hud .hud-mid { flex: 0; }
  .km-hud .hud-level { white-space: normal; font-size: 0.92rem; }
  .km-hud .btn.icon { width: 54px; height: 54px; }
  #km-stage { padding: 8px 10px 6px 4px; }
  .km-foot .klok-status { font-size: 0.9rem; }
}
