/**
 * Hina Gacha スタイル
 * 日向坂ブルー × ゴールドアクセントのスタイリッシュデザイン
 */

:root {
  --hg-blue-primary: #4A90E2;
  --hg-blue-deep: #2E5C8A;
  --hg-blue-light: #6FA8E8;
  --hg-sky: #E8F4FD;
  --hg-gold: #D4A857;
  --hg-gold-light: #E8C896;
  --hg-rare: #F5A623;
  --hg-text: #2C3E50;
  --hg-text-light: #7B8794;
  --hg-white: #FFFFFF;
  --hg-bg: #F7FAFC;
  --hg-shadow: rgba(74, 144, 226, 0.15);
  --hg-shadow-strong: rgba(74, 144, 226, 0.3);
}

/* ========================================
   ガチャボタンエリア（ショートコード）
   ======================================== */

.hg-gacha-container {
  max-width: 600px;
  margin: 30px auto;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

.hg-gacha-card {
  background: linear-gradient(135deg, var(--hg-white) 0%, var(--hg-sky) 100%);
  border-radius: 16px;
  padding: 40px 30px;
  box-shadow: 0 8px 32px var(--hg-shadow);
  text-align: center;
  border: 1px solid rgba(74, 144, 226, 0.1);
}

.hg-gacha-header {
  margin-bottom: 30px;
}

.hg-gacha-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--hg-blue-deep);
  margin: 0 0 12px 0;
  letter-spacing: 0.05em;
}

.hg-gacha-subtitle {
  font-size: 15px;
  color: var(--hg-text-light);
  line-height: 1.7;
  margin: 0;
}

.hg-gacha-action {
  margin: 30px 0;
}

/* ========================================
   ボタン
   ======================================== */

.hg-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 48px;
  font-size: 17px;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  letter-spacing: 0.05em;
}

.hg-button-primary {
  background: linear-gradient(135deg, var(--hg-blue-primary) 0%, var(--hg-blue-deep) 100%);
  color: var(--hg-white);
  box-shadow: 0 4px 16px var(--hg-shadow-strong);
}

.hg-button-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--hg-shadow-strong);
}

.hg-button-primary:active:not(:disabled) {
  transform: translateY(0);
}

.hg-button-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hg-button-secondary {
  background: var(--hg-white);
  color: var(--hg-blue-primary);
  border: 2px solid var(--hg-blue-primary);
}

.hg-button-secondary:hover {
  background: var(--hg-sky);
}

.hg-button-icon {
  font-size: 14px;
  transition: transform 0.3s;
}

.hg-button-primary:hover .hg-button-icon {
  transform: translateX(4px);
}

/* ========================================
   ステータス表示（ガチャ実行中など）
   ======================================== */

.hg-status {
  margin-top: 20px;
  padding: 16px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}

.hg-status-loading {
  background: var(--hg-sky);
  color: var(--hg-blue-deep);
}

.hg-status-error {
  background: #FFE5E5;
  color: #C0392B;
}

.hg-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--hg-sky);
  border-top-color: var(--hg-blue-primary);
  border-radius: 50%;
  animation: hg-spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

.hg-gacha-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(74, 144, 226, 0.1);
}

.hg-track-count {
  font-size: 13px;
  color: var(--hg-text-light);
  margin: 0;
}

.hg-track-count strong {
  color: var(--hg-blue-deep);
  font-weight: 700;
}

/* ========================================
   ガチャ結果ページ
   ======================================== */

.hg-result-container {
  max-width: 720px;
  margin: 30px auto;
  padding: 0 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  color: var(--hg-text);
}

.hg-result-header {
  text-align: center;
  margin-bottom: 32px;
  padding: 32px 20px;
  background: linear-gradient(135deg, var(--hg-blue-primary) 0%, var(--hg-blue-deep) 100%);
  border-radius: 16px;
  color: var(--hg-white);
  box-shadow: 0 8px 24px var(--hg-shadow-strong);
  position: relative;
  overflow: hidden;
}

.hg-result-header::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  border-radius: 50%;
}

.hg-result-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px 0;
  letter-spacing: 0.05em;
  position: relative;
  z-index: 1;
}

.hg-result-date {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
  position: relative;
  z-index: 1;
}

.hg-rare-badge {
  display: inline-block;
  padding: 4px 12px;
  margin-left: 8px;
  background: var(--hg-gold);
  color: var(--hg-white);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* プレイヤーエリア */

.hg-player-area {
  background: var(--hg-white);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px var(--hg-shadow);
}

.hg-player-label {
  font-size: 13px;
  color: var(--hg-text-light);
  margin-bottom: 12px;
  font-weight: 600;
}

.hg-player-current {
  font-size: 14px;
  color: var(--hg-blue-deep);
  font-weight: 700;
  margin-bottom: 12px;
}

#hg-spotify-player {
  width: 100%;
  min-height: 80px;
}

/* トラックリスト */

.hg-tracklist {
  background: var(--hg-white);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 16px var(--hg-shadow);
}

.hg-tracklist-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--hg-blue-deep);
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hg-track-item {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(74, 144, 226, 0.08);
  transition: background 0.2s;
}

.hg-track-item:last-child {
  border-bottom: none;
}

.hg-track-item:hover {
  background: rgba(74, 144, 226, 0.03);
  margin: 0 -10px;
  padding: 14px 10px;
  border-radius: 8px;
}

.hg-track-item.is-playing {
  background: linear-gradient(90deg, rgba(74, 144, 226, 0.08) 0%, transparent 100%);
  margin: 0 -10px;
  padding: 14px 10px;
  border-radius: 8px;
  border-left: 3px solid var(--hg-blue-primary);
}

.hg-track-image {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  background-color: var(--hg-sky);
}

.hg-track-info {
  flex: 1;
  min-width: 0;
}

.hg-track-number {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--hg-text-light);
  background: var(--hg-sky);
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 4px;
}

.hg-track-rare-icon {
  display: inline-block;
  background: var(--hg-gold);
  color: var(--hg-white);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  font-weight: 700;
}

.hg-track-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--hg-text);
  margin: 4px 0;
  line-height: 1.4;
  word-break: break-all;
}

.hg-track-meta {
  font-size: 12px;
  color: var(--hg-text-light);
  margin-bottom: 6px;
  line-height: 1.4;
}

.hg-track-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.hg-track-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--hg-blue-primary);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.2s;
}

.hg-track-link:hover {
  background: var(--hg-sky);
}

/* シェアエリア */

.hg-share-area {
  margin-top: 24px;
  padding: 20px;
  background: var(--hg-white);
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 16px var(--hg-shadow);
}

.hg-share-title {
  font-size: 14px;
  color: var(--hg-text-light);
  margin: 0 0 12px 0;
}

.hg-share-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hg-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.2s;
}

.hg-share-btn-x {
  background: #000000;
  color: var(--hg-white);
}

.hg-share-btn-x:hover {
  background: #1a1a1a;
}

.hg-share-btn-copy {
  background: var(--hg-sky);
  color: var(--hg-blue-deep);
}

.hg-share-btn-copy:hover {
  background: var(--hg-blue-light);
  color: var(--hg-white);
}

/* レスポンシブ */

@media (max-width: 600px) {
  .hg-gacha-card {
    padding: 30px 20px;
  }
  
  .hg-gacha-title {
    font-size: 24px;
  }
  
  .hg-button {
    padding: 16px 36px;
    font-size: 15px;
  }
  
  .hg-result-title {
    font-size: 18px;
  }
  
  .hg-track-image {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
  }
  
  .hg-track-name {
    font-size: 14px;
  }
}

/* ========================================
   ログイン誘導ヒント（ガチャボタンエリア）
   ======================================== */

.hg-login-hint {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(74, 144, 226, 0.06);
  border: 1px solid rgba(74, 144, 226, 0.15);
  border-radius: 8px;
  font-size: 13px;
  color: var(--hg-text-light);
  line-height: 1.5;
}

.hg-login-hint a {
  color: var(--hg-blue-primary);
  font-weight: 700;
  text-decoration: none;
}

.hg-login-hint a:hover {
  text-decoration: underline;
}

/* ========================================
   結果ページの「ログインで保存」ヒント
   ======================================== */

.hg-save-hint {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding: 20px;
  background: linear-gradient(135deg, var(--hg-sky) 0%, #FFF8E5 100%);
  border-radius: 12px;
  border: 1px solid rgba(74, 144, 226, 0.15);
}

.hg-save-hint-icon {
  flex: 0 0 auto;
  font-size: 28px;
}

.hg-save-hint-body {
  flex: 1;
}

.hg-save-hint-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--hg-blue-deep);
  margin: 0 0 4px 0;
}

.hg-save-hint-desc {
  font-size: 13px;
  color: var(--hg-text-light);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

.hg-save-hint-btn {
  padding: 10px 24px !important;
  font-size: 14px !important;
}

/* ========================================
   応援日記カード内のガチャセクション
   ======================================== */

.hg-diary-section {
  margin-top: 12px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.05) 0%, rgba(212, 168, 87, 0.05) 100%);
  border-radius: 10px;
  border: 1px solid rgba(74, 144, 226, 0.12);
}

.hg-diary-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--hg-blue-deep);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}

.hg-diary-gacha-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hg-diary-gacha-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--hg-white);
  border-radius: 8px;
  text-decoration: none;
  color: var(--hg-text);
  border: 1px solid rgba(74, 144, 226, 0.08);
  transition: all 0.2s;
}

.hg-diary-gacha-item:hover {
  background: rgba(74, 144, 226, 0.04);
  transform: translateX(2px);
  border-color: var(--hg-blue-primary);
}

.hg-diary-thumbs {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.hg-diary-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  background-color: var(--hg-sky);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.hg-diary-thumb.is-rare {
  border: 2px solid var(--hg-gold);
  box-shadow: 0 0 4px rgba(212, 168, 87, 0.4);
}

.hg-diary-gacha-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.hg-diary-gacha-time {
  font-size: 13px;
  color: var(--hg-text-light);
  font-weight: 700;
}

.hg-diary-rare {
  display: inline-block;
  background: var(--hg-gold);
  color: var(--hg-white);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

.hg-diary-gacha-arrow {
  font-size: 12px;
  color: var(--hg-blue-primary);
  font-weight: 700;
  white-space: nowrap;
  margin-left: 8px;
}

@media (max-width: 600px) {
  .hg-save-hint {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .hg-save-hint-icon {
    text-align: center;
  }
  
  .hg-diary-thumb {
    width: 28px;
    height: 28px;
  }
}

/* ========================================
   日記編集モーダル内のガチャ表示設定
   ======================================== */

.hg-edit-section {
  margin: 16px 0;
  padding: 16px;
  background: rgba(74, 144, 226, 0.04);
  border: 1px solid rgba(74, 144, 226, 0.15);
  border-radius: 10px;
}

.hg-edit-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--hg-blue-deep);
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}

.hg-edit-section-desc {
  font-size: 11px;
  color: var(--hg-text-light);
  margin-bottom: 12px;
}

.hg-edit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hg-edit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--hg-white);
  border-radius: 8px;
  border: 1px solid rgba(74, 144, 226, 0.08);
  transition: opacity 0.2s, background 0.3s;
}

.hg-edit-item.is-saving {
  opacity: 0.5;
}

.hg-edit-item.is-saved {
  background: rgba(76, 217, 100, 0.08);
  border-color: rgba(76, 217, 100, 0.3);
}

/* トグルスイッチ風チェックボックス */
.hg-edit-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  cursor: pointer;
}

.hg-edit-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.hg-edit-toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 22px;
  transition: 0.2s;
}

.hg-edit-toggle-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}

.hg-edit-checkbox:checked + .hg-edit-toggle-slider {
  background: var(--hg-blue-primary);
}

.hg-edit-checkbox:checked + .hg-edit-toggle-slider::before {
  transform: translateX(16px);
}

.hg-edit-thumbs {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.hg-edit-thumb {
  width: 26px;
  height: 26px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  background-color: var(--hg-sky);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.hg-edit-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hg-edit-time {
  font-size: 12px;
  color: var(--hg-text);
  font-weight: 700;
}

.hg-edit-rare {
  display: inline-block;
  background: var(--hg-gold);
  color: var(--hg-white);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 2px;
}

.hg-edit-link {
  font-size: 11px;
  color: var(--hg-blue-primary);
  text-decoration: none;
}

.hg-edit-link:hover {
  text-decoration: underline;
}

/* ========================================
   トラックアイテムのクリック可能化
   ======================================== */

.hg-track-item[data-track-index] {
  cursor: pointer;
  user-select: none;
}

.hg-track-item[data-track-index]:focus-visible {
  outline: 2px solid var(--hg-blue-primary);
  outline-offset: 2px;
}

.hg-track-item[data-track-index] .hg-track-image {
  position: relative;
  overflow: hidden;
}

/* 再生アイコンオーバーレイ */
.hg-track-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: var(--hg-white);
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 8px;
  pointer-events: none;
}

.hg-track-item[data-track-index]:hover .hg-track-play-icon,
.hg-track-item[data-track-index]:focus-visible .hg-track-play-icon {
  opacity: 1;
}

/* 再生中のトラックには常時アイコン表示（パルス） */
.hg-track-item.is-playing .hg-track-play-icon {
  opacity: 1;
  background: rgba(74, 144, 226, 0.7);
  animation: hg-pulse 1.6s infinite;
}

@keyframes hg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* タップ時の軽いフィードバック */
.hg-track-item[data-track-index]:active {
  transform: scale(0.99);
  transition: transform 0.1s;
}

/* シェアボタンのコピー完了状態 */
.hg-share-btn.is-copied {
  background: #4cd964 !important;
  color: var(--hg-white) !important;
  transform: scale(1.02);
}

/* シェアエリアの説明テキスト */
.hg-share-hint {
  margin: 12px 0 0 0;
  font-size: 11px;
  color: var(--hg-text-light);
  line-height: 1.5;
  text-align: center;
}

/* ========================================
   もう一度引くエリア（結果ページ）
   ======================================== */

.hg-redraw-area {
  margin: 24px 0;
  text-align: center;
}

.hg-redraw-button {
  min-width: 240px;
}

/* 二次的なシェアエリア（ガチャトップ誘導用） */
.hg-share-area-secondary {
  margin-top: 12px;
  background: var(--hg-bg);
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.08);
}

.hg-share-area-secondary .hg-share-title {
  color: var(--hg-blue-deep);
  font-weight: 700;
}
