/*
  R78-PLACE: created for Return 78 (June 2026), an r/place clone event.
  Everything tagged R78-PLACE is one-off event code.
  After the event ends:
    - delete this repo (the r78 greenfield), and
    - delete the vets-deploy stack at stacks/r78-place/.
  Search-tag: R78-PLACE.
*/

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #1a1a1a;
  color: #eee;
}

.polite-bar {
  background: #ffd84a;
  color: #222;
  padding: 0.6rem 1rem;
  text-align: center;
  border-bottom: 2px solid #b89500;
  font-size: 0.95rem;
}
.polite-bar code {
  background: rgba(0, 0, 0, 0.12);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}
.polite-bar .ws-status-banner { display: none; }
.polite-bar.disconnected {
  background: #d9534f;
  color: #fff;
  border-bottom-color: #8b3a37;
}
.polite-bar.disconnected .polite-content { display: none; }
.polite-bar.disconnected .ws-status-banner { display: inline; }
.polite-bar.disconnected code {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

main {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

#auth-pane {
  max-width: 420px;
  margin: 4rem auto;
  padding: 1.5rem;
  background: #262626;
  border: 1px solid #333;
  border-radius: 6px;
}
#auth-pane h2 { margin-top: 0; }
#auth-form { display: flex; gap: 0.5rem; }
#auth-form input { flex: 1; padding: 0.5rem; border: 1px solid #444; background: #1a1a1a; color: #eee; border-radius: 4px; }
#auth-form button { padding: 0.5rem 1rem; background: #4a90e2; color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
.error { color: #f66; margin-top: 0.5rem; }

#canvas-pane {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.canvas-wrap {
  background: #2a2a2a;
  padding: 8px;
  border-radius: 4px;
}

.canvas-stage {
  position: relative;
  width: 640px;
  height: 640px;
}

.canvas-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #fff;
  cursor: crosshair;
  width: 100%;
  height: 100%;
}

.canvas-controls { display: none; }

.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--cell, 10px) - 1px),
      rgba(128, 128, 128, 0.45) calc(var(--cell, 10px) - 1px),
      rgba(128, 128, 128, 0.45) var(--cell, 10px)
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--cell, 10px) - 1px),
      rgba(128, 128, 128, 0.45) calc(var(--cell, 10px) - 1px),
      rgba(128, 128, 128, 0.45) var(--cell, 10px)
    );
}

.toggle-row {
  font-size: 0.85rem;
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.toggle-row label { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.toggle-row input { accent-color: #4a90e2; }

.side {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.palette button {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
}
.palette button.selected {
  border-color: #fff;
  box-shadow: 0 0 0 1px #000;
}

.budget {
  background: #262626;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  font-size: 0.9rem;
}

.status {
  min-height: 1.5em;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
}
.status.error { background: #5a2222; color: #ffb3b3; }
.status.info  { background: #224a5a; color: #b3e0ff; }
.status.warn  { background: #5a4422; color: #ffd99c; }

.meta {
  font-size: 0.8rem;
  color: #999;
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
}

.bot-token-pane {
  margin-top: 0.75rem;
  background: #262626;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  width: 640px;
}
.bot-token-pane label {
  display: block;
  font-size: 0.8rem;
  color: #b8b8b8;
  margin-bottom: 0.35rem;
}
.token-row {
  display: flex;
  gap: 0.4rem;
}
.token-row input {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid #444;
  background: #1a1a1a;
  color: #eee;
  border-radius: 4px;
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  font-size: 0.8rem;
}
.token-row button {
  padding: 0.4rem 0.8rem;
  background: #4a90e2;
  color: #fff;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.token-row button.copied { background: #2e8b3a; }

/* admin-page-specific styles live in admin.html inline; no admin classes here */

/* === Mobile (≤768px) overrides ============================================ */
/* Desktop layout above is the source of truth; the rules below only change
   what's needed to make the canvas + side panel usable on a phone. */
@media (max-width: 768px) {
  main {
    padding: 0.5rem;
  }
  .polite-bar {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    text-align: left;
  }
  .polite-bar code {
    word-break: break-all;
  }
  #canvas-pane {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
  }
  .canvas-wrap {
    width: 100%;
    padding: 4px;
  }
  .canvas-stage {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }
  #canvas {
    width: 100%;
    height: 100%;
    touch-action: manipulation;
  }
  .canvas-column {
    display: contents;
  }
  .bot-token-pane {
    width: 100%;
    order: 99;
  }
  .token-row input {
    min-width: 0;
  }
  .side {
    width: 100%;
  }
  .canvas-stage {
    overflow: hidden;
  }
  .canvas-inner {
    width: calc(100% * var(--zoom, 1));
    height: calc(100% * var(--zoom, 1));
    transform-origin: 0 0;
  }
  #canvas {
    touch-action: manipulation;
  }
  .canvas-controls {
    display: grid;
    gap: 0.5rem;
    background: #262626;
    padding: 0.5rem;
    border-radius: 4px;
  }
  .canvas-controls .ctrl-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    justify-content: center;
  }
  .canvas-controls .ctrl-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    max-width: 220px;
    margin: 0 auto;
  }
  .canvas-controls .empty {
    visibility: hidden;
  }
  .canvas-controls button {
    padding: 0.55rem 0;
    background: #3a3a3a;
    color: #eee;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.15rem;
    min-height: 40px;
    font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  }
  .canvas-controls button:active {
    background: #4a90e2;
    border-color: #4a90e2;
  }
  #zoom-readout {
    font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
    font-size: 1rem;
    color: #ccc;
    min-width: 3em;
    text-align: center;
  }
  .palette {
    gap: 6px;
  }
  .palette button {
    width: 100%;
    height: 36px;
  }
  .budget,
  .status {
    font-size: 0.95rem;
    padding: 0.6rem 0.75rem;
  }
}
