/* Unfold It (js/arcade/unfoldit.js). Every class starts with .uf- */

.uf-wrap { position: relative; display: grid; gap: 8px; width: min(100%, 720px); margin: 0 auto; padding-bottom: 14px; }

/* ---------- HUD ---------- */
.uf-hud { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 14px; font: 700 14px var(--font-ui); color: var(--muted); }
.uf-hud b { color: var(--ink); font-size: 19px; }
.uf-stars { display: inline-flex; gap: 3px; }
.uf-star {
  --f: 0%; width: 24px; height: 24px;
  clip-path: polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 80% 94%, 50% 73%, 20% 94%, 31% 59%, 2% 37%, 38% 36%);
  background: linear-gradient(90deg, var(--sun) var(--f), var(--tile-shadow) var(--f));
}
.uf-star.uf-half { --f: 50%; }
.uf-star.uf-full { --f: 100%; animation: uf-pop 0.45s; }
@keyframes uf-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: none; } }

/* ---------- the question ---------- */
.uf-goal { display: grid; justify-items: center; padding: 8px 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-soft); text-align: center; }
.uf-q { font: 800 22px/1.25 var(--font-read); color: var(--grape-d); }

/* ---------- the solid on the left (on top on a phone), the nets beside it ---------- */
.uf-main { display: grid; gap: 8px; }
.uf-left { display: grid; gap: 6px; align-content: start; }
.uf-stage { position: relative; height: clamp(190px, 30vh, 360px); border-radius: var(--radius); background: color-mix(in srgb, var(--teal) 10%, white); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--teal) 40%, white), var(--shadow-soft); overflow: hidden; }
.uf-area .uf-stage { height: clamp(110px, 15vh, 300px); }
.uf-area { padding-bottom: 64px; }
.uf-solved .uf-stage { box-shadow: inset 0 0 0 4px var(--green-d), var(--shadow-soft); }
.uf-gl { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.uf-flatbox { position: absolute; inset: 0; }
.uf-flat { display: block; width: 100%; height: 100%; }
.uf-drag { display: none; position: absolute; left: 10px; bottom: 6px; font: 700 12px var(--font-ui); color: var(--muted); pointer-events: none; }
.uf-3d .uf-drag { display: block; }
.uf-3d .uf-flatbox { display: none; }
.uf-sf, .uf-ff { fill: var(--sky); stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
.uf-ff.uf-smooth { stroke: var(--sky); stroke-width: 2; }
.uf-ff.uf-bad { fill: var(--rose); }
.uf-open { fill: none; stroke: var(--danger); stroke-width: 12; stroke-linecap: round; }

/* under the stage: turn the flat drawing, go back to the solid, fold the net again */
.uf-tools { display: flex; justify-content: center; gap: 8px; min-height: 44px; }
.uf-tool { padding: 6px 14px; white-space: nowrap; touch-action: manipulation; }
.uf-3d .uf-turn, .uf-folded .uf-turn { display: none; }
#uf-shape, #uf-again { display: none; }
.uf-folded #uf-shape, .uf-folded #uf-again { display: inline-block; }
.uf-area .uf-tools { display: none; }

/* ---------- the nets to choose from ---------- */
.uf-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.uf-choices.uf-n4 { grid-template-columns: repeat(2, 1fr); }
.uf-choice { position: relative; display: grid; place-items: center; min-height: 104px; padding: 8px; border: 0; border-radius: 18px; background: var(--card); box-shadow: 0 5px 0 var(--tile-shadow); cursor: pointer; touch-action: manipulation; }
.uf-n4 .uf-choice { min-height: 96px; }
.uf-choice:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--tile-shadow); }
.uf-net { display: block; width: 100%; height: 88px; }
.uf-n4 .uf-net { height: 80px; }
.uf-nf { fill: var(--sky); stroke: none; }
.uf-nf.uf-smooth { stroke: var(--sky); stroke-width: 2; }
.uf-nl { fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round; }
.uf-choice.uf-wrong { opacity: 0.5; box-shadow: inset 0 0 0 3px var(--rose), 0 5px 0 var(--tile-shadow); cursor: default; }
.uf-choice.uf-wrong .uf-nf { fill: var(--rose); }
.uf-choice.uf-yes { box-shadow: inset 0 0 0 4px var(--green-d), 0 5px 0 var(--tile-shadow); }
.uf-choice.uf-yes .uf-nf { fill: var(--green); }

/* ---------- the unfolded box of the area level ---------- */
.uf-sheet { display: none; padding: 8px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow-soft); }
.uf-area .uf-sheet { display: block; }
.uf-area .uf-choices { display: none; }
.uf-sheet .uf-net { height: auto; max-height: 200px; }
.uf-sheet .uf-nf { fill: color-mix(in srgb, var(--sky) 45%, white); }
.uf-sheet .uf-nl { stroke-width: 5; }
.uf-grid { fill: none; stroke: var(--sky-d); stroke-width: 2; }
.uf-size { font: 800 30px var(--font-ui); fill: var(--ink); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: var(--card); stroke-width: 7px; stroke-linejoin: round; }

.uf-msg { min-height: 44px; margin: 0; display: grid; place-items: center; text-align: center; font: 700 16px/1.35 var(--font-read); color: var(--ink); }

.uf-next { display: none; justify-self: center; min-width: 200px; touch-action: manipulation; }
.uf-solved .uf-next { display: inline-block; }
.uf-pad { display: none; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.uf-area .uf-pad { display: grid; }
.uf-area.uf-solved .uf-key { display: none; }
.uf-entry { grid-column: 1 / -1; justify-self: center; min-width: 96px; padding: 2px 14px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 3px var(--sun), var(--shadow-soft); text-align: center; font: 900 32px/1.2 var(--font-ui); color: var(--grape-d); }
.uf-key { padding: 8px 0; min-width: 0; min-height: 48px; font-size: 22px; touch-action: manipulation; }

.uf-no { animation: uf-no 0.32s; }
@keyframes uf-no { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* iPad: the solid on the left, the nets on the right */
@media (min-width: 700px) {
  .uf-wrap { gap: 12px; }
  .uf-q { font-size: 28px; }
  .uf-msg { font-size: 19px; }
  .uf-main { grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .uf-stage, .uf-area .uf-stage { height: 340px; }
  .uf-choices, .uf-choices.uf-n4 { grid-template-columns: repeat(2, 1fr); }
  .uf-choice, .uf-n4 .uf-choice { min-height: 150px; }
  .uf-net, .uf-n4 .uf-net { height: 130px; }
  .uf-sheet .uf-net { max-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .uf-star.uf-full, .uf-no { animation: none; }
}
