/* Home: one full-viewport pond (graph or koi), with the name, links, and controls overlaid. */
:root {
  --bg: #fbfaf7;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --rule: #e3e1db;
  --accent: #b4441f;
  --pond: #f3efe6;
  --panel: rgba(251, 250, 247, 0.86);
  --koi-me: #c08000;
  --bubble: #8a877f;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --gap: 1.25rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --text: #ecebe7;
    --muted: #a09e98;
    --rule: #2f2e2b;
    --accent: #e8805c;
    --pond: #1c1c1c;
    --panel: rgba(28, 28, 28, 0.82);
    --koi-me: #bf8f30;
    --bubble: #9a9a9a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* overlays set display (flex etc.), which would beat the hidden attribute */
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; background: var(--pond); color: var(--text); font: 16px/1.6 var(--serif); }
a { color: var(--accent); }
p { margin: 0 0 1rem; }

.pond { position: fixed; inset: 0; overflow: hidden; background: var(--pond); }
.pond canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; touch-action: none; }
.js .pond canvas { display: block; }

/* Overlays. The container ignores the pointer so the canvas stays draggable around them. */
.ident, .hint, .panel, .controls, .legend, .columns { position: absolute; z-index: 1; }
.ident {
  top: var(--gap); left: var(--gap);
  display: flex; align-items: center; gap: 0.9rem;
  max-width: calc(100% - 13rem);
  pointer-events: none;
}
.ident a, .ident button { pointer-events: auto; }
.me { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: left; border-radius: 4px; }
.me:hover { color: var(--accent); }
.me .portrait { display: block; }
.me:hover .portrait { box-shadow: 0 0 0 2px var(--accent); }
.me:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.bio-brief { margin: 0.15rem 0 0.75rem; }
.portrait { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; background: var(--rule); }
h1 { font: normal 1.9rem/1.1 var(--serif); margin: 0; text-shadow: 0 0 12px var(--pond), 0 0 3px var(--pond); }
.orgs { font: 0.85rem/1.4 var(--sans); color: var(--muted); margin: 0.35rem 0 0; text-shadow: 0 0 8px var(--pond); }
.orgs a { text-decoration: none; }
.orgs a:hover { text-decoration: underline; }

.hint { top: var(--gap); right: var(--gap); margin: 0; font: 0.75rem var(--sans); color: var(--muted); pointer-events: none; }

.panel {
  top: calc(var(--gap) + 5.5rem); left: var(--gap);
  width: min(24rem, 38%);
  max-height: calc(100% - var(--gap) * 2 - 9rem);
  overflow-y: auto;
  padding: 1rem 1.25rem 0.25rem;
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  border-radius: 10px;
  line-height: 1.55;
}
.node-type { font: 0.75rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0.25rem 0 0.4rem; display: flex; align-items: center; gap: 0.45rem; }
.node-name { font: normal 1.4rem/1.25 var(--serif); color: var(--text); margin: 0 0 0.6rem; }
.node-rel { font: 0.85rem/1.45 var(--sans); color: var(--muted); margin: 0 0 0.5rem; }
.node-summary { margin-top: 0.9rem; }
.node-link { font: 0.9rem var(--sans); text-decoration: none; }
.node-link:hover { text-decoration: underline; }
.toggle { font: 0.85rem var(--sans); background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.toggle:hover { text-decoration: underline; }
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; flex: none; }
.count { font-size: 0.75rem; color: var(--muted); }

.mode, .spin, .legend button {
  font: 0.75rem var(--sans);
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
}
/* The mode and auto-rotate pills share one row (mode first) at the same height. */
.controls { left: var(--gap); bottom: var(--gap); display: flex; align-items: center; gap: 0.5rem; }
.mode, .spin { display: inline-flex; align-items: center; gap: 0.4rem; height: 2rem; padding: 0 0.9rem; font-size: 0.8rem; line-height: 1; }
.spin { padding-left: 0.7rem; }
.spin::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--muted); }
.spin[aria-pressed="true"] { border-color: var(--accent); }
.spin[aria-pressed="true"]::before { background: var(--accent); box-shadow: none; }
.mode:hover, .spin:hover, .legend button:hover { border-color: var(--accent); }
/* The docked mode switch: one pill split into Koi pond · Graph · List. */
.modes { display: inline-flex; height: 2rem; padding: 2px; background: var(--panel); border: 1px solid var(--rule); border-radius: 999px; }
.modes button {
  font: 0.8rem var(--sans); line-height: 1; color: var(--muted);
  background: none; border: 0; border-radius: 999px; padding: 0 0.8rem; cursor: pointer;
}
.modes button:hover { color: var(--text); }
.modes button[aria-pressed="true"] { color: var(--text); background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent); }
.modes button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.legend {
  right: var(--gap); bottom: var(--gap);
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.35rem;
  max-width: min(34rem, calc(50% - 8rem));   /* leaves the bottom center free for the source note */
}
.legend button { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.6rem; }
.legend-all { display: inline-flex; gap: 0.25rem; margin-right: 0.35rem; }
.legend-all button { color: var(--muted); padding: 0.25rem 0.55rem; }
.legend button[aria-pressed="false"] { opacity: 0.4; }
.legend button[aria-pressed="false"] .dot { background: transparent !important; box-shadow: inset 0 0 0 1px var(--muted); }
.mode:focus-visible, .spin:focus-visible, .legend button:focus-visible, .toggle:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.source {
  position: absolute; z-index: 1;
  left: 50%; bottom: var(--gap); translate: -50% 0;
  font: 0.72rem var(--sans);
  color: var(--muted);
  background: none; border: 0; padding: 0.25rem 0.5rem;
  opacity: 0.7;
  cursor: pointer;
}
.source:hover { opacity: 1; text-decoration: underline; }
.source:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; opacity: 1; }

.search { position: absolute; z-index: 1; top: var(--gap); right: var(--gap); display: flex; align-items: center; gap: 0.5rem; flex-direction: row-reverse; }
.search input {
  width: 15rem; height: 2rem; padding: 0 0.9rem;
  font: 0.85rem var(--sans); color: var(--text);
  background: var(--panel); border: 1px solid var(--rule); border-radius: 999px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.search input::placeholder { color: var(--muted); }
#search-count { font: 0.75rem var(--sans); color: var(--muted); white-space: nowrap; }
.pond.is-graph .hint, .pond.is-list .hint { top: calc(var(--gap) + 2.6rem); }

/* List mode: Miller columns (like Finder's column view) over the pond. The first column is Ira;
   each selection opens that entity in a new column to the right, with its own connections. */
.columns {
  top: calc(var(--gap) + 5.5rem); bottom: calc(var(--gap) + 5.25rem); left: var(--gap); right: var(--gap);
  display: flex; align-items: stretch; gap: 0.5rem;
  overflow-x: auto; overscroll-behavior: contain;
}
.col {
  flex: none; width: 19rem; max-width: 100%;
  display: flex; flex-direction: column;
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule); border-radius: 10px;
  overflow-y: auto; overscroll-behavior: contain;
  font: 0.85rem/1.4 var(--sans);
}
/* Scrollbars: none in the columns (the wheel or trackpad scrolls them); the row of columns
   gets a thin rounded thumb with no track, faint until hovered. */
.col { scrollbar-width: none; }
.col::-webkit-scrollbar { display: none; }
.columns { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 30%, transparent) transparent; }
.columns:hover { scrollbar-color: color-mix(in srgb, var(--muted) 60%, transparent) transparent; }
.columns::-webkit-scrollbar { height: 8px; background: transparent; }
.columns::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 30%, transparent); border-radius: 4px; }
.columns:hover::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 60%, transparent); }
.col-head { padding: 0.85rem 1rem 0.5rem; }
.col-head .node-name { font-size: 1.15rem; margin-bottom: 0.4rem; }
.col-head .node-summary { margin: 0.5rem 0 0.6rem; font: 0.88rem/1.5 var(--serif); }
.col-head .bio-brief { font: 0.92rem/1.5 var(--serif); margin: 0 0 0.4rem; }
.col-head p:last-child { margin-bottom: 0.25rem; }
.col-back { display: none; font: 0.8rem var(--sans); color: var(--accent); background: none; border: 0; padding: 0; margin: 0 0 0.5rem; cursor: pointer; }
.col-note { font-size: 0.75rem; color: var(--muted); margin: 0 1rem 0.5rem; }
.col details { border-top: 1px solid var(--rule); }
.col summary {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 1rem; cursor: pointer; list-style: none;
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.col summary::-webkit-details-marker { display: none; }
.col summary::after { content: "▸"; margin-left: auto; font-size: 0.7rem; transition: rotate 0.15s; }
.col details[open] > summary::after { rotate: 90deg; }
.col summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.col ul { list-style: none; margin: 0; padding: 0 0 0.4rem; }
.row {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 0.5rem;
  width: 100%; padding: 0.35rem 1rem; text-align: left;
  font: inherit; color: var(--text); background: none; border: 0; cursor: pointer;
}
.row:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-rel { grid-column: 1; font-size: 0.75rem; color: var(--muted); }
.row::after { content: "›"; grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); }
.row[aria-current="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.row[aria-current="true"]::after { color: var(--accent); }
.row.in-path .row-name::after { content: " ↺"; color: var(--muted); }
.col-empty { padding: 0.5rem 1rem 0.8rem; color: var(--muted); margin: 0; }

/* Narrow screens: smaller name; the legend scrolls sideways in one row; the panel is a sheet. */
@media (max-width: 760px) {
  :root { --gap: 0.75rem; }
  .portrait { width: 44px; height: 44px; }
  h1 { font-size: 1.45rem; }
  .orgs { font-size: 0.78rem; }
  .ident { max-width: calc(100% - 2 * var(--gap)); gap: 0.65rem; }
  .hint { display: none; }
  .controls { left: var(--gap); bottom: auto; top: calc(var(--gap) + 3.6rem); }
  .legend {
    left: 0; right: 0; bottom: 0; max-width: none;
    flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
    padding: 0 var(--gap) var(--gap);
    scrollbar-width: none;
  }
  .legend::-webkit-scrollbar { display: none; }
  .legend button { flex: none; }
  .panel { top: auto; left: var(--gap); right: var(--gap); bottom: calc(var(--gap) + 2.5rem); width: auto; max-height: 48%; }
  .search { top: calc(var(--gap) + 6.1rem); left: var(--gap); right: var(--gap); flex-direction: row; }
  .search input { width: 100%; flex: 1; }
  .source { bottom: calc(var(--gap) + 2.4rem); }
  /* List mode on a phone: one column at a time, drilled into, with a back link to the last. */
  .columns { top: calc(var(--gap) + 8.9rem); bottom: calc(var(--gap) + 2.6rem); }
  .col { width: 100%; }
  .col:not(:last-child) { display: none; }
  .col-back { display: block; }
  .pond.is-list .source { display: none; }
}

/* Intro: the mode pill starts centered in the viewport (fixed, out of the controls row) and pulsing ("Explore my graph"); pond.js docks it
   into its corner on the first click. Last in the file so it overrides the narrow layout. */
.pond .mode.intro {
  position: fixed; left: 50%; top: 50%; right: auto; bottom: auto;
  translate: -50% -50%;
  height: auto; padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-color: var(--accent);
  z-index: 2;
}
.mode.intro::after {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  border: 2px solid var(--accent);
  pointer-events: none;
  animation: pill-pulse 2.2s ease-out infinite;
}
@keyframes pill-pulse {
  0% { transform: scale(1); opacity: 0.7; }
  80%, 100% { transform: scale(1.35, 1.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mode.intro::after { animation: none; opacity: 0; }
}
