.login-body {
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.gate-shell {
  position: relative;
  z-index: 2;
  width: min(100%, 410px);
  display: grid;
  place-items: center;
}

.gate-sparkles {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 520px;
  height: 400px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}

.gate-card {
  position: relative;
  width: 100%;
  background: #fff9f1;
  border: 2.5px solid var(--ink);
  border-radius: 20px 24px 22px 18px / 18px 22px 20px 24px;
  box-shadow:
    0 18px 40px rgba(80, 105, 135, 0.18),
    0 3px 0 rgba(252, 71, 0, 0.14);
  overflow: hidden;
  animation: card-arrive 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-origin: center center;
}

@keyframes card-arrive {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.95) rotate(-1deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

.gate-card.shake {
  animation: card-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes card-shake {
  15%, 85% { transform: translateX(-4px) rotate(-0.4deg); }
  30%, 70% { transform: translateX(5px) rotate(0.4deg); }
  50% { transform: translateX(-5px); }
}

/* Signature gingham ribbon at top, split into two halves so it "unties" on login */
.gingham-wrap {
  position: relative;
  height: 22px;
  display: flex;
  overflow: hidden;
  border-bottom: 2px solid var(--ink);
  transition: border-color 0.35s ease 0.15s;
}

.gingham-half {
  width: 50%;
  height: 100%;
  background-color: #fff9f1;
  background-image:
    linear-gradient(to bottom, transparent 32%, rgba(252, 71, 0, 0.45) 32%, rgba(252, 71, 0, 0.45) 68%, transparent 68%),
    repeating-linear-gradient(var(--stripe-dir, to right), transparent 0 5px, rgba(252, 71, 0, 0.45) 5px 19px, transparent 19px 24px);
  transition: transform 0.6s cubic-bezier(0.6, 0.04, 0.2, 1), opacity 0.45s ease 0.1s;
}

.gingham-left {
  --stripe-dir: to left;
}

.gate-inner {
  padding: 30px 28px 30px;
  text-align: center;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s ease;
}

.gate-heading {
  margin: 0 0 22px;
  font-family: "Caveat", cursive;
  font-size: 46px;
  font-weight: 700;
  line-height: 1.04;
  color: var(--ink);
  animation: heading-pop 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

@keyframes heading-pop {
  from {
    opacity: 0;
    transform: translateY(8px) rotate(-1.5deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
  transition: opacity 0.3s ease, transform 0.35s ease;
}

.password-field input {
  width: 100%;
  height: 50px;
  padding: 0 46px 0 16px;
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 16px;
  color: #2b1d16;
  background: #ffffff;
  border: 2px solid rgba(252, 71, 0, 0.55);
  border-radius: 13px 15px 14px 12px / 12px 14px 13px 15px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.password-field input::placeholder {
  color: #9b8579;
}

.password-field input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(252, 71, 0, 0.16);
}

.pw-toggle {
  position: absolute;
  right: 8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--ink-text);
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
}

.pw-toggle:hover {
  color: var(--ink);
  transform: scale(1.06);
}

.pw-toggle:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 2px;
}

.pw-toggle .eye-closed {
  display: none;
}

.pw-toggle[aria-pressed="true"] .eye-open {
  display: none;
}

.pw-toggle[aria-pressed="true"] .eye-closed {
  display: block;
}

.gate-error {
  margin: -2px 0 0;
  padding: 9px 12px;
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-text);
  background: rgba(252, 71, 0, 0.09);
  border: 1.5px dashed rgba(252, 71, 0, 0.55);
  border-radius: 10px;
}

.gate-submit {
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  font-family: "Caveat", cursive;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff9f1;
  background: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 14px 17px 15px 13px / 15px 13px 16px 14px;
  cursor: pointer;
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.22s ease,
    border-color 0.22s ease,
    opacity 0.18s ease;
}

.gate-submit .btn-arrow {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.gate-submit:hover:not(:disabled) {
  transform: translateY(-1.5px) rotate(-0.6deg);
  background: #e54000;
}

.gate-submit:hover:not(:disabled) .btn-arrow {
  transform: translateX(4px);
}

.gate-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.gate-submit:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 4px;
}

.gate-submit:disabled {
  cursor: default;
}

/* ---- Unlocking / Unwrapping Entrance Choreography ---- */
.gate-card.is-unlocking {
  animation: card-unwrap-exit 0.88s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.gate-card.is-unlocking .gingham-left {
  transform: translateX(-108%) rotate(-2deg);
  opacity: 0;
}

.gate-card.is-unlocking .gingham-right {
  transform: translateX(108%) rotate(2deg);
  opacity: 0;
}

.gate-card.is-unlocking .gingham-wrap {
  border-bottom-color: transparent;
}

.gate-card.is-unlocking .password-field {
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
}

.gate-card.is-unlocking .gate-submit {
  background: var(--green);
  border-color: var(--green);
  transform: scale(1.03);
}

.gate-card.is-unlocking .gate-heading {
  color: var(--green);
  transition: color 0.3s ease;
}

@keyframes card-unwrap-exit {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
  38% {
    opacity: 1;
    transform: translateY(-6px) scale(1.03) rotate(0.5deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-28px) scale(0.94) rotate(-0.6deg);
  }
}

@media (max-width: 480px) {
  .gate-inner {
    padding: 26px 20px 26px;
  }
  .gate-heading {
    font-size: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-card,
  .gate-heading,
  .gate-card.shake,
  .gate-card.is-unlocking {
    animation: none;
  }
}
