/* Shared layout and components for the landing, game and loop pages. Brand tokens come from brand.css. */

:root {
  --ink: var(--eb-accent);
  --ink-2: #6f5d69;
  --ink-3: #9a8b95;
  --line: rgba(63, 47, 58, 0.12);
  --line-strong: rgba(63, 47, 58, 0.24);
  --surface: #ffffff;
  --surface-2: #fcf8f3;
  --sand-deep: #efe5d8;
  --primary-tint: #e8eff7;
  --ok-tint: #e2f1e8;
  --warn-tint: #fbeed3;
  --bad-tint: #f8dfe0;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(63, 47, 58, 0.05), 0 10px 30px rgba(63, 47, 58, 0.07);
  --shadow-lift: 0 2px 4px rgba(63, 47, 58, 0.06), 0 18px 40px rgba(63, 47, 58, 0.12);
  --gutter: clamp(16px, 2.2vw, 44px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
h1 { font-size: clamp(34px, 3.3vw, 60px); }
h2 { font-size: clamp(22px, 1.7vw, 30px); }
h3 { font-size: 19px; }
p { margin: 0; }
a { color: var(--eb-primary); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.eyebrow {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--eb-primary);
}
.lead { font-size: clamp(19px, 1.35vw, 24px); color: var(--ink-2); max-width: 46em; }

/* Top bar and footer, same on every page */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px var(--gutter);
  min-height: 76px;
}
.brand { display: inline-flex; align-items: center; flex: none; }
.brand img { height: 30px; width: auto; display: block; }
.topbar-title {
  font-size: 20px;
  font-weight: 700;
  padding-left: 20px;
  border-left: 1px solid var(--line-strong);
}
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }

main { flex: 1; padding: 0 var(--gutter) 24px; width: 100%; }

.synthetic {
  padding: 10px var(--gutter) 14px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
}

/* Buttons. Big enough for thumbs, no hover-only behaviour. */
button { font: inherit; color: inherit; touch-action: manipulation; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 26px;
  border-radius: 999px;
  border: 2px solid transparent;
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.15s, transform 0.08s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .seg button:focus-visible, .stepper button:focus-visible, .tile:focus-visible {
  outline: 3px solid var(--eb-primary);
  outline-offset: 3px;
}
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-cta { background: var(--eb-accent); color: var(--eb-highlight); box-shadow: 0 6px 18px rgba(63, 47, 58, 0.22); }
.btn-cta:hover:not([disabled]) { background: #2d2029; }
.btn-primary { background: var(--eb-primary); color: #fff; }
.btn-primary:hover:not([disabled]) { background: #46719f; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover:not([disabled]) { border-color: var(--eb-accent); }
.btn-lg { min-height: 64px; padding: 0 34px; font-size: 22px; }
.btn-sm { min-height: 44px; padding: 0 18px; font-size: 17px; }
.btn .arrow { font-size: 1.1em; line-height: 1; }

/* Segmented control */
.seg {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--sand-deep);
  border-radius: 999px;
}
.seg button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(63, 47, 58, 0.14); }
.seg button[disabled] { opacity: 0.4; cursor: not-allowed; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 1.5vw, 28px);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--sand-deep);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

/* Load colours always come with words in a legend, never colour alone */
.load-ok { --load: var(--ok); --load-tint: var(--ok-tint); }
.load-warn { --load: var(--warn); --load-tint: var(--warn-tint); }
.load-bad { --load: var(--bad); --load-tint: var(--bad-tint); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 15px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; background: var(--load); display: inline-block; }
.legend .idle-dot { color: var(--idle); }

/* Toasts */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  background: var(--eb-accent);
  color: var(--eb-sand);
  padding: 14px 26px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 700;
  box-shadow: var(--shadow-lift);
  animation: toast-in 0.3s ease-out;
  max-width: min(90vw, 900px);
  text-align: center;
}
.toast.warn { background: #8a5a12; color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity 0.35s, transform 0.35s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  padding: 10px var(--gutter);
  background: var(--bad);
  color: #fff;
  text-align: center;
  font-weight: 700;
}

/* Idle workers shown as small grey figures */
.idle-figs { display: inline-flex; align-items: center; gap: 2px; color: var(--idle); }
.idle-figs svg { width: 13px; height: 18px; display: block; }
.idle-figs .more { font-size: 14px; font-weight: 700; margin-left: 3px; }

.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 5px solid var(--primary-tint);
  border-top-color: var(--eb-primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Area bars, also used by the loop page when the hub view is missing */
.ab { display: grid; gap: 12px; }
.ab-row { display: grid; grid-template-columns: minmax(100px, 0.8fr) minmax(0, 2fr) 116px; align-items: center; gap: 14px; }
.ab-name b { display: block; font-size: 19px; }
.ab-workers { font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ab-track { position: relative; height: 40px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.ab-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); background: var(--load); opacity: 0.9; }
.ab-val { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); text-shadow: 0 0 4px rgba(255, 255, 255, 0.9); }
.ab-idle { display: flex; align-items: center; gap: 6px; min-height: 20px; font-size: 14px; color: var(--ink-2); white-space: nowrap; }

/* Departures strip */
.deps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.dep { display: grid; gap: 4px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.dep-top { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; }
.dep-top .num { color: var(--ink-2); font-weight: 400; }
.dep-bar { height: 6px; border-radius: 3px; background: var(--sand-deep); overflow: hidden; }
.dep-bar div { height: 100%; width: 0; background: var(--eb-primary); }
.dep-state { font-size: 13px; line-height: 1.2; color: var(--ink-2); }
.dep.gone-ok { background: var(--ok-tint); border-color: transparent; }
.dep.gone-ok .dep-state { color: #24694a; font-weight: 700; }
.dep.gone-bad { background: var(--bad-tint); border-color: transparent; }
.dep.gone-bad .dep-state { color: #a2272c; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
