/*
 * alchemist-base.css
 *
 * あるけみすと ベースデザイン定義
 * - デザイントークン（CSS変数）の一元管理
 * - Bootstrap 5 と競合しない独自コンポーネント
 * - 個別ページ・ゲーム固有スタイルはここに書かない
 *
 * 使用方法:
 *   <link rel="stylesheet" href="{% static 'alchemist-base.css' %}">
 *   ※ bootstrap.min.css の後に読み込むこと
 */

/* ==========================================================================
   1. デザイントークン（CSS変数）
   ========================================================================== */

:root {
  /* --- ブランドカラー --- */
  --al-color-primary:   #a81caf; /* メインカラー（マゼンタ） */
  --al-color-primary-dark: #8d1393;
  --al-color-primary-darker: #740e78;

  /* --- やさしいカラーパレット --- */
  --al-color-lavender:  #c4a3d4;
  --al-color-lavender-dark: #a890c0;
  --al-color-sky:       #97baf1;
  --al-color-sky-dark:  #76a8ee;
  --al-color-mint:      #4db6ac;
  --al-color-mint-dark: #3da09a;
  --al-color-peach:     #ffc98c;
  --al-color-peach-dark: #ffb56d;
  --al-color-rose:      #ffb7c6;
  --al-color-rose-dark: #ffa1b3;
  --al-color-sand:      #dde3b6;
  --al-color-sand-dark: #d2dca1;

  /* --- テキスト --- */
  --al-color-text-primary:   #2D2A26;
  --al-color-text-secondary: #5C5850;
  --al-color-text-muted:     #A8A49C;
  --al-color-text-on-dark:   #ffffff;

  /* --- 背景・サーフェス --- */
  --al-color-surface:        #FDFBF7;
  --al-color-surface-card:   rgba(255, 255, 255, 0.85);
  --al-color-surface-subtle: rgba(240, 240, 240, 0.6);
  --al-color-surface-border: rgba(168, 161, 161, 0.4);

  /* --- ステータスカラー（ランク） --- */
  --al-color-rank-f: #494969;
  --al-color-rank-e: #008000;
  --al-color-rank-d: #8B0000;
  --al-color-rank-c: #0000cd;
  --al-color-rank-b: #DF6C00;
  --al-color-rank-a: #FF0000;
  --al-color-rank-s: #9932cc;

  /* --- バッジ/アクセント --- */
  --al-color-badge-lavender: #c4a3d4;

  /* --- スペーシング --- */
  --al-space-xs:  4px;
  --al-space-s:   8px;
  --al-space-m:  16px;
  --al-space-l:  24px;
  --al-space-xl: 32px;
  --al-space-xxl: 48px;

  /* --- ボーダー半径 --- */
  --al-radius-s:    4px;
  --al-radius-m:    8px;
  --al-radius-l:   12px;
  --al-radius-full: 9999px;

  /* --- シャドウ --- */
  --al-shadow-card:     0 2px 8px rgba(45, 42, 38, 0.08);
  --al-shadow-floating: 0 4px 16px rgba(45, 42, 38, 0.12);
  --al-shadow-primary:  0 2px 4px rgba(168, 28, 175, 0.25);

  /* --- タイポグラフィ --- */
  --al-font-size-xs: 12px;
  --al-font-size-s:  14px;
  --al-font-size-m:  16px;
  --al-font-size-l:  18px;
  --al-font-size-xl: 24px;

  /* --- Z-index --- */
  --al-z-sticky: 100;
  --al-z-modal:  1000;
  --al-z-toast:  1100;
}


/* ==========================================================================
   2. ランクカラー（クラス）
   ========================================================================== */

.al-rank-f { color: var(--al-color-rank-f); }
.al-rank-e { color: var(--al-color-rank-e); }
.al-rank-d { color: var(--al-color-rank-d); }
.al-rank-c { color: var(--al-color-rank-c); }
.al-rank-b { color: var(--al-color-rank-b); }
.al-rank-a { color: var(--al-color-rank-a); }
.al-rank-s { color: var(--al-color-rank-s); }


/* ==========================================================================
   3. ボタン（Bootstrap 非依存）
   ==========================================================================
   使い方: class="btn-al btn-alchemist-mint"
   btn-al  → 基底スタイル（形・サイズ・クロスブラウザ対応）
   btn-alchemist-* → 色の指定
   ========================================================================== */

/* --- 基底クラス（クラシックスタイル） --- */
.btn-al {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  padding: 0.3rem 0.9rem;
  font-size: 0.95rem;
  font-weight: normal;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  color: #000;
  background-color: #e8e8e8;
  border: 1px solid #333;
  border-radius: 0;
  /* ベベル効果（上・左: 明るく / 下・右: 暗く） */
  /* クロスブラウザ対応 */
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  box-sizing: border-box;
}

.btn-al:hover {
  background-color: #d8d8d8;
}

.btn-al:focus-visible {
  outline: 2px dotted #333;
  outline-offset: 2px;
}

/* 押下時：ベベルを反転して沈み込む演出 */
.btn-al:active {
  background-color: #cccccc;
  transform: translateY(1px);
}

.btn-al:disabled,
.btn-al[disabled] {
  cursor: not-allowed;
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    #b5b5b5,
    #b5b5b5 4px,
    #a5a5a5 4px,
    #a5a5a5 8px
  ) !important;
  color: #fff !important;
  border: 1px solid #333 !important;
  text-shadow: 0 0 2px #666, 0 0 2px #666, 0 0 2px #666;
  box-shadow: none;
}

/* サイズ修飾子 */
.btn-al-sm { padding: 0.15rem 0.45rem; font-size: 0.85rem; }
.btn-al-lg { padding: 0.5rem 1.5rem; font-size: 1.1rem; }
.btn-al-block { width: 100%; }

/* --- 危険ボタン（削除等）--- */
.btn-al-danger {
  color: #fff;
  background-color: #c0392b;
  border-color: #922b21;
}
.btn-al-danger:hover { background-color: #a93226; }
.btn-al-danger:active {
  background-color: #922b21;
}

/*
 * カラーボタン（.btn-al と組み合わせて使う）
 * .btn-al でベベル形状・サイズ・クロスブラウザ対応済み
 * ここでは色だけを上書きする
 */

/* カラーボタン共通：太字 */
.btn-alchemist,
.btn-alchemist-lavender,
.btn-alchemist-sky,
.btn-alchemist-mint,
.btn-alchemist-peach,
.btn-alchemist-rose,
.btn-alchemist-sand,
.btn-alchemist-gray {
  font-weight: 800;
}

/* --- ブランドカラー（マゼンタ） --- */
.btn-alchemist {
  color: #fff;
  background-color: #a81caf;
  border-color: #7c117f;
}
.btn-alchemist:hover { background-color: #8d1393; }
.btn-alchemist:active {
  background-color: #740e78;
}

/* --- Lavender --- */
.btn-alchemist-lavender {
  color: #fff;
  background: linear-gradient(to bottom, #aa66e8 45%, #8844cc 55%);
  border-color: #6630a0;
}
.btn-alchemist-lavender:hover { background: linear-gradient(to bottom, #9955d8 45%, #7733bb 55%); }
.btn-alchemist-lavender:active { background: #6630a0; }

/* --- Sky --- */
.btn-alchemist-sky {
  color: #fff;
  background: linear-gradient(to bottom, #44a8ff 45%, #1a80e8 55%);
  border-color: #1060b8;
}
.btn-alchemist-sky:hover { background: linear-gradient(to bottom, #3498ee 45%, #0a70d8 55%); }
.btn-alchemist-sky:active { background: #1060b8; }

/* --- Mint --- */
.btn-alchemist-mint {
  color: #fff;
  background: linear-gradient(to bottom, #28c8b4 45%, #0da898 55%);
  border-color: #087870;
}
.btn-alchemist-mint:hover { background: linear-gradient(to bottom, #1cb8a4 45%, #089888 55%); }
.btn-alchemist-mint:active { background: #087870; }

/* --- Peach --- */
.btn-alchemist-peach {
  color: #fff;
  background: linear-gradient(to bottom, #ff9030 45%, #e86800 55%);
  border-color: #b04800;
}
.btn-alchemist-peach:hover { background: linear-gradient(to bottom, #ee8020 45%, #cc5800 55%); }
.btn-alchemist-peach:active { background: #b04800; }

/* --- Rose --- */
.btn-alchemist-rose {
  color: #fff;
  background: linear-gradient(to bottom, #ee4888 45%, #cc2060 55%);
  border-color: #a01048;
}
.btn-alchemist-rose:hover { background: linear-gradient(to bottom, #dc3878 45%, #b81050 55%); }
.btn-alchemist-rose:active { background: #a01048; }

/* --- Gray --- */
.btn-alchemist-gray {
  color: #fff;
  background: linear-gradient(to bottom, #989898 45%, #707070 55%);
  border-color: #484848;
}
.btn-alchemist-gray:hover { background: linear-gradient(to bottom, #888888 45%, #606060 55%); }
.btn-alchemist-gray:active { background: #484848; }

/* --- Sand --- */
.btn-alchemist-sand {
  color: #fff;
  background: linear-gradient(to bottom, #f0c800 45%, #d0a000 55%);
  border-color: #9a6e00;
}
.btn-alchemist-sand:hover { background: linear-gradient(to bottom, #e0b800 45%, #b88800 55%); }
.btn-alchemist-sand:active { background: #9a6e00; }

/* --- X（旧Twitter）風ボタン --- */
.btn-x-outline {
  color: #111;
  background-color: transparent;
  border: 1px solid #111;
  font-weight: 600;
  border-radius: 0.375rem;
}
.btn-x-outline:hover {
  color: #fff;
  background-color: #111;
  border-color: #111;
}
.btn-x-outline:focus,
.btn-x-outline.focus {
  color: #111;
  background-color: transparent;
  border-color: #111;
  box-shadow: 0 0 0 0.25rem rgba(17, 17, 17, 0.2);
}
.btn-x-outline svg { margin-right: 0.35em; }

/* --- テーブル内用スリムボタン（btn-al + btn-al-table で使う） --- */
.btn-al-table {
  padding: 0 0.6rem;
  font-size: 0.85rem;
  height: 1.9rem;
  line-height: 1;
}

/* --- goback_template.html スコープ適用（ラッパーで opt-in） --- */
.al-goback .d-flex { gap: 0.25rem 0.4rem !important; }
.al-goback input[type="submit"],
.al-goback input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.45rem;
  font-size: 0.85rem;
  font-weight: normal;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  color: #000;
  background-color: #e8e8e8;
  background-image: linear-gradient(to bottom, #f2f2f2, #dedede);
  border: 1px solid #333;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  box-sizing: border-box;
}
.al-goback input[type="submit"]:hover,
.al-goback input[type="button"]:hover {
  background-color: #d8d8d8;
  background-image: linear-gradient(to bottom, #e8e8e8, #cecece);
}

/* --- カスタムラジオボタン --- */
.al-radio {
  appearance: none;
  -webkit-appearance: none;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid #aaa;
  border-radius: 50%;
  cursor: pointer;
  vertical-align: middle;
  margin-right: 0.3em;
  flex-shrink: 0;
  background-color: #fff;
  transition: border-color 0.15s;
}
.al-radio:hover {
  border-color: #659ceb;
}
.al-radio:checked {
  border-color: #659ceb;
  background-image: radial-gradient(circle, #659ceb 38%, transparent 42%);
}
.al-radio:focus-visible {
  outline: 2px solid #659ceb;
  outline-offset: 2px;
}

/* --- カスタムトグルスイッチ --- */
.al-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 2.4em;
  height: 1.3em;
  border-radius: 9999px;
  background-color: #ccc;
  border: 1px solid #aaa;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  transition: background-color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.al-switch::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0.2em;
  transform: translateY(-50%);
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  background-color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: left 0.2s;
}
.al-switch:checked {
  background-color: #659ceb;
  border-color: #3a7bd5;
}
.al-switch:checked::after {
  left: calc(100% - 1.1em);
}
.al-switch:focus-visible {
  outline: 2px solid #659ceb;
  outline-offset: 2px;
}
.al-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  cursor: pointer;
  font-size: 0.9rem;
}

/* --- ヒントボタン --- */
.al-hint-btn {
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  opacity: 0.85;
}
.al-hint-btn:hover { opacity: 1; }

/* --- ヒントモーダル --- */
.al-hint-modal .modal-header {
  background-color: #f5f0ff;
  border-bottom: 1px solid #d9c2e8;
}
.al-hint-modal .modal-title {
  font-size: 1rem;
  font-weight: 700;
}
.al-hint-modal .al-hint-section {
  margin-bottom: 1rem;
}
.al-hint-modal .al-hint-section-title {
  font-weight: 700;
  font-size: 0.9rem;
  border-left: 3px solid var(--al-color-primary);
  padding-left: 0.4em;
  margin-bottom: 0.4rem;
}
.al-hint-modal ul {
  padding-left: 1.2em;
  margin: 0;
  font-size: 0.9rem;
}
.al-hint-modal li { margin-bottom: 0.25rem; }

/* --- テキストボタン --- */
.btn-al-text {
  background-color: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0 0.2em;
}


/* ==========================================================================
   4. アラート（Bootstrap 非依存）
   ========================================================================== */

.al-alert {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: var(--al-radius-m);
  border: 1px solid transparent;
  margin-bottom: var(--al-space-m);
  font-size: 0.95rem;
  line-height: 1.5;
}

.al-alert-success {
  background-color: #d1f0d8;
  border-color: #a3dba8;
  color: #1a5c28;
}
.al-alert-warning {
  background-color: #fff3cd;
  border-color: #ffe08a;
  color: #7a5c00;
}
.al-alert-danger {
  background-color: #fde8e8;
  border-color: #f5aaaa;
  color: #8b1a1a;
}
.al-alert-info {
  background-color: #ddeeff;
  border-color: #aaccf0;
  color: #1a3a5c;
}


/* ==========================================================================
   6. バッジ（Bootstrap 非依存）
   ========================================================================== */

.al-badge {
  display: inline-block;
  padding: 0.3em 0.7em;
  font-size: 0.8em;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  border-radius: 9999px;
  border: 1px solid transparent;
  vertical-align: middle;
}

/* カウント・中立（sand系） */
.al-badge-neutral {
  background: linear-gradient(to bottom, #a0c000 45%, #7a9800 55%);
  border-color: #587000;
  color: #fff;
}
/* 情報・フィルター（sky系） */
.al-badge-info {
  background: linear-gradient(to bottom, #44a0f8 45%, #1a80e0 55%);
  border-color: #1060b8;
  color: #fff;
}
/* ラベンダー */
.al-badge-lavender {
  background: linear-gradient(to bottom, #aa66e8 45%, #8844cc 55%);
  border-color: #6630a0;
  color: #fff;
}
/* お気に入り（peach系） */
.al-badge-favorite {
  background: linear-gradient(to bottom, #ff8820 45%, #e06000 55%);
  border-color: #b04800;
  color: #fff;
}
/* 装備中（mint系） */
.al-badge-equipped {
  background: linear-gradient(to bottom, #28c8b4 45%, #10a090 55%);
  border-color: #087870;
  color: #fff;
}
/* グレー */
.al-badge-gray {
  background: linear-gradient(to bottom, #808080 45%, #606060 55%);
  border-color: #404040;
  color: #fff;
}

/* 大きめバッジ */
.al-badge-lg {
  padding: 0.4em 0.9em;
  font-size: 0.95em;
  line-height: 1;
}

/* 旧 Bootstrap badge との共存（既存ページ影響なし） */

.badge.bg-alchemist-lavender,
.bg-alchemist-lavender { background-color: var(--al-color-badge-lavender); color: #333; }
.text-alchemist-lavender { color: var(--al-color-badge-lavender); }

.bg-alchemist { background-color: var(--al-color-primary); color: #fff; }


/* ==========================================================================
   7. カード（.al-card）
   ========================================================================== */

.al-card {
  background-color: var(--al-color-surface-card);
  border-radius: var(--al-radius-l);
  box-shadow: var(--al-shadow-card);
  border: 1px solid var(--al-color-surface-border);
  padding: var(--al-space-m);
  margin-bottom: var(--al-space-m);
}

.al-card-header {
  margin-bottom: var(--al-space-m);
  padding-bottom: var(--al-space-s);
  border-bottom: 1px solid var(--al-color-surface-border);
  font-weight: 700;
}


/* ==========================================================================
   8. ユーティリティ
   ========================================================================== */

/* インタラクション */
.al-hover-scale {
  transition: transform 0.2s;
}
.al-hover-scale:hover {
  transform: scale(1.05);
}

/* レイアウト最大幅 */
.al-max-width {
  max-width: 1200px;
}
.al-max-width-center {
  max-width: 1200px;
  margin: 0 auto;
}

/* テキスト */
.al-text-primary   { color: var(--al-color-text-primary); }
.al-text-secondary { color: var(--al-color-text-secondary); }
.al-text-muted     { color: var(--al-color-text-muted); }

/* モーダル固定（スクロール内でも上部に表示） */
.al-modal-fixed {
  position: fixed !important;
  top: 0 !important;
}


/* ==========================================================================
   9. 情報表示パターン
   ========================================================================== */

/* --- セクション背景ラッパー --- */
.al-section {
  background-color: rgba(240, 240, 240, 0.55);
  border-radius: 6px;
  padding: 0.75rem 0.5rem;
  margin-bottom: 0.75rem;
}
/* テーブルなど横幅を活かしたい場合は flush を使う（横パディングなし） */
.al-section-flush {
  background-color: rgba(240, 240, 240, 0.55);
  border-radius: 6px;
  padding: 0.75rem 0 0;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.al-section-flush .al-section-title {
  margin-left: 0.5rem;
}

/* --- セクション見出し --- */
.al-section-title {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--al-color-text-primary);
  border-left: 4px solid var(--al-color-primary);
  background: rgba(168, 28, 175, 0.06);
  padding: 0.25em 0.6em;
  margin: 0 0 0.5rem;
  border-radius: 0 3px 3px 0;
}

/* --- 統計行（数値をインラインで並べる） --- */
.al-stat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.4rem 0;
}
.al-stat-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--al-color-text-secondary);
  white-space: nowrap;
}
.al-stat-item {
  font-size: 0.9rem;
  color: var(--al-color-text-primary);
  white-space: nowrap;
}
.al-stat-item strong {
  font-size: 1rem;
}

/* --- 折りたたみセクション（<details>） --- */
.al-details {
  border: 1px solid var(--al-color-surface-border);
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--al-color-surface-card);
}
.al-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  margin: -0.2rem -0.25rem;
  border-radius: 4px;
  user-select: none;
  transition: background-color 0.2s;
}
.al-details summary:hover {
  background-color: rgba(0, 0, 0, 0.04);
}
.al-details summary::-webkit-details-marker { display: none; }
.al-details summary::before {
  content: '▶';
  font-size: 0.7rem;
  transition: transform 0.2s;
  display: inline-block;
}
.al-details[open] summary::before {
  transform: rotate(90deg);
}
.al-details .al-details-body {
  padding-top: 0.5rem;
}
