/* Towne Apps launcher. The look lives in the shader (launcher.js); this styles the type and chrome around it. */
:root {
  color-scheme: dark light;
  --bg: #06070a;
  --bgA: #0a0c10;      /* cell glass, edge  (read by the shader) */
  --bgB: #181c24;      /* cell glass, centre */
  --edge: #dce6ff;     /* the light along cell borders */
  --accent: #ff4a3d;   /* Towne red, as light */
  --ink: #eef1f7;
  --ink2: #a3adbd;
  --mute: #6c7686;
  --line: rgba(220, 230, 255, 0.16);
  --ok: #3ddc84;
  --warn: #ffb020;
  --bad: #ff5a4d;
  --font-d: 'Anybody', 'Arial Narrow', 'Helvetica Neue', system-ui, sans-serif;
  --font-m: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ece8df; --bgA: #f7f4ed; --bgB: #e2ddd0; --edge: #1c1e24; --accent: #c8201c;
    --ink: #14161b; --ink2: #4b505b; --mute: #7c8190; --line: rgba(20, 22, 27, 0.18);
    --ok: #0b8a3e; --warn: #b36b00; --bad: #c8201c;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-m);
  overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
::selection { background: var(--accent); color: #fff; }

#field { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
#hit { position: fixed; inset: 0; z-index: 1; touch-action: manipulation; }
#hit.over { cursor: pointer; }

/* ── masthead ─────────────────────────────────────────────── */
.mast {
  position: fixed; inset: 0 0 auto 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 0; pointer-events: none;
}
.mast > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.plate { display: grid; place-items: center; background: #0b0d11; border: 1px solid rgba(220, 230, 255, 0.16); border-radius: 10px; padding: 4px 9px; }
.plate img { display: block; height: 30px; width: auto; }
.brand b { font: 800 14px/1 var(--font-d); font-stretch: 135%; letter-spacing: 0.1em; text-transform: uppercase; }
.sys { display: flex; align-items: center; gap: 16px; font: 500 11px/1 var(--font-m); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink2); }
.sys .live { display: inline-flex; align-items: center; gap: 8px; }
.sys .live i { width: 7px; height: 7px; border-radius: 50%; background: var(--mute); }
.sys .live[data-s='ok'] i { background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: beat 2.4s ease-in-out infinite; }
.sys .live[data-s='warn'] i { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.sys .live[data-s='bad'] i { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
@keyframes beat { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (max-width: 560px) { .brand b { display: none; } .sys .clock { display: none; } }

/* ── cells (labels sit on the shader's glass) ─────────────── */
#cells { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.cell {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: var(--mw, 220px); text-align: center; color: var(--ink); text-decoration: none; opacity: 0;
  transition: opacity 0.7s ease; will-change: transform; outline: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.cell.ready { opacity: 1; }
.cell.is-admin { opacity: 0; }
.cell.ready.is-dim { opacity: 0.2; transition-duration: 0.25s; }
.cell.is-admin.ready { opacity: 0.62; }
.cell .top { display: flex; align-items: center; gap: 7px; font: 500 11px/1 var(--font-m); letter-spacing: 0.14em; color: var(--ink2); }
.cell .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mute); transition: background 0.3s, box-shadow 0.3s; }
.cell .dot[data-s='up'], .cell .dot[data-s='local'] { background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 75%, transparent); }
.cell .dot[data-s='slow'] { background: var(--warn); box-shadow: 0 0 8px color-mix(in srgb, var(--warn) 75%, transparent); }
.cell .dot[data-s='down'] { background: var(--bad); box-shadow: 0 0 8px color-mix(in srgb, var(--bad) 75%, transparent); }
.cell .ms { min-width: 0; letter-spacing: 0.06em; color: var(--mute); }
.cell .last { display: none; color: var(--accent); letter-spacing: 0.12em; }
.cell.is-last .last { display: inline; }
.cell .nm {
  font-family: var(--font-d); font-weight: 700; font-size: var(--fs, 34px); font-stretch: var(--wd, 120%); line-height: 0.92; letter-spacing: -0.01em;
  text-transform: uppercase; transition: font-weight 0.35s ease, letter-spacing 0.35s ease, color 0.3s;
}
.cell .nm span { display: inline-block; white-space: nowrap; }
.cell .bl { font: 400 12px/1.35 var(--font-m); color: color-mix(in srgb, var(--ink) 86%, transparent); max-width: var(--mw, 220px); opacity: var(--bl, 0); transition: opacity 0.3s; }
.cell.is-hot .nm { font-weight: 900; letter-spacing: 0.004em; }
.cell.is-hot .bl { opacity: 1; }
.cell:focus-visible .nm { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.14em; text-decoration-color: var(--accent); }
.launching .cell:not(.is-launch) { opacity: 0; transition: opacity 0.22s ease; }
.launching .mast, .launching .dock { opacity: 0; transition: opacity 0.22s ease; }
.launching .cell.is-launch .nm { color: #fff; }
.launching .cell.is-launch .top, .launching .cell.is-launch .bl { color: rgba(255, 255, 255, 0.85); }

/* ── dock: suggestions + the intent bar ───────────────────── */
.dock {
  position: fixed; inset: auto 0 0 0; z-index: 6; padding: 0 16px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column;
  align-items: center; gap: 10px; pointer-events: none;
}
.dock > * { pointer-events: auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; max-width: min(100%, 780px); scrollbar-width: none; padding: 2px 2px; min-height: 36px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; font: 500 12.5px/1 var(--font-m); color: var(--ink); text-decoration: none; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--bgA) 88%, transparent); white-space: nowrap; transition: border-color 0.2s, transform 0.2s;
  animation: chipin 0.35s ease both;
}
.chip:hover, .chip:focus-visible { border-color: var(--edge); outline: none; }
.chip small { color: var(--ink2); font-size: 11px; letter-spacing: 0.04em; }
.chip kbd, .keycap {
  font: 500 10.5px/1 var(--font-m); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; color: var(--ink2); background: transparent;
}
.chip.top { border-color: var(--accent); }
@keyframes chipin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.intent {
  width: min(680px, 100%); height: 58px; display: flex; align-items: center; gap: 10px; padding: 0 8px 0 18px; border: 1px solid var(--line); border-radius: 16px;
  background: color-mix(in srgb, var(--bgA) 92%, transparent); transition: border-color 0.2s, box-shadow 0.25s;
}
.intent:focus-within { border-color: var(--edge); box-shadow: 0 0 0 4px color-mix(in srgb, var(--edge) 12%, transparent), 0 0 40px color-mix(in srgb, var(--accent) 26%, transparent); }
.intent.shake { animation: shake 0.4s ease; border-color: var(--bad); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.intent .prompt { color: var(--accent); font: 600 18px/1 var(--font-m); }
.intent input {
  flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0; color: var(--ink); font: 500 16px/1 var(--font-m); letter-spacing: 0.01em;
  caret-color: var(--accent);
}
.intent input::placeholder { color: var(--mute); }
.mic {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: transparent;
  color: var(--ink2); cursor: pointer; transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.mic:hover { color: var(--ink); border-color: var(--edge); }
.mic.on { color: #fff; background: var(--accent); border-color: var(--accent); animation: ring 1.3s ease-out infinite; }
.mic[hidden] { display: none; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.intent .keycap { margin-right: 2px; }
@media (hover: none) { .intent .keycap { display: none; } }
.msg { font: 500 12px/1.3 var(--font-m); color: var(--ink2); letter-spacing: 0.02em; min-height: 14px; margin-top: -4px; text-align: center; }
.foot { display: flex; justify-content: space-between; gap: 16px; width: min(680px, 100%); font: 500 11px/1.2 var(--font-m); letter-spacing: 0.06em; color: var(--ink2); }
.foot a, .foot button { color: inherit; background: none; border: 0; padding: 0; font: inherit; letter-spacing: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
.foot a:hover, .foot button:hover { color: var(--ink); }

/* ── no-WebGL fallback: a plain, fast grid of the same links ─ */
.nogl body { overflow: auto; }
.nogl #field, .nogl #hit { display: none; }
.nogl #cells {
  position: static; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; padding: 84px 14px 190px; pointer-events: auto;
}
.nogl .cell {
  position: relative; opacity: 1 !important; transform: none !important; max-width: none; width: auto; align-items: flex-start; text-align: left; padding: 18px;
  border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--bgA) 90%, var(--bgB));
}
.nogl .cell { transition: none; }
.nogl .cell:hover { border-color: var(--edge); }
.nogl .cell .nm { font-size: 26px; }

@media (prefers-reduced-motion: reduce) {
  .cell, .chip, .cell .nm { transition: none !important; animation: none !important; }
  .sys .live i, .mic.on { animation: none !important; }
}
