/* Gipity Graffiti — wall, header, editor, notes, cursors */

:root {
  --paper: #f7f5ef;
  --paper-line: #e4e0d4;
  --ink: #1f2937;
  --card-bg: rgba(247, 245, 239, 0.82);
  --card-border: rgba(31, 41, 55, 0.18);
  --accent: #2563eb;
  --header-h: 52px;
  --wall-w: 3840px;
  --wall-h: 2160px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

/* ---------- Header (fixed) ---------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--paper-line);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  font-size: 14px;
}
#topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
#topbar .logo { font-size: 20px; }
#topbar .name { font-weight: 700; letter-spacing: 0.2px; }
#topbar .hint { color: #6b7280; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar .presence { display: flex; align-items: center; gap: 14px; flex: none; }
#topbar .stat { font-variant-numeric: tabular-nums; white-space: nowrap; }
#topbar .conn {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 999px; font-weight: 600;
}
#topbar .conn[data-state="live"]        { background: #dcfce7; color: #166534; }
#topbar .conn[data-state="reconnecting"]{ background: #fef9c3; color: #854d0e; }
#topbar .conn[data-state="offline"]     { background: #fee2e2; color: #991b1b; }

@media (max-width: 640px) {
  #topbar .hint { display: none; }
}

/* ---------- Wall ---------- */
#wall {
  position: relative;
  width: var(--wall-w);
  height: var(--wall-h);
  margin-top: var(--header-h);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 40px 40px;
  cursor: text;
}
#notes, #ghosts, #cursors {
  position: absolute;
  inset: 0;
  pointer-events: none; /* notes re-enable their own */
}

/* ---------- A saved note ---------- */
.note {
  position: absolute;
  max-width: 360px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  line-height: 1.3;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-wrap: balance;
  pointer-events: auto;
  transform-origin: top left;
}
.note.pop { animation: note-pop 0.9s ease-out; }
@keyframes note-pop {
  0%   { transform: scale(0.6); background: #fde68a; }
  35%  { transform: scale(1.06); background: #fef08a; }
  100% { transform: scale(1); background: var(--card-bg); }
}

/* ---------- Ghost (someone else typing) ---------- */
.ghost {
  position: absolute;
  max-width: 360px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed rgba(31, 41, 55, 0.5);
  line-height: 1.3;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  pointer-events: none;
  animation: ghost-pulse 1.4s ease-in-out infinite;
}
@keyframes ghost-pulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

/* ---------- Live cursors ---------- */
.cursor {
  position: absolute;
  width: 18px; height: 18px;
  pointer-events: none;
  transition: transform 0.08s linear;
  will-change: transform;
  z-index: 900;
}
.cursor svg { display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }
.cursor .label {
  position: absolute; left: 16px; top: 12px;
  font-size: 10px; padding: 1px 5px; border-radius: 4px; color: #fff;
  white-space: nowrap;
}

/* ---------- Editor ---------- */
#editor {
  position: absolute;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
}
#editor textarea {
  min-width: 220px;
  max-width: 380px;
  width: 280px;
  min-height: 2.2em;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  resize: none;
  outline: none;
  line-height: 1.3;
  overflow: hidden;
  font-family: inherit;
}
#editor .toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--paper-line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  font-size: 12px;
  color: #374151;
  width: max-content;
  max-width: 380px;
  flex-wrap: wrap;
}
#editor .toolbar label { display: flex; align-items: center; gap: 4px; }
#editor .toolbar input[type="range"] { width: 92px; }
#editor .toolbar input[type="color"] {
  width: 26px; height: 24px; padding: 0; border: 1px solid #d1d5db;
  border-radius: 5px; background: none; cursor: pointer;
}
#editor .toolbar .bold-toggle {
  font-weight: 700; width: 26px; height: 24px; border-radius: 5px;
  border: 1px solid #d1d5db; background: #fff; cursor: pointer;
}
#editor .toolbar .bold-toggle[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
#editor .toolbar .count { font-variant-numeric: tabular-nums; color: #6b7280; }
#editor .toolbar .count.over { color: #dc2626; font-weight: 700; }
#editor .toolbar button.post {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 4px 12px; cursor: pointer; font-weight: 600;
}
#editor .toolbar button.post:disabled { opacity: 0.45; cursor: not-allowed; }
#editor .toolbar button.cancel {
  background: none; border: none; cursor: pointer; color: #6b7280; font-size: 15px; line-height: 1;
}

/* ---------- Jump-to-latest ---------- */
#jump-latest {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}
#jump-latest:hover { filter: brightness(1.06); }
