:root {
  --bg: #fafafa;
  --ink: #0a0a0a;
  --paper: #ffffff;
  --line: #dedad2;
  --muted: rgba(10, 10, 10, 0.5);
  --shadow: rgba(10, 10, 10, 0.14);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
}

/* ---------- stage & ambient background ---------- */

.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bg-grid {
  position: absolute;
  inset: -30px;
  background-image: radial-gradient(rgba(10, 10, 10, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  animation: driftGrid 60s linear infinite;
  pointer-events: none;
}

@keyframes driftGrid {
  from { background-position: 0 0; }
  to { background-position: 280px 280px; }
}

.scene {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: clamp(1rem, 4vw, 3rem);
  padding: clamp(0.75rem, 4vh, 2rem);
}

/* ---------- card ---------- */

.card {
  position: relative;
  width: min(360px, 86vw);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(1.35rem, 4vh, 2.5rem) clamp(1.35rem, 4vw, 2.25rem);
  box-shadow: 0 30px 60px -25px var(--shadow);
  opacity: 0;
  transform: translateY(18px);
  animation: riseIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s forwards;
  overflow: hidden;
}

@keyframes riseIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card.shake { animation: shake 0.45s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

h1 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: clamp(1.1rem, 3vh, 1.75rem);
}

/* ---------- fields ---------- */

.field {
  position: relative;
  margin-bottom: 1.3rem;
}

.field input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  padding: 0.5rem 0;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  outline: none;
}

.field label {
  position: absolute;
  left: 0;
  top: 0.5rem;
  color: var(--muted);
  font-size: 1rem;
  pointer-events: none;
  transition: transform 0.2s ease, font-size 0.2s ease, color 0.2s ease;
  transform-origin: left top;
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  transform: translateY(-1.15rem);
  font-size: 0.72rem;
  color: var(--ink);
}

.field .underline {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1.5px;
  width: 0;
  background: var(--ink);
  transition: width 0.25s ease;
}

.field input:focus ~ .underline {
  width: 100%;
}

/* ---------- button & feedback ---------- */

button[type="submit"] {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.85rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

button[type="submit"]:hover { opacity: 0.88; }
button[type="submit"]:active { transform: scale(0.97); }

.feedback {
  min-height: 1.1rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.feedback:not(:empty) { opacity: 1; }

/* ---------- success state ---------- */

.card-success {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--paper);
  border-radius: 18px;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.card.is-success .card-face {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.card.is-success .card-success {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.card-success p {
  font-weight: 600;
  font-size: 0.95rem;
}

.check-circle {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-dasharray: 145;
  stroke-dashoffset: 145;
}

.check-mark {
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
}

.card.is-success .check-circle {
  animation: drawCircle 0.5s ease forwards;
}
.card.is-success .check-mark {
  animation: drawCheck 0.3s ease 0.4s forwards;
}

@keyframes drawCircle { to { stroke-dashoffset: 0; } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

/* ---------- post-it ---------- */

.postit {
  position: relative;
  width: min(190px, 40vw);
  background: var(--bg);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--bg) 0 27px,
    var(--line) 27px 28px
  );
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.25rem 1.1rem 1.5rem;
  box-shadow: 0 20px 40px -22px var(--shadow), 0 2px 0 var(--line);
  opacity: 0;
  transform: rotate(-4deg);
  animation: postitIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.45s forwards,
    sway 6s ease-in-out 1.1s infinite;
}

@keyframes postitIn {
  from {
    opacity: 0;
    transform: rotate(-9deg) translateY(14px);
  }
  to {
    opacity: 1;
    transform: rotate(-4deg) translateY(0);
  }
}

@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(-2deg); }
}

.postit::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 16px 16px;
  border-color: transparent transparent var(--paper) transparent;
  filter: drop-shadow(-1px -1px 1px var(--shadow));
}

.tape {
  position: absolute;
  top: -13px;
  left: 50%;
  width: 54px;
  height: 22px;
  background: rgba(10, 10, 10, 0.06);
  border: 1px solid rgba(10, 10, 10, 0.08);
  transform: translateX(-50%) rotate(-3deg);
}

.postit-text {
  font-family: "Caveat", cursive;
  font-size: 1.3rem;
  line-height: 1.55;
  color: var(--ink);
}

.postit-text strong {
  font-weight: 700;
}

/* ---------- accessibility & responsiveness ---------- */

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .scene {
    flex-direction: column;
  }
  .postit {
    width: min(230px, 68vw);
    transform: rotate(-2deg);
  }
  @keyframes sway {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(0deg); }
  }
}

@media (max-height: 700px) {
  .card {
    padding: 1rem 1.25rem;
  }
  .subtitle {
    margin-bottom: 0.9rem;
  }
  .field {
    margin-bottom: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
