/* ===============================================
   現代氣功研究機関 - 国家研究所レベルUI
   ADVERSE RESEARCH INSTITUTE
   =============================================== */

/* リセット */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* スマホ最適化 - 横スクロール完全禁止 */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* すべての要素の最大幅制限 */
* {
  max-width: 100%;
}

/* 画像はみ出し防止 */
img {
  max-width: 100%;
  height: auto;
}

/* テキストはみ出し防止 */
p, h1, h2, h3, h4, h5, h6, span, div {
  word-break: break-word;
  overflow-wrap: break-word;
}

:root {
  /* カラーパレット - 研究機関仕様 */
  --white: #FFFFFF;
  --off-white: #FAFBFC;
  --light-gray: #F5F7F9;
  --gray-100: #E8EBED;
  --gray-200: #D1D5D9;
  --gray-300: #A8ADB3;
  --gray-400: #7A8087;
  --gray-500: #5B6168;
  --gray-600: #3F4449;
  --gray-700: #2A2D31;
  --gray-800: #1A1C1F;
  --gray-900: #0F1114;
  
  /* 研究機関アクセント - 電脳水色 */
  --research-teal: #19b9dd;
  --research-blue: #6fd3ea;
  --research-cyan: #e8f8fc;
  --research-dark: #0f7f99;
  --research-line: rgba(25, 185, 221, 0.2);
  --research-line-light: rgba(25, 185, 221, 0.1);
  --research-glow: rgba(25, 185, 221, 0.3);
  
  /* フォント - 研究機関仕様 */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', 'Noto Sans JP', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Roboto Mono', 'Courier New', monospace;
  
  /* スペーシング */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 2rem;
  --spacing-lg: 4rem;
  --spacing-xl: 6rem;
  --spacing-2xl: 8rem;
  --spacing-3xl: 12rem;
}

body {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.8;
  color: var(--gray-800);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* ヘッダー - 研究機関端末風 */
.research-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--research-line);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-md);
}

.research-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--research-teal), transparent);
  opacity: 0.3;
}

.header-left {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--gray-800);
}

.header-center {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--research-teal);
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--gray-500);
}

.status-indicator {
  width: 6px;
  height: 6px;
  background: var(--research-teal);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ヒーロー - 研究施設モニター画面 */
.research-hero {
  position: relative;
  height: 100vh;
  min-height: 700px;
  background: var(--white);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 3D収束グリッド背景 */
.grid-3d-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  perspective: 1000px;
  overflow: hidden;
}

#grid-3d-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
}

/* スマホでは3D効果を弱める */
@media (max-width: 768px) {
  .grid-3d-container {
    perspective: 500px;
    opacity: 0.5;
  }
}

/* 中央情報構造体 */
.center-structure {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  height: 500px;
  z-index: 1;
}

#structure-canvas {
  width: 100%;
  height: 100%;
  opacity: 0.3;
}

/* HUD情報層 */
.hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.hud-corner {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--research-teal);
  opacity: 0.7;
  line-height: 1.6;
}

.hud-top-left {
  top: 80px;
  left: var(--spacing-md);
}

.hud-top-right {
  top: 80px;
  right: var(--spacing-md);
  text-align: right;
}

.hud-bottom-left {
  bottom: var(--spacing-md);
  left: var(--spacing-md);
}

.hud-bottom-right {
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  text-align: right;
}

/* センサーライン */
.scan-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--research-teal), transparent);
  opacity: 0.2;
  animation: scan 8s linear infinite;
}

.scan-line:nth-child(1) { top: 20%; animation-delay: 0s; }
.scan-line:nth-child(2) { top: 50%; animation-delay: 2s; }
.scan-line:nth-child(3) { top: 80%; animation-delay: 4s; }

@keyframes scan {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.3; }
}

/* ヒーローコンテンツ */
.hero-content {
  position: relative;
  z-index: 3;
  text-align: center;
  max-width: 900px;
  padding: var(--spacing-md);
}

.hero-main-title {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--gray-800);
  margin-bottom: 1rem;
  text-shadow: 0 0 20px var(--research-glow);
}

.hero-subtitle-jp {
  font-size: 2.1rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--research-teal);
  margin-bottom: 0.8rem;
}

.hero-subtitle-en {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--gray-500);
  text-transform: uppercase;
  margin-bottom: var(--spacing-md);
}

.hero-tagline {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  color: var(--gray-600);
  margin-bottom: var(--spacing-xl);
}

/* UIライン装飾 */
.ui-line-top {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--research-teal), transparent);
  opacity: 0.5;
}

.ui-line-bottom {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--research-teal), transparent);
  opacity: 0.5;
}

/* セクション共通 - 研究レポート風 */
.research-section {
  position: relative;
  padding: var(--spacing-2xl) 0;
  background: var(--white);
  width: 100%;
  overflow: hidden;
}

.research-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--research-line), transparent);
}

.research-section.alt {
  background: var(--light-gray);
}

.section-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .research-section {
    padding: var(--spacing-lg) 0;
  }
  
  .section-container {
    padding: 0 1rem;
  }
}

/* セクションヘッダー */
.section-header {
  margin-bottom: var(--spacing-xl);
  text-align: center;
}

.section-code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--research-teal);
  text-transform: uppercase;
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.section-code::before,
.section-code::after {
  content: '';
  width: 40px;
  height: 1px;
  background: var(--research-line);
}

.section-title {
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--gray-800);
  margin-bottom: var(--spacing-md);
}

.section-description {
  font-size: 1.1rem;
  line-height: 2;
  color: var(--gray-600);
  max-width: 700px;
  margin: 0 auto;
}

/* 研究フィールドグリッド */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
  width: 100%;
}

@media (max-width: 768px) {
  .research-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: var(--spacing-md);
  }
}

/* 研究カード */
.research-card {
  background: var(--white);
  border: 1px solid var(--research-line);
  padding: var(--spacing-lg);
  position: relative;
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

@media (max-width: 768px) {
  .research-card {
    padding: 1.5rem 1rem;
  }
}

.research-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  width: 60px;
  height: 60px;
  border-top: 2px solid var(--research-teal);
  border-left: 2px solid var(--research-teal);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.research-card::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 60px;
  height: 60px;
  border-bottom: 2px solid var(--research-teal);
  border-right: 2px solid var(--research-teal);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.research-card:hover {
  border-color: var(--research-teal);
  box-shadow: 0 8px 30px rgba(62, 111, 127, 0.1);
}

.research-card:hover::before,
.research-card:hover::after {
  opacity: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-md);
}

.card-id {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--research-teal);
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--research-line);
  background: var(--light-gray);
}

.card-title {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--gray-800);
  margin: var(--spacing-md) 0;
}

.card-body {
  color: var(--gray-600);
  line-height: 1.9;
  margin-bottom: var(--spacing-md);
}

.card-meta {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  margin-top: var(--spacing-md);
}

.meta-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--gray-500);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--gray-200);
  background: var(--off-white);
}

/* 入塾案内CTA - 研究機関風 */
.research-cta {
  background: var(--light-gray);
  padding: var(--spacing-xl) 0;
  position: relative;
  width: 100%;
  overflow: hidden;
}

@media (max-width: 768px) {
  .research-cta {
    padding: var(--spacing-lg) 0;
  }
}

.research-cta::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--research-line), transparent);
}

.cta-content {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.cta-title {
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--gray-800);
  margin-bottom: var(--spacing-md);
}

.cta-description {
  font-size: 1.1rem;
  line-height: 2;
  color: var(--gray-600);
  margin-bottom: var(--spacing-xl);
}

.cta-buttons {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

@media (max-width: 768px) {
  .cta-buttons {
    flex-direction: column;
    gap: 1rem;
  }
}

.btn-research {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 1rem 2.5rem;
  border: 2px solid var(--research-teal);
  background: var(--white);
  color: var(--research-teal);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-height: 44px;
  width: auto;
}

@media (max-width: 768px) {
  .btn-research {
    width: 100%;
    padding: 1.2rem 1.5rem;
    font-size: 1.05rem;
  }
}

.btn-research::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--research-teal);
  transition: left 0.3s ease;
  z-index: 0;
}

.btn-research span {
  position: relative;
  z-index: 1;
}

.btn-research:hover {
  color: var(--white);
}

.btn-research:hover::before {
  left: 0;
}

.btn-research.primary {
  background: var(--research-teal);
  color: var(--white);
}

.btn-research.primary::before {
  background: var(--research-dark);
}

/* フッター */
.research-footer {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: var(--spacing-xl) 0 var(--spacing-md);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.footer-section h4 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--research-cyan);
  margin-bottom: var(--spacing-md);
  text-transform: uppercase;
}

.footer-section p {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--gray-500);
}

.footer-bottom {
  text-align: center;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--gray-700);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--gray-600);
}

/* レスポンシブ */
@media (max-width: 768px) {
  .hero-main-title {
    font-size: 2rem;
  }
  
  .hero-subtitle-jp {
    font-size: 1.3rem;
  }
  
  .hero-subtitle-en {
    font-size: 0.75rem;
  }
  
  .hero-tagline {
    font-size: 0.7rem;
  }
  
  .section-title {
    font-size: 1.8rem;
  }
  
  .section-description {
    font-size: 1rem;
  }
  
  .card-title {
    font-size: 1.3rem;
  }
  
  .hud-corner {
    font-size: 0.55rem;
    padding: 0.5rem;
  }
  
  .header-center {
    display: none;
  }
  
  /* スマホでは横方向アニメーションを無効化 */
  .grid-3d-container,
  .center-structure {
    transform: none !important;
  }
  
  /* スマホでは微粒子を少なくする */
  .particle {
    display: none;
  }
}

/* 極小画面対応 (320px-430px) */
@media (max-width: 430px) {
  :root {
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-2xl: 4rem;
  }
  
  body {
    font-size: 16px;
  }
  
  .hero-main-title {
    font-size: 1.75rem;
  }
  
  .hero-subtitle-jp {
    font-size: 1.1rem;
  }
  
  .hero-subtitle-en {
    font-size: 0.65rem;
  }
  
  .section-title {
    font-size: 1.5rem;
  }
  
  .research-card {
    padding: 1rem;
  }
  
  .hud-corner {
    font-size: 0.5rem;
  }
}

/* 研究領域カード（国家研究所UI） */
.research-domain-card {
  position: relative;
  background: var(--research-cyan);
  border: 1px solid var(--research-line);
  padding: 1.5rem;
  transition: all 0.2s ease;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.research-domain-card:hover {
  border-color: var(--research-teal);
  box-shadow: 0 2px 8px rgba(25, 185, 221, 0.15);
  transform: translateY(-2px);
}

.research-domain-card svg {
  transition: all 0.2s ease;
}

.research-domain-card:hover svg {
  opacity: 0.8;
}

/* スマホ対応：研究領域カード */
@media (max-width: 768px) {
  .research-domain-card {
    min-height: 140px;
    max-height: 180px;
    width: 90%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    padding: 1.2rem;
  }
  
  .research-domain-card svg {
    width: 36px;
    height: 36px;
  }
  
  .research-domain-card h3 {
    font-size: 1.3rem !important;
  }
  
  .research-domain-card p {
    font-size: 0.9rem !important;
  }
  
  .research-domain-card div[style*="font-family: var(--font-mono)"] {
    font-size: 0.65rem !important;
  }
}

@media (max-width: 430px) {
  .research-domain-card {
    min-height: 150px;
    width: 90%;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    padding: 1rem;
  }
  
  .research-domain-card svg {
    width: 32px;
    height: 32px;
  }
  
  .research-domain-card h3 {
    font-size: 1.2rem !important;
  }
}

/* スマホ改行最適化（最重要） */
@media (max-width: 768px) {
  /* 本文改行制御 */
  .section-description,
  .cta-description,
  .card-body,
  p {
    word-break: normal;
    overflow-wrap: normal;
    line-break: strict;
    max-width: 28em;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.8;
    font-size: 16px;
  }
  
  /* 見出し幅調整 */
  .section-title,
  .cta-title,
  h2, h3 {
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    line-height: 1.6;
  }
  
  .section-title {
    font-size: 28px;
    margin-bottom: 20px;
  }
  
  .cta-title {
    font-size: 26px;
    margin-bottom: 16px;
  }
  
  /* CTA説明文の中央寄せ */
  .cta-description {
    max-width: 26em;
    margin: 0 auto 24px;
    text-align: center;
  }
  
  /* セクションコード2行表示 */
  .section-code {
    line-height: 1.5;
    max-width: 90%;
    margin: 0 auto;
    text-align: center;
  }
  
  /* 本文余白 */
  .section-description {
    margin-bottom: 24px;
  }
  
  /* 見出し下余白 */
  .section-title,
  .cta-title {
    margin-bottom: 20px;
  }
  
  /* テーブル内文字列の改行制御 */
  table td {
    word-break: normal;
    overflow-wrap: break-word;
    line-height: 1.8;
  }
  
  /* フッター文章の改行制御 */
  .footer-section p {
    word-break: normal;
    overflow-wrap: break-word;
    line-height: 1.8;
    max-width: 100%;
  }
}

/* 極小画面（320-430px）の追加最適化 */
@media (max-width: 430px) {
  .section-description,
  .cta-description {
    max-width: 24em;
    font-size: 15px;
  }
  
  .section-title {
    font-size: 24px;
  }
  
  .cta-title {
    font-size: 22px;
  }
}

/* ヒーロー説明文 */
.hero-description {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--gray-700);
  margin: 1.5rem auto;
  max-width: 600px;
  text-align: center;
}

/* CTA補足情報 */
.cta-info {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--gray-600);
  margin: 1rem auto 2rem;
  max-width: 500px;
  text-align: center;
}

/* スマホ対応 */
@media (max-width: 768px) {
  .hero-description {
    font-size: 0.95rem;
    margin: 1rem auto;
  }
  
  .cta-info {
    font-size: 0.85rem;
    margin: 0.8rem auto 1.5rem;
  }
}

@media (max-width: 430px) {
  .hero-description {
    font-size: 0.9rem;
  }
  
  .cta-info {
    font-size: 0.8rem;
  }
}
