/*
 * 試し引き（kujis/_trial_draw）の券。
 *
 * 券の外枠とめくる仕組みはくじカス箱（box.css・box_controller.js）をそのまま使う。
 * めくって出てくる面だけ、くじカス占いの結果面（fortune.css の .fortune-result）の作りと色に寄せる（運営の判断。2026-11）。
 * 占いは実物のくじ券に寄せてあるので、こちらも同じ見え方にする。ミシン目・上の青い帯の見出し・墨色の面に白い大きな字・右下の注記。
 * 外枠は藍（くじカス箱と同じ）なので、券を見れば占い（赤い外枠）とは分かれる。
 * 上位賞だけ、占いの「神引き」と同じく帯と面が金になる（めくった端から金がのぞいたら上位賞）。
 *
 * 共通化はしない。占いと箱は本番で動いていて、触ると壊す（box.css と同じ方針）。
 */

/* ---------- iPhone で券の中身が消える不具合の手当て ----------
   試し引きの券はシート（スクロールする枠）の中にある。iPhone の Safari は、スクロールする枠の中の
   transform-style: preserve-3d を正しく描けず、めくる前の面・ミシン目・つまみ・結果がまるごと消えて、
   外枠しか見えなかった（めくり終えた瞬間に初めて出る。運営の画面収録。2026-11-15）。
   占いとくじカス箱はページにそのまま置いてあるので起きない。
   試し引きの券だけ立体をやめて、z-index の重ね順で描く。めくれる紙は少し平たく見えるが、めくる動きは同じ */
.trial-stage .box-holder { perspective: none; }

.trial-stage .box-ticket,
.trial-stage .box-window {
  transform-style: flat;
}

/* 立体をやめると、めくれて立ち上がるはずの紙が平たく結果に重なり、めくっている間と開き切る直前に
   結果が隠れてチラついた（運営の画面収録。2026-11-15）。試し引きでは紙を出さず、銀のめくれ目だけを動かす。
   結果はめくった端からそのまま見える */
.trial-stage .box-paper { display: none; }

/* 引くたびに券が透明から現れると、前の券が消えて白く光ったように見えた。透明にはせず、少しずれて止まるだけにする */
.trial-stage.is-drawn .box-holder {
  animation: trial-appear .28s ease both;
}

@keyframes trial-appear {
  from { transform: translateY(-6px) scale(1.02); }
  to   { transform: none; }
}

/* ミシン目。めくれる窓の縁に重ねる */
.trial-perforation {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  z-index: 21;
  overflow: visible;
  pointer-events: none;
}

.trial-perforation path {
  fill: none;
  stroke: rgb(255 255 255 / .48);
  stroke-width: 1.3;
  stroke-dasharray: 5 6;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* ---------- 結果面 ---------- */
.trial-result {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-radius: 2px;
  background: #29292c;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .16);
}

/* 上の帯。占いと同じ青 */
.trial-result-top {
  display: flex;
  align-items: center;
  height: 23%;
  padding: 0 13px;
  background: #168bd1;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .04em;
}

.trial-result-body {
  position: absolute;
  left: 0;
  right: 0;
  top: 23%;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 15px;
  color: #fff;
}

/* まず目に入る賞の記号。「A賞」と「フォト風カード＆ステッカー賞」が同じ券に載るので、
   長さで大きさを変える（--trial-rank-size は trial_draw_controller.js が決める） */
.trial-result-rank {
  flex: 0 0 auto;
  font-size: var(--trial-rank-size, 84px);
  font-weight: 900;
  line-height: .95;
  letter-spacing: -.03em;
  white-space: nowrap;
}

/* 「A賞」の「賞」。実物の券は記号が面いっぱいに大きく、「賞」はその右下に 4 分の 1 ほどの大きさで付く（運営が撮った実券。2026-11）。
   同じ大きさだと漢字のほうが大きく見えた */
.trial-result-suffix {
  font-size: .27em;
  margin-left: .06em;
  letter-spacing: 0;
}

.trial-result-copy {
  min-width: 0;
}

/* 賞の名前。実物の券に合わせて 20px（運営が撮った実券で、名前の 1 行の高さは面の幅の 6% ほど。2026-11）。
   実物は「いずく：オリジン／MASTERLISE」のように正式な品名を 2 行に組むので、縮めずに折り返す。
   折る位置は、空白・「＆」・「・」・「/」・閉じカッコの後ろ（JavaScript が <wbr> を入れる）を優先し、
   そこで折れない長い語だけ語の途中で折る。行の長さはそろえて、1 文字だけ次の行に落ちないようにする
   （そのまま折ったら「モンスターヘッドマグネッ／ト」になった）。面に収まらない長さのときだけ字を小さくする */
.trial-result-name {
  font-size: var(--trial-name-size, 20px);
  font-weight: 900;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.trial-result-note {
  position: absolute;
  right: 9px;
  bottom: 5px;
  font-size: 5px;
  font-weight: 800;
  color: #aaa;
}

/* 賞の記号が長いくじは、記号を上に置いて名前を下に回す（横に並べると名前が入らない） */
.trial-result.is-long .trial-result-body {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
}

.trial-result.is-long .trial-result-rank {
  white-space: normal;
  line-height: 1.15;
}

/* 上位賞：占いの「神引き」と同じ金。帯は金、面は金の光が差す暗い地 */
.trial-result.is-top {
  background:
    radial-gradient(circle at 30% 52%, rgb(255 224 111 / .16), transparent 30%),
    radial-gradient(circle at 72% 50%, rgb(255 224 111 / .14), transparent 30%),
    linear-gradient(135deg, #332d1b, #171717 68%);
}

.trial-result.is-top .trial-result-top {
  background: linear-gradient(90deg, #d8a52d, #f3d66f, #c99118);
  color: #191919;
}

.trial-result.is-top .trial-result-rank {
  background: linear-gradient(180deg, #fff3c4 0%, #f3d66f 55%, #d8a52d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}


/* ---------- 上位賞の「キラン」 ----------
   占いの金の結果（fortune.css の .is-effect-gold）と同じ演出。めくり終えたら一度だけ、
   券の周りに金のオーラが灯り、券の上を光が走り、面がふわっと弾む。画面全体は光らせない */
.trial-aura {
  position: absolute;
  inset: -18px;
  z-index: 17;
  opacity: 0;
  border-radius: 10px;
  pointer-events: none;
  filter: blur(1px);
  background:
    radial-gradient(circle at 33% 50%, rgb(255 209 73 / .30), transparent 30%),
    radial-gradient(circle at 70% 50%, rgb(255 235 140 / .30), transparent 30%);
}

.trial-sheen {
  position: absolute;
  inset: 0;
  z-index: 17;
  overflow: hidden;
  opacity: 0;
  border-radius: 6px;
  pointer-events: none;
}

.trial-sheen::before {
  content: "";
  position: absolute;
  top: -40%;
  bottom: -40%;
  left: -45%;
  width: 32%;
  transform: skewX(-17deg);
  background: linear-gradient(90deg,
    transparent,
    rgb(255 255 255 / .16),
    rgb(255 255 255 / .72),
    rgb(255 255 255 / .12),
    transparent);
}

.box-stage.is-revealed .box-ticket.is-won .trial-aura {
  animation: trial-aura 1.35s ease-out .10s both;
}

.box-stage.is-revealed .box-ticket.is-won .trial-sheen { opacity: 1; }

.box-stage.is-revealed .box-ticket.is-won .trial-sheen::before {
  animation: trial-sheen 1.05s cubic-bezier(.18, .72, .2, 1) .18s both;
}

.box-stage.is-revealed .trial-result.is-top {
  animation: trial-card-pop .72s cubic-bezier(.18, .9, .26, 1) .08s both;
}

.box-stage.is-revealed .trial-result.is-top .trial-result-name {
  animation: trial-name-pop .7s cubic-bezier(.15, 1.2, .24, 1) .16s both;
}

@keyframes trial-aura {
  0% { opacity: 0; transform: scale(.96); }
  34% { opacity: .95; transform: scale(1.015); }
  100% { opacity: .38; transform: scale(1); }
}

@keyframes trial-sheen {
  0% { left: -45%; opacity: 0; }
  18% { opacity: 1; }
  100% { left: 115%; opacity: 0; }
}

@keyframes trial-card-pop {
  0% { transform: scale(.94); filter: brightness(.82) saturate(.9); }
  42% { transform: scale(1.035); filter: brightness(1.22) saturate(1.18); }
  100% { transform: scale(1); filter: brightness(1) saturate(1); }
}

@keyframes trial-name-pop {
  0% { transform: scale(.82); opacity: .45; }
  42% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .box-stage.is-revealed .box-ticket.is-won .trial-aura,
  .box-stage.is-revealed .box-ticket.is-won .trial-sheen::before,
  .box-stage.is-revealed .trial-result.is-top,
  .box-stage.is-revealed .trial-result.is-top .trial-result-name {
    animation: none;
  }
}
