/* Engine `units` (DESIGN §13.1): every selector starts with `.un-` (state classes `.is-*` allowed). Package F.
   The Pilana place-value workshop: the tray of pieces (kockica mango, štapić teal, metar violet), the strip and its
   „n cm“ tag, the folding metar, the real things, the tree house of `compare`. The drawings are in local units under
   a matrix, so every shape keeps a screen-px ink line (vector-effect). Motion is transform / opacity only. */

/* ---------------------------------------------------------------- drawings */
.un-art * { vector-effect: non-scaling-stroke; }
.un-w { transform-box: fill-box; transform-origin: center; }
.un-tagbg { fill: #FFFBF1; stroke: #24263B; stroke-width: 2.6; }
.un-tag.is-cm .un-tagbg { fill: #FFF1C9; stroke: #D98A00; }
.un-tag.is-target .un-tagbg { fill: #FFE3DF; stroke: #EC4A3D; }
.un-tag.is-count .un-tagbg { fill: #FFF3C4; stroke: #F5A300; }
.un-tagtext { font-weight: 900; fill: #24263B; }
.un-sketchtext { font-weight: 900; fill: #2F6FD6; paint-order: stroke; stroke: #FFF4DF; stroke-width: 5px; stroke-linejoin: round; }
.un-mlabel, .un-rooftext, .un-tracknum, .un-trackunit, .un-revealtext { font-weight: 900; fill: #24263B; paint-order: stroke; stroke: #FFFBF1; stroke-width: 5px; stroke-linejoin: round; }
.un-trackunit { fill: #5B6578; }
.un-revealtext { fill: #24263B; }
.un-ico-u { font: 900 15px/1 var(--font, Nunito, sans-serif); fill: #24263B; }

/* ---------------------------------------------------------------- pieces and the strip */
.un-piece.is-new { animation: un-drop .32s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes un-drop { from { transform: translateY(-14px) scale(1.08); opacity: .4; } }
.un-piece.is-wrong .un-art > * { opacity: .95; }
.un-piece.is-wrong { animation: un-wobble .32s ease-in-out 2; }
.un-piece.is-fall { transition: transform .4s ease-in, opacity .4s ease-in; transform: translateY(46px) rotate(14deg); opacity: 0; }
.un-overpart { fill: rgba(255, 150, 54, .42); stroke: #FF9636; stroke-width: 3; }
@keyframes un-wobble { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.un-fuse { fill: rgba(255, 255, 255, .55); stroke: #19B5C8; stroke-width: 5; animation: un-flash .85s ease-out forwards; }
@keyframes un-flash { from { opacity: 1; transform: scale(1.06); } to { opacity: 0; } }
.un-thing.is-shake, .un-real.is-shake, .un-piece.is-shake, .un-seg.is-shake { animation: un-shake .38s ease-in-out 2; }
@keyframes un-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------------------------------------------------------------- the metar */
.un-seg.is-open { animation: un-open .38s cubic-bezier(.3, 1.4, .5, 1); transform-origin: left center; }
@keyframes un-open { from { transform: scaleX(.2) rotate(-25deg); opacity: .3; } }
.un-bundle { cursor: pointer; }
.un-prevseg { fill: rgba(25, 181, 200, .25); stroke: #19B5C8; stroke-width: 2.4; stroke-dasharray: 6 4; }
.un-zoomsel { animation: un-breathe .9s ease-in-out infinite; }
.un-flag.is-in { animation: un-plant .35s cubic-bezier(.3, 1.5, .5, 1); }
.un-flag.is-lifted { opacity: .75; }
@keyframes un-plant { from { transform: translateY(-12px); } }

/* ---------------------------------------------------------------- the tray */
.un-cell { cursor: grab; }
.un-cell.un-cell-pop { cursor: pointer; background: #F2F4F8; }
.un-cell.is-off { opacity: .4; }
.un-cell.is-lifted { opacity: .5; }
.un-cell.is-kbd { box-shadow: 0 0 0 4px #FFC53D, var(--shadow-sm, 0 3px 0 #24263B); }
.un-cell.is-hint { animation: un-cellpulse .9s ease-in-out infinite; }
@keyframes un-cellpulse { 50% { box-shadow: 0 0 0 7px rgba(255, 197, 61, .6); } }
.un-tray.is-boards { grid-template-columns: repeat(3, 84px); }
html[data-layout="short"] .un-tray.is-boards { grid-template-columns: repeat(3, 70px); }
html[data-layout="tall"] .un-tray.is-boards { grid-template-columns: repeat(3, 84px); }
.un-boardcell { overflow: hidden; }
.un-boardcell > .un-plank { position: absolute; inset: 4px 3px; width: calc(100% - 6px); height: calc(100% - 8px); }
.un-boardlbl { position: relative; font: 900 18px/1 var(--font, Nunito, sans-serif); color: #24263B; white-space: nowrap; letter-spacing: -.2px; }
html[data-layout="short"] .un-boardlbl { font-size: 17px; }
.un-drag, .un-drag-live { pointer-events: none; }
.un-drag { opacity: .95; }

/* ---------------------------------------------------------------- compare */
.un-zones { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.un-zone { position: absolute; border-radius: 10px; }
.un-zone.is-hint { box-shadow: 0 0 0 4px rgba(255, 197, 61, .9); }
.un-roof.is-new { animation: un-drop .35s cubic-bezier(.3, 1.5, .5, 1); }
.un-roof.is-wrong { animation: un-wobble .3s ease-in-out 3; }
.un-tok-nest { animation: un-bob 2.6s ease-in-out infinite; }
@keyframes un-bob { 50% { transform: translateY(-3px); } }

/* ---------------------------------------------------------------- hints */
.un-hintring { fill: rgba(255, 197, 61, .3); stroke: #F5A300; stroke-width: 4; animation: un-breathe .9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.un-nextslot { fill: rgba(255, 197, 61, .35); stroke: #F5A300; stroke-width: 3; stroke-dasharray: 6 4; animation: un-blink .9s ease-in-out infinite; }
.un-hintbtn { animation: un-btnpulse .9s ease-in-out infinite; }
@keyframes un-btnpulse { 50% { box-shadow: 0 0 0 8px rgba(255, 197, 61, .55); } }
@keyframes un-breathe { 50% { transform: scale(1.18); opacity: .55; } }
@keyframes un-blink { 50% { opacity: .45; } }

/* ---------------------------------------------------------------- payoffs */
.un-print, .un-hop { animation: un-pop .3s cubic-bezier(.3, 1.5, .5, 1); }
.un-cmcount circle { fill: #FFC53D; stroke: #24263B; stroke-width: 2.4; }
.un-cmcount text { font-weight: 900; font-size: 17px; fill: #24263B; }
.un-cmcount { animation: un-pop .35s cubic-bezier(.3, 1.5, .5, 1); transform-box: fill-box; transform-origin: center; }
.un-tumble { animation: un-tumble .6s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(var(--i) * 0.07s); transform-box: fill-box; transform-origin: center; }
@keyframes un-tumble { from { opacity: 0; transform: translateY(-60px) rotate(140deg); } }
.un-rung { animation: un-pop .3s cubic-bezier(.3, 1.5, .5, 1); }
.un-tri { animation: un-fold .7s cubic-bezier(.3, 1.3, .5, 1); transform-box: fill-box; transform-origin: center; }
@keyframes un-fold { from { transform: scaleY(.1) rotate(-30deg); opacity: 0; } }
.un-tok-hop { animation: un-bob .45s ease-in-out infinite; }
@keyframes un-pop { from { transform: scale(.3); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .un-hintring, .un-nextslot, .un-hintbtn, .un-cell.is-hint, .un-zoomsel, .un-tok-nest, .un-tok-hop, .un-tumble, .un-tri, .un-seg.is-open { animation: none !important; }
}
[data-motion="reduce"] .un-hintring, [data-motion="reduce"] .un-nextslot, [data-motion="reduce"] .un-tok-nest, [data-motion="reduce"] .un-tok-hop, [data-motion="reduce"] .un-tumble, [data-motion="reduce"] .un-tri { animation: none !important; }
