/* ============ 多人模式 ============ */

:root {
  /* 折角下面露出的一小片 Normal 玉米蛇皮 */
  --scale-a: #d9824a;
  --scale-b: #b8341f;
  --flap-a: #f7f7f7;
  --flap-b: #c9c9c9;
  --pop: #ffffff;
  --pop-line: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --flap-a: #3a3a3a;
    --flap-b: #262626;
    --pop: #2a2a2a;
    --pop-line: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

/* 折角不能挡住导航 */
.topbar {
  position: relative;
  padding-right: max(var(--gutter), 96px);
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- 右上角折角 ---------- */

.curl {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 15;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(-2px 3px 3px rgba(0, 0, 0, 0.18));
  transition: width 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), height 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.curl:hover,
.curl:focus-visible {
  width: 72px;
  height: 72px;
}

.curl:focus-visible {
  outline: none;
}

.curl span {
  position: absolute;
  inset: 0;
}

/* 折角下面露出来的“另一面”：一小片蛇鳞 */
.curl__under {
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  background:
    radial-gradient(circle at 50% 0, transparent 38%, var(--scale-b) 40% 52%, transparent 54%) 0 0 / 10px 10px,
    radial-gradient(circle at 50% 0, transparent 38%, var(--scale-b) 40% 52%, transparent 54%) 5px 5px / 10px 10px,
    var(--scale-a);
}

.curl__flap {
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  background: linear-gradient(45deg, var(--flap-b) 20%, var(--flap-a) 70%);
}

body.is-live .curl {
  display: none;
}

/* ---------- 确认弹窗 ---------- */

.live-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.28);
  animation: live-fade 0.18s ease-out;
}

.live-dialog__card {
  width: min(360px, 100%);
  padding: 24px;
  background: var(--pop);
  box-shadow: var(--shadow);
  animation: live-rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.live-dialog__who {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.live-dialog__id {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.live-dialog__name {
  font-weight: 600;
}

.live-dialog__genes {
  color: var(--muted);
  font-size: 12px;
}

/* 父母和这一窝的概率 */
.litter {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  font-size: 12px;
}

.litter__title {
  color: var(--muted);
}

.litter__parent {
  display: flex;
  align-items: center;
  gap: 8px;
}

.litter__sex {
  width: 12px;
  color: var(--muted);
}

.litter__odds {
  padding-top: 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.litter__odds b {
  color: var(--text);
}

.live-dialog__reroll {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.live-dialog__reroll:hover {
  color: var(--text);
}

.live-dialog h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.live-dialog p {
  margin: 0 0 20px;
  color: var(--muted);
}

.live-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  padding: 7px 16px;
  border: 1px solid var(--line);
  background: none;
  cursor: pointer;
}

.btn--primary {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* ---------- 头像 ---------- */

.avatar {
  display: inline-block;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.avatar svg {
  display: block;
}

.avatar--lg {
  width: 52px;
  height: 52px;
}

.avatar--sm {
  width: 22px;
  height: 22px;
}

/* ---------- 蛇鳞加载页 ---------- */

.live-loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  transition: opacity 0.45s ease;
}

.live-loader canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.live-loader__label {
  position: absolute;
  left: 50%;
  bottom: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  background: var(--pop);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  white-space: nowrap;
  transition: bottom 0.5s cubic-bezier(0.2, 0.9, 0.3, 1), transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* 孵化好了：提示框移到屏幕中间，出现“点击进入” */
.live-loader.is-ready .live-loader__label {
  bottom: 50%;
  padding-right: 8px;
  transform: translate(-50%, 50%);
}

.live-loader__go {
  margin-left: 4px;
  padding: 6px 14px;
  border: 0;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  animation: live-rise 0.3s ease-out;
}

.live-loader.is-done {
  opacity: 0;
  pointer-events: none;
}

/* ---------- 多人层 ---------- */

/* 不在任何卡片上的位置，挂在这一层（按视口比例定位） */
.live-page {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.live-page > * {
  pointer-events: auto;
}

body.is-live .rail {
  padding-top: 36px;
}

body.is-commenting,
body.is-commenting * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26'%3E%3Cpath d='M2 24V13a11 11 0 1 1 11 11z' fill='%23fff' stroke='%23000' stroke-width='1.5'/%3E%3Cpath d='M13 8v10M8 13h10' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") 2 24, crosshair;
}

body.is-commenting .live-ui,
body.is-commenting .live-ui *,
body.is-commenting .thread,
body.is-commenting .thread *,
body.is-commenting .pin {
  cursor: auto;
}

body.is-commenting .pin,
body.is-commenting .live-ui button,
body.is-commenting .thread button {
  cursor: pointer;
}

/* 别人的光标 */
.cursor {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  transition: left 0.08s linear, top 0.08s linear;
}

.cursor svg {
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.cursor__label {
  position: absolute;
  top: 16px;
  left: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--c);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  width: max-content;
  max-width: 240px;
}

.cursor__chat {
  display: block;
  max-width: 220px;
  margin-top: 2px;
  font-size: 14px;
  white-space: normal;
  word-break: break-word;
}

.cursor__chat:empty {
  display: none;
}

/* 自己的光标聊天输入框 */
.cursor-chat {
  position: fixed;
  z-index: 40;
  padding: 4px 10px;
  border: 0;
  border-radius: 12px;
  outline: none;
  background: var(--c);
  color: #fff;
  font: 14px/1.4 var(--font);
  width: 220px;
}

.cursor-chat::placeholder {
  color: rgba(255, 255, 255, 0.75);
}

/* Figma 式评论图钉：左下角是尖的，尖角指向评论的位置 */
.pin {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid var(--c);
  border-radius: 50% 50% 50% 0;
  background: var(--pop);
  box-shadow: var(--shadow);
  cursor: pointer;
  transform: translateY(-100%);
  transform-origin: 0 100%;
  animation: pin-drop 0.25s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.pin:hover,
.pin.is-open {
  z-index: 7;
  transform: translateY(-100%) scale(1.15);
}

.pin .avatar {
  width: 24px;
  height: 24px;
}

.pin__count {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 10px;
  line-height: 16px;
}

.pin--draft {
  opacity: 0.85;
}

/* 评论线程浮层 */
.thread {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 300px;
  max-height: min(420px, calc(100vh - 32px));
  background: var(--pop);
  box-shadow: var(--shadow);
  animation: live-rise 0.16s ease-out;
}

.thread__list {
  overflow-y: auto;
}

.msg {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--pop-line);
}

.msg .avatar {
  grid-row: span 2;
}

.msg__head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
}

.msg__name {
  font-weight: 600;
}

.msg__time {
  color: var(--muted);
  font-size: 12px;
}

.msg__text {
  grid-column: 2 / 4;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg__del {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.msg__del:hover {
  color: #e5484d;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
}

.composer textarea {
  flex: 1;
  min-height: 22px;
  max-height: 120px;
  padding: 2px 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
  resize: none;
}

.composer button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}

.composer button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* 底部工具栏 */
.live-ui {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--pop);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  animation: live-rise 0.3s ease-out;
  white-space: nowrap;
}

.tool {
  display: grid;
  place-items: center;
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
}

.tool:hover {
  color: var(--text);
}

.tool[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

.live-ui__sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--line);
}

.presence {
  display: flex;
  align-items: center;
  padding: 0 6px;
}

.presence .avatar {
  margin-left: -6px;
  box-shadow: 0 0 0 2px var(--pop);
}

.presence .avatar:first-child {
  margin-left: 0;
}

.presence__more {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
}

.live-ui__status {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.live-ui__status:empty {
  display: none;
}

.live-toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  z-index: 70;
  padding: 8px 14px;
  background: var(--text);
  color: var(--bg);
  transform: translateX(-50%);
  animation: live-rise 0.2s ease-out;
}

@keyframes live-fade {
  from {
    opacity: 0;
  }
}

@keyframes live-rise {
  from {
    opacity: 0;
    translate: 0 6px;
  }
}

@keyframes pin-drop {
  from {
    opacity: 0;
    scale: 0.3;
  }
}

@media (max-width: 640px) {
  .thread {
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: 64px;
    width: auto;
  }

  .tool__hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .curl,
  .cursor,
  .live-dialog,
  .live-dialog__card,
  .pin,
  .thread,
  .live-ui {
    transition: none;
    animation: none;
  }
}
