/* The skill tree page. Tokens come from site.css. */

/* The columns need more room than the other tools' single column. */
.skills-page .wrap { max-width: 78rem; }

.skills-app { display: flex; flex-direction: column; gap: 1rem; }

/* --- buttons, as on the other pages -------------------------------------- */

.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.actions button,
.to-domains {
  padding: .6rem 1rem;
  font-family: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.actions button:hover,
.to-domains:hover { border-color: var(--accent); }

.actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .actions button.primary { color: #10201b; }
}

/* --- someone else's tree ------------------------------------------------- */

.shared {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .9rem 1.1rem;
  background: var(--focus-soft);
  border: 1px solid var(--focus);
  border-radius: var(--radius);
}

.shared[hidden] { display: none; }
.shared p { margin: 0; }

/* --- totals, share, search ----------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}

.total { margin: 0; font-size: 1.15rem; font-weight: 600; }

.share-link,
.finder input {
  width: 100%;
  padding: .7rem .9rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.share-link[hidden] { display: none; }

.share-link:focus,
.finder input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.finder { position: relative; }

.results {
  position: absolute;
  z-index: 2;
  top: calc(100% + .3rem);
  left: 0;
  right: 0;
  max-height: 22rem;
  overflow-y: auto;
  margin: 0;
  padding: .3rem;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / .12);
}

.results[hidden] { display: none; }

.results button {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .2rem 1rem;
  width: 100%;
  padding: .55rem .7rem;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}

.results button:hover,
.results button:focus-visible { background: var(--accent-soft); outline: none; }
.results button.is-have::before { content: "✓ "; color: var(--accent); font-weight: 700; }

.results-where { color: var(--ink-faint); font-size: .9rem; }
.results-none { padding: .55rem .7rem; color: var(--ink-faint); }

/* Messages float at the bottom of the screen, because the skill that was
   clicked may be far below the top of the page — on a phone, always. */
.message {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 34rem);
  margin: 0;
  padding: .7rem 1.1rem;
  color: var(--paper);
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / .2);
  font-size: .95rem;
  transition: opacity .2s;
}

/* Hidden by opacity, not display, so screen readers still hear it change. */
.message:empty { opacity: 0; padding: 0; pointer-events: none; }

/* --- the areas of life --------------------------------------------------- */

.domains {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  gap: .8rem;
}

.domain {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon name"
    "icon count"
    "bar  bar";
  align-items: center;
  gap: .15rem .8rem;
  width: 100%;
  height: 100%;
  padding: 1rem 1.1rem;
  font: inherit;
  text-align: left;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.domain:hover,
.domain:focus-visible { border-color: var(--accent); outline: none; }
.domain:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }

.domain-icon { grid-area: icon; font-size: 1.9rem; line-height: 1; }
.domain-name { grid-area: name; font-weight: 600; font-size: 1.05rem; }
.domain-progress { grid-area: count; color: var(--ink-soft); font-size: .9rem; }

.bar {
  grid-area: bar;
  height: .4rem;
  margin-top: .6rem;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* --- one area: its branches as columns ----------------------------------- */

#domain-view[hidden],
#domains-view[hidden] { display: none; }

.domain-head {
  /* Stays in view, so "All areas" is one tap away in a long tree. */
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem 1rem;
  margin-bottom: .6rem;
  padding: .6rem 0;
  background: var(--paper);
}

.domain-head h2 { margin: 0; font-size: 1.5rem; }
.domain-count { margin: 0; color: var(--ink-soft); }

/* Columns flow onto a new line rather than scrolling sideways, so no branch
   is ever hidden off the edge. */
.branches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  align-items: start;
  gap: .8rem;
}

.branch {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.branch h3 {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin: 0;
  padding: .75rem .9rem;
  font-size: 1rem;
  border-bottom: 1px solid var(--line);
}

.branch-count { color: var(--ink-faint); font-weight: 400; font-size: .9rem; white-space: nowrap; }

.branch-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  padding: 1rem .7rem 1.2rem;
}

.lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.lines path { fill: none; stroke: var(--line); stroke-width: 2; }
.lines path.is-lit { stroke: var(--accent); stroke-width: 3; }

.row {
  position: relative; /* above the lines */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
}

/* --- a skill ------------------------------------------------------------- */

.node {
  flex: 1 1 6.5rem;
  max-width: 12rem;
  padding: .55rem .7rem;
  font: inherit;
  font-size: .9rem;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: break-word;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .15s;
}

.node.is-open { border-color: var(--accent); border-style: dashed; }
.node.is-open:hover { background: var(--accent-soft); border-style: solid; }

.node.is-have {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.node.is-have::before { content: "✓ "; }

@media (prefers-color-scheme: dark) {
  .node.is-have { color: #10201b; }
}

.node.is-locked {
  color: var(--ink-faint);
  background: var(--paper);
  border-style: dotted;
  cursor: help;
}

.node.is-locked::before { content: "🔒 "; font-size: .8em; }

.node:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.node.is-found { animation: found 1.6s ease-out; }

@keyframes found {
  0%, 40% { transform: scale(1.08); box-shadow: 0 0 0 6px var(--focus-soft); }
  100% { transform: none; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .node { transition: none; }
  .node.is-found { animation: none; outline: 3px solid var(--focus); }
}

/* --- legend and help ----------------------------------------------------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.4rem;
  margin: .8rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-soft);
  font-size: .9rem;
}

.legend li { display: flex; align-items: center; gap: .4rem; }
.legend .node { display: inline-block; flex: none; width: 1.6rem; height: 1.1rem; padding: 0; cursor: default; }
.legend .node::before { content: none; }

.help { color: var(--ink-soft); font-size: .95rem; }
.help summary { cursor: pointer; color: var(--ink); }
.help ol { padding-left: 1.3rem; }

/* --- phones -------------------------------------------------------------- */

@media (max-width: 34rem) {
  /* Two small cards per row, so all 13 areas fit in about one screen. */
  .domains { grid-template-columns: repeat(2, 1fr); gap: .6rem; }

  .domain {
    grid-template-columns: 1fr;
    grid-template-areas: "icon" "name" "count" "bar";
    gap: .1rem;
    padding: .8rem .85rem;
  }

  .domain-icon { font-size: 1.6rem; margin-bottom: .3rem; }
  .domain-name { font-size: 1rem; line-height: 1.3; }
  .bar { margin-top: .5rem; }

  .toolbar .actions { width: 100%; }
  .toolbar .actions button { flex: 1; }

  .domain-head h2 { font-size: 1.25rem; }
  .to-domains { padding: .45rem .8rem; }

  .branch-body { padding: .9rem .6rem 1rem; }
}

/* --- choosing a view ------------------------------------------------------ */

.view-switch {
  display: flex;
  align-self: flex-start;
  padding: .25rem;
  gap: .25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.view-switch button {
  padding: .45rem 1.1rem;
  font: inherit;
  font-size: .95rem;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.view-switch button[aria-pressed="true"] { color: var(--paper); background: var(--accent); font-weight: 600; }

@media (prefers-color-scheme: dark) {
  .view-switch button[aria-pressed="true"] { color: #10201b; }
}

/* --- the game map ----------------------------------------------------------
   Always dark, whatever the site's theme, so it looks like a game screen. */

.map-view[hidden] { display: none; }

.map {
  --map-bg: #0d111c;
  --map-ink: #e8ecf6;
  --map-soft: #8d97b0;
  --map-line: #2c3550;
  --map-gold: #f2c14e;
  --map-weak: #7f8cff;

  position: relative;
  height: min(78vh, 52rem);
  min-height: 26rem;
  overflow: hidden;
  color: var(--map-ink);
  background:
    radial-gradient(circle at 50% 50%, #1c2440 0%, transparent 70%),
    var(--map-bg);
  border: 1px solid #000;
  border-radius: var(--radius);
  touch-action: none; /* the map handles drag and pinch itself */
  user-select: none;
  -webkit-user-select: none;
}

.map:fullscreen { height: 100%; border-radius: 0; }

.map-svg { display: block; width: 100%; height: 100%; cursor: grab; }
.map-svg:active { cursor: grabbing; }

.map-guides circle { fill: none; stroke: #ffffff08; stroke-width: 2; }

.map-strong line { stroke: var(--map-line); stroke-width: 4; }
.map-strong line.is-lit { stroke: var(--map-gold); stroke-width: 6; }
.map-strong line.map-spoke { stroke: #ffffff14; stroke-width: 10; }

.map-weak path {
  fill: none;
  stroke: var(--map-weak);
  stroke-width: 3;
  stroke-dasharray: 10 12;
  opacity: .22;
}

.map-weak path.is-lit { opacity: .7; stroke: #b9c2ff; }
.map-strong line.is-picked { stroke: #fff; }
.map-weak path.is-picked { opacity: 1; stroke: #fff; stroke-width: 4; }

/* An area's hub, and "You" in the middle. */
.map-hub { cursor: pointer; }
.map-hub circle {
  fill: hsl(var(--hue) 45% 16%);
  stroke: hsl(var(--hue) 70% 60%);
  stroke-width: 8;
}
.map-hub:hover circle,
.map-hub:focus-visible circle { stroke: #fff; outline: none; }
.map-hub:focus { outline: none; }
.map-hub text { text-anchor: middle; fill: var(--map-ink); }
.map-hub-icon { font-size: 150px; }
.map-hub-name { font-size: 110px; font-weight: 700; paint-order: stroke; stroke: var(--map-bg); stroke-width: 18px; }
.map-hub-count { font-size: 80px; fill: var(--map-soft) !important; paint-order: stroke; stroke: var(--map-bg); stroke-width: 14px; }

.map-centre circle { fill: #151b2e; stroke: var(--map-gold); stroke-width: 10; }
.map-centre text { text-anchor: middle; fill: var(--map-gold); font-size: 120px; font-weight: 700; }

/* A skill. */
.map-node { cursor: pointer; }
.map-node:focus { outline: none; }

.map-node-frame {
  fill: #161c2d;
  stroke: #3a4258;
  stroke-width: 3;
  transition: stroke .15s, fill .15s;
}

.map-node-glow { fill: var(--map-gold); opacity: 0; }
.map-node-icon { text-anchor: middle; font-size: 30px; }
.map-node-label {
  display: none; /* shown once the map is zoomed in far enough to read it */
  text-anchor: middle;
  font-size: 22px;
  fill: var(--map-soft);
  paint-order: stroke;
  stroke: var(--map-bg);
  stroke-width: 4px;
}

.map-svg.is-near .map-node-label { display: block; }

.map-node.is-locked .map-node-icon { opacity: .28; filter: grayscale(1); }
.map-node.is-locked .map-node-label { fill: #5b6479; }

.map-node.is-open .map-node-frame { stroke: hsl(var(--hue) 80% 66%); stroke-width: 4; }
.map-node.is-open .map-node-label { fill: var(--map-ink); }

.map-node.is-have .map-node-frame { fill: #3a2e0e; stroke: var(--map-gold); stroke-width: 5; }
.map-node.is-have .map-node-glow { opacity: .22; }
.map-node.is-have .map-node-label { fill: var(--map-gold); font-weight: 600; }

.map-node:hover .map-node-frame,
.map-node:focus-visible .map-node-frame { stroke: #fff; }

.map-node.is-selected .map-node-frame { stroke: #fff; stroke-width: 6; }
.map-node.is-selected .map-node-label { display: block; fill: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .map-node.is-open .map-node-frame { animation: map-pulse 2.4s ease-in-out infinite; }
}

@keyframes map-pulse {
  50% { stroke-opacity: .45; }
}

/* Zoom buttons. */
.map-controls {
  position: absolute;
  z-index: 2;
  top: .6rem;
  right: .6rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .35rem;
}

.map-controls button {
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 .75rem;
  font: inherit;
  font-size: .9rem;
  color: var(--map-ink);
  background: #1a2133e6;
  border: 1px solid #3a4258;
  border-radius: 8px;
  cursor: pointer;
}

.map-controls button:hover { border-color: var(--map-gold); }
.map-controls button[hidden] { display: none; }

/* The details of the skill that was tapped. */
.map-panel {
  position: absolute;
  z-index: 2;
  left: .6rem;
  bottom: .6rem;
  width: min(22rem, calc(100% - 1.2rem));
  max-height: calc(100% - 4.2rem);
  overflow-y: auto;
  padding: .9rem 1rem;
  color: var(--map-ink);
  background: #141a2bf2;
  border: 1px solid #3a4258;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px #0008;
}

.map-panel[hidden] { display: none; }
.map-panel h3 { margin: 0 1.6rem .2rem 0; font-size: 1.1rem; line-height: 1.3; }
.map-panel p { margin: 0 0 .4rem; font-size: .9rem; }
.map-panel-where { color: var(--map-soft); }
.map-panel-state[data-state="have"] { color: var(--map-gold); font-weight: 600; }
.map-panel-state[data-state="open"] { color: #9fe0c4; }
.map-panel-state[data-state="locked"] { color: var(--map-soft); }
.map-panel-needs[hidden],
.map-panel-related[hidden] { display: none; }

.map-panel-related ul { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .6rem; padding: 0; list-style: none; }

.map-panel-related button {
  padding: .25rem .6rem;
  font: inherit;
  font-size: .85rem;
  color: var(--map-ink);
  background: transparent;
  border: 1px dashed var(--map-weak);
  border-radius: 999px;
  cursor: pointer;
}

.map-panel-related button.is-have { color: var(--map-gold); border-color: var(--map-gold); }

.map-panel .actions button.primary { color: #1b1404; background: var(--map-gold); border-color: var(--map-gold); }
.map-panel .actions button:disabled { opacity: .45; cursor: default; }
.map-panel .actions button[hidden] { display: none; }

.map-panel-close {
  position: absolute;
  top: .35rem;
  right: .4rem;
  width: 2rem;
  height: 2rem;
  font: inherit;
  font-size: 1.2rem;
  color: var(--map-soft);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.map-panel-close:hover { color: #fff; background: #ffffff14; }

.map-hint { margin: .6rem 0 0; color: var(--ink-soft); font-size: .9rem; }

@media (max-width: 34rem) {
  .map { height: 72vh; min-height: 22rem; }
  .map-controls button { height: 2.2rem; min-width: 2.2rem; padding: 0 .55rem; font-size: .85rem; }
  .view-switch { align-self: stretch; }
  .view-switch button { flex: 1; }
}

/* --- compact map: names hidden, pictures carry the meaning --------------- */

.map-svg.is-compact .map-node:not(.is-selected) .map-node-label { display: none; }
.map-svg.is-compact .map-node-icon { font-size: 34px; }

.map-controls button[aria-pressed="true"] { color: #1b1404; background: var(--map-gold); border-color: var(--map-gold); }

/* The name shown while the mouse is over a skill. */
.map-tip {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, calc(-100% - 8px));
  max-width: 16rem;
  padding: .3rem .6rem;
  color: var(--map-ink);
  background: #000c;
  border: 1px solid #3a4258;
  border-radius: 6px;
  font-size: .85rem;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}

.map-tip[hidden] { display: none; }
