/* ============================================================
   12世紀英仏歴史地図 — スタイルシート
   暖色パレット: #f9f6f0 / #3d3430 / #b5752d / #c84a31 / #6b7c2f / #a5469b
   ============================================================ */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', 'Hiragino Sans', sans-serif;
  font-size: 14px;
  color: #3d3430;
  background: #f9f6f0;
}

/* ─── ツールバー ─── */
#toolbar {
  background: #3d3430;
  color: #f9f6f0;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1000;
  position: relative;
}

#title-bar {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

#title-bar h1 {
  font-size: 1.1em;
  font-weight: 700;
  color: #c9b896;
  letter-spacing: 0.03em;
}

#subtitle {
  font-size: 0.8em;
  color: #b0a090;
}

#marker-mode-btn {
  margin-left: auto;
  background: #5a4d3d;
  color: #f0e8d8;
  border: 1px solid #7a6a58;
  border-radius: 3px;
  padding: 3px 12px;
  font-size: 0.82em;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

#marker-mode-btn:hover {
  background: #7a6a58;
}

#marker-mode-btn.icon-mode {
  background: #b5752d;
  border-color: #b5752d;
  color: #fff;
}

#view-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

#timeline-bar {
  display: none;
}

.timeline-btn {
  background: #4a3d30;
  color: #9a8a78;
  border: 1px solid #5a4d3d;
  border-radius: 3px;
  padding: 2px 9px;
  font-size: 0.8em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.timeline-btn:hover {
  background: #5a4d3d;
  color: #c8b89a;
}

.timeline-btn.active {
  background: #b5752d;
  border-color: #b5752d;
  color: #fff;
  font-weight: 600;
}

.view-label, .filter-label {
  font-size: 0.75em;
  color: #b0a090;
  white-space: nowrap;
  margin-right: 2px;
}

.view-btn {
  background: #5a4d3d;
  color: #f0e8d8;
  border: 1px solid #7a6a58;
  border-radius: 3px;
  padding: 2px 10px;
  font-size: 0.8em;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.view-btn:hover {
  background: #7a6a58;
}

.view-btn.active {
  background: #b5752d;
  border-color: #b5752d;
  color: #fff;
}

/* ─── Leaflet レイヤーコントロール ─── */
.leaflet-control-layers {
  background: #3d3430 !important;
  border: 1px solid #7a6a58 !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(61,52,48,0.3) !important;
}

.leaflet-control-layers-toggle {
  background-color: #3d3430 !important;
  border-radius: 4px !important;
}

.leaflet-control-layers-expanded {
  padding: 6px 10px !important;
  color: #d0c8bc !important;
  font-family: inherit !important;
  font-size: 0.82em !important;
}

.leaflet-control-layers label {
  color: #d0c8bc !important;
  font-family: inherit !important;
}

/* ─── フィルターバー ─── */
#filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78em;
  color: #d0c8bc;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.filter-item:hover {
  background: #5a4d3d;
  border-color: #7a6a58;
}

.filter-item.disabled {
  opacity: 0.4;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.3);
}

/* ─── 巡回ルートバー ─── */
#itinerary-bar {
  display: none;
}

.itinerary-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78em;
  color: #d0c8bc;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.itinerary-item:hover {
  background: #5a4d3d;
  border-color: #7a6a58;
}

.itinerary-item.disabled {
  opacity: 0.4;
}

.itinerary-note {
  font-size: 0.7em;
  color: #8a7a68;
  margin-left: 6px;
  font-style: italic;
}

/* ─── マップコンテナ ─── */
#map-container {
  position: relative;
  flex: 1;
  height: calc(100vh - var(--toolbar-height, 90px) - 26px);
}

#map {
  width: 100%;
  height: 100%;
}

/* ─── Leaflet ポップアップのカスタマイズ ─── */
.leaflet-popup-content-wrapper {
  background: #f9f6f0;
  border: 1px solid #c9b896;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(61,52,48,0.2);
}

.leaflet-popup-content {
  font-family: inherit;
  color: #3d3430;
  margin: 10px 14px;
  min-width: 180px;
  max-width: 260px;
}

.popup-name-ja {
  font-size: 1em;
  font-weight: 700;
  color: #3d3430;
  line-height: 1.3;
  margin-bottom: 2px;
}

.popup-name-western {
  font-size: 0.78em;
  color: #7a6a58;
  margin-bottom: 6px;
}

.popup-category {
  display: inline-block;
  font-size: 0.72em;
  padding: 1px 6px;
  border-radius: 10px;
  color: #fff;
  margin-bottom: 6px;
}

.popup-desc {
  font-size: 0.82em;
  line-height: 1.5;
  color: #5a4a40;
  margin-bottom: 8px;
}

.popup-detail-btn {
  background: #b5752d;
  color: #fff;
  border: none;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 0.78em;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.popup-detail-btn:hover {
  background: #9a6226;
}

.leaflet-popup-tip {
  background: #f9f6f0;
}

/* ─── 詳細パネル ─── */
#detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 360px;
  height: 100%;
  background: #f9f6f0;
  border-left: 2px solid #c9b896;
  box-shadow: -3px 0 12px rgba(61,52,48,0.15);
  z-index: 500;
  overflow-y: auto;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

#detail-panel.hidden {
  transform: translateX(100%);
}

#detail-close {
  position: sticky;
  top: 0;
  width: 100%;
  background: #3d3430;
  color: #c9b896;
  border: none;
  padding: 8px 14px;
  text-align: right;
  font-size: 0.85em;
  cursor: pointer;
  font-family: inherit;
  z-index: 1;
}

#detail-close:hover {
  background: #5a4d3d;
}

#detail-content {
  padding: 16px;
}

#detail-category-badge {
  display: inline-block;
  font-size: 0.75em;
  padding: 2px 10px;
  border-radius: 10px;
  color: #fff;
  margin-bottom: 8px;
}

#detail-name-ja {
  font-size: 1.2em;
  font-weight: 700;
  color: #b5752d;
  line-height: 1.3;
  border-bottom: 1px solid #d4c9a8;
  padding-bottom: 6px;
  margin-bottom: 4px;
}

#detail-name-western {
  font-size: 0.85em;
  color: #7a6a58;
  margin-bottom: 12px;
  font-style: italic;
}

#detail-content hr {
  border: none;
  border-top: 1px solid #d4c9a8;
  margin: 10px 0;
}

#detail-description {
  font-size: 0.88em;
  line-height: 1.7;
  color: #3d3430;
  margin-bottom: 14px;
}

#detail-events-section h3,
#detail-people-section h3 {
  font-size: 0.82em;
  font-weight: 700;
  color: #8b6914;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  border-bottom: 1px solid #e0d5c0;
  padding-bottom: 3px;
}

#detail-events {
  list-style: none;
  padding: 0;
  margin-bottom: 14px;
}

#detail-events li {
  font-size: 0.82em;
  line-height: 1.5;
  padding: 5px 0;
  border-bottom: 1px dotted #e0d5c0;
  color: #3d3430;
}

#detail-events li:last-child {
  border-bottom: none;
}

#detail-events li.event-highlight {
  background: #fff8e8;
  border-left: 3px solid #b5752d;
  padding-left: 6px;
  border-radius: 2px;
}

.event-date {
  font-weight: 700;
  color: #c84a31;
  margin-right: 4px;
}

#detail-people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.person-badge {
  display: inline-block;
  font-size: 0.78em;
  padding: 2px 10px;
  border-radius: 10px;
  color: #fff;
}

.person-badge.richard-i   { background: #c84a31; }
.person-badge.philip-ii   { background: #4a6fa5; }
.person-badge.henry-ii    { background: #6b7c2f; }
.person-badge.saladin     { background: #8b6914; }
.person-badge.eleanor     { background: #a5469b; }

/* ─── ステータスバー ─── */
#statusbar {
  height: 26px;
  background: #3d3430;
  color: #b0a090;
  font-size: 0.72em;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
}

/* ─── 絵文字アイコンマーカー ─── */
.map-icon-bubble {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  line-height: 1;
}

/* ─── Leaflet マーカーのラベル ─── */
.marker-label {
  background: none;
  border: none;
  white-space: nowrap;
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans JP', sans-serif;
  color: #3d3430;
  text-shadow:
    1px  1px 0 #f9f6f0,
   -1px  1px 0 #f9f6f0,
    1px -1px 0 #f9f6f0,
   -1px -1px 0 #f9f6f0;
  pointer-events: none;
}
