@charset "UTF-8";

/* ==========================================================================
   Blue Logic Kids - UI Overrides
   ========================================================================== */

/* 1. Parent-theme M3 Token Overrides (Pastel Palette, sky preset default)
   --------------------------------------------------------------------------
   Blue Logic（親）は Tailwind の alpha-modifier 構文のために、色トークンを
   "RGB 空白区切りトリプレット" の CSS 変数（例: --primary-container-rgb: 214 235 255）
   として公開しています。Tailwind ユーティリティ bg-primary-container 等は
   rgb(var(--primary-container-rgb) / <alpha-value>) を解決するため、
   子テーマで色を差し替える際もこの「*-rgb」変数名・RGB 空白区切り形式を使います。
   ========================================================================== */
:root {
  --primary-container-rgb:      214 235 255;  /* #d6ebff */
  --on-primary-container-rgb:   0 56 101;     /* #003865 */

  --secondary-container-rgb:    255 243 196;  /* #fff3c4 */
  --on-secondary-container-rgb: 92 74 0;      /* #5c4a00 */

  --tertiary-container-rgb:     255 217 228;  /* #ffd9e4 */
  --on-tertiary-container-rgb:  92 24 56;     /* #5c1838 */

  --surface-container-rgb:      247 249 252;  /* #f7f9fc */
  --outline-variant-rgb:        215 224 236;  /* #d7e0ec */
}

.dark {
  --primary-container-rgb:      26 58 92;     /* #1a3a5c */
  --on-primary-container-rgb:   214 235 255;  /* #d6ebff */

  --secondary-container-rgb:    74 67 34;     /* #4a4322 */
  --on-secondary-container-rgb: 255 243 196;  /* #fff3c4 */

  --tertiary-container-rgb:     74 35 51;     /* #4a2333 */
  --on-tertiary-container-rgb:  255 217 228;  /* #ffd9e4 */

  --surface-container-rgb:      35 38 44;     /* #23262c */
  --outline-variant-rgb:        59 66 76;     /* #3b424c */
}

/* 2. Typography
   ========================================================================== */
html, body {
  font-family: "M PLUS Rounded 1c", system-ui, -apple-system, sans-serif;
  font-feature-settings: "palt";
  line-height: 1.8;
  letter-spacing: 0.02em;
}

h1, h2, h3 { font-weight: 800; }
p, li { font-weight: 500; }

ruby {
  ruby-align: center;
}
rt {
  font-size: 0.6em;
  color: rgb(var(--on-surface-variant-rgb));
  font-weight: 700;
}

/* 3. Border Radii (Pill / Extreme Rounded)
   ========================================================================== */
.wp-block-button__link,
.button,
button[type="submit"] {
  border-radius: 9999px !important;
}

article.post, 
.card, 
.tool-card { 
  border-radius: 1.5rem; 
}

.wp-block-image img,
.post-thumbnail img { 
  border-radius: 1.25rem; 
}

input[type="text"],
input[type="email"],
input[type="number"],
textarea, select {
  border-radius: 1rem;
  padding: 0.75rem 1rem;
}

/* 4. Accessibility & Layout
   ========================================================================== */
:focus-visible {
  outline: 3px solid #ffd54f;
  outline-offset: 2px;
  border-radius: inherit;
}

a, button, [role="button"] { 
  min-height: 44px; 
}

.site-main > * + * { 
  margin-top: 1.5rem; 
}

/* Quiz Specific Fixes */
.kids-quiz-choice {
  transition: all 0.2s ease-in-out;
}
.kids-quiz-choice:hover {
  transform: translateY(-2px);
}
.kids-quiz-explain {
  animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   PHASE 1: 形状の遊び（シェイプ & ステッカー感）
   ========================================================================== */

/* 5-1. 見出し形状（body クラスでスキン切替）
   ------------------------------------------------------------------
   body.kids-heading-ribbon    … 既定。リボン切れ込み
   body.kids-heading-cloud     … もこもこ雲形（"スイート・まほう"）
   body.kids-heading-tag       … 付箋タグ形（"ゆうやけ"）
   body.kids-heading-underline … 下線のみのミニマル（"ミント"中学生向け）
*/

/* --- Ribbon（既定） --- */
body.kids-heading-ribbon .entry-content h2 {
  position: relative;
  display: inline-block;
  background: rgb(var(--primary-container-rgb));
  color: rgb(var(--on-primary-container-rgb));
  padding: 0.5em 1.25em 0.5em 1em;
  border-radius: 9999px 0 0 9999px;
  margin-left: 0;
  margin-right: 0;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.06);
}
body.kids-heading-ribbon .entry-content h2::after {
  content: "";
  position: absolute;
  right: -16px;
  top: 0;
  width: 0;
  height: 0;
  border-top: 1.2em solid rgb(var(--primary-container-rgb));
  border-bottom: 1.2em solid rgb(var(--primary-container-rgb));
  border-right: 16px solid transparent;
}

/* --- Cloud（もこもこ雲形） --- */
body.kids-heading-cloud .entry-content h2 {
  position: relative;
  display: inline-block;
  background: rgb(var(--primary-container-rgb));
  color: rgb(var(--on-primary-container-rgb));
  padding: 0.6em 1.6em;
  margin-left: 0;
  border-radius: 2rem 2rem 2rem 2rem / 60% 60% 60% 60%;
  box-shadow:
    -10px 0 0 -2px rgb(var(--primary-container-rgb)),
    10px 0 0 -2px rgb(var(--primary-container-rgb)),
    0 6px 0 rgba(0,0,0,0.05);
}
body.kids-heading-cloud .entry-content h2::before {
  content: "☁";
  margin-right: 0.3em;
  opacity: 0.65;
}

/* --- Tag（付箋タグ形） --- */
body.kids-heading-tag .entry-content h2 {
  position: relative;
  display: inline-block;
  background: rgb(var(--primary-container-rgb));
  color: rgb(var(--on-primary-container-rgb));
  padding: 0.45em 1.2em 0.45em 1.6em;
  margin-left: 0.6em;
  border-radius: 0 0.8rem 0.8rem 0;
  box-shadow: 0 4px 0 rgba(0,0,0,0.06);
}
body.kids-heading-tag .entry-content h2::before {
  content: "";
  position: absolute;
  left: -0.6em;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 1.1em solid transparent;
  border-bottom: 1.1em solid transparent;
  border-right: 0.6em solid rgb(var(--primary-container-rgb));
}
body.kids-heading-tag .entry-content h2::after {
  /* 紐穴 */
  content: "";
  position: absolute;
  left: 0.4em;
  top: 50%;
  transform: translateY(-50%);
  width: 0.35em;
  height: 0.35em;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
}

/* --- Underline（ミニマル下線のみ） --- */
body.kids-heading-underline .entry-content h2 {
  background: none;
  color: rgb(var(--on-primary-container-rgb));
  padding: 0 0 0.15em 0;
  border-bottom: 3px solid rgb(var(--primary-container-rgb));
  display: inline-block;
  border-radius: 0;
  box-shadow: none;
}

/* 5-2. h3 は吹き出し付きマーカー下線（どのスキンでも共通、
   ミニマルスキンでは装飾密度で色を弱める） */
.entry-content h3 {
  position: relative;
  padding-left: 1em;
  padding-bottom: 0.15em;
  background-image: linear-gradient(
    transparent 68%,
    rgb(var(--secondary-container-rgb)) 68%,
    rgb(var(--secondary-container-rgb)) 94%,
    transparent 94%
  );
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.entry-content h3::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: rgb(var(--on-secondary-container-rgb));
  font-size: 0.85em;
  top: 0.15em;
}

/* 5-2b. ミニマル装飾密度：h3 のアイコンを隠し、下線もおとなしく */
body.kids-deco-minimal .entry-content h3::before { content: none; }
body.kids-deco-minimal .entry-content h3 {
  padding-left: 0;
  background-image: linear-gradient(
    transparent 80%,
    rgba(var(--secondary-container-rgb) / 0.6) 80%,
    rgba(var(--secondary-container-rgb) / 0.6) 95%,
    transparent 95%
  );
}

/* ミニマル装飾密度：セクション装飾（⭐️）も止める、スティッカー傾きもなくす */
body.kids-deco-minimal .entry-content > h2 + p::before,
body.kids-deco-minimal .entry-content > h2 + ul::before { content: none; }
body.kids-deco-minimal .kids-sticker-left,
body.kids-deco-minimal .kids-sticker-right { transform: none; }

/* 5-3. <hr> をジグザグ区切りに */
hr, .wp-block-separator {
  border: 0;
  height: 12px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'><path d='M0 6 L6 0 L12 6 L18 0 L24 6 L18 12 L12 6 L6 12 Z' fill='rgba(0,79,149,0.15)'/></svg>");
  background-size: 24px 12px;
  background-repeat: repeat-x;
  background-position: center;
  margin: 2.5rem 0;
}

/* 5-4. カードのわずかな傾き（付箋感） */
.kids-sticker-left  { transform: rotate(-1.2deg); }
.kids-sticker-right { transform: rotate(1.2deg); }
.kids-sticker-left:hover,
.kids-sticker-right:hover { transform: rotate(0); }

/* 5-5. 蛍光マーカー（[kids_mark] ショートコード用） */
.kids-mark {
  background-image: linear-gradient(transparent 60%, var(--kids-mark-color, #fff59d) 60%);
  padding: 0 0.15em;
  font-weight: 700;
}
.kids-mark--yellow { --kids-mark-color: #fff59d; }
.kids-mark--pink   { --kids-mark-color: #f8bbd0; }
.kids-mark--blue   { --kids-mark-color: #bbdefb; }
.kids-mark--green  { --kids-mark-color: #c8e6c9; }

/* 5-6. セクション装飾：サイドに星が散る */
.entry-content > h2 + p::before,
.entry-content > h2 + ul::before {
  content: "⭐️";
  float: right;
  margin-left: 0.5em;
  opacity: 0.8;
}

/* ==========================================================================
   PHASE 2: アニメーション & タイポグラフィ強化
   ========================================================================== */

/* 6-1. ゆるい呼吸アニメ（アイコン・バッジ用） */
@keyframes kidsBreathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.kids-breathe {
  animation: kidsBreathe 3s ease-in-out infinite;
  transform-origin: center center;
}

/* 6-2. ジェリーホバー（押したときに弾む） */
.kids-jelly {
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.kids-jelly:hover { transform: scale(1.06); }
.kids-jelly:active { transform: scale(0.94); }

/* ボタン・クイズ選択肢にデフォルト適用 */
.wp-block-button__link,
.button,
.kids-quiz-choice {
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color 0.2s, color 0.2s;
}
.wp-block-button__link:hover,
.button:hover {
  transform: scale(1.04);
}
.wp-block-button__link:active,
.button:active {
  transform: scale(0.96);
}

/* 6-3. スクロールで下からふわっと登場 */
.kids-fade-up {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.kids-fade-up.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* 6-4. H1 のグラデーション文字（home-page / single のページタイトル） */
.page-title,
.entry-title,
h1.kids-gradient {
  background: linear-gradient(
    135deg,
    rgb(var(--on-primary-container-rgb)),
    rgba(255, 120, 150, 0.9) 60%,
    rgb(var(--on-secondary-container-rgb))
  );
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
}

/* 6-5. クイズ正解時の紙吹雪 */
.kids-confetti {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 9999;
  animation: kidsConfettiFall 1.6s linear forwards;
}
@keyframes kidsConfettiFall {
  0%   { transform: translateY(-10vh) rotate(0);   opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ==========================================================================
   PHASE 3: 常駐マスコット & 背景パターン
   ========================================================================== */

/* 7-1. 常駐マスコット（画面右下固定、親テーマの「ページトップへ戻る」FABの真上に積む） */
.kids-persistent-mascot {
  position: fixed;
  right: 1rem;
  bottom: 5rem;          /* 親テーマ scroll-to-top FAB と重ならないよう持ち上げる */
  z-index: 50;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: rgb(var(--secondary-container-rgb));
  color: rgb(var(--on-secondary-container-rgb));
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  border: 3px solid #fff;
  animation: kidsBreathe 4s ease-in-out infinite;
  user-select: none;
  /* ここを原点に吹き出しを絶対配置する */
}
.kids-persistent-mascot:hover { transform: scale(1.08); }

/* 吹き出し：マスコットの左に自然な幅で出す
   以前は right:80px + max-width で幅が崩れて 1 文字改行になっていたため、
   right:calc(100% + 12px) で「マスコットの左外側」に貼り付け、width も
   フォールバック付きで明示する。 */
.kids-persistent-mascot__bubble {
  position: absolute;
  right: calc(100% + 12px);
  bottom: 50%;
  transform: translateY(50%);
  width: max-content;
  max-width: min(240px, calc(100vw - 96px));
  padding: 12px 14px;
  background: #fff;
  color: #222;
  border-radius: 1rem 1rem 0 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
  line-height: 1.6;
  font-weight: 500;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;  /* 長い URL などでも溢れない */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  animation: none;
}
.kids-persistent-mascot[data-open="true"] .kids-persistent-mascot__bubble {
  opacity: 1;
  pointer-events: auto;
}

/* モバイル縦画面は吹き出しを「マスコットの上」に出す方が安全 */
@media (max-width: 480px) {
  .kids-persistent-mascot__bubble {
    right: auto;
    left: 50%;
    bottom: calc(100% + 10px);
    top: auto;
    transform: translateX(-50%);
    border-radius: 1rem 1rem 1rem 0.25rem;
    width: max-content;
    max-width: min(260px, calc(100vw - 32px));
  }
}

/* 7-2. body 背景パターン（カスタマイザーでON） */
body.kids-bg-stars {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'><g fill='rgba(0,79,149,0.06)'><circle cx='10' cy='10' r='1.4'/><circle cx='55' cy='28' r='1.8'/><circle cx='30' cy='50' r='1.2'/><circle cx='70' cy='65' r='1.5'/></g></svg>");
  background-attachment: fixed;
}
body.kids-bg-clouds {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60' viewBox='0 0 120 60'><g fill='rgba(0,79,149,0.05)'><ellipse cx='30' cy='40' rx='22' ry='10'/><ellipse cx='90' cy='18' rx='18' ry='8'/></g></svg>");
  background-attachment: fixed;
}
body.dark.kids-bg-stars {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'><g fill='rgba(255,220,120,0.18)'><circle cx='10' cy='10' r='1.4'/><circle cx='55' cy='28' r='1.8'/><circle cx='30' cy='50' r='1.2'/><circle cx='70' cy='65' r='1.5'/></g></svg>");
}

/* ==========================================================================
   アクセシビリティ：動きを減らす設定を尊重
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .kids-sticker-left,
  .kids-sticker-right { transform: none; }
  .kids-fade-up {
    opacity: 1;
    transform: none;
  }
}
