/*
  サイト共通スタイル
  - すべて日本語コメント
  - デザイントークンはCSS変数
*/

:root {
  /* カラー */
  --color-base: #0B0F19;
  --color-surface: rgba(255,255,255,0.06);
  --color-text: #E5E7EB;
  --color-muted: rgba(229,231,235,0.7);
  --color-accent: #22D3EE;
  --color-border: rgba(255,255,255,0.12);
  --color-border-strong: rgba(255,255,255,0.2);

  /* 影とガラス表現 */
  --glass-blur: 16px;
  --glass-radius: 20px;
  --glass-shadow: 0 10px 30px rgba(0,0,0,0.35);
  --glass-outline: 1px solid var(--color-border);

  /* タイポグラフィ */
  --font-sans: "Inter", "Noto Sans JP", system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans", sans-serif;
  --fs-hero: clamp(32px, 6vw, 56px);
  --fs-h2: clamp(22px, 3.2vw, 32px);
  --fs-body: 16px;

  /* スペーシング */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 72px;

  /* トランジション */
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--color-text);
  background: radial-gradient(1200px 800px at 70% 10%, rgba(34,211,238,0.1), transparent 60%), var(--color-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; display: block; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.skip-link {
  position: absolute; left: -999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: var(--space-4); top: var(--space-4); width: auto; height: auto; padding: var(--space-2) var(--space-3);
  background: #000; color: #fff; z-index: 10000;
}

/* ヘッダー（ガラス固定） */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  backdrop-filter: blur(var(--glass-blur));
  background: linear-gradient(135deg, #ff6700 0%, #ff0093 100%);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.site-header.is-opaque {
  background: rgba(11,15,25,0.8);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { color: #ffffff; text-decoration: none; font-weight: 700; letter-spacing: 0.08em; text-shadow: 0 1px 2px rgba(0,0,0,0.3); font-size: 22px; }
.logo.small { font-size: 20px; }

.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-3); align-items: center; }
.site-nav a { color: #ffffff; text-decoration: none; opacity: 0.9; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.site-nav a:hover { opacity: 1; }
.nav-toggle { display: none; }

/* ヒーロー */
.hero {
  position: relative;
  height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(135deg, rgba(11,15,25,0.3) 0%, rgba(26,35,50,0.4) 25%, rgba(45,55,72,0.5) 50%, rgba(26,35,50,0.4) 75%, rgba(11,15,25,0.3) 100%);
}
.hero-canvas-wrap { position: absolute; inset: 0; z-index: -1; }
.hero-inner { text-align: center; }
.hero-title { font-size: var(--fs-hero); margin: 0 0 var(--space-3); letter-spacing: 0.02em; }
.hero-sub { 
  font-size: 24px; 
  margin: 0 0 var(--space-3); 
  color: rgba(255,255,255,0.9); 
  font-weight: 300;
  text-shadow: 0 0 20px rgba(255,255,255,0.3), 0 0 40px rgba(255,255,255,0.1);
  letter-spacing: 0.5px;
}
.hero-badge { 
  font-size: 20px; 
  margin: 0; 
  color: rgba(34,211,238,0.9); 
  font-weight: 400;
  text-shadow: 0 0 20px rgba(34,211,238,0.4), 0 0 40px rgba(34,211,238,0.2);
  letter-spacing: 0.3px;
}

/* ギャラリー */
.gallery { 
  padding: 0; 
  overflow: hidden; 
  position: relative; 
  height: 200px; /* デスクトップでの高さを少し増加 */
}
.gallery-grid { 
  display: flex; 
  height: 100%; 
  animation: slide 12s linear infinite; /* アニメーション速度を20s→12sに短縮 */
  will-change: transform;
  transform: translateZ(0); /* GPU加速を強制 */
  align-items: center; /* 縦方向の中央揃え */
}
.gallery-item { 
  position: relative; 
  overflow: hidden; 
  height: 100%; 
  flex-shrink: 0; 
  min-width: 300px; /* 最小幅を大きくして長方形を保持 */
  width: 300px; /* 固定幅を大きくして長方形を保持 */
  /* 背景色を設定して黒い背景を隠す */
  background: var(--color-base);
  /* SafariでのFlexbox内画像問題を解決 */
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-item img { 
  width: 100%; 
  height: 100%; /* 高さを100%に戻して統一 */
  object-fit: cover; 
  object-position: center; /* 画像の中央部分を表示 */
  display: block; 
  transform: translateZ(0); /* GPU加速 */
  /* Safari専用の修正 */
  -webkit-object-fit: cover;
  -webkit-object-position: center;
  /* すべての画像を同じ高さに統一 */
  min-height: 100%;
  max-height: 100%;
}
@keyframes slide {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-66.666%, 0, 0); }
}

/* セクション */
.section { padding: var(--space-6) 0; }
.section-title { font-size: var(--fs-h2); margin: 0 0 var(--space-4); }

/* 3Dモデル表示 */
.model-section { 
  padding: var(--space-6) 0; 
  background: linear-gradient(135deg, rgba(11,15,25,0.1) 0%, rgba(26,35,50,0.2) 50%, rgba(11,15,25,0.1) 100%);
}
.model-viewer { 
  width: 100%; 
  height: 500px; 
  border-radius: var(--glass-radius); 
  overflow: hidden; 
  background: rgba(255,255,255,0.02); 
  border: 1px solid rgba(255,255,255,0.1); 
  box-shadow: var(--glass-shadow); 
  position: relative; 
}
.model-viewer canvas { 
  width: 100% !important; 
  height: 100% !important; 
  display: block; 
}

/* カード（ガラスモーフィズム） */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: var(--glass-outline);
  border-radius: var(--glass-radius);
  box-shadow: var(--glass-shadow);
  padding: var(--space-5);
  backdrop-filter: blur(var(--glass-blur));
  transition: transform var(--dur-2) var(--ease), border-color var(--dur-1) var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: var(--color-border-strong); }
.card h3 { margin-top: 0; margin-bottom: var(--space-2); }
.card p { margin: 0; color: var(--color-muted); }

/* グリッド */
.grid { display: grid; gap: var(--space-3); }
.expertise-list { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* アバウト */
.about-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--space-4); }
.about-card { @supports(backdrop-filter: blur(1px)) { backdrop-filter: blur(var(--glass-blur)); } background: var(--color-surface); border: var(--glass-outline); border-radius: var(--glass-radius); padding: var(--space-5); }
.stats { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-5); }
.stats .num { font-size: 28px; font-weight: 700; }
.stats .label { color: var(--color-muted); display: block; margin-top: 2px; font-size: 12px; }
.timeline { margin: 0; padding-left: 1.2em; }

/* FAQ アコーディオン */
.accordion details { border: var(--glass-outline); border-radius: 12px; padding: var(--space-3) var(--space-4); background: rgba(255,255,255,0.04); transition: background var(--dur-1) var(--ease); }
.accordion details + details { margin-top: var(--space-2); }
.accordion summary { cursor: pointer; list-style: none; font-weight: 600; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion details[open] { background: rgba(255,255,255,0.06); }
.accordion .content { color: var(--color-muted); margin-top: var(--space-2); }

/* フォーム */
.glass { background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)); border: var(--glass-outline); border-radius: var(--glass-radius); box-shadow: var(--glass-shadow); padding: var(--space-5); }
.form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field { display: grid; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field label { font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  color: var(--color-text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  outline: none;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-accent) 40%, transparent); }
.field input:invalid, .field textarea:invalid { border-color: #e67; }
.hp { position: absolute; left: -5000px; }
.consent label { 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  max-width: 100%;
  word-wrap: break-word;
}
.consent input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
}
.consent label span {
  flex: 1;
  line-height: 1.4;
}
.form-actions { display: flex; gap: var(--space-3); align-items: center; margin-top: var(--space-4); }
.form-note { color: var(--color-muted); font-size: 13px; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 18px; border-radius: 12px; text-decoration: none; border: 1px solid var(--color-border); color: var(--color-text); transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-accent { background: linear-gradient(180deg, #ff6700, #ff8533); color: #ffffff; border-color: #ff6700; box-shadow: 0 6px 22px rgba(255,103,0,0.28); }
.btn-accent:hover { box-shadow: 0 10px 28px rgba(255,103,0,0.4); }
.btn-ghost { background: rgba(255,255,255,0.06); }

/* フッター */
.site-footer { border-top: 1px solid var(--color-border); padding: var(--space-5) 0; margin-top: var(--space-6); background: rgba(255,255,255,0.02); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; }
.copy { color: var(--color-muted); font-size: 13px; }

/* レスポンシブ */
@media (max-width: 1200px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .gallery { 
    height: 160px; /* モバイルでの高さを適切に調整 */
  }
  .gallery-item { 
    min-width: 240px; /* タブレットでの最小幅を調整（長方形を保持） */
    width: 240px; /* タブレットでの固定幅を設定 */
  }
  .gallery-grid {
    animation-duration: 8s; /* モバイルではさらに高速化 */
  }
  .model-viewer { 
    height: 300px; /* モバイルでは高さを小さく */
  }
  .cards { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .expertise-list { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .site-nav ul { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--color-border); background: rgba(255,255,255,0.06); color: var(--color-text); }
  .site-nav[aria-expanded="true"] ul { display: flex; position: absolute; right: var(--space-4); top: 64px; flex-direction: column; gap: 0; background: rgba(11,15,25,0.92); border: 1px solid var(--color-border); border-radius: 12px; padding: var(--space-2); box-shadow: var(--glass-shadow); }
  .site-nav[aria-expanded="true"] li { padding: 6px 8px; }
}

/* 低速環境/Reduced Motion 対応 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* スマホでのパフォーマンス最適化 */
@media (max-width: 767px) {
  .gallery { 
    height: 140px; /* スマホではさらにコンパクトに */
  }
  .gallery-item { 
    min-width: 200px; /* スマホでの最小幅を調整（長方形を保持） */
    width: 200px; /* スマホでの固定幅を設定 */
  }
  .gallery-grid {
    animation-duration: 6s; /* スマホでは最速 */
    /* スマホでのGPU最適化 */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
  }
  .gallery-item img {
    /* スマホでの画像最適化 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    backface-visibility: hidden;
  }
}

/* Safari専用の修正 */
@supports (-webkit-appearance: none) {
  .gallery-item {
    /* SafariでのFlexbox内画像サイズ問題を解決 */
    position: relative;
    /* 横サイズを確実に保持 - 各デバイスサイズに対応（長方形を保持） */
    width: 300px;
    min-width: 300px;
  }
  .gallery-item img {
    /* Safariでのobject-fit問題を回避しつつ高さを統一 */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    -webkit-object-fit: cover;
    object-position: center;
    -webkit-object-position: center;
    /* すべての画像を同じ高さに統一 */
    min-height: 100%;
    max-height: 100%;
    min-width: 100%;
    max-width: 100%;
  }
  
  /* タブレット用Safari修正 */
  @media (max-width: 960px) {
    .gallery-item {
      width: 240px;
      min-width: 240px;
    }
  }
  
  /* スマホ用Safari修正 */
  @media (max-width: 767px) {
    .gallery-item {
      width: 200px;
      min-width: 200px;
    }
  }
}


