/* ============================================================
   cmp- : 比較表セレクタの機能CSS（サイトに組み込む本体）
   ============================================================ */

.cmp-select,
.cmp-result {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 1rem;
}

.cmp-select table,
.cmp-result table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  min-width: 620px;
}

.cmp-select th,
.cmp-select td,
.cmp-result th,
.cmp-result td {
  min-width: 110px;
  padding: 0.6em 0.8em;
  border-bottom: 1px solid #dcdfe4;
  text-align: left;
  vertical-align: middle;
}

.cmp-select thead th,
.cmp-result thead th {
  background: #f4f6f9;
  border-bottom: 2px solid #d0d5dd;
  font-weight: 700;
}

/* チェック列 */

.cmp-check-col {
  min-width: 56px;
  width: 56px;
  text-align: center;
}

.cmp-check-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0 auto;
  cursor: pointer;
}

.cmp-check {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.cmp-check-col--disabled {
  opacity: 0.4;
}

.cmp-check-col--disabled .cmp-check-label {
  cursor: not-allowed;
}

/* 並び替え可能な見出し */

.cmp-sortable {
  cursor: pointer;
  user-select: none;
  /* display: table-cell には min-height が効かないため指定しない。
     タップ領域44px以上は上下の padding（0.6em）+ line-height で担保している */
}

.cmp-sortable:hover {
  background: #eaeef3;
}

.cmp-sortable:focus-visible {
  outline: 2px solid #2f6fed;
  outline-offset: -2px;
}

.cmp-sort-arrow {
  display: inline-block;
  margin-left: 0.35em;
  font-size: 0.8em;
  color: #6b7280;
}

.cmp-sort-asc .cmp-sort-arrow,
.cmp-sort-desc .cmp-sort-arrow {
  color: #2f6fed;
}

/* ツール（元の順に戻す／元のHTMLを見る） */

.cmp-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin: 0 0 2rem;
}

.cmp-restore-btn,
.cmp-source-toggle {
  min-height: 44px;
  padding: 0.5em 1em;
  border: 1px solid #c7ccd4;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2933;
  font-size: 0.9rem;
  cursor: pointer;
}

.cmp-restore-btn:hover,
.cmp-source-toggle:hover {
  background: #f4f6f9;
}

.cmp-source-panel {
  width: 100%;
  margin-top: 0.6em;
}

.cmp-source-panel pre {
  margin: 0;
  padding: 1em;
  background: #1f2933;
  color: #e5e9f0;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.6;
}

.cmp-source-panel mark {
  background: #ffd866;
  color: #1f2933;
  padding: 0 0.1em;
  border-radius: 2px;
}

/* 比較結果表（転置表） */

.cmp-result {
  margin-top: 1rem;
  border: 1px solid #dcdfe4;
  border-radius: 8px;
  /* padding は付けない（sticky 1列目が padding 領域に重なるため）。
     余白が必要な場合はテーブル内側（th/td の padding）で担保する */
}

.cmp-result th:first-child,
.cmp-result td:first-child {
  position: sticky;
  left: 0;
  background: #ffffff;
  box-shadow: 1px 0 0 #dcdfe4;
  z-index: 1;
}

.cmp-result thead th:first-child {
  background: #f4f6f9;
  z-index: 2;
}

/* 固定バー */

.cmp-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 0.8em 1.2em;
  background: #1f2933;
  color: #ffffff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
}

.cmp-bar[hidden] {
  display: none;
}

.cmp-bar-count {
  font-weight: 700;
  white-space: nowrap;
}

.cmp-bar-actions {
  display: flex;
  gap: 0.6em;
}

.cmp-bar-compare,
.cmp-bar-reset {
  min-height: 44px;
  padding: 0.5em 1.1em;
  border-radius: 6px;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.cmp-bar-compare {
  background: #2f6fed;
  color: #ffffff;
}

.cmp-bar-compare:hover {
  background: #255bc7;
}

.cmp-bar-reset {
  background: transparent;
  color: #ffffff;
  border: 1px solid #6b7280;
}

.cmp-bar-reset:hover {
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 480px) {
  .cmp-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .cmp-bar-actions {
    justify-content: stretch;
  }

  .cmp-bar-compare,
  .cmp-bar-reset {
    flex: 1;
  }
}

/* ============================================================
   demo- : ポートフォリオ用デモページの装飾（機能CSSとは無関係）
   ============================================================ */

.demo-body * {
  box-sizing: border-box;
}

body.demo-body {
  --demo-bg: #f7f8fa;
  --demo-surface: #ffffff;
  --demo-text: #1f2933;
  --demo-muted: #5b6472;
  --demo-border: #e2e5ea;
  --demo-accent: #2f6fed;
  margin: 0;
  background: var(--demo-bg);
  color: var(--demo-text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  line-height: 1.8;
  padding-bottom: 6rem;
}

.demo-container {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem;
}

.demo-header {
  margin-bottom: 2rem;
}

.demo-title {
  font-size: 1.6rem;
  margin: 0 0 0.6em;
}

.demo-lead {
  color: var(--demo-muted);
  margin: 0;
}

.demo-section {
  background: var(--demo-surface);
  border: 1px solid var(--demo-border);
  border-radius: 10px;
  padding: 1.5rem 1.5rem 1.25rem;
  margin-bottom: 1.5rem;
}

.demo-section-title {
  font-size: 1.15rem;
  margin: 0 0 0.8em;
}

.demo-section p {
  margin: 0 0 0.9em;
}

.demo-section p:last-child {
  margin-bottom: 0;
}

.demo-steps {
  margin: 0;
  padding-left: 1.3em;
}

.demo-steps li {
  margin-bottom: 0.5em;
}

.demo-points {
  margin: 0;
  padding-left: 1.3em;
}

.demo-points li {
  margin-bottom: 0.6em;
}

.demo-table-block {
  margin-bottom: 2.5rem;
}

.demo-table-title {
  font-size: 1.05rem;
  margin: 0 0 0.8em;
  padding-bottom: 0.4em;
  border-bottom: 2px solid var(--demo-accent);
  display: inline-block;
}

.demo-btn {
  display: inline-block;
  margin-top: 0.3em;
  padding: 0.3em 0.8em;
  background: var(--demo-accent);
  color: #ffffff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.85rem;
}

.demo-btn:hover {
  background: #255bc7;
}

.demo-footer {
  margin-top: 2rem;
  color: var(--demo-muted);
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 480px) {
  .demo-container {
    padding: 1.5rem 1rem;
  }

  .demo-section {
    padding: 1.2rem 1rem;
  }
}
