/* OSRS Item Tree: dark minimal theme */

:root {
  --bg: #121417;
  --bg-raised: #1b1e23;
  --bg-hover: #252931;
  --border: #2c3139;
  --text: #e4e6ea;
  --text-dim: #9097a3;
  --accent: #d9b45a;
  --accent-dim: rgba(217, 180, 90, 0.35);
  --edge: #3a404a;
  --edge-hl: #d9b45a;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  top: 0; left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}

.back {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}
.back:hover, .back:focus-visible { background: var(--bg-hover); outline: none; border-color: var(--accent-dim); }

.brand { color: var(--text-dim); text-decoration: none; font-size: 14px; }
.brand:hover { color: var(--text); }

main { flex: 1; display: flex; min-height: 0; }

/* ---------- home ---------- */

.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: 18vh;
}

.home h1 { margin: 0 0 6px; font-size: 34px; font-weight: 600; letter-spacing: 0.5px; }
.tagline { margin: 0 0 28px; color: var(--text-dim); text-align: center; }

.search { position: relative; width: min(560px, 100%); }

#search {
  width: 100%;
  padding: 16px 20px;
  font-size: 18px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.15s;
}
#search:focus { border-color: var(--accent-dim); }

.results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 10;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.results li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.results li.active, .results li:hover { background: var(--bg-hover); }
.results li .icon { width: 32px; height: 32px; }
.results li mark { background: none; color: var(--accent); }
.results .empty { color: var(--text-dim); cursor: default; }

/* Icon box used in search results, nodes, and the panel */
.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.icon .spr { display: block; flex: none; background-repeat: no-repeat; image-rendering: pixelated; }
.icon .ph {
  width: 70%; height: 70%;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------- graph view ---------- */

.view { flex: 1; display: flex; min-height: 0; }

.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.stage.panning { cursor: grabbing; }

.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.edges path { fill: none; stroke: var(--edge); stroke-width: 1.6; transition: stroke 0.15s, opacity 0.15s; }
.edges path.hl { stroke: var(--edge-hl); stroke-width: 2.2; }
.edges.dim path:not(.hl) { opacity: 0.35; }

.fading { transition: opacity 0.3s ease; opacity: 0; pointer-events: none; }

.node {
  position: absolute;
  left: 0; top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.node:hover, .node:focus-visible, .node.hl { border-color: var(--accent); outline: none; }
.node .icon { width: 70%; height: 70%; }

.node.center {
  border-radius: 16px;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 4px rgba(217, 180, 90, 0.08);
}
.node.center .label {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}

.node.junction {
  border-radius: 50%;
  background: var(--edge);
  border: 2px solid var(--bg);
}
.node.junction:hover, .node.junction.hl { background: var(--accent); }

.node.source .glyph { color: var(--text-dim); font-size: 15px; line-height: 1; }
.node.text-ing { border-style: dashed; }
.node.text-ing .glyph { color: var(--text-dim); font-size: 12px; }

.node.pill {
  border-radius: 999px;
  padding: 0 12px;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
.node.pill .icon { width: 18px; height: 18px; }
.node.pill:hover { color: var(--text); }
.node.more { border-style: dashed; }

.legend {
  position: absolute;
  right: 14px; top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.legend .up-label::before { content: "\2191  "; }
.legend .down-label::before { content: "\2193  "; }

/* ---------- detail panel ---------- */

.panel {
  width: 340px;
  flex: none;
  overflow-y: auto;
  padding: 64px 20px 20px;
  border-left: 1px solid var(--border);
  background: var(--bg);
}
.panel h2 { margin: 0; font-size: 20px; }
.panel .head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.panel .head .icon { width: 44px; height: 44px; }
.panel .examine { color: var(--text-dim); font-style: italic; margin: 0 0 14px; }
.panel dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 16px; font-size: 14px; }
.panel dt { color: var(--text-dim); }
.panel dd { margin: 0; text-align: right; }
.panel h3 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); font-weight: 600; }
.panel ul { margin: 0; padding-left: 18px; font-size: 14px; }
.panel li { margin: 2px 0; }
.panel .note { font-size: 12px; color: var(--text-dim); }
.panel .linkish { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-color: var(--accent-dim); }
.panel .list-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-top: 8px; background: var(--bg-raised); }
.panel .list-box ul { max-height: 320px; overflow-y: auto; }
.panel .close { float: right; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; }
.panel .wiki { display: inline-block; margin-top: 16px; font-size: 13px; }

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

.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  padding: 8px 11px;
  background: #0b0c0e;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.tooltip strong { display: block; margin-bottom: 2px; }
.tooltip .dim { color: var(--text-dim); }

/* ---------- footer ---------- */

.footer {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ---------- small screens: panel goes below the graph ---------- */

@media (max-width: 860px) {
  body { height: auto; min-height: 100%; }
  .view { flex-direction: column; }
  .stage { flex: none; height: 62vh; }
  .panel { width: 100%; padding: 16px; border-left: none; border-top: 1px solid var(--border); }
  .home h1 { font-size: 28px; }
}

/* ---------- Phase 4: states, messages, accessibility ---------- */

.loading { margin: 14px 0 0; color: var(--text-dim); font-size: 14px; }
.hint { margin: 18px 0 0; color: var(--text-dim); font-size: 12px; opacity: 0.8; text-align: center; }
#search:disabled { opacity: 0.6; }

/* Notices (unknown item, missing data, unexpected errors) */
.message {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 16px;
  background: #2a2216;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  font-size: 14px;
  text-align: center;
}

/* Text for screen readers only */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Panel links are buttons styled as links, so they work with the keyboard */
button.linkish {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
}
button.linkish:focus-visible, .close:focus-visible, .wiki:focus-visible, .brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.node:focus-visible { box-shadow: 0 0 0 3px var(--accent-dim); }

@media (hover: none) {
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Footer paragraphs: credits and the required Jagex Fan Content Policy wording */
.footer p { margin: 2px 0; }
.footer .legal { color: var(--text); opacity: 0.85; }
