/* ==========================================================================
   limbr — shared design system
   Calm, high-legibility theme tuned for older adults exercising memory.
   ========================================================================== */

:root {
  /* Palette — warm paper, deep ink, calm teal, coral for "remember" cues */
  --bg:          #f4f1ea;
  --bg-tint:     #ecf4f1;
  --surface:     #ffffff;
  --surface-2:   #faf8f3;
  --ink:         #1f232b;
  --ink-soft:    #565d6d;
  --ink-faint:   #8b91a0;
  --line:        #e4dfd4;
  --line-strong: #d2ccbe;

  --accent:      #0e8f7e;   /* teal */
  --accent-deep: #0a6b5e;
  --accent-soft: #d8efe9;
  --accent-glow: rgba(14,143,126,.18);

  --warm:        #e2703a;   /* coral — prospective / "remember" */
  --warm-soft:   #fbe6da;

  --sky:         #2f7fc1;   /* sky blue — soft glance / speed of processing */
  --sky-deep:    #205f95;
  --sky-soft:    #dcebf8;
  --sky-glow:    rgba(47,127,193,.2);

  --good:        #2e9e5b;
  --good-soft:   #dcf2e4;
  --bad:         #d24a3a;
  --bad-soft:    #fadfdb;
  --resolve-miss:      #7b6fd0;   /* soft indigo — a warm "not this one", never red */
  --resolve-miss-soft: #ece8fb;
  --gold:        #e0a92e;

  /* Type */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Scale — generous base for legibility */
  --fs-base: 1.125rem;   /* 18px */
  --radius: 18px;
  --radius-lg: 26px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(31,35,43,.04), 0 8px 28px rgba(31,35,43,.07);
  --shadow-lift: 0 2px 6px rgba(31,35,43,.06), 0 18px 48px rgba(31,35,43,.13);
  --tap: 52px;           /* min interactive target */
  --maxw: 1080px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--ui);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ambient backdrop — soft, slow-drifting colour fields behind everything.
   Calm and premium: barely-there depth, no hard shapes. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(46rem 32rem at 82% -8%,  rgba(14,143,126,.10), transparent 60%),
    radial-gradient(40rem 30rem at -6% 12%,  rgba(106,90,205,.07), transparent 58%),
    radial-gradient(50rem 38rem at 50% 116%, rgba(226,112,58,.06), transparent 60%);
  animation: drift 34s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(0, -1.6%, 0) scale(1.05); }
}
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.3rem; }
p  { margin: 0 0 1rem; }
a  { color: var(--accent-deep); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2rem); }

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1.1rem clamp(1rem, 4vw, 2rem);
  max-width: var(--maxw); margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand .mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff; font-family: var(--display); font-size: 1.4rem; line-height: 1;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.brand .name { font-family: var(--display); font-size: 1.5rem; letter-spacing: -0.02em; }
.brand .name b { color: var(--accent-deep); font-weight: 600; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a {
  text-decoration: none; color: var(--ink-soft); font-weight: 500; font-size: .98rem;
  padding: .5rem .8rem; border-radius: 999px; white-space: nowrap;
}
.topbar nav a:hover { background: var(--surface); color: var(--ink); }
.topbar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-deep); }

/* Narrow screens: stack the bar so the nav never collides with the brand. */
@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: .5rem; padding: .9rem 1rem; }
  .topbar nav { justify-content: center; gap: .15rem; }
  .topbar nav a { font-size: .9rem; padding: .45rem .6rem; }
}

/* ---- Cards ------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem;
}
.card-lg { border-radius: var(--radius-lg); padding: clamp(1.5rem, 4vw, 2.5rem); }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  font-family: var(--ui); font-size: 1.05rem; font-weight: 600;
  min-height: var(--tap); padding: .8rem 1.5rem;
  border-radius: 999px; border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  text-decoration: none; user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; border-color: transparent; box-shadow: 0 6px 18px var(--accent-glow); }
.btn-primary:hover { box-shadow: 0 10px 26px var(--accent-glow); }
.btn-warm { background: linear-gradient(135deg, #ef8a55, var(--warm)); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-lg { font-size: 1.2rem; min-height: 60px; padding: 1rem 2rem; }
.btn-block { width: 100%; }

/* ---- Pills / tags ----------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .82rem; font-weight: 600; letter-spacing: .02em;
  padding: .3rem .7rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-deep);
}
.pill.warm { background: var(--warm-soft); color: var(--warm); }
.pill.muted { background: var(--surface-2); color: var(--ink-soft); }

/* ---- Stats ------------------------------------------------------------ */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat {
  flex: 1 1 140px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 1rem 1.2rem;
}
.stat .v { font-family: var(--display); font-size: 2rem; line-height: 1; color: var(--ink); }
.stat .l { font-size: .85rem; color: var(--ink-soft); margin-top: .35rem; }

/* ---- Progress bar ----------------------------------------------------- */
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-deep)); border-radius: 999px; transition: width .5s cubic-bezier(.4,0,.2,1); }

/* ---- Game stage ------------------------------------------------------- */
.stage {
  /* Anchor content to the upper-middle rather than dead-centre of a tall void —
     calmer and more composed, no float on text-light intro screens. */
  min-height: calc(100vh - 180px);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  text-align: center; gap: 1.4rem; padding: clamp(2rem, 11vh, 7rem) 1rem 3rem;
}
.stage > * { animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }
.stage > *:nth-child(2) { animation-delay: .05s; }
.stage > *:nth-child(3) { animation-delay: .10s; }
.stage > *:nth-child(4) { animation-delay: .15s; }
.stage > *:nth-child(5) { animation-delay: .20s; }
.stage > *:nth-child(6) { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .stage > * { animation: none; } }
.stage .lead { color: var(--ink-soft); max-width: 46ch; }
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--ink-soft); }
.tiny { font-size: .85rem; }

/* ---- Focus & motion --------------------------------------------------- */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---- Level line (results): "Level 2 → 3 · closer look-alikes ahead" ----- */
.level-line {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 600; font-size: .95rem; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: .4rem 1rem;
}
.level-line.up { color: var(--accent-deep); background: var(--accent-soft); border-color: transparent; }
.level-line:empty { display: none; }

/* ---- Resolve kit: every meaningful tap gets answered -------------------
   ack (<=100ms squash) -> commit (100-250ms ring: teal ok / soft indigo miss)
   -> optional one-line meaning -> silence. Driven by Limbr.pulseCommit(). */
.limbr-ack { transform: scale(.96) !important; transition: transform .08s ease !important; }
.limbr-commit {
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease !important;
  transform: scale(1) !important;
}
.limbr-ok      { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 5px var(--accent) !important; border-color: var(--accent) !important; }
.limbr-miss    { box-shadow: 0 0 0 3px var(--resolve-miss-soft), 0 0 0 5px var(--resolve-miss) !important; border-color: var(--resolve-miss) !important; }
.limbr-neutral { box-shadow: 0 0 0 3px var(--surface-2), 0 0 0 5px var(--line-strong) !important; border-color: var(--line-strong) !important; }
.limbr-line { font-weight: 600; min-height: 1.5em; }
.limbr-line.ok      { color: var(--accent-deep); }
.limbr-line.miss    { color: var(--resolve-miss); }
.limbr-line.neutral { color: var(--ink-soft); }
@media (prefers-reduced-motion: reduce) {
  /* instant stroke, no squash, no bounce */
  .limbr-ack { transform: none !important; }
  .limbr-commit, .limbr-ack { transition: none !important; }
}

/* ---- Toast ------------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: .8rem 1.3rem; border-radius: 999px;
  box-shadow: var(--shadow-lift); opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 50;
  font-weight: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer.site {
  text-align: center; color: var(--ink-faint); font-size: .85rem;
  padding: 3rem 1rem 2rem;
}
