/* ── Base ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.quests-page {
  background: #141414;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
}
@media (max-width: 768px) { body.quests-page { padding-top: 56px; } }

/* ── Hero ───────────────────────────────────────────────────────────────────── */
.quest-hero {
  position: relative;
  width: 100%;
  height: 320px;
  background: linear-gradient(135deg, #0a1628 0%, #111929 40%, #141414 100%);
  margin-bottom: -80px;
  overflow: hidden;
}
.quest-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 900px 400px at 20% 60%, rgba(74,174,232,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 600px 300px at 80% 30%, rgba(155,109,189,0.07) 0%, transparent 70%);
  pointer-events: none;
}
.quest-hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 120px;
  background: linear-gradient(to bottom, transparent, #141414);
}
.quest-hero-content {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: 60px 40px 0;
}
.quest-hero-content h1 {
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  margin: 0 0 10px;
  letter-spacing: -0.5px;
}
.quest-hero-content p {
  font-size: 1.1rem;
  color: #aaa;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
  margin: 0;
}
@media (max-width: 768px) {
  .quest-hero { height: 240px; margin-bottom: -60px; }
  .quest-hero-content { padding: 40px 20px 0; }
  .quest-hero-content h1 { font-size: 2rem; }
  .quest-hero-content p  { font-size: 0.95rem; }
}

/* ── Main container ─────────────────────────────────────────────────────────── */
.quests-main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  position: relative;
  z-index: 1;
}

/* ── Canvas wrapper (mirrors skill-tree .canvas-wrapper) ─────────────────────── */
.canvas-wrapper {
  background: #141414;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  margin-bottom: 0;
  overflow: hidden;
  position: relative;
}

/* Controls header */
.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 24px 16px;
  flex-wrap: wrap;
}
.ctrl-left {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.instr-item {
  font-size: 0.82rem;
  color: #666;
  white-space: nowrap;
}
.ctrl-center { flex: 1; min-width: 220px; max-width: 360px; position: relative; }
.ctrl-right  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Search (in controls-header) */
.search-wrap {
  position: relative;
  width: 100%;
}
.srch-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: #555; pointer-events: none;
}
#graph-search-input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 7px 30px 7px 30px;
  color: #e0e0e0;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
#graph-search-input::placeholder { color: #444; }
#graph-search-input:focus { border-color: #3a5878; }
.srch-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 0.7rem; color: #333; background: #222; border: 1px solid #333;
  border-radius: 3px; padding: 1px 5px; font-family: monospace; pointer-events: none;
}
#search-dropdown {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
  z-index: 100;
}
.search-result-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 0.88rem;
  transition: background 0.1s;
}
.search-result-item:hover,
.search-result-item.keyboard-focus { background: #222; }
.sri-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.sri-name { flex: 1; color: #d0d0d0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sri-name mark { background: rgba(245,166,35,0.25); color: #f5a623; border-radius: 2px; padding: 0 1px; }
.sri-trader { font-size: 0.78rem; flex-shrink: 0; opacity: 0.85; }

/* Trader filter pills (in controls-header) */
.trader-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.t-pill {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 100px;
  padding: 4px 11px;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.t-pill:hover { border-color: var(--tc, #555); color: #aaa; }
.t-pill.active {
  background: var(--tc, rgba(58,120,200,0.3));
  border-color: var(--tc, #3a78c8);
  color: #fff;
}
.t-pill[data-trader=""].active {
  background: #2a2a2a; border-color: #444; color: #ccc;
}

/* Fit button */
.ctrl-btn {
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px;
  padding: 6px 12px; font-size: 0.82rem; font-family: inherit; color: #888;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.ctrl-btn:hover { background: #222; border-color: #444; color: #ccc; }

/* ── Canvas container (matches skill-tree .canvas-container) ─────────────────── */
.canvas-container {
  position: relative;
  display: flex;          /* canvas + sidebar sit side-by-side */
  align-items: stretch;
  width: 100%;
  height: 720px;
  background: #111929;
  overflow: hidden;
  border-top: 2px solid #1e1e1e;
  cursor: grab;
}
.canvas-container:active { cursor: grabbing; }
@media (max-width: 768px) { .canvas-container { height: 480px; } }

#quest-canvas {
  flex: 1;
  min-width: 0;   /* let flex shrink below natural size */
  display: block;
  height: 100%;
}

/* ── Quest detail sidebar ────────────────────────────────────────────────────── */
/* Desktop: flex sibling that squeezes the canvas */
#quest-popup {
  position: relative;
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  background: #181818;
  border-left: 1px solid transparent;
  transition: width 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.1s 0.16s;   /* border fades in once gap is visible */
  z-index: 10;
}
#quest-popup.is-open {
  width: 310px;
  border-color: #2a2a2a;
  transition: width 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0s;
}

/* Inner scroll container — fixed width so content never squishes during animation */
.popup-scroll {
  width: 310px;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
  position: relative;
}

/* Mobile: full-width overlay sliding up from the bottom of the canvas */
@media (max-width: 768px) {
  #quest-popup {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: auto !important;
    border-left: none !important;
    background: rgba(24, 24, 24, 0.97);
    transform: translateY(100%);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #quest-popup.is-open {
    transform: translateY(0);
    width: auto !important;
    border-color: transparent !important;
  }
  .popup-scroll { width: 100%; }
}

/* ── Dev bar (inside canvas-container) ─────────────────────────────────────── */
#dev-bar[hidden] { display: none !important; }
#dev-bar {
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center;
  background: rgba(20, 30, 50, 0.95);
  border: 1px solid #f5a623;
  border-radius: 8px; padding: 6px 14px; z-index: 30;
}
.dev-label { font-size: 0.7rem; font-weight: 700; color: #f5a623; letter-spacing: 0.08em; }
.dev-label-sm { font-size: 0.7rem; color: #7a99bb; white-space: nowrap; }
.dev-sep { width: 1px; height: 18px; background: #2a3a5a; flex-shrink: 0; }
.dev-btn {
  background: #1a1a2e; border: 1px solid #2a3a5a; border-radius: 5px;
  color: #c8d8ec; padding: 3px 10px; font-size: 0.78rem; font-family: inherit; cursor: pointer;
}
.dev-btn:hover { border-color: #4aaee8; color: #fff; }
.dev-btn.accent { border-color: #f5a623; color: #f5a623; }
.dev-num  { width: 46px; background: #111929; border: 1px solid #2a3a5a; border-radius: 4px; color: #c8d8ec; font-size: 0.78rem; text-align: center; padding: 2px 4px; }
.dev-range { width: 70px; accent-color: #4aaee8; cursor: pointer; }
.dev-file { font-size: 0.7rem; color: #7a99bb; max-width: 130px; cursor: pointer; }
.dev-val  { font-size: 0.68rem; color: #9ab; min-width: 26px; }
#dev-bar  { flex-wrap: wrap; max-height: 70px; overflow-y: auto; }

/* ── Popup inner content ─────────────────────────────────────────────────────── */
#popup-close {
  position: sticky; top: 0; float: right;
  margin: 10px 10px 0 0;
  background: #222; border: 1px solid #333; border-radius: 50%;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  color: #666; font-size: 13px; cursor: pointer; z-index: 2; line-height: 1;
  transition: all 0.15s;
}
#popup-close:hover { border-color: #555; color: #ccc; }

.popup-img-wrap {
  width: 100%; height: 140px; overflow: hidden; background: #111;
}
.popup-quest-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.popup-body { padding: 12px 16px 24px; }
.popup-badges { display: flex; gap: 5px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.popup-trader-badge {
  font-size: 0.72rem; font-weight: 700; color: #080e1a;
  padding: 2px 7px; border-radius: 3px; letter-spacing: 0.04em;
}
.popup-update-badge {
  font-size: 0.72rem; font-weight: 600; color: var(--uc, #888);
  border: 1px solid var(--uc, #888); border-radius: 3px;
  padding: 1px 6px; letter-spacing: 0.04em; opacity: 0.9;
}
.popup-title {
  font-size: 1.1rem; font-weight: 700; color: #fff;
  margin: 0 0 3px; line-height: 1.3; padding-right: 28px;
}
.popup-map { font-size: 0.8rem; color: #555; margin: 0 0 12px; }
.popup-section { margin-bottom: 12px; }
.popup-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: #555; margin-bottom: 5px;
}
.popup-list { margin: 0; padding: 0 0 0 14px; color: #888; }
.popup-list li { font-size: 0.85rem; line-height: 1.7; }
.popup-list .qty { color: #f5a623; font-weight: 600; }
.popup-objectives { margin: 0; padding: 0 0 0 16px; color: #ccc; }
.popup-objectives li { font-size: 0.83rem; line-height: 1.6; margin-bottom: 2px; }
.popup-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.prereq-tag {
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 4px;
  padding: 2px 7px; font-size: 0.8rem; font-family: inherit; color: #8ab4d8;
  cursor: pointer; transition: all 0.12s;
}
.prereq-tag:hover { border-color: #3a5878; color: #c8d8ec; }
.popup-wiki-link {
  display: inline-block; margin-top: 6px;
  font-size: 0.8rem; color: #444; text-decoration: none; transition: color 0.15s;
}
.popup-wiki-link:hover { color: #4aaee8; }

/* ── Quest list section ─────────────────────────────────────────────────────── */
.quest-list-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 0 40px;
}
.list-section-header { margin-bottom: 18px; }
.list-section-header h2 {
  font-size: 1.25rem; font-weight: 700; color: #fff;
  margin: 0 0 4px;
  display: flex; align-items: center; gap: 10px;
}
#list-count-badge {
  font-size: 0.75rem; font-weight: 600;
  background: #1a1a1a; color: #666;
  border: 1px solid #2a2a2a; border-radius: 100px; padding: 2px 9px;
}
.list-sub { font-size: 0.85rem; color: #555; margin: 0; }

/* Update filter tabs */
.update-tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin-bottom: 14px;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 10px;
}
.u-tab {
  background: none; border: none;
  padding: 4px 12px; font-size: 0.82rem; font-family: inherit;
  font-weight: 500; color: #444; cursor: pointer;
  border-radius: 5px; transition: all 0.15s; position: relative;
}
.u-tab::after {
  content: ''; position: absolute; bottom: -11px; left: 0; right: 0;
  height: 2px; background: var(--uc, #4aaee8); border-radius: 2px;
  opacity: 0; transition: opacity 0.15s;
}
.u-tab:hover { color: #888; background: rgba(255,255,255,0.03); }
.u-tab.active { color: var(--uc, #4aaee8); }
.u-tab.active::after { opacity: 1; }

/* List toolbar */
.list-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.ls-search-wrap {
  position: relative; flex: 1; min-width: 180px;
}
.ls-search-wrap svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: #444; pointer-events: none;
}
#list-search-input {
  width: 100%; background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px;
  padding: 7px 10px 7px 28px; color: #d0d0d0; font-size: 0.86rem; font-family: inherit;
  outline: none; transition: border-color 0.15s;
}
#list-search-input::placeholder { color: #333; }
#list-search-input:focus { border-color: #3a5878; }

.ls-select {
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px;
  padding: 7px 26px 7px 10px; color: #888; font-size: 0.86rem;
  font-family: inherit; outline: none; cursor: pointer; min-width: 130px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23444' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 13px;
  transition: border-color 0.15s;
}
.ls-select:focus { border-color: #3a5878; }
.ls-select option { background: #1a1a1a; }
.ls-count { font-size: 0.8rem; color: #444; white-space: nowrap; margin-left: auto; }

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid #1e1e1e;
  border-radius: 8px;
  background: #161616;
}
.quests-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.quests-table th {
  padding: 9px 12px; text-align: left;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: #444;
  border-bottom: 1px solid #1e1e1e;
  background: #141414;
  white-space: nowrap;
}
.quests-table td {
  padding: 9px 12px; border-bottom: 1px solid #1a1a1a;
  color: #888; vertical-align: top; line-height: 1.5;
}
.quests-table tr:last-child td { border-bottom: none; }
.quests-table tr:hover td { background: rgba(255,255,255,0.02); }

.col-img { width: 94px; padding: 6px 6px 6px 10px !important; }
.col-name { min-width: 150px; }
.col-trader { width: 110px; }
.col-loc { min-width: 140px; }

.quest-thumb {
  width: 82px; height: 54px; border-radius: 4px;
  background: rgba(50,80,120,0.15);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: var(--tc, #4aaee8);
  border: 1px solid #1e1e1e; flex-shrink: 0;
}
.quest-thumb img { width: 100%; height: 100%; object-fit: cover; }

.quest-link { color: #c0c0c0; text-decoration: none; font-weight: 500; transition: color 0.1s; }
.quest-link:hover { color: #4aaee8; }

.jump-to-btn {
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; margin-left: 5px;
  width: 18px; height: 18px;
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 3px;
  color: #333; cursor: pointer; opacity: 0; transition: all 0.12s;
}
.quests-table tr:hover .jump-to-btn { opacity: 1; }
.jump-to-btn:hover { border-color: #4aaee8; color: #4aaee8; }
.jump-to-btn svg { width: 11px; height: 11px; }

/* Trader cell with image + name */
.trader-cell {
  display: flex; align-items: center; gap: 7px;
}
.trader-avatar {
  width: 28px; height: 38px;
  object-fit: cover; object-position: top center;
  border-radius: 3px; flex-shrink: 0;
  background: #1a1a1a; border: 1px solid #1e1e1e;
}
.t-name {
  font-size: 0.78rem; font-weight: 600; white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Clickable map links */
.map-link { color: #6a8aac; text-decoration: none; transition: color 0.1s; }
.map-link:hover { color: #4aaee8; text-decoration: underline; }

.dash { color: #333; }

@media (max-width: 780px) { .col-loc, .quests-table .td-loc { display: none; } }
@media (max-width: 560px) { .col-req, .quests-table .td-req { display: none; } }

/* ── Quest tracking ─────────────────────────────────────────────────────────── */
.col-done {
  width: 36px;
  padding: 6px 4px 6px 10px !important;
  text-align: center;
  vertical-align: middle;
}
.quest-cb {
  width: 15px; height: 15px;
  accent-color: #48c79c;
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
}
tr.quest-done > td {
  opacity: 0.5;
}
tr.quest-done > td.col-done {
  opacity: 1; /* keep checkbox full-opacity */
}
tr.quest-done .quest-link {
  text-decoration: line-through;
  color: #5a8a78;
}

/* Reset progress button in list toolbar */
.ls-reset-btn {
  background: none;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 7px 12px;
  color: #555;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.ls-reset-btn:hover {
  border-color: #e84c4c;
  color: #e84c4c;
  background: rgba(232,76,76,0.06);
}

/* ── SEO block ──────────────────────────────────────────────────────────────── */
.seo-block {
  max-width: 800px; margin: 60px auto 0;
  padding: 28px 0; border-top: 1px solid #1e1e1e; text-align: center;
}
.seo-block h2 { font-size: 0.95rem; font-weight: 600; color: #888; margin: 0 0 8px; }
.seo-block p  { font-size: 0.82rem; color: #444; line-height: 1.75; margin: 0; }
