/* ============================================================
   Chronica Characters — フロントエンド CSS

   目次:
     §1  カスタムプロパティ
     §2  カードグリッド
     §3  キャラクターカード
     §4  body スクロールロック
     §5  キャラクターモーダル（オーバーレイ）
     §6  モーダル内部レイアウト
     §7  プロフィールグリッド
     §8  説明文
     §9  表情差分ギャラリー
     §10 表情差分ライトボックス
     §11 レスポンシブ
     §12 prefers-reduced-motion
   ============================================================ */

/* ============================================================
   §1 カスタムプロパティ
      .cc-wrap に定義 → 子要素が継承
      テーマ側で上書き可能
   ============================================================ */
.cc-wrap {
  --cc-bg:         #1c1814;
  --cc-surface:    #28211a;
  --cc-paper:      #f5efe6;
  --cc-paper-dim:  #c8bfb2;
  --cc-brass:      #c8a45a;
  --cc-muted:      #7a6e65;
  --cc-backdrop:   rgba(0, 0, 0, .74);
}

/* ============================================================
   §2 カードグリッド
   ============================================================ */
.cc-char-grid {
  display: grid;
  grid-template-columns: repeat(var(--cc-columns, 5), 1fr);
  gap: 10px;
}

/* ============================================================
   §3 キャラクターカード
   ============================================================ */
.cc-char-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--cc-surface);
  border: 1px solid rgba(200, 164, 90, .20);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-family: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.cc-char-card:hover,
.cc-char-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .50);
  border-color: rgba(200, 164, 90, .55);
  outline: none;
}

.cc-char-card-img-wrap {
  aspect-ratio: 5 / 6;
  overflow: hidden;
  background: var(--cc-bg);
}

.cc-char-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.cc-char-card-img--placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #2e261e 0%, #1c1814 100%);
}

.cc-char-card-foot {
  padding: 7px 9px 8px;
  background: var(--cc-surface);
}

.cc-char-card-label {
  display: block;
  font-size: .54rem;
  letter-spacing: .08em;
  color: var(--cc-brass);
  margin-bottom: 2px;
  opacity: .82;
}

.cc-char-card-name {
  margin: 0;
  min-height: calc(1em * 2.56);
  font-size: .77rem;
  font-weight: 600;
  color: var(--cc-paper);
  line-height: 1.28;
}

/* ============================================================
   §4 body スクロールロック
   ============================================================ */
body.cc-modal-open {
  overflow: hidden;
}

/* ============================================================
   §5 キャラクターモーダル（オーバーレイ）
   ============================================================ */
.cc-char-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease;
}

.cc-char-modal.is-open {
  pointer-events: auto;
  opacity: 1;
}

/* バックドロップ */
.cc-char-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--cc-backdrop);
}

/* ============================================================
   §6 モーダル内部レイアウト
   ============================================================ */

/* パネル本体 */
.cc-char-modal-inner {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  max-width: 920px;
  min-height: min(560px, 76vh);
  max-height: 90vh;
  background: var(--cc-bg);
  border: 1px solid rgba(200, 164, 90, .28);
  border-radius: 6px;
  overflow: hidden;
  /* 入場アニメーション（.is-open で解除） */
  transform: translateY(20px) scale(.93);
  opacity: 0;
  transition: transform .36s cubic-bezier(.22, 1, .36, 1),
              opacity    .28s ease;
}

.cc-char-modal.is-open .cc-char-modal-inner {
  transform: none;
  opacity: 1;
}

/* 左カラム: 立ち絵 */
.cc-char-modal-img-col {
  width: 268px;
  flex-shrink: 0;
  background: var(--cc-surface);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 14px;
}

.cc-char-modal-img {
  width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center top;
  display: block;
}

/* 右カラム: 情報 */
.cc-char-modal-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ヘッダー */
.cc-char-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid rgba(200, 164, 90, .18);
  flex-shrink: 0;
}

.cc-char-modal-titles {
  flex: 1;
  min-width: 0;
}

.cc-char-modal-name {
  margin: 0 0 4px;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--cc-paper);
  letter-spacing: .04em;
}

.cc-char-modal-role {
  margin: 0;
  font-size: .72rem;
  color: var(--cc-brass);
  letter-spacing: .06em;
  opacity: .86;
}

/* 閉じるボタン */
.cc-char-modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 4px;
  color: var(--cc-paper);
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: 0;
  transition: background .15s ease;
}

.cc-char-modal-close:hover,
.cc-char-modal-close:focus-visible {
  background: rgba(255, 255, 255, .14);
  outline: 2px solid var(--cc-brass);
  outline-offset: 2px;
}

/* ボディ（スクロール可能） */
.cc-char-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   §7 プロフィールグリッド
   ============================================================ */
.cc-char-modal-profile {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 14px;
}

.cc-char-profile-item {
  display: flex;
  gap: 8px;
  font-size: .73rem;
  line-height: 1.5;
  border-bottom: 1px solid rgba(200, 164, 90, .12);
  padding-bottom: 4px;
}

.cc-char-profile-key {
  flex-shrink: 0;
  min-width: 3em;
  color: var(--cc-brass);
  opacity: .84;
}

.cc-char-profile-val {
  color: var(--cc-paper);
}

/* ============================================================
   §8 説明文
   ============================================================ */
.cc-char-modal-desc {
  margin: 0;
  font-size: .79rem;
  line-height: 1.78;
  color: var(--cc-paper);
  opacity: .90;
}

/* ============================================================
   §9 表情差分ギャラリー
   ============================================================ */
/* .cc-char-expressions の display は JS で制御 */

.cc-char-expressions-label {
  margin: 0 0 8px;
  font-size: .64rem;
  letter-spacing: .10em;
  color: var(--cc-muted);
  text-transform: uppercase;
}

.cc-char-expressions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 7px;
}

.cc-expr-item {
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  background: var(--cc-surface);
  border: 1px solid transparent;
  text-align: center;
  transition: border-color .15s ease, transform .15s ease;
}

.cc-expr-item:hover,
.cc-expr-item:focus-visible {
  border-color: var(--cc-brass);
  transform: scale(1.05);
  outline: none;
}

.cc-expr-item-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}

.cc-expr-item-cap {
  display: block;
  font-size: .56rem;
  padding: 3px 4px;
  color: var(--cc-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   §10 表情差分ライトボックス
       z-index 300 でキャラモーダル（200）の上に重なる
   ============================================================ */
.cc-expr-lb {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .20s ease;
}

.cc-expr-lb.is-open {
  pointer-events: auto;
  opacity: 1;
}

.cc-expr-lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .86);
}

.cc-expr-lb-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: scale(.92);
  opacity: 0;
  transition: transform .28s cubic-bezier(.22, 1, .36, 1),
              opacity    .22s ease;
}

.cc-expr-lb.is-open .cc-expr-lb-inner {
  transform: none;
  opacity: 1;
}

.cc-expr-lb-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 4px;
  color: #fff;
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: 0;
  transition: background .15s ease;
}

.cc-expr-lb-close:hover,
.cc-expr-lb-close:focus-visible {
  background: rgba(255, 255, 255, .22);
  outline: 2px solid var(--cc-brass);
  outline-offset: 2px;
}

/* width で強制拡大（max-width はネイティブサイズより小さい画像を拡大しない） */
.cc-expr-lb-img {
  width: min(460px, 86vw);
  height: auto;
  max-height: 78vh;
  object-fit: contain;
  display: block;
  border-radius: 3px;
}

.cc-expr-lb-caption {
  margin: 0;
  font-size: .78rem;
  color: rgba(255, 255, 255, .72);
  text-align: center;
}

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

/* タブレット: モーダルを縦並びに */
@media (max-width: 900px) {
  .cc-char-modal-inner {
    flex-direction: column;
    max-height: 95vh;
    min-height: 0;
  }

  .cc-char-modal-img-col {
    width: 100%;
    max-height: 230px;
    padding: 16px;
  }

  .cc-char-modal-img {
    max-height: 198px;
    width: auto;
    margin: 0 auto;
  }
}

/* 中画面: 列数を最大 3 に抑制 */
@media (max-width: 680px) {
  .cc-char-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

/* 小画面: 2 列 + プロフィール 1 列 */
@media (max-width: 440px) {
  .cc-char-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .cc-char-modal-profile {
    grid-template-columns: 1fr;
  }

  .cc-char-modal-body {
    padding: 14px 16px 20px;
  }

  .cc-char-modal-header {
    padding: 14px 16px 12px;
  }

  .cc-char-card-foot {
    padding: 6px 7px 7px;
  }
}

/* ============================================================
   §12 prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .cc-char-modal,
  .cc-char-modal-inner,
  .cc-char-card,
  .cc-expr-lb,
  .cc-expr-lb-inner,
  .cc-expr-item {
    transition: none !important;
    transform:  none !important;
  }
}
