/* © 2026 Targle’s Apps. All rights reserved. */
/* SparQED Circuits — layout.
 * Sizes come from app.js, which measures the real screen and sets
 * --u (base unit, from the shorter screen side) and --gap. Nothing here
 * uses fixed pixel sizes. */
:root {
  --u: 16px;
  --gap: 10px;
  --ink: #1f2933;
  --muted: #6b7682;
  --bg: #eef1f5;
  --panel: #ffffff;
  --line: #d5dbe3;
  --accent: #1d3557;
  --accent-soft: #e3ebf6;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(var(--gap) + env(safe-area-inset-top)) calc(var(--gap) + env(safe-area-inset-right))
           calc(var(--gap) + env(safe-area-inset-bottom)) calc(var(--gap) + env(safe-area-inset-left));
  gap: var(--gap);
  font-size: var(--u);
}

/* Toolbar */
#bar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--gap);
}
.brand { font-weight: 600; color: var(--accent); margin-right: auto; letter-spacing: 0.01em; white-space: nowrap; }
.brand b { color: #e07a1f; }
.brand small { display: block; font-size: 0.6em; font-weight: 400; color: var(--muted); letter-spacing: 0; }
button {
  font: inherit; color: var(--ink);
  background: var(--panel); border: 0.08em solid var(--line);
  border-radius: 0.6em; padding: 0.5em 0.8em;
  cursor: pointer; touch-action: manipulation;
}
button:disabled { opacity: 0.4; cursor: default; }
.group { display: inline-flex; border: 0.08em solid var(--line); border-radius: 0.6em; overflow: hidden; background: var(--panel); }
.group button { border: 0; border-radius: 0; }
.group button + button { border-left: 0.08em solid var(--line); }
.group button.on, .toggle.on { background: var(--accent); color: #fff; }
.mode button[data-mode="test"].on { background: #2a7a4b; }

/* Main area: drawer + views. app.js sets flex-direction for the screen shape. */
#main { flex: 1; min-height: 0; display: flex; gap: var(--gap); }
#main.landscape { flex-direction: row; }
#main.portrait { flex-direction: column-reverse; }

#drawer {
  display: flex; gap: var(--gap);
  background: var(--panel); border: 0.08em solid var(--line); border-radius: 0.8em;
  padding: var(--gap);
}
#main.landscape #drawer { flex-direction: column; }
#main.portrait #drawer { flex-direction: row; }
.part-item {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 0.6em; touch-action: none; cursor: grab;
  color: var(--muted); font-size: 0.78em; text-align: center; line-height: 1.15;
}
.part-item:active { background: var(--accent-soft); }
.part-item.armed { background: var(--accent-soft); box-shadow: inset 0 0 0 0.12em var(--accent); color: var(--accent); }
.part-item svg { width: 100%; flex: 1; min-height: 0; pointer-events: none; }
.part-item span { pointer-events: none; padding-top: 0.2em; }

#views { flex: 1; min-width: 0; min-height: 0; display: flex; gap: var(--gap); position: relative; }
#views.row { flex-direction: row; }
#views.col { flex-direction: column; }
.pane { flex: 1; min-width: 0; min-height: 0; display: flex; }
.pane[hidden] { display: none; }
svg.view { width: 100%; height: 100%; touch-action: none; display: block; }

#ghost {
  position: fixed; pointer-events: none; z-index: 20;
  transform: translate(-50%, -50%); opacity: 0.85;
}
#ghost svg { width: 100%; height: 100%; }

/* Takeover */
#takeover {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  padding: var(--gap);
  pointer-events: auto;
}
#takeover[hidden] { display: none; }
#takeover .card {
  background: #ffffff; border: 0.1em solid #9db4d6; border-radius: 1em;
  box-shadow: 0 0.4em 1.6em rgba(29, 53, 87, 0.25);
  padding: 1em 1.2em; width: 100%; max-width: 34em;
  font-size: 1.1em; line-height: 1.4;
  animation: rise 0.35s ease-out;
}
#takeover p { margin: 0 0 0.8em; }
#takeover button { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
@keyframes rise { from { transform: translateY(1em); opacity: 0; } to { transform: none; opacity: 1; } }

#toast {
  position: absolute; left: 50%; top: var(--gap); transform: translateX(-50%);
  background: rgba(31, 41, 51, 0.88); color: #fff; z-index: 11;
  padding: 0.5em 0.9em; border-radius: 0.6em; font-size: 0.9em;
  pointer-events: none; white-space: nowrap;
}
#toast[hidden] { display: none; }

/* SVG drawing classes */
.ring { fill: none; stroke: #2f80ed; stroke-width: 0.12; animation: pulse 1s ease-in-out infinite; }
.ring-fill { fill: rgba(47, 128, 237, 0.25); }
@keyframes pulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: 0.35; } }
.dimmed { opacity: 0.18; }
.readout { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
