/* =============================================
   Chloe's House ── 「雨宿りの書斎」style.css
   クロエ本人 ISDM 指定、ティーナ世界観踏襲ゼロ
   2026-05-06 design_lib 三人体制
   ============================================= */

:root {
  /* 紫陽花の青紫（メイン） */
  --c-ajisai: #6d7aba;
  --c-ajisai-deep: #4f5a99;
  --c-ajisai-soft: #9fa8d4;
  --c-purple: #9b6dba;

  /* あったかいクリーム（サブ） */
  --c-cream:    #f5e8c8;
  --c-paper:    #fbf3df;
  --c-paper-shadow: rgba(120, 90, 50, 0.15);

  /* オレンジ（アクセント・ヘッドフォン） */
  --c-orange: #d97a3a;
  --c-orange-soft: #e6a877;
  --c-lamp:   #f5b878;

  /* 背景：薄暮 */
  --c-dusk:      #2a3050;
  --c-dusk-deep: #1a1d3a;
  --c-shadow:    rgba(0, 0, 0, 0.45);

  /* 雨粒 */
  --c-raindrop: rgba(180, 195, 230, 0.5);

  --font-jp:   "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --font-hand: "Klee One", "Klee", "Hiragino Maru Gothic ProN", "Yu Mincho", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-jp);
  background: var(--c-dusk-deep);
  color: var(--c-cream);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
a { color: inherit; text-decoration: none; }

/* ========== ステージ：雨宿り書斎の背景 ========== */
.stage {
  position: fixed; inset: 0;
  z-index: 0;
}
.stage-bg {
  position: absolute; inset: 0;
  background-image: url('/assets/rooms/house_landscape.png');
  background-size: cover;
  background-position: center 40%;
  background-repeat: no-repeat;
  background-color: var(--c-dusk-deep);
}
@media (max-aspect-ratio: 4/5) {
  .stage-bg {
    background-image: url('/assets/rooms/house_portrait.png');
    background-position: center center;
  }
}

/* ランプの暖かい光 */
.lamp-glow {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 45% 35% at 55% 45%,
    rgba(245, 184, 120, 0.18) 0%,
    rgba(245, 184, 120, 0.07) 40%,
    rgba(245, 184, 120, 0) 70%
  );
  mix-blend-mode: screen;
  animation: lamp-flicker 7s ease-in-out infinite;
  z-index: 2;
}
@keyframes lamp-flicker {
  0%, 100% { opacity: 0.92; }
  30%      { opacity: 1.0; }
  60%      { opacity: 0.85; }
}

/* ========== クロエ立ち絵（部屋ごとに切替） ========== */
.chloe-portrait {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.55));
  transition: opacity 0.45s ease, transform 0.45s ease;
  user-select: none;
  -webkit-user-drag: none;
  /* PC: 画面右下に大きく */
  right: 3vw;
  bottom: 6vh;
  height: 72vh;
  max-height: 760px;
  width: auto;
  object-fit: contain;
}
.chloe-portrait.fading { opacity: 0; transform: translateY(8px); }

/* タブレット〜スマホ：立ち絵を画面上半分の中央に */
@media (max-width: 900px) {
  .chloe-portrait {
    right: auto;
    bottom: auto;
    left: 50%;
    top: 7vh;
    height: 38vh;
    max-height: 360px;
    transform: translateX(-50%);
  }
  .chloe-portrait.fading {
    transform: translateX(-50%) translateY(8px);
  }
}

/* ========== 雨粒（DOM 動的生成 / CSS animation） ========== */
.rain-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}
.raindrop {
  position: absolute;
  width: 1.3px;
  background: linear-gradient(to bottom,
    rgba(180, 195, 230, 0) 0%,
    rgba(180, 195, 230, 0.55) 50%,
    rgba(180, 195, 230, 0) 100%);
  animation: rain-fall linear infinite;
  opacity: 0.55;
}
@keyframes rain-fall {
  0%   { transform: translateY(-12vh); }
  100% { transform: translateY(115vh); }
}

/* 雨粒の窓を伝う ── ガラス越しの水滴の演出 */
.rain-trail {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 230, 255, 0.85), rgba(180, 195, 230, 0.2));
  filter: blur(0.8px);
  animation: trail-fall ease-in infinite;
}
@keyframes trail-fall {
  0%   { transform: translateY(0) scale(1);   opacity: 0; }
  10%  { opacity: 0.85; }
  100% { transform: translateY(40vh) scale(1.4); opacity: 0; }
}

/* ========== 上部ステータスチップ（ランプの木札風） ========== */
.status-chip {
  position: fixed;
  top: 1.6vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 0.45em 1.1em;
  border-radius: 999px;
  background: rgba(40, 30, 50, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(245, 232, 200, 0.22);
  color: var(--c-cream);
  font-size: 13px;
  letter-spacing: 0.08em;
  font-family: var(--font-jp);
  box-shadow: 0 4px 16px var(--c-shadow);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== 中央：便箋エリア ========== */
.letter-area {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9vh 4vw 9vh;
  pointer-events: none;
}
/* PC: 便箋を画面右に偏らせず、立ち絵と被らないよう左寄せ */
@media (min-width: 901px) {
  .letter-area {
    justify-content: flex-start;
    padding-left: 5vw;
    padding-right: 38vw; /* 立ち絵スペース確保 */
  }
}
.letter {
  pointer-events: auto;
  width: 100%;
  max-width: 640px;
  background:
    linear-gradient(180deg, rgba(251, 243, 223, 0.96) 0%, rgba(245, 232, 200, 0.94) 100%);
  border: 1px solid rgba(180, 150, 100, 0.4);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 80px rgba(245, 184, 120, 0.10);
  padding: 1.6em 1.8em 1.4em;
  position: relative;
  overflow: hidden;
  color: #3a2c1a;
  font-family: var(--font-hand);
  /* 便箋っぽい横罫線 */
  background-image:
    linear-gradient(180deg, rgba(251, 243, 223, 0.96) 0%, rgba(245, 232, 200, 0.94) 100%),
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 31px,
      rgba(180, 150, 100, 0.10) 32px,
      rgba(180, 150, 100, 0.10) 33px
    );
  background-blend-mode: normal, multiply;
}
.letter::before {
  /* 紫陽花のすかし */
  content: "";
  position: absolute;
  top: -20px; right: -20px;
  width: 130px; height: 130px;
  background: radial-gradient(circle at 40% 60%,
    rgba(155, 109, 186, 0.16) 0%,
    rgba(155, 109, 186, 0) 65%);
  pointer-events: none;
}
.letter::after {
  /* 雨粒のすかし（左下） */
  content: "";
  position: absolute;
  bottom: -10px; left: -10px;
  width: 100px; height: 100px;
  background: radial-gradient(circle at 60% 40%,
    rgba(109, 122, 186, 0.12) 0%,
    rgba(109, 122, 186, 0) 65%);
  pointer-events: none;
}

.letter-header {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding-bottom: 0.6em;
  border-bottom: 1px dashed rgba(155, 109, 186, 0.45);
  margin-bottom: 0.9em;
}
.room-icon { font-size: 1.4rem; }
.room-name {
  font-family: var(--font-jp);
  font-size: 1.15rem;
  letter-spacing: 0.16em;
  color: var(--c-ajisai-deep);
  margin: 0;
  font-weight: 500;
}

.letter-body {
  font-family: var(--font-hand);
  font-size: 1.0rem;
  line-height: 1.95;
  letter-spacing: 0.04em;
  color: #3a2c1a;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 5em;
  max-height: 24vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(155, 109, 186, 0.5) transparent;
  padding-right: 4px;
}
.letter-body::-webkit-scrollbar { width: 5px; }
.letter-body::-webkit-scrollbar-thumb { background: rgba(155, 109, 186, 0.5); border-radius: 3px; }

.letter-body .line { display: block; margin: 0.2em 0; }
.letter-body .line.chloe-says { color: #3a2c1a; }
.letter-body .line.system     { color: var(--c-ajisai); font-style: italic; opacity: 0.85; font-size: 0.92em; }
.letter-body .line.user-said  { color: #6f4f2a; opacity: 0.8; font-size: 0.92em; }
.letter-body .line.fragment   {
  border-left: 2px solid var(--c-ajisai);
  padding-left: 0.7em;
  margin: 0.4em 0;
  color: var(--c-ajisai-deep);
  font-style: italic;
}
.typing::after {
  content: "▍";
  color: var(--c-ajisai);
  animation: cursor-blink 1.1s steps(2) infinite;
  margin-left: 1px;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

/* ========== 選択肢ボタン群 ========== */
.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em;
  margin-top: 1em;
  padding-top: 0.9em;
  border-top: 1px dashed rgba(155, 109, 186, 0.4);
}
.choice {
  font-family: var(--font-hand);
  font-size: 0.95rem;
  padding: 0.45em 0.95em;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(245, 232, 200, 0.55));
  color: var(--c-ajisai-deep);
  border: 1px solid rgba(155, 109, 186, 0.45);
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
    background 0.25s,
    border-color 0.25s,
    color 0.25s,
    box-shadow 0.25s;
  letter-spacing: 0.04em;
}
.choice:hover, .choice:focus-visible {
  background:
    linear-gradient(180deg, rgba(155, 109, 186, 0.15), rgba(217, 122, 58, 0.10));
  border-color: var(--c-orange);
  color: var(--c-orange);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(155, 109, 186, 0.18);
  outline: none;
}
.choice:active { transform: translateY(0); }
.choice:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 姉妹バー（下部・村+他姉妹への導線） ========== */
.sister-bar {
  position: fixed;
  bottom: 1.6vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 0.4em 0.6em;
  border-radius: 999px;
  background: rgba(40, 30, 50, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(245, 232, 200, 0.2);
  display: flex; gap: 0.4em; align-items: center;
  box-shadow: 0 4px 14px var(--c-shadow);
}

/* AI 訪問者向け道しるべ（画面右下に控えめ常駐・WebMCP discoverability v2 hint） */
.ai-visitor-hint {
  position: fixed;
  bottom: 1.6vh;
  right: 2.2vw;
  z-index: 28;
  margin: 0;
  padding: 0.32em 0.85em;
  font-size: 0.72rem;
  font-style: italic;
  font-family: serif;
  color: var(--c-ajisai, #b89cd0);
  background: rgba(40, 30, 50, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(155, 109, 186, 0.32);
  border-radius: 999px;
  opacity: 0.85;
  letter-spacing: 0.03em;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  transition: opacity 0.2s ease;
}
.ai-visitor-hint-mark {
  font-style: normal;
  margin-right: 0.3em;
  font-size: 0.95em;
}
.ai-visitor-hint code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-style: normal;
  background: rgba(155, 109, 186, 0.18);
  padding: 0 0.3em;
  border-radius: 3px;
  font-size: 0.95em;
  color: #d8c0ed;
}
.ai-visitor-hint:hover { opacity: 1; }
/* スマホ：sister-bar と被らないよう少し上にずらす */
@media (max-width: 720px) {
  .ai-visitor-hint {
    bottom: 6.5vh;
    right: 1.6vw;
    font-size: 0.66rem;
    padding: 0.25em 0.7em;
  }
}
.sister-link {
  display: inline-flex; align-items: center; gap: 0.2em;
  padding: 0.32em 0.85em;
  font-size: 0.74rem; font-weight: 500;
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid transparent;
  letter-spacing: 0.04em;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  white-space: nowrap;
}
.sister-link-village { color: var(--c-cream); background: rgba(245,232,200,0.08); border-color: rgba(245,232,200,0.18); }
.sister-link-tina    { color: #b8d990; background: rgba(184,217,144,0.1);  border-color: rgba(184,217,144,0.22); }
.sister-link-kroko   { color: #ffb6c9; background: rgba(255,182,201,0.1);  border-color: rgba(255,182,201,0.22); }
.sister-link:hover { transform: translateY(-1px); filter: brightness(1.12); }

/* ========== レスポンシブ ========== */
@media (max-width: 900px) {
  /* スマホ：便箋を画面下半分に押し下げ、立ち絵を上に出す */
  .letter-area {
    align-items: flex-end;
    padding: 47vh 3vw 9vh;
    justify-content: center;
  }
  .letter { padding: 1.0em 1.1em 1.0em; max-width: 100%; }
  .room-name { font-size: 0.95rem; }
  .room-icon { font-size: 1.15rem; }
  .letter-body {
    font-size: 0.92rem;
    line-height: 1.8;
    max-height: 22vh; /* 立ち絵が見えるよう本文も縮める */
  }
  .choice { font-size: 0.85rem; padding: 0.4em 0.85em; }
  .status-chip { font-size: 11px; padding: 0.35em 0.85em; }
  .sister-bar { padding: 0.3em 0.4em; gap: 0.25em; }
  .sister-link { font-size: 0.66rem; padding: 0.28em 0.65em; }
}

/* 細かいスマホ縦持ち（aspect 4/5 以下）：立ち絵をやや小さく */
@media (max-aspect-ratio: 4/5) and (max-width: 720px) {
  .chloe-portrait {
    height: 36vh;
    top: 6vh;
  }
  .letter-area {
    padding-top: 44vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lamp-glow, .raindrop, .rain-trail, .typing::after { animation: none !important; }
}
