/* WebRTC log drawer + edge tab. Strict B&W. Slides in from right; the
   drawer respects the existing chrome heights (52px header, 44px footer
   per chrome.css). */

:root {
  --log-w: 400px;
  --log-z: 110;           /* above site-header/footer (z=100) */
  --page-shift: 0px;
}

/* When the drawer is open, the rest of the page shifts left to reveal it.
   Body margin shrinks the document width; fixed chrome (header, footer,
   modal backdrop) also pulls in from the right. Everything stays inside
   the new visible area. */
html.log-open { --page-shift: var(--log-w); }

body { margin-right: var(--page-shift); }
.site-header { right: var(--page-shift); }
.site-footer { right: var(--page-shift); }
.modal-backdrop { right: var(--page-shift); }

@media (prefers-reduced-motion: no-preference) {
  body,
  .site-header,
  .site-footer,
  .modal-backdrop {
    transition: margin-right 180ms ease, right 180ms ease;
  }
}

/* Mobile: drawer takes the whole viewport, so no shift — there's nothing
   to reveal underneath. The page stays put; the drawer covers it. */
@media (max-width: 480px) {
  html.log-open { --page-shift: 0px; }
}

.log-root {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;               /* container is non-interactive; children are */
  z-index: var(--log-z);
  pointer-events: none;
}

/* ===== Edge tab ===== */
.log-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--log-z);
  pointer-events: auto;
  background: white;
  color: black;
  border: 1px solid black;
  border-right: none;
  border-radius: 4px 0 0 4px;
  padding: 14px 4px;
  cursor: pointer;
  font-family: var(--font-mono, ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: background 0.12s ease, color 0.12s ease;
}
.log-tab:hover { background: black; color: white; }
.log-tab:focus-visible {
  outline: 2px solid black;
  outline-offset: 2px;
}

.log-tab-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 700;
}

/* ===== Drawer =====
   Slightly darker than the page (off-white) with a soft inset shadow on the
   left inner edge — gives the impression the page sits ABOVE the log, with
   the drawer recessed underneath. */
.log-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--log-w);
  min-width: 400px;
  max-width: 100vw;
  background: #f4f4f3;
  color: black;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  box-shadow: inset 10px 0 14px -6px rgba(0, 0, 0, 0.12);
  z-index: var(--log-z);
}

/* Resize handle on the left edge — grab and drag to widen. */
.log-resize {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 12px;
  cursor: ew-resize;
  z-index: 1;
  touch-action: none;
}
.log-resize::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 56px;
  border-radius: 2px;
  background: #888;
  opacity: 0.45;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.log-resize:hover::before,
.log-resize:active::before {
  opacity: 1;
  background: black;
}
.log-drawer[data-open="true"] {
  transform: translateX(0);
}

@media (prefers-reduced-motion: no-preference) {
  .log-drawer {
    transition: transform 180ms ease;
  }
}

.log-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-bottom: 1px solid #ddd;
  font-family: var(--font-mono);
}
.log-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
}
.log-close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: white;
  color: black;
  border: 1px solid black;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
}
.log-close:hover { background: black; color: white; }
.log-close:focus-visible {
  outline: 2px solid black;
  outline-offset: 2px;
}

/* ===== Feed ===== */
.log-feed {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  padding: 4px 0 12px;
}

.log-entry {
  border-bottom: 1px solid #e6e6e4;
}
.log-entry[data-expanded] { background: white; }

.log-row {
  display: grid;
  grid-template-columns: 64px 14px 1fr;
  grid-template-areas: "time glyph kind" "time glyph sum";
  gap: 0 8px;
  padding: 5px 12px;
  cursor: pointer;
}
.log-row:hover { background: #eaeae8; }

.log-time { grid-area: time; color: #888; font-size: 10px; align-self: center; }
.log-glyph { grid-area: glyph; align-self: center; text-align: center; }
.log-kind { grid-area: kind; color: #555; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.log-sum { grid-area: sum; color: black; word-break: break-word; }

.log-detail {
  margin: 0;
  padding: 6px 12px 10px 84px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
}

/* ===== Mobile: full-width drawer ===== */
@media (max-width: 480px) {
  .log-drawer { width: 100vw; min-width: 0; }
  .log-tab { padding: 12px 3px; }
  .log-resize { display: none; }
}
