/* The Bug Hunt list and skill tree (assets/v3/catalog.mjs, assets/v3/skill-tree.mjs).
   Theme colours only: difficulty uses good (easy), warn (medium), bad (hard), flow-return
   (expert) and muted (unrated); branches of the winding path use the track channels (--ch-*). */

.view-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 4px 0 6px; }
.seg-switch { display: inline-flex; gap: 2px; padding: 4px; border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent); border-radius: var(--r-pill); background: color-mix(in srgb, var(--card) 70%, transparent); }
.seg-switch button { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 16px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font: 600 14.5px var(--sans); cursor: pointer; }
.seg-switch button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.seg-switch button svg circle { fill: currentColor; stroke: none; }
.seg-switch button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.seg-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg-switch.small button { min-height: 32px; padding: 0 13px; font-size: 13.5px; }
.seg-switch[hidden] { display: none; }
.sort-by { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font: 600 13px var(--sans); color: var(--muted); }
.sort-by[hidden] { display: none; }
.sort-by select { min-height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--rule-strong); background: var(--card); color: var(--ink); font: 500 14px var(--sans); }

/* list rows: a rating column; a padlock on locked problems for visitors */
.problem-row { grid-template-columns: 70px minmax(0, 1fr) 54px 84px 96px 84px 82px; }
.row-rating { font: 600 13px var(--mono); color: var(--muted); text-align: right; }
.row-lock { display: none; vertical-align: -1px; margin-right: 7px; fill: none; stroke: var(--muted); stroke-width: 1.6; }
.bh-signed-out .row-lock { display: inline; }
@media (max-width: 900px) { .row-rating { order: 2; } }

.skill-tree { margin-top: 14px; }
.tree-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; padding: 14px 0 10px; }
.tree-progress { display: flex; align-items: center; gap: 8px; font: 600 14.5px var(--sans); color: var(--ink-2); }
.tree-progress strong { font: 700 20px var(--display); color: var(--ink); }
.tree-bar { display: inline-block; width: 140px; height: 8px; margin-left: 8px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.tree-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .6s var(--ease); }
.tree-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font: 500 13px var(--sans); color: var(--muted); }
.tree-legend li { display: inline-flex; align-items: center; gap: 7px; }
.tree-legend li[hidden] { display: none; }
.tree-legend .lg { position: relative; display: inline-block; width: 15px; height: 15px; border-radius: 50%; border: 2.5px solid var(--dc); background: var(--card); }
.tree-legend .lg.s-solved { background: var(--dc); }
.tree-legend .lg.s-started { background: color-mix(in srgb, var(--dc) 35%, var(--card)); }
.tree-legend .lg.unready { border-style: dashed; opacity: .7; }
.tree-legend .lg.next { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.tree-legend .lg.locked { border-color: var(--muted); }
.tree-signin { margin: 0 0 10px; padding: 11px 14px; border-radius: 12px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2);
  background: color-mix(in srgb, var(--accent) 8%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.tree-signin a { color: var(--link); font-weight: 650; }
.tree-signin[hidden] { display: none; }

/* The branching circuit is the visual centre. Navigation and the rating ruler stay quiet. */
.tr-sv { --tc: var(--ch-sv); } .tr-uvm { --tc: var(--ch-uvm); }
.tr-sva { --tc: var(--ch-sva); } .tr-coverage { --tc: var(--ch-cov); }
.bh-tree-view .learn-head { padding-top: 24px; padding-bottom: 20px; }
.bh-tree-view .learn-head h1 { font-size: clamp(26px, 3vw, 38px); margin-bottom: 0; }
.bh-tree-view .learn-head > p { display: none; }
.tree-tracks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 24px 0 16px; }
.tree-track { position: relative; display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 18px; border: 1px solid var(--rule); border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer; transition: border-color .2s, background .2s; }
.tree-track > svg { flex: 0 0 30px; width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tree-track span { display: grid; gap: 4px; }.tree-track strong { font: 650 16px/1.2 var(--sans); }.tree-track small { font: 450 12px/1.2 var(--sans); color: var(--muted); }
.tree-track[aria-pressed="true"] { color: var(--tc); border-color: var(--tc); background: color-mix(in srgb, var(--tc) 6%, var(--card)); box-shadow: inset 0 -2px var(--tc); }
.tree-track:hover:not(:disabled) { border-color: var(--tc); color: var(--tc); }.tree-track:disabled { opacity: .45; cursor: default; }
.tree-skills { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: thin; }
.tree-skills[hidden] { display: none; }
.tree-skills button { flex: 0 0 auto; padding: 9px 14px; min-height: 40px; background: transparent; border: 1px solid transparent; border-radius: 7px; color: var(--ink-2); font: 500 13px/1.2 var(--sans); cursor: pointer; }
.tree-skills button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tree-skills button:hover:not([aria-pressed="true"]) { background: var(--paper-2); border-color: var(--rule); }
.tree-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0 12px; }
.tree-heading h2 { font: 650 clamp(22px, 2.6vw, 30px)/1.2 var(--sans); letter-spacing: -.035em; margin: 0 0 6px; }
.tree-heading p { font: 450 13px/1.4 var(--sans); color: var(--muted); margin: 0; }
.tree-heading .tree-progress { flex-shrink: 0; font-size: 13px; gap: 6px; }.tree-heading .tree-bar { width: 70px; height: 4px; }
.tree-actions { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; font: 450 12px/1.4 var(--sans); color: var(--muted); }
.tree-actions > span { margin-right: auto; }.tree-actions button { background: transparent; border: 1px solid var(--rule); border-radius: 7px; padding: 7px 10px; min-height: 34px; color: var(--ink-2); font: 550 12px var(--sans); cursor: pointer; }
.tree-actions button:hover:not(:disabled) { border-color: var(--ink-2); }.tree-actions button:disabled { opacity: .45; cursor: default; }.tree-actions [hidden] { display: none; }
.tree-canvas { position: relative; isolation: isolate; min-height: 120px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; border: 1px solid var(--rule); border-radius: 22px;
  background: var(--paper); }
.tree-stage { position: relative; background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--tc, var(--accent)) 7%, transparent), transparent 65%); }
.tree-empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.tree-lines { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.tree-lines path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.route-bed { stroke: color-mix(in srgb, var(--tc) 5%, transparent); stroke-width: 10; }
.route-wire { stroke: color-mix(in srgb, var(--tc) 48%, var(--paper)); stroke-width: 1.8; transition: stroke .2s, opacity .2s; }
.route-signal { stroke: var(--tc); stroke-width: 3; stroke-dasharray: 3 97; opacity: 0; }
.route.complete .route-wire { stroke: var(--tc); stroke-width: 2.5; }
.route.lit .route-wire { stroke: var(--tc); stroke-width: 2.5; }
.route.lit .route-bed { stroke: color-mix(in srgb, var(--tc) 13%, transparent); }
.route.lit .route-signal { opacity: 1; animation: route-flow 1.6s linear infinite; }
.exploring .route:not(.lit) { opacity: .25; }
@keyframes route-flow { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.rating-ruler { position: absolute; inset: 0; pointer-events: none; }
.rating-tick { position: absolute; left: 0; right: 0; border-top: 1px solid color-mix(in srgb, var(--ink) 5%, transparent); }
.rating-tick span { position: absolute; left: 16px; top: -7px; padding-right: 10px; background: var(--paper); color: var(--muted); font: 500 11px/1.2 var(--mono); }
.tier-bands { position: absolute; inset: 0; pointer-events: none; }
.tier-band { position: absolute; left: 0; right: 0; border-top: 1px solid color-mix(in srgb, var(--tc) 12%, transparent); }
.tier-band.b1 { background: color-mix(in srgb, var(--tc) 2%, transparent); }
.tier-band > span { position: absolute; right: 18px; top: 9px; color: var(--muted); font: 450 12px var(--sans); }
.flipped .tier-band > span { top: auto; bottom: 9px; }
.skill-root { position: absolute; translate: -50% -50%; width: 44px; height: 44px; color: var(--tc); }
.skill-root svg { width: 44px; height: 44px; flex-shrink: 0; fill: var(--paper); stroke: var(--tc); stroke-width: 1.5; stroke-linejoin: round; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--tc) 30%, transparent)); }
.skill-root span { position: absolute; top: 52px; left: 50%; translate: -50% 0; width: max-content; max-width: 200px; text-align: center; color: var(--ink); font: 600 13px/1.3 var(--sans); padding: 3px 8px; border-radius: 4px; background: var(--paper); }
.you-are-here { position: absolute; left: 0; right: 0; z-index: 2; border-top: 1px dashed var(--accent); pointer-events: none; }
.you-are-here > span { position: absolute; right: 10px; top: -13px; padding: 5px 9px; border-radius: 5px; font: 600 11px var(--sans); color: var(--on-accent); background: var(--accent); }
/* Faceted silicon nodes: one shape, with status and format independent of colour. */
.tree-node { --dc: var(--muted); position: absolute; width: 48px; height: 48px; margin: -24px 0 0 -24px; z-index: 3; text-decoration: none; outline-offset: 7px; border-radius: 10px; color: var(--dc); }
.node-face { position: absolute; inset: 5px; display: grid; place-items: center; background: var(--card); border: 1.5px solid var(--dc); border-radius: 9px; transform: rotate(45deg);
  box-shadow: inset 3px 3px 0 color-mix(in srgb, var(--dc) 11%, transparent), inset -3px -3px 0 color-mix(in srgb, var(--ink) 6%, transparent), 0 0 0 5px color-mix(in srgb, var(--dc) 5%, transparent);
  transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s, background .22s; }
.node-face svg { width: 22px; height: 22px; transform: rotate(-45deg); fill: none; stroke: currentColor; stroke-width: 3.8; stroke-linecap: round; stroke-linejoin: round; }
.d-easy { --dc: var(--good); }.d-medium { --dc: var(--warn); }.d-hard { --dc: var(--bad); }.d-expert { --dc: var(--flow-return); }.d-unrated { --dc: var(--muted); }
.node-caption { position: absolute; top: 55px; left: 50%; translate: -50% 0; display: grid; gap: 3px; width: var(--caption-width, 134px); text-align: center; }
.node-id { font: 500 10px/1.2 var(--mono); color: var(--muted); }.node-name { font: 500 12px/1.3 var(--sans); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 0 4px var(--paper), 0 0 4px var(--paper); }
.tree-node:hover, .tree-node:focus-visible { z-index: 6; }.tree-node:focus-visible { outline: 2px solid var(--focus); }
.tree-node:hover .node-face, .tree-node:focus-visible .node-face, .tree-node[aria-expanded="true"] .node-face { transform: rotate(45deg) scale(1.17); background: color-mix(in srgb, var(--dc) 12%, var(--card)); box-shadow: 0 0 0 6px color-mix(in srgb, var(--dc) 9%, transparent), 0 0 30px color-mix(in srgb, var(--dc) 25%, transparent); }
.tree-node.on-route .node-name { color: var(--ink); }.tree-node.on-route .node-face { box-shadow: 0 0 0 5px color-mix(in srgb, var(--dc) 10%, transparent), 0 0 22px color-mix(in srgb, var(--dc) 15%, transparent); }
.tree-node.s-solved .node-face { background: var(--dc); color: var(--card); }.tree-node.s-started .node-face { background: color-mix(in srgb, var(--dc) 22%, var(--card)); }
.tree-node.s-revealed .node-face { border-style: dotted; }.tree-node.next .node-face { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent); }
.leaf-lock, .leaf-check { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; box-shadow: 0 0 0 2px var(--paper); background: var(--ink-2) center / 10px no-repeat; }
.leaf-lock { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='3' y='7' width='10' height='7' rx='1.6' fill='white'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 0 1 5 0v2' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E"); }
.leaf-check { display: grid; place-items: center; color: var(--paper); font: 700 11px var(--sans); background: var(--ink); }
/* A real description, floating in the viewport; on phones it becomes a bottom card. */
.tree-tip { position: fixed; z-index: 200; display: grid; gap: 8px; padding: 18px; border-radius: 16px; border: 1px solid var(--tc, var(--rule-strong)); background: var(--card); color: var(--ink); pointer-events: none; overflow-y: auto;
  box-shadow: 0 18px 70px -15px rgb(0 0 0 / .6), inset 0 3px var(--tc, var(--accent)); }
.tree-tip[hidden] { display: none; }.tree-tip.pinned { pointer-events: auto; animation: card-open .22s cubic-bezier(.2,.8,.2,1); }
.tip-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }.tip-id { font: 500 11px var(--mono); color: var(--muted); }
.tree-tip strong { font: 650 20px/1.2 var(--sans); letter-spacing: -.025em; }.tip-meta { font: 550 12px var(--sans); color: var(--tc, var(--ink-2)); }.tip-lead { font: 450 14px/1.55 var(--sans); margin: 4px 0; color: var(--ink-2); }.tip-topic { font: 450 12px/1.4 var(--sans); color: var(--muted); }
.tip-close { display: none; width: 30px; height: 30px; border-radius: 50%; padding: 0; border: 1px solid var(--rule); background: transparent; color: var(--ink); font-size: 22px; cursor: pointer; }.pinned .tip-close { display: inline-grid; place-items: center; }
.tip-open { display: none; padding: 11px 18px; margin-top: 8px; justify-self: start; border-radius: 8px; color: var(--on-accent); background: var(--accent); text-decoration: none; font: 650 14px var(--sans); }.pinned .tip-open { display: block; }.tip-open:hover { color: var(--on-accent); }
@keyframes card-open { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.tree-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 0; }.tree-foot .tree-signin { padding: 0; border: 0; background: none; margin: 0; font-size: 13px; }
.tree-drafts { margin: 0 0 12px; color: var(--muted); font-size: 13px; }.tree-drafts[hidden] { display: none; }
.flip-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; min-height: 38px; border: 1px solid var(--rule); border-radius: var(--r-pill); color: var(--ink-2); background: transparent; cursor: pointer; font: 550 13px var(--sans); }
.flip-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }.flip-toggle[aria-pressed="true"] { color: var(--ink); background: var(--paper-2); border-color: var(--ink-2); }.flip-toggle[hidden] { display: none; }
/* Root-to-leaf wake-up. The static routes stay visible throughout the entrance. */
.grow .route-wire { animation: wire-grow .65s ease-out both; animation-delay: calc(var(--d) * .7s); }
.grow .tree-node { animation: node-awake .4s ease-out both; animation-delay: calc(var(--d) * .7s + .2s); }
@keyframes wire-grow { from { stroke-dasharray: 100; stroke-dashoffset: 100; } to { stroke-dasharray: 100; stroke-dashoffset: 0; } }
@keyframes node-awake { from { opacity: .15; scale: .55; } to { opacity: 1; scale: 1; } }
/* The winding path keeps the owner's horizontal layout. */
.snake { --tc: var(--accent); }.snake .tree-lines .trunk { stroke: color-mix(in srgb, var(--ink) 22%, var(--paper)); stroke-width: 4; }
.snake .tree-lines .branch { stroke: var(--tc); stroke-width: 1.8; }.snake .node-name { display: none; }.snake .node-caption { width: 70px; top: 54px; }
.path-tier, .path-you, .path-end { position: absolute; z-index: 2; translate: -50% -50%; white-space: nowrap; pointer-events: none; }
.path-tier span, .path-you span, .path-end span { display: inline-block; padding: 5px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); color: var(--ink-2); font: 550 12px var(--sans); }
.path-you span { background: var(--accent); color: var(--on-accent); }.path-end.start { translate: 0 -50%; }.path-end span { color: var(--ink); }
.snake.grow .tree-lines path { animation: wire-grow .8s ease-out both; stroke-dasharray: 1; }.snake.grow .tree-node { animation-delay: .35s; }
.compact .tree-node { width: 44px; height: 44px; margin: -22px 0 0 -22px; }.compact .node-face { inset: 6px; border-radius: 7px; }.compact .node-face svg { width: 19px; height: 19px; }
.compact .node-caption { width: 46px; top: 46px; }.compact .node-name { display: none; }.compact .rating-tick span { left: 8px; font-size: 10px; }.compact .tier-band > span { right: 10px; font-size: 10px; }
.compact .skill-root { width: 36px; height: 36px; }.compact .skill-root svg { width: 36px; height: 36px; }.compact .skill-root span { top: 43px; font-size: 12px; width: 160px; }
@media (max-width: 700px) {
  .tree-tracks { gap: 6px; grid-template-columns: repeat(2, 1fr); margin-top: 18px; }.tree-track { padding: 10px 12px; gap: 10px; }.tree-track > svg { flex-basis: 23px; width: 23px; height: 23px; }.tree-track strong { font-size: 14px; }.tree-track small { font-size: 11px; }
  .tree-heading { align-items: flex-start; gap: 10px; }.tree-heading .tree-bar { display: none; }.tree-heading .tree-progress { font-size: 11px; padding-top: 5px; }.tree-heading .tree-progress strong { font-size: 16px; }.tree-heading p { font-size: 12px; max-width: 30ch; }
  .tree-actions { flex-wrap: wrap; }.tree-actions > span { flex-basis: 100%; margin-bottom: 3px; }.tree-legend { gap: 8px 14px; font-size: 12px; }.tree-canvas { border-radius: 14px; }.sort-by { margin-left: 0; }
  .tree-tip.pinned { border-radius: 18px; }.tip-close { width: 36px; height: 36px; }.tip-open { width: 100%; text-align: center; }
}
.motion-off *, .tree-tip.motion-off { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .tree-stage *, .tree-tip, .tree-track { animation: none !important; transition: none !important; } }
