/* Eastworlds Factory home. The FORGE tokens the fleet pages use (ui/src/index.css),
   so leaving this page for /wagmi/ or /yam/ changes nothing but the content:
   cool slate in light, warm soot in dark, one amber accent.
   Radii: 12 plates, 6 controls, 3 floor cells. Kode Mono for display and for
   machine-issued numbers, Inter for reading. Fonts are bundled, never a CDN. */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Kode Mono"; font-weight: 500; font-display: swap; src: url(fonts/kode-mono-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Kode Mono"; font-weight: 700; font-display: swap; src: url(fonts/kode-mono-latin-700-normal.woff2) format("woff2"); }

:root {
  color-scheme: light;
  --paper: #f8fafc;
  --plate: #ffffff;
  --plate-2: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #64748b;
  --rule: #e2e8f0;
  --rule-strong: #cbd5e1;
  --signal: #b45309;
  --signal-soft: rgba(180, 83, 9, 0.10);
  --ok: #047857;
  --crit: #b91c1c;
  --ok-glow: rgba(4, 120, 87, 0.35);
  --cell-idle: #94a3b8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-lift: 0 18px 40px -18px rgba(15, 23, 42, 0.28);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Kode Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(16px, 3.2vw, 64px);
  /* the page uses the window up to here, then centres */
  --stage-max: 2000px;
}

.dark {
  color-scheme: dark;
  --paper: #0e0c0a;
  --plate: #1d1915;
  --plate-2: #2f2a23;
  --ink: #f8f3e9;
  --ink-2: #b0a48c;
  --ink-3: #94897a;
  --rule: #2f2a23;
  --rule-strong: #454036;
  --signal: #d4924a;
  --signal-soft: rgba(212, 146, 74, 0.14);
  --ok: #6ee7b7;
  --crit: #fca5a5;
  --ok-glow: rgba(110, 231, 183, 0.35);
  --cell-idle: #6b6254;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 24px 48px -20px rgba(0, 0, 0, 0.7);
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* ---------- top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  /* the rule runs the full width; the content lines up with the stage */
  padding-inline: max(var(--gutter), calc((100% - var(--stage-max)) / 2 + var(--gutter)));
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
}
.brand-mark { width: 15px; height: 23px; fill: currentColor; }
.brand-name { font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.brand-name b { font-weight: 600; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--plate);
  color: var(--ink-2);
  cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--rule-strong); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.theme-toggle .ico { display: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .ico .fill { fill: currentColor; stroke: none; }
.theme-toggle[data-mode="system"] .ico-system,
.theme-toggle[data-mode="light"] .ico-light,
.theme-toggle[data-mode="dark"] .ico-dark { display: block; }

/* ---------- stage ---------- */
.stage {
  flex: 1;
  width: 100%;
  max-width: var(--stage-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: clamp(24px, 4vh, 56px) clamp(20px, 3vh, 32px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(20px, 3.2vh, 36px);
  align-content: start;
}

.intro { min-width: 0; }
.kicker {
  margin: 0 0 14px;
  font: 500 0.75rem/1 var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
}
h1 {
  margin: 0;
  font: 700 clamp(2.1rem, 0.55rem + 4.6vw, 4rem)/1.04 var(--font-display);
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.lede {
  margin: 16px 0 0;
  max-width: 52ch;
  font-size: clamp(1rem, 0.94rem + 0.3vw, 1.125rem);
  color: var(--ink-2);
}
.pulse {
  margin: 12px 0 0;
  font-size: 0.875rem;
  color: var(--ink-3);
}
.pulse-figure {
  font: 500 0.9375rem/1 var(--font-display);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- bays: one per live embodiment, all the same size ----------
   A bay is a stack of five rows: model, title, floor map, stats, foot.
   Side by side, the bays share those rows (subgrid), so every bay's stats
   and link sit on one line whatever its floor holds, and the only spare
   height is under the smaller floors, not stretched through the card. */
.bays {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(16px, 1.4vw, 24px);
}

.bay {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto auto;
  align-content: start;
  gap: 16px;
  min-width: 0;
  padding: clamp(18px, 1.6vw, 28px);
  background: var(--plate);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 260ms var(--ease), box-shadow 260ms var(--ease), border-color 260ms var(--ease);
}
.bay:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--rule-strong); }
.bay:active { transform: translateY(-1px) scale(0.995); }
.bay:focus-visible, .brand:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}

.bay-title { min-width: 0; display: grid; gap: 6px; align-content: start; }
.bay-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bay-name {
  margin: 0;
  font: 700 clamp(1.75rem, 1.2rem + 1.2vw, 2.5rem)/1 var(--font-display);
  letter-spacing: -0.02em;
}
.bay-key {
  font: 500 0.75rem/1 var(--font-display);
  color: var(--ink-3);
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 4px 7px;
}
.bay-desc { margin: 0; color: var(--ink-2); }
.bay-foot { display: grid; gap: 8px; align-content: end; }

/* FORGE's 3D model of the embodiment (viewer/viewer.js, loaded after first
   paint). The slot is reserved up front so nothing shifts when it arrives;
   its shape follows the layout below. */
.model {
  position: relative;
  aspect-ratio: 16 / 10;
  min-height: 180px;
  border-radius: 8px;
  background: var(--plate-2);
  overflow: hidden;
}
.model canvas {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 600ms var(--ease);
}
.model.is-ready canvas { opacity: 1; }
.bay.no-model .model { display: none; }
/* phones never load the models (home.js skips the download below 480px) */
@media (max-width: 479px) {
  .model { display: none; }
}

/* the floor map: one cell per station, in station order */
.floor {
  --cell: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr));
  gap: 5px;
  min-height: calc(var(--cell) * 2 + 5px);
  align-content: start;
}
.floor.is-few { --cell: 34px; grid-template-columns: repeat(var(--cols, 5), minmax(0, var(--cell))); }
.cell {
  display: block;
  aspect-ratio: 1;
  max-width: 100%;
  border-radius: 3px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  display: grid;
  place-items: center;
  font: 500 0.625rem/1 var(--font-display);
  letter-spacing: -0.02em;
  font-style: normal;
  color: var(--paper);
  overflow: hidden;
}
.cell.is-off { color: var(--ink-3); }
.cell.is-idle { background: var(--cell-idle); border: 1px solid transparent; }
.cell.is-rec { background: var(--ok); border: 1px solid transparent; }
.cell.is-skeleton { background: var(--plate-2); border: 1px solid transparent; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: auto 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.stats div { min-width: 0; }
.stats dt { font-size: 0.75rem; color: var(--ink-3); }
.stats dd {
  margin: 2px 0 0;
  font: 500 1.25rem/1.2 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.stats dd small { font-size: 0.8125rem; color: var(--ink-3); }

.bay-error { margin: 0; font-size: 0.875rem; color: var(--ink-2); }

.bay-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--signal);
}
.arrow { display: inline-block; transition: transform 260ms var(--ease); }
.bay:hover .arrow { transform: translateX(4px); }

/* ---------- coming soon: a bay with the robot and nothing to open ---------- */
.bay.is-soon { border-style: dashed; cursor: default; }
.bay.is-soon:hover { transform: none; box-shadow: var(--shadow); border-color: var(--rule-strong); }
.bay.is-soon:active { transform: none; }
.bay.is-soon .bay-head { align-items: center; }
.soon-stamp {
  flex: none;
  padding: 3px 9px;
  border: 1px dashed var(--rule-strong);
  border-radius: 999px;
  font: 600 0.6875rem/1.2 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--signal);
}
.soon-note { margin: 0; align-self: end; font-size: 0.875rem; color: var(--ink-3); max-width: 46ch; }

/* Useful links: the small sites people forget, kept by admins in the
   dashboard (Admin, Links). A tile per link, the name first, the address
   under it so people learn it. */
.links-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 10px; }
.links h2 { margin: 0; font: 600 0.9375rem/1.3 var(--font-sans); color: var(--ink-2); }
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.link-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--plate);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 150ms var(--ease), transform 150ms var(--ease), box-shadow 150ms var(--ease);
}
.link-tile:hover { border-color: var(--signal); box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.link-tile:active { transform: translateY(0); }
.link-tile:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.link-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--signal-soft);
  color: var(--signal);
  font: 700 1rem/1 var(--font-display);
}
.link-img { object-fit: contain; padding: 3px; background: var(--plate); border: 1px solid var(--rule); }
.link-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.link-name { font: 600 0.9375rem/1.25 var(--font-sans); overflow-wrap: anywhere; }
.link-host { font: 500 0.75rem/1.2 var(--font-display); color: var(--signal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-note { font-size: 0.78rem; line-height: 1.3; color: var(--ink-3); }

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  font-size: 0.8125rem;
  color: var(--ink-3);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend .cell { width: 12px; height: 12px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- phones: no number keys ---------- */
@media (max-width: 767px) {
  .bay-key { display: none; }
}

/* ---------- the bays across the window ----------
   phone and small tablet: one bay a row, the model beside the floor once
   there is room; laptop: two across; wide screen: all four in a row. */
@media (min-width: 480px) and (max-width: 959px) {
  .bay { grid-template-columns: minmax(0, 1fr) minmax(180px, 38%); grid-template-rows: auto 1fr auto auto; column-gap: 20px; }
  .bay .model { grid-column: 2; grid-row: 1 / 3; aspect-ratio: auto; min-height: 200px; }
  .bay-title { grid-column: 1; grid-row: 1; }
  .bay .floor { grid-column: 1; grid-row: 2; }
  .bay .stats, .bay .bay-foot { grid-column: 1 / -1; }
  .bay.no-model { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 960px) {
  .bays { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* an odd last bay (five fleets) takes the full row instead of half of it */
  .bays > .bay:last-child:nth-child(odd) { grid-column: 1 / -1; }
  @supports (grid-template-rows: subgrid) {
    .bay { grid-row: span 5; grid-template-rows: subgrid; row-gap: 16px; }
  }
  .model { aspect-ratio: 16 / 9; max-height: 400px; }
}
@media (min-width: 1680px) {
  .bays { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bays > .bay:last-child:nth-child(odd) { grid-column: auto; }
  .model { aspect-ratio: 5 / 4; max-height: 420px; }
}
/* stats four across wherever a bay is wide enough (all bays share a width,
   so this stays a media query: a container on the bay would stop subgrid
   from sizing the shared rows in Chrome) */
@media (min-width: 600px) and (max-width: 959px), (min-width: 1160px) and (max-width: 1679px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .floor { --cell: 30px; gap: 6px; }
  .floor.is-few { --cell: 42px; gap: 8px; }
}

/* ---------- motion: entry in reading order, live state on the floor ---------- */
@media (prefers-reduced-motion: no-preference) {
  .intro > *, .bay, .links, .legend {
    animation: rise 700ms var(--ease) both;
  }
  .intro > :nth-child(2) { animation-delay: 60ms; }
  .intro > :nth-child(3) { animation-delay: 120ms; }
  .intro > :nth-child(4) { animation-delay: 160ms; }
  .bay { animation-delay: calc(200ms + var(--i, 0) * 90ms); }
  .links { animation-delay: 340ms; }
  .legend { animation-delay: 440ms; }

  /* cells light up across the floor the first time it is drawn */
  .floor.is-drawing .cell { animation: cell-in 520ms var(--ease) both; animation-delay: calc(var(--n, 0) * 14ms); }
  /* a recording station breathes: the only perpetual motion on the page */
  .cell.is-rec { animation: rec 2.4s ease-in-out infinite; }
  .floor.is-drawing .cell.is-rec { animation: cell-in 520ms var(--ease) both, rec 2.4s ease-in-out 600ms infinite; animation-delay: calc(var(--n, 0) * 14ms), 600ms; }
  .cell { transition: background-color 400ms var(--ease), border-color 400ms var(--ease); }
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes cell-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes rec {
  0%, 100% { box-shadow: 0 0 0 0 var(--ok-glow); }
  50% { box-shadow: 0 0 0 4px transparent; }
}

/* ---------- sign-in: the whole site is behind it ---------- */
/* What each state shows. "checking" (the token is being asked about) shows the
   welcome only, so nothing flashes from one state to the other. */
body:not([data-auth="in"]) .pulse,
body:not([data-auth="in"]) .bays,
body:not([data-auth="in"]) .links,
body:not([data-auth="in"]) .legend,
body:not([data-auth="in"]) .lede-in { display: none; }
body:not([data-auth="out"]) .gate,
body:not([data-auth="out"]) .lede-out { display: none; }

.bar-end { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who[hidden], body:not([data-auth="in"]) .who { display: none; }
.who { display: inline-flex; align-items: center; gap: 10px; min-width: 0; font-size: 0.8125rem; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14ch; }
.who-role {
  font: 500 0.6875rem/1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--signal);
  background: var(--signal-soft);
  border-radius: 4px;
  padding: 4px 6px;
}
.who-out {
  font: 500 0.8125rem/1 var(--font-sans);
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.who-out:hover { color: var(--ink); border-color: var(--rule-strong); }
.who-out:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }

.gate { display: grid; }
.gate-form {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 420px;
  padding: clamp(20px, 3vw, 28px);
  background: var(--plate);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
}
.gate-form[hidden] { display: none; }
.gate-form h2 { margin: 0 0 8px; font: 700 1.5rem/1.1 var(--font-display); letter-spacing: -0.02em; }
.gate-note { margin: -4px 0 8px; font-size: 0.875rem; color: var(--ink-2); }
.gate-form label { margin-top: 8px; font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.gate-form input {
  font: 400 1rem/1.4 var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 10px 12px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.gate-form input:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.gate-error { margin: 8px 0 0; font-size: 0.875rem; color: var(--crit); }
.gate-error[hidden] { display: none; }
.gate-submit {
  margin-top: 14px;
  font: 600 0.9375rem/1 var(--font-sans);
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}
.gate-submit:hover { opacity: 0.9; }
.gate-submit:active { transform: translateY(1px); }
.gate-submit:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.gate-submit[disabled] { opacity: 0.55; cursor: progress; }

/* The other way to sign in: a quiet line under the main button. */
.gate-alt { margin: 6px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); text-align: center; }
.gate-alt[hidden] { display: none; }
.gate-step { display: grid; gap: 6px; }
.gate-step[hidden] { display: none; }
.gate-hint { margin: 2px 0 0; font-size: 0.8125rem; color: var(--ink-3); }
.gate-sent { margin: 0 0 4px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); font-size: 0.875rem; color: var(--ink-2); }
.gate-sent b { color: var(--ink); overflow-wrap: anywhere; }
.gate-form input.gate-code { font: 600 1.375rem/1.2 var(--font-display); letter-spacing: 0.4em; }
.gate-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 2px 0 0; }
.gate-link { padding: 0; border: 0; background: none; font: 500 0.8125rem/1.4 var(--font-sans); color: var(--signal); cursor: pointer; }
.gate-link:hover { text-decoration: underline; }
.gate-link[disabled] { color: var(--ink-3); cursor: default; text-decoration: none; }
.gate-guides { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; max-width: 420px; margin-top: 14px; font-size: 0.8125rem; color: var(--ink-3); }
.gate-guides a { font-weight: 600; color: var(--signal); text-decoration: none; }
.gate-guides a:hover { text-decoration: underline; }
.gate-guides a:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 3px; }

@media (max-width: 767px) {
  .who-name, .who-role { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .gate-form { animation: rise 600ms var(--ease) both; animation-delay: 120ms; }
}
.who-cctv { text-decoration: none; display: inline-flex; align-items: center; }

/* ---------- view switch: List (the bays) or Factory (one 3D hall) ---------- */
.view-switch {
  display: inline-flex;
  margin-top: 20px;
  padding: 3px;
  gap: 2px;
  background: var(--plate-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.view-switch[hidden] { display: none; }
.view-switch button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-3);
  font: 600 0.8125rem/1 var(--font-sans);
  cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.view-switch svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.view-switch button:hover { color: var(--ink); }
.view-switch button[aria-pressed="true"] { background: var(--plate); color: var(--ink); box-shadow: var(--shadow); }
.view-switch button:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.view-switch button:active { transform: scale(0.98); }

body[data-view="factory"] .bays { display: none; }
body:not([data-view="factory"]) .factory,
body:not([data-auth="in"]) .factory,
body:not([data-auth="in"]) .view-switch { display: none; }

/* ---------- factory: the 3D hall with its zone list and panel over it ---------- */
.factory {
  position: relative;
  height: clamp(460px, 74vh, 900px);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--plate-2);
  box-shadow: var(--shadow);
}
.factory-scene { position: absolute; inset: 0; }
.factory-scene canvas { touch-action: none; }
.factory-loading {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--plate-2);
  font: 500 0.8125rem/1 var(--font-display);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3);
}
.factory-loading p { margin: 0; }
.factory-loading[hidden] { display: none; }
.factory-bar { width: min(260px, 60vw); height: 4px; border-radius: 999px; background: var(--rule); overflow: hidden; }
.factory-bar span {
  display: block; height: 100%; background: var(--signal);
  transform: scaleX(0); transform-origin: left; transition: transform 200ms linear;
}
.factory-robots {
  position: absolute; top: 14px; right: 14px; z-index: 2; margin: 0;
  padding: 7px 12px 7px 26px; border-radius: 999px;
  background: var(--plate); border: 1px solid var(--rule);
  font: 500 0.75rem/1 var(--font-display); color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.factory-robots::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
  border-radius: 50%; background: var(--signal); animation: factory-pulse 1s ease-in-out infinite alternate;
}
@keyframes factory-pulse { from { opacity: 0.3; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .factory-robots::before { animation: none; } .factory-bar span { transition: none; } }
.factory-robots[hidden] { display: none; }
.factory-label {
  margin: 0;
  font: 500 0.6875rem/1.2 var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.factory-zones, .factory-panel {
  position: absolute;
  /* solid, no backdrop blur: on macOS Chrome a blur over a live WebGL
     canvas makes the canvas drop frames and flash the plate behind it */
  background: var(--plate);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.factory-zones {
  top: 14px; left: 14px; z-index: 2;
  display: flex; flex-direction: column;
  padding: 6px;
  width: 200px;
  max-height: calc(100% - 28px);
}
.factory-zones-body { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding-top: 4px; }
.factory-zones[data-open="false"] .factory-zones-body { display: none; }
.factory-zones .factory-zones-head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 7px 8px;
}
.factory-zones-current {
  font: 600 0.8125rem/1.2 var(--font-sans); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
}
.factory-chevron { color: var(--ink-3); transition: transform 180ms var(--ease); }
.factory-zones[data-open="false"] .factory-chevron { transform: rotate(-90deg); }
.factory-zones[data-open="true"] .factory-zones-current { visibility: hidden; }
.factory-zones button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 7px 8px;
  border: 1px solid transparent; border-radius: 6px;
  background: none; color: var(--ink);
  font: 600 0.8125rem/1.2 var(--font-sans); text-align: left;
  cursor: pointer;
}
.factory-zones small { font: 500 0.75rem/1 var(--font-display); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.factory-zones .is-soon { color: var(--ink-2); }
.factory-zones .is-soon small { color: var(--signal); }
.factory-zones button:hover { background: var(--plate-2); }
.factory-zones button[aria-pressed="true"] { border-color: var(--signal); background: var(--signal-soft); }
.factory-zones button:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }
.factory-panel {
  right: 14px; bottom: 14px;
  width: min(300px, calc(100% - 28px));
  padding: 16px 18px 18px;
  display: grid; gap: 6px;
  box-shadow: var(--shadow-lift);
}
.factory-panel[hidden] { display: none; }
.factory-panel h2 { margin: 0; font: 700 1.75rem/1.05 var(--font-display); letter-spacing: -0.02em; }
.factory-sub { margin: 0 0 8px; color: var(--ink-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.factory-open {
  display: flex; justify-content: center; gap: 8px;
  padding: 11px 14px; border-radius: 8px;
  background: var(--ink); color: var(--paper);
  font: 600 0.875rem/1 var(--font-sans); text-decoration: none;
  transition: transform 160ms var(--ease);
}
.factory-open[hidden] { display: none; }
.factory-open:hover { transform: translateY(-1px); }
.factory-open:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.factory-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  margin: 0; padding: 7px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 78%, transparent); color: var(--paper);
  font-size: 0.75rem; white-space: nowrap; pointer-events: none;
}
.factory-panel:not([hidden]) ~ .factory-hint { display: none; }

/* phones: the zone list is a bottom sheet -- a handle bar naming the zone,
   pulled up into a two-column grid; the zone panel sits just above it */
/* Low / High graphics, top right; the robots count sits under it while loading */
.factory-quality {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--plate); border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: var(--shadow);
}
.factory-quality button {
  padding: 6px 12px; border: 0; border-radius: 6px;
  background: none; color: var(--ink-3);
  font: 600 0.75rem/1 var(--font-sans); cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease);
}
.factory-quality button:hover { color: var(--ink); }
.factory-quality button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.factory-quality button:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.factory-quality button:active { transform: scale(0.98); }
.factory-quality ~ .factory-robots { top: 56px; }

@media (max-width: 720px) {
  .factory { height: clamp(460px, 74vh, 680px); }
  .factory-quality { top: 10px; right: 10px; }
  .factory-quality button { min-height: 36px; padding: 6px 14px; }
  .factory-quality ~ .factory-robots { top: 58px; }
  .factory-zones {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 72%;
    border-radius: 14px 14px 0 0; border-width: 1px 0 0;
    padding: 4px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 24px rgb(15 23 42 / 0.12);
  }
  .factory-zones::before {
    content: ""; align-self: center; width: 36px; height: 4px; margin: 4px 0 2px;
    border-radius: 999px; background: var(--rule);
  }
  .factory-zones .factory-zones-head { padding: 8px 6px; min-height: 44px; }
  .factory-zones[data-open="true"] .factory-zones-current { visibility: visible; }
  .factory-zones[data-open="false"] .factory-chevron { transform: rotate(180deg); }
  .factory-zones-body { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .factory-zones-body button { min-height: 44px; align-items: center; }
  .factory-panel { right: 10px; left: 10px; bottom: 74px; width: auto; }
  .factory-zones[data-open="true"] ~ .factory-panel { display: none; }
  .factory-robots { top: 10px; right: 10px; }
  .factory-hint { display: none; }
}

/* the factory floor is the home page; the list opens from the control room,
   and only the way back is a button */
body[data-view="factory"] .view-switch,
.view-switch [data-view="list"] { display: none; }

/* ---------- footer: the company's registered name and number ---------- */
.site-foot {
  width: 100%;
  max-width: var(--stage-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: 16px calc(20px + env(safe-area-inset-bottom, 0px));
}
.site-foot p {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 0.8125rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
