/* Welcome Book — the front door.
   The first thing a guest ever sees of the house, usually on a phone, often at
   night, sometimes standing outside in the cold. So: the photo, the name, one
   field. Everything else earns its place or isn't here. */

.wb-door {
  min-height: 100svh;
  display: grid;
  align-items: end;
  position: relative;
  background: #14110e;
  color: #fdfbf7;
}

/* ── The house ─────────────────────────────────────────────────────────────── */

/* The drifting photograph is clipped here rather than on the page, so a short
   screen — a phone held sideways — can still scroll to reach the field. */
.wb-door__media {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.wb-door__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 55%;
  /* A drift slow enough that you never catch it moving, only notice that it has. */
  animation: wb-drift 48s ease-in-out infinite alternate;
}

@keyframes wb-drift {
  from { transform: scale(1.06) translate3d(0, 0, 0); }
  to   { transform: scale(1.14) translate3d(-1.5%, -1.5%, 0); }
}

.wb-door::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to top, rgb(16 13 11 / 92%) 0%, rgb(16 13 11 / 55%) 38%, rgb(16 13 11 / 8%) 72%),
    linear-gradient(to right, rgb(16 13 11 / 55%) 0%, transparent 55%);
}

/* ── The panel ─────────────────────────────────────────────────────────────── */

.wb-door__panel {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 32rem;
  padding: clamp(2rem, 7vw, 4.5rem) clamp(1.25rem, 5vw, 3.5rem) clamp(2.5rem, 7vw, 4rem);
}

.wb-door__eyebrow,
.wb-door__title,
.wb-door__tagline,
.wb-door__form {
  animation: wb-rise 700ms cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

.wb-door__eyebrow { animation-delay: 60ms; }
.wb-door__title   { animation-delay: 140ms; }
.wb-door__tagline { animation-delay: 220ms; }
.wb-door__form    { animation-delay: 300ms; }

@keyframes wb-rise {
  from { opacity: 0; transform: translateY(0.75rem); }
  to   { opacity: 1; transform: none; }
}

.wb-door__eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}

.wb-door__title {
  margin: 0;
  font-family: var(--wb-serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 9vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.wb-door__tagline {
  margin: 0.85rem 0 0;
  font-size: 1rem;
  line-height: 1.55;
  opacity: 0.78;
  max-width: 26rem;
}

/* ── The field ─────────────────────────────────────────────────────────────── */

.wb-door__form {
  margin-top: clamp(2rem, 5vw, 2.75rem);
  transition: opacity 320ms ease, transform 320ms ease;
}

.wb-door__row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1rem;
}

.wb-door__field { flex: 1 1 12rem; display: block; }

.wb-door__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.6;
}

/* A line, not a box — a box on a photograph always looks stuck on. */
.wb-door__input {
  width: 100%;
  padding: 0.5rem 0 0.55rem;
  border: 0;
  border-bottom: 1px solid rgb(253 251 247 / 32%);
  background: transparent;
  color: #fdfbf7;
  font: inherit;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  border-radius: 0;
  transition: border-color 220ms ease, box-shadow 220ms ease;
}

.wb-door__input[name="wb_code"] {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.wb-door__input::placeholder { color: rgb(253 251 247 / 35%); }

.wb-door__input:focus {
  outline: none;
  border-bottom-color: #fdfbf7;
  box-shadow: 0 1px 0 0 #fdfbf7;
}

.wb-door__stack { flex: 1 1 100%; display: grid; gap: 1rem; }

/* Any rule that sets display beats the browser's own [hidden] handling, so every
   part the door hides has to say so itself. Without this the manager's fields and
   the access code are both on screen at once, whatever door.js asked for. */
.wb-door__field[hidden],
.wb-door__stack[hidden],
.wb-door__switch[hidden] { display: none; }

/* ── The button ────────────────────────────────────────────────────────────── */

.wb-door__submit {
  position: relative;
  flex: none;
  min-height: 3rem;
  padding: 0.7rem 1.6rem;
  border: 1px solid rgb(253 251 247 / 45%);
  border-radius: 999px;
  background: transparent;
  color: #fdfbf7;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.wb-door__submit:hover,
.wb-door__submit:focus-visible {
  background: #fdfbf7;
  color: #1a1613;
  border-color: #fdfbf7;
}

.wb-door__submit:disabled { cursor: default; opacity: 0.75; }

.wb-door__spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0;
}

.is-working .wb-door__submit-text { opacity: 0; }
.is-working .wb-door__spinner { opacity: 1; animation: wb-spin 620ms linear infinite; }

@keyframes wb-spin { to { transform: rotate(360deg); } }

/* ── One message, one place ────────────────────────────────────────────────── */

.wb-door__message {
  /* The height is held whether or not there is anything to say, so the button
     never jumps out from under a thumb that is already on its way down. */
  min-height: 1.5rem;
  margin: 1rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(-0.25rem);
  transition: opacity 240ms ease, transform 240ms ease, color 240ms ease;
}

.wb-door__message.is-shown { opacity: 1; transform: none; }
.wb-door__message.is-error { color: #ffb4a2; }
.wb-door__message.is-note { color: rgb(253 251 247 / 72%); }
.wb-door__message.is-good { color: #a8d5b5; }

.wb-door__switches {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.25rem;
}

.wb-door__switch {
  margin-top: 0.5rem;
  padding: 0.35rem 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  opacity: 0.55;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: opacity 200ms ease;
}

.wb-door__switch:hover,
.wb-door__switch:focus-visible { opacity: 0.9; }

/* ── Getting in ────────────────────────────────────────────────────────────── */

.wb-door__greeting {
  position: absolute;
  left: clamp(1.25rem, 5vw, 3.5rem);
  right: clamp(1.25rem, 5vw, 3.5rem);
  bottom: clamp(2.5rem, 7vw, 4rem);
  margin: 0;
  font-family: var(--wb-serif);
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  line-height: 1.2;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 420ms ease, transform 420ms ease;
  pointer-events: none;
}

.wb-door.is-entering .wb-door__form {
  opacity: 0;
  transform: translateY(-0.5rem);
  pointer-events: none;
}

.wb-door.is-entering .wb-door__greeting {
  opacity: 1;
  transform: none;
  transition-delay: 160ms;
}

/* The photograph opens up as the panel gives way — the house, not the form, is
   the last thing on screen before the book. */
.wb-door.is-entering::after { opacity: 0.75; transition: opacity 600ms ease; }

:where(.wb-door) :focus-visible {
  outline: 2px solid #fdfbf7;
  outline-offset: 3px;
  border-radius: 3px;
}

@media (min-width: 60rem) {
  .wb-door__panel { padding-bottom: clamp(3rem, 8vh, 5.5rem); }
}

@media (max-width: 26rem) {
  /* A button that has wrapped onto its own line may as well be reachable across
     the whole of it. */
  .wb-door__submit { width: 100%; }
  .wb-door__field { flex: 1 1 100%; }
}

/* Landscape on a phone: the name can give up some of its size so the field it
   exists to introduce is still on screen. */
@media (max-height: 30rem) {
  .wb-door { align-items: center; }
  .wb-door__title { font-size: clamp(1.75rem, 7vw, 2.5rem); }
  .wb-door__tagline { display: none; }
  .wb-door__panel { padding-top: 1.5rem; padding-bottom: 1.5rem; }
  .wb-door__form { margin-top: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .wb-door__media img { animation: none; transform: scale(1.06); }
  .wb-door__eyebrow,
  .wb-door__title,
  .wb-door__tagline,
  .wb-door__form { animation: none; }
  .wb-door *, .wb-door *::after { transition-duration: 0.01ms !important; }
  .wb-door__spinner { animation-duration: 1.4s; }
}
