/* ════════════════════════════════════════════════════════════
   Questline — Detroit: Become Human style chapter flowchart
   ────────────────────────────────────────────────────────────
   All color/shape tokens live in tokens.css (--dbh-* aliases included).
   ════════════════════════════════════════════════════════════ */

/* Faceted, slightly tilted background plates behind everything */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  /* Calmer two-layer wash: a faint corner glow each side, no hatching lines
     behind text (the old 115deg/25deg stripes added noise under copy). */
  background:
    radial-gradient(120% 90% at 88% -10%, var(--bg-wash-a) 0%, transparent 46%),
    radial-gradient(120% 90% at 8% 108%, var(--bg-wash-b) 0%, transparent 48%);
  /* Promote to its own GPU layer so the fixed plate is not repainted on scroll. */
  transform: translateZ(0);
  will-change: transform;
}

/* Console-screen texture: a faint film grain over very soft scanlines. This is
   the single cheapest "expensive" cue — it kills gradient banding on the dark
   field and reads as a powered CRT/HUD surface. Kept under z-index:0 (behind
   all content) and at low opacity so copy stays crisp; the SVG fractal-noise
   data URI needs no network request. */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .5;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.014) 0 1px, transparent 1px 3px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: auto, 160px 160px;
  mix-blend-mode: soft-light;
  transform: translateZ(0);
}
@media (prefers-reduced-motion: reduce) {
  /* Texture is static so it stays, but drop blend cost on low-power requests. */
  body::after { opacity: .32; }
}
main#main, .header-bar { position: relative; z-index: 1; }

/* Widescreen console: fill the canvas instead of a centered 960px column. */
#app { max-width: min(1400px, 92vw); width: 100%; margin: 0 auto; padding: var(--space-6); }

/* ── Flowchart ─────────────────────────────────────────────── */
.tree { position: relative; padding: var(--space-2) 0; }
.tree__wires {
  position: absolute; inset: 0; z-index: 0;
  overflow: visible; pointer-events: none;
}
.wire { fill: none; stroke-width: 1.5; transition: stroke .15s, filter .15s, opacity .15s; }
.wire--dim { stroke: var(--dbh-edge); }
.wire--lit { stroke: var(--dbh-cyan); filter: drop-shadow(0 0 4px var(--dbh-cyan-glow)); }
.wire.is-focus { stroke: var(--dbh-cyan); filter: drop-shadow(0 0 6px var(--dbh-cyan-glow)); stroke-width: 2.2; opacity: 1 !important; }
.wire-node.wire--dim { fill: var(--text-faint); }
.wire-node.wire--lit { fill: var(--dbh-cyan); filter: drop-shadow(0 0 4px var(--dbh-cyan-glow)); }

.tree[data-focus-branch] .wire:not(.is-focus) { opacity: .18; }
.tree[data-focus-branch] .tnode:not(.is-focus) { opacity: .35; }
.tree[data-focus-branch] .tnode.is-focus { opacity: 1; }

.tree__rows { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 52px; }
.tree__row {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--space-6); width: 100%;
}

/* Angular parallelogram chapter node */
.tnode {
  position: relative; display: block;
  width: 246px;
  text-decoration: none; color: var(--text-primary);
  transition: transform var(--dur) var(--ease-out-quint), filter var(--dur);
}
.tnode__inner {
  display: block; position: relative; overflow: hidden;
  --tnode-rim: var(--dbh-edge);
  background: var(--tnode-rim);
  clip-path: var(--plate-poly);
  transition: background var(--dur), box-shadow var(--dur);
}
.tnode__inner::before {
  content: ""; position: absolute; inset: 1px; z-index: 0;
  background: var(--surface-raise); box-shadow: var(--surface-raise-hi);
  clip-path: var(--plate-poly);
  pointer-events: none;
}
.tnode__frame, .tnode__bar { position: relative; z-index: 1; }
.tnode__frame {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 92px;
  background:
    radial-gradient(120% 140% at 80% 0%, var(--accent-soft), transparent 60%),
    var(--surface-1);
  border-bottom: 1px solid var(--dbh-edge);
  overflow: hidden;
}
.tnode__icon { color: var(--text-muted); transition: color var(--dur), filter var(--dur); }
.tnode__no {
  position: absolute; top: 8px; left: 12px;
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .18em;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.tnode__seal {
  position: absolute; top: 8px; right: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; color: var(--ink-on-success); background: var(--dbh-done);
  border-radius: 4px;
  box-shadow: 0 0 10px var(--success-glow);
}
.tnode__bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 11px 14px;
}
.tnode__title {
  font-size: var(--text-base); font-weight: 600;
  letter-spacing: .01em; color: var(--text-primary);
}
.tnode__count {
  font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--dbh-cyan); letter-spacing: .08em;
}
.tnode__lock {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); text-align: right;
}
.tnode__lock svg { flex-shrink: 0; opacity: .75; }

/* Node states. The faceted plate is clipped, so the hover lift glow rides the
   parent .tnode via drop-shadow (which follows the bevel silhouette). */
.tnode--available:hover,
.tnode--in-progress:hover,
.tnode--complete:hover {
  transform: translateY(-3px);
  filter: drop-shadow(0 14px 26px var(--scrim)) drop-shadow(0 0 14px var(--dbh-cyan-glow));
}
.tnode--available:hover .tnode__inner,
.tnode--in-progress:hover .tnode__inner,
.tnode--complete:hover .tnode__inner {
  --tnode-rim: var(--dbh-cyan);
}

/* State now reads from the bevel rim colour, not a side stripe. */
.tnode--available .tnode__inner,
.tnode--in-progress .tnode__inner { --tnode-rim: var(--dbh-cyan); }
.tnode--available .tnode__icon,
.tnode--in-progress .tnode__icon {
  color: var(--dbh-cyan); filter: drop-shadow(0 0 6px var(--dbh-cyan-glow));
}

.tnode--complete .tnode__inner { --tnode-rim: var(--dbh-done); }
.tnode--complete .tnode__icon { color: var(--dbh-done); filter: drop-shadow(0 0 6px var(--success-glow)); }
.tnode--complete .tnode__title { color: var(--text-secondary); }
.tnode--complete .tnode__count { color: var(--dbh-done); }

.tnode--locked { filter: grayscale(.6) brightness(.7); cursor: not-allowed; }
.tnode--locked .tnode__inner { --tnode-rim: var(--border); }
.tnode--locked .tnode__icon { opacity: .55; }

/* ── Chapter detail (inside the Chapters tab) ──────────────── */
.branch-progress { display: flex; align-items: center; gap: var(--space-3); }
.branch-progress__bar {
  flex: 1; height: 6px; background: var(--surface-2); overflow: hidden;
  border-radius: 3px;
}
.branch-progress__bar div {
  height: 100%; width: 100%;
  background: var(--qprog-fill);
  box-shadow: 0 0 10px var(--accent-glow);
  /* Fill is full-width and scaled from the left, so the bar animates via
     transform (compositor) rather than width (layout). */
  transform: scaleX(var(--pct, 0)); transform-origin: left center;
  transition: transform .4s var(--ease-out-quint);
}
.branch-progress__count {
  font-size: var(--text-xs); color: var(--accent);
  font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: .08em;
}

.skills { display: flex; flex-direction: column; gap: var(--space-3); }
.skill {
  position: relative;
  --skill-rim: var(--dbh-edge);
  --skill-fill: var(--dbh-panel);
  display: flex; gap: var(--space-4); padding: var(--space-4);
  background: var(--skill-rim);
  border-radius: var(--radius-sm);
  transition: background var(--dur);
}
.skill::before {
  content: ""; position: absolute; inset: 1px; z-index: 0;
  background: var(--skill-fill); border-radius: calc(var(--radius-sm) - 1px);
  pointer-events: none; transition: background var(--dur);
}
.skill > * { position: relative; z-index: 1; }
.skill:hover { --skill-rim: var(--dbh-cyan); }
.skill--done {
  --skill-rim: var(--dbh-done);
  --skill-fill: linear-gradient(160deg, rgba(52,211,153,.08), var(--dbh-panel));
}
/* Closed-bevel ring: bg is the rim, an inset ::before re-fills the interior,
   so the faceted corners are fully stroked (a border + clip leaves the
   diagonal torn). The interior fill matches the card behind it when empty. */
.skill__check {
  flex-shrink: 0; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: transparent; position: relative;
  background: var(--border-strong);
  border-radius: 6px;
  transition: background var(--dur),
    color var(--dur), box-shadow var(--dur), transform var(--dur-fast) var(--ease-out-quint);
}
.skill__check::before {
  content: ""; position: absolute; inset: 1.5px; z-index: 0;
  background: var(--dbh-panel); border-radius: 5px;
  transition: background var(--dur);
}
.skill__check > svg { position: relative; z-index: 1; }
/* Pad the hit area out to the 44px touch minimum without growing the glyph. */
.skill__check::after { content: ""; position: absolute; inset: -5px; z-index: 2; }
.skill__check:hover { background: var(--dbh-cyan); }
.skill__check:active { transform: scale(.9); }
.skill--done .skill__check {
  background: var(--dbh-done); color: var(--ink-on-success);
  box-shadow: 0 0 12px var(--success-glow);
}
.skill--done .skill__check::before { background: var(--dbh-done); }
.skill__main { flex: 1; min-width: 0; }
.skill__head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.skill__title { font-weight: 600; font-size: var(--text-lg); letter-spacing: .01em; }
.skill__tag {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .14em;
  color: var(--dbh-cyan); padding: 3px 10px; background: var(--dbh-cyan-soft);
  border-radius: 999px;
}
.skill__body { margin-top: 6px; color: var(--text-secondary); font-size: var(--text-base); line-height: 1.6; }
.skill__list { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.skill__list li {
  font-size: var(--text-sm); color: var(--text-secondary); padding: 4px 12px;
  background: var(--surface-1); border: 1px solid var(--dbh-edge);
  border-radius: 999px;
}

.branch-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Orientation line above the map — how to move on keyboard and touch. */
.tree__howto {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  #app { padding: var(--space-4); }
  .tnode { width: 100%; max-width: 320px; }
  .tree__rows { gap: 40px; }
  .tree__row { gap: var(--space-4); }
  .tree__wires { display: none; }      /* stacked layout, wires would be noise */
}

