/* ============================================================
   しりとりグラフサイト スタイル
   ============================================================ */

/* ---- リセット & ベース ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #f5f5f5;
  color: #333;
  touch-action: none; /* スマホでのスクロール防止 */
}

/* ---- グラフコンテナ ---- */
#graph-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#graph-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- 背景グリッド（Desmos風） ---- */
.grid-line {
  stroke: #e0e0e0;
  stroke-width: 0.5;
}

.grid-line-minor {
  stroke: #f0f0f0;
  stroke-width: 0.3;
}

/* ---- エッジ（線） ---- */
/* 1本の線で点線アニメーション */
.edge-line,
.edge-line-first,
.edge-line-second {
  stroke: #4a90d9;
  stroke-width: 2;
  stroke-opacity: 0.7;
  fill: none;
  stroke-dasharray: 8 6;
  animation: dashMove 0.8s linear infinite;
}

@keyframes dashMove {
  to {
    stroke-dashoffset: -14;
  }
}

/* ---- ノード（角丸カード） ---- */
.node-card {
  cursor: grab;
  user-select: none;
  transition: filter 0.2s ease;
}

.node-card:active {
  cursor: grabbing;
}

.node-card:hover {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

/* カード全体の背景 */
.node-card-bg {
  fill: #ffffff;
  stroke: #e0e0e0;
  stroke-width: 1.5;
}

/* スタートノードのカード背景（赤色） */
.node-card-bg-start {
  fill: #fff5f5;
  stroke: #e74c3c;
  stroke-width: 2.5;
}

/* タイトル領域の背景（上半分） */
.node-title-bg {
  fill: #f0f4f8;
  stroke: none;
}

/* スタートノードのタイトル背景 */
.node-title-bg-start {
  fill: #fde8e8;
  stroke: none;
}

/* 画像領域の背景（下半分） */
.node-image-bg {
  fill: #ffffff;
  stroke: none;
}

/* ---- ノード内テキスト ---- */
.node-title {
  font-size: 11px;
  font-weight: 700;
  fill: #333;
  text-anchor: middle;
  dominant-baseline: central;
}

/* スタートノードのタイトルテキスト */
.node-title-start {
  fill: #c0392b;
  font-size: 12px;
}

/* ---- サムネイル ---- */
.thumbnail-placeholder-text {
  font-size: 24px;
  fill: #bbb;
  text-anchor: middle;
  dominant-baseline: central;
}

.thumbnail-image {
  rx: 0;
  ry: 0;
}

/* ---- Desmos埋め込みiframe ---- */
.desmos-embed {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none; /* クリックは親要素で処理 */
}

/* ---- サイトタイトル（左上） ---- */
#site-title {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  font-size: 18px;
  font-weight: 800;
  color: #222;
  z-index: 20;
  max-width: calc(100% - 32px);
  line-height: 1.4;
  letter-spacing: 0.5px;
}

/* ---- コントロールUI ---- */
#controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  padding: 12px 24px;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  font-size: 13px;
  z-index: 10;
}

#controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
}

#controls input[type="range"] {
  width: 120px;
  accent-color: #4a90d9;
}

#controls .control-value {
  min-width: 32px;
  text-align: center;
  font-weight: 600;
  color: #333;
}

#controls button {
  background: #4a90d9;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

#controls button:hover {
  background: #357abd;
}

/* ---- レスポンシブ（スマホ対応） ---- */
@media (max-width: 768px) {
  #site-title {
    font-size: 14px;
    padding: 10px 14px;
    top: 12px;
    left: 12px;
    max-width: calc(100% - 24px);
  }

  #controls {
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px 16px;
    gap: 10px;
    bottom: 16px;
    width: calc(100% - 32px);
  }

  #controls input[type="range"] {
    width: 80px;
  }

  #controls label {
    font-size: 12px;
  }

  #controls button {
    font-size: 12px;
    padding: 5px 12px;
  }
}

@media (max-width: 480px) {
  #site-title {
    font-size: 12px;
    padding: 8px 12px;
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
  }

  #controls {
    padding: 8px 12px;
    gap: 8px;
    bottom: 12px;
    width: calc(100% - 24px);
  }

  #controls input[type="range"] {
    width: 60px;
  }
}
