/* ============================================
   通信の匠 — Design System
   宇宙 × ガラス × ネオン × visionOS
   ============================================ */
:root {
  --bg: #05060f;
  --bg-deep: #020308;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --border-bright: rgba(120, 220, 255, 0.35);
  --text: #eef2ff;
  --text-dim: #8b93b0;
  --cyan: #22d3ee;
  --blue: #3b82f6;
  --violet: #a78bfa;
  --emerald: #34d399;
  --danger: #f87171;
  --glow-cyan: 0 0 24px rgba(34, 211, 238, 0.45);
  --grad-hero: linear-gradient(120deg, var(--cyan), var(--blue) 45%, var(--violet));
  --radius: 20px;
  --radius-lg: 28px;
  --font: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 背景演出 ---------- */
#space {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
}

.aurora {
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 20% 25%, rgba(34, 211, 238, 0.14), transparent 70%),
    radial-gradient(35% 40% at 80% 20%, rgba(167, 139, 250, 0.12), transparent 70%),
    radial-gradient(45% 40% at 60% 85%, rgba(59, 130, 246, 0.12), transparent 70%);
  animation: aurora-drift 24s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 2%, 0) scale(1.08); }
}

/* ---------- ガラス ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--border);
}

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky;
  top: 12px;
  z-index: 100;
  margin: 12px auto 0;
  max-width: 1100px;
  width: calc(100% - 32px);
  border-radius: 999px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.brand-mark { filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.8)); }

.nav-menu {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-menu a {
  display: block;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  transition: color 0.2s, background 0.2s;
}

.nav-menu a:hover, .nav-menu a:focus-visible {
  color: var(--text);
  background: var(--surface-hover);
}

.nav-toggle { display: none; }

/* ---------- レイアウト ---------- */
main { display: block; min-height: 70vh; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.section { padding: 72px 0; }

.section-title {
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 800;
  text-align: center;
  margin-bottom: 12px;
  background: var(--grad-hero);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.section-lead {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 40px;
}

/* ---------- ヒーロー ---------- */
.hero {
  min-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  position: relative;
}

.hero-title {
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.25;
  background: var(--grad-hero);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 30px rgba(59, 130, 246, 0.35));
}

.hero-sub {
  margin-top: 18px;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-dim);
}

/* ---------- 測定開始ボタン ---------- */
.start-btn {
  margin-top: 52px;
  position: relative;
  width: clamp(200px, 40vw, 260px);
  height: clamp(200px, 40vw, 260px);
  border-radius: 50%;
  border: 1px solid var(--border-bright);
  background:
    radial-gradient(circle at 50% 35%, rgba(34, 211, 238, 0.18), rgba(5, 6, 15, 0.6) 70%);
  color: var(--text);
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s;
  box-shadow: var(--glow-cyan), inset 0 0 40px rgba(34, 211, 238, 0.08);
}

.start-btn:hover, .start-btn:focus-visible {
  transform: scale(1.05);
  box-shadow: 0 0 60px rgba(34, 211, 238, 0.6), inset 0 0 50px rgba(34, 211, 238, 0.15);
}

.start-btn::before, .start-btn::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(34, 211, 238, 0.25);
  animation: ring-pulse 2.6s ease-out infinite;
  pointer-events: none;
}

.start-btn::after { animation-delay: 1.3s; }

@keyframes ring-pulse {
  from { transform: scale(0.92); opacity: 1; }
  to   { transform: scale(1.25); opacity: 0; }
}

/* ---------- スピードメーター ---------- */
.meter-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 40px;
}

.meter-wrap.active { display: flex; }

.gauge { width: clamp(260px, 60vw, 380px); }

.gauge-value {
  font-family: var(--mono);
  font-size: clamp(2.6rem, 7vw, 4rem);
  font-weight: 700;
  text-shadow: var(--glow-cyan);
}

.gauge-unit { color: var(--text-dim); font-size: 1rem; }

.gauge-phase {
  margin-top: 8px;
  color: var(--cyan);
  font-weight: 700;
  letter-spacing: 0.1em;
  min-height: 1.6em;
}

/* ---------- 結果グリッド ---------- */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 760px;
  margin-top: 36px;
}

.stat-card {
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  transition: transform 0.25s, border-color 0.25s;
}

.stat-card:hover { transform: translateY(-3px); border-color: var(--border-bright); }

.stat-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--mono);
  font-size: clamp(0.95rem, 1.8vw, 1.25rem);
  font-weight: 700;
  margin-top: 4px;
  word-break: break-all;
}

.stat-value.cyan { color: var(--cyan); }
.stat-value.violet { color: var(--violet); }
.stat-value.emerald { color: var(--emerald); }
.stat-value.blue { color: #7cb8ff; }

/* ---------- ツールカード ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.tool-card {
  display: block;
  border-radius: var(--radius);
  padding: 24px 22px;
  text-decoration: none;
  color: var(--text);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.3s, box-shadow 0.3s;
}

.tool-card:hover, .tool-card:focus-visible {
  transform: translateY(-5px);
  border-color: var(--border-bright);
  box-shadow: 0 12px 40px rgba(34, 211, 238, 0.12);
}

.tool-icon { font-size: 1.8rem; }

.tool-name { font-weight: 800; margin-top: 10px; font-size: 1.05rem; }

.tool-desc { color: var(--text-dim); font-size: 0.88rem; margin-top: 6px; line-height: 1.6; }

/* ---------- ツールページ共通 ---------- */
.tool-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.tool-page h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 900;
  text-align: center;
  background: var(--grad-hero);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tool-page .lead {
  text-align: center;
  color: var(--text-dim);
  margin: 12px 0 36px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }

.input {
  flex: 1;
  min-width: 200px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2); }

select.input { font-family: var(--font); }

.btn {
  padding: 14px 30px;
  border-radius: 14px;
  border: 1px solid var(--border-bright);
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.2), rgba(59, 130, 246, 0.2));
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover, .btn:focus-visible { transform: translateY(-2px); box-shadow: var(--glow-cyan); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-danger {
  border-color: rgba(248, 113, 113, 0.5);
  background: linear-gradient(120deg, rgba(248, 113, 113, 0.2), rgba(167, 139, 250, 0.15));
}

.result-box {
  margin-top: 20px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.4);
  padding: 20px;
  font-family: var(--mono);
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
  min-height: 60px;
  color: #b7e9ff;
}

.result-box:empty { display: none; }

.kv-table { width: 100%; border-collapse: collapse; margin-top: 16px; }

.kv-table th, .kv-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  vertical-align: top;
}

.kv-table th { color: var(--text-dim); font-weight: 600; white-space: nowrap; width: 34%; }

.kv-table td { font-family: var(--mono); word-break: break-all; }

/* ---------- DataWaster ---------- */
.dw-progress {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin-top: 24px;
}

.dw-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--grad-hero);
  box-shadow: var(--glow-cyan);
  transition: width 0.4s ease;
}

.dw-bar.indeterminate { animation: dw-pulse 1.6s ease-in-out infinite; }

@keyframes dw-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.dw-graph { width: 100%; height: 140px; margin-top: 20px; }

/* ---------- ステータス ---------- */
.status-ok { color: var(--emerald); }
.status-ng { color: var(--danger); }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -3px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- フッター ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
  padding: 48px 20px 32px;
  background: rgba(0, 0, 0, 0.3);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.footer-brand { font-weight: 800; font-size: 1.1rem; }

.footer-tagline { color: var(--text-dim); font-size: 0.85rem; font-weight: 400; margin-top: 8px; }

.footer-nav ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 24px;
  max-width: 520px;
}

.footer-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  transition: color 0.2s;
}

.footer-nav a:hover { color: var(--cyan); }

.copyright {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 40px;
}

/* ---------- アクセシビリティ ---------- */
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- モバイル ---------- */
@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
  }

  .nav-toggle span {
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
  }

  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    flex-direction: column;
    min-width: 200px;
    padding: 10px;
    border-radius: var(--radius);
    background: rgba(10, 12, 24, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
  }

  .nav { position: relative; }

  .nav-menu.open { display: flex; }

  .section { padding: 52px 0; }
}
