/*
 * GATE · the password screen (js/gate.js)
 * A laminated 70s backstage pass hanging on a lanyard in the night sky.
 * Shown only while <html> has .is-locked; the sky keeps twinkling behind it.
 */

.gate {
  display: none;
}
html.is-locked body {
  overflow: hidden;
}
/* Everything but the pass is hidden (and unfocusable) while locked. */
html.is-locked .skip-link,
html.is-locked .site-nav,
html.is-locked main,
html.is-locked .site-footer,
html.is-locked .toast {
  visibility: hidden;
}

html.is-locked .gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 3.5rem) var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 2rem);
  background: radial-gradient(ellipse at 50% 35%, rgba(36, 26, 85, 0.35), rgba(10, 8, 32, 0.8) 70%);
}

/* ---------- the pass ---------- */
.gate__pass {
  --focus: var(--ink);
  --gate-tilt: -2.5deg;
  position: relative;
  width: min(100%, 23rem);
  display: grid;
  gap: 0.85rem;
  padding: 3rem clamp(1.25rem, 5vw, 1.9rem) 1.4rem;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.28) 0 18%, transparent 18% 100%),
    var(--paper);
  border-radius: 20px;
  box-shadow:
    0 0 0 7px rgba(246, 230, 196, 0.16),
    8px 10px 0 var(--orange),
    16px 20px 0 var(--rust),
    var(--shadow-soft);
  transform: rotate(var(--gate-tilt));
  transform-origin: 50% -40vh;
  /* swings in on its lanyard once, then holds still so it's easy to type into */
  animation: gate-swing-in 1.6s var(--ease-out) both;
}
/* the lanyard, running up and out of frame */
.gate__pass::before {
  content: "";
  position: absolute;
  bottom: calc(100% - 1.2rem);
  left: 50%;
  width: 26px;
  height: 60vh;
  transform: translateX(-50%);
  background:
    repeating-linear-gradient(0deg, transparent 0 18px, rgba(0, 0, 0, 0.12) 18px 19px),
    linear-gradient(90deg, var(--mustard) 0 25%, var(--orange) 25% 50%, var(--rust) 50% 75%, var(--brown) 75%);
  border-radius: 4px;
  z-index: -1;
}
/* the punched slot the clip goes through */
.gate__hole {
  position: absolute;
  top: 1.05rem;
  left: 50%;
  width: 3rem;
  height: 0.7rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--night-0);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.5);
}

.gate__kicker {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  color: var(--rust-ink);
}
.gate__band {
  height: 12px;
  margin-inline: calc(-1 * clamp(1.25rem, 5vw, 1.9rem));
  background: var(--stripe-band);
}
.gate__title {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  margin: 0.15rem 0 0.35rem;
}
.gate__logo {
  font-family: var(--font-display);
  font-variation-settings: var(--soft);
  font-weight: 900;
  font-size: clamp(4.2rem, 22vw, 5.6rem);
  line-height: 0.85;
  letter-spacing: -0.02em;
  color: var(--cream);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: var(--stripes);
  padding-bottom: 0.14em;
}
.gate__name {
  font-family: var(--font-display);
  font-variation-settings: var(--soft);
  font-weight: 800;
  font-size: var(--fs-lg);
  line-height: 1.1;
  text-align: center;
}

.gate__field {
  display: grid;
  gap: 0.35rem;
}
.gate__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.gate__input {
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: inset 2px 2px 0 rgba(30, 20, 36, 0.12);
}
.gate__input:focus-visible {
  outline-offset: 2px;
}
.gate__remember {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.gate__remember input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--rust);
}
.gate__go {
  width: 100%;
  min-height: 3.1rem;
}
.gate__msg {
  min-height: 1.4em;
  font-family: var(--font-hand);
  font-size: 1.05rem;
  text-align: center;
  color: var(--rust-ink);
}
.gate__fine {
  padding-top: 0.6rem;
  border-top: 2px dashed rgba(30, 20, 36, 0.35);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-soft);
}

/* wrong password: a quick head-shake */
.gate__pass.is-wrong {
  animation: gate-shake 0.45s var(--ease-out);
}
/* right password: the pass drops away and the site appears */
html.is-unlocking .gate {
  transition: opacity 0.6s ease;
  opacity: 0;
}
html.is-unlocking .gate__pass {
  animation: none;
  transition: transform 0.6s var(--ease-out);
  transform: translateY(40vh) rotate(8deg);
}

@keyframes gate-swing-in {
  0% { transform: translateY(-30vh) rotate(-9deg); }
  45% { transform: translateY(0) rotate(3deg); }
  70% { transform: rotate(-4deg); }
  85% { transform: rotate(-1.5deg); }
  100% { transform: rotate(var(--gate-tilt)); }
}
@keyframes gate-shake {
  0%, 100% { transform: rotate(var(--gate-tilt)) translateX(0); }
  20% { transform: rotate(var(--gate-tilt)) translateX(-12px); }
  40% { transform: rotate(var(--gate-tilt)) translateX(10px); }
  60% { transform: rotate(var(--gate-tilt)) translateX(-7px); }
  80% { transform: rotate(var(--gate-tilt)) translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .gate__pass,
  .gate__pass.is-wrong {
    animation: none;
  }
}
/* phones: narrower, gentler tilt and shadows so nothing runs off the edge */
@media (max-width: 480px) {
  .gate__pass {
    --gate-tilt: -1deg;
    width: calc(100% - 28px);
    box-shadow:
      0 0 0 5px rgba(246, 230, 196, 0.16),
      5px 6px 0 var(--orange),
      10px 12px 0 var(--rust),
      var(--shadow-soft);
  }
}
@media (max-height: 640px) {
  html.is-locked .gate {
    place-items: start center;
  }
  .gate__logo {
    font-size: 3.6rem;
  }
}
