/**
 * ========================================
 * STS2 Critical CSS
 * ========================================
 * 統合元:
 * - common.css (基本レイアウト・タブ・モーダル)
 * - loading.css (ローディング画面)
 *
 * 目的: 初期表示に必要な最小限のスタイル
 * ========================================
 */

/* ========================================
   CSS変数定義（グローバル）
======================================== */
:root {
  /* カラーパレット */
  --sts2-primary: #4169e1;
  --sts2-danger: #dc143c;
  --sts2-success: #32cd32;
  --sts2-warning: #ffd700;
  --sts2-info: #9370db;

  /* 背景色 */
  --sts2-bg-dark: #1a1a2e;
  --sts2-bg-darker: #16213e;
  --sts2-bg-overlay: rgba(0, 0, 0, 0.3);

  /* テキスト色 */
  --sts2-text-primary: rgba(255, 255, 255, 0.95);
  --sts2-text-secondary: rgba(255, 255, 255, 0.7);
  --sts2-text-muted: rgba(255, 255, 255, 0.5);

  /* 共通サイズ変数 */
  --sts2-font-xs: 0.7em;
  --sts2-font-sm: 0.75em;
  --sts2-font-base: 0.8em;
  --sts2-font-md: 0.85em;
  --sts2-font-lg: 0.9em;
  --sts2-font-xl: 1em;

  --sts2-padding-xs: 0.3em;
  --sts2-padding-sm: 0.45em;
  --sts2-padding-md: 0.65em;
  --sts2-padding-lg: 1em;
  --sts2-padding-xl: 1.35em;

  --sts2-gap-xs: 0.3em;
  --sts2-gap-sm: 0.45em;
  --sts2-gap-md: 0.65em;
  --sts2-gap-lg: 0.9em;
  --sts2-gap-xl: 1.35em;

  --sts2-border-thin: 0.0625em;
  --sts2-border-base: 0.125em;
  --sts2-border-thick: 0.1875em;

  /* 共通カラー */
  --sts2-rarity-starter: #808080;
  --sts2-rarity-common: #c0c0c0;
  --sts2-rarity-uncommon: #4169e1;
  --sts2-rarity-rare: #9370db;
  --sts2-rarity-boss: #dc143c;
  --sts2-rarity-event: #ffd700;
  --sts2-rarity-curse: #4b0082;

  --sts2-cost-base: rgba(60, 80, 120, 0.9);
  --sts2-cost-changed: rgba(220, 180, 50, 0.9);

  /* ボーダー */
  --sts2-border: rgba(255, 255, 255, 0.1);
  --sts2-border-hover: rgba(255, 255, 255, 0.2);

  /* スペーシング */
  --sts2-space-xs: 0.25em;
  --sts2-space-sm: 0.5em;
  --sts2-space-md: 1em;
  --sts2-space-lg: 1.5em;
  --sts2-space-xl: 2em;

  /* 角丸 */
  --sts2-radius-xs: 0.25em;
  --sts2-radius-sm: 0.5em;
  --sts2-radius-md: 0.75em;
  --sts2-radius-lg: 1em;

  /* シャドウ */
  --sts2-shadow-sm: 0 0.125em 0.25em rgba(0, 0, 0, 0.2);
  --sts2-shadow-md: 0 0.25em 0.5em rgba(0, 0, 0, 0.3);
  --sts2-shadow-lg: 0 0.5em 1em rgba(0, 0, 0, 0.4);
  --sts2-shadow-xl: 0 1.25em 3.75em rgba(0, 0, 0, 0.8);

  /* トランジション */
  --sts2-transition: all 0.3s ease;
  --sts2-transition-fast: all 0.15s ease;

  /* Z-Index */
  --sts2-z-base: 1;
  --sts2-z-dropdown: 100;
  --sts2-z-sticky: 200;
  --sts2-z-fixed: 1000;
  --sts2-z-modal: 9999;
  --sts2-z-loading: 99999;

  /* グラデーション */
  --sts2-gradient-card: linear-gradient(135deg, #252525, #1a2a3a);
  --sts2-gradient-dark: linear-gradient(135deg, #1a1a2e, #16213e);
  --sts2-gradient-darker: linear-gradient(135deg, #0f0f1a, #1a1a2e);
  --sts2-gradient-overlay: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05),
    transparent
  );
  --sts2-gradient-overlay-strong: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    transparent
  );
  --sts2-gradient-primary: linear-gradient(
    135deg,
    rgba(60, 80, 120, 0.8),
    rgba(40, 60, 100, 0.8)
  );
  --sts2-gradient-primary-strong: linear-gradient(
    135deg,
    rgba(60, 80, 120, 0.95),
    rgba(40, 60, 100, 0.95)
  );
  --sts2-gradient-primary-light: linear-gradient(
    135deg,
    rgba(80, 100, 140, 0.9),
    rgba(60, 80, 120, 0.9)
  );
  --sts2-gradient-accent: linear-gradient(
    135deg,
    rgba(220, 180, 50, 0.9),
    rgba(180, 140, 30, 0.9)
  );
  --sts2-gradient-accent-strong: linear-gradient(
    135deg,
    rgba(220, 180, 50, 0.95),
    rgba(180, 140, 30, 0.95)
  );
  --sts2-gradient-danger: linear-gradient(
    135deg,
    rgba(200, 20, 60, 0.8),
    rgba(160, 15, 50, 0.8)
  );
  --sts2-gradient-danger-strong: linear-gradient(
    135deg,
    rgba(200, 20, 60, 0.9),
    rgba(160, 15, 50, 0.9)
  );
}

/* ========================================
   共通アニメーション定義
======================================== */
@keyframes sts2-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes sts2-fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes sts2-glow {
  0% {
    box-shadow: 0 0 0.9375em rgba(255, 220, 100, 0.8);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0.125em 0.25em rgba(0, 0, 0, 0.3);
    transform: scale(1);
  }
}

@keyframes sts2-pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* ========================================
   基本コンテナ
======================================== */
.sts2-container {
  max-width: 75em;
  margin: 0 auto;
}

.sts2-title {
  margin: 0 0 1.8em;
  color: #222;
  font-size: 1.8em;
  text-align: center;
  text-shadow: 0.125em 0.125em 0.25em rgba(0, 0, 0, 0.1);
}

/* ========================================
   セクション
======================================== */
.sts2-section {
  background: var(--sts2-gradient-dark);
  border-radius: var(--sts2-radius-lg);
  border: 0.15em solid var(--sts2-border);
  box-shadow: var(--sts2-shadow-lg);
  overflow: hidden;
}

/* ========================================
   タブ
======================================== */
.sts2-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--sts2-bg-overlay);
  border-bottom: 0.15em solid var(--sts2-border);
}

.sts2-tabs.four-cols {
  grid-template-columns: repeat(4, 1fr);
}

.sts2-tab {
  padding: 0.9em 0.45em;
  background: transparent;
  color: var(--sts2-text-muted);
  font-weight: 600;
  font-size: var(--sts2-font-base);
  text-align: center;
  cursor: pointer;
  transition: var(--sts2-transition);
  border: none;
  border-right: var(--sts2-border-thin) solid rgba(255, 255, 255, 0.05);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
}

.sts2-tab:last-child {
  border-right: none;
}

.sts2-tab::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0.15em;
  background: var(--color);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.sts2-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--sts2-text-secondary);
}

.sts2-tab.active {
  background: var(--sts2-gradient-overlay-strong);
  color: var(--sts2-text-primary);
}

.sts2-tab.active::after {
  transform: scaleX(1);
}

.sts2-tab .icon {
  font-size: 1.4em;
  flex-shrink: 0;
}

.sts2-tab .label {
  font-size: var(--sts2-font-base);
}

/* ========================================
   グリッドコンテナ
======================================== */
.sts2-grid-container {
  padding: 1.3em;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent);
  min-height: 27em;
}

.sts2-grid {
  display: grid;
  gap: 1.3em;
}

/* ========================================
   モーダル
======================================== */
.modal,
.enemy-patterns-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--sts2-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

.modal.show,
.enemy-patterns-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(0.25em);
}

.modal-content,
.enemy-patterns-panel {
  position: relative;
  width: 90%;
  max-width: 60em;
  max-height: 90vh;
  background: var(--sts2-gradient-dark);
  border-radius: var(--sts2-radius-xs);
  border: 0.15em solid var(--sts2-border);
  box-shadow: var(--sts2-shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateY(1.25em);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.enemy-patterns-panel {
  max-width: 50em;
  max-height: 80vh;
}

.modal.show .modal-content,
.enemy-patterns-overlay.show .enemy-patterns-panel {
  transform: translateY(0);
  opacity: 1;
}

.modal-close,
.patterns-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 3em;
  height: 3em;
  background: var(--sts2-gradient-danger-strong);
  border: none;
  border-bottom-left-radius: var(--sts2-radius-md);
  color: var(--sts2-text-primary);
  font-size: 1.2em;
  cursor: pointer;
  transition: var(--sts2-transition);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.4);
}

.modal-close:hover,
.patterns-close:hover {
  transform: scale(1.05);
  box-shadow: -3px 3px 12px rgba(220, 20, 60, 0.5);
}

.modal-close:active,
.patterns-close:active {
  transform: scale(0.95);
}

.modal-body {
  padding: 1.8em;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.modal-body h2 {
  margin: 0 0 1.3em;
  padding: 0 3em;
  color: var(--sts2-text-primary);
  font-size: 1.6em;
  text-align: center;
  text-shadow: 0.125em 0.125em 0.25em rgba(0, 0, 0, 0.8);
}

/* ========================================
   履歴リスト
======================================== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 1.25em;
}

.history-item {
  background: rgba(35, 45, 65, 0.6);
  border-radius: var(--sts2-radius-xs);
  padding: 1.25em;
  border: var(--sts2-border-base) solid var(--sts2-border);
  box-shadow: var(--sts2-shadow-md);
}

.history-item.latest {
  border-color: rgba(220, 180, 50, 0.5);
  box-shadow:
    var(--sts2-shadow-md),
    0 0 1.25em rgba(220, 180, 50, 0.2);
}

.history-header {
  display: flex;
  gap: var(--sts2-gap-sm);
  align-items: center;
  margin-bottom: 1em;
  padding-bottom: 0.75em;
  border-bottom: var(--sts2-border-base) solid rgba(255, 255, 255, 0.15);
}

.version-badge {
  padding: 0.375em 0.875em;
  background: var(--sts2-gradient-primary);
  color: var(--sts2-text-primary);
  font-weight: 700;
  font-size: var(--sts2-font-lg);
  border-radius: var(--sts2-radius-xs);
  border: var(--sts2-border-thin) solid rgba(100, 150, 200, 0.4);
  box-shadow: var(--sts2-shadow-sm);
}

.latest-badge {
  padding: 0.25em 0.625em;
  background: var(--sts2-gradient-accent);
  color: var(--sts2-text-primary);
  font-weight: 700;
  font-size: var(--sts2-font-xs);
  border-radius: var(--sts2-radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.03125em;
  box-shadow: var(--sts2-shadow-sm);
}

/* ========================================
   ローディング画面
======================================== */
.sts2-loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--sts2-gradient-dark);
  z-index: var(--sts2-z-loading);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

.sts2-loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sts2-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2em;
}

.sts2-loading-spinner {
  width: 80px;
  height: 80px;
  border: 6px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--sts2-primary);
  border-right-color: var(--sts2-info);
  border-radius: 50%;
  animation: sts2-spin 1s linear infinite;
}

.sts2-loading-text {
  color: var(--sts2-text-primary);
  font-size: 1.2em;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: center;
}

.sts2-loading-subtext {
  color: var(--sts2-text-muted);
  font-size: var(--sts2-font-lg);
  margin-top: 0.5em;
  animation: sts2-pulse 1.5s ease-in-out infinite;
}

/* ========================================
   images 調整
======================================== */
.sts2-grid [class$="-icon"],
.sts2-shortcode-container [class$="-icon"] {
  opacity: 0.9;
}

.sts2-grid [class$="-icon"]::after,
.sts2-shortcode-container [class$="-icon"]::after {
  z-index: -1;
}

/* ========================================
   スクロールバー
======================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 150, 200, 0.6) rgba(0, 0, 0, 0.2);
}

*::-webkit-scrollbar {
  width: 0.625em;
  height: 0.625em;
}

*::-webkit-scrollbar-track {
  background: rgba(25, 30, 40, 0.8);
  border-radius: var(--sts2-radius-xs);
}

*::-webkit-scrollbar-thumb {
  background: rgba(70, 110, 170, 0.8);
  border-radius: var(--sts2-radius-xs);
  transition: var(--sts2-transition);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(90, 130, 190, 0.9);
}

*::-webkit-scrollbar-thumb:active {
  background: rgba(110, 150, 210, 1);
}

*::-webkit-scrollbar-corner {
  background: rgba(0, 0, 0, 0.2);
}

/* ========================================
   cocoon
======================================== */
.content-bottom-in {
  padding-left: 20px;
  padding-right: 20px;
}

@media screen and (max-width: 834px) {
  .content-bottom-in {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ========================================
   レスポンシブ
======================================== */
@media (max-width: 48em) {
  .sts2-title {
    font-size: 1.4em;
    margin-bottom: 1.3em;
  }

  .sts2-grid-container {
    padding: 1.1em 0.9em;
  }

  .sts2-grid {
    gap: 1.1em;
  }

  .sts2-tabs,
  .sts2-tabs.four-cols {
    grid-template-columns: repeat(3, 1fr);
  }

  .sts2-tab {
    padding: 0.65em 0.2em;
    font-size: var(--sts2-font-xs);
  }

  .sts2-tab .icon {
    font-size: 1.2em;
  }

  .sts2-tab .label {
    font-size: var(--sts2-font-sm);
  }

  .modal-content {
    width: 95%;
    max-width: 95%;
  }

  .enemy-patterns-panel {
    width: 95%;
  }

  .modal-body {
    padding: 1.3em 0.9em;
  }

  .modal-body h2 {
    font-size: 1.3em;
    padding-right: 2.5em;
  }

  .modal-close,
  .patterns-close {
    width: 2.5em;
    height: 2.5em;
    font-size: 1.1em;
  }

  *::-webkit-scrollbar {
    width: 0.5em;
    height: 0.5em;
  }

  .sts2-loading-spinner {
    width: 60px;
    height: 60px;
    border-width: 5px;
  }

  .sts2-loading-text {
    font-size: var(--sts2-font-xl);
  }

  .sts2-loading-subtext {
    font-size: var(--sts2-font-md);
  }
}

/* add */

.hidden {
  visibility: hidden !important;
}
