/* PIN screens (unlock and set-a-PIN): lock emblem, greeting, round keys, dots, attempts pips, success moment.
   Tokens come from tokens.css; the generic .shake keyframes live in components.css. */

/* ---- Frame: original key and icon sizes; only the gaps flex with screen height, so the page never scrolls. Extra room on tall phones goes above the block. ---- */
.pin-view, .pin-pad { --pin-key: 76px; --pin-emblem: 76px; --pin-row: clamp(6px, 1.3dvh, 12px); --pin-block: clamp(14px, 2.8dvh, 28px); }
/* The gap under the logo header was 32px, too much on this page only. */
body:has(.pin-view) .app-header { margin-bottom: clamp(8px, 1.1dvh, 14px); }
.pin-view--setup, .pin-view--setup .pin-pad { --pin-key: 60px; --pin-emblem: 56px; }
@media (max-height: 700px) { .pin-view--setup, .pin-view--setup .pin-pad { --pin-key: 56px; --pin-emblem: 52px; } }
.pin-view { position: relative; z-index: 1; text-align: center; display: flex; flex-direction: column; align-items: center; padding-top: clamp(0px, calc((100svh - 780px) / 3), 56px); }
.pin-view > * + * { margin-top: 0; }

/* The PIN screens cannot scroll or rubber-band (not on very short screens, where the bottom keys would be cut off). */
@media (min-height: 600px) { html:has(.pin-view), body:has(.pin-view) { overflow: hidden; overscroll-behavior: none; } }

/* ---- Lock emblem (K3): padlock in a soft ring. On success the shackle lifts and a bloom fills the screen. ---- */
.pin-emblem { position: relative; width: var(--pin-emblem); height: var(--pin-emblem); display: grid; place-items: center; color: var(--accent); margin-bottom: var(--space-4); }
.pin-emblem-ring { position: absolute; inset: 0; border-radius: 50%; background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 30%, transparent); }
.pin-lock { position: relative; width: 34px; height: 34px; overflow: visible; }
.pin-shackle { transform-origin: 8px 11px; transition: transform var(--dur-slow) var(--ease-spring); }
.pin-emblem.open .pin-shackle { transform: translateY(-2px) rotate(-22deg); }
.pin-emblem.open .pin-emblem-ring { animation: pin-ring-pulse var(--dur-slow) var(--ease-out); }
@keyframes pin-ring-pulse { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }
.pin-bloom { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: color-mix(in srgb, var(--accent) 14%, var(--bg)); clip-path: circle(0 at var(--bx, 50%) var(--by, 30%)); animation: pin-bloom 620ms var(--ease-in-out) forwards; }
@keyframes pin-bloom { to { clip-path: circle(150vmax at var(--bx, 50%) var(--by, 30%)); } }

/* ---- Greeting (G1) ---- */
.pin-view h1 { font-size: calc(2.25rem * var(--text-scale)); line-height: 1.1; }
.pin-chip { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; margin-top: var(--space-3); padding: 3px var(--space-3) 3px 3px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-caption); }
.pin-avatar { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font: 600 0.6875rem/1 var(--font-sans); letter-spacing: 0.02em; }
.pin-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-sub { margin: var(--space-3) 0 0; color: var(--text-muted); max-width: 22rem; }

/* ---- Dots (F1): bigger, fill with a spring; green on success, red and shaking on error ---- */
.pin-pad { width: 100%; max-width: 20rem; margin: var(--pin-block) auto 0; }
.pin-dots-wrap { position: relative; }
.pin-dots { display: flex; justify-content: center; gap: 1.35rem; height: 20px; align-items: center; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--text-muted) 70%, transparent); transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-spring); }
.pin-dot.on { background: var(--accent); border-color: var(--accent); transform: scale(1.2); }
.pin-dots.err .pin-dot { background: var(--negative); border-color: var(--negative); transform: scale(1); }
.pin-dots.ok .pin-dot { background: var(--positive); border-color: var(--positive); transform: scale(1.2); }
.pin-dots.busy .pin-dot { background: var(--accent); border-color: var(--accent); animation: dot-wave 0.9s var(--ease-in-out) infinite; }
.pin-dots.busy .pin-dot:nth-child(2) { animation-delay: 0.1s; } .pin-dots.busy .pin-dot:nth-child(3) { animation-delay: 0.2s; } .pin-dots.busy .pin-dot:nth-child(4) { animation-delay: 0.3s; }
@keyframes dot-wave { 0%, 100% { transform: translateY(0) scale(1.2); } 50% { transform: translateY(-6px) scale(1.2); } }

/* ---- Message line, with clear space before the keys ---- */
.pin-msg { min-height: 1.5em; margin: 22px 0 0; font-size: var(--fs-small); color: var(--text-muted); }
.pin-msg--error { color: var(--negative); }
.pin-msg--busy { display: flex; align-items: center; justify-content: center; gap: var(--space-2); color: var(--text); }
.pin-msg--ok { display: flex; align-items: center; justify-content: center; gap: var(--space-2); color: var(--positive); font-weight: 500; }
.pin-check .icon { width: 18px; height: 18px; stroke-width: 2.2; stroke-dasharray: 24; stroke-dashoffset: 24; animation: pin-check-draw var(--dur-base) var(--ease-out) 60ms forwards; }
@keyframes pin-check-draw { to { stroke-dashoffset: 0; } }

/* ---- Attempts pips (F2): five small marks, lost ones go grey-red ---- */
.pin-pips { position: absolute; left: 0; right: 0; top: calc(100% + 6px); display: flex; justify-content: center; align-items: center; gap: 6px; height: 12px; }
.pin-pips[hidden] { display: none; }
.pin-pip { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transition: background var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring); }
.pin-pip.lost { background: color-mix(in srgb, var(--negative) 35%, transparent); transform: scale(0.75); }
.pin-pip.just-lost { animation: pin-pip-pop var(--dur-slow) var(--ease-spring); }
@keyframes pin-pip-pop { 0% { transform: scale(1.7); background: var(--negative); } 100% { transform: scale(0.75); } }

/* ---- Keys (K1): round, borderless, thin numerals, soft tint that blooms on press ---- */
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); justify-items: center; gap: var(--pin-row) var(--space-3); margin-top: clamp(12px, 2dvh, 24px); }
.pin-key { position: relative; isolation: isolate; width: var(--pin-key); height: var(--pin-key); padding: 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: var(--text); font: 300 calc(var(--pin-key) * 0.46)/1 var(--font-sans); font-variant-numeric: tabular-nums; cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; transition: transform var(--dur-base) var(--ease-spring), opacity var(--dur-base) var(--ease-out); }
.pin-key::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 50%; background: var(--accent-soft); opacity: 0; transform: scale(0.55); transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out); }
.pin-key:active { transform: scale(0.94); transition-duration: var(--dur-instant); }
.pin-key:active::after { opacity: 1; transform: scale(1); transition-duration: var(--dur-instant), 200ms; }
@media (hover: hover) { .pin-key:hover::after { opacity: 0.6; transform: scale(1); } }
.pin-key:focus-visible { outline: 2px solid var(--focus-ring, var(--accent)); outline-offset: 2px; }
.pin-key .icon { width: 28px; height: 28px; stroke-width: 1.4; color: var(--text-muted); }
.pin-key--del.is-idle { opacity: 0.3; }
.pin-key--text { width: var(--pin-key); font: 500 var(--fs-caption)/1.2 var(--font-sans); color: var(--accent); text-align: center; }
.pin-keys-gap { width: var(--pin-key); height: var(--pin-key); }

/* ---- Footer text on the PIN screens ---- */
.pin-view .hint { max-width: 22rem; margin: var(--pin-block) auto 0; font-size: var(--fs-caption); line-height: 1.35; }
.pin-view .link-btn { margin-top: 0; min-height: 36px; padding: 0; }

@media (max-height: 700px) { .pin-view, .pin-pad { --pin-key: 64px; --pin-emblem: 60px; } .pin-view .hint { margin-top: 4px; font-size: 0.75rem; } .pin-view .link-btn { min-height: 32px; } }

@media (prefers-reduced-motion: reduce) {
  .pin-bloom { display: none; }
  .pin-check .icon { animation: none; stroke-dashoffset: 0; }
  .pin-pip.just-lost { animation: none; }
}
