/* =========================================================
   小学生タブレットコース3～6年生 おためしコンテンツ
   サイズ・位置はステージ幅基準（cqw）と % で指定する。
   ========================================================= */

:root {
  --navy: #0b3a8f;
  --glow: #ffb26b;                    /* 押せる場所の光（薄いオレンジ） */
  --glow-soft: rgba(255, 178, 107, .7);
  --glow-halo: rgba(255, 140, 40, .35);
  --glow-halo-strong: rgba(255, 140, 40, .7);
  --callout: #f5a623;
  --letterbox: #0f2350;
  --panel: #fcfdfe;
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--letterbox);
  color: #222;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Meiryo", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

button { font: inherit; }

/* ルビ（漢字の上に表示） */
ruby { ruby-position: over; }

rt {
  font-size: .5em;
  font-weight: 500;
  line-height: 1;
}

/* 読みが漢字より長いとき、漢字の間が空かないよう詰める */
.ruby-tight rt { letter-spacing: -.1em; }

/* ---------- ステージ ---------- */

.app {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  container-type: inline-size;
  user-select: none;
  -webkit-user-select: none;
}

.stage__bg,
.screen__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --x/--y/--w/--h（%）で配置する要素 */
.hotspot,
.schedule,
.screen__panel,
.card-link {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
}

/* ---------- タップ領域 ---------- */

.hotspot {
  z-index: 3;
  padding: 0;
  border: 0;
  border-radius: calc(var(--r, 1.2) * 1cqw);  /* --r でボタンの角の丸みに合わせる */
  background: transparent;
  cursor: pointer;
}

.hotspot:active,
.card-link:active { background: rgba(255, 178, 107, .18); }

.hotspot:focus-visible,
.card-link:focus-visible {
  outline: .25cqw solid var(--navy);
  outline-offset: .2cqw;
}

/* 押せる場所を光らせる */
.glow::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  animation: glow 1.8s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 .15cqw var(--glow-soft), 0 0 .8cqw .2cqw var(--glow-halo); }
  50%      { box-shadow: 0 0 0 .3cqw var(--glow), 0 0 2.2cqw .6cqw var(--glow-halo-strong); }
}

@media (prefers-reduced-motion: reduce) {
  .glow::after {
    animation: none;
    box-shadow: 0 0 0 .3cqw var(--glow), 0 0 1.6cqw .4cqw var(--glow-halo-strong);
  }

  .pointer__target,
  .pointer__line { animation: none; stroke-dashoffset: 0; }

  .callout,
  .medal-pop { animation: none; opacity: 1; }
}

/* ---------- ③ レッスン一覧 ---------- */

.schedule {
  z-index: 2;
  background: var(--panel);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.schedule::-webkit-scrollbar { display: none; }

.schedule__sheet {
  position: relative;
  display: block;
  width: 100%;
}

.schedule__sheet img { display: block; width: 100%; }

.card-link { border-radius: .9cqw; }

/* ---------- 画面（モーダル） ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  animation: fade-in .2s ease-out;
}

.screen[hidden],
.screen [hidden] { display: none; }

.screen__backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.screen__panel { z-index: 2; }

.screen--dialog .screen__backdrop { background: rgba(8, 24, 64, .5); }

/*
  吹き出し：対象を枠で囲む → 線が伸びる → 吹き出しが出る、の順に表示する。
  --d は開始までの遅延。--x/--y は線がつながる点で、吹き出しのどの辺をそこに合わせるかを
  callout--l（左辺の中央）/ --r（右辺）/ --t（上辺）/ --b（下辺）で指定する。
*/
.pointer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.pointer__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pointer__target,
.pointer__line {
  fill: none;
  stroke: var(--callout);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.pointer__target {
  stroke-width: 4;
  animation: draw .8s var(--d, 0s) ease-in-out forwards;
}

.pointer__line {
  stroke-width: 3;
  animation: draw .6s calc(var(--d, 0s) + .75s) ease-in-out forwards;
}

.callout {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  margin: 0;
  padding: 1cqw 1.6cqw;
  border: .22cqw solid var(--callout);
  border-radius: .6cqw;
  background: #fff;
  box-shadow: 0 .4cqw 1.2cqw rgba(0, 0, 0, .18);
  color: #333;
  font-size: 1.45cqw;
  font-weight: 700;
  line-height: 1.85;
  text-align: center;
  white-space: nowrap;
  transform: translate(var(--tx), var(--ty));
  transform-origin: var(--origin);
  animation: pop .5s calc(var(--d, 0s) + 1.35s) cubic-bezier(.2, 1.3, .4, 1) both;
}

.callout--l { --tx: 0;     --ty: -50%;  --origin: left center; }
.callout--r { --tx: -100%; --ty: -50%;  --origin: right center; }
.callout--t { --tx: -50%;  --ty: 0;     --origin: center top; }
.callout--b { --tx: -50%;  --ty: -100%; --origin: center bottom; }

/* メダルが1つずつ増えるアニメーション（main.js で生成） */
.medal-anim {
  position: absolute;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
}

.medal-slot,
.medal-slot > span {
  position: absolute;
  background-repeat: no-repeat;
}

/* 円形に切り抜く（四角い切り出しの角が背景のグラデーションと合わずに見えるのを防ぐ） */
.medal-slot > span {
  inset: 0;
  border-radius: 50%;
}

.medal-pop {
  opacity: 0;
  animation: medal-pop .5s calc(.4s + var(--i) * var(--step)) cubic-bezier(.2, 1.6, .4, 1) forwards;
}

@keyframes medal-pop {
  0%   { opacity: 0; transform: scale(.2) rotate(-25deg); filter: brightness(1.6); }
  60%  { opacity: 1; filter: brightness(1.4); }
  100% { opacity: 1; transform: none; filter: none; }
}

@keyframes draw { to { stroke-dashoffset: 0; } }

/* 文言モーダル */
.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 46cqw;
  padding: 2.6cqw 3.2cqw 2.2cqw;
  border-radius: 1.4cqw;
  background: #fff;
  box-shadow: 0 1cqw 3cqw rgba(0, 0, 0, .25);
  font-size: 1.55cqw;
  line-height: 1.95;
  transform: translate(-50%, -50%);
  animation: pop-center .3s cubic-bezier(.2, 1.3, .4, 1) both;
}

.dialog p { margin: 0 0 .8em; }

.dialog strong { color: var(--navy); }

.dialog__title {
  margin: 0 0 1.4cqw;
  color: var(--navy);
  font-size: 2cqw;
  text-align: center;
}

.dialog__img {
  display: block;
  width: 60%;
  height: auto;
  margin: 0 auto 1.4cqw;
}

.dialog__close {
  display: block;
  width: 60%;
  margin: 1.6cqw auto 0;
  padding: .9cqw 0;
  border: 0;
  border-radius: .6cqw;
  background: var(--navy);
  color: #fff;
  font-size: 1.5cqw;
  font-weight: 700;
  cursor: pointer;
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(var(--tx, 0), var(--ty, 0)) scale(.6); } }
@keyframes pop-center { from { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }

/* ---------- スマホ縦向きの案内 ---------- */

.rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  background: var(--letterbox);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.rotate p { margin: 0; }

.rotate__icon {
  width: 48px;
  height: 80px;
  border: 4px solid #fff;
  border-radius: 10px;
  animation: rotate-hint 2.4s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 25%   { transform: rotate(0); }
  50%, 75%  { transform: rotate(-90deg); }
  100%      { transform: rotate(0); }
}

@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  .rotate { display: flex; }
  .app { display: none; }
}
