/* 攻略wiki レイアウトCSS */
/* common-theme.css の変数を使用 */

/* ========== 全体レイアウト ========== */

body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-body);
  font-family: var(--font-family);
  min-height: 100vh;
}

/* ヘッダー */
.wiki-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: var(--header-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.wiki-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wiki-header-left a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 700;
}

.wiki-header-left a:hover {
  color: var(--accent);
}

.wiki-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wiki-header-right .user-name {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.btn-logout,
.btn-login {
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.btn-login {
  background: var(--bg-accent);
  color: #fff;
}

.btn-login:hover {
  background: var(--bg-accent-hover);
}

.btn-logout {
  background: var(--bg-btn);
  color: var(--text-secondary);
  border: 1px solid var(--border-base);
}

.btn-logout:hover {
  background: var(--bg-btn-hover);
  color: var(--text-body);
}

/* ハンバーガーメニュー（モバイル用） */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

/* 2カラムレイアウト */
.wiki-layout {
  display: flex;
  min-height: calc(100vh - 53px);
}

/* ========== サイドバー ========== */

#sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-base);
  padding: 16px 0;
  position: sticky;
  top: 53px;
  height: calc(100vh - 53px);
  overflow-y: auto;
  box-sizing: border-box;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  padding: 8px 20px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-link {
  display: block;
  padding: 7px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-link:hover {
  background: var(--bg-btn);
  color: var(--text-primary);
}

.nav-link.active {
  border-left-color: var(--bordeaux);
  color: var(--text-primary);
  background: var(--bordeaux-bg);
}

.nav-link.disabled {
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.6;
}

.nav-link.sub {
  padding-left: 36px;
  font-size: 0.84rem;
}

/* サイドバーオーバーレイ（モバイル用） */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 199;
}

.sidebar-overlay.visible {
  display: block;
}

/* ========== メインコンテンツ ========== */

#content {
  flex: 1;
  padding: 24px 32px;
  max-width: 900px;
  box-sizing: border-box;
}

/* パンくず */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 0.84rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.breadcrumb .separator {
  color: var(--text-muted);
}

.breadcrumb .current {
  color: var(--text-body);
}

/* セクション見出し */
.section-heading {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-base);
  margin: 32px 0 16px;
}

.section-heading:first-of-type {
  margin-top: 0;
}

/* ページ内目次 */
.page-toc {
  background: var(--bg-card);
  border-left: var(--card-left-border);
  border-radius: 0 4px 4px 0;
  padding: 14px 20px;
  margin-bottom: 24px;
}

.page-toc-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.page-toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-toc li {
  margin: 4px 0;
}

.page-toc a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}

.page-toc a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ========== ティアリスト ========== */

.tier-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.tier-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border-base);
  min-height: 60px;
}

.tier-label {
  width: 48px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.tier-label-S { background: #c0392b; }
.tier-label-A { background: #e67e22; }
.tier-label-B { background: #f1c40f; color: #333; }
.tier-label-C { background: #27ae60; }
.tier-label-D { background: #2980b9; }

.tier-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  align-items: center;
  flex: 1;
}

.tier-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 4px 0;
}

/* ========== 武将カード ========== */

.general-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-base);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-body);
  transition: border-color 0.15s, background 0.15s;
}

.general-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-btn);
}

.general-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-base);
}

.general-card-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.general-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.general-card-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* 武将カード（一覧用の大きめサイズ） */
.general-card-lg {
  padding: 10px 14px;
}

.general-card-lg .general-card-icon {
  width: 44px;
  height: 44px;
}

.general-card-lg .general-card-name {
  font-size: 0.92rem;
}

/* ========== 武将インラインリンク ========== */

.general-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
}

.general-inline-link:hover {
  text-decoration: underline;
}

.general-inline-link img {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  vertical-align: middle;
}

/* ========== wiki内部リンク ========== */

.wiki-link {
  color: var(--accent);
  text-decoration: none;
}

.wiki-link:hover {
  text-decoration: underline;
}

/* ========== 環境メモ ========== */

.env-note {
  background: var(--bg-card);
  border: 1px solid var(--border-base);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
  line-height: 1.7;
  color: var(--text-body);
}

/* ========== メタ情報 ========== */

.meta-info {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.meta-tag {
  background: var(--bordeaux-bg);
  color: var(--bordeaux-text);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ========== フィルタ ========== */

.filter-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: flex-start;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-toggles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-toggle {
  padding: 5px 12px;
  border: 1px solid var(--border-base);
  border-radius: 4px;
  background: var(--bg-btn);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-toggle:hover {
  background: var(--bg-btn-hover);
  color: var(--text-body);
}

.filter-toggle.active {
  background: var(--bg-accent);
  color: #fff;
  border-color: var(--bg-accent);
}

/* ========== 武将一覧グリッド ========== */

.generals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.generals-grid .general-card {
  width: 100%;
  box-sizing: border-box;
}

/* 一覧ティアセクション */
.tier-section-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 0 10px;
  padding-left: 4px;
}

/* ========== 武将個別ページ ========== */

.general-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.general-header-icon {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-card);
}

.general-header-info {
  flex: 1;
}

.general-header-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.general-header-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.general-header-tier {
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #fff;
}

.tier-badge-S { background: #c0392b; }
.tier-badge-A { background: #e67e22; }
.tier-badge-B { background: #f1c40f; color: #333; }
.tier-badge-C { background: #27ae60; }
.tier-badge-D { background: #2980b9; }

/* 評価セクション */
.eval-list {
  margin: 0;
  padding: 0 0 0 20px;
  line-height: 1.8;
}

.eval-list li {
  color: var(--text-body);
}

.eval-comment {
  background: var(--bg-card);
  border-left: var(--card-left-border);
  padding: 12px 16px;
  border-radius: 0 4px 4px 0;
  line-height: 1.7;
  color: var(--text-body);
  margin: 8px 0;
}

/* ティア変遷 */
.tier-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tier-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.tier-history-label {
  width: 120px;
  min-width: 120px;
  color: var(--text-secondary);
  text-align: right;
}

.tier-history-bar {
  height: 22px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  min-width: 32px;
}

.tier-bar-S { background: #c0392b; width: 100%; }
.tier-bar-A { background: #e67e22; width: 80%; }
.tier-bar-B { background: #f1c40f; width: 60%; color: #333; }
.tier-bar-C { background: #27ae60; width: 40%; }
.tier-bar-D { background: #2980b9; width: 20%; }

/* 準備中表示 */
.placeholder-text {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 12px 0;
}

/* 関連ページ */
#related-pages {
  border-top: 1px solid var(--border-base);
  margin-top: 40px;
  padding-top: 20px;
}

.related-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* ========== 過去ティアリストリンク ========== */

.tier-history-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tier-history-links li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-base);
}

.tier-history-links li:last-child {
  border-bottom: none;
}

.tier-history-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.tier-history-links a:hover {
  text-decoration: underline;
}

/* ========== ローディング・認証画面 ========== */

.loading-screen,
.login-screen,
.denied-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 16px;
}

.loading-screen p,
.denied-screen p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.login-screen p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

/* 通知 */
.notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  color: var(--text-body);
  border: 1px solid var(--border-base);
  border-radius: 6px;
  padding: 12px 20px;
  font-size: 0.88rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}

.notification.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========== レスポンシブ ========== */

@media (max-width: 768px) {
  .hamburger-btn {
    display: block;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    height: 100vh;
    z-index: 200;
    transition: left 0.25s ease;
    padding-top: 16px;
  }

  #sidebar.open {
    left: 0;
  }

  .wiki-layout {
    flex-direction: column;
  }

  #content {
    padding: 16px;
    max-width: 100%;
  }

  .generals-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .general-header {
    flex-wrap: wrap;
  }

  .tier-history-label {
    width: 80px;
    min-width: 80px;
    font-size: 0.78rem;
  }

  .filter-bar {
    gap: 10px;
  }

  .meta-info {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }
}
