/* ============================================================================
   RESEARCH  ·  tech tree stylesheet
   ----------------------------------------------------------------------------
   The tokens copy pages/home/style.css. The board fills the window under the
   bar. On a wide screen the panel is a glass card on the right. On a phone
   (max-width 760px) the panel is a bottom sheet and the dock sits above it.

   grep -n targets
     tokens ............... ":root"
     top bar .............. ".bar"
     search ............... ".find" / ".hits"
     legend ............... ".legend"
     board ................ "#view" / "#world"
     lanes and tier heads . ".lane" / ".tier-head"
     edges ................ "#edges"
     node card ............ ".node"
     sprite chips ......... ".chip"
     node states .......... ".node.sel"
     key close button ..... ".p-close" / ".key-hidden"
     dock ................. "#dock"
     panel ................ "#panel"
     phone ................ "@media (max-width: 760px)"
     short landscape ...... "@media (max-height: 520px) and (min-width: 761px)"
     touch sizes .......... "@media (pointer: coarse)"
   ============================================================================ */

:root {
  --bg: #0a0c12; --bg2: #0e1119; --bg3: #131826;
  --ink: #eef3fb; --text: #c3d0e2; --dim: #7f91ad; --faint: #3a4866;
  --line: rgba(150, 200, 255, 0.09); --line2: rgba(150, 200, 255, 0.18);
  --blue: #96c8ff; --gold: #ffc832; --orange: #ff7b00;
  --glass: rgba(16, 21, 33, 0.62);
  --f-sans: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --f-serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --r: 16px; --r-sm: 10px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --bar-h: 76px;
  /* discipline colours */
  --c-materials: #96c8ff; --c-combat: #ff8a5c; --c-antimatter: #c39bff;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }
body { font: 400 15px/1.5 var(--f-sans); color: var(--text); background: var(--bg); overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
em { font-family: var(--f-serif); font-style: italic; font-weight: 400; color: var(--gold); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
.kicker { font: 500 0.66rem/1.3 var(--f-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--blue); opacity: 0.8; }

/* ── top bar ─────────────────────────────────────────────────────────────── */
.bar { position: fixed; inset: 0 0 auto 0; z-index: 20; height: var(--bar-h); display: flex; align-items: center; gap: 24px; padding: 0 22px; background: linear-gradient(180deg, rgba(10, 12, 18, .96), rgba(10, 12, 18, .82)); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.bar-title { flex: none; }
.bar-title .kicker, .bar h1 { white-space: nowrap; }
.bar h1 { font: 300 1.65rem/1.05 var(--f-sans); color: var(--ink); letter-spacing: -0.01em; }
.find { position: relative; flex: 0 1 360px; min-width: 0; }
.find svg { position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--dim); stroke-width: 2; pointer-events: none; }
.find input { width: 100%; height: 42px; padding: 0 14px 0 38px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(16, 21, 33, .8); color: var(--ink); outline: none; transition: border-color .2s; }
.find input:focus { border-color: var(--blue); }
.find input::placeholder { color: var(--dim); }
.hits { position: absolute; left: 0; right: 0; top: calc(100% + 6px); list-style: none; max-height: 320px; overflow-y: auto; padding: 6px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(12, 16, 26, .97); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .8); }
.hits li button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; cursor: pointer; }
.hits li button:hover, .hits li button.on { background: rgba(150, 200, 255, .08); }
.hits .h-name { color: var(--ink); font-weight: 500; }
.hits .h-sub { margin-left: auto; font: 400 0.7rem/1.2 var(--f-mono); color: var(--dim); white-space: nowrap; }
.hits .h-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c); }
.hits .empty { padding: 10px; color: var(--dim); font-size: 0.85rem; }
.legend { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border: 1px solid var(--line2); border-radius: 999px; font: 500 0.68rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }

/* ── board ───────────────────────────────────────────────────────────────── */
#view { position: fixed; inset: var(--bar-h) 0 0 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background:
    radial-gradient(1200px 600px at 30% 20%, rgba(150, 200, 255, .05), transparent 70%),
    radial-gradient(900px 500px at 80% 90%, rgba(195, 155, 255, .045), transparent 70%),
    var(--bg); }
#view.drag { cursor: grabbing; }
#view::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(150, 200, 255, .14) 1px, transparent 1.2px); background-size: 28px 28px; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.hint { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); font: 400 0.72rem/1 var(--f-mono); color: var(--dim); letter-spacing: .06em; pointer-events: none; transition: opacity .6s; white-space: nowrap; }
.hint.gone { opacity: 0; }

.lane { position: absolute; border-radius: 22px; border: 1px solid var(--line); background: linear-gradient(90deg, color-mix(in srgb, var(--c) 7%, transparent), transparent 40%); pointer-events: none; }
.lane-label { position: absolute; left: 22px; top: 14px; font: 500 0.7rem/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--c); opacity: .85; }
.tier-head { position: absolute; top: 0; width: 196px; text-align: center; font: 500 0.68rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.tier-head::after { content: ''; display: block; margin: 9px auto 0; width: 1px; height: 14px; background: var(--line2); }
.col-rule { position: absolute; width: 1px; background: linear-gradient(180deg, var(--line), transparent); pointer-events: none; }

#edges path { fill: none; stroke: rgba(150, 200, 255, .2); stroke-width: 1.3; transition: stroke .25s, opacity .25s, stroke-width .25s; }
#edges path.cross { stroke-dasharray: 4 5; }
.has-sel #edges path { opacity: .12; }
.has-sel #edges path.up { opacity: 1; stroke: var(--gold); stroke-width: 2; }
.has-sel #edges path.down { opacity: 1; stroke: var(--blue); stroke-width: 2; }
.has-q #edges path { opacity: .25; }

/* ── node card ───────────────────────────────────────────────────────────── */
.node { position: absolute; width: 196px; height: 74px; display: flex; flex-direction: column; justify-content: space-between; padding: 10px 12px 9px 14px; border-radius: 14px; border: 1px solid var(--line2); background: rgba(16, 21, 33, .9); text-align: left; cursor: pointer; overflow: hidden; transition: border-color .25s, box-shadow .3s, opacity .25s, transform .3s var(--ease); }
.node::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); opacity: .8; }
.node:hover { border-color: color-mix(in srgb, var(--c) 60%, transparent); box-shadow: 0 10px 30px -14px color-mix(in srgb, var(--c) 70%, transparent); }
.node .n-name { font: 500 0.88rem/1.2 var(--f-sans); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .n-chips { display: flex; gap: 5px; align-items: center; min-height: 26px; }
.node .n-more { font: 400 0.66rem/1 var(--f-mono); color: var(--dim); }
.node .n-lead { font: 400 0.68rem/1 var(--f-mono); color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }

.chip { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); overflow: hidden; }
.chip img { width: 22px; height: 22px; object-fit: contain; }
.chip b { font: 600 0.68rem/1 var(--f-mono); color: var(--dim); letter-spacing: 0; }
.chip.mod { border-color: color-mix(in srgb, var(--gold) 45%, transparent); }

.has-sel .node { opacity: .22; }
.has-sel .node.sel, .has-sel .node.anc, .has-sel .node.desc { opacity: 1; }
.node.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 14px 40px -12px rgba(255, 200, 50, .55); }
.node.anc { border-color: rgba(255, 200, 50, .55); }
.node.desc { border-color: rgba(150, 200, 255, .6); }
.has-q:not(.has-sel) .node { opacity: .25; }
.has-q:not(.has-sel) .node.hit { opacity: 1; border-color: var(--gold); }

/* ── dock ────────────────────────────────────────────────────────────────── */
#dock { position: fixed; left: 22px; bottom: 22px; z-index: 15; display: flex; gap: 6px; padding: 6px; border-radius: 16px; border: 1px solid var(--line2); background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
#dock button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 11px; background: rgba(255, 255, 255, .02); cursor: pointer; transition: border-color .2s, background .2s; }
#dock button:hover { border-color: var(--line2); background: rgba(150, 200, 255, .07); }
#dock svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── panel ───────────────────────────────────────────────────────────────── */
#panel { position: fixed; right: 22px; top: calc(var(--bar-h) + 18px); z-index: 16; width: 340px; max-height: calc(100% - var(--bar-h) - 40px); overflow-y: auto; overscroll-behavior: contain; border-radius: var(--r); border: 1px solid var(--line2); background: rgba(14, 18, 28, .9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .9); padding: 20px 20px 22px; transition: transform .35s var(--ease), opacity .3s; }
#panel.empty { opacity: .94; }
#panel.empty.key-hidden { display: none; }
.p-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 11px; background: none; cursor: pointer; transition: border-color .2s, background .2s; }
.p-close:hover { border-color: var(--line2); background: rgba(150, 200, 255, .07); }
.p-close svg { width: 16px; height: 16px; fill: none; stroke: var(--dim); stroke-width: 2; stroke-linecap: round; }
.p-close + .p-kicker { padding-right: 40px; min-height: 24px; }
.grip { display: none; }
.p-kicker { display: flex; align-items: center; gap: 8px; font: 500 0.66rem/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--c, var(--blue)); }
.p-kicker i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.p-name { margin: 8px 0 14px; font: 300 1.6rem/1.1 var(--f-sans); color: var(--ink); letter-spacing: -0.01em; }
.p-sec { margin-top: 16px; }
.p-sec h3 { margin-bottom: 8px; font: 500 0.66rem/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.p-list { display: flex; flex-wrap: wrap; gap: 6px; }
.p-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 6px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .025); font-size: 0.8rem; color: var(--text); cursor: pointer; transition: border-color .2s, color .2s; }
.p-pill:hover { border-color: var(--blue); color: var(--ink); }
.p-pill i { width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: var(--c); }
.p-pill img { width: 20px; height: 20px; object-fit: contain; }
.p-pill .chip { width: 22px; height: 22px; border-radius: 6px; }
.p-none { font-size: 0.82rem; color: var(--faint); }
.p-actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.p-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(150, 200, 255, .06); color: var(--ink); font-size: 0.85rem; cursor: pointer; transition: border-color .2s, box-shadow .3s; }
.p-btn:hover { border-color: var(--blue); box-shadow: 0 8px 26px -12px rgba(150, 200, 255, .6); }
.p-btn.gold { background: linear-gradient(135deg, #ffd65c, #ffb31a 55%, #ff8a3d); color: #1a1204; border-color: transparent; font-weight: 600; }
.p-notes:empty { display: none; }
.p-intro { font-size: 0.88rem; color: var(--dim); }
.p-intro b { color: var(--text); font-weight: 500; }
.p-key { margin-top: 14px; display: grid; gap: 8px; font-size: 0.8rem; color: var(--dim); }
.p-key div { display: flex; align-items: center; gap: 10px; }
.p-key s { display: inline-block; width: 26px; height: 0; border-top: 2px solid var(--k); text-decoration: none; }
.p-key s.dash { border-top-style: dashed; border-top-width: 1.5px; }

/* ── phone ───────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  :root { --bar-h: 112px; }
  .bar { flex-wrap: wrap; align-content: center; gap: 8px 12px; padding: 8px 16px; }
  .bar h1 { font-size: 1.3rem; }
  .bar-title { display: flex; align-items: baseline; gap: 10px; }
  .find { flex: 1 1 100%; order: 3; }
  .find input { height: 40px; }
  .legend { margin-left: auto; gap: 5px; }
  .legend span { padding: 4px 8px; font-size: 0.6rem; gap: 5px; }
  .legend span b { display: none; }
  .hint { left: 16px; right: 16px; transform: none; bottom: calc(86px + env(safe-area-inset-bottom)); text-align: center; white-space: normal; line-height: 1.4; }
  .p-close, #dock [data-act="key"] { display: none; }
  #dock { left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); transition: bottom .35s var(--ease); }
  #dock button { width: 48px; height: 48px; }
  body.sheet-open #dock { bottom: calc(var(--sheet-h, 46vh) + 10px); }
  #panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 46vh; max-height: 46dvh; border-radius: 20px 20px 0 0; border-bottom: 0; padding: 4px 18px calc(20px + env(safe-area-inset-bottom)); transform: translateY(105%); }
  #panel.open { transform: none; }
  #panel.full { max-height: calc(100dvh - var(--bar-h) - 20px); }
  .grip { display: flex; justify-content: center; width: 100%; height: 44px; align-items: center; border: 0; background: none; cursor: pointer; }
  .grip span { width: 46px; height: 5px; border-radius: 3px; background: var(--dim); opacity: .6; }
  .p-name { font-size: 1.35rem; margin: 6px 0 8px; }
}
/* A phone held sideways: the wide layout with a short bar and a narrow panel,
   so the board keeps most of the screen. */
@media (max-height: 520px) and (min-width: 761px) {
  :root { --bar-h: 58px; }
  .bar { gap: 16px; padding: 0 16px 0 calc(16px + env(safe-area-inset-left)); }
  .bar-title .kicker { display: none; }
  .bar h1 { font-size: 1.3rem; }
  .find input { height: 40px; }
  .legend { flex-wrap: nowrap; gap: 5px; }
  .legend span { padding: 4px 8px; }
  #panel { width: 290px; top: calc(var(--bar-h) + 10px); right: calc(12px + env(safe-area-inset-right)); max-height: calc(100% - var(--bar-h) - 22px); padding: 14px 16px 16px; }
  .p-name { font-size: 1.25rem; margin: 6px 0 8px; }
  .p-key { margin-top: 10px; gap: 6px; }
  #dock { left: calc(12px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); }
  .hint { left: calc((100% - 302px) / 2); }
}
/* Touch: inputs at 16px so iOS Safari does not zoom on focus, and every
   control the finger hits is at least 44px tall. */
@media (pointer: coarse) {
  .h-wheel { display: none; }
  .find input { font-size: 16px; height: 44px; }
  .hits li button { min-height: 44px; }
  .p-btn { min-height: 44px; }
  .p-pill { min-height: 36px; }
  #dock button { width: 48px; height: 48px; }
}
/* Touch on a wide screen: the dock buttons grow, so the hint moves above the dock. */
@media (pointer: coarse) and (min-width: 761px) {
  .hint { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
