/*
 * The story inspector -- the one page here that is not read on a phone.
 *
 * It inherits the game's palette from style.css so the two feel like one
 * site, and then departs from every other decision in it. The game is a
 * column of prose at thumb reach in the dark; this is a wall of structure at
 * a desk. Density is the point: the whole value is seeing a flag's setters
 * and its readers without scrolling between them.
 */

body.inspect {
  position: static;
  overflow: auto;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  padding-bottom: 3rem;
}

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

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.6rem calc(1rem + var(--safe-r)) 0.6rem calc(1rem + var(--safe-l));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.top__home {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.top__home:hover { color: var(--ink); border-color: var(--line-strong); }

.top__brand { font-family: var(--font-display); letter-spacing: 0.02em; }
.top__stories { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.top__spacer { flex: 1 1 auto; }
.top__meta { color: var(--ink-faint); font-size: 0.82rem; }

.chip--story {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}
.chip--story:hover { border-color: var(--line-strong); color: var(--ink); }
.chip--story.is-active {
  border-color: var(--amber);
  background: rgba(240, 168, 60, 0.14);
  color: var(--ink);
}

/* ----------------------------------------------------------------- gate -- */

.gate {
  max-width: 34rem;
  margin: 5rem auto;
  padding: 0 1.5rem;
  text-align: center;
}
.gate h1 { font-family: var(--font-display); font-weight: 500; }
.gate p { color: var(--ink-dim); }

/* ----------------------------------------------------------------- tabs -- */

.tabs {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  padding: 0.9rem calc(1rem + var(--safe-l));
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink-faint);
  padding: 0.35rem 0.7rem;
  font: inherit;
  cursor: pointer;
}
.tab:hover { color: var(--ink-dim); }
.tab.is-active {
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel-solid);
}

.panel { display: none; padding: 0 calc(1rem + var(--safe-r)) 0 calc(1rem + var(--safe-l)); }
.panel.is-active { display: block; }

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

.graph {
  display: grid;
  /* The details pane grows with the desktop instead of holding at 21rem: on
     a wide monitor the map cannot use every remaining pixel -- past a point
     it only shows more of the journey at the same size -- while the pane is
     where the prose facts, the artwork and the edge lists are read. */
  grid-template-columns: minmax(0, 1fr) clamp(21rem, 26vw, 34rem);
  gap: 1rem;
  align-items: stretch;
}

.graph__canvas {
  position: relative;
  overflow: hidden;
  height: min(72vh, 780px); /* until the first fit, which sizes it to the drawing */
  background:
    radial-gradient(circle at 30% 20%, rgba(79, 209, 197, 0.05), transparent 60%),
    var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: grab;
  touch-action: none;
}
.graph__canvas.is-dragging { cursor: grabbing; }
.graph__canvas svg { width: 100%; height: 100%; display: block; }

.btn--small {
  width: auto;
  min-height: 0;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
}

.graph__side {
  overflow-y: auto;
  min-height: 0;
  padding: 0.9rem 1rem;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.graph__bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.6rem 0.1rem;
  font-size: 0.84rem;
}

.legend { display: flex; gap: 0.5rem; align-items: center; color: var(--ink-faint); }
.key {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  display: inline-block;
  margin-left: 0.6rem;
  border: 1.5px solid currentColor;
}
.key--start  { color: var(--cyan); }
.key--combat { color: var(--red); }
.key--good   { color: var(--green); }
.key--bad    { color: var(--red); background: currentColor; }

/* Nodes and edges are drawn by js; everything about how they read is here. */
.node rect {
  fill: #131926;
  stroke: var(--line-strong);
  stroke-width: 1.2;
  rx: 7;
}
.node text { fill: var(--ink-dim); font-size: 11px; pointer-events: none; }
.node:hover rect { stroke: var(--ink-dim); }
.node.is-selected rect { stroke: var(--amber); stroke-width: 2.2; }
.node.is-start   rect { stroke: var(--cyan); }
.node.is-combat  rect { stroke: var(--red); }
.node.is-ending  rect { fill: #1a1420; }
.node.is-good    rect { stroke: var(--green); }
.node.is-bad     rect { stroke: var(--red); }
.node.is-neutral rect { stroke: var(--amber-dim); }
.node.is-dimmed  { opacity: 0.25; }
.node { cursor: pointer; }

.edge { fill: none; stroke: rgba(148, 168, 200, 0.3); stroke-width: 1.2; }
.edge.is-goto     { stroke: var(--amber-dim); stroke-dasharray: 5 4; }
.edge.is-enter    { stroke: var(--cyan); stroke-dasharray: 2 4; opacity: 0.55; }
.edge.is-win      { stroke: rgba(99, 209, 138, 0.5); }
.edge.is-lose     { stroke: rgba(226, 86, 74, 0.45); }
.edge.is-flee     { stroke: rgba(240, 168, 60, 0.4); stroke-dasharray: 6 3; }
.edge.is-locked   { opacity: 0.5; }
.edge.is-highlit  { stroke: var(--amber); stroke-width: 2.2; opacity: 1; }
.edge.is-dimmed   { opacity: 0.07; }

/* ---------------------------------------------------------------- cards -- */

/* Not `.detail`: the game's stylesheet is loaded first for the palette, and
   it lays a class of that name out as a flex row for the stats drawer, which
   turned this card sideways. */
.scene-card h2 { font-size: 1.05rem; margin: 0 0 0.15rem; font-family: var(--font-display); }
.scene-card .sub { color: var(--ink-faint); font-size: 0.8rem; margin: 0 0 0.8rem; }
.scene-card h3 {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
  margin: 1rem 0 0.35rem;
}
.scene-card ul { list-style: none; margin: 0; padding: 0; }
.scene-card li { padding: 0.28rem 0; border-bottom: 1px solid var(--line); font-size: 0.87rem; }
.scene-card li:last-child { border-bottom: 0; }

.cards { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); }

.card2 {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
}
.card2--good     { border-left-color: var(--green); }
.card2--bad      { border-left-color: var(--red); }
.card2--neutral  { border-left-color: var(--amber); }
.card2 h3 { margin: 0 0 0.1rem; font-size: 1rem; font-family: var(--font-display); }
.card2 .sub { color: var(--ink-faint); font-size: 0.78rem; margin: 0 0 0.5rem; }

.steps { margin: 0.4rem 0 0; padding-left: 1.1rem; color: var(--ink-dim); font-size: 0.84rem; }
.steps li { padding: 0.1rem 0; }

details > summary { cursor: pointer; color: var(--ink-dim); font-size: 0.85rem; }

/* --------------------------------------------------------------- tables -- */

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
table.grid th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line-strong);
  position: sticky;
  top: 3.1rem;
  background: var(--bg);
}
table.grid td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.grid tr:hover td { background: rgba(148, 168, 200, 0.05); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }

.where { display: block; color: var(--ink-faint); font-size: 0.78rem; }
.where b { color: var(--ink-dim); font-weight: 500; }

.pill {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid var(--line-strong);
  color: var(--ink-dim);
}
.pill--ok   { border-color: var(--green); color: var(--green); }
.pill--bad  { border-color: var(--red);   color: var(--red); }
.pill--warn { border-color: var(--amber); color: var(--amber); }

.muted { color: var(--ink-faint); }
.warnbar {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--amber-dim);
  border-radius: var(--radius-sm);
  background: rgba(240, 168, 60, 0.08);
  font-size: 0.86rem;
}

.thumb {
  width: 108px;
  height: 81px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0a0d14;
  display: block;
}

/* In the scene card the artwork is the point, not a row marker: give it the
   pane's width rather than the table's postage stamp. */
.graph__side .thumb { width: 100%; height: auto; }

/* ------------------------------------------------------------- controls -- */

.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.controls label { color: var(--ink-faint); font-size: 0.82rem; }
.controls input[type="number"] {
  width: 5.5rem;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 0.35rem 0.5rem;
  font: inherit;
}
.controls__gear { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.controls__gear label {
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
}
.controls__gear input { margin-right: 0.3rem; }

.meter {
  display: block;
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(148, 168, 200, 0.14);
  overflow: hidden;
  min-width: 6rem;
}
.meter i { display: block; height: 100%; background: var(--green); }
.meter i.is-thin { background: var(--red); }
.meter i.is-mid  { background: var(--amber); }

/* --------------------------------------------------------------- narrow -- */

@media (max-width: 900px) {
  .graph { grid-template-columns: 1fr; }
  .graph__side { height: 20rem; }
  table.grid th { position: static; }
}
