/* Two knobs, two units. Cards, gaps and card text are sized in --u, which is
   1vmin times the operator's card scale; the centre panel (QR, logo,
   headline, tagline) is sized in --p, 1vmin times the QR scale. vmin is the
   smaller viewport side, so the same CSS keeps its proportions on a 1080p TV,
   a 4K wall, a projector or a portrait LED column, with no pixel caps. The
   knobs are independent: "can they scan it from the back" and "can they read
   the cards" are different questions. See display.js for the controls. */
:root {
  --scale: 1;
  --qr-scale: 1;
  --u: calc(1vmin * var(--scale));              /* cards */
  --p: calc(1vmin * var(--qr-scale));           /* centre panel */
  --gap: calc(1.2 * var(--u));
  --edge: calc(1.6 * var(--u));
  --card-min: calc(28 * var(--u));              /* min card column width */
  --qr: calc(30 * var(--p));                    /* QR image side */
  --hair: max(1px, calc(0.1 * var(--u)));       /* hairline that survives 4K */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--brand-bg);
  color: var(--brand-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}
body.idle { cursor: none; }

/* 3x3 grid: the centre panel owns the middle cell and sets the middle row's
   height; the four zones around it take whatever is left and tile cards
   into it. Nothing ever renders underneath the QR. */
.wall {
  display: grid;
  width: 100%;
  height: 100%;
  padding: var(--edge);
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas:
    "top    top    top"
    "left   center right"
    "bottom bottom bottom";
}

.zone {
  /* Size containment: a zone's cards never push the grid around (that is what
     used to squash the top/bottom bands to nothing) — the zone is exactly the
     space the grid gives it, and display.js only keeps cards that fit. */
  contain: size;
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: var(--gap);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
.zone-top    { grid-area: top; }
.zone-left   { grid-area: left; }
.zone-right  { grid-area: right; }
.zone-bottom { grid-area: bottom; align-content: end; }

.card {
  background: rgba(255, 255, 255, 0.07);
  border: var(--hair) solid rgba(255, 255, 255, 0.12);
  border-radius: calc(1.3 * var(--u));
  padding: calc(1.4 * var(--u)) calc(1.6 * var(--u));
  min-width: 0;
}
.card.fresh { animation: pop 0.5s ease both; }
.card .reason {
  font-size: calc(2.2 * var(--u));
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .name {
  margin-top: calc(0.7 * var(--u));
  font-size: calc(1.5 * var(--u));
  color: var(--brand-primary);
  font-weight: 700;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(calc(1.4 * var(--u))) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

.center {
  grid-area: center;
  align-self: center;
  justify-self: center;
  text-align: center;
  width: calc(var(--qr) + 8 * var(--p));
  max-width: calc(100vw - 2 * var(--edge));
  background: rgba(0, 0, 0, 0.6);
  border: var(--hair) solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  border-radius: calc(2.4 * var(--p));
  padding: calc(2.4 * var(--p)) calc(2.6 * var(--p));
  box-shadow: 0 calc(2 * var(--p)) calc(6 * var(--p)) rgba(0, 0, 0, 0.55);
}
.center .logo {
  max-height: calc(7 * var(--p));
  max-width: 80%;
  margin-bottom: calc(1.4 * var(--p));
}
.headline {
  font-size: calc(3 * var(--p));
  margin: 0 0 calc(1.6 * var(--p));
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.qr-wrap {
  background: #fff;
  padding: calc(1.5 * var(--p));
  border-radius: calc(1.4 * var(--p));
  display: inline-block;
  max-width: 100%;
}
.qr {
  display: block;
  width: var(--qr);
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
}
.tagline {
  margin: calc(1.6 * var(--p)) 0 0;
  font-size: calc(1.8 * var(--p));
  opacity: 0.85;
}

/* Operator overlays: small, out of the way, never scaled below legibility. */
.badge {
  position: fixed;
  z-index: 20;
  font-size: max(12px, calc(1.3 * var(--u)));
  line-height: 1.4;
  padding: 0.45em 1em;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}
.reconnect {
  top: var(--edge);
  right: var(--edge);
  background: rgba(220, 60, 60, 0.92);
}
.hud {
  left: var(--edge);
  bottom: var(--edge);
  opacity: 0.92;
}
.hud b { font-weight: 700; }
.hud .url { opacity: 0.75; margin-left: 1em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.hud .keys { opacity: 0.6; margin-left: 1em; }
.hidden { display: none; }
