/* A state drawn (kit/stateplate.js; 15.2711, 21.11: «графически оформленные интерфейсы… должны быть анимированными»):
   an island with the state's colour washed from its emblem in rings; the emblem a ring round a disc - the ring's arc in
   the state's gradient, its track the same colour faint; a live term breathes and sends waves. Beside it the title and
   one sentence; a narrow island stacks them centred. */
.sp-plate {
  --sp-tone: var(--ink3); --sp-tone-2: var(--ink3); --sp-weak: var(--a-100); --sp-ink: var(--ink2);
  --sp-art: 160px; --sp-pad: var(--sp-300);
  position: relative; isolation: isolate; overflow: clip; container-type: inline-size;
  border-radius: var(--r-l); background: var(--card);
}
.sp-good   { --sp-tone: var(--good);   --sp-tone-2: color-mix(in srgb, var(--good) 70%, var(--ink));
             --sp-weak: var(--good-weak);   --sp-ink: var(--good-ink); }
.sp-warn   { --sp-tone: var(--warn);   --sp-tone-2: color-mix(in srgb, var(--warn) 55%, var(--danger));
             --sp-weak: var(--warn-weak);   --sp-ink: var(--warn-ink); }
.sp-danger { --sp-tone: var(--danger); --sp-tone-2: color-mix(in srgb, var(--danger) 65%, var(--warn));
             --sp-weak: var(--danger-weak); --sp-ink: var(--danger-ink); }

.sp-body {
  --sp-cx: calc(var(--sp-pad) + var(--sp-art) / 2); --sp-cy: 50%;
  position: relative; display: grid; grid-template-columns: var(--sp-art) minmax(0, 1fr); align-items: center;
  gap: var(--sp-300); padding: var(--sp-pad) var(--sp-400) var(--sp-pad) var(--sp-pad);
}
/* the wash: the state's colour from the emblem, and rings running out of it and fading */
.sp-body::before, .sp-body::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.sp-body::before {
  background: radial-gradient(circle at var(--sp-cx) var(--sp-cy), color-mix(in srgb, var(--sp-tone) 16%, transparent),
                              transparent calc(var(--sp-art) * 1.5));
}
.sp-body::after {
  background: repeating-radial-gradient(circle at var(--sp-cx) var(--sp-cy), transparent 0 23px,
                                        color-mix(in srgb, var(--sp-tone) 16%, transparent) 23px 24px);
  -webkit-mask: radial-gradient(circle at var(--sp-cx) var(--sp-cy), transparent calc(var(--sp-art) * .5),
                                #000 calc(var(--sp-art) * .56), transparent calc(var(--sp-art) * 1.9)); /* own colour: a mask's alpha, never painted */
          mask: radial-gradient(circle at var(--sp-cx) var(--sp-cy), transparent calc(var(--sp-art) * .5),
                                #000 calc(var(--sp-art) * .56), transparent calc(var(--sp-art) * 1.9)); /* own colour: a mask's alpha, never painted */
}
.sp-plain .sp-body::before, .sp-plain .sp-body::after { opacity: .6; }

.sp-art { position: relative; display: grid; place-items: center; width: var(--sp-art); aspect-ratio: 1; }
.sp-art > * { grid-area: 1 / 1; }
.sp-ring { width: 100%; height: 100%; overflow: visible; }
.sp-track { fill: none; stroke: color-mix(in srgb, var(--sp-tone) 18%, transparent); stroke-width: 8; }
.sp-arc {
  fill: none; stroke-width: 8; stroke-linecap: round; stroke-dasharray: 100 100;
  filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--sp-tone) 45%, transparent));
  transition: stroke-dashoffset 1.1s var(--ease-out) calc(.14s + var(--sp-since, 0ms));
}
.sp-stop-a { stop-color: var(--sp-tone); }
.sp-stop-b { stop-color: var(--sp-tone-2); }
.sp-tick { stroke: color-mix(in srgb, var(--sp-tone) 55%, var(--ink3)); stroke-width: 1.5; stroke-linecap: round; opacity: .55; }

.sp-halo {
  width: 92%; aspect-ratio: 1; border-radius: var(--r-full);
  background: radial-gradient(circle, color-mix(in srgb, var(--sp-tone) 30%, transparent) 35%, transparent 70%);
}
.sp-waves { position: relative; width: 100%; aspect-ratio: 1; }
.sp-waves > i {
  position: absolute; inset: 11%; border-radius: var(--r-full); opacity: 0;
  border: 1.5px solid color-mix(in srgb, var(--sp-tone) 60%, transparent);
}
.sp-disc {
  display: grid; place-items: center; width: 68%; aspect-ratio: 1; border-radius: var(--r-full);
  background: radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--sp-weak) 55%, var(--card)), var(--sp-weak) 70%);
  color: var(--sp-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sp-tone) 22%, transparent),
              0 8px 20px -10px color-mix(in srgb, var(--sp-tone) 60%, transparent);
}
.sp-middle { display: grid; justify-items: center; gap: var(--sp-025); text-align: center; }
.sp-time { display: flex; align-items: baseline; gap: 3px; white-space: nowrap; color: var(--ink); }
.sp-time > b { font-size: var(--fs-num-s); line-height: 1; font-weight: var(--fw-semi); letter-spacing: -.01em; }
.sp-time > i { font-size: var(--fs-s); line-height: 1; font-style: normal; color: var(--ink2); margin-right: 2px; }
.sp-time > i:last-child { margin-right: 0; }
.sp-time-label { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--sp-ink); }

.sp-words { min-width: 0; }
.sp-title { margin: 0; font-size: var(--fs-h); line-height: 1.3; font-weight: var(--fw-semi); color: var(--ink);
            text-wrap: balance; }
.sp-sub { margin: var(--sp-100) 0 0; max-width: 60ch; font-size: var(--fs); line-height: var(--lh); color: var(--ink2);
          text-wrap: pretty; }

/* a narrow island: the emblem over the words, both centred */
@container (max-width: 30rem) {
  .sp-body { --sp-cx: 50%; --sp-cy: calc(var(--sp-pad) + var(--sp-art) / 2);
             grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center;
             gap: var(--sp-200); padding: var(--sp-pad) var(--sp-200); }
  .sp-sub { margin-inline: auto; }
}

/* motion: the plate rises, the halo opens, the disc pops, the ticks come round, the arc fills, the words follow; a plate
   drawn again while it comes in goes on from where it was (--sp-since, negative) */
.sp-plate:not(.sp-settled) { animation: sp-rise var(--dur-reveal) var(--ease-out) var(--sp-since, 0ms) both; }
.sp-plate:not(.sp-settled) .sp-halo { animation: sp-open .8s var(--ease-out) var(--sp-since, 0ms) both; }
.sp-plate:not(.sp-settled) .sp-disc { animation: sp-pop .56s var(--ease-out) calc(.06s + var(--sp-since, 0ms)) both; }
.sp-plate:not(.sp-settled) .sp-middle { animation: sp-fade .3s var(--ease-out) calc(.28s + var(--sp-since, 0ms)) both; }
.sp-plate:not(.sp-settled) .sp-tick { animation: sp-tick-in .3s var(--ease-out) both;
                                      animation-delay: calc(.2s + var(--i) * 40ms + var(--sp-since, 0ms)); }
.sp-plate:not(.sp-settled) .sp-title { animation: sp-rise var(--dur-reveal) var(--ease-out) calc(.1s + var(--sp-since, 0ms)) both; }
.sp-plate:not(.sp-settled) .sp-sub { animation: sp-rise var(--dur-reveal) var(--ease-out) calc(.17s + var(--sp-since, 0ms)) both; }
/* a live term: the halo breathes, waves run out of the ring */
.sp-live .sp-halo { animation: sp-breathe 3.2s ease-in-out infinite alternate; }
.sp-live:not(.sp-settled) .sp-halo { animation: sp-open .8s var(--ease-out) var(--sp-since, 0ms) both,
                                     sp-breathe 3.2s ease-in-out calc(.8s + var(--sp-since, 0ms)) infinite alternate; }
.sp-live .sp-waves > i { animation: sp-wave 3.6s var(--ease-out) infinite; }
.sp-live .sp-waves > i:nth-child(2) { animation-delay: 1.2s; }
.sp-live .sp-waves > i:nth-child(3) { animation-delay: 2.4s; }
/* the state leaves: the arc runs back, the halo and waves go out, the disc sinks */
.sp-draining .sp-arc { opacity: 0; transition: stroke-dashoffset .5s cubic-bezier(.4, 0, .7, .2), opacity .08s linear .46s; }
.sp-draining .sp-halo, .sp-draining .sp-waves { animation: sp-out .4s ease-in both; }
.sp-draining .sp-disc { animation: sp-sink .5s ease-in both; }

@keyframes sp-rise { from { opacity: 0; transform: translateY(var(--sp-150)); } }
@keyframes sp-fade { from { opacity: 0; } }
@keyframes sp-open { from { opacity: 0; transform: scale(.5); } }
@keyframes sp-pop { 0% { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: scale(1.06); } 100% { transform: none; } }
@keyframes sp-tick-in { from { opacity: 0; } }
@keyframes sp-breathe { from { opacity: .7; transform: scale(.94); } to { opacity: 1; transform: scale(1.04); } }
@keyframes sp-wave { 0% { opacity: .6; transform: scale(.86); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes sp-out { to { opacity: 0; } }
@keyframes sp-sink { to { opacity: .75; transform: scale(.92); } }

/* calm motion and reduced motion: the plate stands as it is (above every motion rule here, whatever their weight) */
html[data-motion="calm"] :is(.sp-plate, .sp-plate *) { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { :is(.sp-plate, .sp-plate *) { animation: none !important; transition: none !important; } }
