/* ====================================
   レイアウト — PC中央縮小追従 & モバイル全画面
   ==================================== */

html {
  background: linear-gradient(180deg, #7ec8ea 0%, #a8dcf2 28%, #c6eaf8 58%, #e0f5fc 100%);
  height: 100%;
  overflow: hidden;
}
body {
  font-family: var(--font-b);
  color: var(--text);
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: transparent;
  overflow: hidden;
}

/* フレーム外 青空 + ふわふわ雲 ☁️ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    /* ☁️ 雲1 左上 */
    radial-gradient(ellipse 72px 30px at 12% 18%, rgba(255,255,255,0.95) 0%, transparent 100%),
    radial-gradient(ellipse 48px 28px at 19% 14%, rgba(255,255,255,0.90) 0%, transparent 100%),
    radial-gradient(ellipse 42px 24px at  7% 21%, rgba(255,255,255,0.82) 0%, transparent 100%),
    /* ☁️ 雲2 右上 */
    radial-gradient(ellipse 88px 34px at 80% 10%, rgba(255,255,255,0.93) 0%, transparent 100%),
    radial-gradient(ellipse 58px 30px at 87%  6%, rgba(255,255,255,0.87) 0%, transparent 100%),
    radial-gradient(ellipse 52px 26px at 73% 13%, rgba(255,255,255,0.80) 0%, transparent 100%),
    /* ☁️ 雲3 左中 */
    radial-gradient(ellipse 64px 26px at  6% 52%, rgba(255,255,255,0.88) 0%, transparent 100%),
    radial-gradient(ellipse 40px 22px at 13% 48%, rgba(255,255,255,0.82) 0%, transparent 100%),
    /* ☁️ 雲4 右下 */
    radial-gradient(ellipse 76px 30px at 88% 72%, rgba(255,255,255,0.90) 0%, transparent 100%),
    radial-gradient(ellipse 50px 25px at 94% 68%, rgba(255,255,255,0.84) 0%, transparent 100%),
    radial-gradient(ellipse 44px 22px at 82% 76%, rgba(255,255,255,0.78) 0%, transparent 100%),
    /* ☁️ 雲5 中央 */
    radial-gradient(ellipse 60px 24px at 50% 38%, rgba(255,255,255,0.86) 0%, transparent 100%),
    radial-gradient(ellipse 38px 20px at 57% 34%, rgba(255,255,255,0.80) 0%, transparent 100%);
  animation: cloudDrift 14s ease-in-out infinite;
}
@keyframes cloudDrift {
  0%,100% { transform: translateX(0px)  translateY(0px);  }
  25%      { transform: translateX(12px) translateY(-5px); }
  50%      { transform: translateX(8px)  translateY(-10px);}
  75%      { transform: translateX(-5px) translateY(-4px); }
}

/* アプリラッパー（PC: ビューポート高さに追従） */
.app-scale-wrapper {
  width: var(--app-w);
  height: 100vh;
  max-height: 100vh;
  flex-shrink: 0;
  transform-origin: top center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow:
    3px 0 0 rgba(212,165,217,0.7),
    -3px 0 0 rgba(212,165,217,0.7),
    0 0 40px rgba(212,165,217,0.3);
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

/* スマホ: 全画面（バブル背景・ボーダー不要）
   480px以下 = 実機モバイル全機種をカバー（Android最大幅 430px超あり） */
@media (max-width: 480px) {
  /* background は nav の white に合わせてホームインジケーター下の帯を目立たなくする */
  html, body { background: #ffffff; overflow: auto; }
  body::before { display: none; }
  /* シミュレートstatusbar: モバイルではOSのstatusbarがあるため不要
     Capacitor は別途 html.capacitor-native で制御済み */
  .status-bar { display: none; }
  .app-scale-wrapper {
    /* 100vw は Android WebView でスクロールバー幅が含まれて右はみ出しを起こすため
       width: 100% に変更 (#71)。フォールバック計算が必要なら calc() を別途検討。 */
    width: 100%;
    height: 100dvh;
    min-height: -webkit-fill-available;
    box-shadow: none;
    border-radius: 0;
    transform: none !important;
  }
}

/* スクロール可能なコンテンツ領域 */
.app-scroll {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--bg);
  /* iOS PWA のrubber-band バウンスがヘッダーを飛ばさないよう制御 */
  overscroll-behavior-y: contain;
}
.app-scroll::-webkit-scrollbar { display: none; }

/* ヘッダー sticky 固定 — iOS PWA/全ブラウザ共通
   top:0 でビューポート最上部に吸い付く。safe-area はヘッダー自身の padding で吸収。
   これにより スクロールコンテンツがステータスバー部分に透けるのを防ぐ。 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg); /* スクロール中に後ろのコンテンツが透けないよう */
}

/* ボディ */
.app-body {
  padding: 16px 16px 24px;
  box-sizing: border-box;
}

/* セクション共通 */
.sec { margin-bottom: 22px; }
.sec-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sec-title {
  font-family: var(--font-h);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 5px;
}
.sec-more {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-h);
  text-decoration: none;
}

/* ホームパネルは #appWrapper に移動後も他タブで非表示を保証 */
.hs-panel { display: none; }
#hsOverlay { display: none; }

/* Safe Area 対応 — iOS Safari PWA + Capacitor ネイティブ共通
   viewport-fit=cover が必須（index.html で設定済み）
   ★ padding-top は app-header に持たせる → components.css で定義（ロード順の都合）
   左右は app-scroll に残す */
@supports (padding: env(safe-area-inset-top)) {
  @media (max-width: 480px) {
    .app-scroll {
      /* 左右のセーフエリア対応: ノッチ/パンチホール/カットアウト機種で
         右上 absolute 配置の要素 (新人バッジ等) が見切れないように (#71) */
      padding-right: env(safe-area-inset-right);
      padding-left: env(safe-area-inset-left);
    }
  }
}

/* ネイティブアプリ: Capacitor が status-bar を管理するため非表示 */
html.capacitor-native .status-bar {
  display: none;
}
/* PC スケーリング無効化（ネイティブは実デバイス幅） */
html.capacitor-native .app-scale-wrapper {
  width: 100%;
  max-width: 100%;
  transform: none;
  margin: 0;
}
