/* tag: slice 2 owns this file. Screen 1, "Write your tag". */

.tag-screen { display: flex; flex-direction: column; min-height: calc(100dvh - 136px); }

.tag-head { display: flex; align-items: center; gap: 12px; }
.tag-head__icon { flex: none; display: block; width: 44px; height: 44px; }
.tag-head__name { font-size: 22px; margin-top: 2px; }
.tag-head__count { font-size: 13px; color: var(--soft); }

.tag-msg { margin-top: 90px; text-align: center; font-size: 32px; line-height: 1.2; color: var(--soft); }

/* ---- the tag, and what three taps do to it ---- */

.tag-stagewrap { position: relative; margin: auto -20px; padding: 24px 0 8px 6px; }
.tag-stage { position: relative; transform-origin: 55% 50%; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.tag-stage .tag-input:not([readonly]) { cursor: text; }
.tag-stage .tag-wrap { margin-right: 0; transition: transform 0.28s cubic-bezier(.3,1.4,.5,1), opacity 0.25s ease; }

.tag-screen .tag {
  position: relative;
  padding: 26px 26px 26px 64px;
  transition: clip-path 0.3s ease;
  clip-path: polygon(38px 0, 100% 0, 100% 100%, 38px 100%, 0 50%);
}

.tag-from { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--soft); }

.tag-input {
  display: block; width: 100%; margin-top: 4px; padding: 0 0 2px;
  border: 0; background: transparent; outline: none; border-radius: 0;
  font-family: var(--hand); font-weight: 600; font-size: 56px; line-height: 1.1;
  color: oklch(0.28 0.07 260); /* ink-pen blue, as in the design */
  caret-color: var(--red);
}
.tag-input::placeholder { color: var(--line); opacity: 1; }
.tag-input:focus-visible { outline: none; }
.tag-underline { display: block; border-bottom: 2px dotted oklch(0.6 0.04 60); margin-top: 2px; }
.tag-screen .tag:focus-within .tag-underline { border-bottom-color: var(--red); }

.tag-wrinkles {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.25s ease;
  background:
    linear-gradient(112deg, transparent 38%, oklch(0.5 0.03 60 / 0.22) 39%, transparent 41%),
    linear-gradient(68deg, transparent 52%, oklch(1 0 0 / 0.8) 53%, oklch(0.5 0.03 60 / 0.2) 54%, transparent 56%),
    linear-gradient(160deg, transparent 20%, oklch(0.5 0.03 60 / 0.2) 21%, transparent 23%),
    linear-gradient(20deg, transparent 60%, oklch(0.5 0.03 60 / 0.18) 61%, transparent 63%),
    radial-gradient(ellipse at 30% 40%, oklch(0.5 0.03 60 / 0.12), transparent 55%),
    radial-gradient(ellipse at 75% 65%, oklch(0.5 0.03 60 / 0.14), transparent 50%);
}

/* stage 1: a first scrunch */
.tag-stage[data-stage="1"] .tag-wrap { transform: rotate(-6deg) scale(0.86) skew(-3deg, 2deg); }
.tag-stage[data-stage="1"] .tag { clip-path: polygon(44px 4%, 96% 0, 100% 92%, 40px 100%, 2% 52%); }
.tag-stage[data-stage="1"] .tag-wrinkles { opacity: 0.55; }

/* stage 2: balled up, still a tag if you squint */
.tag-stage[data-stage="2"] .tag-wrap { transform: rotate(14deg) scale(0.58) skew(1deg, -1deg); }
.tag-stage[data-stage="2"] .tag { clip-path: polygon(30% 10%, 88% 6%, 94% 80%, 40% 94%, 8% 50%); }
.tag-stage[data-stage="2"] .tag-wrinkles { opacity: 1; }
.tag-stage[data-stage="2"] .twine { opacity: 0.5; }

/* stage 3: a paper ball */
.tag-ball {
  position: absolute; left: 50%; top: 50%; width: 92px; height: 92px; margin: -46px 0 0 -46px;
  border-radius: 50%; opacity: 0; transform: scale(0.4); pointer-events: none;
  background:
    radial-gradient(circle at 34% 30%, #fff 0 18%, transparent 19%),
    linear-gradient(120deg, transparent 40%, oklch(0.6 0.03 60 / 0.25) 41%, transparent 43%),
    linear-gradient(40deg, transparent 55%, oklch(0.6 0.03 60 / 0.22) 56%, transparent 58%),
    radial-gradient(circle at 36% 32%, #fffdf6, var(--tag) 45%, oklch(0.84 0.03 75) 100%);
  box-shadow: 0 14px 14px -8px oklch(0.3 0.03 50 / 0.45), inset -6px -8px 14px oklch(0.7 0.04 70 / 0.5);
}
.tag-stage[data-stage="3"] .tag-wrap { transform: scale(0.1); opacity: 0; }
.tag-stage[data-stage="3"] .tag-ball { opacity: 1; transform: scale(1); transition: transform 0.3s cubic-bezier(.3,1.5,.5,1), opacity 0.15s ease; }

/* each tap gives it a jolt */
.tag-stage.is-jolt { animation: tag-jolt 0.22s ease-out; }
@keyframes tag-jolt {
  0% { transform: scale(1.04) rotate(-1.5deg); }
  50% { transform: scale(0.96) rotate(1deg); }
  100% { transform: none; }
}

/* ---- controls ---- */

.tag-error { min-height: 20px; margin: 0 0 8px; text-align: center; color: var(--red); font-size: 14px; font-weight: 600; }
.tag-error[hidden] { display: block; visibility: hidden; }
.tag-crumple { font-size: 18px; }
.tag-taps { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; color: var(--soft); }
.tag-dots { display: inline-flex; gap: 5px; }
.tag-dots i { width: 9px; height: 9px; border-radius: 50%; background: oklch(0.8 0.01 70); transition: background 0.2s ease, transform 0.2s ease; }
.tag-dots i.on { background: var(--pine); transform: scale(1.15); }
