/* ============================================================
   Work Games — shared design system
   Dark-only, mobile-first. No build step, no dependencies.
   ============================================================ */

:root {
  color-scheme: dark;

  --bg:        #0e1014;
  --bg-2:      #14171e;
  --surface:   #1a1e26;
  --surface-2: #232833;
  --surface-3: #2d333f;
  --line:      #333a47;
  --line-soft: #262c36;

  --text:      #eef1f6;
  --text-2:    #b6bfcd;
  --muted:     #808b9c;

  --accent:    #7aa2ff;
  --ok:        #55b972;
  --warn:      #d9a92f;
  --bad:       #e0574a;

  --r-sm: 8px;
  --r:    13px;
  --r-lg: 20px;
  --r-pill: 999px;

  --pad: 16px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --header-h: 52px;

  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
          "Segoe UI Variable Display", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; }

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

html {
  /* stop iOS text auto-inflation in landscape */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  /* kill the grey flash / text selection that makes web games feel non-native */
  -webkit-tap-highlight-color: transparent;
}

/* Games opt into this: nothing selectable, no double-tap zoom, no scroll. */
body.is-game {
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

a { color: var(--accent); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- app shell ---------- */

.shell {
  display: flex;
  flex-direction: column;
  /* dvh tracks the collapsing mobile browser chrome; vh is the fallback */
  height: 100vh;
  height: 100dvh;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

.hdr {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(var(--header-h) + var(--safe-t));
  padding: var(--safe-t) 6px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line-soft);
  position: relative;
  z-index: 20;
}

.hdr h1 {
  flex: 1 1 auto;
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 44px minimum tap target, everywhere */
.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:active { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; display: block; }

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px var(--pad);
}

.dock {
  flex: 0 0 auto;
  padding: 0 8px calc(8px + var(--safe-b));
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--line);
  transition: transform .1s var(--ease), background .15s;
}
.btn:active { transform: scale(.97); background: var(--surface-3); }
.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: #0b0e14;
}
.btn--primary:active { background: color-mix(in srgb, var(--accent) 85%, #fff); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; }

/* ---------- toast ---------- */

#toaster {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + var(--header-h) + 12px);
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: min(90vw, 420px);
}

.toast {
  padding: 10px 16px;
  border-radius: var(--r-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  box-shadow: 0 8px 24px rgb(0 0 0 / .45);
  animation: toast-in .18s var(--ease);
}
.toast.is-out { animation: toast-out .22s var(--ease) forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-8px); } }

/* ---------- sheet (modal) ---------- */

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(0 0 0 / .6);
  animation: fade-in .18s var(--ease);
}
.sheet-wrap[hidden] { display: none; }

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 86dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px var(--pad) calc(var(--pad) + var(--safe-b));
  animation: sheet-up .26s var(--ease);
}

.sheet__grip {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  margin: 4px auto 14px;
}

.sheet__close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  z-index: 2;
}
.sheet__close:active { background: var(--surface-2); color: var(--text); }
.sheet__close svg { width: 20px; height: 20px; display: block; }
.sheet h2 { margin: 0 0 10px; font-size: 20px; font-weight: 700; }
.sheet h3 { margin: 18px 0 6px; font-size: 15px; font-weight: 650; color: var(--text-2); }
.sheet p, .sheet li { color: var(--text-2); font-size: 15px; }
.sheet ul { margin: 6px 0; padding-left: 20px; }
.sheet li { margin: 5px 0; }
.sheet .sheet__actions { margin-top: 20px; display: grid; gap: 8px; }
.sheet kbd {
  font: 600 13px var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text);
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(14px); } }

/* ---------- stat row ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
  margin: 4px 0 2px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 8px 4px;
  text-align: center;
}
.stat b { display: block; font-size: 22px; font-weight: 700; line-height: 1.15; }
.stat span {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Screen-reader-only, for live regions and labels. */
.sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
