/* ===== LORE MAP - Core Styles ===== */

:root {
  --bg: #080a10;
  --gold: #c8a84b;
  --gold-bright: #e8c86a;
  --gold-dim: rgba(200,168,75,0.4);
  --text: #d8d0c0;
  --text-dim: #887860;
  --frame-bg: #0d0f16;
  --frame-border: #2a2218;
  --parchment: #1a1610;

  --c-divine:     #8888ff;
  --c-prime:      #44cc88;
  --c-liminal:    #cc8844;
  --c-primordial: #cc4466;

  --font-title: 'Cinzel', Georgia, serif;
  --font-ui:    'Rajdhani', system-ui, sans-serif;
  --font-mono:  'Share Tech Mono', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
}

/* Starfield background */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 40%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 20%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 25%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 20% 75%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 85%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 70%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 55%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 75% 10%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(2px 2px at 5%  50%, rgba(200,168,75,0.2) 0%, transparent 100%),
    radial-gradient(2px 2px at 92% 45%, rgba(200,168,75,0.2) 0%, transparent 100%);
}


/* ======================================================
   WoW-STYLE MAP FRAME
   ====================================================== */

.map-frame {
  position: fixed;
  inset: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--frame-bg);
  border: 2px solid var(--gold-dim);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(200,168,75,0.1),
    0 0 40px rgba(0,0,0,0.8),
    inset 0 0 60px rgba(0,0,0,0.4);
  overflow: hidden;
  /* Ensure height is always fully bounded by viewport */
  max-height: calc(100vh - 32px);
}

/* Corner ornaments */
.map-frame::before,
.map-frame::after {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border-color: var(--gold);
  border-style: solid;
  z-index: 20;
  pointer-events: none;
}
.map-frame::before {
  top: 6px;
  left: 6px;
  border-width: 2px 0 0 2px;
  border-radius: 4px 0 0 0;
}
.map-frame::after {
  bottom: 6px;
  right: 6px;
  border-width: 0 2px 2px 0;
  border-radius: 0 0 4px 0;
}

/* Title bar */
.frame-title-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 350px 10px 50px; /* right padding accounts for 300px sidebar so content centers over map */
  background: linear-gradient(90deg, transparent, rgba(200,168,75,0.06), transparent);
  border-bottom: 1px solid var(--gold-dim);
  flex-shrink: 0;
}

.frame-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(200,168,75,0.4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.frame-title-ornament {
  font-size: 12px;
  color: var(--gold-dim);
  margin: 0 16px;
  letter-spacing: 4px;
}

.frame-close-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: 50%;
  color: var(--gold);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.frame-close-btn:hover {
  background: var(--gold);
  color: var(--bg);
  text-decoration: none;
}

/* Main body */
.map-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* Map side (left) */
.map-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--frame-border);
  min-width: 0;
}

/* Layer breadcrumb */
.map-layer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--frame-border);
  flex-shrink: 0;
}

.layer-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.layer-back {
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}
.layer-back:hover { background: var(--gold-dim); }
.layer-back.hidden { display: none; }

/* Map controls */
.map-controls {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  background: rgba(0,0,0,0.2);
  border-top: 1px solid var(--frame-border);
  flex-shrink: 0;
}

.ctrl-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200,168,75,0.1);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  color: var(--gold);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}
.ctrl-btn:hover { background: rgba(200,168,75,0.25); }
/* Center map button - distinct from zoom controls */
.ctrl-center {
  margin-left: 6px;
  font-size: 18px;
  font-weight: normal;
  border-color: rgba(200,168,75,0.6);
  title: 'Center Map';
}


/* ======================================================
   ZONE INFO PANEL - right sidebar (WoW zone info)
   ====================================================== */

.zone-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--parchment) 0%, rgba(10,9,7,0.95) 100%);
  overflow-y: auto;
  padding: 20px 16px;
}

.zone-panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  text-align: center;
  padding: 40px 20px;
}

.panel-empty-icon {
  font-size: 40px;
  color: rgba(200,168,75,0.2);
  line-height: 1;
}

.zone-panel-content {
  animation: panelReveal 0.3s ease-out;
}
.zone-panel-content.hidden { display: none; }

@keyframes panelReveal {
  0% { opacity: 0; transform: translateX(10px); }
  100% { opacity: 1; transform: translateX(0); }
}

.zp-tier {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-bottom: 8px;
}
.zp-tier.t-divine     { background: rgba(136,136,255,0.15); color: #8888ff; border: 1px solid rgba(136,136,255,0.3); }
.zp-tier.t-prime      { background: rgba(68,204,136,0.15);  color: #44cc88; border: 1px solid rgba(68,204,136,0.3); }
.zp-tier.t-liminal    { background: rgba(204,136,68,0.15);  color: #cc8844; border: 1px solid rgba(204,136,68,0.3); }
.zp-tier.t-primordial { background: rgba(204,68,102,0.15);  color: #cc4466; border: 1px solid rgba(204,68,102,0.3); }

.zp-name {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  color: var(--gold-bright);
  line-height: 1.2;
  text-shadow: 0 0 16px rgba(200,168,75,0.3);
  margin-bottom: 10px;
}

.zp-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: 10px 0;
}

.zp-desc {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 14px;
}

.zp-features {
  list-style: none;
  margin-bottom: 16px;
}
.zp-features li {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0 4px 14px;
  border-bottom: 1px solid rgba(200,168,75,0.05);
  position: relative;
}
.zp-features li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--gold-dim);
}

.zp-drill {
  width: 100%;
  padding: 10px 16px;
  background: rgba(200,168,75,0.1);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.zp-drill:hover {
  background: rgba(200,168,75,0.25);
  color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(200,168,75,0.2);
}
.zp-drill.hidden { display: none; }

/* KS Backer badge — shown below features when a zone is associated with a KS tier */
.zp-ks-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 4px;
  color: #ffd700;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.06em;
  font-weight: 600;
}
.zp-ks-badge.hidden { display: none; }

/* ======================================================
   LEGEND BAR
   ====================================================== */

.frame-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 7px 316px 7px 16px; /* right padding accounts for 300px sidebar so legend centers over map */
  background: rgba(0,0,0,0.3);
  border-top: 1px solid var(--frame-border);
  flex-shrink: 0;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

.leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.leg-dot.leg-divine     { background: #8888ff; box-shadow: 0 0 5px #8888ff; }
.leg-dot.leg-prime      { background: #44cc88; box-shadow: 0 0 5px #44cc88; }
.leg-dot.leg-liminal    { background: #cc8844; box-shadow: 0 0 5px #cc8844; }
.leg-dot.leg-primordial { background: #cc4466; box-shadow: 0 0 5px #cc4466; }

/* Backer creation links group (KS tier-gated) */
.leg-suggest-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.leg-suggest-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold-dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
  margin-right: 2px;
}
.leg-suggest-link {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #c8a84b;
  text-decoration: none;
  letter-spacing: 0.04em;
  opacity: 0.55;
  transition: opacity 0.15s, border-color 0.15s;
  padding: 2px 6px;
  border: 1px solid rgba(200,168,75,0.12);
  border-radius: 3px;
  white-space: nowrap;
}
.leg-suggest-link:hover {
  opacity: 1;
  border-color: rgba(200,168,75,0.5);
  text-decoration: none;
}


/* Scrollbar */
.zone-panel::-webkit-scrollbar { width: 4px; }
.zone-panel::-webkit-scrollbar-track { background: transparent; }
.zone-panel::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }


/* Responsive */
@media (max-width: 700px) {
  /* Frame fills almost full screen on mobile */
  .map-frame { inset: 4px; max-height: calc(100vh - 8px); }

  /* Title bar: remove the fixed right-padding that assumes 300px sidebar */
  .frame-title-bar { padding: 8px 40px; }
  .frame-title { font-size: 14px; letter-spacing: .05em; }
  .frame-title-ornament { display: none; }

  /* Stack map + panel vertically — legend moved to top on mobile */
  .map-body { flex-direction: column; order: 2; }
  .map-side { flex: 1; min-height: 0; border-right: none; padding-bottom: 52px; }
  /* Legend: move to top (between title bar and map), compact for mobile */
  .frame-legend {
    display: flex;
    order: 1;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 6px 12px;
    justify-content: flex-start;
    border-top: none;
    border-bottom: 1px solid var(--frame-border);
  }
  .leg-suggest-group { margin-left: 0; flex-wrap: wrap; }
  .leg-suggest-label { display: none; } /* too narrow — skip label, keep buttons */

  /* Zone panel: fixed bottom sheet, always shows 44px pull-tab */
  .zone-panel {
    width: 100%; position: fixed; bottom: 0; left: 0; right: 0;
    height: 44px;
    background: linear-gradient(180deg, rgba(20,16,10,0.97) 0%, rgba(10,9,7,0.98) 100%);
    border-top: 2px solid var(--gold-dim); border-radius: 12px 12px 0 0;
    z-index: 30; transition: height .3s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    display: flex; flex-direction: column;
  }
  .zone-panel.panel-open { height: 55vh; overflow-y: auto; }

  /* Drag handle — always visible on mobile */
  #panel-drag-handle { display: flex !important; align-items: center; justify-content: center;
    width: 100%; height: 44px; flex-shrink: 0; cursor: pointer; }
  #panel-drag-handle > div { width: 40px; height: 4px; border-radius: 2px;
    background: var(--gold-dim, rgba(200,168,75,.45)); transition: background .2s; }
  #panel-drag-handle:active > div { background: var(--gold, rgba(200,168,75,.9)); }

  /* Panel content below the handle */
  .zone-panel-empty, .zone-panel-content { padding-top: 4px; }

  /* Zoom controls above the bottom sheet */
  .map-controls { bottom: 56px; }
}
