/* public/styles.css (All suggestions included) */

/* --- 全体のスタイルと背景 --- */
@import url("https://fonts.googleapis.com/css2?family=Yuji+Syuku&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", Meiryo,
    メイリオ, Osaka, "MS PGothic", arial, helvetica, sans-serif;
  line-height: 1.7;
  color: #333;
  min-height: 100vh;

  /* 2. 背景画像を画面いっぱいに広げる設定 */
  background-image: url("/images/night-sky.jpg");
  background-size: cover; /* 画像が常に要素全体を覆うように拡大・縮小 */
  background-position: center; /* 画像を中央に配置 */
  background-repeat: no-repeat; /* 画像の繰り返しを無効化 */
  background-attachment: fixed; /* スクロールしても背景画像を固定 */

  /* 3. 画像が読み込めなかった場合の代替背景色 */
  background-color: #1a234a;
  /* background: linear-gradient(to bottom, #1a234a, #3a4a8b); */
  padding: 20px;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
}

/* --- コンテナとヘッダーのスタイル --- */
.container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

h1 {
  color: #fff;
  font-weight: 300;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  margin: 0;
}

/* --- ボタンのスタイル --- */
.primary-button,
.secondary-button {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 12px 20px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.primary-button:hover,
.secondary-button:hover {
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* --- フォームのスタイル --- */
.form-group {
  margin-bottom: 20px;
}
label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #eee;
}
input,
textarea {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.5);
}
textarea {
  min-height: 120px;
  resize: vertical;
}

/* --- メッセージのスタイル --- */
#status-message {
  margin-top: 15px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}
.status-message.success {
  background-color: rgba(46, 204, 113, 0.8);
  color: #fff;
}
.status-message.error {
  background-color: rgba(231, 76, 60, 0.8);
  color: #fff;
}

/* --- 短冊表示エリア --- */
.wishes-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 25px;
  padding: 20px 0;
}

@keyframes sway-subtle {
  0% {
    transform: rotate(1.2deg);
  }
  50% {
    transform: rotate(-0.6deg);
  }
  100% {
    transform: rotate(1.2deg);
  }
}

@keyframes sway-wide {
  0% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(2.5deg);
  }
  100% {
    transform: rotate(-2deg);
  }
}

.wish-card {
  font-family: "Yuji Syuku", serif;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 40px 15px 15px 15px;
  border-radius: 4px;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
  width: fit-content;
  height: fit-content;
  min-height: 200px;
  max-height: 400px;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: transform 0.4s ease-in-out, box-shadow 0.4s ease;
  animation: var(--sway-name, sway-subtle) /* アニメーション名 (JSから指定) */
    var(--sway-duration, 8s) /* 時間 (JSから指定) */
    var(--sway-timing, ease-in-out) /* 緩急 (JSから指定) */
    var(--sway-delay, 0s) /* 遅延 (JSから指定) */ infinite /* 無限ループ */
    var(--sway-direction, alternate); /* 進行方向 (JSから指定) */
}

.wish-card::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f5f5f5;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.2);
  z-index: 2; /* 紐より手前に表示 */
}

.wish-card::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 15px;
  background-color: rgba(0, 0, 0, 0.2);
  opacity: 0.7;
}

.wish-card:nth-child(5n + 1) {
  background-color: #ffefb8;
  animation-delay: -1.2s;
}
.wish-card:nth-child(5n + 2) {
  background-color: #d4f0fd;
  animation-delay: -0.5s;
}
.wish-card:nth-child(5n + 3) {
  background-color: #ffd8d8;
  animation-delay: -2.5s;
}
.wish-card:nth-child(5n + 4) {
  background-color: #d9f7d6;
  animation-delay: -3.1s;
}
.wish-card:nth-child(5n + 5) {
  background-color: #f3e0ff;
  animation-delay: -1.8s;
}

.wish-card:hover {
  /* ★ 1. アニメーションを停止する */
  animation-play-state: paused;

  /* ★ 2. 少し拡大し、回転をリセットしてまっすぐにする */
  transform: rotate(0deg) scale(1.08) !important; /* !importantで他のtransformを上書き */

  /* ★ 3. 他の短冊より手前に表示させる */
  z-index: 10;

  /* ★ 4. 浮き上がったような影をつける */
  box-shadow: 0px 15px 30px rgba(0, 0, 0, 0.4);
}

.wish-content {
  font-size: 18px;
  letter-spacing: 2px;
  max-height: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 20px;
}

.wish-author {
  font-size: 16px;
  color: #555;
  align-self: flex-end;
}

/* --- 応援ボタンのスタイル --- */
.wish-support {
  position: absolute;
  bottom: 10px;
  right: 10px;
  writing-mode: initial;
  text-orientation: initial;
}

.support-button {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: #333;
}

.support-button:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.support-button.supported {
  background: #ffd700;
  color: #333;
  border-color: #ffcc00;
}

.support-button.supported:hover {
  background: #ffcc00;
}

.support-button.disabled {
  background: rgba(150, 150, 150, 0.5);
  color: #999;
  border-color: rgba(150, 150, 150, 0.3);
  cursor: not-allowed;
  opacity: 0.6;
}

.support-button.disabled:hover {
  background: rgba(150, 150, 150, 0.5);
  box-shadow: none;
  transform: none;
}

.star-icon {
  font-size: 16px;
  line-height: 1;
}

.support-count {
  font-weight: bold;
  min-width: 20px;
  text-align: center;
}

/* --- 非表示・ローディングのスタイル --- */
.hidden {
  display: none !important;
}
.loading-indicator {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
.loading-indicator p {
  color: #fff;
}

/* --- 「使い方」リンクのスタイル --- */
#how-to-use-link {
  position: fixed;
  bottom: 20px;
  right: 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  z-index: 100;
  transition: all 0.3s ease;
}

#how-to-use-link:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
}

/* --- ポップアップ（モーダル）のスタイル --- */
.modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* ポップアップ表示時のスタイル */
.modal-container:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #fff;
  color: #333;
  padding: 30px 40px;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-container:not(.hidden) .modal-content {
  transform: scale(1);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #2c3e50;
  font-weight: 600;
}

.modal-content p {
  margin-bottom: 20px;
  line-height: 1.8;
}

.modal-content ul {
  padding-left: 20px;
  line-height: 1.8;
}

.modal-content li {
  margin-bottom: 10px;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  color: #aaa;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: #333;
}

/* ヘッダー内のボタンとアイコンを囲むdivのスタイル */
header > div {
  display: flex;
  align-items: center; /* ★アイコンとボタンを垂直方向中央揃えにする */
  gap: 10px;
}

/* アバターアイコンのスタイル */
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%; /* 円形にする */
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  object-fit: cover; /* 画像が円の中に綺麗に収まるようにする */
}

/* --- 流れ星アニメーション --- */
.shooting-star {
  position: fixed;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 4px #fff, 0 0 8px #fff, 0 0 12px #ffd700;
  z-index: 1;
  pointer-events: none;
}

.shooting-star::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 1px;
  background: linear-gradient(
    to left,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 100%
  );
  transform-origin: 0 50%;
  transform: rotate(-45deg);
}

@keyframes shootingStar {
  0% {
    transform: translateX(calc(100vw + 100px)) translateY(-100px);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(-100px) translateY(calc(100vh + 100px));
    opacity: 0;
  }
}

.shooting-star.animate {
  animation: shootingStar 2s linear;
}

/* 画面幅が768px以下の場合に適用されるスタイル */
@media (max-width: 768px) {
  /* ヘッダーのレイアウトを縦並びに変更 */
  header {
    flex-direction: column; /* 要素を縦に並べる */
    align-items: flex-start; /* 左揃えにする */
    gap: 20px; /* タイトルとボタンの間に余白を追加 */
  }

  header > div {
    width: 100%;
    display: flex;
    justify-content: flex-end; /* 右端に寄せる */
    align-items: center; /* ★ここも中央揃えを追加 */
    gap: 10px;
  }

  /* フォームコンテナの余白を少し減らす */
  .container {
    padding: 20px;
  }

  /* 短冊の縦書きの文字サイズを少し小さくして見やすくする */
  .wish-content {
    font-size: 16px;
  }

  /* 「使い方」リンクの位置を調整 */
  #how-to-use-link {
    bottom: 10px;
    right: 10px;
    font-size: 12px;
  }
}
