/* ============================================
   weather.css — 天気予報ウィジェット
   右下に追従するボタン + 2週間予報パネル
   ※ style.css のCSS変数（--accent 等）を利用
   ============================================ */

/* ===== 追従ボタン（FAB: Floating Action Button） ===== */
.weather-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;

  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  cursor: pointer;

  background: var(--gradient);
  color: #fff;
  font-size: 28px;
  line-height: 1;

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), var(--shadow-glow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.weather-fab:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 48px var(--accent-glow);
}

.weather-fab:active {
  transform: scale(0.96);
}

/* パネルが開いている間はボタンを少し沈める */
.weather-fab.is-open {
  transform: scale(0.9);
  opacity: 0.85;
}

/* アイコンのふわっとした浮遊アニメ */
.weather-fab__icon {
  display: inline-block;
  animation: weather-float 3s ease-in-out infinite;
}

@keyframes weather-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* ===== オーバーレイ（背景の薄暗幕） ===== */
.weather-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(5, 5, 10, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.weather-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* ===== 予報パネル ===== */
.weather-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 960;

  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);

  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity var(--transition), visibility var(--transition),
              transform var(--transition);
}

.weather-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ===== パネルヘッダー ===== */
.weather-panel__header {
  flex-shrink: 0;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    rgba(124, 92, 255, 0.12) 0%,
    rgba(124, 92, 255, 0) 100%
  );
}

.weather-panel__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.weather-panel__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.weather-panel__close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}

.weather-panel__close:hover {
  background: var(--border);
  color: var(--text);
}

/* 都市セレクト */
.weather-panel__city {
  margin-top: 12px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: border-color var(--transition);
}

.weather-panel__city:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== パネル本体（スクロール領域） ===== */
.weather-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 16px;
}

/* スクロールバーの装飾 */
.weather-panel__body::-webkit-scrollbar {
  width: 8px;
}
.weather-panel__body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

/* ===== 1日分の予報行 ===== */
.weather-day {
  display: grid;
  grid-template-columns: 54px 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 12px;
  transition: background var(--transition);
}

.weather-day:hover {
  background: var(--surface);
}

/* 今日を強調 */
.weather-day.is-today {
  background: rgba(124, 92, 255, 0.12);
  border: 1px solid rgba(124, 92, 255, 0.3);
}

.weather-day__date {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
}

.weather-day__date strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}

/* 土日に色を付ける */
.weather-day__date.is-sat strong { color: var(--accent-2); }
.weather-day__date.is-sun strong { color: #ff6b8a; }

.weather-day__icon {
  font-size: 26px;
  text-align: center;
}

.weather-day__desc {
  font-size: 13px;
  color: var(--text-muted);
}

.weather-day__rain {
  font-size: 12px;
  color: var(--accent-2);
  margin-top: 2px;
}

.weather-day__temp {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 14px;
  white-space: nowrap;
}

.weather-day__temp .max { color: #ff8a5c; font-weight: 600; }
.weather-day__temp .sep { color: var(--text-dim); margin: 0 2px; }
.weather-day__temp .min { color: var(--accent-2); }

/* ===== 状態表示（ローディング / エラー） ===== */
.weather-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.weather-state__spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: weather-spin 0.8s linear infinite;
}

@keyframes weather-spin {
  to { transform: rotate(360deg); }
}

.weather-state__retry {
  margin-top: 14px;
  padding: 8px 18px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.weather-state__retry:hover {
  background: var(--accent);
  color: #fff;
}

/* ===== フッター（出典） ===== */
.weather-panel__footer {
  flex-shrink: 0;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
}

.weather-panel__footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.weather-panel__footer a:hover {
  color: var(--accent-2);
}

/* ===== モバイル対応 ===== */
@media (max-width: 520px) {
  .weather-fab {
    right: 16px;
    bottom: 16px;
    width: 54px;
    height: 54px;
    font-size: 25px;
  }

  .weather-panel {
    right: 8px;
    left: 8px;
    bottom: 80px;
    width: auto;
    max-height: 72vh;
  }
}

/* アニメーションを抑制する設定のユーザーに配慮 */
@media (prefers-reduced-motion: reduce) {
  .weather-fab__icon { animation: none; }
  .weather-panel,
  .weather-fab,
  .weather-overlay { transition: none; }
}
