/* Engine `grid` (DESIGN §13.1, §5.9): every selector starts with `.gr-` (state classes `.is-*` allowed). Package D.
   Trg mreža: graph paper and the peg board, the grid pencil and the lastiš, the nacrt card, Nitica's silk and the
   Gradska kuća. Motion is transform / opacity (+ the one-shot draw-in dash offsets); no filters. */

/* ---------------------------------------------------------------- the paper and the pegs */
.gr-paper { fill: #FFFBF1; stroke: #D9CDF2; stroke-width: 3; }
.gr-peg { fill: #B7BFD1; stroke: #24263B; stroke-width: 1.8; }
.gr-peg-sh { fill: rgba(36, 38, 59, .18); }
.gr-peg-hi { fill: #fff; opacity: .8; }

/* ---------------------------------------------------------------- lines: given · Šestarko · the child · accepted */
.gr-ln { stroke-linecap: round; fill: none; }
.gr-ln-pen { stroke: #3B4A6B; }
.gr-ln-given { stroke: #6A38C4; }
.gr-ln-ses { stroke: #F29A2E; }
.gr-ln-fig { stroke: #6A38C4; }
.gr-ln.is-new { stroke-dasharray: var(--len) var(--len); animation: gr-draw .32s ease-out backwards; }
@keyframes gr-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
.gr-ends circle { fill: #3B4A6B; }
.gr-band-o { stroke: #C2457A; stroke-linecap: round; }
.gr-band-i { stroke: #FF8FB8; stroke-linecap: round; }
.gr-band.is-new { animation: gr-twang .42s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes gr-twang { 20% { transform: scale(1.04, .8); } 45% { transform: scale(.98, 1.12); } 70% { transform: scale(1.01, .95); } }
.gr-fill { fill: #ECE2FF; stroke: none; }
.gr-fill.is-band { fill: rgba(236, 106, 156, .2); }
.gr-stray { stroke: #FF9636; stroke-linecap: round; opacity: .45; animation: gr-blink 1s ease-in-out infinite; }
@keyframes gr-blink { 50% { opacity: .15; } }

/* ---------------------------------------------------------------- marks: start dot, glowing points, garden, flower */
.gr-start-glow { fill: rgba(236, 74, 61, .22); animation: gr-breathe 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.gr-start.is-quiet .gr-start-glow, .gr-glowpt.is-quiet .gr-glowpt-halo { animation: none; opacity: .25; }
.gr-glowpt-halo { fill: #FFE27A; opacity: .6; animation: gr-breathe 1.2s ease-in-out infinite; animation-delay: calc(var(--i, 0) * .2s); transform-box: fill-box; transform-origin: center; }
@keyframes gr-breathe { 50% { transform: scale(1.22); opacity: .3; } }
.gr-soil { fill: #E9D2AE; opacity: .75; }
.gr-garden-rim { fill: none; stroke: #A86A38; stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; }
.gr-picket { fill: #F6D9A4; stroke: #8A5A2E; stroke-width: 1.4; }

/* ---------------------------------------------------------------- the eraser, hints, gags */
.gr-xh circle { fill: #FF9DB8; stroke: #24263B; stroke-width: 2.2; }
.gr-xh path { stroke: #24263B; stroke-width: 2.6; stroke-linecap: round; }
.gr-hint-ring { fill: rgba(255, 197, 61, .3); stroke: #F5A300; stroke-width: 4; animation: gr-breathe .9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.gr-hint-run { stroke: #FFC53D; stroke-linecap: round; opacity: .7; animation: gr-blink .9s ease-in-out infinite; }
.gr-hint, .gr-glow { animation: gr-btn-pulse .9s ease-in-out infinite; }
@keyframes gr-btn-pulse { 50% { box-shadow: 0 0 0 8px rgba(255, 197, 61, .55); } }
.gr-snap { animation: gr-snap .5s ease-in forwards; }
.gr-snap .gr-band-o, .gr-snap .gr-ln { stroke: #FF9636; }
@keyframes gr-snap { 30% { opacity: 1; } to { opacity: 0; } }
.gr-fall { animation: gr-fall 1s cubic-bezier(.5, 0, .9, .6) forwards; animation-delay: var(--d, 0s); transform-box: fill-box; transform-origin: center; }
.gr-crumble.is-short .gr-fall { animation-duration: .42s; }
.gr-fall .is-wrong { stroke: #FF9636; }
@keyframes gr-fall { 15% { transform: translateY(-4px) rotate(0); } to { transform: translateY(120px) rotate(var(--r, 20deg)); opacity: 0; } }

/* ---------------------------------------------------------------- the nacrt card */
.gr-card { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 10px 10px; background: #fff; border: 3px solid #24263B; border-radius: 16px; box-shadow: 0 4px 0 #24263B; transform: rotate(-1.5deg); }
.gr-card svg { display: block; border-radius: 6px; }
.gr-card-t { font-weight: 1000; font-size: 16px; line-height: 1.1; color: #2F6FD6; letter-spacing: .06em; text-transform: uppercase; }
.gr-card-paper { fill: #E6F0FF; }
.gr-card-grid { stroke: #BCD3F5; stroke-width: 1.4; fill: none; }
.gr-card-fig { fill: #CFE0FF; stroke: #2F6FD6; stroke-linejoin: round; }
.gr-card-roof { fill: #FFD2C4; }
.gr-card-frame { fill: #fff; stroke: #24263B; stroke-width: 3; }
html[data-layout="short"] .gr-card { padding: 4px 8px 8px; gap: 2px; }

/* ---------------------------------------------------------------- the payoff: Nitica, silk, the Gradska kuća */
.gr-thread { stroke: #9094B3; stroke-width: 1.8; }
.gr-nit-in { animation: gr-nit-in .65s cubic-bezier(.3, 1.4, .5, 1) backwards; }
@keyframes gr-nit-in { from { transform: translateY(-260px); } }
.gr-nit-in.is-up { transition: transform .9s ease-in; transform: translateY(-420px); }
.gr-nit-in.is-swing { animation: gr-swing .5s ease-in-out 3 alternate; transform-box: view-box; transform-origin: 50% 0; }
@keyframes gr-swing { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.gr-silk { fill: none; stroke: #fff; stroke-width: 6; stroke-linejoin: round; stroke-dasharray: var(--len) var(--len); animation: gr-silk 1s linear forwards; }
@keyframes gr-silk { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
.gr-piece-in { animation: gr-fade .5s ease-out backwards; }
@keyframes gr-fade { from { opacity: 0; } }
.gr-piece-line { fill: none; stroke: #24263B; stroke-width: 4; stroke-linejoin: round; }
.gr-fac-panel { animation: gr-rise .65s cubic-bezier(.3, 1.3, .5, 1) backwards; }
@keyframes gr-rise { from { transform: translateY(110%); } }
.gr-fac-slot { fill: #E6F0FF; stroke: #2F6FD6; stroke-width: 2.4; stroke-dasharray: 6 4; }
.gr-slot-new { animation: gr-pop .5s cubic-bezier(.3, 1.6, .5, 1) .55s backwards; transform-box: fill-box; transform-origin: center; }
@keyframes gr-pop { from { transform: scale(.2); opacity: 0; } }
.gr-confetti { animation: gr-confetti 1.1s ease-in forwards; animation-delay: var(--d, 0s); }
@keyframes gr-confetti { from { transform: translateY(0) rotate(0); } to { transform: translateY(var(--y, 300px)) rotate(240deg); opacity: .2; } }
.gr-bird { animation: gr-land .6s cubic-bezier(.3, 1.5, .5, 1) backwards; }
@keyframes gr-land { from { transform: translate(60px, -90px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .gr-start-glow, .gr-glowpt-halo, .gr-hint-ring, .gr-hint-run, .gr-hint, .gr-glow, .gr-stray, .gr-band.is-new { animation: none !important; }
}
html[data-motion="reduce"] :is(.gr-start-glow, .gr-glowpt-halo, .gr-hint-ring, .gr-hint-run, .gr-hint, .gr-glow, .gr-stray, .gr-band.is-new, .gr-ln.is-new) { animation: none !important; }
.gr-fly { transform-origin: 0 0; }
.gr-fly.is-home { animation: gr-bump .3s ease-out; }
@keyframes gr-bump { 50% { opacity: .75; } }
/* Šestarko's figure draws itself in at the start of a „fix Šestarko“ round */
.gr-ln-ses.is-new { animation-duration: 1.1s; animation-timing-function: ease-in-out; }
.gr-fill.is-wait { fill: rgba(23, 165, 101, .14); }
