/* ==========================================================================
   visitor.css — the name gate
   One field before the site, one line on the hero, and the visitor's own
   initials wherever a product would show an account holder.

   Nothing here hides content by itself: the gate is display:none until the
   head script sets [data-gate="ask"] on <html>, so with no JavaScript — or a
   script error — the page opens straight through to the work.

   The gate is the hero's twin, not a toll booth: the same centred column, the
   same display size, the same rhythm. Answering it does not change the screen,
   it finishes the sentence — which is why the drawn face belongs to the hero
   and not to the question. Ask plainly; let the smile be the reward.
   ========================================================================== */

/* ---------- the gate ---------------------------------------------------- */

.gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  padding: var(--card-gap);              /* the card's margins, as everywhere else */
  background: var(--dark);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* only the head script can open it. `safe` centring keeps a form taller than
   the viewport reachable — plain centring pushes its top out of the scroll
   area on a short phone. */
html[data-gate="ask"] .gate { display: grid; }

/* the front door is one large rounded card filling the screen (a .surface,
   so --paper inside it is the card's colour); the field draws only inside
   it ([data-field-clip]) */
.gate__card {
  display: grid;
  place-items: safe center;
  min-height: calc(100svh - 2 * var(--card-gap));
  padding: clamp(1.25rem, 5vw, 3rem);
  border-radius: var(--card-radius);
  background: var(--paper);
}

/* the gate is a field of type too (field.js): the same faint grid as the
   hero's dark half, with its stars, behind the question */
.gate { --grid-alpha: 0.03; }
/* its stars are pinned to the screen, so they can never make the gate
   scroll; and the gate scrolls (a short phone) without showing a bar */
.gate > .type-field { position: fixed; }
/* the card paints its own ground, so the stars sit above it (z 1) and the
   words above the stars (z 2); field.css's default z-index of -1 would put
   them under the card, where nobody sees them */
.gate > .type-field { z-index: 1; }
.gate__form { position: relative; z-index: 2; }
.gate { scrollbar-width: none; }
.gate::-webkit-scrollbar { display: none; }
html[data-gate="ask"] { overflow: hidden; }

/* the hero's column and the hero's optical centre */
.gate__form {
  width: 100%;
  /* wide enough for the question to break in two, the way the hero's greeting
     does; the field keeps its own narrower measure below */
  max-width: min(92vw, 62rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.gate__kicker {
  font-family: var(--font-small);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

/* the hero's display size, not a form's: the question is set in the type the
   answer is going to arrive in, which is the whole of the continuity */
.gate__q {
  max-width: 20ch;
  margin: 0.5em 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6.8vw, 6rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-wrap: balance;
}

.gate__field {
  width: 100%;
  max-width: 34rem;
  margin-inline: auto;
  margin-top: clamp(1.9rem, 4vw, 2.8rem);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  /* a well in the darker colour: it knocks the stars out behind the answer */
  padding: 0.85rem 1rem 0;
  border-radius: 8px 8px 0 0;
  background: var(--paper-deep);         /* one step up from the card */
  border-bottom: 1px solid var(--ink-faint);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.gate__field:hover { border-bottom-color: var(--ink); }
.gate__field:focus-within {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}
.gate__field:has(.gate__input[aria-invalid="true"]) { border-bottom-color: var(--alert); box-shadow: 0 1px 0 0 var(--alert); }

.gate__label {
  font-family: var(--font-small);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.gate__input {
  width: 100%;
  min-height: 56px;
  padding: 0.2rem 0.1rem 0.5rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4.6vw, 1.9rem);
  font-weight: 460;
  letter-spacing: -0.02em;
}
.gate__input::placeholder { color: var(--ink-faint); opacity: 1; }
.gate__input:focus { outline: none; }

.gate__error {
  display: none;
  margin-top: 4px;
  /* the gate's own ground behind the words, so the stars never shimmer through them */
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--paper);
  font-family: var(--font-small);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--alert);
}
.gate__error.is-on { display: block; }
/* the easter egg's line is not an error: it raises an eyebrow, in the theme */
.gate__error.is-wink { color: var(--accent); font-style: italic; }

.gate__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.7rem 0.75rem;
  margin-top: clamp(1.3rem, 2.6vw, 1.8rem);
}
/* the primary action is the one thing a thumb must hit easily */
.gate .btn { min-height: 48px; padding-inline: 1.6rem; }

/* the other answer is a button too, the same shape, in the field's darker
   colour: a real choice, quieter than Enter, never a footnote */
.gate__skip {
  min-height: 48px;
  padding: 0 1.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--font-small);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}
.gate__skip:hover { box-shadow: inset 0 0 0 1px var(--rule-strong); }
.gate__skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* the promise, set to its own measure so the column keeps one optical centre
   instead of two right edges */
.gate__priv {
  max-width: 42ch;
  margin: clamp(0.8rem, 1.6vw, 1.2rem) auto 0;
  padding: 6px 12px;                /* the ground behind the words, so the stars stay out of them */
  border-radius: 10px;
  background: var(--paper);
  font-family: var(--font-small);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--ink-faint);
  text-wrap: pretty;
}

/* the gate leaves the way a curtain does — one phrase, no bounce */
html[data-gate="leaving"] .gate { display: grid; }
html[data-gate="leaving"] .gate__form {
  animation: gate-out var(--phrase, 420ms) var(--md-sys-motion-easing-accelerate) forwards;
}
html[data-gate="leaving"] { overflow: hidden; }
html[data-gate="leaving"] .gate { pointer-events: none; }

@keyframes gate-out {
  to { opacity: 0; transform: translateY(-14px); }
}

/* ---------- the hero salutation ----------------------------------------- */

/* the name line is shown by [data-visitor="named"] on <html>, set before first
   paint; the markup itself carries nothing to fall back on */

.hero__name-line.is-long .hero__name,
.hero__name-line.is-long .hero__punct {   /* the ! steps down with the name */
  font-size: clamp(1.5rem, 4.6vw, 3rem);
  letter-spacing: -0.03em;
}

/* ---------- inside the concepts ----------------------------------------- */

/* the account holder's initials, wherever a product would show them */
[data-visitor-initials] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  html[data-gate="leaving"] .gate__form { animation-duration: 1ms; }
}

/* ---------- a name that looks like a keyboard smash ---------------------
   [data-visitor-odd] (1, or 2 for a long one) is set before first paint by
   the head script and kept by visitor.js. The cover winks: a small
   "…if that's really you." under the name, and the link asks again. A long
   smash also gets the spell-checker's wavy red underline. */
.hero__odd { display: none; }
html[data-visitor="named"][data-visitor-odd] .hero__odd {
  display: block;
  margin-top: 0.3em;
  font-size: 0.5em;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.hero__rename-odd { display: none; }
html[data-visitor="named"][data-visitor-odd] .hero__rename-named { display: none; }
html[data-visitor="named"][data-visitor-odd] .hero__rename-odd { display: inline; }
html[data-visitor-odd="2"] .hero__name {
  text-decoration: underline wavy var(--red-ink);
  text-decoration-thickness: 0.045em;
  text-underline-offset: 0.12em;
  text-decoration-skip-ink: none;
}
