/* オンライン支援のボードゲーム＆1on1ツール：どのツールでも使う土台（ボタン・ふきだし・たぎっくま・説明の窓） */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ol,
ul {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* 語のまとまりの途中で改行させない */
.nw {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 24px;
  border: var(--border);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--edge);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease, background-color var(--t-fast) ease;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line);
}

.btn svg {
  flex: none;
  width: 22px;
  height: 22px;
}

.btn--primary {
  background: var(--green-deep);
  color: #fff;
}

.btn--small {
  min-height: 44px;
  padding: 6px 16px;
  font-size: 15px;
  box-shadow: 0 3px 0 var(--line);
}

.btn.is-done {
  background: var(--cream-deep);
}

@media (hover: hover) {
  .btn:hover {
    background: var(--cream-deep);
  }

  .btn--primary:hover {
    background: var(--green-shade);
  }
}

/* ---------- たぎっくま ---------- */

.kuma-img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* ひとことが変わったときの、小さなジャンプ */
.kuma-hop {
  animation: kuma-hop 360ms var(--ease-out);
}

@keyframes kuma-hop {
  40% {
    transform: translateY(-9%);
  }
}

:root[data-motion="reduce"] .kuma-hop {
  animation: none;
}

/* ---------- ふきだし ----------
   使い方: <p class="bubble"><span class="bubble__in">ひとこと</span></p>

   線は「こげ茶の形」の上に「ひとまわり小さい白い形」を重ねて作る（border は使わない）。
   こげ茶どうし・白どうしを大きく重ねてあるだけなので、本体としっぽの「つなぎ目」がそもそも無く、
   画面の倍率が変わってもずれない。
   （本体の線としっぽの線を別々に描いて位置を合わせる方法は、倍率によってずれたのでやめた）

   ボタンやカードとちがって「押せるもの」ではないので、厚み（下の影）は付けない。

   調整用の値:
   --bubble-r  角の丸み。しっぽの付け根が角の丸みにかかると矢印のような形になるので、
               「ふきだしの高さ − 丸み×2」が、しっぽの付け根（--tail の約1.1倍）より大きくなるようにする
   --tail      しっぽの大きさ
   --tail-y    ふきだしの下のふちから、しっぽのまんなかまでの高さ（話している相手の口もとに合わせる）
   --bubble-pad 文字のまわりのすき間（文字は行の中で少し下に出るので、上を下より2px小さくしてある） */

.bubble {
  --bubble-r: 16px;
  --tail: 13px;
  --tail-y: 24px;
  position: relative;
  padding: 2px; /* これが線の太さになる */
  border-radius: var(--bubble-r);
  background: var(--line);
}

.bubble__in {
  position: relative;
  z-index: 1;
  display: block;
  padding: var(--bubble-pad, 7px 16px 9px);
  border-radius: calc(var(--bubble-r) - 2px);
  background: var(--paper);
  line-height: 1.6;
  word-break: auto-phrase; /* 対応しているブラウザでは、文節の切れ目で折り返す */
}

/* しっぽ（左向き）。四角を45度まわしたもの。こげ茶と白で同じ形を、線の太さのぶんだけずらして重ねる。
   高さは、背の低いふきだしではまんなか、背の高いふきだしでは --tail-y に合わせる */
.bubble::before,
.bubble__in::before {
  content: "";
  position: absolute;
  width: var(--tail);
  height: var(--tail);
  transform: rotate(45deg);
}

.bubble::before {
  bottom: min(calc(50% - var(--tail) / 2), calc(var(--tail-y) - var(--tail) / 2));
  left: calc(var(--tail) * -0.36);
  border-bottom-left-radius: 3px;
  background: var(--line);
}

.bubble__in::before {
  bottom: min(calc(50% - var(--tail) / 2), calc(var(--tail-y) - var(--tail) / 2 - 2px));
  left: calc(var(--tail) * -0.36 + 0.83px);
  border-bottom-left-radius: 1.5px;
  background: var(--paper);
}

/* ---------- 説明の窓 ---------- */

.sheet {
  width: min(880px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 3px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 8px 0 var(--line);
  overflow: auto;
}

.sheet::backdrop {
  background: rgba(42, 26, 14, 0.55);
}

.sheet[open] {
  animation: sheet-in 260ms var(--ease-back);
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
}

:root[data-motion="reduce"] .sheet[open] {
  animation: none;
}
