/* ==========================================================
   GATE — the candle-lit welcome screen with the password
   ========================================================== */

body.gate {
  background: radial-gradient(ellipse at 50% 30%, #6d2a3f 0%, #48162a 42%, #1f0a16 100%);
  background-attachment: fixed;
}
body.gate::before { opacity: 0.16; }
body.gate::after {
  background: radial-gradient(ellipse at 50% 50%, transparent 42%, rgba(0, 0, 0, 0.5) 100%);
}

.candle {
  position: fixed;
  left: 50%;
  top: 46%;
  width: min(130vw, 920px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 190, 110, 0.36) 0%, rgba(255, 160, 90, 0.14) 35%, transparent 65%);
  animation: flicker 5s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes flicker {
  0%   { opacity: 0.8;  transform: translate(-50%, -50%) scale(1); }
  30%  { opacity: 1; }
  55%  { opacity: 0.86; transform: translate(-50%, -50%) scale(1.035); }
  100% { opacity: 0.96; transform: translate(-50%, -50%) scale(1.01); }
}

/* canvas particles */
.gate__stage {
  position: relative;
  z-index: 6;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 4.6rem 1rem 2.6rem;
}

.gate__wrap {
  position: relative;
  width: min(94vw, 470px);
  filter: drop-shadow(0 30px 38px rgba(0, 0, 0, 0.55)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}
.js:not(.is-ready) .gate__wrap { opacity: 0; }
.is-ready .gate__wrap { animation: gate-in 1.8s var(--ease) both; }
.is-unlocking .gate__wrap { animation: gate-out 1.7s var(--ease) forwards; }

@keyframes gate-in {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}
@keyframes gate-out {
  0%   { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-22px) scale(0.965); }
}

.gate__wax {
  --wax: 74px;
  position: absolute;
  left: 50%;
  top: -37px;
  margin-left: -37px;
  z-index: 3;
}

.gate__card {
  position: relative;
  padding: 3.6rem clamp(1.4rem, 6vw, 2.6rem) 2.5rem;
  text-align: center;
  border-radius: 3px;
}
.gate__card.is-shaking { animation: shake 0.55s var(--ease-soft); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-9px) rotate(-0.6deg); }
  38% { transform: translateX(8px) rotate(0.5deg); }
  58% { transform: translateX(-5px); }
  78% { transform: translateX(3px); }
}

.gate__to {
  font-family: var(--font-script);
  font-weight: 400;
  font-size: clamp(3.4rem, 13vw, 4.6rem);
  line-height: 1.05;
  color: var(--burgundy);
}
.gate__from {
  margin-top: 0.5rem;
  font-style: italic;
  font-size: clamp(1.3rem, 4.6vw, 1.55rem);
  line-height: 1.35;
  color: var(--ink-soft);
  text-wrap: balance;
}
.gate .ornament { margin: 1.3rem auto 1.1rem; }
.gate .ornament [data-icon] { width: 22px; height: 22px; display: block; }
.gate__line {
  font-family: var(--font-hand);
  font-size: clamp(1.6rem, 5.4vw, 1.9rem);
  line-height: 1.2;
  color: var(--brown);
}

.gate__form { margin-top: 1.5rem; }

.field {
  position: relative;
  max-width: 330px;
  margin: 0 auto;
}
.field input {
  width: 100%;
  padding: 0.45rem 3.6rem 0.4rem 3.6rem;
  text-align: center;
  font-family: var(--font-hand);
  font-size: 1.8rem;
  letter-spacing: 0.05em;
  color: var(--burgundy);
  background: transparent;
  border: 0;
  border-bottom: 2px solid rgba(107, 74, 58, 0.5);
  border-radius: 0;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.field input::placeholder {
  color: rgba(107, 74, 58, 0.5);
  letter-spacing: 0;
}
.field input:focus-visible {
  border-bottom-color: var(--burgundy);
  box-shadow: 0 3px 0 0 var(--gold);
}
.field__toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.5rem;
  background: none;
  border: 0;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: var(--rose-deep);
  cursor: pointer;
}

.gate__msg {
  min-height: 2.5rem;
  margin: 0.6rem 0 0.9rem;
  font-family: var(--font-hand);
  font-size: 1.45rem;
  line-height: 1.25;
  color: var(--burgundy);
}
.gate__msg.is-hint { color: var(--brown); }

.gate .btn {
  width: min(100%, 320px);
}

/* the welcome line that appears after unlocking */
.gate__welcome {
  position: fixed;
  left: 50%;
  top: 46%;
  z-index: 7;
  width: min(90vw, 720px);
  transform: translate(-50%, -50%);
  text-align: center;
  font-family: var(--font-script);
  font-size: clamp(3rem, 10vw, 5.2rem);
  line-height: 1.15;
  color: var(--cream);
  text-shadow: 0 0 34px rgba(235, 209, 150, 0.6), 0 2px 0 rgba(0, 0, 0, 0.3);
  opacity: 0;
  filter: blur(10px);
  pointer-events: none;
  transition: opacity 1.7s var(--ease) 0.9s, filter 1.7s var(--ease) 0.9s;
}
.is-unlocking .gate__welcome {
  opacity: 1;
  filter: none;
}

/* cream wash before moving to the story */
.wash {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--cream);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.1s var(--ease-soft);
}
.wash.is-on { opacity: 1; }
