/* The entrance (docs/landing-scope.md): the game's first screen, drawn before any script runs.
   Small on purpose: the game's own stylesheet (style.css) loads only when the game starts.

   - The entrance responds to the space it has, with its own media queries in em. It never reads
     #app[data-layout], so the gameplay layout choice can't change it.
   - Its rules are scoped to .entry with at least two classes, so style.css (loaded later, with
     element rules such as input[type=email] and h1) can't restyle it.
   - The colour tokens are the same values as style.css :root; tests/ui/entrance.test.mjs checks
     they stay in step. */
:root {
  --bg: #15110e;
  --surface: #1f1914;
  --surface-2: #2a221b;
  --line: #3a3027;
  --line-strong: #806f5c;
  --text: #ede4d4;
  --muted: #a39482;
  --gold: #dcae4c;
  --gold-soft: #f2d48f;
  --on-gold: #1b140b;
  --good: #79c27d;
  --bad: #e5705f;
  --focus: #f2d48f;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
#alerts:empty { display: none; } /* the game's problem list (style.css styles it once the game starts) */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The realm's backdrop: the entrance, and hero creation once the game has started (body.creating,
   set by main.js). Gradients only; no images. */
body.realm, body.creating {
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, rgba(220, 174, 76, .14), transparent 70%),
    radial-gradient(ellipse 60% 45% at 100% 100%, rgba(154, 91, 212, .07), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* ---------------------------------------------------------------- frame */
/* Its own scroll container: the game's stylesheet stops the body scrolling. */
.entry { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.entry .e-wrap {
  max-width: 68rem; margin: 0 auto;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 2.5rem max(1rem, env(safe-area-inset-left));
  display: grid; gap: 1.25rem;
  grid-template-areas: "id" "gate" "about";
}
.entry .e-id { grid-area: id; text-align: center; }
.entry .e-gate { grid-area: gate; }
.entry .e-about { grid-area: about; }

/* Side by side when there is room: identity and the realm on the left, the gate on the right.
   The reading order stays identity, gate, realm. */
@media (min-width: 52em) {
  .entry .e-wrap {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 25rem);
    grid-template-areas: "id gate" "about gate";
    grid-template-rows: auto 1fr;
    column-gap: clamp(2rem, 5vw, 4.5rem); row-gap: 1.75rem;
    padding-top: clamp(2rem, 8vh, 6rem);
    align-items: start;
  }
  .entry .e-id { text-align: left; }
}

/* ---------------------------------------------------------------- identity */
.entry .e-kicker {
  margin: 0 0 .35rem; font-size: .75rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
}
.entry .e-title {
  margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 600;
  font-size: clamp(2.25rem, 1.6rem + 3vw, 3.75rem); line-height: 1.05; letter-spacing: .02em;
  color: var(--gold-soft); text-shadow: 0 2px 18px rgba(220, 174, 76, .18);
}
.entry .e-sub { margin: .6rem 0 0; color: var(--muted); font-size: 1rem; }
.entry .e-id::after {
  content: ""; display: block; width: 7rem; height: 1px; margin: 1.1rem auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
@media (min-width: 52em) { .entry .e-id::after { margin-left: 0; } }

/* ---------------------------------------------------------------- the gate: sign in */
.entry .e-gate {
  background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--gold);
  border-radius: 14px; padding: 1.25rem 1.25rem 1rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.entry .e-h { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 600; font-size: 1.3125rem; line-height: 1.2; color: var(--text); }
.entry .e-h:focus { outline: none; }
.entry .e-h:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.entry .e-field {
  display: block; margin-top: .9rem; font-size: .8125rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.entry .e-input {
  display: block; width: 100%; margin-top: .4rem; min-height: 48px; padding: 10px 12px;
  background: #0f0c0a; color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; font-size: 1rem; letter-spacing: normal; text-transform: none;
}
.entry .e-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.entry .e-input[aria-invalid="true"] { border-color: var(--bad); }

.entry .e-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; min-height: 48px; margin-top: 1.1rem; padding: 8px 14px; border-radius: 10px;
  background: var(--gold); color: var(--on-gold); border: 1px solid var(--gold);
  font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.entry .e-btn:disabled { cursor: progress; opacity: .7; }
.entry .e-btn.e-quiet { background: transparent; color: var(--text); border-color: var(--line-strong); }
.entry .e-btn:focus-visible, .entry .e-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Waiting for the server: a moving bar along the bottom edge (transform only). */
.entry .e-btn[aria-busy="true"] { position: relative; overflow: hidden; }
.entry .e-btn[aria-busy="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(27, 20, 11, .55);
  transform-origin: left; animation: e-busy 1.1s var(--ease) infinite;
}
@keyframes e-busy { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.entry .e-switch { margin: .75rem 0 0; text-align: center; }
.entry .e-link {
  appearance: none; background: none; border: 0; padding: 10px 4px; min-height: 44px;
  color: var(--gold); font: inherit; font-weight: 600; cursor: pointer;
}
.entry .e-link:disabled { cursor: default; }

.entry .e-msg {
  margin: .9rem 0 0; padding: .55rem .75rem; border-left: 3px solid var(--line-strong); border-radius: 4px;
  background: rgba(0, 0, 0, .18); font-size: .9375rem; color: var(--text);
}
.entry .e-msg.e-bad { border-left-color: var(--bad); color: #f19a8c; }
.entry .e-msg.e-good { border-left-color: var(--good); }

/* The interface choice (landing L-2). It sets the game's layout, never the entrance's. */
.entry .e-iface { margin: 1rem 0 0; padding: .9rem 0 0; border: 0; border-top: 1px solid var(--line); min-width: 0; }
.entry .e-legend { padding: 0; font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.entry .e-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .5rem; margin-top: .5rem; }
.entry .e-choice {
  display: flex; align-items: center; gap: .55rem; min-height: 44px; padding: .4rem .7rem;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #0f0c0a; cursor: pointer; font-size: .9375rem;
}
.entry .e-choice:has(input:checked) { border-color: var(--gold); background: #33281a; }
.entry .e-choice input { accent-color: var(--gold); width: 18px; height: 18px; margin: 0; flex: none; }
.entry .e-choice input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.entry .e-note { margin: .6rem 0 0; color: var(--muted); font-size: .875rem; }
.resuming .entry .e-iface, .entering .entry .e-iface { display: none; }

/* In-place status while a saved session is restored or the game starts: it replaces the form, so
   there is never a separate loading screen. */
.entry .e-status { margin: .9rem 0 0; color: var(--muted); }
.entry .e-status:empty, .entry .e-resume { display: none; }
.resuming .entry .e-resume { display: inline; }
.resuming .entry #authform, .resuming .entry .e-switch,
.entering .entry #authform, .entering .entry .e-switch { display: none; }
.resuming .entry .e-status::after, .entering .entry .e-status::after {
  content: ""; display: block; width: 100%; height: 2px; margin-top: .75rem; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform-origin: left; animation: e-busy 1.4s var(--ease) infinite;
}
.entry .e-problem { margin-top: .9rem; }
.entry .e-problem p { margin: 0; padding: .55rem .75rem; border-left: 3px solid var(--bad); background: rgba(0, 0, 0, .18); color: #f19a8c; border-radius: 4px; }
.entry .e-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.entry .e-actions .e-btn { margin-top: .9rem; }

/* ---------------------------------------------------------------- the realm */
.entry .e-about { color: var(--muted); max-width: 40rem; margin: 0 auto; }
.entry .e-about .e-h { color: var(--text); font-size: 1.125rem; margin-bottom: .5rem; }
.entry .e-about p { margin: 0 0 .75rem; }
.entry .e-points { margin: 0; padding: 0; list-style: none; display: grid; gap: .55rem; }
.entry .e-points li { position: relative; padding-left: 1.1rem; }
.entry .e-points li::before {
  content: ""; position: absolute; left: 0; top: .62em; width: .4rem; height: .4rem;
  border: 1px solid var(--gold); transform: rotate(45deg);
}
@media (min-width: 52em) { .entry .e-about { margin: 0; } }

/* ---------------------------------------------------------------- arriving in the game */
/* The game rises into place as the entrance gives way (transform only: fading text would fail
   contrast mid-fade). None with reduced motion. */
#app.veiled { visibility: hidden; }
#app.arriving { animation: e-arrive 260ms var(--ease); }
@keyframes e-arrive { from { transform: translateY(14px); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  #app.arriving { animation: none; }
  .entry .e-btn[aria-busy="true"]::after,
  .resuming .entry .e-status::after, .entering .entry .e-status::after { animation: none; transform: none; }
}
