/**
 * ========================================
 * STS2 Critical CSS
 * ========================================
 * 目的: 初期表示に必要な最小限のスタイル
 * 依存: sts2-variables.css
 * ========================================
 */

/* ========================================
   共通アニメーション定義
======================================== */
@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 var(--sts2-border-base) 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: var(--sts2-bg-dark);
  font-size: 1.8em;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
  line-height: var(--sts2-line-height-tight);
  text-shadow: 0 0.05em 0.15em rgba(0, 0, 0, 0.12);
}

/* タイトルサブテキスト */
.sts2-title-sub {
  display: block;
  font-size: 0.55em;
  font-weight: 600;
  color: var(--sts2-primary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.3em;
  opacity: 0.85;
}

/* パッチバージョン表示 */
.sts2-patch-label {
  text-align: center;
  color: rgba(0, 0, 0, 0.35);
  font-size: var(--sts2-font-sm);
  margin: -2.2em 0 1.8em;
}

/* タイトルリンク */
.sts2-title a {
  color: inherit;
  text-decoration: none;
  transition: var(--sts2-transition-fast);
}

.sts2-title a:hover {
  color: var(--sts2-primary);
  text-shadow: none;
}

/* ========================================
   セクション
======================================== */
.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 var(--sts2-border);
  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: var(--sts2-border);
  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;
  animation: sts2-fadeIn var(--sts2-duration-base) ease both;
}

.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: var(--sts2-border-base) var(--sts2-border-base) 0.25em
    rgba(0, 0, 0, 0.8);
}

/* ========================================
   履歴リスト
======================================== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 1.25em;
}

.history-item {
  background: transparent;
  border: none;
  border-top: var(--sts2-border-thin) solid var(--sts2-border);
  border-radius: 0;
  padding: 1.25em 0;
  box-shadow: none;
}

.history-item:first-child {
  border-top: none;
  padding-top: 0;
}

.history-item.latest {
  border-color: rgba(220, 180, 50, 0.25);
  box-shadow: none;
}

.history-item.latest .enemy-history-details::before {
  display: none;
}

.history-header {
  display: flex;
  gap: var(--sts2-gap-sm);
  align-items: center;
  margin-bottom: 0.75em;
  padding-bottom: 0;
  border-bottom: none;
}

.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 var(--sts2-border);
  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;
}

/* ========================================
   画像調整
======================================== */
.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);
}

/* ========================================
   レスポンシブ
======================================== */
@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);
  }
}

/* ========================================
   ユーティリティ
======================================== */
.hidden {
  visibility: hidden !important;
}

/* ========================================
   統一フォーカススタイル（アクセシビリティ）
======================================== */
*:focus-visible {
  outline: var(--sts2-focus-width, 3px) solid
    var(--sts2-focus-color, var(--sts2-primary));
  outline-offset: var(--sts2-focus-offset, 2px);
  border-radius: var(--sts2-radius-xs, 0.25em);
}

/* スキップリンク */
.skip-to-content {
  position: absolute;
  top: -999px;
  left: 0;
  background: var(--sts2-primary);
  color: white;
  padding: var(--sts2-padding-md, 0.65em);
  z-index: var(--sts2-z-modal, 9999);
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 var(--sts2-radius-xs, 0.25em) 0;
}

.skip-to-content:focus {
  top: 0;
}
