/* ───────────────────────────────────────────────────────────
   Local Fonts — IM Fell English (Tudor/Elizabethan period type)
─────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'IM Fell English';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/IMFellEnglish-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'IM Fell English';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/IMFellEnglish-Italic.woff2') format('woff2');
}

/* ───────────────────────────────────────────────────────────
   Base & Reset
─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Crimson Text', Georgia, serif;
  background: #f4e8c1;
  color: #2a1208;
  overflow: hidden;
}

/* ───────────────────────────────────────────────────────────
   Header
─────────────────────────────────────────────────────────── */
#site-header {
  position: relative;
  z-index: 1000;
  background: #2a0808;
  border-bottom: 3px solid #8b6914;
  padding: 0.6rem 1.5rem;
  flex-shrink: 0;
}

/* Worn parchment vignette on the header */
#site-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.15) 0%, transparent 6%, transparent 94%, rgba(0,0,0,0.15) 100%);
  pointer-events: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1600px;
  margin: 0 auto;
}

h1 {
  font-family: 'IM Fell English', Georgia, serif;
  font-weight: 400;
  font-size: 1.75rem;
  color: #f0dfa0;
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.tagline {
  font-family: 'IM Fell English', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: #9a7a4a;
  margin-top: 0.15rem;
  letter-spacing: 0.01em;
}

.header-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(240, 223, 160, 0.08);
  border: 1px solid rgba(139, 105, 20, 0.5);
  border-radius: 4px;
  padding: 0.35rem 0.9rem;
  min-width: 84px;
  flex-shrink: 0;
}

.stat-number {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 1.7rem;
  color: #f0dfa0;
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  color: #9a7a4a;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  margin-top: 0.15rem;
}

/* Mobile index toggle (hidden on desktop) */
#index-toggle {
  display: none;
  background: rgba(240, 223, 160, 0.08);
  border: 1px solid rgba(139, 105, 20, 0.4);
  color: #f0dfa0;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#index-toggle:hover { background: rgba(240, 223, 160, 0.18); }

/* ───────────────────────────────────────────────────────────
   Main Layout
─────────────────────────────────────────────────────────── */
#main {
  display: flex;
  flex-direction: row;
  flex: 1;
  height: calc(100vh - 68px);
  overflow: hidden;
}

/* ───────────────────────────────────────────────────────────
   Character Index (left panel) — aged parchment
─────────────────────────────────────────────────────────── */
#street-index {
  width: 230px;
  min-width: 230px;
  display: flex;
  flex-direction: column;
  background: #ecdcb0;
  border-right: 2px solid #8b6914;
  overflow: hidden;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.index-header {
  padding: 0.7rem 0.75rem 0.6rem;
  border-bottom: 1px solid #c4a84a;
  background: #e4d09a;
  flex-shrink: 0;
}

.index-header h2 {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7a5010;
  margin-bottom: 0.5rem;
}

#index-search {
  width: 100%;
  background: rgba(255, 255, 240, 0.6);
  border: 1px solid #c4a84a;
  border-radius: 3px;
  color: #2a1208;
  padding: 0.35rem 0.6rem;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
#index-search:focus {
  border-color: #8b1a1a;
  background: rgba(255, 255, 240, 0.9);
}
#index-search::placeholder { color: #b09050; }

#index-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c4a84a #ecdcb0;
}

.play-group { margin-bottom: 0.1rem; }

.play-heading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem 0.2rem;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7a5010;
  border-top: 1px solid #d4bc7a;
  margin-top: 0.3rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border-radius: 3px 3px 0 0;
  user-select: none;
}
.play-heading:hover { background: rgba(139, 96, 20, 0.12); color: #5a3008; }
.play-heading.active {
  background: rgba(139, 96, 20, 0.18);
  color: #4a2004;
  font-weight: bold;
}
.play-group:first-child .play-heading { border-top: none; margin-top: 0; }

.play-swatch {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.9;
}

.index-item {
  display: flex;
  flex-direction: column;
  padding: 0.28rem 0.75rem 0.28rem 0.9rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.index-item:hover {
  background: rgba(139, 26, 26, 0.07);
  border-left-color: rgba(139, 26, 26, 0.4);
}
.index-item.active {
  background: rgba(139, 26, 26, 0.12);
  border-left-color: #8b1a1a;
}
.index-item.hidden-filter { display: none; }

.item-name {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.82rem;
  color: #2a1208;
  line-height: 1.3;
}
.item-street {
  font-size: 0.7rem;
  color: #8a6030;
  font-style: italic;
}

/* ───────────────────────────────────────────────────────────
   Map wrap
─────────────────────────────────────────────────────────── */
#map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ───────────────────────────────────────────────────────────
   Character Panel (right side) — parchment
─────────────────────────────────────────────────────────── */
#character-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: #faf3e0;
  border-left: 2px solid #8b6914;
  overflow-y: auto;
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: thin;
  scrollbar-color: #c4a84a #faf3e0;
}
#character-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

#panel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(139, 26, 26, 0.08);
  border: 1px solid rgba(139, 26, 26, 0.3);
  color: #8b1a1a;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}
#panel-close:hover { background: rgba(139, 26, 26, 0.2); }

#panel-image-wrap {
  width: 100%;
  height: 260px;
  background: #e8d8a8;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  border-bottom: 2px solid #8b6914;
}

#panel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: none;
}

#panel-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #b09050;
}
#panel-image-placeholder svg { width: 80px; height: 93px; opacity: 0.35; }
#panel-image-placeholder p { font-size: 0.8rem; font-style: italic; opacity: 0.7; }

#panel-info { padding: 1.25rem 1.5rem 2rem; flex: 1; }

#panel-play-badge {
  display: inline-block;
  padding: 0.18rem 0.65rem;
  border-radius: 3px;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #fff;
  margin-bottom: 0.5rem;
}

#panel-name {
  font-family: 'IM Fell English', Georgia, serif;
  font-weight: 400;
  font-size: 2rem;
  color: #2a0808;
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

#panel-street-name {
  font-family: 'IM Fell English', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: #8a6030;
  margin-bottom: 1rem;
}

#panel-description {
  font-size: 1rem;
  line-height: 1.68;
  color: #3a1a08;
  margin-bottom: 1.25rem;
}

#panel-quotes h3 {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #7a5010;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #d4bc7a;
}

#panel-quotes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

#panel-quotes-list li {
  padding-left: 1.1rem;
  border-left: 2px solid #8b6914;
}

#panel-quotes-list li q {
  quotes: "\201C" "\201D" "\2018" "\2019";
  font-family: 'IM Fell English', Georgia, serif;
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.6;
  color: #3a1a08;
}
#panel-quotes-list li q::before { content: open-quote; }
#panel-quotes-list li q::after  { content: close-quote; }

#panel-script-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #2a0808;
  border: 1px solid #8b6914;
  border-radius: 3px;
  color: #f0dfa0;
  text-decoration: none;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  transition: background 0.2s;
  margin-top: 0.5rem;
}
#panel-script-link:hover { background: #3d0f0f; }

/* ───────────────────────────────────────────────────────────
   Map Legend
─────────────────────────────────────────────────────────── */
#map-legend {
  position: absolute;
  bottom: 1.5rem;
  left: 1rem;
  z-index: 800;
  background: rgba(244, 232, 193, 0.95);
  border: 1px solid #8b6914;
  border-radius: 4px;
  padding: 0.6rem 0.85rem;
  font-size: 0.75rem;
  color: #5a3a1a;
  backdrop-filter: blur(2px);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c4a84a transparent;
}

.legend-title {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #7a5010;
  margin-bottom: 0.45rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-line {
  display: inline-block;
  width: 28px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-line.gold { background: #8b1a1a; }

/* ───────────────────────────────────────────────────────────
   Loading Overlay
─────────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(244, 232, 193, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  color: #5a3a1a;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 1rem;
  font-style: italic;
}
#loading-overlay.done {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(139, 26, 26, 0.15);
  border-top-color: #8b1a1a;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────────────────────────────────────────────────
   Leaflet Overrides
─────────────────────────────────────────────────────────── */
.leaflet-container { background: #f4e8c1; }

.leaflet-control-zoom a {
  background: #faf3e0 !important;
  color: #2a0808 !important;
  border-color: #8b6914 !important;
  font-weight: bold;
}
.leaflet-control-zoom a:hover { background: #f0dfa0 !important; }

.leaflet-control-attribution {
  background: rgba(244, 232, 193, 0.85) !important;
  color: #8a6030 !important;
  font-size: 0.65rem !important;
}
.leaflet-control-attribution a { color: #5a3a1a !important; }

.street-tooltip {
  background: rgba(250, 243, 224, 0.96) !important;
  border: 1px solid #8b6914 !important;
  border-radius: 3px !important;
  color: #2a0808 !important;
  font-family: 'IM Fell English', Georgia, serif !important;
  font-size: 0.82rem !important;
  padding: 0.3rem 0.6rem !important;
  white-space: nowrap;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.15) !important;
}
.street-tooltip::before { display: none !important; }

/* ───────────────────────────────────────────────────────────
   Responsive — Mobile
─────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  h1 { font-size: 1.2rem; }
  .tagline { display: none; }
  .header-stats { padding: 0.3rem 0.6rem; }
  .stat-number { font-size: 1.4rem; }
  .stat-label { font-size: 0.62rem; }
  .header-inner { gap: 0.5rem; }

  #index-toggle { display: flex; }

  /* Index slides in from the left over the map */
  #street-index {
    position: fixed;
    top: 58px;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 270px;
    min-width: unset;
    transform: translateX(-100%);
    z-index: 900;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  #street-index.open { transform: translateX(0); }

  /* Character panel slides up from the bottom */
  #character-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 58vh;
    border-left: none;
    border-top: 2px solid #8b6914;
    transform: translateY(0);
  }
  #character-panel.hidden { transform: translateY(100%); }

  #panel-image-wrap { height: 150px; }
  #map-legend { bottom: 0.5rem; left: 0.5rem; padding: 0.5rem 0.7rem; }
}

/* ── Play panel character list ───────────────────────────────────────────── */

#play-char-list {
  margin-top: 1rem;
}
#play-char-list h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a5010;
  margin: 0 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #d4bc7a;
}
#play-char-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.play-char-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
  border-left: 3px solid transparent;
}
.play-char-link:hover {
  background: rgba(139, 96, 20, 0.1);
  border-left-color: #8b6914;
}
.char-link-name {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.9rem;
  color: #2a1208;
  white-space: nowrap;
}
.char-link-street {
  font-size: 0.72rem;
  color: #7a5010;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
