/* ============================================================
   Meertec — Enterprise Capability Explorer
   Design tokens match the main site (ink/paper/brass/verdigris,
   Fraunces + IBM Plex). Three-column explorer layout.
   ============================================================ */

:root {
  --ink:          #0F1B2B;
  --ink-soft:     #16263B;
  --ink-line:     #2A3B52;
  --ink-text-lo:  #A8B3C2;
  --ink-text-hi:  #EDEFF2;

  --paper:        #F6F3EC;
  --paper-alt:    #ECE7DA;
  --paper-line:   #D9D2C0;
  --paper-text-lo:#6B6355;
  --paper-text-hi:#1B1A17;

  --brass:        #B08D57;
  --brass-dark:   #8C6E3F;
  --verdigris:    #4C7A6D;

  --font-display: "Fraunces", Georgia, serif;
  --font-body:    "IBM Plex Sans", -apple-system, Segoe UI, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

  --panel-bg:     #efeadd;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--paper-text-hi);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font-body); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Explorer masthead tweaks ---------- */

.explorer-masthead-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-text-lo);
}
.masthead-back {
  color: var(--ink-text-hi);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid var(--ink-line);
  border-radius: 4px;
  padding: 6px 12px;
}
.masthead-back:hover { color: var(--brass); border-color: var(--brass); }

@media (max-width: 640px) {
  .explorer-masthead-label { display: none; }
}

/* ---------- Page shell: sticky header + full-height explorer ---------- */

.explorer-wrap {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.explorer-main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 1px;
  background: var(--paper-line);
  overflow: hidden;
}

/* ---------- Left & right panels ---------- */

.panel {
  background: var(--panel-bg);
  overflow-y: auto;
  padding: 14px 14px 24px;
}

.panel-block-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-text-lo);
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: 6px;
}
.panel-block-title:first-child { margin-top: 0; }

/* Left panel: keep a visible scrollbar when the tree/filters overflow. */
#left-panel {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-line) transparent;
}
#left-panel::-webkit-scrollbar { width: 10px; }
#left-panel::-webkit-scrollbar-track { background: transparent; }
#left-panel::-webkit-scrollbar-thumb {
  background: var(--paper-line);
  border-radius: 6px;
  border: 2px solid var(--panel-bg);
}
#left-panel::-webkit-scrollbar-thumb:hover { background: var(--brass); }

/* ---------- Capability tree ---------- */

.tree-item { margin: 2px 0; }

.tree-toggle {
  background: none;
  border: 0;
  color: var(--paper-text-lo);
  cursor: pointer;
  width: 18px;
  font-size: 12px;
  padding: 0;
  vertical-align: middle;
}
.tree-toggle:hover { color: var(--brass-dark); }

.tree-name, .tree-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 20px);
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 3px;
  color: var(--paper-text-hi);
  font-size: 13px;
}
.tree-name:hover, .tree-child:hover { background: var(--paper-alt); color: var(--brass-dark); }

.tree-child { font-size: 12px; color: var(--paper-text-lo); width: calc(100% - 26px); margin-left: 20px; }

.dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  display: inline-block;
}

.tree-children { margin: 2px 0 2px 0; }

/* ---------- Layer filters ---------- */

.filters { display: flex; flex-direction: column; gap: 4px; }

.filter {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 3px;
}
.filter:hover { background: var(--paper-alt); }

.filter input { accent-color: var(--brass); cursor: pointer; }

.filter-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto;
}

.filter-label { font-size: 13px; }

.filter-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--brass-dark);
}

/* ---------- Centre graph panel ---------- */

.graph-panel {
  position: relative;
  background: var(--paper);
  min-width: 0;
  min-height: 0;
}

#graph {
  position: absolute;
  inset: 0;
}

.graph-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 5;
  gap: 10px;
}
.graph-toolbar > * { pointer-events: auto; }

.search-wrap { position: relative; flex: 1; max-width: 340px; }
.search-input {
  width: 100%;
  border: 1px solid var(--paper-line) !important;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  background: rgba(246, 243, 236, 0.92) !important;
  color: var(--paper-text-hi);
  box-shadow: 0 1px 3px rgba(15,27,43,.08) !important;
  box-sizing: border-box !important;
}
.search-input:focus { outline: 2px solid var(--brass); outline-offset: 0; }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(15,27,43,.18);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 20;
}
.search-results.open { display: block; }

.search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}
.search-result:hover { background: var(--paper-alt); }

.search-swatch { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.search-name { font-size: 13px; color: var(--paper-text-hi); flex: 1; }
.search-type {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--paper-text-lo);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.toolbar-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  line-height: 1;
}

.toolbar-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .05em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px !important;
  min-height: 26px !important;
  max-height: 26px !important;
  width: auto !important;
  flex: 0 0 auto !important;
  background: var(--paper);
  color: var(--paper-text-hi);
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  padding: 0 9px;
  cursor: pointer;
  text-transform: uppercase;
  white-space: nowrap;
}
.toolbar-btn:hover { background: var(--paper-alt); border-color: var(--brass); color: var(--brass-dark); }

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.layout-select {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .05em;
  line-height: 1;
  height: 26px;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--paper-text-hi);
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  padding: 0 6px;
  cursor: pointer;
  max-width: 120px;
}
.layout-select:focus { outline: 2px solid var(--brass); outline-offset: 0; }

/* ---------- Details panel ---------- */

.details-empty {
  color: var(--paper-text-lo);
  font-size: 13px;
  padding: 8px 0;
}

.details h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 8px 0 6px;
  line-height: 1.15;
}

.details-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-text-hi);
  background: var(--badge-color, #64748b);
  padding: 2px 8px;
  border-radius: 3px;
}

.details-desc { font-size: 13px; color: var(--paper-text-hi); margin: 8px 0 14px; line-height: 1.5; }

.details-field { margin: 4px 0; }
.details-field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--paper-text-lo);
  display: block;
}
.details-field-value { font-size: 13px; }

.details-section { margin-top: 16px; }
.details-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--paper-text-lo);
  margin: 0 0 8px;
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: 4px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--paper-line);
  background: var(--paper);
  color: var(--paper-text-hi);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  position: relative;
}
.chip:hover {
  border-color: var(--chip-color, var(--brass));
  background: var(--paper-alt);
  color: var(--chip-color, var(--brass-dark));
}
.chip::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--chip-color, var(--brass));
  margin-right: 6px;
  display: inline-block;
}

/* ---------- Hover tooltip ---------- */

#tooltip {
  position: fixed;
  z-index: 40;
  background: var(--ink);
  color: var(--ink-text-hi);
  border: 1px solid var(--ink-line);
  border-radius: 6px;
  padding: 8px 10px;
  max-width: 240px;
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, -130%);
  opacity: 0;
  transition: opacity .12s ease;
  box-shadow: 0 6px 18px rgba(15,27,43,.3);
}
#tooltip.visible { opacity: 1; }

.tip-type {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  margin-bottom: 4px;
  width: fit-content;
  color: #fff;
}
.tip-name { font-weight: 600; display: block; margin-bottom: 2px; }
.tip-desc { color: var(--ink-text-lo); display: block; line-height: 1.35; }

/* ---------- Context menu ---------- */

#context-menu {
  position: fixed;
  z-index: 50;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15,27,43,.22);
  padding: 4px;
  min-width: 170px;
  display: none;
}
#context-menu.visible { display: block; }

.ctx-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--paper-line);
  margin-bottom: 4px;
}
.ctx-swatch { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.ctx-item {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  padding: 6px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  color: var(--paper-text-hi);
}
.ctx-item:hover { background: var(--paper-alt); color: var(--brass-dark); }

/* ---------- Loading overlay ---------- */

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  z-index: 30;
  font-family: var(--font-display);
  color: var(--paper-text-lo);
  font-size: 1.1rem;
}
.loading-overlay.hidden { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .explorer-main { grid-template-columns: 220px 1fr 260px; }
}

@media (max-width: 820px) {
  .explorer-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .panel { max-height: 180px; }
  #details { max-height: 240px; }
}
