/* ===========================================
 * Entity Detail Page - シリーズ / マイリスト解析ページ
 * =========================================== */

.entity-detail-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px clamp(12px, 2vw, 24px);
}

/* ===== 詳細ヘッダー ===== */
.entity-detail-header {
  position: relative;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 12px;
}

.entity-analysis-summary {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 14px 18px;
  margin-bottom: 12px;
}

.entity-analysis-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.entity-analysis-heading h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #1f2937;
}

.entity-analysis-count {
  color: #64748b;
  font-size: 0.84rem;
  font-weight: 800;
}

.entity-analysis-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.entity-analysis-heading > span,
.entity-analysis-actions span {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.entity-analysis-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.entity-analysis-button:hover,
.entity-analysis-button:focus-visible {
  background: #dbeafe;
  border-color: #93c5fd;
}

.entity-analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.entity-analysis-item {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
}

.entity-analysis-item span {
  display: block;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.entity-analysis-item strong {
  display: block;
  color: #1f2937;
  font-size: 0.95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.entity-analysis-notes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  color: #52606d;
  font-size: 0.8rem;
}

.entity-analysis-notes a {
  color: #0066cc;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.entity-analysis-notes a:hover {
  text-decoration: underline;
}

.entity-analysis-error {
  margin: 8px 0 0;
  color: #b91c1c;
  font-size: 0.82rem;
  font-weight: 700;
}

/* 解析データの遅延ロード中プレースホルダ（C方式） */
.entity-analysis-loading-text {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 700;
}

.entity-analysis-loading-text::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: 6px;
  vertical-align: -1px;
  border: 2px solid #cbd5e1;
  border-top-color: #64748b;
  border-radius: 50%;
  animation: entity-analysis-spin 0.7s linear infinite;
}

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

.entity-analysis-retry {
  margin-left: 8px;
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1f2937;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
}

.entity-modal-open {
  overflow: hidden;
}

.entity-modal[hidden] {
  display: none;
}

.entity-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.entity-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
}

.entity-modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.28);
}

.entity-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}

.entity-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #1f2937;
}

.entity-modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.entity-modal-close:hover,
.entity-modal-close:focus-visible {
  background: #f8fafc;
  border-color: #94a3b8;
}

.entity-modal-body {
  padding: 16px 18px 18px;
}

.entity-pace-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.entity-pace-item {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
}

.entity-pace-item span {
  display: block;
  margin-bottom: 3px;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
}

.entity-pace-item strong {
  display: block;
  color: #111827;
  font-size: 0.92rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.entity-pace-note {
  margin-top: 14px;
}

.entity-pace-note h4 {
  margin: 0 0 6px;
  color: #1f2937;
  font-size: 0.9rem;
  font-weight: 800;
}

.entity-pace-note p {
  margin: 0;
  color: #4b5563;
  font-size: 0.84rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.entity-pace-months {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.entity-pace-months span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.78rem;
}

.entity-detail-header-inner {
  display: flex;
  gap: 16px;
  padding: 16px 18px;
}

.entity-detail-thumb {
  flex: 0 0 auto;
}

.entity-detail-thumb img {
  width: 160px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  background: #edf2f7;
}

.entity-detail-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entity-detail-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: #1f2937;
  line-height: 1.35;
}

.entity-detail-owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: #52606d;
  font-size: 0.82rem;
}

.entity-detail-owner-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
}

.entity-detail-owner-link:hover .entity-owner-name {
  text-decoration: underline;
}

.entity-detail-meta {
  display: flex;
  gap: 10px 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #4b5563;
}

.entity-detail-meta strong {
  font-weight: 700;
  color: #1f2937;
}

.entity-detail-desc {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.entity-detail-actions {
  margin-top: 6px;
}

.entity-detail-header-series .entity-detail-info,
.entity-detail-header-mylist .entity-detail-info {
  padding-right: 118px;
}

.entity-detail-header-series .entity-detail-actions,
.entity-detail-header-mylist .entity-detail-actions {
  position: absolute;
  top: 14px;
  right: 16px;
  margin-top: 0;
}

/* ===== コンテンツ部 ===== */
.entity-detail-content {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 16px 18px;
}

.entity-detail-content .result-sort-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.result-title-filter {
  flex: 1 1 180px;
  min-width: 0;
  height: 34px;
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  font-size: 0.86rem;
}

.result-filter-submit,
.result-filter-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.result-filter-submit:hover,
.result-filter-clear:hover {
  background: #eef6ff;
  border-color: #93c5fd;
  text-decoration: none;
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .entity-detail-page {
    padding: 10px 10px;
  }

  .entity-detail-header-inner {
    flex-direction: column;
    padding: 12px 14px;
    gap: 10px;
  }

  .entity-detail-header-series .entity-detail-info,
  .entity-detail-header-mylist .entity-detail-info {
    padding-right: 0;
  }

  .entity-detail-header-series .entity-detail-actions,
  .entity-detail-header-mylist .entity-detail-actions {
    top: 12px;
    right: 14px;
  }

  .entity-detail-header-series .entity-detail-title,
  .entity-detail-header-mylist .entity-detail-title {
    padding-right: 96px;
  }

  .entity-detail-thumb img {
    width: 100%;
    max-width: 280px;
  }

  .entity-detail-title {
    font-size: 1rem;
  }

  .entity-detail-content {
    padding: 12px 12px;
  }

  .entity-analysis-summary {
    padding: 12px 12px;
  }

  .entity-analysis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entity-analysis-heading {
    align-items: flex-start;
    flex-direction: row;
  }

  .entity-analysis-actions {
    justify-content: flex-end;
  }

  .entity-pace-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entity-modal {
    padding: 10px;
  }
}
