/* ==========================================================
 * My9VTuber - app.css
 * VTuber向けデザイン（紫系アクセント）
 * ========================================================== */

/* --- Webフォント: RocknRoll One（ローカルホスト） --- */
@font-face {
  font-family: 'RocknRoll One';
  src: url('/assets/fonts/RocknRollOne-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --- カラートークン --- */
:root {
  --bg: #F5F0FF;
  --card-bg: #FFFFFF;
  --text-main: #333333;
  --text-sub: #666666;
  --accent: #8B5CF6;
  --accent-hover: #7C3AED;
  --accent-light: #F5F3FF;
  --danger: #EF4444;
  --radius: 16px;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* --- リセット・ベース --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'RocknRoll One', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
img { display: block; max-width: 100%; }

/* --- ページヘッダー --- */
.page-header {
  text-align: center;
  padding: 28px 16px 8px;
}

.site-logo {
  font-family: 'RocknRoll One', 'Hiragino Kaku Gothic ProN', sans-serif;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--text-main);
  position: relative;
  display: inline-block;
}
.logo-accent {
  font-size: 2.8rem;
  color: var(--accent);
  vertical-align: baseline;
  text-shadow: 2px 2px 0 rgba(139, 92, 246, 0.15);
  margin: 0 2px;
}
.logo-nico {
  background: linear-gradient(135deg, var(--accent), #A78BFA);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.site-logo::after {
  content: '';
  display: block;
  width: 60%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #C4B5FD);
  border-radius: 2px;
  margin: 6px auto 0;
}

.page-header .subtitle {
  font-size: 0.88rem;
  color: var(--text-sub);
  margin-top: 8px;
}

/* --- メインレイアウト --- */
.main-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* --- リスト名入力 --- */
.title-input-wrap {
  text-align: center;
  margin-bottom: 16px;
}
.title-input {
  width: 100%;
  max-width: 480px;
  padding: 10px 16px;
  font-family: 'RocknRoll One', 'Hiragino Kaku Gothic ProN', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  background: var(--card-bg);
  outline: none;
  transition: border-color 0.2s;
}
.title-input:focus { border-color: var(--accent); }
.title-input::placeholder { color: #bbb; font-weight: 400; }

/* --- 3×3グリッド --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* --- カード --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.card:hover { box-shadow: var(--shadow-lg); }

/* 番号バッジ */
.card .badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  line-height: 1;
}

/* 削除ボタン */
.card .btn-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover .btn-remove { opacity: 1; }

/* サムネイル */
.card .thumb-wrap {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 正方形 */
  background: #f0f0f0;
  overflow: hidden;
}
.card .thumb-wrap img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-touch-callout: none;
  pointer-events: none;
}

/* カード情報 */
.card .card-info { padding: 8px 10px; }
.card .card-title {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-main);
  min-height: 1.2em;
  text-align: center;
}
.card .card-agency {
  font-size: 0.68rem;
  color: var(--text-sub);
  text-align: center;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- プレースホルダー（未選択） --- */
.card.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  cursor: pointer;
  border: 2px dashed #DDD;
  background: var(--accent-light);
  box-shadow: none;
}
.card.placeholder:hover {
  border-color: var(--accent);
  background: #EDE9FE;
}
.card.placeholder .placeholder-text {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}
.card.placeholder .placeholder-text .plus {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 2px;
}

/* --- アクションバー --- */
.action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  justify-content: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.btn-outline { background: var(--card-bg); color: var(--text-main); border: 1.5px solid #DDD; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger-outline { background: var(--card-bg); color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger-outline:hover { background: #FEF2F2; }

.btn-x { background: #000; color: #fff; }
.btn-x:hover { background: #333; }

.btn-copy { background: #2563EB; color: #fff; border: none; }
.btn-copy:hover { background: #1D4ED8; }

/* --- 検索モーダル --- */
.add-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 16px 24px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.2s ease-out;
}
@keyframes modalFadeIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.add-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.add-modal-header h3 { font-size: 1rem; font-weight: 700; }
.add-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-sub);
  padding: 4px;
  line-height: 1;
}

/* 検索入力 */
.search-box {
  display: flex;
  gap: 8px;
}
.search-box input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #DDD;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); }

/* 検索結果リスト */
.search-results {
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.search-result-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  align-items: center;
}
.search-result-item:hover { background: var(--accent-light); }
.search-result-item .sr-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #f0f0f0;
}
.search-result-item .sr-info {
  flex: 1;
  min-width: 0;
}
.search-result-item .sr-title {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-item .sr-meta {
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-top: 2px;
}

.search-status {
  text-align: center;
  padding: 16px 0;
  font-size: 0.82rem;
  color: var(--text-sub);
}

/* --- 通知 --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333;
  color: #fff;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 1000;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- 共有ページ --- */
.share-page .card { cursor: default; }
.share-page .card .btn-remove { display: none; }
.share-actions { text-align: center; margin-top: 20px; }

/* --- 生成画像プレビュー --- */
.image-preview {
  margin-top: 24px;
  text-align: center;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.image-preview img {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  margin: 0 auto;
}
.preview-actions { margin-top: 16px; }
.preview-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.preview-row + .preview-row { margin-top: 8px; }

/* --- 共有URL表示 --- */
.share-url-display {
  margin-top: 16px;
  padding: 12px;
  background: #F9FAFB;
  border-radius: 8px;
  word-break: break-all;
  font-size: 0.82rem;
  color: var(--accent);
  text-align: center;
}
.share-url-display a { color: var(--accent); }

/* --- フッター --- */
.page-footer {
  text-align: center;
  padding: 24px 16px 32px;
}
.footer-brand {
  font-family: 'RocknRoll One', 'Hiragino Kaku Gothic ProN', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 8px;
}

/* --- ローディング --- */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #ddd;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- リスト並べ替え（ドラッグ） --- */
@keyframes jiggle {
  0%, 100% { transform: rotate(-1.2deg); }
  50% { transform: rotate(1.2deg); }
}
.card-grid.jiggle .card:not(.placeholder) {
  animation: jiggle 0.25s ease-in-out infinite;
}
.card-grid.jiggle .card:nth-child(even) { animation-delay: 0.12s; }
.card-grid.jiggle .btn-remove { opacity: 1; }

.card.drag-active {
  position: fixed !important;
  z-index: 1000;
  pointer-events: none;
  transform: skewX(-5deg) scale(1.06);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  opacity: 0.92;
  transition: none;
  animation: none !important;
}
.card.drag-origin { opacity: 0.3; border: 2px dashed var(--accent); }
.card.drag-target { box-shadow: 0 0 0 3px var(--accent); transform: scale(0.95); transition: transform 0.15s; }

.reorder-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-sub);
  margin: 8px 0 0;
}

/* --- レスポンシブ --- */
@media (max-width: 768px) {
  .main-container { padding: 0 12px 32px; }
  .card-grid { gap: 8px; }
  .card .card-info { padding: 6px 8px; }
  .card .card-title { font-size: 0.72rem; }
  .card .card-agency { font-size: 0.6rem; }
  .card .badge { width: 18px; height: 18px; font-size: 0.6rem; }
  .card.placeholder { min-height: 120px; }
  .site-logo { font-size: 1.5rem; }
  .logo-accent { font-size: 2.1rem; }
  .btn { padding: 8px 14px; font-size: 0.8rem; }
}
