/* The look of the Realm of the Majestic Cheese Wizard, shared by the realm's page and
   every game. Colours follow the style bible in the realm's docs/art-prompts.md.

   Everything is prefixed realm- so it can sit beside a game's own styles. Nothing here
   styles bare elements: a page opts in by using the classes and variables. */

@font-face {
  font-family: "Luckiest Guy";
  src: url("fonts/luckiest-guy.woff2") format("woff2");
  font-display: swap;
}

:root {
  --realm-ink: #2a1230;
  --realm-night: #1b1036;
  --realm-violet: #3a1c6b;
  --realm-cheddar: #f5b400;
  --realm-butter: #ffe27a;
  --realm-rind: #c77a00;
  --realm-old-rind: #8a4b00;
  --realm-stilton: #2e4fa3;
  --realm-midnight: #18265c;
  --realm-gold: #e8b931;
  --realm-molten: #ff8a1f;
  --realm-magic: #ff3ea5;
  --realm-pink: #ff4fa3;
  --realm-sparkle: #ffd23f;
  --realm-teal: #3fe0d0;
  --realm-parchment: #f6e6c4;
  --realm-parchment-dark: #e2c58e;
  --realm-cream: #fff8ec;
  --realm-red: #e0302f;
  --realm-muted-dark: #c8b9e0; /* quiet text on night */
  --realm-muted-light: #4b3a52; /* quiet text on cream */
  --realm-error: #c0392b;
  --realm-success: #1b7a52;

  --realm-display: "Luckiest Guy", "Arial Black", Impact, sans-serif;
  --realm-body: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}

/* The night sky behind every realm page. */
.realm-sky {
  background: linear-gradient(var(--realm-night), var(--realm-violet) 70vh, var(--realm-night) 140vh);
  color: var(--realm-cream);
  font-family: var(--realm-body);
}

/* Big gold lettering with an inked edge and an extruded rind. Size it with font-size. */
.realm-title {
  font-family: var(--realm-display);
  font-weight: 400;
  color: var(--realm-sparkle);
  -webkit-text-stroke: 0.08em var(--realm-ink);
  paint-order: stroke fill;
  text-shadow:
    0 0.04em 0 var(--realm-rind),
    0 0.08em 0 var(--realm-old-rind),
    0 0.12em 0 var(--realm-ink),
    0 0.2em 0.3em rgb(0 0 0 / 0.45);
}

/* Inked like the art: a thick aubergine outline and a hard offset shadow. */
.realm-button {
  display: inline-block;
  padding: 12px 22px 9px;
  border: 3px solid var(--realm-ink);
  border-radius: 14px;
  background: var(--realm-cheddar);
  box-shadow: 0 5px 0 var(--realm-ink);
  color: var(--realm-ink);
  font: 1.15rem/1 var(--realm-display);
  letter-spacing: 0.03em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.realm-button:hover { background: var(--realm-butter); }
.realm-button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--realm-ink); }
.realm-button:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: 0 5px 0 var(--realm-ink); }
.realm-button--quiet { border-color: transparent; background: transparent; box-shadow: none; color: inherit; }
.realm-button--quiet:hover { background: rgb(42 18 48 / 0.08); }
.realm-button--quiet:active { box-shadow: none; }

/* A rounded cream badge: the player's name, or Sign in. */
.realm-pill {
  display: inline-block;
  max-width: 55vw;
  padding: 8px 16px 6px;
  overflow: hidden;
  border: 3px solid var(--realm-ink);
  border-radius: 999px;
  background: var(--realm-cream);
  box-shadow: 0 4px 0 var(--realm-ink);
  color: var(--realm-ink);
  font: 1rem/1.2 var(--realm-display);
  letter-spacing: 0.03em;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.realm-pill:hover { background: var(--realm-butter); }

/* A cream panel, inked and casting a hard shadow. */
.realm-card {
  border: 4px solid var(--realm-ink);
  border-radius: 22px;
  background: var(--realm-cream);
  box-shadow: 8px 8px 0 var(--realm-ink);
  color: var(--realm-ink);
}

/* ── Dialogs ──────────────────────────────────────────────────────── */

dialog.realm-dialog {
  width: min(92vw, 400px);
  padding: 26px;
  border: 4px solid var(--realm-ink);
  border-radius: 24px;
  background: var(--realm-cream);
  box-shadow: 10px 10px 0 var(--realm-ink);
  color: var(--realm-ink);
  font-family: var(--realm-body);
  line-height: 1.45;
}
dialog.realm-dialog::backdrop { background: rgb(27 16 54 / 0.75); }
.realm-dialog h2 {
  margin: 0 0 14px;
  color: var(--realm-stilton);
  font: 400 1.8rem/1.05 var(--realm-display);
  letter-spacing: 0.02em;
}
.realm-dialog .realm-button { display: block; width: 100%; margin-top: 10px; }
.realm-dialog [hidden] { display: none; }

/* ── Sign in ──────────────────────────────────────────────────────── */

.realm-auth-help { margin: 0 0 10px; color: var(--realm-muted-light); }
.realm-auth-error { min-height: 1.2em; margin: 8px 0 0; color: var(--realm-error); font-size: 0.92rem; }
.realm-auth-input {
  box-sizing: border-box;
  width: 100%;
  padding: 12px 14px;
  border: 3px solid var(--realm-ink);
  border-radius: 12px;
  background: #fff;
  color: var(--realm-ink);
  font: inherit;
}
.realm-auth-input:focus { outline: 3px solid var(--realm-teal); outline-offset: 2px; }
.realm-emoji-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
  max-height: 150px;
  margin-top: 10px;
  overflow-y: auto;
}
.realm-emoji-choices button {
  padding: 4px 0;
  border: 2px solid var(--realm-ink);
  border-radius: 10px;
  background: #fff;
  font-size: 1.35rem;
  cursor: pointer;
}
.realm-emoji-choices button:hover { background: var(--realm-butter); }

/* ── Asking: the realm's confirm() and prompt() (ask.js) ───────────── */

.realm-ask-text { margin: 0 0 6px; color: var(--realm-muted-light); }
.realm-ask .realm-auth-input { margin: 4px 0 6px; }
.realm-button--danger { background: var(--realm-red); color: var(--realm-cream); }
.realm-button--danger:hover { background: #f04a49; }

/* ── Paused (pause.js) ─────────────────────────────────────────────── */

/* Covers the board while the game waits; a tap carries on. */
.realm-paused {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  gap: 4px;
  width: 100%;
  border: 0;
  border-radius: inherit;
  background: rgb(27 16 54 / 0.92);
  color: var(--realm-cream);
  font: 700 1rem/1.3 var(--realm-body);
  text-align: center;
  cursor: pointer;
}
.realm-paused-title { color: var(--realm-cheddar); font: 400 2.2rem/1 var(--realm-display); letter-spacing: 0.03em; }
.realm-paused:focus-visible { outline: 3px solid var(--realm-teal); outline-offset: -6px; }

/* ── Tries ────────────────────────────────────────────────────────── */

.realm-tries { margin: 10px 0 0; color: var(--realm-muted-dark); font-size: 0.85rem; text-align: center; }
.realm-tries[hidden] { display: none; }
.realm-rest { text-align: center; }
.realm-rest-wizard { display: block; width: min(200px, 60%); height: auto; margin: -6px auto 6px; }
.realm-rest-when { margin: 0 0 6px; color: var(--realm-muted-light); }

@media (prefers-reduced-motion: reduce) {
  .realm-button { transition: none; }
}
