/* Ding Web: whiteboards (whiteboard-board.js, whiteboard.js, whiteboard-play.js).
   The board on the theme's paper with a soft grid of dots, as the app draws it
   (WhiteboardCanvas); its editor over the whole window, its controls glass at
   its foot; a sent one's page in a chat, and it opened big. */

:root {
  --wb-paper: #FFFFFF;
  --wb-fill: #F2F2F7;
  --wb-dots: rgba(46, 50, 55, 0.13);
  --wb-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --wb-paper: #1E2227; --wb-fill: #2A2F36; --wb-dots: rgba(255, 255, 255, 0.12); }
}
:root[data-theme="dark"] { --wb-paper: #1E2227; --wb-fill: #2A2F36; --wb-dots: rgba(255, 255, 255, 0.12); }

/* MARK: The board */

.wb-board {
  --wb-ink: var(--ink);
  position: relative; width: 100%; aspect-ratio: 4 / 5; overflow: hidden; isolation: isolate;
  color: var(--wb-ink); background: var(--wb-paper); border-radius: 6%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 10%, transparent);
  -webkit-user-select: none; user-select: none;
}
.wb-space { position: absolute; left: 0; top: 0; width: 1000px; height: 1250px; transform-origin: 0 0; }
.wb-paper {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 25px 25px, var(--wb-dots) 0 1.6px, transparent 2px);
  background-size: 50px 50px;
}
.wb-items { position: absolute; inset: 0; }
.wb-item { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; will-change: transform; }
.wb-face { position: absolute; inset: 0; font-family: var(--wb-font); }
.wb-face img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.wb-face svg { stroke-width: 2; }
.wb-pic { border-radius: 26px; overflow: hidden; background: var(--wb-fill); }
.wb-pic::after, .wb-link::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--wb-ink) 8%, transparent);
}
.wb-blank { position: absolute; inset: 0; background: var(--wb-fill); }
.wb-sticker img { object-fit: contain; }
.wb-play {
  position: absolute; left: 50%; top: 50%; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.42); display: grid; place-items: center; color: #fff;
}
.wb-play svg { width: 38px; height: 38px; fill: currentColor; stroke: none; margin-left: 4px; }
.wb-link { border-radius: 26px; overflow: hidden; background: var(--wb-fill); display: flex; flex-direction: column; }
.wb-link-pic { position: relative; flex: 1; min-height: 0; }
.wb-link-pic img { position: absolute; inset: 0; }
.wb-band { flex: none; height: 110px; display: flex; align-items: center; gap: 10px; padding: 0 22px; font-size: 32px; font-weight: 600; line-height: 1.15; }
.wb-band svg { width: 32px; height: 32px; flex: none; }
.wb-band span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.wb-file { border-radius: 26px; background: var(--wb-fill); display: flex; align-items: center; gap: 16px; padding: 0 28px; font-size: 34px; font-weight: 600; line-height: 1.2; }
.wb-file svg { width: 56px; height: 56px; flex: none; }
.wb-file span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.wb-words { display: grid; place-items: center; padding: 8px; text-align: center; font-size: 46px; font-weight: 600; line-height: 1.2; overflow: hidden; }
.wb-words span { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.wb-note { padding: 30px; background: var(--wb-fill); border-radius: 22px; }
.wb-lines { position: absolute; left: 0; top: 0; width: 1000px; height: 1250px; pointer-events: none; }

/* MARK: The editor */

.wbe {
  position: fixed; inset: 0; z-index: 80; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  background: var(--mist-1); color: var(--ink);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.wbe-glass, .wbe-round, .wbe-x, .wbe-turn {
  background: var(--glass-strong); -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid var(--glass-edge); box-shadow: var(--shadow);
}
.wbe-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px 8px; position: relative; }
.wbe-title { position: absolute; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; max-width: calc(100% - 220px); }
.wbe-title b { font-size: 16px; }
.wbe-sub { font-size: 12px; color: var(--steel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: inline-flex; align-items: center; gap: 5px; }
.wbe-sub.live { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.wbe-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: wbe-breathe 1.4s ease-in-out infinite; }
@keyframes wbe-breathe { 50% { opacity: 0.35; } }
.wbe-top [data-w="undo"] { margin-left: auto; }
.wbe-round {
  width: 44px; height: 44px; flex: none; border-radius: 999px; display: grid; place-items: center; padding: 0;
  color: var(--ink); cursor: pointer; transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.wbe-round svg { width: 19px; height: 19px; stroke-width: 2; }
.wbe-round.big { width: 52px; height: 52px; }
.wbe-round.big svg { width: 21px; height: 21px; }
.wbe-round.small { width: 32px; height: 32px; box-shadow: none; }
.wbe-round.small svg { width: 14px; height: 14px; stroke-width: 2.4; }
.wbe-round.on { background: var(--ink); color: var(--on-ink); border-color: transparent; }
.wbe-round:disabled, .wbe-record:disabled, .wbe-done:disabled { opacity: 0.38; cursor: default; }
.wbe-round:active:not(:disabled), .wbe-record:active:not(:disabled), .wbe-done:active:not(:disabled) { transform: scale(0.94); }
[data-w="play"] svg { fill: currentColor; stroke: none; margin-left: 2px; }

.wbe-stage { display: grid; place-items: center; min-height: 0; padding: 4px 12px; }
.wbe-box { position: relative; touch-action: none; }
.wbe-box.drawing { cursor: crosshair; }
.wbe-box .wb-item { cursor: grab; }
.wbe-box .wb-item:active { cursor: grabbing; }
.wbe-box.drawing .wb-item, .wbe-box.previewing .wb-item { cursor: inherit; }
.wbe-board { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 10%, transparent), var(--shadow); }
/* The one picked out: a dashed line round it, as thin whatever its size. */
.wb-item.wb-picked::before {
  content: ""; position: absolute; inset: -6px; z-index: 1; pointer-events: none; border-radius: 28px;
  border: calc(2px * var(--k, 1)) dashed var(--wb-ink); opacity: 0.85;
}
.wbe-handles { position: absolute; inset: 0; pointer-events: none; }
.wbe-x, .wbe-turn {
  position: absolute; left: 0; top: 0; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 999px;
  display: grid; place-items: center; padding: 0; pointer-events: auto; cursor: pointer; color: var(--ink);
}
/* The small × at its top right, as on everything else in Ding. */
.wbe-x { background: var(--ink); color: var(--on-ink); border-color: transparent; }
.wbe-x svg { width: 13px; height: 13px; stroke-width: 2.6; }
.wbe-turn { cursor: nwse-resize; touch-action: none; }
.wbe-turn svg { width: 14px; height: 14px; stroke-width: 2.3; }
.wbe-hint {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 0 12%; text-align: center; pointer-events: none;
  color: var(--steel); font-size: 15px; font-weight: 500; line-height: 1.4;
}

.wbe-foot { position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px 16px calc(14px + var(--wbe-keyboard, 0px)); }
.wbe-over {
  position: absolute; left: 0; right: 0; bottom: 100%; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 0 16px 6px; pointer-events: none;
}
.wbe-over > * { pointer-events: auto; }
.wbe-problem {
  margin: 0; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink); text-align: center; max-width: 520px;
  background: var(--glass-strong); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.wbe-bar { display: flex; align-items: center; justify-content: center; gap: 14px; }
.wbe-record {
  position: relative; width: 68px; height: 68px; border-radius: 999px; border: 0; padding: 0; display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); cursor: pointer; box-shadow: var(--shadow); transition: transform 0.15s ease, background 0.2s ease;
}
.wbe-record svg { width: 26px; height: 26px; stroke-width: 2; }
.wbe-record.recording { background: var(--danger); color: #fff; }
.wbe-record.recording svg { fill: currentColor; stroke: none; width: 24px; height: 24px; }
.wbe-again {
  position: absolute; top: -2px; right: -2px; width: 24px; height: 24px; border-radius: 999px; display: grid; place-items: center;
  background: var(--mist-1); color: var(--ink); box-shadow: 0 0 0 1px var(--hair);
}
.wbe-again svg { width: 13px; height: 13px; stroke-width: 2.6; }
.wbe-done {
  width: 52px; height: 52px; border-radius: 999px; border: 0; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow); transition: transform 0.15s ease;
}
.wbe-done svg { width: 22px; height: 22px; stroke-width: 2.6; }
.wbe-tools, .wbe-picked { display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 999px; }
.wbe-tools button {
  width: 46px; height: 46px; border-radius: 999px; border: 0; background: none; color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.wbe-tools button svg { width: 20px; height: 20px; stroke-width: 1.9; }
.wbe-tools button.on { background: var(--ink); color: var(--on-ink); }
.wbe-picked button {
  height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: none; color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 14px; font-weight: 600;
}
.wbe-picked button:hover, .wbe-tools button:hover:not(.on) { background: var(--soft); }
.wbe-picked button svg { width: 17px; height: 17px; stroke-width: 2; }
.wbe-tray {
  position: absolute; z-index: 3; left: 50%; bottom: calc(10px + var(--wbe-keyboard, 0px)); transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 90px - var(--wbe-keyboard, 0px)); overflow: auto;
  border-radius: 26px; padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 10px;
}
.wbe-tray-head { display: flex; align-items: center; gap: 8px; }
.wbe-tray-head b { flex: 1; font-size: 15px; padding-left: 6px; }
.wbe-words-field { height: auto; min-height: 56px; padding: 12px 14px; resize: none; font: inherit; line-height: 1.4; }
.wbe-seg { display: flex; padding: 3px; border-radius: 999px; background: var(--soft); }
.wbe-seg button { flex: 1; height: 32px; border: 0; border-radius: 999px; background: none; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.wbe-seg button[aria-checked="true"] { background: var(--glass-strong); box-shadow: var(--shadow); }
.wbe-menu { z-index: 90; }
/* +'s menu and its trays (adding.js, add-tray.js) over the board. */
body:has(> .wbe) .ding-menu { z-index: 90; }
body:has(> .wbe) .add-tray.floating, body:has(> .wbe) .add-tray.lifted { z-index: 85; }
.wbe button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

@media (max-width: 520px) {
  /* 16 px, or a phone zooms in as it's written in. */
  .wbe .field { font-size: 16px; }
  .wbe-top { padding: 8px 12px 6px; }
  .wbe-title { max-width: calc(100% - 180px); }
  .wbe-bar { gap: 10px; }
  .wbe-round.big, .wbe-done { width: 48px; height: 48px; }
  .wbe-record { width: 62px; height: 62px; }
  .wbe-tools button { width: 42px; height: 42px; }
  .wbe-foot { padding: 6px 12px 10px; gap: 8px; }
}

/* MARK: In a chat */

.wb-page {
  position: relative; display: block; width: min(300px, 64vw); aspect-ratio: 4 / 5; padding: 0; border: 0; cursor: pointer;
  border-radius: 22px; overflow: hidden; background: var(--wb-paper); color: var(--ink); isolation: isolate;
  box-shadow: inset 0 0 0 1px var(--hair);
}
.wb-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wb-cover-blank { background: var(--wb-paper); }
.wb-live { position: absolute; inset: 0; display: none; }
.wb-page.playing .wb-live { display: block; }
.wb-live .wb-board { border-radius: 0 !important; box-shadow: none; }
.wb-badge {
  position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink);
  background: var(--glass-strong); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--glass-edge); box-shadow: var(--shadow);
}
.wb-badge svg { width: 11px; height: 11px; fill: currentColor; stroke: none; }
.wb-page:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* MARK: Opened big */

.wbv { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; padding: 16px; }
.wbv-scrim { position: absolute; inset: 0; background: rgba(12, 14, 18, 0.32); }
.wbv-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 16px; border-radius: 30px; max-width: 100%;
  background: var(--glass-strong); -webkit-backdrop-filter: blur(28px) saturate(1.6); backdrop-filter: blur(28px) saturate(1.6);
  border: 1px solid var(--glass-edge); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 24px 70px rgba(10, 12, 16, 0.35);
}
.wbv-head { display: flex; align-items: center; gap: 10px; }
.wbv-mark { width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; background: var(--soft); flex: none; }
.wbv-mark svg { width: 18px; height: 18px; stroke-width: 2; }
.wbv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.wbv-title b { font-size: 16px; }
.wbv-title span { font-size: 13px; color: var(--steel); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wbv-btn { width: 36px; height: 36px; border-radius: 999px; border: 0; background: var(--soft); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.wbv-btn svg { width: 15px; height: 15px; stroke-width: 2.4; }
.wbv-board { position: relative; align-self: center; }
.wbv-host { width: 100%; }
.wbv-board .wb-item[data-place] { cursor: pointer; }
.wbv-picture { display: block; width: 100%; border-radius: 6%; }
.wbv-wait { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; }
.wbv-wait i { width: 26px; height: 26px; border-radius: 999px; border: 2.5px solid var(--hair); border-top-color: var(--ink); animation: wbv-turn 0.8s linear infinite; }
@keyframes wbv-turn { to { transform: rotate(360deg); } }
.wbv-controls { display: flex; align-items: center; gap: 12px; }
.wbv-play { width: 40px; height: 40px; border-radius: 999px; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.wbv-play svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.wbv-scrub { flex: 1; min-width: 0; accent-color: var(--ink); }
.wbv-time { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--steel); white-space: nowrap; }
.wbv button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .wbe-dot { animation: none; }
}
