/* После подтверждения веб-лицензии см. README. */
:root {
  color-scheme: light;
  font-family: "RF Dewi", system-ui, -apple-system, "Segoe UI", sans-serif;
  --background: #fff;
  --ink: #222122;
  --accent: #222122;
  --paw: #222122;
  --decor: #222122;
  --fade: 240ms;
  --intro-background: #000;
  --intro-ink: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--background); }
button, textarea { color: inherit; font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
h1, h2, p { margin: 0; }

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 32px 24px;
  padding: max(32px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.screen {
  grid-area: 1 / 1;
  width: min(100%, 50rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: translateY(7px);
  transition: opacity var(--fade) ease, transform var(--fade) ease;
}

.screen.active { opacity: 1; transform: none; }
.screen:not(.active) { pointer-events: none; }
.paw {
  display: block;
  aspect-ratio: 271.5 / 250.2;
  background: var(--paw);
  -webkit-mask: url("./assets/paw.svg") center / contain no-repeat;
  mask: url("./assets/paw.svg") center / contain no-repeat;
}

body.loading { background: var(--intro-background); }
#intro {
  width: auto;
  position: fixed;
  inset: 0;
  z-index: 1;
  justify-content: center;
  padding: 24px;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  isolation: isolate;
  --fade: var(--intro-exit, 360ms);
  color: var(--intro-ink);
  opacity: 1;
  transform: none;
}
#intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--intro-background);
  transition: opacity var(--fade) ease;
}
#intro:not(.active)::before { opacity: 0; }
.intro-content { display: grid; justify-items: center; gap: 1.45rem; width: min(100%, 38rem); }
.intro-mark {
  transition: transform var(--fade) ease, opacity var(--fade) ease;
  transform: translate(var(--intro-x, 0px), var(--intro-y, 0px));
}
.intro-paw {
  width: clamp(3.1rem, 12vw, 5rem);
  background: var(--intro-ink);
  animation: intro-mark var(--intro-duration, 2800ms) cubic-bezier(.2,.7,.35,1) both;
}
#greeting {
  animation: intro-copy var(--intro-duration, 2800ms) cubic-bezier(.2,.7,.35,1) both;
  transform: translate(var(--copy-x, 0px), var(--copy-y, 0px));
  transition: transform var(--fade) ease, opacity var(--fade) ease;
}
#intro:not(.active) .intro-mark { transform: scale(.18); opacity: 0; }
#intro:not(.active) #greeting { animation: none; transform: translateY(12px) scale(.72); opacity: 0; }
@keyframes intro-mark {
  from { transform: translateY(15px) scale(1.14); opacity: .2; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes intro-copy {
  from { translate: 0 5px; }
  to { translate: 0 0; }
}
#greeting, #problem p { font-size: clamp(1rem, 4vw, 1.35rem); line-height: 1.45; }
.paw-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.9rem, 6vw, 3.3rem);
  padding: 1rem;
  border: 0;
  border-radius: 1.25rem;
  background: transparent;
  font-weight: 500;
  font-size: clamp(2.35rem, 8.4vw, 5.1rem);
  line-height: .98;
  letter-spacing: -.075em;
  touch-action: manipulation;
}

.main-paw {
  width: clamp(9rem, 40vw, 16rem);
  animation: breathe 3.4s ease-in-out infinite;
  transition: transform 150ms ease;
}

@keyframes breathe { 0%, 100% { scale: 1; } 50% { scale: 1.035; } }
@media (hover: hover) { .paw-button:hover .main-paw { transform: rotate(-4deg) scale(1.045); } }
.paw-button:active .main-paw, .paw-button.pressed .main-paw { transform: scale(.88) rotate(4deg); }

.card-paw { width: clamp(2.4rem, 7vw, 3.4rem); margin-bottom: clamp(1.6rem, 5vw, 3rem); }
#wish {
  font-weight: 500;
  font-size: clamp(1.85rem, 6.9vw, 4.15rem);
  line-height: 1.05;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
#wish:focus { outline: none; }
.signature { margin-top: clamp(1.2rem, 4vw, 2rem); font-size: clamp(1rem, 3vw, 1.2rem); }
.share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  color: var(--accent);
  background: none;
  border: 1px solid currentColor;
  border-radius: 999px;
  min-height: 44px;
  padding: .45rem 1rem;
  margin-top: clamp(1.8rem, 5vw, 2.75rem);
  font-size: .9rem;
}
@media (hover: hover) { .share:hover { background: var(--accent); color: var(--background); } }
.load-status { position: absolute; top: 100%; margin-top: .4rem; font-size: .85rem; }
.share-status { margin-top: .6rem; min-height: 1.2em; font-size: .85rem; }
#share-text { width: min(100%, 25rem); min-height: 6rem; margin-top: .5rem; }

#decoration, #confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.particle {
  position: absolute;
  inset-inline-start: var(--x);
  top: -2rem;
  color: var(--decor);
  font-size: var(--size);
  opacity: 0;
  animation: drift var(--duration) var(--delay) linear infinite;
}
@keyframes drift {
  0% { opacity: 0; transform: translate(0, 0); }
  15%, 82% { opacity: var(--particle-opacity, .26); }
  100% { opacity: 0; transform: translate(var(--sway), calc(100vh + 4rem)); }
}
.confetti-piece {
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: var(--piece-width);
  height: var(--piece-height);
  border-radius: 1px;
  background: var(--piece-color);
  animation: confetti-burst var(--burst-time) var(--burst-delay) both;
}
.confetti-piece.round { border-radius: 50%; }
.confetti-piece.star {
  width: var(--piece-height);
  height: var(--piece-height);
  clip-path: polygon(50% 0, 63% 34%, 100% 38%, 72% 63%, 81% 100%, 50% 80%, 19% 100%, 28% 63%, 0 38%, 37% 34%);
}
@keyframes confetti-burst {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0) scale(.15);
    animation-timing-function: cubic-bezier(.12,.72,.24,1);
  }
  8% { opacity: 1; }
  58% {
    opacity: 1;
    transform: translate3d(var(--burst-x), var(--burst-y), 0) rotate(var(--spin)) scale(var(--depth));
    animation-timing-function: ease-in;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--burst-x), var(--drop-y), 0) rotate(calc(var(--spin) + 140deg)) scale(var(--depth));
  }
}
@media (prefers-reduced-motion: reduce) {
  :root { --fade: 0ms; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #decoration, #confetti { display: none; }
}
