/* Whiteboard: a full-bleed drafting table. Neutral tokens from Diego's portfolio
   (umbra/app/styles); color is reserved for the connection signal. */
:root {
  color-scheme: dark;
  --bg: #08090b;
  --text: #e6e4df;
  --muted: #a6a6ac;
  --soft: #d1d3d9;
  --accent: #c5c7ce;
  --line: rgba(255, 255, 255, 0.13);
  --panel: rgba(8, 9, 11, 0.86);
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --live: #7ccf8a;
  --offline: #e0705a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 11px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

:is(button, a):focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

/* The table: grid, ink and rulers stacked edge to edge. */
.table {
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
}

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.rulers,
.cursors,
.pen-ring,
.title-card,
.grain {
  pointer-events: none;
}

/* Cinematic finish: the portfolio's grain and a soft vignette over the whole table. */
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.15;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.55' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

.table::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 50% 48%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* The title card is printed on the sheet beneath the ink, then steps back once drawing starts. */
.title-card {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 9.5em;
  font-size: 100px;
  transform-origin: 0 0;
  transition: opacity 0.8s ease;
}

.title-card .eyebrow {
  display: block;
  margin-bottom: 0.2em;
  font-size: max(10px, 0.1em);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8e9097;
}

.title-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1em;
  line-height: 0.98;
  letter-spacing: -0.045em;
  color: var(--text);
}

.title-card h2 em {
  color: #bcbdc8;
  letter-spacing: -0.03em;
}

.title-card p {
  max-width: 34ch;
  margin: 1.1em 0 0;
  font-size: max(11px, 0.13em);
  line-height: 1.7;
  color: var(--muted);
}

.title-card.faint {
  opacity: 0.16;
}

.title-card.faint p {
  visibility: hidden;
}

.cursors {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Other visitors: a hairline cross and a small white label. */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  transition: transform 80ms linear;
  will-change: transform;
}

.cursor::before,
.cursor::after {
  content: "";
  position: absolute;
  background: var(--text);
}

.cursor::before {
  left: -6px;
  top: 0;
  width: 13px;
  height: 1px;
}

.cursor::after {
  left: 0;
  top: -6px;
  width: 1px;
  height: 13px;
}

.cursor span {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 1px 5px 2px;
  border-radius: 2px;
  background: var(--text);
  color: var(--bg);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pen-ring {
  position: absolute;
  left: 0;
  top: 0;
  border: 1px solid rgba(230, 228, 223, 0.6);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
}

@media (hover: hover) {
  .table:hover .pen-ring.on {
    opacity: 1;
  }
}

/* Title block, like the corner block on a drawing sheet. */
.title-block {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 248px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(6px);
}

.title-block h1 {
  margin: 0;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.title-block h1 span {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8e9097;
}

.title-block dl {
  display: grid;
  grid-template-columns: 74px 1fr;
  margin: 0;
}

.title-block dt,
.title-block dd {
  margin: 0;
  padding: 5px 12px;
  border-bottom: 1px solid var(--line);
}

.title-block dt {
  border-right: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8e9097;
}

.title-block dd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The visitor list truncates before it can push the connection status out of view. */
#present {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  flex-shrink: 0;
}

.title-block dt:nth-last-of-type(1),
.title-block dd:last-child {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6f7178;
}

.status[data-state="live"] i {
  background: var(--live);
}

.status[data-state="offline"] i {
  background: var(--offline);
}

/* Tiny floating toolbar. */
.toolbar {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(6px);
}

.group {
  display: flex;
  align-items: center;
  padding: 0 4px;
}

.group + .group {
  border-left: 1px solid var(--line);
}

.toolbar button {
  height: 30px;
  min-width: 28px;
  padding: 0 8px;
  border: 0;
  background: none;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}

.toolbar button:hover:not(:disabled),
.toolbar button[aria-checked="true"] {
  color: var(--text);
}

.toolbar button:disabled {
  color: #4b4d53;
  cursor: default;
}

.ink {
  display: grid;
  place-items: center;
}

.ink i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  outline: 1px solid transparent;
  outline-offset: 3px;
  transition: outline-color 0.2s;
}

.ink.eraser i {
  background: none;
  border: 1px dashed var(--muted);
}

.ink[aria-checked="true"] i {
  outline-color: var(--text);
}

.pen {
  position: relative;
}

.pen[aria-checked="true"]::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  height: 1px;
  background: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  padding: 3px 8px;
  border-radius: 2px;
  background: var(--text);
  color: var(--bg);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Phone: the title block moves to the top, the toolbar spans the bottom. */
@media (max-width: 760px) {
  .title-block {
    left: 30px;
    right: 12px;
    top: 30px;
    bottom: auto;
    width: auto;
  }

  .title-block dl {
    grid-template-columns: 70px 1fr;
  }

  .title-block dt,
  .title-block dd {
    padding: 4px 10px;
  }

  /* Touch has no hover position to read out. */
  .title-block dt:nth-last-of-type(1),
  .title-block dd:last-child {
    display: none;
  }

  .title-block dt:nth-last-of-type(2),
  .title-block dd:nth-last-child(3) {
    border-bottom: 0;
  }

  .toolbar {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    transform: none;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .toolbar .group:first-child {
    flex: 1 0 100%;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
  }

  .toolbar .group:nth-child(2) {
    border-left: 0;
  }

  .toolbar button {
    height: 40px;
    min-width: 36px;
  }

  .toast {
    bottom: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor,
  .title-card,
  .pen-ring,
  .toast,
  .toolbar button,
  .ink i {
    transition: none;
  }
}
