/* Descent of Tongues — the page IS the poster. Chrome stays at the family's
   weight: one link row, one control bar, one dialog; the title lives inside
   the SVG so the exported image is self-contained. Shares the Descent of
   Letters stylesheet almost exactly, so the two posters read as a pair. */

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, sans-serif;
}

.sites {
  position: fixed; top: 16px; right: 18px; z-index: 100;
  display: flex; gap: 14px;
  font-size: 10px; letter-spacing: 0.5px;
  padding: 6px 10px; border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(6px);
}
.sites a { color: var(--ink-muted); text-decoration: none; transition: color 0.15s; }
.sites a:hover { color: var(--ink-bright); }

.sheet {
  width: min(1760px, 100vw);
  margin: 0 auto;
  padding: 8px 12px 132px;
}
#poster { display: block; width: 100%; height: auto; }

.tip {
  position: fixed; background: var(--surface); border: 1px solid var(--border);
  border-radius: 5px; padding: 10px 13px; max-width: 320px;
  pointer-events: none; opacity: 0; transition: opacity 0.1s;
  z-index: 1000; backdrop-filter: blur(10px); color: var(--ink);
  font-size: 12px; line-height: 1.5;
}
.tip.show { opacity: 1; }
.tip strong { display: block; color: var(--ink-bright); font-size: 14px; font-weight: 600; }
.tip .src { display: block; margin-top: 4px; color: var(--ink-muted); font-size: 10px; }

.ctrl {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 6px; z-index: 100;
  max-width: calc(100vw - 16px);
}
.ctrl button, .ctrl select {
  background: var(--btn-bg); border: 1px solid var(--btn-border);
  color: var(--ink); padding: 6px 12px; border-radius: 4px;
  font-size: 13px; cursor: pointer; backdrop-filter: blur(6px);
  transition: all 0.15s; letter-spacing: 0.3px; min-width: 0;
}
.ctrl button:hover, .ctrl select:hover {
  background: var(--surface); color: var(--ink-bright); border-color: var(--border);
}
.ctrl button[disabled] { opacity: 0.5; cursor: wait; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 6px; flex-shrink: 0; color: var(--ink);
  background: none; border: none; cursor: pointer;
}
.icon-btn:hover { color: var(--ink-bright); background: none; border: none; }
.icon-btn svg { display: block; }
/* The branch legend used to float bottom-left. The poster prints its own
   branch names, in their own colours, directly above the proto-branch row, so
   the floating copy was a second answer to a question already answered - and
   it sat on top of the footer. */
.branches { display: none; }

.sep { width: 1px; background: var(--btn-border); margin: 0 3px; align-self: stretch; }

#loading {
  position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; flex-direction: column;
  background: var(--bg); z-index: 2000; transition: opacity 0.4s;
}
#loading.hide { opacity: 0; pointer-events: none; visibility: hidden; }
.spinner {
  width: 28px; height: 28px; border: 2px solid var(--btn-border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300; font-size: 28px; letter-spacing: 4px; color: var(--ink-bright);
}
#loading p { font-size: 13px; color: var(--ink-muted); margin-top: 5px; }

dialog {
  max-width: 480px; width: calc(100vw - 32px); padding: 20px 22px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  backdrop-filter: blur(18px);
  margin: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-head h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500; font-size: 24px; color: var(--ink-bright);
}
dialog p { margin: 10px 0; font-size: 12px; line-height: 1.6; }
dialog .key { color: var(--ink-muted); }
dialog .fine { color: var(--ink-muted); font-size: 11px; }
dialog ul { margin: 8px 0 8px 18px; font-size: 12px; line-height: 1.6; }
dialog strong { color: var(--ink-bright); }

/* SVG interaction states, applied via class on column groups */
#poster .col { transition: opacity 0.25s; }
#poster.focused .col { opacity: 0.13; }
#poster.focused .col.is-focus { opacity: 1; }
#poster .hit { cursor: pointer; }

/* A hint that only exists when the sheet is wider than the screen. */
.swipe {
  display: none;
  text-align: center; color: var(--ink-muted);
  font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase;
  padding: 6px 0 2px;
}

@media (max-width: 900px) {
  .sites { display: none; }
  .branches { display: none; }
  /* Five controls do not fit across a phone; let them wrap rather than
     clipping the last two off the edge. */
  .ctrl {
    flex-wrap: wrap; justify-content: center;
    width: calc(100vw - 16px); bottom: 10px; gap: 5px;
  }
  .ctrl .sep { display: none; }
  .ctrl button, .ctrl select {
    padding: 9px 10px; font-size: 13px; min-height: 44px;
    flex: 0 1 auto; max-width: 46vw;
    text-overflow: ellipsis; white-space: nowrap;
  }

  /* Squeezing a 2,500-pixel sheet into a 390-pixel phone puts the type at
     four pixels, which is not a small chart but no chart at all. Hold the
     poster at a height the type survives and let the sheet scroll sideways
     instead - the same thing you would do with a paper one. */
  .sheet {
    width: 100vw; max-width: none;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding: 0 0 104px;
  }
  #poster { width: auto; height: min(74vh, 900px); max-width: none; }
  .swipe { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  #loading, #poster .col { transition: none; }
}

/* Cross-links live in the help dialog, not over the drawing. */
.sees { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 14px; }
.sees a { color: var(--accent); text-decoration: none; }
.sees a:hover { text-decoration: underline; }
