/*
 * ============================================================
 * モータースポーツ史
 * 基本スタイル
 * ============================================================
 *
 * まずはシンプルな縦型年表を作ります。
 * デザインは後から変更しやすいように、
 * 基本的な構造だけを整えています。
 * ============================================================
 */


/* ------------------------------------------------------------
 * ページ全体
 * ------------------------------------------------------------ */

body {
  margin: 0;
  padding: 0;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;

  line-height: 1.7;

  background: #f5f5f5;
  color: #222;
}


/* ------------------------------------------------------------
 * ページの主要部分
 * ------------------------------------------------------------ */

body > h1,
body > p,
body > section {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}


/* タイトル */
h1 {
  margin-top: 50px;
  margin-bottom: 20px;
}


/* ------------------------------------------------------------
 * 年表全体
 * ------------------------------------------------------------ */

#timeline {
  margin-top: 50px;
  margin-bottom: 80px;
}


/*
 * 年表の左側に縦線を引きます。
 */
#timeline-list {
  position: relative;

  margin-top: 30px;
  padding-left: 40px;

  border-left: 3px solid #333;
}


/* ------------------------------------------------------------
 * 年表の1項目
 * ------------------------------------------------------------ */

.timeline-item {
  position: relative;

  margin-bottom: 40px;
  padding: 20px 24px;

  background: #fff;

  border-radius: 8px;
}


/*
 * 年表上の「点」を作ります。
 */
.timeline-item::before {
  content: "";

  position: absolute;

  left: -50px;
  top: 28px;

  width: 16px;
  height: 16px;

  background: #fff;

  border: 3px solid #333;
  border-radius: 50%;
}


/* ------------------------------------------------------------
 * 日付
 * ------------------------------------------------------------ */

.timeline-date {
  margin-top: 0;
  margin-bottom: 8px;

  font-weight: bold;
}


/* ------------------------------------------------------------
 * 出来事タイトル
 * ------------------------------------------------------------ */

.timeline-item h3 {
  margin-top: 0;
  margin-bottom: 10px;

  font-size: 1.25rem;
}


/* ------------------------------------------------------------
 * 説明文
 * ------------------------------------------------------------ */

.timeline-description {
  margin-bottom: 0;
}


/* ------------------------------------------------------------
 * スマートフォン向け
 * ------------------------------------------------------------ */

@media (max-width: 700px) {

  body > h1,
  body > p,
  body > section {
    margin-left: 20px;
    margin-right: 20px;
  }

  #timeline-list {
    padding-left: 25px;
  }

  .timeline-item::before {
    left: -35px;
  }

}

/*
 * ============================================================
 * 時間表現：spot と span
 * ============================================================
 *
 * timeline.json の display.scale に設定した
 *
 *   spot = ある時点の出来事
 *   span = 一定期間続いた出来事
 *
 * を視覚的に区別します。
 *
 * JavaScript側ですでに
 *
 *   timeline-item spot
 *   timeline-item span
 *
 * というclassが自動的に付いているため、
 * CSSだけで表示を変えることができます。
 */


/* ------------------------------------------------------------
 * spot：ある時点の出来事
 * ------------------------------------------------------------
 *
 * 基本の「○」をそのまま使います。
 */

.timeline-item.spot::before {
  border-radius: 50%;
}


/* ------------------------------------------------------------
 * span：一定期間続いた出来事
 * ------------------------------------------------------------
 *
 * 「点」ではなく縦長のマーカーにすることで、
 * 時間的な広がりがあることを表現します。
 */

.timeline-item.span::before {
  top: 20px;

  width: 12px;
  height: calc(100% - 40px);

  left: -48px;

  border-radius: 6px;

  background: #333;
}


/*
 * span のカードには左側に線を追加します。
 *
 * 期間を持つ情報であることを、
 * カード側からも分かるようにします。
 */
.timeline-item.span {
  border-left: 5px solid #333;
}

/*
 * ============================================================
 * カテゴリーフィルター
 * ============================================================
 *
 * 年表をカテゴリー別に絞り込むためのボタンです。
 * JavaScriptによって、現在選択されているボタンには
 * active クラスが付与されます。
 */


/* ボタン全体を並べる領域 */
#timeline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;

  margin-top: 20px;
  margin-bottom: 30px;
}


/* 各フィルターボタン */
#timeline-filters button {
  padding: 8px 16px;

  font: inherit;
  font-size: 0.95rem;

  color: #333;
  background: #fff;

  border: 1px solid #bbb;
  border-radius: 999px;

  cursor: pointer;

  /*
   * 色や背景が切り替わるときに、
   * 少しだけ滑らかに変化させます。
   */
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}


/* マウスを重ねたとき */
#timeline-filters button:hover {
  border-color: #333;
  background: #eee;
}


/*
 * 現在選択されているカテゴリー。
 *
 * app.js が active クラスを付けます。
 */
#timeline-filters button.active {
  color: #fff;
  background: #333;
  border-color: #333;
}

/*
 * ============================================================
 * 年表カード内のカテゴリータグ
 * ============================================================
 *
 * timeline.json の categories を、
 * 各カードの下部に小さなラベルとして表示します。
 */


/* タグ全体を並べる領域 */
.timeline-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;

  margin-top: 16px;
}


/* 各カテゴリータグ */
.timeline-category-tag {
  display: inline-block;

  padding: 4px 10px;

  font-size: 0.8rem;
  line-height: 1.4;

  color: #444;
  background: #f2f2f2;

  border: 1px solid #d0d0d0;
  border-radius: 999px;
}

/*
 * ============================================================
 * 年表カード内の典拠表示
 * ============================================================
 *
 * timeline.json の sources に登録された資料情報を、
 * 各カードの下部に表示します。
 */


/* 典拠欄全体 */
.timeline-sources {
  margin-top: 18px;
  padding-top: 14px;

  border-top: 1px solid #ddd;
}


/* 「典拠」という見出し */
.timeline-sources-title {
  margin: 0 0 6px;

  font-size: 0.85rem;
  font-weight: bold;

  color: #555;
}


/* 各典拠 */
.timeline-source-item {
  margin: 4px 0 0;

  font-size: 0.85rem;
  line-height: 1.6;

  color: #666;
}


/* 典拠URL */
.timeline-source-item a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   人物セクション
   ============================================================ */

#people {
  margin-top: 70px;
  margin-bottom: 80px;
}


/* 人物カード一覧 */
#people-list {
  display: grid;

  /* PCでは2列 */
  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 18px;
}


/* 1人分の人物カード */
.person-item {
  background: #ffffff;
  border-radius: 8px;
  padding: 24px;
}


/* 人物名 */
.person-item h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}


/* 生没年月日 */
.person-lifespan {
  margin: 0;
  color: #666;
  line-height: 1.6;
}

/* ------------------------------------------------------------
 * 人物カード：スマートフォン向け
 * ------------------------------------------------------------ */

@media (max-width: 700px) {

  #people-list {
    grid-template-columns: 1fr;
  }

}

/* ============================================================
   人物ライフライン比較
   ============================================================ */

#people-lifeline {
  margin-top: 70px;
  margin-bottom: 80px;
}


/* ライフライン全体 */
#people-lifeline-chart {
  margin-top: 24px;
}


/* 1人分の行 */
.lifeline-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}


/* 人物名 */
.lifeline-label {
  font-weight: bold;
  line-height: 1.4;
}


/* 横方向の時間軸 */
.lifeline-track {
  position: relative;
  height: 34px;
  background: #e9e9e9;
  border-radius: 999px;
  overflow: hidden;
}


/* 人物の生涯を表す帯 */
.lifeline-bar {
  position: absolute;
  top: 5px;
  height: 24px;
  background: #333;
  border-radius: 999px;
}


/* 帯の中の生没年表示 */
.lifeline-text {
  display: block;
  padding: 3px 10px;
  color: #fff;
  font-size: 0.8rem;
  line-height: 18px;
  white-space: nowrap;
}


/* スマホ表示 */
@media (max-width: 700px) {

  .lifeline-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .lifeline-label {
    margin-bottom: 2px;
  }
}

/* ============================================================
   人物ライフライン：年代目盛り
   ============================================================ */

/*
  人物名の列（140px）＋列間の余白（16px）ぶん、
  年代目盛りを右へずらして、
  実際のライフラインと横位置を合わせます。
*/
.lifeline-scale {
  position: relative;
  height: 32px;
  margin-left: 156px;
  margin-bottom: 8px;
}


/* 20年ごとの目盛り */
.lifeline-scale-marker {
  position: absolute;
  top: 0;
  height: 100%;
  border-left: 1px solid #aaa;
}


/* 年代の数字 */
.lifeline-scale-marker span {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(-50%);
  font-size: 0.78rem;
  color: #666;
  white-space: nowrap;
}


/* スマホでは人物名が上段になるため、左余白を解除 */
@media (max-width: 700px) {

  .lifeline-scale {
    margin-left: 0;
  }
}

/* ============================================================
   人物ライフライン：現在ラベルのスマホ調整
   ============================================================ */

/*
  スマホでは「2020」と「現在」が近くなるため、
  「現在」だけ少し下へずらして重なりを避けます。
*/
@media (max-width: 700px) {

  .lifeline-scale-current span {
    top: 16px;
    transform: translateX(-100%);
  }
}

/* ============================================================
   人物ライフライン：年表イベント
   ============================================================ */

/*
  timeline.json に登録されている出来事を、
  人物ライフライン上へ薄い縦線として重ねます。

  例：
  ・1936年 多摩川スピードウェイ開場
  ・1966年 富士スピードウェイ開業
*/


/* 年表イベントの縦線 */
.lifeline-event-marker {
  position: absolute;

  top: 0;
  bottom: 0;

  width: 1px;

  background: #999;

  opacity: 0.45;

  z-index: 1;
}


/*
  人物の生涯を表す帯は、
  イベント線より前面へ表示します。
*/
.lifeline-bar {
  z-index: 2;
}

/* ============================================================
   人物ライフライン：年表イベントの年ラベル
   ============================================================ */

/*
  20年ごとの年代目盛りとは少し見た目を変えて、
  「これは年表上の出来事の年です」と分かるようにします。
*/

.lifeline-scale-event {
  position: absolute;

  top: 16px;

  transform: translateX(-50%);

  font-size: 0.72rem;

  color: #888;

  white-space: nowrap;

  z-index: 3;
}


/*
  イベント年ラベルの文字
*/
.lifeline-scale-event span {
  display: inline-block;

  padding: 1px 4px;

  background: #fff;

  border-radius: 3px;
}

/* ============================================================
   人物ライフライン：タップできるイベント年
   ============================================================ */

/*
  1936 / 1966 などのイベント年を
  スマホでも押しやすいボタンとして表示します。
*/

.lifeline-scale-event {
  position: absolute;

  top: 14px;

  transform: translateX(-50%);

  border: none;

  background: transparent;

  padding: 3px 5px;

  font-size: 0.72rem;

  color: #777;

  cursor: pointer;

  z-index: 4;
}


/*
  年の文字部分
*/
.lifeline-scale-event span {
  display: inline-block;

  padding: 2px 5px;

  background: #fff;

  border-radius: 4px;
}


/*
  選択中のイベント年
*/
.lifeline-scale-event.active span {
  background: #333;

  color: #fff;
}


/* ============================================================
   選択したイベントの説明欄
   ============================================================ */

.lifeline-event-info {
  min-height: 24px;

  margin: 8px 0 18px;

  padding: 8px 10px;

  font-size: 0.82rem;

  line-height: 1.5;

  color: #444;

  background: #f7f7f7;

  border-radius: 6px;
}


/*
  年とイベント名の間に少し余白
*/
.lifeline-event-info strong {
  margin-right: 8px;
}

/* ============================================================
   人物ライフライン：イベント詳細カード
   ============================================================ */

/*
  年＋タイトルの行
*/
.lifeline-event-info-heading {
  display: flex;

  flex-wrap: wrap;

  gap: 6px;

  align-items: baseline;

  margin-bottom: 6px;

  font-size: 0.86rem;
}


/*
  年
*/
.lifeline-event-info-heading strong {
  font-weight: 700;
}


/*
  イベント名
*/
.lifeline-event-info-heading span {
  font-weight: 600;
}


/*
  説明文
*/
.lifeline-event-info-description {
  margin: 0;

  font-size: 0.78rem;

  line-height: 1.6;

  color: #666;
}

/* ============================================================
   人物ライフライン：端のイベント年ラベル補正
   ============================================================ */

/*
  時間軸の左端・右端にあるイベント年が、
  画面の外へはみ出しにくいようにします。
*/

/* 左端付近のイベント */
.lifeline-scale-event:first-of-type {
  transform: translateX(0);
}


/*
  右端付近にイベントが来た場合のための補助。
  将来的にイベントが現在年付近へ増えても、
  画面外へ出にくくするためです。
*/
.lifeline-scale-event:last-of-type {
  transform: translateX(-100%);
}


/* ============================================================
   人物ライフライン：選択中イベントの縦線を強調
   ============================================================ */

/*
  通常時は薄い縦線。
  イベント年をタップしたときだけ、
  対応する縦線を少し濃く・太くします。
*/

.lifeline-event-marker.active {
  width: 2px;

  background: #333;

  opacity: 0.9;

  z-index: 3;
}


/* ============================================================
   サーキットセクション
   ============================================================ */

#circuits {
  margin-top: 70px;
  margin-bottom: 80px;
}


/* ------------------------------------------------------------
 * サーキットカード一覧
 * ------------------------------------------------------------ */

#circuit-list {
  display: grid;

  /* PCでは2列 */
  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 18px;
}


/* ------------------------------------------------------------
 * 1サーキット分のカード
 * ------------------------------------------------------------ */

.circuit-item {
  background: #ffffff;

  border-radius: 8px;

  padding: 24px;
}


/* サーキット名 */
.circuit-item h3 {
  margin: 0 0 10px;

  font-size: 1.2rem;
}


/* 所在地 */
.circuit-location {
  margin: 0 0 6px;

  color: #444;
}


/* 開場・閉場期間 */
.circuit-history {
  margin: 0;

  color: #666;

  line-height: 1.6;
}


/* ------------------------------------------------------------
 * スマートフォン向け
 * ------------------------------------------------------------ */

@media (max-width: 700px) {

  #circuit-list {
    grid-template-columns: 1fr;
  }

}
