/* Chaucer — dark premium design system.
 *
 * Tokens and shared primitives only. Screen-specific rules live in their own
 * files (wf-auth.css, wf-picker.css, ...). Everything colour-bearing reads
 * var(--acc) / var(--acc2), which wf.js rewrites per genre — no component
 * should ever know which genre is active.
 */

:root {
  /* Surfaces */
  --wf-bg: #06060a;
  --wf-base: #08080b;
  --wf-cell: #08080c;
  --wf-panel: rgba(9, 9, 14, 0.94);

  /* Ink */
  --ink: #ece9f5;
  --ink-prose: #e4e1f0;
  --ink-2: #c9c5da;
  --ink-dim: #a5a1b8;
  --ink-muted: #9a96b0;
  --ink-faint: #8f8ba6;
  --ink-faintest: #837f9c;
  --sep: #3f3d52;
  --on-acc: #0b0a10;

  /* Lines */
  --hair: rgba(255, 255, 255, 0.06);
  --bd: rgba(255, 255, 255, 0.09);
  --bd-2: rgba(255, 255, 255, 0.13);
  /* The outline of a control a person has to FIND (button, field, card, chip): 3.5:1 against the page. --bd and --bd-2
     are for dividers and decoration only; at 1.2-1.5:1 they are invisible as a control's edge (WCAG 1.4.11). */
  --bd-ctl: rgba(255, 255, 255, 0.38);

  /* Fills */
  --surface: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012));
  --field: rgba(255, 255, 255, 0.035);

  /* Genre-driven; wf.js overwrites these on <html> before first paint.
     The fantasy values are the fallback so the page is never unthemed. */
  --acc: #d8a24a;
  --acc2: #8b6cf2;
  --fh: 'Cinzel', Georgia, serif;
  --fb: 'Newsreader', Georgia, serif;
  --fm: 'JetBrains Mono', ui-monospace, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-sweep: cubic-bezier(0.76, 0, 0.24, 1);

  /* The older pages' names (forge build steps, dials, play-mode cards, People builder) on this theme's tokens:
     they were never defined here, so those styles silently fell away (31 Oct). */
  --accent: var(--acc2);
  --accent-soft: color-mix(in srgb, var(--acc2) 70%, white);
  --accent-glow: color-mix(in srgb, var(--acc2) 35%, transparent);
  --border: var(--bd-2);
  --bg: var(--wf-base);
  --bg-input: var(--field);
  --text: var(--ink);
  --text-dim: var(--ink-dim);
  --text-muted: var(--ink-muted);
  --radius: 8px;
  --success: #6fcf97;
}

*, *::before, *::after { box-sizing: border-box; }

/* Hover help: styles with static/js/wf-tip.js further down. */
[data-tooltip], [data-tip] { cursor: help; }
button[data-tip], a[data-tip], label[data-tip], [role="radio"][data-tip] { cursor: pointer; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--wf-bg);
  color: var(--ink-prose);
  font-family: var(--fb);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

/* ── the stage ──────────────────────────────────────────────────────────── */

/* Fades in under its own CSS animation rather than waiting on JS — if a
   script fails the page is still readable. */
.wf-stage {
  position: relative;
  z-index: 1;
  height: 100%;
  opacity: 0;
  animation: wf-fade 380ms ease 180ms forwards;
}

/* ── ambient motion field ───────────────────────────────────────────────── */

.wf-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--wf-base);
}
.wf-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.wf-grain {
  position: absolute;
  inset: 0;
  opacity: 0.4;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 3px 3px;
}
.wf-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% -10%, transparent 36%, rgba(0, 0, 0, 0.62) 100%);
}

/* ── page sweep ─────────────────────────────────────────────────────────── */

.wf-sweep {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: linear-gradient(180deg, #06060a, color-mix(in srgb, var(--acc) 26%, #06060a) 55%, #06060a);
}
/* the hairline that reads as the leading edge of the wipe */
.wf-sweep::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--acc);
  opacity: 0.6;
}

@keyframes wf-in { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes wf-out { from { transform: scaleY(1); } to { transform: scaleY(0); } }

/* Arrival: server-rendered, covering the page, retracting downward so content
   is uncovered top-first. Pure CSS — it clears itself with no JS involved. */
.wf-sweep--enter {
  transform-origin: bottom;
  pointer-events: none;
  animation: wf-out 440ms var(--ease-sweep) forwards;
}
/* Departure: injected by wf.js, covering downward from the top. */
.wf-sweep--exit {
  transform-origin: top;
  animation: wf-in 440ms var(--ease-sweep) forwards;
}

@keyframes wf-rise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}
@keyframes wf-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wf-line { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes wf-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1); }
}

.wf-rise { animation: wf-rise 800ms var(--ease) both; }
.wf-fade { animation: wf-fade 600ms ease both; }

/* ── typography primitives ──────────────────────────────────────────────── */

.wf-brand {
  font-family: var(--fm);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.42em;
  color: var(--ink-muted);
  transition: color 240ms var(--ease);
}
a.wf-brand:hover { color: var(--ink-dim); }

.wf-kicker {
  font-family: var(--fm);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--ink-faintest);
}
.wf-kicker--acc { color: var(--acc); }

.wf-label {
  font-family: var(--fm);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
}

.wf-meta {
  font-family: var(--fm);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.wf-h1 {
  font-family: var(--fh);
  font-weight: 400;
  font-size: 96px;
  line-height: 0.94;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}
.wf-h2 {
  font-family: var(--fh);
  font-weight: 400;
  font-size: 70px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}
.wf-em { font-style: italic; color: var(--acc); }

.wf-rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(90deg, var(--acc), rgba(255, 255, 255, 0.05));
  transform-origin: left;
  animation: wf-line 900ms var(--ease) both;
}

/* ── buttons ────────────────────────────────────────────────────────────── */

.wf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--fm);
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  padding: 13px 20px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 240ms var(--ease), box-shadow 240ms var(--ease),
              border-color 240ms var(--ease), background 240ms var(--ease),
              color 240ms var(--ease);
}

.wf-btn--primary {
  background: var(--acc);
  color: var(--on-acc);
  border-color: var(--acc);
}
.wf-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 46px color-mix(in srgb, var(--acc) 45%, transparent);
}

.wf-btn--ghost {
  background: transparent;
  color: var(--ink-dim);
  border-color: var(--bd-ctl);
  font-size: 12px;
  letter-spacing: 0.12em;
  padding: 10px 16px;
}
.wf-btn--ghost:hover {
  color: var(--acc);
  border-color: var(--acc);
  box-shadow: 0 0 24px color-mix(in srgb, var(--acc) 18%, transparent);
}

.wf-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.wf-btn[disabled]:hover { transform: none; box-shadow: none; }

/* ── fields ─────────────────────────────────────────────────────────────── */

.wf-field-group { display: flex; flex-direction: column; gap: 8px; }

.wf-input {
  width: 100%;
  font-family: var(--fb);
  font-size: 16px;
  font-weight: 300;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--bd-ctl);
  border-radius: 3px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 240ms var(--ease), box-shadow 240ms var(--ease);
}
/* A borderless text field with an underline: the world builder's boxes and the play page's "What do you do?" box. */
.wf-bare {
  width: 100%;
  font-family: var(--fb);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--bd-ctl);
  padding: 8px 0 12px;
  outline: none;
  resize: none;
  transition: border-color 240ms var(--ease);
}
.wf-bare::placeholder { color: var(--ink-faintest); }
.wf-bare:focus { border-bottom-color: var(--acc); }

.wf-input::placeholder { color: var(--ink-faintest); }
.wf-input:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

/* ── pills ──────────────────────────────────────────────────────────────── */

.wf-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--fm);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--bd-ctl);
  color: var(--ink-dim);
  white-space: nowrap;
}

/* ── notices ────────────────────────────────────────────────────────────── */

.wf-notice {
  font-family: var(--fm);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  line-height: 1.7;
  padding: 11px 14px;
  border-radius: 3px;
  border: 1px solid var(--bd);
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink-dim);
}
.wf-notice--error {
  border-color: color-mix(in srgb, #c2413f 55%, transparent);
  background: color-mix(in srgb, #c2413f 10%, transparent);
  color: #e6a9a8;
}

/* ── scrollbars ─────────────────────────────────────────────────────────── */

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ── reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .wf-stage { opacity: 1; animation: none; }
  .wf-sweep { display: none; }
}

/* ── wf-tip: hover help on every page (wf-tip.js) ─────────────────────────── */
.wf-tip {
  position: fixed;
  z-index: 1000;
  max-width: min(340px, calc(100vw - 16px));
  padding: 10px 12px;
  background: #14131c;
  border: 1px solid var(--bd-2);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--ink-2);
  font-family: var(--fb);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease);
}
.wf-tip.is-on { opacity: 1; transform: none; }
.wf-tip-title {
  margin-bottom: 4px;
  color: var(--ink);
  font-family: var(--fm);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
[data-tip-tap] { cursor: help; }
[data-tip-tap]:focus-visible { outline: 1px dashed var(--acc); outline-offset: 2px; }

/* Korean pages (owner, 6 Nov): the wide tracking and small capitals suit English labels; in Hangul they pull the
   syllables apart ("로 그 인"). The brand mark keeps its own. */
html[lang="ko"] body :not(.wf-brand) { letter-spacing: normal !important; }
